/* ShortsGen — monochrome, rounded, quiet UI. Theme is set on <html data-theme="dark|light"> by theme.js. */
:root,
:root[data-theme="dark"] {
  --bg: #0e0e0f;
  --sidebar: #141415;
  --surface: #18181a;
  --surface-2: #202023;
  --surface-3: #2a2a2e;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --primary: #fafafa;
  --primary-text: #0a0a0a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --danger-bg: rgb(248 113 113 / 0.12);
  --focus: #fafafa;
  --shadow: 0 8px 30px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --sidebar: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e9e9ec;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-2: #27272a;
  --muted: #71717a;
  --primary: #09090b;
  --primary-text: #ffffff;
  --ok: #16a34a;
  --warn: #b45309;
  --danger: #dc2626;
  --danger-bg: rgb(220 38 38 / 0.08);
  --focus: #09090b;
  --shadow: 0 8px 30px rgb(0 0 0 / 0.08);
  color-scheme: light;
}
:root {
  --radius: 14px;
  --radius-lg: 22px;
  --sidebar-w: 248px;
  --orb: radial-gradient(circle at 30% 30%, #ffd29d, #ff7a3d 45%, #e2264d 80%);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.icon svg { width: 100%; height: 100%; display: block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 13px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { opacity: 0.88; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 14px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--primary-text) transparent var(--primary-text) transparent;
  animation: spin 0.7s linear infinite;
}
.btn:not(.primary).loading::after { border-color: var(--text) transparent var(--text) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .select {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--surface-3); }
.field-error { color: var(--danger); font-size: 12px; min-height: 0; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.form-error:empty, .field-error:empty { display: none; }
.form-ok { color: var(--ok); font-size: 13px; margin-top: 4px; }
.form-ok:empty { display: none; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  background: var(--sidebar); border-right: 1px solid var(--border); padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 14px; font-weight: 700; font-size: 16px; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--orb); flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 14px 10px 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 10px;
  text-decoration: none; color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-3); color: var(--text); font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.usage-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); }
.usage-card .row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 8px; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > div { height: 100%; background: var(--primary); border-radius: inherit; transition: width 0.4s ease; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; border-radius: 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-3); font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.user-row .email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; height: 56px;
  padding: 0 20px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h2 { font-size: 15px; font-weight: 600; flex: 1; }
.menu-btn { display: none; }
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; }
.page-head p { margin-top: 4px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 30; left: 0; top: 0; width: min(84vw, 300px); transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; }
  .menu-btn { display: inline-grid; }
  .page { padding: 20px 16px 48px; }
}
.scrim { display: none; position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.5); }

/* ---------- banners ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; margin-bottom: 20px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; flex-wrap: wrap;
}
.banner .grow { flex: 1; min-width: 200px; }

/* ---------- create: hero + composer ---------- */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: clamp(26px, 4vw, 34px); font-weight: 600; }
.hero p { margin-top: 8px; }
.composer {
  max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); transition: border-color 0.15s;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea {
  display: block; width: 100%; min-height: 132px; max-height: 50vh; resize: none; border: 0; outline: none;
  background: transparent; padding: 18px 20px 6px; font-size: 15px; line-height: 1.6;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px 10px 12px; flex-wrap: wrap; }
.orb { width: 26px; height: 26px; border-radius: 50%; background: var(--orb); flex: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--text-2); max-width: 220px;
}
.pill > .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill:hover { color: var(--text); background: var(--surface-3); }
.pill[aria-expanded="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.composer-bar .spacer { flex: 1; }
.count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.count.over { color: var(--danger); }
.send {
  width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--primary); color: var(--primary-text); transition: opacity 0.12s;
}
.send:disabled { opacity: 0.35; cursor: not-allowed; }
.send.loading .icon { animation: spin 0.8s linear infinite; }

.panel {
  max-width: 760px; margin: 12px auto 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { font-size: 14px; font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; max-width: 760px; margin: 36px auto 0; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 6px; border-radius: 14px;
  background: transparent; border: 0; cursor: pointer; color: var(--text); font-weight: 600; font-size: 13px;
}
.tile:hover { background: var(--surface-2); }
.tile .tile-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
}
.tile:hover .tile-icon { background: var(--surface-3); }

.section { max-width: 760px; margin: 40px auto 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; font-weight: 600; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  height: 38px; padding: 0 12px; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }

/* ---------- voices ---------- */
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.voice-grid.scroll { max-height: 320px; overflow-y: auto; padding: 2px; }
.voice-card {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent;
}
.voice-card:hover { border-color: var(--border-strong); }
.voice-card:has(input:checked) { border-color: var(--text); background: var(--surface-3); }
.voice-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.voice-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff;
}
.voice-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.voice-name { font-weight: 600; font-size: 13px; }
.voice-desc { font-size: 11.5px; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-strong); padding: 0;
  display: grid; place-items: center; background: var(--surface); cursor: pointer; color: var(--text);
}
.play .icon { width: 14px; height: 14px; }
.play:hover { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.play.playing { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.play.loading { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ---------- captions ---------- */
.caption-setup { display: flex; gap: 18px; align-items: flex-start; }
.cap-phone {
  flex: none; width: 128px; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; position: relative;
  background: radial-gradient(circle at 30% 20%, #3a6b8c, transparent 60%), linear-gradient(160deg, #1d3b2f, #0d1b2a 60%, #2b1a36);
  border: 1px solid var(--border);
}
.cap-text {
  position: absolute; left: 6px; right: 6px; top: 58%; transform: translateY(-50%); text-align: center;
  color: #fff; line-height: 1.05; text-transform: uppercase; font-size: calc(20px * var(--cap-scale, 1));
  -webkit-text-stroke: 3px #000; paint-order: stroke fill; text-shadow: 0 2px 3px rgb(0 0 0 / 0.6);
}
.cap-text[data-style="phrase"] { font-size: calc(13px * var(--cap-scale, 1)); }
.cap-word.hl { color: #ffe500; }
.cap-text .pop, .cap-text.pop { display: inline-block; animation: cap-pop 0.14s ease-out; }
@keyframes cap-pop { 0% { transform: scale(0.6); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }
.cap-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.seg { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 999px; border: 1px solid var(--border); }
.seg label { margin: 0; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--muted); }
.seg label:has(input:checked) { background: var(--primary); color: var(--primary-text); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.chip {
  display: flex; align-items: center; justify-content: center; margin: 0; height: 42px; padding: 0 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
}
.chip:hover { border-color: var(--border-strong); }
.chip:has(input:checked) { border-color: var(--text); background: var(--surface-3); }
.chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.font-sample { font-size: 16px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- effects ---------- */
.fx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.fx-item {
  display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent;
}
.fx-item:hover { border-color: var(--border-strong); }
.fx-item:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.switch { flex: none; position: relative; width: 34px; height: 20px; margin-top: 1px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
input:checked + .switch { background: var(--primary); border-color: var(--primary); }
input:checked + .switch::after { transform: translateX(14px); background: var(--primary-text); }
.fx-text { display: flex; flex-direction: column; min-width: 0; }
.fx-name { font-weight: 600; font-size: 13px; }
.fx-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.fx-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- shorts library ---------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button {
  height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-weight: 600; font-size: 12.5px; cursor: pointer;
}
.filters button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.short-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.thumb {
  position: relative; aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border); cursor: pointer; padding: 0; width: 100%; display: block;
}
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.thumb .overlay {
  position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(to top, rgb(0 0 0 / 0.55), transparent 45%);
  opacity: 0; transition: opacity 0.15s; color: #fff;
}
.thumb:hover .overlay, .thumb:focus-visible .overlay { opacity: 1; }
.thumb .overlay .icon { width: 42px; height: 42px; }
.thumb .duration { position: absolute; right: 8px; bottom: 8px; font-size: 11px; font-weight: 700; color: #fff; background: rgb(0 0 0 / 0.6); padding: 2px 7px; border-radius: 99px; }
.thumb.pending { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 18px; cursor: default; text-align: center; }
.thumb.failed { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; cursor: default; text-align: center; color: var(--danger); }
.ring { width: 54px; height: 54px; }
.ring circle { fill: none; stroke-width: 5; }
.ring .track { stroke: var(--surface-3); }
.ring .value { stroke: var(--text); stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; transform: rotate(-90deg); transform-origin: center; }
.card-meta { display: flex; align-items: flex-start; gap: 6px; }
.card-meta .text { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.done { color: var(--ok); }
.badge.processing, .badge.queued { color: var(--warn); }
.badge.failed { color: var(--danger); }
.empty { text-align: center; padding: 64px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty .icon { width: 36px; height: 36px; color: var(--muted); margin-bottom: 10px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { margin-bottom: 18px; }
.recent-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

/* ---------- dialogs & menus ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  padding: 0; box-shadow: var(--shadow); max-width: min(94vw, 900px); width: 100%;
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); backdrop-filter: blur(2px); }
.dialog-body { padding: 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.dialog-head h3 { font-size: 16px; }
dialog.narrow { max-width: 440px; }
.viewer { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 22px; }
.viewer video { width: 100%; aspect-ratio: 9 / 16; border-radius: 16px; background: #000; display: block; }
.viewer .details { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.viewer .script { font-size: 14px; color: var(--text-2); max-height: 160px; overflow: auto; white-space: pre-wrap; }
.viewer .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.scenes { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); max-height: 220px; overflow: auto; }
.scenes .q { color: var(--text); }
@media (max-width: 680px) { .viewer { grid-template-columns: 1fr; } .viewer video { max-width: 280px; margin: 0 auto; } }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 160px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.menu-list button, .menu-list a {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; text-decoration: none; font-size: 13px; text-align: left; color: var(--text);
}
.menu-list button:hover, .menu-list a:hover { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.settings-nav { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { height: 34px; display: flex; align-items: center; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; }
.settings-nav a:hover { color: var(--text); background: var(--surface-2); }
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 22px; margin-bottom: 18px; scroll-margin-top: 76px; }
.card > h2 { font-size: 16px; font-weight: 600; }
.card > .desc { color: var(--muted); font-size: 13px; margin: 4px 0 18px; }
.card.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.status-pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); }
.status-pill.ok { color: var(--ok); }
.status-pill.warn { color: var(--warn); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 14px; }
.stat .n { font-size: 22px; font-weight: 700; }
.form-narrow { max-width: 420px; }
@media (max-width: 760px) {
  .settings { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .caption-setup { flex-direction: column; align-items: center; }
  .cap-controls { width: 100%; }
}

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; padding-bottom: 28px; font-size: 18px; }
.auth-card h1 { font-size: 24px; font-weight: 600; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 8px 0 26px; }
.auth-card .alt { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-card .alt a { color: var(--text); font-weight: 600; }
.auth-foot { text-align: center; margin-top: 28px; font-size: 12px; color: var(--muted); }
.link-row { display: flex; justify-content: flex-end; margin: -6px 0 14px; }
.link-row a, .text-link { font-size: 12.5px; color: var(--muted); }
.link-row a:hover, .text-link:hover { color: var(--text); }
.notice { text-align: center; padding: 8px 0; }
.notice .icon { width: 40px; height: 40px; margin-bottom: 14px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 380px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13px; font-weight: 500;
  background: var(--primary); color: var(--primary-text); box-shadow: var(--shadow); animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.app-loading { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--text); animation: spin 0.7s linear infinite; }

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