/* Social Brainbox — editorial, paper-first design system.
   Tokens → base → layout → components → pages. Light + dark are designed together. */

/* ---------- tokens ---------- */
:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-2: #F0EDE6;
  --ink: #1B1A17;
  --ink-2: #4E4B45;
  --muted: #74706A;
  --line: #E5E0D6;
  --line-strong: #CFC9BD;
  --accent: #2A55D6;
  --accent-hover: #1F44B3;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(42, 85, 214, .10);
  --ok: #1E7A4E;      --ok-soft: rgba(30, 122, 78, .12);
  --warn: #8F5E00;    --warn-soft: rgba(184, 122, 0, .14);
  --err: #B93232;     --err-soft: rgba(185, 50, 50, .12);
  --code-bg: #F0EDE6;
  --shadow-1: 0 1px 2px rgba(27, 26, 23, .05), 0 1px 1px rgba(27, 26, 23, .03);
  --shadow-2: 0 4px 16px rgba(27, 26, 23, .08), 0 1px 3px rgba(27, 26, 23, .05);
  --radius-s: 8px; --radius: 12px; --radius-l: 18px;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 150ms; --t: 220ms;
  --nav-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1C1B18;
    --surface-2: #252420;
    --ink: #ECE9E2;
    --ink-2: #C9C5BC;
    --muted: #9C978D;
    --line: #2F2D28;
    --line-strong: #43403A;
    --accent: #8AA6FF;
    --accent-hover: #A7BBFF;
    --on-accent: #0E1A3E;
    --accent-soft: rgba(138, 166, 255, .14);
    --ok: #62CF98;     --ok-soft: rgba(98, 207, 152, .14);
    --warn: #E5B54B;   --warn-soft: rgba(229, 181, 75, .14);
    --err: #F08A8A;    --err-soft: rgba(240, 138, 138, .14);
    --code-bg: #252420;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 6px 20px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(28px, 4vw, 38px); letter-spacing: -0.015em; }
h2 { font-size: 20px; margin-top: 40px; margin-bottom: 12px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
ul, ol { margin: 0 0 12px; padding-left: 22px; }
li { margin: 4px 0; }
code, pre, kbd { font-family: var(--font-mono); font-size: .875em; }
pre { margin: 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px 16px; overflow-x: auto; line-height: 1.5; }
code.inline { background: var(--code-bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
img { max-width: 100%; display: block; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-display); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 1000; }
.skip-link:focus { left: 8px; }

/* ---------- layout ---------- */
.container { width: min(1040px, 100% - 40px); margin-inline: auto; }
.container.narrow { width: min(760px, 100% - 40px); }
main { padding: 32px 0 80px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--muted); margin: 6px 0 0; }
@media (max-width: 640px) { .container, .container.narrow { width: min(100% - 32px, 1040px); } main { padding-top: 20px; } }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 40; height: var(--nav-h); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--line); }
.nav .container { display: flex; align-items: center; gap: 6px; height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 21px; font-weight: 500; color: var(--ink); margin-right: 18px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--on-accent); }
.brand .mark .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.nav a.item, .nav button.item { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; border-radius: 10px; color: var(--ink-2); font-size: 14.5px; font-weight: 500; border: 0; background: none; cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.nav a.item:hover, .nav button.item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.item.active { color: var(--ink); background: var(--surface-2); }
.nav .spacer { flex: 1; }
.nav .user { color: var(--muted); font-size: 14px; margin-right: 4px; }
@media (max-width: 720px) {
  .nav a.item span, .nav button.item span, .nav .user { display: none; }
  .nav a.item, .nav button.item { padding: 0 10px; }
  .brand { font-size: 19px; margin-right: 8px; }
}
@media (max-width: 400px) { .brand > span:last-child { display: none; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast); text-decoration: none; touch-action: manipulation; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: progress; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--err); border-color: transparent; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.icon-only { width: 44px; padding: 0; }
.btn.icon-only.sm { width: 36px; }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input.error { border-color: var(--err); }
.field .help { font-size: 13px; color: var(--muted); }
.field .err { font-size: 13px; color: var(--err); display: flex; gap: 6px; align-items: center; }
.errorlist { margin: 0; padding: 0; list-style: none; color: var(--err); font-size: 13.5px; }
.helptext { display: none; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--line); }
.seg label { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast); user-select: none; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow-1); }
.card.flush { padding: 0; overflow: hidden; }
.card h3 { margin-bottom: 8px; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 14.5px; }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.err { background: var(--err-soft); border-color: transparent; color: var(--err); }
.callout .icon { margin-top: 2px; }

/* ---------- badges / tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; letter-spacing: .01em; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--err-soft); color: var(--err); }
.badge.queued, .badge.downloading, .badge.transcribing, .badge.extracting, .badge.enriching { background: var(--warn-soft); color: var(--warn); }
.badge.mode { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag { display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; text-decoration: none; transition: background var(--t-fast), border-color var(--t-fast); }
a.tag:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent); text-decoration: none; }
.tag .count { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

/* ---------- composer (dashboard) ---------- */
.composer { padding: 20px 22px; }
.composer .modes { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.composer .hint { color: var(--muted); font-size: 14px; }
.composer .inline { display: flex; gap: 10px; }
.composer .inline .input { flex: 1; height: 48px; font-size: 16px; }
.composer .inline .btn { height: 48px; }
.dropzone { margin-top: 12px; border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 16px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.dropzone input { display: none; }
.dropzone .file { color: var(--ink); font-weight: 500; }
.composer details { margin-top: 12px; }
.composer summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; cursor: pointer; }
.composer summary::-webkit-details-marker { display: none; }
.composer summary:hover { color: var(--ink); }
.composer details[open] summary .icon { transform: rotate(180deg); }
.composer .status { min-height: 20px; margin-top: 10px; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.composer .status.ok { color: var(--ok); }
.composer .status.err { color: var(--err); }
@media (max-width: 560px) { .composer .inline { flex-direction: column; } }

/* ---------- saves list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 36px 0 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 4px; }
.filters button { height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.filters button:hover { background: var(--surface-2); color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.saves { list-style: none; margin: 0; padding: 0; }
.save-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); transition: background var(--t-fast); }
.card.flush .save-row:first-child { border-top: 0; }
.save-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.save-row .title { font-family: var(--font-display); font-size: 18px; font-weight: 500; color: var(--ink); line-height: 1.3; }
.save-row .title.pending { font-family: var(--font-ui); font-size: 15px; font-weight: 500; color: var(--ink-2); word-break: break-all; }
.save-row .title:hover { text-decoration: underline; text-underline-offset: 3px; }
.save-row .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 4px; }
.save-row .meta .icon { width: 14px; height: 14px; }
.save-row .err { color: var(--err); font-size: 13px; margin-top: 4px; }
.save-row .side { display: flex; align-items: center; gap: 8px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; margin: 0 auto 10px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.row-enter { animation: rise var(--t) var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- detail ---------- */
.detail-head { margin-bottom: 20px; }
.detail-head .kicker { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: 14px; margin: 10px 0 12px; }
.detail-head .kicker .icon { width: 15px; height: 15px; }
.detail-head .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.summary { font-size: 17px; line-height: 1.6; color: var(--ink); }
.summary ul { margin-top: 12px; }
.stepper { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 18px 20px; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.step.done { color: var(--ink-2); } .step.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.active { color: var(--ink); font-weight: 600; } .step.active .n { border-color: var(--accent); color: var(--accent); }
.concepts { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.concepts li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--line); }
.concepts li:first-child { border-top: 0; padding-top: 0; }
.concepts b { font-weight: 600; }
.ts { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 2px 7px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.section { display: grid; grid-template-columns: 240px 1fr; gap: 20px; padding: 22px 0; border-top: 1px solid var(--line); }
.section:first-of-type { border-top: 0; padding-top: 6px; }
.section .frame-wrap { position: relative; }
.section .frame { border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.section .frame.portrait { aspect-ratio: 9 / 16; max-height: 320px; width: auto; }
.section h3 { font-family: var(--font-display); font-size: 21px; font-weight: 500; margin-bottom: 8px; }
.section .lbl { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 2px; }
.section p { color: var(--ink); }
@media (max-width: 680px) { .section { grid-template-columns: 1fr; } .section .frame.portrait { max-height: 260px; } }
.transcript { white-space: pre-wrap; line-height: 1.7; }
.transcript .t { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
details.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.panel summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; cursor: pointer; font-weight: 500; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary .icon { transition: transform var(--t) var(--ease); color: var(--muted); }
details.panel[open] summary .icon { transform: rotate(180deg); }
details.panel .body { padding: 0 20px 18px; }

/* ---------- search ---------- */
.searchbar { display: flex; gap: 10px; }
.searchbar .input { height: 52px; font-size: 17px; padding-left: 44px; }
.searchbar .wrap { position: relative; flex: 1; }
.searchbar .wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.result { padding: 18px 0; border-top: 1px solid var(--line); }
.result:first-child { border-top: 0; }
.result h3 { font-family: var(--font-display); font-size: 20px; font-weight: 500; margin-bottom: 4px; }
.result .score { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-left: 8px; }

/* ---------- settings ---------- */
.token { display: flex; align-items: center; gap: 8px; }
.token code { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); }
.stat .v { font-family: var(--font-display); font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- auth / landing ---------- */
.auth { width: min(420px, 100% - 32px); margin: 8vh auto; }
.auth h1 { margin-bottom: 20px; }
.auth form { display: grid; gap: 14px; }
.hero { padding: clamp(48px, 10vh, 120px) 0 40px; }
.hero h1 { font-size: clamp(40px, 7vw, 76px); font-weight: 500; letter-spacing: -0.02em; line-height: 1.02; max-width: 14ch; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero .lede { font-size: clamp(17px, 2vw, 21px); color: var(--ink-2); max-width: 52ch; margin: 22px 0 30px; line-height: 1.5; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 56px; }
.feature { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.feature .icon { width: 22px; height: 22px; color: var(--accent); margin-bottom: 12px; }
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--ink-2); font-size: 14.5px; margin: 0; }
.flow { margin-top: 64px; padding: 28px; border-radius: var(--radius-l); background: var(--surface-2); border: 1px solid var(--line); }
.flow ol { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; counter-reset: s; list-style: none; padding: 0; margin: 0; }
.flow li { counter-increment: s; font-size: 14.5px; color: var(--ink-2); }
.flow li::before { content: counter(s, decimal-leading-zero); display: block; font-family: var(--font-display); font-size: 22px; color: var(--accent); margin-bottom: 6px; }
.flow li b { color: var(--ink); display: block; margin-bottom: 2px; }

/* ---------- toast / dialog ---------- */
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-2); animation: rise var(--t) var(--ease); }
.toast .icon { color: var(--bg); }
.toast.err { background: var(--err); color: #fff; }
dialog.confirm { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 24px; width: min(420px, 100% - 32px); box-shadow: var(--shadow-2); }
dialog.confirm::backdrop { background: rgba(0, 0, 0, .45); }
dialog.confirm h3 { margin-bottom: 6px; }
dialog.confirm p { color: var(--ink-2); font-size: 14.5px; }
dialog.confirm .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.messages { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.messages li { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-size: 14.5px; font-weight: 500; }

/* ---------- setup checklist ---------- */
.checklist { margin-bottom: 28px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.checklist .progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 4px 0 18px; }
.checklist .progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width var(--t) var(--ease); }
.checklist .steps { list-style: none; margin: 0; padding: 0; }
.checklist .steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.checklist .steps li:first-child { border-top: 0; padding-top: 0; }
.checklist .mark { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.checklist li.done .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist li.done .text b { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.checklist li.done .text p { display: none; }
.checklist li.na { opacity: .6; }
.checklist .text b { display: block; font-weight: 600; }
.checklist .text p { margin: 3px 0 0; color: var(--ink-2); font-size: 14px; max-width: 62ch; }
.checklist .do { padding-top: 2px; }
@media (max-width: 560px) { .checklist .steps li { grid-template-columns: 28px 1fr; } .checklist .do { grid-column: 2; } }

/* ---------- key/value settings rows ---------- */
.kv { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.kv > div { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.kv > div:first-child { border-top: 0; }
.kv .k { width: 130px; flex: none; font-size: 13px; color: var(--muted); }
.kv code { font-size: 13.5px; }

/* ---------- brain ---------- */
.shelves { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.shelf { display: grid; grid-template-rows: auto auto 1fr; gap: 4px; padding: 18px 18px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1); transition: border-color var(--t-fast), transform var(--t-fast) var(--ease), box-shadow var(--t-fast); }
.shelf:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.shelf .n { font-family: var(--font-display); font-size: 30px; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.shelf b { font-size: 15.5px; margin-top: 6px; }
.shelf .hint { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.badge.cat { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.badge.cat:hover { text-decoration: none; filter: brightness(.95); }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.note-card { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease); }
.note-card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.note-card h3 { font-family: var(--font-display); font-size: 19px; font-weight: 500; line-height: 1.25; }
.note-card p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; flex: 1; }
.note-card .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--muted); font-size: 12.5px; }
.note-card .tags .tag { height: 24px; font-size: 12px; padding: 0 9px; }
.checklist li.opt .mark { border-style: dashed; }

/* ---------- graph ---------- */
:root { --graph-cat: #2A55D6; --graph-topic: #C2410C; --graph-note: #0E8A6B; }
@media (prefers-color-scheme: dark) { :root { --graph-cat: #6584EE; --graph-topic: #D2742D; --graph-note: #2FA085; } }
.graph-panel { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; box-shadow: var(--shadow-1); display: flex; flex-direction: column; }
.graph-panel canvas { flex: 1; width: 100%; min-height: 0; display: block; cursor: grab; touch-action: none; }
.graph-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent); flex-wrap: wrap; }
.graph-bar .input { width: 200px; min-height: 36px; padding: 6px 12px; font-size: 14px; margin-left: auto; }
.graph-legend { display: flex; gap: 14px; align-items: center; font-size: 13px; color: var(--ink-2); }
.graph-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.graph-legend i { display: inline-block; border-radius: 50%; }
.graph-legend i.dash { width: 18px; height: 0; border-top: 2px dashed var(--accent); border-radius: 0; }
.graph-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: 13px; max-width: 280px; box-shadow: var(--shadow-2); display: grid; gap: 2px; }
.graph-tip span { opacity: .75; font-size: 12px; }
.graph-help { position: absolute; left: 14px; bottom: 8px; margin: 0; pointer-events: none; }
@media (max-width: 640px) { .graph-help { display: none; } .graph-bar .input { width: 100%; margin-left: 0; } }

/* ---------- share landing + phone setup ---------- */
.share-landing { text-align: center; display: grid; gap: 10px; justify-items: center; max-width: 440px; }
.share-landing h1 { font-size: 26px; }
.share-landing .state { display: grid; gap: 10px; justify-items: center; }
.share-landing .url { word-break: break-all; max-width: 100%; }
.share-landing .row { justify-content: center; margin-top: 8px; }
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 14px; }
.howto > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); }
.howto b { display: block; margin-bottom: 6px; }
.howto ol { margin: 0; padding-left: 18px; }

/* ---------- themes (collections) ---------- */
.theme { margin: 28px 0 8px; }
.theme-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.theme-head h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 22px; }
.theme-head h2 a { color: var(--ink); text-decoration: none; }
.theme-head h2 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.theme-head p { margin: 4px 0 0; max-width: 70ch; }
.note-card.theme-card h3 { font-size: 20px; }
.note-card.theme-card .meta { order: -1; }

/* ---------- share setup (getting the site into a phone's share sheet) ---------- */
.setup-steps { margin: 14px 0 0; padding-left: 20px; display: grid; gap: 12px; }
.setup-steps li { line-height: 1.55; }
.setup-steps .muted { display: block; font-size: 13px; margin-top: 2px; }
.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0;
            padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s);
            background: var(--surface-2); }
.copy-value { flex: 1 1 200px; font-family: var(--font-mono); font-size: 13px; word-break: break-all; }
.setup-diy { margin-top: 16px; }
.setup-diy summary { cursor: pointer; color: var(--muted); }
.setup-phone h3 { display: flex; align-items: center; gap: 8px; }
