/*
 * AI Trainer worker app. Mobile-first; iPhone Safari is the primary target.
 *
 * iPhone notes:
 * - viewport-fit=cover + env(safe-area-inset-*) keep UI clear of the notch / Dynamic Island / home indicator.
 * - The document itself scrolls (not an inner div) so Safari's toolbar collapses normally and
 *   tapping the status bar scrolls to top.
 * - Heights use dvh with a vh fallback; never plain 100vh for layout.
 * - Form controls are 16px so Safari does not zoom on focus; pinch-zoom stays enabled.
 */

:root {
	--bg: #f6f7f9;
	--surface: #ffffff;
	--surface-2: #f0f2f5;
	--text: #14171c;
	--muted: #5b6472;
	--border: #e3e6eb;
	--accent: #3b5bdb;
	--accent-ink: #ffffff;
	--accent-soft: #e8edff;
	--success: #1f8a4c;
	--success-soft: #e3f5ea;
	--warning: #a35f00;
	--warning-soft: #fff1db;
	--danger: #c92a2a;
	--danger-soft: #ffe3e3;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
	--shadow-lg: 0 8px 32px rgba(16, 24, 40, .18);
	--radius: 14px;
	--radius-sm: 10px;
	--topbar-h: 52px;
	--tabbar-h: 56px;
	--gutter: 16px;
	--safe-top: env(safe-area-inset-top, 0px);
	--safe-right: env(safe-area-inset-right, 0px);
	--safe-bottom: env(safe-area-inset-bottom, 0px);
	--safe-left: env(safe-area-inset-left, 0px);
	--kb-offset: 0px;
	--font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #111317;
		--surface: #1a1d23;
		--surface-2: #23272f;
		--text: #eef0f3;
		--muted: #a1a9b6;
		--border: #2d323b;
		--accent: #7c94ff;
		--accent-ink: #0d1020;
		--accent-soft: #232b4d;
		--success: #5fd38d;
		--success-soft: #183626;
		--warning: #f5b453;
		--warning-soft: #3a2a12;
		--danger: #ff8787;
		--danger-soft: #3d1c1c;
		--shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
		--shadow-lg: 0 8px 32px rgba(0, 0, 0, .55);
	}
}

*, *::before, *::after { box-sizing: border-box; }

/* Component display rules must never override the hidden attribute. */
[hidden] { display: none !important; }

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	-webkit-tap-highlight-color: transparent;
}

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 1rem;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

/* Scroll lock while a sheet is open, without iOS's jump-to-top (JS stores the offset in --lock-top). */
body.is-locked {
	position: fixed;
	top: var(--lock-top, 0);
	left: 0;
	right: 0;
	overflow: hidden;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }

:focus-visible {
	outline: 3px solid var(--accent);
	outline-offset: 2px;
	border-radius: 6px;
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	background: var(--surface);
	padding: 12px 16px;
}
.skip-link:focus { left: calc(8px + var(--safe-left)); top: calc(8px + var(--safe-top)); }

/* ---------- Frame ---------- */

.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: calc(var(--topbar-h) + var(--safe-top));
	padding: var(--safe-top) calc(var(--gutter) + var(--safe-right)) 0 calc(var(--gutter) + var(--safe-left));
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	-webkit-backdrop-filter: saturate(180%) blur(16px);
	backdrop-filter: saturate(180%) blur(16px);
	border-bottom: 1px solid var(--border);
}

.topbar__title {
	font-size: 1.0625rem;
	font-weight: 650;
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.topbar__title:focus { outline: none; }

.main {
	padding: 16px calc(var(--gutter) + var(--safe-right)) calc(var(--tabbar-h) + var(--safe-bottom) + 96px) calc(var(--gutter) + var(--safe-left));
	max-width: 760px;
	margin: 0 auto;
}
.main:focus { outline: none; }

.view > * + * { margin-top: 12px; }

.tabbar {
	position: fixed;
	z-index: 30;
	left: 0;
	right: 0;
	bottom: 0;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
	background: color-mix(in srgb, var(--surface) 92%, transparent);
	-webkit-backdrop-filter: saturate(180%) blur(16px);
	backdrop-filter: saturate(180%) blur(16px);
	border-top: 1px solid var(--border);
}

.tab {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-height: var(--tabbar-h);
	color: var(--muted);
	text-decoration: none;
	touch-action: manipulation;
}
.tab__label { font-size: .6875rem; font-weight: 600; letter-spacing: .01em; }
.tab[aria-current="page"] { color: var(--accent); }

.rail { display: none; }

.fab {
	position: fixed;
	z-index: 31;
	right: calc(16px + var(--safe-right));
	bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 48px;
	padding: 0 18px;
	border: 0;
	border-radius: 999px;
	background: var(--accent);
	color: var(--accent-ink);
	font: 600 .9375rem/1 var(--font);
	box-shadow: var(--shadow-lg);
	cursor: pointer;
	touch-action: manipulation;
}
.fab:active { transform: scale(.97); }
.fab[data-badge]::after {
	content: "";
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--danger);
	border: 2px solid var(--accent);
	margin-left: -2px;
}

@media (min-width: 900px) {
	.app { padding-left: 248px; }
	.rail {
		position: fixed;
		inset: 0 auto 0 0;
		width: 248px;
		display: flex;
		flex-direction: column;
		gap: 4px;
		padding: calc(20px + var(--safe-top)) 12px 20px calc(12px + var(--safe-left));
		background: var(--surface);
		border-right: 1px solid var(--border);
	}
	.rail__brand { font-weight: 700; font-size: 1.0625rem; padding: 4px 12px 16px; }
	.nav-item {
		display: flex;
		align-items: center;
		gap: 12px;
		min-height: 44px;
		padding: 0 12px;
		border: 0;
		border-radius: var(--radius-sm);
		background: none;
		color: var(--text);
		font: 500 .9375rem var(--font);
		text-decoration: none;
		text-align: left;
		cursor: pointer;
	}
	.nav-item:hover { background: var(--surface-2); }
	.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
	.tabbar { display: none; }
	.fab { bottom: calc(24px + var(--safe-bottom)); right: calc(24px + var(--safe-right)); }
	.main { padding-bottom: 120px; padding-top: 24px; }
}

/* ---------- Components ---------- */

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 16px;
	box-shadow: var(--shadow);
}
.card--center { text-align: center; max-width: 420px; margin: 0 auto; }

.card__eyebrow { color: var(--muted); font-size: .8125rem; font-weight: 600; margin-bottom: 4px; }

.card__note { margin: 14px 0 0; color: var(--muted); font-size: .8125rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value { font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__label { color: var(--muted); font-size: .8125rem; }

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 18px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	color: var(--text);
	font: 600 1rem var(--font);
	text-decoration: none;
	cursor: pointer;
	touch-action: manipulation;
	user-select: none;
	-webkit-user-select: none;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--text);
	cursor: pointer;
	touch-action: manipulation;
}

.avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 700;
}

.badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: .75rem;
	font-weight: 650;
	background: var(--surface-2);
	color: var(--muted);
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }

input, select, textarea {
	width: 100%;
	min-height: 44px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--text);
	font: 400 16px/1.4 var(--font); /* 16px: prevents iOS focus zoom. */
}
textarea { resize: vertical; }

.empty {
	text-align: center;
	padding: 32px 16px;
	color: var(--muted);
}
.empty__icon { font-size: 2rem; margin-bottom: 8px; }
.empty__title { color: var(--text); font-weight: 650; margin-bottom: 4px; }

.notice {
	padding: 12px 14px;
	border-radius: var(--radius-sm);
	background: var(--warning-soft);
	color: var(--warning);
}
.notice--error { background: var(--danger-soft); color: var(--danger); }

.skeleton {
	border-radius: var(--radius);
	background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface) 50%, var(--surface-2) 100%);
	background-size: 200% 100%;
	animation: ait-shimmer 1.4s ease-in-out infinite;
}
.skeleton--card { height: 96px; }
.skeleton--line { height: 14px; border-radius: 6px; }
@keyframes ait-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Sheet (bottom sheet on phones, side drawer on desktop) ---------- */

.sheet-backdrop {
	position: fixed;
	inset: 0;
	z-index: 50;
	background: rgba(0, 0, 0, .35);
	opacity: 0;
	transition: opacity .2s ease;
}
.sheet-backdrop.is-open { opacity: 1; }

.sheet {
	position: fixed;
	z-index: 51;
	left: 0;
	right: 0;
	bottom: var(--kb-offset);
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - var(--safe-top) - 12px);
	max-height: calc(100dvh - var(--safe-top) - 12px - var(--kb-offset));
	padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
	background: var(--surface);
	border-radius: 20px 20px 0 0;
	box-shadow: var(--shadow-lg);
	transform: translateY(100%);
	transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet.is-open { transform: translateY(0); }
.sheet.is-keyboard { padding-bottom: 0; }

.sheet__grabber {
	width: 36px;
	height: 5px;
	margin: 8px auto 0;
	border-radius: 3px;
	background: var(--border);
}

.sheet__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 8px 8px 20px;
	border-bottom: 1px solid var(--border);
}
.sheet__title { margin: 0; font-size: 1.0625rem; }

.sheet__body {
	flex: 1 1 auto;
	min-height: 160px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 16px 20px;
}

.sheet__footer {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--border);
	background: var(--surface);
}

@media (min-width: 900px) {
	.sheet {
		left: auto;
		top: 0;
		bottom: 0;
		width: 420px;
		max-height: none;
		border-radius: 0;
		transform: translateX(100%);
		padding-top: var(--safe-top);
	}
	.sheet.is-open { transform: translateX(0); }
	.sheet__grabber { display: none; }
}

/* ---------- Toasts ---------- */

.toasts {
	position: fixed;
	z-index: 60;
	left: calc(16px + var(--safe-left));
	right: calc(16px + var(--safe-right));
	bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 76px);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	pointer-events: none;
}
.toast {
	max-width: 420px;
	padding: 12px 16px;
	border-radius: 12px;
	background: var(--text);
	color: var(--bg);
	font-weight: 550;
	box-shadow: var(--shadow-lg);
	pointer-events: auto;
}
.toast--error { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toasts { bottom: 96px; } }

.standalone {
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	align-items: center;
	padding: calc(24px + var(--safe-top)) calc(16px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.standalone .card { width: 100%; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}
}

/* ---------- Signed-out screens ---------- */

.auth {
	min-height: 100vh;
	min-height: 100dvh;
	max-width: 420px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 20px;
	padding: calc(24px + var(--safe-top)) calc(16px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth__brand img { border-radius: 14px; box-shadow: var(--shadow); }
.auth__site { font-weight: 700; font-size: 1.125rem; }
.auth__card { padding: 20px; }
.auth__form { display: flex; flex-direction: column; gap: 14px; }
.auth__title { font-size: 1.375rem; margin: 0; }
.auth__title:focus { outline: none; }
.auth__intro { color: var(--muted); margin: 0; }
.auth__links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth__links a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 550; text-decoration: none; }
.auth__done {
	width: 48px; height: 48px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: var(--success-soft); color: var(--success); font-size: 1.5rem; font-weight: 700;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-weight: 600; font-size: .9375rem; }
.field__hint { color: var(--muted); font-size: .8125rem; }
.field__error { color: var(--danger); font-size: .875rem; font-weight: 550; }
.field__error:empty { display: none; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--danger); }
.field__row { position: relative; display: flex; }
.field__row input { padding-right: 72px; }
.field__toggle {
	position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
	min-width: 60px; min-height: 40px; border: 0; background: none;
	color: var(--accent); font: 600 .875rem var(--font); cursor: pointer;
}
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--accent); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Topbar actions, lists, profile ---------- */

.topbar__actions { display: flex; align-items: center; gap: 4px; }
.bell { position: relative; }
.bell__count {
	position: absolute; top: 6px; right: 4px;
	min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
	background: var(--danger); color: #fff; font-size: .6875rem; font-weight: 700; line-height: 18px; text-align: center;
}
.bell__count:empty, .bell__count[data-count="0"] { display: none; }

.profile { display: flex; gap: 14px; align-items: center; }
.avatar--lg { width: 56px; height: 56px; font-size: 1.25rem; flex: 0 0 auto; }
.profile__name { font-size: 1.125rem; font-weight: 700; margin: 0; }
.profile__meta { color: var(--muted); font-size: .875rem; margin: 2px 0 0; overflow-wrap: anywhere; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 14px 0 0; }
.kv dt { color: var(--muted); font-size: .875rem; }
.kv dd { margin: 0; text-align: right; font-weight: 550; overflow-wrap: anywhere; }

.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card__head h2 { margin: 0; }
.card__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.list__item:first-child { border-top: 0; }
.list__main { flex: 1 1 auto; min-width: 0; }
.list__title { font-weight: 650; margin: 0; }
.list__text { color: var(--muted); margin: 2px 0 0; font-size: .9375rem; overflow-wrap: anywhere; }
.list__time { color: var(--muted); font-size: .75rem; margin-top: 4px; }
.list__item--unread .list__title::before {
	content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
	background: var(--accent); margin-right: 8px; vertical-align: middle;
}
.sheet__body form { display: flex; flex-direction: column; gap: 14px; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Characters ---------- */

.section-title { font-size: 1.0625rem; margin: 20px 0 10px; }
.stepper { color: var(--muted); font-size: .8125rem; font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.cards { display: grid; gap: 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-stack { display: flex; flex-direction: column; gap: 14px; }

.char-card { display: flex; gap: 14px; align-items: flex-start; color: inherit; text-decoration: none; touch-action: manipulation; }
.char-card:active { transform: scale(.99); }
.char-card__img { width: 72px; height: 72px; flex: 0 0 72px; border-radius: 12px; object-fit: cover; background: var(--surface-2); }
.char-card__img--empty { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.5rem; color: var(--muted); }
.char-card__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.char-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.char-card__name { margin: 0; font-size: 1.0625rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-card__desc { margin: 0; color: var(--muted); font-size: .875rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.progress { display: flex; align-items: center; gap: 10px; }
.progress__track { flex: 1 1 auto; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress__fill { height: 100%; background: var(--accent); border-radius: 4px; }
.progress__pct { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }

.char-hero { padding: 0; overflow: hidden; }
.char-hero__img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-2); }
.char-hero__img--empty { display: flex; align-items: center; justify-content: center; font-size: 3rem; font-weight: 700; color: var(--muted); }
.char-hero__body { padding: 16px; }
.char-hero__name { margin: 0; font-size: 1.375rem; }
@media (min-width: 640px) { .char-hero { display: grid; grid-template-columns: 240px 1fr; } .char-hero__img { height: 100%; aspect-ratio: auto; } }

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.action {
	display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px;
	min-height: 88px; padding: 14px; border: 1px solid var(--border); border-radius: 12px;
	background: var(--surface-2); color: var(--text); font: 600 .9375rem var(--font); text-align: left; text-decoration: none; cursor: pointer;
	touch-action: manipulation;
}
.action:active { transform: scale(.98); }
.action__icon { font-size: 1.375rem; }
.tool-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.tool-row .action { min-height: 76px; padding: 10px; gap: 6px; font-size: .875rem; line-height: 1.2; }
.tool-row .action .soon { font-size: .6875rem; }

.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .tpl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tpl {
	display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; cursor: pointer;
	border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
	box-shadow: var(--shadow); font: inherit; touch-action: manipulation;
}
.tpl:active { transform: scale(.98); }
.tpl__img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.tpl__img--empty { display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--muted); }
.tpl__body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; }
.tpl__name { font-weight: 650; }
.tpl__meta { color: var(--muted); font-size: .8125rem; }
.tpl--disabled { opacity: .62; }
.tpl--disabled .tpl__img { filter: grayscale(1); }
.tpl--scratch .tpl__img { background: var(--accent-soft); color: var(--accent); }
.tpl .badge { align-self: flex-start; white-space: normal; }

/* ---------- Character information ---------- */

.back-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }
.info-cat { padding: 0; }
.info-cat__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 16px; cursor: pointer; list-style: none; }
.info-cat__head::-webkit-details-marker { display: none; }
.info-cat__head::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-left: 4px; transition: transform .15s; }
.info-cat[open] > .info-cat__head::after { transform: rotate(-135deg); }
.info-cat__title { font-weight: 650; font-size: 1.0625rem; flex: 1 1 auto; }
.info-cat > form, .info-cat > .info-cat__body { padding: 0 16px 16px; }
.info-cat > form > .info-cat__body { display: flex; flex-direction: column; gap: 18px; }
.info-cat > .info-cat__body { display: flex; flex-direction: column; gap: 14px; }
.req { color: var(--danger); }
.field__value { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); overflow-wrap: anywhere; }
.field__value--empty { color: var(--muted); font-style: italic; }
.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit input { flex: 1 1 auto; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 550; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pill:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.pill--clear { color: var(--muted); font: 500 .9375rem var(--font); }

.picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pick { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; text-align: center; font-size: .875rem; font-weight: 550; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 8px; }
.thumbs img, .thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; }
.thumb { position: relative; margin: 0; }
.thumb__remove { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: .875rem; cursor: pointer; }
.thumb__remove::before { content: ""; position: absolute; inset: -6px; } /* 44px touch area */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.guidance { font-size: .9375rem; }
.guidance summary { display: inline-flex; align-items: center; min-height: 36px; color: var(--accent); font-weight: 600; cursor: pointer; }
.guidance p { margin: 4px 0 8px; color: var(--muted); }
.btn--small { min-height: 44px; padding: 0 14px; font-size: .875rem; }
.avatar-btn { position: relative; display: inline-flex; cursor: pointer; border-radius: 50%; min-width: 56px; min-height: 56px; }
.avatar--img { object-fit: cover; padding: 0; }
.avatar-btn__badge { position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; font-size: .8125rem; }
.avatar-btn:has(+ input:focus-visible), input:focus-visible + .avatar-btn { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- AI Helper chat ---------- */

.sheet--chat { height: calc(100vh - var(--safe-top) - 12px); height: calc(100dvh - var(--safe-top) - 12px - var(--kb-offset)); }
@media (min-width: 900px) { .sheet--chat { height: auto; } }
.sheet__body.chat-body { padding: 0 14px 12px; display: flex; flex-direction: column; }

.scope { display: flex; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.scope__tab {
	flex: 0 0 auto; min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
	background: var(--surface); color: var(--text); font: inherit; font-size: .875rem; font-weight: 600;
	touch-action: manipulation; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scope__tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.chat__toolbar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; background: var(--surface); min-height: 8px; }
.chat__toolbar:empty { padding: 4px 0; }
.chat__new { border: 0; background: none; color: var(--accent); font: inherit; font-size: .875rem; font-weight: 600; min-height: 44px; padding: 0 4px; touch-action: manipulation; }
.chat__resumed { color: var(--muted); font-size: .75rem; }

.chat { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; }
.msg__bubble {
	max-width: 86%; padding: 10px 14px; border-radius: 18px; line-height: 1.4;
	white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); color: var(--text);
	border-bottom-left-radius: 6px;
}
.msg--user { align-items: flex-end; }
.msg--user .msg__bubble { background: var(--accent); color: var(--accent-ink); border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.msg--failed .msg__bubble { opacity: .6; }
.msg--error .msg__bubble { background: var(--danger-soft); color: var(--danger); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.msg--system { align-items: center; }
.msg__bubble.skeleton { width: 60%; height: 40px; }
.msg__picture { display: block; margin-top: 4px; padding: 0; border: 0; background: var(--surface-2); border-radius: 16px; border-bottom-left-radius: 6px; overflow: hidden; width: min(62vw, 240px); aspect-ratio: 3 / 4; cursor: zoom-in; }
.msg__picture-img { display: block; width: 100%; height: 100%; object-fit: cover; }

.dots { display: inline-flex; gap: 4px; align-items: center; height: 1.2em; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ait-dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ait-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .7; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
	min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
	background: var(--surface); color: var(--accent); font: inherit; font-size: .9375rem; text-align: left; touch-action: manipulation;
}
.chip:active { background: var(--accent-soft); }

.sheet__footer:has(.chat__composer) { padding: 8px 10px; }
.chat__composer { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
.chat__composer[hidden] { display: none; }
.chat__input {
	flex: 1 1 auto; min-height: 44px; max-height: 140px; resize: none; padding: 10px 14px; border-radius: 22px;
	border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
	font: inherit; font-size: 16px; line-height: 1.35; overflow-y: auto;
}
.chat__send { min-height: 44px; border-radius: 22px; padding: 0 16px; flex: 0 0 auto; }

/* ---------- Jobs ---------- */

.seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--surface-2); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg__btn {
	flex: 1 0 auto; min-height: 44px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent;
	color: var(--muted); font: 600 .875rem var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	touch-action: manipulation; white-space: nowrap;
}
.seg__btn[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg__count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; line-height: 20px; }

.job-card { display: block; color: inherit; text-decoration: none; touch-action: manipulation; }
.job-card:active { transform: scale(.99); }
.job-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.job-card__title, .job-hero__title { margin: 0; font-size: 1.0625rem; line-height: 1.3; overflow-wrap: anywhere; }
.job-hero__title { font-size: 1.25rem; }
.job-card__reward { flex: 0 0 auto; font-weight: 750; color: var(--success); font-variant-numeric: tabular-nums; }
.job-card__reward--big { font-size: 1.25rem; }
.job-card__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; color: var(--muted); font-size: .875rem; }
.job-card__meta a { color: inherit; }
.job-card__desc { margin: 8px 0 0; font-size: .9375rem; color: var(--muted); }
.job-card__foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.job-card__foot:empty { display: none; }
.job-card__reason { margin: 10px 0 0; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); font-size: .875rem; }
.job-card__locked { margin: 10px 0 0; font-size: .875rem; color: var(--muted); font-weight: 600; }
.job-hero { margin-top: 8px; }
.job-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; padding-top: 8px; }
.job-actions .btn:only-child { grid-column: 1 / -1; }
.card__subtitle { margin: 16px 0 6px; font-size: .9375rem; }
.card__subtitle:first-child { margin-top: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 8px; }

.notice--warning { background: var(--warning-soft); color: var(--warning); }
.notice--success { background: var(--success-soft); color: var(--success); }
.notice p { margin: 4px 0 0; }
.notice__hint { font-size: .875rem; opacity: .85; }

.sheet__text { margin: 0; }
.sheet__footer .btn { flex: 1 1 0; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.list__main--link { color: inherit; text-decoration: none; display: block; }
.list__chev { align-self: center; color: var(--muted); font-size: 1.25rem; }
.notice--info { background: var(--accent-soft); color: var(--accent); }
/* With a sheet open, toasts move to the top so they never cover the sheet. */
body.is-locked .toasts { top: calc(var(--safe-top) + 12px); bottom: auto; }
/* Four status tabs don't fit one row on phones: use a 2×2 grid there. */
@media (max-width: 479px) {
	.seg { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
	.seg__btn { flex: none; }
}

/* ---------- AI Helper cards ---------- */

.msg--card { align-items: stretch; }
.hcard { border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; background: var(--surface); max-width: 100%; display: flex; flex-direction: column; gap: 8px; }
.msg .hcard { margin-top: 8px; }
.hcard--offer { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hcard__eyebrow { font-size: .75rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.hcard__head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.hcard__title { font-size: 1rem; overflow-wrap: anywhere; }
.hcard__meta, .hcard__text { color: var(--muted); font-size: .9375rem; margin: 0; }
.hcard__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hcard__actions .btn[hidden] { display: none; }
.hcard__actions:not(:has(.btn:not([hidden]))) { display: none; }
.hcard__rows { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: .9375rem; }
.hcard__rows dt { color: var(--muted); }
.hcard__rows dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.hcard--templates { padding: 10px; }
.hcard-tpls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hcard-tpl { display: flex; flex-direction: column; gap: 4px; padding: 0 0 8px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
.hcard-tpl:active { transform: scale(.98); }
.hcard-tpl:disabled { cursor: default; }
.hcard-tpl.is-unavailable, .hcard--templates.is-done .hcard-tpl { opacity: .55; }
.hcard-tpl__img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.hcard-tpl__img--empty { display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: var(--muted); }
.hcard-tpl__name { padding: 0 10px; font-weight: 650; font-size: .9375rem; overflow-wrap: anywhere; }
.hcard-tpl__why { padding: 0 10px; color: var(--muted); font-size: .75rem; }
.hcard--created { flex-direction: row; align-items: center; gap: 12px; color: var(--text); text-decoration: none; border-color: var(--success); }
.hcard-created__img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-2); }
.hcard-created__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hcard--done { flex-direction: row; justify-content: space-between; align-items: center; background: var(--success-soft); color: var(--success); border-color: transparent; font-weight: 600; }
.hcard--done:has(.hcard__actions) { flex-direction: column; align-items: stretch; }
.hcard--done .hcard__actions .btn { white-space: nowrap; }
.hcard--done .card__note { margin: 0; color: var(--text); font-weight: 400; }
.hcard__link { color: inherit; min-height: 44px; display: inline-flex; align-items: center; }
.chat__progress { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.chat__toolbar:has(.chat__gen), .chat__toolbar:has(.chat__goal) { flex-wrap: wrap; justify-content: flex-start; }
.chat__gen { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .875rem; font-weight: 600; text-decoration: none; border: 1px solid transparent; }
.chat__gen.is-done { background: var(--success-soft); color: var(--success); }
.chat__goal { display: block; width: 100%; font-size: .875rem; line-height: 1.4; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.chat__closed { margin: 0; text-align: center; color: var(--muted); font-size: .875rem; }
.hcard__link { white-space: nowrap; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; align-self: center; }
.amount--plus { color: var(--success); }
.amount--minus { color: var(--text); }
.with-unit--prefix span { order: -1; }

/* Narrow phones: the AI Helper button becomes a compact round icon so it covers less content. */
@media (max-width: 400px) {
	.fab { width: 56px; height: 56px; min-height: 56px; padding: 0; justify-content: center; font-size: 1.5rem; }
	.fab__label { display: none; }
}

/* ---------- Coming soon (feature switched off by the admin) ---------- */
.is-soon { opacity: .55; cursor: not-allowed; filter: grayscale(.4); }
.is-soon:active { transform: none; }
.soon { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.action.is-soon { flex-direction: column; }
.action .soon { margin: 2px 0 0; padding-left: 0; background: none; }
.tpl .soon { margin: 4px 0 0; align-self: flex-start; }

/* ---------- Photos ---------- */
.photo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 640px) { .photo-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.photo-grid__item { position: relative; }
.photo-grid__item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; background: var(--surface-2); }
.photo-grid__item .thumb__remove { position: absolute; top: 4px; right: 4px; }
.upload-queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.upload-queue:empty { display: none; }
.upload-queue__row { display: grid; grid-template-columns: minmax(0, 1fr) 80px auto; gap: 8px; align-items: center; font-size: .8125rem; }
.upload-queue__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-queue__status { color: var(--muted); white-space: nowrap; }
.upload-queue__row.is-error .upload-queue__status { color: var(--danger); white-space: normal; }

/* ---------- Generate ---------- */
.gen-live:empty { display: none; }
.gen-live__label { margin: 0 0 10px; font-weight: 600; }
.gen-live__card.is-failed .gen-live__label { color: var(--danger); }
.gen-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.gen-results:empty { display: none; }
.gen-results__img img { width: 100%; border-radius: 12px; display: block; background: var(--surface-2); }
.gen-results__video { width: 100%; grid-column: 1 / -1; border-radius: 12px; background: #000; }
.gen-results__audio { width: 100%; grid-column: 1 / -1; min-height: 44px; }
.gen-script { grid-column: 1 / -1; margin-top: 8px; font-size: 0.95rem; }
.gen-script summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted, #555); }
.gen-script p { margin: 4px 0 0; white-space: pre-wrap; }
.gen-recent + .gen-recent { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.gen-recent .list__time { margin: 0; }
select { font-size: 16px; }

/* Free-form AI jobs: generation requirements. Chat goal jobs: the goal. */
.gen-reqs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gen-reqs__item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); min-height: 52px; }
.gen-reqs__label { flex: 1; font-weight: 600; }
.gen-reqs__count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.gen-reqs__item.is-done .gen-reqs__count { color: var(--success); }
.goal-box { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.goal-box__eyebrow { font-size: .8125rem; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.goal-box p { margin: 0; }
.gen-jobs:empty { display: none; }
.gen-job { display: flex; align-items: center; gap: 12px; }
.gen-job__text { flex: 1; min-width: 0; }
.gen-job__title { font-weight: 600; overflow-wrap: anywhere; }
.gen-job__count { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.gen-job.is-done .gen-job__count { color: var(--success); font-weight: 600; }

/* Contact us */
.support-card .chat { margin-bottom: 16px; }
.msg__from { font-size: .75rem; font-weight: 700; color: var(--accent); margin: 0 4px 2px; }
.msg__time { font-size: .6875rem; color: var(--muted); margin: 2px 6px 0; }
.support-card .chat__input { width: 100%; min-height: 88px; font-size: 16px; }

/* Generate: one group of choices per character (two-character images) */
.gen-person { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 14px 14px; margin: 0; display: grid; gap: 12px; min-width: 0; }
.gen-person__name { font-weight: 700; padding: 0 6px; }

/* Full-screen image viewer */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .86); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .18s ease; }
.lightbox.is-open { opacity: 1; }
.lightbox__stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(56px + var(--safe-top, 0px)) 8px calc(48px + var(--safe-bottom, 0px)); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.lightbox__img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; transition: transform .22s ease, opacity .22s ease; -webkit-touch-callout: none; }
.lightbox__close { position: absolute; top: calc(10px + var(--safe-top, 0px)); right: calc(10px + var(--safe-right, 0px)); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.25rem; cursor: pointer; }
.lightbox__count { position: absolute; bottom: calc(14px + var(--safe-bottom, 0px)); left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .85); font-size: .875rem; font-variant-numeric: tabular-nums; pointer-events: none; }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 2rem; cursor: pointer; display: none; }
.lightbox__nav--prev { left: 10px; }
.lightbox__nav--next { right: 10px; }
@media (hover: hover) and (pointer: fine) { .lightbox__nav:not([hidden]) { display: block; } }
/* Recent generations: compact thumbnails; tap opens the full-screen viewer. */
.gen-recent .gen-results { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.gen-recent .gen-results__img img { aspect-ratio: 3 / 4; object-fit: cover; }
.bonus-note { margin: 8px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--success-soft); color: var(--success); font-weight: 600; font-size: .9375rem; }

/* ---------- On/off switch (Explicit mode) ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; cursor: pointer; }
.switch-row__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.switch-row__title { font-weight: 650; font-size: 1.0625rem; }
.switch-row__text .card__note { margin: 0; }
.switch-row__control { display: flex; align-items: center; gap: 8px; flex: none; }
.switch-row__state { color: var(--muted); font-size: .875rem; font-weight: 600; min-width: 24px; text-align: right; }
.switch {
	-webkit-appearance: none; appearance: none; flex: none;
	position: relative; width: 51px; height: 31px; min-height: 0; margin: 0; padding: 0;
	border: 0; border-radius: 16px; background: var(--border); cursor: pointer;
	transition: background-color .2s ease;
}
.switch::after {
	content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
	background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s ease;
}
.switch:checked { background: var(--danger); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch[aria-busy="true"] { opacity: .7; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
.badge--18 { background: var(--danger-soft); color: var(--danger); }
.badges { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.badge[hidden] { display: none; }
#ait-auth > .notice { margin-bottom: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1 1 140px; }
.char-hero__body .notice { margin: 10px 0 0; }
.gen-reqs__hint { display: block; font-weight: 400; font-size: .8125rem; color: var(--muted); }

/* ---------- First sign-in: country question before anything else ---------- */
.app--gate .rail, .app--gate .tabbar, .app--gate .fab, .app--gate .bell { display: none !important; }
.country-gate { max-width: 480px; margin: 24px auto 0; text-align: left; }
.country-gate__icon { font-size: 2.5rem; line-height: 1; }
.country-gate h2 { margin: 4px 0 0; font-size: 1.375rem; }
@media (min-width: 900px) { .app.app--gate { padding-left: 0; } }

/* ---------- Notices from staff on Home ---------- */
.dash-notice { display: flex; align-items: flex-start; gap: 12px; padding: 14px 12px 14px 16px; border: 1px solid transparent; }
.dash-notice--info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text); }
.dash-notice--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--text); }
.dash-notice__icon { font-size: 1.25rem; line-height: 1.4; flex: none; }
.dash-notice__body { flex: 1; min-width: 0; }
.dash-notice__title { margin: 0 0 2px; font-size: 1rem; font-weight: 700; }
.dash-notice--warning .dash-notice__title { color: var(--warning); }
.dash-notice--info .dash-notice__title { color: var(--accent); }
.dash-notice__text { margin: 0; font-size: .9375rem; }
.dash-notice__close { flex: none; margin: -8px -4px -8px 0; color: var(--muted); }

/* ---------- Image to image / image to video: the uploaded picture ---------- */
.gen-picture__preview { margin: 4px 0 8px; }
.gen-picture__preview img { display: block; max-width: 100%; max-height: 320px; border-radius: var(--radius-sm); object-fit: contain; background: var(--surface-2); }
