/* BookPages design system: tokens from the original app (styles/design-system.css), modernised. */
:root {
	--bg: #f7f7f5;
	--surface: #ffffff;
	--surface-2: #fafaf8;
	--surface-sunk: #efefec;
	--text: #1f2023;
	--text-2: #3d3f45;
	--muted: #62656e;
	--muted-2: #8b8e95;
	--border: #e4e4e1;
	--border-strong: #cfcfcb;
	--accent: #5b3fd1;
	--accent-hover: #4b31bb;
	--accent-deep: #3f2a9e;
	--accent-soft: #efecfb;
	--accent-softer: #f8f7fd;
	--accent-ring: rgba(31, 32, 35, 0.16);
	--ok: #16a34a;
	--ok-soft: #dcfce7;
	--r-xs: 4px;
	--r-sm: 6px;
	--r-md: 8px;
	--r-lg: 12px;
	--r-xl: 16px;
	--r-pill: 999px;
	--shadow-sm: 0 1px 2px rgba(15, 15, 20, 0.04), 0 0 0 1px rgba(15, 15, 20, 0.03);
	--shadow-md: 0 4px 12px rgba(15, 15, 20, 0.06), 0 0 0 1px rgba(15, 15, 20, 0.04);
	--shadow-lg: 0 20px 50px rgba(15, 15, 20, 0.14), 0 8px 20px rgba(15, 15, 20, 0.06);
	--shadow-accent: 0 1px 2px rgba(91, 33, 182, 0.25), 0 4px 12px rgba(124, 58, 237, 0.22);
	--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
	--font-sans: "Plus Jakarta Sans", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	--font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

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

html {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-sans);
	font-size: 15px;
	font-weight: 500;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

a { color: var(--accent); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

h1 { font-size: 26px; font-weight: 600; line-height: 1.25; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

/* ── Logo ── */
.logo-mark {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: var(--r-sm);
	background: linear-gradient(150deg, #8b5cf6 0%, var(--accent) 55%, var(--accent-deep) 100%);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(91, 33, 182, 0.3);
	color: #fff;
}
.logo-mark-lg { width: 36px; height: 36px; border-radius: var(--r-md); }

/* ── Buttons ── */
.btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 20px;
	border: 0;
	border-radius: var(--r-md);
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s var(--ease), border-color 0.15s, box-shadow 0.15s, transform 0.15s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text-2); border: 1.5px solid var(--border-strong); }
.btn-ghost:hover { background: var(--surface-sunk); color: var(--text); }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-full { width: 100%; }

.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading::after {
	content: "";
	position: absolute;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}
.btn-ghost.is-loading::after { border-color: var(--border-strong); border-top-color: var(--accent); }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.input {
	width: 100%;
	height: 46px;
	padding: 0 14px;
	border: 1.5px solid var(--border-strong);
	border-radius: var(--r-md);
	background: var(--surface);
	font-size: 15px;
	font-weight: 500;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input:hover { border-color: #c4c4cc; }
.input::placeholder { color: var(--muted-2); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.input-error, .input-error:hover { border-color: #f87171; background: #fffafa; }
.input-error:focus { box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.2); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-toggle {
	position: absolute;
	top: 50%;
	right: 6px;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: var(--r-sm);
	color: var(--muted-2);
	transform: translateY(-50%);
	transition: color 0.15s, background 0.15s;
}
.input-toggle:hover, .input-toggle.on { color: var(--accent); background: var(--accent-soft); }
.help { margin-top: 6px; font-size: 13px; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ── Surfaces ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }

.banner { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; padding: 12px 14px; border: 1.5px solid; border-radius: var(--r-md); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; animation: rise 0.25s var(--ease); }
.banner svg { margin-top: 2px; }
.banner a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.banner-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.banner-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.banner-warn { background: #fffbeb; border-color: #fde68a; color: #854d0e; }
.banner-dev { background: var(--accent-softer); border-color: #dcd6f6; color: var(--accent-deep); }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }

/* ── Sign-in pages ── */
body.is-auth {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px 16px;
	background:
		radial-gradient(ellipse 70% 50% at 50% -10%, rgba(124, 58, 237, 0.12), transparent 70%),
		radial-gradient(circle at 1px 1px, rgba(24, 24, 27, 0.06) 1px, transparent 0) 0 0 / 22px 22px,
		var(--bg);
}
.auth-card {
	width: 100%;
	max-width: 420px;
	padding: 44px 40px 36px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--r-xl);
	box-shadow: var(--shadow-lg);
	animation: rise 0.35s var(--ease);
}
.auth-card h1 { margin-bottom: 8px; text-align: center; }
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; color: var(--text); font-size: 16px; }
.auth-logo:hover { text-decoration: none; }
.auth-subtitle { margin-bottom: 28px; text-align: center; font-size: 14px; color: var(--text-2); }
.auth-card .btn-primary { margin-top: 4px; min-height: 46px; }
.forgot-password { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-foot { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); text-align: center; font-size: 14px; color: var(--text-2); }
.resend { margin-bottom: 18px; }

/* ── Signed-in pages ── */
body.is-app { display: flex; flex-direction: column; }
.topnav {
	position: sticky;
	top: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	gap: 20px;
	height: 56px;
	padding: 0 24px;
	background: rgba(255, 255, 255, 0.82);
	border-bottom: 1px solid var(--border);
	-webkit-backdrop-filter: saturate(180%) blur(12px);
	backdrop-filter: saturate(180%) blur(12px);
}
.nav-logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.nav-logo:hover { text-decoration: none; }
.nav-divider { width: 1px; height: 20px; background: var(--border); }
.nav-links { display: flex; flex: 1; gap: 2px; }
.nav-link { padding: 6px 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13px; font-weight: 500; transition: background 0.12s, color 0.12s; }
.nav-link:hover { background: var(--surface-sunk); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.account-menu { position: relative; }
.account-menu-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 38px;
	padding: 3px 10px 3px 3px;
	border: 1px solid var(--border);
	border-radius: var(--r-pill);
	background: var(--surface);
	box-shadow: var(--shadow-sm);
	color: var(--muted);
	list-style: none;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}
.account-menu-trigger::-webkit-details-marker { display: none; }
.account-menu-trigger:hover, .account-menu[open] .account-menu-trigger { background: var(--surface-2); border-color: var(--border-strong); }
.account-menu-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.account-menu-name { max-width: 160px; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.account-menu[open] .account-menu-trigger svg { transform: rotate(180deg); }
.account-menu-panel { position: absolute; top: calc(100% + 8px); right: 0; z-index: 100; width: 240px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: rise 0.18s var(--ease); }
.account-menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.account-menu-head strong { font-size: 14px; font-weight: 600; }
.account-menu-head span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-item { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-2); font-size: 14px; font-weight: 600; }
.account-menu-item:hover { background: var(--surface-sunk); color: var(--text); text-decoration: none; }
.account-menu-item.danger { color: #b91c1c; }
.account-menu-item.danger:hover { background: #fef2f2; }

.page-content { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 36px 24px 80px; animation: rise 0.3s var(--ease); }
.page-head { margin-bottom: 24px; }
.page-head p { max-width: 640px; margin-top: 6px; color: var(--text-2); }
.section-title { margin: 28px 0 14px; }

/* ── Dashboard onboarding ── */
.onboarding { padding: 24px; }
.onboarding-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.progress-pill { padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-sunk); color: var(--text-2); font-size: 12px; font-weight: 600; }
.progress-track { height: 6px; margin: 14px 0 8px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-sunk); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.6s var(--ease); }
.onboarding-steps { list-style: none; }
.onboarding-steps li, .connected-card { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.onboarding-steps li:last-child { border-bottom: 0; padding-bottom: 0; }
.onboarding-steps li > div, .connected-card > div { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.onboarding-steps strong, .connected-card strong { font-size: 15px; font-weight: 600; }
.onboarding-steps li span:not(.step-icon), .connected-card > div span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.onboarding-steps li.done strong { color: var(--text-2); }
.onboarding-steps li.locked { opacity: 0.55; }
.step-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-sunk); color: var(--muted); }
.done .step-icon, .step-icon.ok { background: var(--ok-soft); color: #166534; }
.current .step-icon { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.connected-card { margin-bottom: 8px; padding: 18px 20px; border-bottom: 1px solid var(--border); }

/* ── Storage wizard ── */
.wizard-steps { display: flex; align-items: center; margin: 4px 0 20px; list-style: none; counter-reset: step; }
.wizard-steps li { display: flex; flex: 1; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; counter-increment: step; }
.wizard-steps li:last-child { flex: 0 0 auto; }
.wizard-steps li::before { content: counter(step); display: grid; flex-shrink: 0; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--border-strong); color: var(--muted); font-size: 12px; transition: all 0.25s var(--ease); }
.wizard-steps li:not(:last-child)::after { content: ""; flex: 1; height: 2px; margin: 0 12px 0 2px; border-radius: 2px; background: var(--border); transition: background 0.25s; }
.wizard-steps li.current { color: var(--text); }
.wizard-steps li.current::before { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.wizard-steps li.done { color: var(--text-2); }
.wizard-steps li.done::before { content: "✓"; background: var(--ok-soft); border-color: var(--ok-soft); color: #166534; }
.wizard-steps li.done::after { background: #86efac; }
.wizard-panel { animation: rise 0.28s var(--ease); }

.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.provider-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	padding: 18px;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.15s, box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.provider-card:hover { border-color: var(--ink-soft); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.provider-top { display: flex; align-items: center; gap: 8px; width: 100%; margin-bottom: 10px; }
.provider-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: color-mix(in srgb, var(--tint) 12%, #fff); color: var(--tint); font-size: 16px; font-weight: 700; }
.provider-arrow { margin-left: auto; color: var(--muted-2); opacity: 0; transform: translateX(-4px); transition: all 0.2s var(--ease); }
.provider-card:hover .provider-arrow { color: var(--accent); opacity: 1; transform: none; }
.provider-card strong { font-size: 15px; font-weight: 600; }
.provider-tagline { color: var(--text-2); font-size: 13px; line-height: 1.5; }
.reassure { display: flex; align-items: center; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.setup-card .reassure { margin: 0 0 18px; }

.link-back { margin: 0 0 14px; padding: 4px 0; border-radius: var(--r-sm); color: var(--text-2); font-size: 14px; font-weight: 600; }
.link-back:hover { color: var(--accent); }
.setup-card { margin-bottom: 16px; padding: 24px; }
.setup-card > h2 { margin-bottom: 18px; }
.guide { list-style: none; counter-reset: guide; margin-bottom: 18px; }
.guide li { position: relative; padding: 0 0 14px 40px; color: var(--text-2); counter-increment: guide; }
.guide li::before { content: counter(guide); position: absolute; top: 0; left: 0; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.guide li:not(:last-child)::after { content: ""; position: absolute; top: 30px; bottom: 4px; left: 12px; width: 2px; border-radius: 2px; background: var(--accent-soft); }

.checklist { margin-bottom: 20px; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: var(--muted); }
.checklist li::before { content: ""; display: grid; flex: 0 0 auto; place-items: center; width: 24px; height: 24px; border: 2px solid var(--border-strong); border-radius: 50%; font-size: 12px; font-weight: 700; }
.checklist li[data-state] { color: var(--text); }
.checklist li[data-state="running"]::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.checklist li[data-state="ok"]::before { content: "✓"; border-color: var(--ok); background: var(--ok); color: #fff; animation: pop 0.3s var(--ease); }
.checklist li[data-state="fail"]::before { content: "!"; border-color: #f59e0b; background: #fef3c7; color: #92400e; animation: pop 0.3s var(--ease); }

#bpp-cors p { margin-bottom: 12px; color: var(--text-2); }
#bpp-cors pre { max-height: 260px; margin-bottom: 14px; padding: 16px; overflow: auto; border-radius: var(--r-md); background: #18181b; color: #e4e4e7; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Shared page parts ── */
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.link-back { display: inline-block; margin-bottom: 14px; }
.req { color: #dc2626; }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
select.input { appearance: none; padding-right: 40px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.4' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 14px center; cursor: pointer; }
.help-right { text-align: right; }
.help-ok { color: #15803d; }
.help-error { color: #b91c1c; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.section-label { margin: 4px 0 12px; color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.form-card { padding: 28px; }
.form-card .section-label:not(:first-of-type) { margin-top: 28px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.save-state { margin-right: auto; color: var(--muted); font-size: 13px; }
.save-state.pending { color: #b45309; }
.save-state.saved { color: #15803d; }
.btn-danger { background: var(--surface); color: #b91c1c; border: 1.5px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-quiet { border-color: transparent; }

.slug-field { display: flex; align-items: stretch; height: 46px; overflow: hidden; border: 1.5px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.slug-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.slug-field:has(.input-error) { border-color: #f87171; }
.slug-prefix { display: flex; align-items: center; max-width: 55%; padding: 0 4px 0 14px; overflow: hidden; background: var(--surface-2); border-right: 1px solid var(--border); color: var(--muted); font-family: var(--font-mono); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.slug-input { flex: 1; min-width: 0; padding: 0 12px; border: 0; outline: none; background: transparent; font-family: var(--font-mono); font-size: 14px; }

.toggle-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; }
.toggle-row > span { display: flex; flex-direction: column; }
.toggle-row strong { font-size: 14px; font-weight: 600; }
.toggle-row > span > span { color: var(--muted); font-size: 13px; }
.switch { position: relative; flex-shrink: 0; width: 42px; height: 24px; border-radius: var(--r-pill); background: var(--border-strong); appearance: none; cursor: pointer; transition: background 0.2s var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.2s var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 18px; border: 1.5px solid var(--border); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.type-card:hover { border-color: var(--ink-soft); }
.type-card:has(input:checked) { border-color: var(--accent); background: var(--accent-softer); box-shadow: 0 0 0 3px var(--accent-soft); }
.type-card input { position: absolute; top: 18px; right: 18px; width: 18px; height: 18px; accent-color: var(--accent); }
.type-card strong { font-size: 15px; }
.type-card > span:last-child { color: var(--text-2); font-size: 13px; }
.type-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 8px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); }

.type-pill { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.type-pill.ebook { background: #ecfdf5; color: #065f46; }
.page-slug { overflow: hidden; color: var(--muted-2); font-family: var(--font-mono); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--surface-sunk); color: var(--muted); font-size: 12px; font-weight: 600; }
.status-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }
.status-chip.live { background: var(--ok-soft); color: #166534; }
.status-chip.live::before { background: var(--ok); }

/* ── Dashboard list ── */
.stats-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-pill { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.stat-pill > div { display: flex; flex-direction: column; }
.stat-pill strong { font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.stat-pill span:not(.stat-icon) { color: var(--muted); font-size: 12px; }
.stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); }
.onboarding + .stats-strip { margin-top: 16px; }
.pages-list { overflow: hidden; }
.list-toolbar { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tab { height: 32px; padding: 0 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13px; font-weight: 500; transition: background 0.12s; }
.tab:hover { background: var(--surface-sunk); }
.tab.active { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text); font-weight: 600; }
.tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: var(--r-pill); background: var(--border); font-size: 11px; font-weight: 600; }
.tab.active .tab-count { background: var(--accent-soft); color: var(--accent); }
.page-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 110px 150px 70px; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--border); color: inherit; font-weight: 500; transition: background 0.12s; }
.page-row:last-of-type { border-bottom: 0; }
.page-row:hover { background: var(--surface-2); text-decoration: none; }
.page-row[hidden] { display: none; }
.page-cover { display: block; width: 40px; height: 56px; overflow: hidden; border-radius: var(--r-sm); box-shadow: var(--shadow-sm); background: #2b4a3e; }
.page-cover.square { height: 40px; }
.page-cover.tint-1 { background: #3b3a6b; }
.page-cover.tint-2 { background: #8a4b2f; }
.page-cover img, .cover-thumb img, .cover-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.page-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-info strong { overflow: hidden; font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.page-info-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-status { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; }
.row-status .status-dot { width: 7px; height: 7px; background: var(--ok); }
.row-status .status-dot.draft { background: var(--muted-2); }
.row-stat { display: flex; flex-direction: column; color: var(--text-2); font-size: 13px; }
.row-stat small { color: var(--muted-2); font-size: 12px; }
.row-action { display: flex; align-items: center; justify-content: flex-end; gap: 6px; color: var(--accent); font-size: 13px; font-weight: 600; opacity: 0.7; transition: opacity 0.15s, gap 0.15s; }
.page-row:hover .row-action { gap: 9px; opacity: 1; }
.list-empty { padding: 28px 16px; color: var(--muted); font-size: 14px; text-align: center; }

/* ── Editor ── */
.editor-head { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.cover-thumb { flex-shrink: 0; width: 64px; height: 88px; overflow: hidden; border-radius: var(--r-md); background: #2b4a3e; box-shadow: var(--shadow-md); }
.editor-head-text { min-width: 0; }
.editor-head h1 { overflow-wrap: anywhere; }
.editor-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; gap: 20px; }
.editor-main, .editor-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.section-card { padding: 22px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2 { display: flex; align-items: center; gap: 8px; }
.section-sub { margin-top: 2px; color: var(--muted); font-size: 13px; }
.count-pill { padding: 0 8px; border-radius: var(--r-pill); background: var(--surface-sunk); color: var(--text-2); font-size: 12px; font-weight: 600; }
.count-pill:empty { display: none; }

.drop-zone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 20px; border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text); text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease); }
.drop-zone:hover, .drop-zone.is-over { border-color: var(--accent); background: var(--accent-softer); }
.drop-zone.is-over { transform: scale(1.01); }
.drop-zone strong { font-size: 14px; font-weight: 600; }
.drop-zone > span:last-of-type { color: var(--muted); font-size: 12px; }
.drop-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }

.file-list { display: flex; flex-direction: column; margin-top: 14px; list-style: none; }
.file-list:empty { margin-top: 0; }
.list-empty[data-empty] { padding: 18px 0 4px; }
.file-row { position: relative; display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 6px; border-radius: var(--r-md); transition: background 0.12s, opacity 0.15s; }
.file-row + .file-row { border-top: 1px solid var(--border); }
.file-row:hover { background: var(--surface-2); }
.file-row.is-playing { background: var(--accent-softer); }
.file-row.is-busy { opacity: 0.45; pointer-events: none; }
.file-row.is-dragging { opacity: 0.35; }
.file-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.file-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.file-row.flash-saved { background: #f0fdf4; }
.handle { display: grid; place-items: center; width: 24px; height: 36px; border-radius: var(--r-xs); color: var(--muted-2); cursor: grab; }
.handle:hover { color: var(--text); background: var(--surface-sunk); }
.file-num { width: 22px; color: var(--muted-2); font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.file-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.file-title { width: 100%; padding: 3px 6px; margin-left: -6px; border: 1px solid transparent; border-radius: var(--r-xs); background: transparent; font-size: 14px; font-weight: 600; text-overflow: ellipsis; outline: none; transition: border-color 0.12s, background 0.12s; }
.file-title:hover { border-color: var(--border); background: var(--surface); }
.file-title:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }
.file-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.icon-btn { display: grid; flex-shrink: 0; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); color: var(--muted); transition: background 0.12s, color 0.12s; }
.icon-btn:hover { background: var(--surface-sunk); color: var(--text); text-decoration: none; }
.icon-btn:disabled { opacity: 0.3; pointer-events: none; }
.icon-btn.danger:hover { background: #fef2f2; color: #b91c1c; }
.ico { display: grid; place-items: center; }
.play-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.play-btn:hover, .is-playing .play-btn { background: var(--accent); color: #fff; }
.touch-only { display: none; }
.move-group { flex-direction: column; flex-shrink: 0; }
.move-group .icon-btn { width: 30px; height: 22px; }
@media (pointer: coarse) { .touch-only { display: flex; } .handle { display: none; } }
.format-badge { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); background: #ecfdf5; color: #065f46; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; }
.format-badge.f-pdf { background: #fef2f2; color: #b91c1c; }
.format-badge.f-mobi, .format-badge.f-azw3 { background: #fff7ed; color: #c2410c; }

.file-row.pending .file-main { gap: 4px; }
.bar { display: block; height: 4px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-sunk); }
.bar > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.2s linear; }
.spinner { width: 18px; height: 18px; margin: 0 9px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.is-waiting .spinner { animation: none; border-top-color: var(--accent-soft); }
.is-failed .spinner { animation: none; border-color: #fecaca; background: #fef2f2; }
.is-failed .file-meta { color: #b91c1c; }
.is-failed .bar { display: none; }

.cover-preview { position: relative; display: grid; place-items: center; aspect-ratio: 2 / 3; overflow: hidden; margin-bottom: 14px; border-radius: var(--r-md); background: var(--surface-sunk); }
.cover-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted-2); font-size: 13px; }
.cover-progress { position: absolute; right: 12px; bottom: 12px; left: 12px; height: 5px; overflow: hidden; border-radius: var(--r-pill); background: rgba(255, 255, 255, 0.7); }
.cover-progress > span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 0.2s linear; }
.cover-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.cover-actions .btn { flex: 1; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-stats > div { display: flex; flex-direction: column; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); }
.mini-stats strong { font-size: 20px; font-weight: 600; }
.mini-stats span { color: var(--muted); font-size: 12px; }
.danger-card .help { margin: -6px 0 14px; }

.zip-panel { margin-top: 14px; padding: 16px; border: 1px solid #dcd6f6; border-radius: var(--r-lg); background: var(--accent-softer); animation: rise 0.25s var(--ease); }
.zip-panel .banner { margin: 0; }
.zip-reading { display: flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 14px; }
.zip-found { display: flex; flex-direction: column; gap: 4px; }
.zip-found > strong { font-size: 15px; }
.zip-found > span { color: var(--muted); font-size: 13px; }
.zip-preview { margin: 8px 0 4px; list-style: none; color: var(--text-2); font-size: 13px; }
.zip-preview .more { color: var(--muted); }
.zip-option { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; font-size: 13px; font-weight: 600; cursor: pointer; }
.zip-option input { width: 16px; height: 16px; accent-color: var(--accent); }
.zip-found .actions { margin-top: 10px; }

a.stat-pill { color: inherit; font-weight: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
a.stat-pill:hover { border-color: var(--ink-soft); text-decoration: none; }
.editor-head .editor-head-text { flex: 1; }
.editor-view { flex-shrink: 0; }
.emails-toolbar { align-items: center; justify-content: space-between; }
.emails-count { color: var(--text-2); font-size: 14px; }
.input-sm { width: auto; max-width: 60%; height: 36px; font-size: 13px; }
.empty-block { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 48px 20px; text-align: center; }
.empty-block span:last-child { max-width: 380px; color: var(--muted); font-size: 14px; }
.email-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.email-table th { padding: 10px 18px; border-bottom: 1px solid var(--border); color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-align: left; text-transform: uppercase; }
.email-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.email-table tr:last-child td { border-bottom: 0; }
.email-table tbody tr:hover { background: var(--surface-2); }
.email-cell { display: flex; align-items: center; gap: 10px; color: var(--text) !important; font-weight: 600; overflow-wrap: anywhere; }
.email-cell .account-menu-avatar { width: 28px; height: 28px; flex-shrink: 0; }
.date-cell { white-space: nowrap; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 640px) {
	h1 { font-size: 22px; }
	.auth-card { padding: 32px 22px 28px; }
	.topnav { gap: 10px; padding: 0 14px; }
	.nav-logo { font-size: 0; gap: 0; }
	.nav-divider, .account-menu-name { display: none; }
	.account-menu-trigger { padding-right: 8px; }
	.page-content { padding: 24px 16px 64px; }
	.onboarding { padding: 18px; }
	.onboarding-steps li, .connected-card { flex-wrap: wrap; }
	.onboarding-steps li .btn, .connected-card .btn { margin-left: 46px; width: calc(100% - 46px); }
	.page-head-row { flex-direction: column; align-items: stretch; }
	.field-row, .type-grid { grid-template-columns: 1fr; }
	.stats-strip { gap: 8px; }
	.stat-pill { flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; }
	.stat-icon { display: none; }
	.stat-pill strong { font-size: 18px; }
	.file-row { gap: 8px; padding: 8px 2px; }
	.file-row .icon-btn.danger { width: 30px; }
	.form-card { padding: 20px; }
	.page-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px; }
	.row-stat, .row-action { display: none; }
	.editor-grid { grid-template-columns: 1fr; }
	.editor-head { flex-wrap: wrap; }
	.editor-view { width: 100%; }
	.email-table th:nth-child(2), .email-table td:nth-child(2) { display: none; }
	.email-table td, .email-table th { padding: 10px 12px; }
	.editor-head { gap: 14px; }
	.cover-thumb { width: 52px; height: 72px; }
	.section-card { padding: 16px; }
	.file-num { display: none; }
	.cover-preview { max-width: 220px; margin-left: auto; margin-right: auto; }
	.wizard-steps li span { display: none; }
	.wizard-steps li.current span { display: inline; }
	.setup-card { padding: 18px; }
}

/* ── Plain editorial finish, matching the home page: white, ink, pills, no gradients ── */
:root { --ink: #1f2023; --ink-soft: #a9a9a4; }
html { font-weight: 500; }
body.is-app { background: #fff; }
h1 { font-weight: 800; letter-spacing: -0.035em; }
h2 { font-weight: 800; letter-spacing: -0.02em; }
.page-content h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.12; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: none; }
.logo-mark { background: var(--ink); box-shadow: none; }
.btn { border-radius: var(--r-pill); }
.btn-sm { border-radius: var(--r-pill); }
.btn-primary { background: var(--ink); box-shadow: none; }
.btn-primary:hover { background: #000; }
.btn-ghost { border: 1px solid var(--ink); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-quiet { border-color: transparent; }
.btn-danger { border-width: 1px; }
.input:focus, .slug-field:focus-within { border-color: var(--ink); }
.input, .slug-field { border-width: 1px; border-radius: 12px; }
.card, .stat-pill { box-shadow: none; border-radius: 16px; }
body.is-auth { background: var(--bg); }
.auth-card { border-radius: 18px; box-shadow: var(--shadow-md); }
.auth-logo, .nav-logo { font-weight: 800; letter-spacing: -0.04em; }
.nav-logo { font-size: 18px; }
.topnav { height: 64px; background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
.nav-link { background: none; font-size: 14px; font-weight: 600; color: var(--muted); border-radius: 0; position: relative; }
.nav-link:hover { background: none; color: var(--ink); }
.nav-link.active { background: none; color: var(--ink); }
.nav-link.active::after { content: ""; position: absolute; right: 12px; bottom: 0; left: 12px; height: 2px; border-radius: 2px; background: var(--ink); }
.stat-pill { border: 0; background: var(--bg); }
.stat-pill strong { font-size: 28px; font-weight: 800; letter-spacing: -0.035em; }
.stat-icon { background: #fff; color: var(--ink); }
a.stat-pill:hover { background: var(--surface-sunk); }
.section-label, .email-table th { color: var(--muted); }
.drop-zone { border-color: var(--border-strong); }
.drop-zone:hover, .drop-zone.is-over { border-color: var(--ink); background: var(--bg); }
.drop-icon { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.provider-card:hover, .type-card:hover { box-shadow: var(--shadow-md); }
.type-card:has(input:checked) { border-color: var(--ink); background: var(--bg); box-shadow: 0 0 0 1px var(--ink); }
.type-card input { accent-color: var(--ink); }
.type-icon { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.switch:checked { background: var(--ink); }
.row-action { color: var(--ink); }
.toggle-row { background: var(--bg); }
