/* AI Newsroom — design system
 * Tokens first, then shell (sidebar, topbar), then components. Class names are shared with app.js. */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-tint: #eef1f6;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --panel-hover: #f1f3f7;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --faint: #9aa3b2;
  --line: #e5e7eb;
  --line-strong: #d6dae1;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #ffffff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #be123c;
  --bad-soft: #fff1f2;
  --info: #0369a1;
  --chip: #f1f3f6;
  --sidebar: #0f172a;
  --sidebar-ink: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1e1b4b;
  --shadow-xs: 0 1px 2px rgb(16 24 40 / 5%);
  --shadow: 0 1px 3px rgb(16 24 40 / 6%), 0 1px 2px rgb(16 24 40 / 4%);
  --shadow-lg: 0 12px 32px -8px rgb(16 24 40 / 18%);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", Tahoma, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Consolas, monospace;
  --sidebar-w: 248px;
  --topbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f17; --bg-tint: #0f1520; --panel: #121826; --panel-soft: #161d2c; --panel-hover: #1b2335;
    --ink: #e8ecf3; --ink-2: #c7cfdc; --muted: #94a0b4; --faint: #6b778c; --line: #232c3d; --line-strong: #2e3a50;
    --accent: #818cf8; --accent-strong: #a5b4fc; --accent-soft: #1e1b4b; --accent-ink: #0b0f17;
    --ok: #34d399; --ok-soft: #052e22; --warn: #fbbf24; --warn-soft: #2d2205; --bad: #fb7185; --bad-soft: #3a0d18; --info: #38bdf8;
    --chip: #1b2335; --sidebar: #080b12; --sidebar-hover: #141b2a; --sidebar-active: #1e1b4b;
    --shadow-xs: none; --shadow: 0 1px 2px rgb(0 0 0 / 40%); --shadow-lg: 0 16px 40px -8px rgb(0 0 0 / 60%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17; --bg-tint: #0f1520; --panel: #121826; --panel-soft: #161d2c; --panel-hover: #1b2335;
  --ink: #e8ecf3; --ink-2: #c7cfdc; --muted: #94a0b4; --faint: #6b778c; --line: #232c3d; --line-strong: #2e3a50;
  --accent: #818cf8; --accent-strong: #a5b4fc; --accent-soft: #1e1b4b; --accent-ink: #0b0f17;
  --ok: #34d399; --ok-soft: #052e22; --warn: #fbbf24; --warn-soft: #2d2205; --bad: #fb7185; --bad-soft: #3a0d18; --info: #38bdf8;
  --chip: #1b2335; --sidebar: #080b12; --sidebar-hover: #141b2a; --sidebar-active: #1e1b4b;
  --shadow-xs: none; --shadow: 0 1px 2px rgb(0 0 0 / 40%); --shadow-lg: 0 16px 40px -8px rgb(0 0 0 / 60%);
}

/* ------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14.5px/1.6 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"] body { font-size: 15px; line-height: 1.7; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .icon.flip { transform: scaleX(-1); }

/* ------------------------------------------------------------ shell */
.app-shell { min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  background: linear-gradient(var(--sidebar), var(--sidebar)) left top / var(--sidebar-w) 100% no-repeat; }
[dir="rtl"] .app-shell { background-position: right top; }
.sidebar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-direction: column; gap: 18px;
  height: 100dvh; padding: 18px 12px 14px;
  background: var(--sidebar); color: var(--sidebar-ink);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 6px; }
.brand > div { display: grid; line-height: 1.25; min-width: 0; }
.brand strong { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.brand > div > span { color: var(--sidebar-muted); font-size: 12px; }
.brand-mark {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #ec4899 120%);
  color: #fff; font-size: 13px; font-weight: 800; letter-spacing: .02em;
  box-shadow: 0 6px 16px -4px rgb(99 102 241 / 60%);
}
.sidebar-nav { display: grid; align-content: start; gap: 18px; overflow-y: auto; overflow-x: hidden; margin-inline: -4px; padding-inline: 4px; scrollbar-width: thin; scrollbar-color: var(--sidebar-hover) transparent; }
.nav-group { display: grid; gap: 2px; }
.nav-group-label, .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.eyebrow { color: var(--muted); }
.nav-group-label { padding: 0 10px 6px; color: var(--sidebar-muted); }
[dir="rtl"] .nav-group-label, [dir="rtl"] .eyebrow { letter-spacing: 0; text-transform: none; font-size: 12px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--sidebar-ink); font-size: 13.5px; text-align: start; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.nav-link .icon { width: 17px; height: 17px; color: var(--sidebar-muted); transition: color .15s ease; }
.nav-link > .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link:hover .icon { color: #fff; }
.nav-link[aria-current="page"] { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-link[aria-current="page"] .icon { color: #a5b4fc; }
.nav-link[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -4px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #818cf8; }
[dir="rtl"] .nav-link[aria-current="page"]::before { border-radius: 3px 0 0 3px; }
.nav-badge { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: #6366f1; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.nav-badge.warn { background: #f59e0b; color: #111827; }
.sidebar-footer { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid var(--sidebar-hover); color: var(--sidebar-muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgb(52 211 153 / 18%); }
.sidebar-scrim { display: none; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--topbar-h); padding: 10px clamp(16px, 3vw, 36px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(160%) blur(12px);
}
.topbar-start { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { display: grid; gap: 0; min-width: 0; }
.topbar-title .eyebrow { font-size: 11px; }
.topbar-title strong { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn.menu-toggle { display: none; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.who .user { display: flex; align-items: center; gap: 9px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); }
[dir="rtl"] .who .user { padding: 3px 3px 3px 10px; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-size: 12px; font-weight: 700; }
.who .user .chip { margin: 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink-2); cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--panel-hover); color: var(--ink); border-color: var(--line-strong); }
.icon-btn.text { display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 11px; font-size: 13px; font-weight: 600; }

main { width: min(100%, 1280px); margin: 0 auto; padding: clamp(20px, 3vw, 36px) clamp(16px, 3vw, 36px) 64px; animation: page-in .22s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ type */
main > h2:first-child { margin: 0 0 22px; font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; line-height: 1.25; letter-spacing: -.025em; }
h2 { font-size: 20px; font-weight: 700; line-height: 1.3; margin: 0 0 12px; letter-spacing: -.02em; }
h3 { font-size: 15px; font-weight: 650; line-height: 1.4; margin: 28px 0 10px; letter-spacing: -.01em; color: var(--ink); }
h4 { font-size: 14px; font-weight: 650; margin: 16px 0 6px; }
.card > h3:first-child, .card > b:first-child { margin-top: 0; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
small { color: var(--muted); }

/* ------------------------------------------------------------ surfaces */
.card {
  min-width: 0; padding: clamp(16px, 2vw, 20px); margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow-xs);
}
.card > h3:first-child { margin-bottom: 8px; }
.card .card { box-shadow: none; background: var(--panel-soft); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr)); }
.cols { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.empty { color: var(--muted); padding: 32px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel-soft); text-align: center; font-size: 13.5px; }

/* stats / KPI cards */
.stat { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; min-height: 120px; overflow: hidden; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.stat[style*="cursor:pointer"], .stat.link { cursor: pointer; }
.stat[style*="cursor:pointer"]:hover, .stat.link:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); box-shadow: var(--shadow-lg); }
.stat b { font-size: clamp(28px, 3.4vw, 34px); font-weight: 700; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.stat .stat-icon { position: absolute; inset-inline-end: 16px; top: 16px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.stat.tone-warn .stat-icon { background: var(--warn-soft); color: var(--warn); }
.stat.tone-ok .stat-icon { background: var(--ok-soft); color: var(--ok); }
.stat.tone-bad .stat-icon { background: var(--bad-soft); color: var(--bad); }
.stat.hot { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: linear-gradient(180deg, var(--accent-soft), var(--panel) 70%); }

/* dashboard */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.hero h2 { margin: 2px 0 2px; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -.03em; }
.hero p { margin: 0; color: var(--muted); }
.hero .row { margin: 0; }
.dash-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 10px; }
.section-head h3 { margin: 0; }
.section-head .link-btn { border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.section-head .link-btn:hover { background: var(--accent-soft); }
.queue { display: flex; flex-wrap: wrap; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 9px 0 9px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { grid-row: span 2; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--line-strong); }
.timeline .dot.ai { background: #8b5cf6; } .timeline .dot.human { background: var(--accent); } .timeline .dot.system { background: var(--faint); }
.timeline .what { font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
.timeline .meta { font-size: 12px; color: var(--muted); }

/* tables */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th, td { text-align: start; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { position: sticky; top: 0; background: var(--panel-soft); color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
[dir="ltr"] th { letter-spacing: .02em; }
tr:last-child td { border-bottom: 0; }
.table-card td:first-child { white-space: nowrap; }
tbody tr { transition: background .12s ease; }
tr.click { cursor: pointer; }
tr.click:hover, tbody tr:hover { background: var(--panel-hover); }
.selected-row, tr.selected-row:hover { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
[dir="rtl"] .selected-row { box-shadow: inset -3px 0 var(--accent); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; width: fit-content; max-width: 100%; padding: 2px 9px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 1.6; margin-inline-end: 4px; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }

/* buttons */
button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 14px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  font-size: 13.5px; font-weight: 600; text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgb(255 255 255 / 12%);
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
button.btn:hover, a.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.btn:active { transform: translateY(1px); }
button.btn.secondary { border-color: var(--line-strong); background: var(--panel); color: var(--ink); box-shadow: var(--shadow-xs); }
button.btn.secondary:hover { background: var(--panel-hover); }
button.btn.danger { border-color: var(--bad); background: var(--bad); color: #fff; }
button.btn.danger:hover { filter: brightness(.94); }
button.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.review-actions {
  position: sticky; bottom: 12px; z-index: 3;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(12px);
}
.review-actions .btn { min-width: 112px; }

/* forms */
label { display: block; color: var(--ink-2); font-size: 12.5px; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); font: inherit; font-size: 14px;
  box-shadow: var(--shadow-xs);
  transition: border-color .14s ease, box-shadow .14s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input:disabled, select:disabled, textarea:disabled { background: var(--panel-soft); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; margin: 0 7px 0 0; padding: 0; vertical-align: middle; accent-color: var(--accent); box-shadow: none; }
[dir="rtl"] input[type="checkbox"] { margin: 0 0 0 7px; }
input[type="file"] { padding: 6px; }
textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
select { cursor: pointer; }
.inline { display: inline-block; width: auto; }
.check-label { display: flex; align-items: center; gap: 4px; font-weight: 500; color: var(--ink); }
.inline-check { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-weight: 500; cursor: pointer; }
progress { accent-color: var(--accent); }
audio { width: 100%; max-width: 560px; height: 40px; }

/* tabs */
.tabs-wrap { min-width: 0; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 0 16px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-soft); width: fit-content; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; border-radius: 8px; color: var(--muted); padding: 7px 14px; font: inherit; font-size: 13.5px; font-weight: 550; white-space: nowrap; cursor: pointer; transition: background .15s ease, color .15s ease; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--panel); color: var(--ink); font-weight: 650; box-shadow: var(--shadow); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tab-panel > .card:first-child { margin-top: 0; }
.settings-save { position: sticky; bottom: 0; z-index: 2; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); border-top: 1px solid var(--line); }
.settings-save[hidden] { display: none; }

/* editorial pieces */
.sentence { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sentence:last-child { border-bottom: 0; }
.sentence .n { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 7px; background: var(--chip); color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sentence .t { flex: 1; line-height: 1.85; }
.gate-guidance { margin-bottom: 12px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--bad) 22%, var(--line)); border-inline-start: 3px solid var(--bad); border-radius: var(--radius); background: var(--bad-soft); }
.gate-guidance > strong { color: var(--bad); }
.gate-guidance > p { margin: 6px 0 12px; }
.gate-help + .gate-help { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.gate-help > p { margin: 3px 0 0; color: var(--muted); }
.gate-result { padding: 5px 0; }
.gate-detail { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-inline-start: 8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.gate-detail > span { font-weight: 650; }
.blocked-story-actions { margin-top: 12px; }
.blocked-story-actions > label { color: var(--ink); }
.story-review-card { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); box-shadow: 0 0 0 4px var(--accent-soft); }
.verification-card { border-inline-start: 3px solid var(--warn); }
.source-url { overflow-wrap: anywhere; word-break: break-word; font-size: 12.5px; }
.data-details { margin: 10px 0; }
.data-details summary, details > summary { color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; list-style-position: inside; }
details.card > summary { color: var(--ink); }
.data-details pre { margin-bottom: 0; }
pre { max-height: 300px; overflow: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-soft); color: var(--ink); font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.checkpoint-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(140px, .7fr) minmax(140px, auto) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.checkpoint-row > b { min-width: 0; }
.checkpoint-row > select { max-width: 220px; }
.checkpoint-row .sample-rate { margin: 0; white-space: nowrap; }
.checkpoint-row .sample-rate[hidden] { display: none; }
.checkpoint-row .sample-rate input { margin-inline-start: 6px; }
.eye-issues { margin: 6px 0 0; padding-inline-start: 18px; }
.eye-issues li { margin: 4px 0; line-height: 1.6; }
.eye-settings { margin-top: 10px; box-shadow: none; border-inline-start: 3px solid var(--accent); }
.entry-frozen { opacity: .6; }
.entry-frozen:hover, .entry-frozen:focus-within { opacity: 1; }
.cleanup-result { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.processing-card { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.processing-card progress { display: block; width: 100%; height: 6px; margin: 14px 0 10px; }
.processing-spinner, .btn.is-working::before { content: ""; display: inline-block; width: 15px; height: 15px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: processing-spin .8s linear infinite; flex-shrink: 0; }
.btn.is-working::before { margin-inline-end: 6px; vertical-align: middle; }
@keyframes processing-spin { to { transform: rotate(360deg); } }

/* toast */
.toast {
  position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 50;
  display: flex; align-items: flex-start; gap: 10px;
  max-width: min(440px, calc(100vw - 32px)); padding: 12px 16px;
  border: 1px solid var(--line); border-inline-start: 3px solid var(--ok); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: toast-in .2s ease-out;
}
.toast.err { border-inline-start-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* chat */
.chat { display: flex; flex-direction: column; gap: 12px; min-height: 340px; max-height: min(72vh, 900px); overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-tint); scroll-behavior: smooth; }
.chat-card > textarea { min-height: 96px; margin-top: 12px; }
.chat-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.chat-footer .row { margin: 4px 0; }
.chat-empty { margin: auto; border: 0; background: none; }
.msg { max-width: min(86%, 820px); padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow-xs); line-height: 1.7; }
.msg.user { align-self: flex-end; border-color: transparent; border-end-end-radius: 4px; background: var(--accent); color: var(--accent-ink); }
.msg.assistant { align-self: flex-start; border-end-start-radius: 4px; }
.msg.update { border-style: dashed; background: var(--panel-soft); }
.msg-group { display: flex; flex-direction: column; gap: 8px; max-width: min(96%, 900px); }
.msg-group.assistant { align-self: flex-start; width: min(96%, 900px); }
.msg-group .msg { max-width: 100%; align-self: flex-start; }
.tools { font-size: 11.5px; color: var(--muted); margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line); }
.chat-choice { margin: 0; border-inline-start: 3px solid var(--accent); }
.chat-selectors { margin-bottom: 8px; }
.stage-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.stage { padding: 2px 9px; border-radius: 999px; background: var(--chip); color: var(--muted); font-size: 12px; }
.stage.done { color: var(--ok); background: var(--ok-soft); }
.stage.now { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.live-steps { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); margin: 6px 2px 0; min-height: 0; }
.live-step.running { color: var(--ink); }
.btn[hidden], button[hidden] { display: none !important; }

/* login */
.login-screen {
  min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 26px; padding: 24px;
  background: radial-gradient(60rem 30rem at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg);
}
.login-brand { display: flex; align-items: center; gap: 13px; }
.login-brand h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.login-brand p { margin: 2px 0 0; color: var(--muted); }
.login { width: min(420px, calc(100vw - 32px)); margin: 0; padding: 28px; box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); }
.login h2 { margin-top: 4px; }
.login .row { margin-top: 20px; }
.login .btn { width: 100%; min-height: 42px; }

/* sign-in through Clerk */
.link-btn { border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--accent-soft); }
.clerk-mount { display: flex; justify-content: center; min-height: 120px; }
.clerk-mount.wide { display: block; overflow-x: auto; }
.station-switcher { padding: 10px 4px 2px; }
button.user { cursor: pointer; font: inherit; }

/* platform */
.ceiling { display: grid; gap: 4px; min-width: 140px; }
.ceiling-bar { height: 6px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.ceiling-bar i { display: block; height: 100%; background: var(--accent); }
.ceiling-bar i.warn { background: var(--warn); }
.ceiling-bar i.bad { background: var(--bad); }
.plan-row + .plan-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

.prev-chat { justify-content: space-between; margin: 4px 0; padding: 4px 0; border-bottom: 1px solid var(--line); }
.prev-chat.current .link-btn { font-weight: 700; }

/* side-menu tooltips (floating, on <body>) */
.nav-tooltip {
  position: fixed; z-index: 60; transform: translateY(-50%) translateX(-4px);
  max-width: 280px; padding: 9px 12px; border-radius: 10px;
  background: var(--ink); color: var(--panel); font-size: 13px; line-height: 1.55; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease;
}
[dir="rtl"] .nav-tooltip { transform: translateY(-50%) translateX(4px); }
.nav-tooltip.show { opacity: 1; transform: translateY(-50%); }
@media (max-width: 900px) { .nav-tooltip { display: none; } }

/* ⓘ tooltips */
.info-tip { position: relative; display: inline-grid; place-items: center; margin-inline-start: 8px; color: var(--faint); cursor: help; vertical-align: middle; border-radius: 50%; }
.info-tip .icon { width: 18px; height: 18px; }
.info-tip:hover, .info-tip:focus-visible, .info-tip.open { color: var(--accent); outline: none; }
.info-tip::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 8px); inset-inline-start: -8px; z-index: 30;
  width: max-content; max-width: min(340px, 80vw); padding: 10px 12px; border-radius: 10px;
  background: var(--ink); color: var(--panel); font-size: 13px; font-weight: 500; line-height: 1.6; letter-spacing: 0; white-space: normal;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity .12s ease, transform .12s ease;
}
.info-tip:hover::after, .info-tip:focus-visible::after, .info-tip.open::after { opacity: 1; transform: none; }

/* help */
.help-search { position: relative; max-width: 520px; margin-bottom: 18px; }
.help-search .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.help-search input { padding-inline-start: 38px; min-height: 42px; border-radius: 11px; }
.help-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 22px; align-items: start; }
.help-toc { position: sticky; top: calc(var(--topbar-h) + 16px); display: grid; gap: 2px; max-height: calc(100dvh - var(--topbar-h) - 40px); overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.help-toc-link { padding: 7px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink-2); font-size: 13.5px; text-align: start; cursor: pointer; }
.help-toc-link:hover { background: var(--panel-hover); color: var(--ink); }
.help-section { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.help-section .section-head { margin: 0 0 6px; }
.help-section p { color: var(--ink-2); line-height: 1.75; }
.help-steps, .help-list { margin: 8px 0; padding-inline-start: 22px; color: var(--ink-2); line-height: 1.75; }
.help-steps li, .help-list li { margin: 5px 0; padding-inline-start: 4px; }
.help-steps li::marker { color: var(--accent); font-weight: 700; }
.help-tip { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 4px; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: 13.5px; line-height: 1.7; }
.help-tip .icon { margin-top: 3px; color: var(--accent); }
.help-section[hidden] { display: none; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: 1fr; }
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; max-height: none; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 900px) {
  .app-shell { display: block; background: none; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(290px, 84vw); height: 100dvh;
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .app-shell.nav-open .sidebar { transform: none; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 15; background: rgb(15 23 42 / 45%); backdrop-filter: blur(2px); }
  .app-shell.nav-open .sidebar-scrim { display: block; }
  .icon-btn.menu-toggle { display: inline-grid; }
  html, body { overflow-x: clip; }
  .sidebar { visibility: hidden; }
  .app-shell.nav-open .sidebar { visibility: visible; }
  .who .user .name { display: none; }
}
@media (max-width: 600px) {
  body { font-size: 14px; }
  .topbar { padding: 8px 14px; gap: 8px; }
  .topbar-title .eyebrow { display: none; }
  .who { gap: 6px; }
  .who .user { padding: 2px; border: 0; background: none; }
  .who .user .chip { display: none; }
  main { padding: 18px 14px 48px; }
  main > h2:first-child { margin-bottom: 16px; }
  .card { padding: 14px; border-radius: 11px; }
  th, td { padding: 10px 12px; }
  .msg { max-width: 94%; }
  .chat { min-height: 220px; max-height: 56vh; padding: 10px; }
  .checkpoint-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .checkpoint-row > select { max-width: none; }
  .checkpoint-row .sample-rate { grid-column: 1 / -1; }
  .tabs { width: 100%; }
  .table-card td:first-child { white-space: normal; }
  .icon-btn.text .lbl { display: none; }
  .icon-btn.text { width: 36px; padding: 0; justify-content: center; }
  .hero .row { width: 100%; }
  .hero .row .btn { flex: 1; }
  .stat { min-height: 104px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* setup wizard */
.setup { max-width: 860px; }
.setup-progress { display: flex; gap: 8px; margin: 4px 0 14px; }
.setup-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-strong); color: var(--muted); background: var(--panel); }
.setup-dot.done { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.setup-dot.now { background: var(--accent); color: var(--panel); border-color: var(--accent); }
.setup-card { display: grid; gap: 16px; }
.setup-field { display: grid; gap: 6px; }
.setup-field > label { font-weight: 600; }
.setup-field .muted { margin: 0; font-size: 13px; }
.setup-mediums, .setup-voices, .setup-optional { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.setup-voices { grid-template-columns: 1fr; }
.setup-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-medium, .setup-choice, .setup-chip, .setup-voice {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; }
.setup-choice { flex-direction: column; align-items: flex-start; gap: 2px; min-width: 140px; }
.setup-choice input, .setup-chip input { position: absolute; opacity: 0; pointer-events: none; }
.setup-chip { border-radius: 999px; padding: 6px 12px; position: relative; }
.setup-choice { position: relative; }
.setup-medium.on, .setup-choice.on, .setup-chip.on, .setup-voice.on { border-color: var(--accent); background: var(--accent-soft); }
.setup-medium.soon { opacity: .6; cursor: not-allowed; }
.setup-medium .chip { margin-inline-start: auto; }
.setup-voice { flex-wrap: wrap; }
.setup-voice-name { flex: 1; min-width: 160px; }
.setup-voice audio { width: 100%; }
.setup-link { display: grid; gap: 4px; text-align: start; cursor: pointer; border: 1px solid var(--line); }
.setup-link:hover { border-color: var(--accent); }
.setup-nav { margin-top: 14px; align-items: center; }
.setup textarea { width: 100%; }

/* platform console */
.platform-exit { margin: 6px 12px 12px; width: calc(100% - 24px); border: 1px dashed var(--sidebar-muted); border-radius: var(--radius-sm); }
.stat-link { cursor: pointer; text-align: start; border: 1px solid var(--line); }
.stat-link:hover { border-color: var(--accent); }

.suggested { border-color: var(--warn) !important; background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }
.calc-step { margin-bottom: 12px; } .calc-step h4 { margin-top: 0; }
tr.total td { border-top: 1px solid var(--line-strong); }

.calc-inputs { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.calc-field { display: grid; gap: 4px; }
.calc-field > label { font-weight: 600; }
.calc-field .muted { font-size: 12px; }
.calc-results .stat b { font-size: 30px; }
.calc-parts { margin: 8px 0 12px; color: var(--ink-2); }
.calc-details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.calc-details > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.calc-details[open] > summary { margin-bottom: 12px; }
.from-invoice { border-color: var(--ok) !important; background: color-mix(in srgb, var(--ok) 10%, var(--panel)); }

/* credits by day */
.day-bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 6px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.day-bar { position: relative; flex: 1 0 14px; height: 100%; display: flex; flex-direction: column-reverse; }
.day-bar i { display: block; width: 100%; }
.day-bar i.ours { background: var(--accent); border-radius: 3px 3px 0 0; }
.day-bar i.other { background: var(--line-strong); }
.day-bar span { position: absolute; bottom: -16px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline: 8px 4px; vertical-align: middle; }
.legend .dot.ours { background: var(--accent); } .legend .dot.other { background: var(--line-strong); }

/* platform console */
.platform-console .stat small { font-size: 12px; line-height: 1.4; }
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alert-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--panel-soft); border-inline-start: 3px solid var(--warn); }
.alert-list li.alert-bad { border-inline-start-color: var(--bad); }
.kv-grid { display: grid; gap: 12px 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.kv { display: grid; gap: 2px; min-width: 0; }
.kv strong { font-weight: 600; overflow-wrap: anywhere; }
.platform-console .row > label { min-width: 150px; margin: 0; }
.platform-console .row > input, .platform-console .row > select { width: auto; flex: 1 1 200px; max-width: 320px; }
a.nav-link { text-decoration: none; }
.day-bars.fit { overflow: visible; }
.day-bars.fit .day-bar { flex: 1 1 0; min-width: 0; }
@media (max-width: 640px) { .day-bars.fit.dense .day-bar:not(:nth-child(5n)) span { visibility: hidden; } }
.period-picker { display: grid; gap: 8px; margin: 0 0 6px; }
.period-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.period-tabs .btn { padding: 6px 12px; }
.period-custom > label { margin: 0; }
.period-custom > input { width: auto; }
.alert-list li.alert-ok { border-inline-start-color: var(--ok); }

/* plan and billing */
.billing-plans .plan-card { display: grid; gap: 6px; align-content: start; }
.billing-plans .plan-card.current { border-color: var(--accent); }
.plan-price { font-size: 26px; font-weight: 700; margin: 4px 0; }
.plan-price .muted { font-size: 14px; font-weight: 400; }
.plans-table input { margin: 0; }
.plans-table .row-actions { white-space: nowrap; }
.plans-table .row-actions .btn { margin-inline-end: 4px; }
.plans-table td { white-space: nowrap; }

/* support view (signed in as a customer) */
.impersonation-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid var(--warn); font-weight: 600; }
.impersonation-banner .icon { color: var(--warn); width: 18px; height: 18px; }

.mode-card.mode-live { border-color: var(--bad); }
.mode-card.mode-test { border-color: var(--warn); }

/* station usage */
.usage-meters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.usage-meter .usage-figure { font-size: 26px; font-weight: 700; margin: 6px 0; }
.usage-meter .usage-figure .muted { font-size: 15px; font-weight: 400; }

/* a customer in tabs (platform console) */
.customer-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 14px 0 18px; }
.customer-tabs .tab-btn { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; border-radius: 6px 6px 0 0; }
.customer-tabs .tab-btn:hover { color: var(--ink); background: var(--panel-soft); }
.customer-tabs .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.customer-tabs .tab-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-inline-start: 6px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 11px; line-height: 18px; text-align: center; }
.customer-pane > .section-head:first-child { margin-top: 0; }

/* compact period filter and profile (platform console) */
.period-picker.compact { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.period-picker.compact > .icon { width: 16px; height: 16px; color: var(--muted); }
.period-picker.compact .period-select { width: auto; min-width: 150px; padding: 6px 10px; font-size: 13px; }
.period-picker.compact .period-custom { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period-picker.compact .period-custom[hidden] { display: none; }
.period-picker.compact .period-custom input { width: auto; padding: 5px 8px; font-size: 13px; }
.period-picker.compact .period-custom .btn { padding: 5px 12px; }
.period-picker.compact .period-note { font-size: 12.5px; }
.profile-card { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px 18px; padding: 14px 16px; font-size: 13px; margin-bottom: 10px; }
.profile-card .kv strong { font-weight: 600; }

/* a customer, tidied */
.customer-head h2 { margin-bottom: 2px; }
.customer-head p { margin: 0 0 12px; font-size: 13px; }
.customer-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 14px 0 18px; }
.customer-bar .customer-tabs { border-bottom: 0; margin: 0; }
.customer-bar .period-picker.compact { margin: 0 0 6px; }
.chart-pair { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.chart-pair .card > b { display: block; margin-bottom: 6px; font-size: 13px; }
.customer-bar .customer-tabs { flex: 0 1 auto; }
.customer-bar .period-picker.compact { flex: 0 0 auto; margin-inline-start: auto; }
.chart-pair .day-bars.fit.dense .day-bar:not(:nth-child(5n)) span { visibility: hidden; }
.profile-card { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }

/* a section that opens on demand (platform console) */
.fold { margin: 22px 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.fold > summary { display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; font-weight: 650; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; color: var(--muted); transition: transform .15s ease; }
.fold[open] > summary::before { transform: rotate(90deg); }
[dir="rtl"] .fold > summary::before { content: "◂"; }
[dir="rtl"] .fold[open] > summary::before { transform: rotate(-90deg); }
.fold > .table-wrap, .fold > .empty { margin: 0 12px 12px; }

/* the credits a button will cost, beside it */
.estimate { font-size: 12px; align-self: center; white-space: nowrap; }

/* the story's verification checks: one per line, its explanation beside it */
.verify-actions { display: grid; gap: 8px; margin: 6px 0 12px; }
.verify-actions .row { flex-wrap: nowrap; align-items: center; }
.verify-actions .row .btn { flex: 0 0 auto; min-width: 120px; }
@media (max-width: 640px) { .verify-actions .row { flex-wrap: wrap; } }
/* dashboard: each group fills its row, so no card is left alone on a line */
.stat-group { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-bottom: 8px; }
