/* KCK Invitations. Mobile first. Colours come from the preset as --ki-* on .kinv. */

.kinv {
	--ki-shadow: 0 1px 2px rgba(30, 26, 34, .06), 0 8px 24px rgba(30, 26, 34, .08);
	font-family: var(--ki-font);
	color: var(--ki-ink);
	-webkit-tap-highlight-color: transparent;
}
.kinv *, .kinv *::before, .kinv *::after { box-sizing: border-box; }

.kinv-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.kinv-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.kinv-muted { color: var(--ki-muted); font-size: 15px; line-height: 1.5; margin: 0; }
.kinv-small { color: var(--ki-muted); font-size: 13px; line-height: 1.5; margin: 0; }
.kinv-small a { color: inherit; text-decoration: underline; }
.kinv-center { text-align: center; }

/* ---------------------------------------------------------------- buttons */

.kinv-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 0 22px; border: 0; border-radius: 999px;
	font: inherit; font-size: 16px; font-weight: 600; line-height: 1.2; text-decoration: none; text-align: center;
	cursor: pointer; transition: background-color .15s, transform .1s, opacity .15s;
}
.kinv-btn:active { transform: scale(.98); }
.kinv-btn:disabled { opacity: .55; cursor: default; }
.kinv-btn:focus-visible, .kinv-chip:focus-visible, .kinv-bar-btn:focus-visible, .kinv-x:focus-visible, .kinv-card-link:focus-visible {
	outline: 3px solid var(--ki-accent); outline-offset: 2px;
}
.kinv-btn-primary { background: var(--ki-accent); color: #fff; }
.kinv-btn-primary:hover { background: var(--ki-accent-dark); color: #fff; }
.kinv-btn-soft { background: var(--ki-sand); color: var(--ki-ink); }
.kinv-btn-soft:hover { background: var(--ki-line); }
.kinv-btn-block { display: flex; width: 100%; }
.kinv-btn-sm { min-height: 40px; padding: 0 16px; font-size: 15px; }
.kinv-btn.is-busy { opacity: .6; pointer-events: none; }

/* ---------------------------------------------------------------- a design, drawn small or large */

.kinv-host { position: relative; display: block; width: 100%; overflow: hidden; opacity: 0; transition: opacity .2s; }
.kinv-host.is-scaled { opacity: 1; }

/* ---------------------------------------------------------------- gallery */

.kinv-gallery {
	/* Wider than the page's reading column. */
	width: min(1180px, calc(100vw - 2rem));
	margin: 1.5rem 0 2.5rem calc(50% - (min(1180px, 100vw - 2rem) / 2));
}
.kinv-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 0 8px; scrollbar-width: none; }
.kinv-chips::-webkit-scrollbar { display: none; }
.kinv-chip {
	flex: none; min-height: 44px; padding: 0 18px; border: 1px solid var(--ki-line); border-radius: 999px;
	background: var(--ki-surface); color: var(--ki-ink); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.kinv-chip[aria-pressed="true"] { background: var(--ki-ink); border-color: var(--ki-ink); color: #fff; }

.kinv-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 640px) { .kinv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1024px) { .kinv-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; } }
.kinv-grid > li { margin: 0; padding: 0; }
.kinv-grid > li::before, .kinv-grid > li::marker { content: none; }
.kinv-card[hidden] { display: none; }

.kinv-card-link {
	display: flex; flex-direction: column; height: 100%; border-radius: var(--ki-radius); overflow: hidden;
	background: var(--ki-surface); box-shadow: var(--ki-shadow); color: inherit; text-decoration: none !important;
	transition: transform .15s, box-shadow .15s;
}
.kinv-card-link:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(30, 26, 34, .06), 0 14px 32px rgba(30, 26, 34, .12); }
.kinv-card-art { display: flex; align-items: center; justify-content: center; aspect-ratio: 5 / 6; padding: 10px; background: var(--ki-sand); }
.kinv-card-art .kinv-host, .kinv-card-thumb { width: auto; height: 100%; border-radius: 6px; box-shadow: 0 6px 16px rgba(30, 26, 34, .18); }
.kinv-card-art .kinv-host.is-wide { width: 100%; height: auto; }
.kinv-card-thumb { display: block; max-width: 100%; object-fit: contain; }
.kinv-card-body { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 4px; }
.kinv-card-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.kinv-card-cta { padding: 0 14px 14px; color: var(--ki-accent); font-size: 14px; font-weight: 600; }
.kinv-badge { flex: none; padding: 3px 9px; border-radius: 999px; background: var(--ki-accent-soft); color: var(--ki-accent-dark); font-size: 12px; font-weight: 700; }
.kinv-badge.is-premium { background: #fff1c7; color: #7a5b00; }
.kinv-none { color: var(--ki-muted); }
.kinv-empty { padding: 24px; border-radius: var(--ki-radius); background: var(--ki-sand); }

/* ---------------------------------------------------------------- editor page */

.kinv-app { max-width: 1180px; margin: 0 auto; padding: 8px 16px 112px; }
.kinv-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.kinv-back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--ki-ink-soft); font-weight: 600; font-size: 15px; text-decoration: none; }
.kinv-back:hover { color: var(--ki-ink); }
.kinv-status { color: var(--ki-muted); font-size: 14px; }

.kinv-layout { display: flex; flex-direction: column; gap: 4px; }
.kinv-side { order: -1; }
.kinv-eyebrow { margin: 0; color: var(--ki-accent-dark); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.kinv-h1 { margin: 2px 0 0; font-family: var(--ki-font-display); font-size: 26px; line-height: 1.15; font-weight: 600; }
.kinv-lede, .kinv-details, .kinv-side-actions { display: none; }
.kinv-hint { margin: 4px 0 10px; color: var(--ki-muted); font-size: 15px; }
.kinv-stage { display: flex; justify-content: center; }
.kinv-stage .kinv-host { border-radius: 4px; box-shadow: 0 2px 6px rgba(30, 26, 34, .08), 0 18px 40px rgba(30, 26, 34, .16); }

@media (min-width: 900px) {
	.kinv-app { padding-bottom: 48px; }
	.kinv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; align-items: start; }
	.kinv-side { order: 0; position: sticky; top: 96px; padding: 24px; border-radius: var(--ki-radius); background: var(--ki-surface); box-shadow: var(--ki-shadow); }
	.kinv-h1 { font-size: 32px; }
	.kinv-lede { display: block; margin: 8px 0 16px; color: var(--ki-ink-soft); font-size: 15px; line-height: 1.5; }
	.kinv-details { display: block; max-height: calc(100vh - 380px); overflow: auto; margin: 0 -8px; padding: 0 8px; }
	.kinv-side-actions { display: flex; gap: 10px; margin-top: 18px; }
	.kinv-side-actions .kinv-btn { flex: 1; padding: 0 14px; white-space: nowrap; }
	.kinv-side-actions .kinv-btn-soft { flex: 0 1 auto; }
	.kinv-stage-wrap { padding-top: 8px; }
	.kinv-hint { text-align: center; }
}

/* The bar at the bottom of a phone screen. */
.kinv-bar {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
	display: flex; align-items: center; gap: 6px;
	padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
	background: rgba(255, 255, 255, .97); border-top: 1px solid var(--ki-line);
	box-shadow: 0 -6px 20px rgba(30, 26, 34, .06);
}
.kinv-bar-btn {
	display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
	min-width: 64px; min-height: 52px; padding: 0 6px; border: 0; border-radius: 14px; background: transparent;
	color: var(--ki-ink-soft); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.kinv-bar-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kinv-bar-get { flex: 1; min-height: 52px; }
@media (min-width: 900px) { .kinv-bar { display: none; } }

/* ---------------------------------------------------------------- dialogs and sheets */

/* Centred here, not left to the browser: a theme's CSS reset (margin: 0 on everything) would pin it top left. */
.kinv-dialog {
	position: fixed; inset: 0; margin: auto; height: fit-content;
	width: 100%; max-width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
	padding: 0; border: 0; border-radius: var(--ki-radius);
	background: var(--ki-surface); color: var(--ki-ink); box-shadow: 0 24px 60px rgba(20, 16, 24, .3);
	font-family: var(--ki-font); overflow: hidden;
}
.kinv-dialog[open] { display: flex; flex-direction: column; }
.kinv-dialog::backdrop { background: rgba(20, 16, 24, .55); }
.kinv-dialog *, .kinv-dialog *::before, .kinv-dialog *::after { box-sizing: border-box; }

@media (max-width: 639px) {
	.kinv-sheet {
		max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0;
		max-height: calc(100dvh - 48px - var(--kinv-kb, 0px));
		margin-bottom: var(--kinv-kb, 0px);
		animation: kinv-up .22s ease-out;
	}
}
@keyframes kinv-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .kinv-sheet { animation: none; } .kinv-host { transition: none; } }

.kinv-sheet-head, .kinv-full-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 6px 20px; }
.kinv-sheet-title { flex: 1; margin: 0; font-family: var(--ki-font); font-size: 18px; font-weight: 700; line-height: 1.3; }
.kinv-x {
	display: inline-flex; align-items: center; justify-content: center; flex: none;
	width: 44px; height: 44px; border: 0; border-radius: 999px; background: var(--ki-sand); color: var(--ki-ink); cursor: pointer;
}
.kinv-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.kinv-sheet-body { display: flex; flex-direction: column; gap: 14px; padding: 8px 20px 20px; overflow: auto; overscroll-behavior: contain; }
.kinv-sheet-body[hidden] { display: none; }
/* One field in its own sheet: the sheet's title already names it. */
[data-kinv-sheet-body] > .kinv-field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kinv-sheet-foot { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ki-line); }
@media (max-width: 639px) { .kinv-sheet-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)); } }

/* ---------------------------------------------------------------- form fields */

.kinv-form { display: flex; flex-direction: column; gap: 14px; }
.kinv-field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.kinv-field label { font-size: 14px; font-weight: 700; color: var(--ki-ink-soft); }
.kinv-field input[type="text"], .kinv-field input[type="email"], .kinv-field textarea {
	width: 100%; min-height: 48px; padding: 11px 14px; border: 1.5px solid var(--ki-line); border-radius: 12px;
	background: #fff; color: var(--ki-ink); font: inherit; font-size: 16px; line-height: 1.4; /* 16px: no zoom on iPhone */
}
.kinv-field textarea { resize: vertical; min-height: 76px; }
.kinv-field input:focus, .kinv-field textarea:focus { outline: none; border-color: var(--ki-accent); box-shadow: 0 0 0 3px var(--ki-accent-soft); }
.kinv-field [aria-invalid="true"] { border-color: #b3231f; }
.kinv-count { align-self: flex-end; color: var(--ki-muted); font-size: 12px; }
.kinv-count.is-low { color: #b3231f; font-weight: 700; }
.kinv-check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.45; cursor: pointer; }
.kinv-check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--ki-accent); }
.kinv-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fdecea; color: #8e1c19; font-size: 15px; }
.kinv-error[hidden] { display: none; }

.kinv-datepick { margin-top: 2px; }
.kinv-datepick summary { display: inline-flex; align-items: center; min-height: 36px; color: var(--ki-accent-dark); font-size: 14px; font-weight: 600; cursor: pointer; }
.kinv-daterow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.kinv-daterow input { min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--ki-line); border-radius: 10px; font: inherit; font-size: 16px; background: #fff; color: var(--ki-ink); }
.kinv-daterow input[type="date"] { flex: 1 1 150px; }
.kinv-daterow input[type="time"] { flex: 0 1 120px; }

.kinv-photo-row { flex-direction: row; align-items: center; gap: 12px; }
.kinv-thumb { width: 56px; height: 56px; flex: none; border-radius: 12px; object-fit: cover; background: var(--ki-sand); }
.kinv-photo-label { flex: 1; font-size: 14px; font-weight: 700; color: var(--ki-ink-soft); }

/* The photo sheet: drag to move, pinch or slide to zoom. */
.kinv-photo-frame {
	position: relative; overflow: hidden; align-self: center; max-width: 100%;
	border-radius: 14px; background: repeating-conic-gradient(#f1ece6 0 25%, #fff 0 50%) 0 0 / 20px 20px;
	box-shadow: inset 0 0 0 1px var(--ki-line); touch-action: none; user-select: none;
}
.kinv-photo-frame.is-pannable { cursor: grab; }
.kinv-photo-frame.is-pannable:active { cursor: grabbing; }
.kinv-photo-frame:focus-visible { outline: 3px solid var(--ki-accent); outline-offset: 2px; }
.kinv-photo-frame > img {
	position: absolute; left: 0; top: 0; width: 100%; height: 100%; max-width: none; display: block; pointer-events: none;
	object-fit: cover; object-position: var(--x, 50%) var(--y, 50%);
	transform: scale(var(--s, 1)); transform-origin: var(--x, 50%) var(--y, 50%);
}
.kinv-zoom { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 700; color: var(--ki-ink-soft); }
.kinv-zoom[hidden] { display: none; }
.kinv-zoom input { flex: 1; min-height: 44px; accent-color: var(--ki-accent); }
.kinv-row { display: flex; gap: 10px; }
.kinv-row .kinv-btn { flex: 1; }
.kinv-row .kinv-btn[hidden] { display: none; }

/* ---------------------------------------------------------------- preview */

.kinv-full { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; background: #1d1922; color: #fff; }
.kinv-full .kinv-sheet-title { color: #fff; }
.kinv-full .kinv-x { background: rgba(255, 255, 255, .14); color: #fff; }
.kinv-full-head { padding: calc(10px + env(safe-area-inset-top)) 12px 10px 20px; }
.kinv-full-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; }
.kinv-full-foot { display: flex; gap: 10px; justify-content: center; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
.kinv-full-foot .kinv-btn { flex: 1; max-width: 260px; }
.kinv-full-foot .kinv-btn-soft { background: rgba(255, 255, 255, .14); color: #fff; }
.kinv-preview-card { border-radius: 4px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.kinv-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.kinv-seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.kinv-seg button[aria-pressed="true"] { background: #fff; color: #1d1922; }
@media (max-width: 420px) { .kinv-full-head .kinv-sheet-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }

.kinv-chat {
	width: min(380px, 100%); height: 100%; max-height: 720px; display: flex; flex-direction: column; justify-content: flex-end;
	padding: 18px 14px; border-radius: 28px; background: #e9e1d6 radial-gradient(rgba(0, 0, 0, .04) 1px, transparent 1px) 0 0 / 14px 14px;
}
.kinv-bubble { align-self: flex-end; max-width: 92%; padding: 4px; border-radius: 12px 12px 2px 12px; background: #d9fdd3; box-shadow: 0 1px 1px rgba(0, 0, 0, .12); }
.kinv-chat-card { border-radius: 9px; }
.kinv-bubble-text { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 6px 2px; color: #111b21; font-size: 15px; }
.kinv-bubble-time { color: #667781; font-size: 11px; }

/* ---------------------------------------------------------------- your invitation is ready */

.kinv-done-art { display: flex; align-items: center; justify-content: center; min-height: 220px; padding: 6px; border-radius: 14px; background: var(--ki-sand); }
.kinv-done-art img { display: block; max-width: 100%; max-height: 42dvh; border-radius: 4px; box-shadow: 0 10px 28px rgba(30, 26, 34, .22); }
.kinv-done-note { margin: 0; color: var(--ki-ink-soft); font-size: 15px; line-height: 1.5; text-align: center; }
.kinv-done-actions { display: flex; flex-direction: column; gap: 10px; }
.kinv-done-actions .kinv-btn[hidden] { display: none; }
.kinv-spinner { width: 34px; height: 34px; border: 3px solid var(--ki-line); border-top-color: var(--ki-accent); border-radius: 50%; animation: kinv-spin .8s linear infinite; }
@keyframes kinv-spin { to { transform: rotate(360deg); } }

.kinv-toast {
	position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 2147483000; transform: translateX(-50%);
	max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px; background: #1e1a22; color: #fff;
	font-size: 15px; line-height: 1.4; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.kinv-toast[hidden] { display: none; }
@media (min-width: 900px) { .kinv-toast { bottom: 32px; } }

/* ---------------------------------------------------------------- messages */

.kinv-message { max-width: 560px; margin: 32px auto 56px; padding: 0 16px; }
.kinv-message p { line-height: 1.6; color: var(--ki-ink-soft); }
.kinv-resend { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; padding: 20px; border-radius: var(--ki-radius); background: var(--ki-surface); box-shadow: var(--ki-shadow); }
.kinv-noscript { padding: 16px; border-radius: 12px; background: #fdecea; color: #8e1c19; }
