/* Scrollsake. One stylesheet, no build step.
   Tokens, base, layout, components, pages.
   Written for a 360px screen first: every media query is min-width and only adds.
   Flat surfaces, hairlines, small radii. Light and dark share one structure.

   The palette is the logo's: a coral box, a lavender card, a plum wordmark.
   Coral fills the one primary action on a page (with plum text, which is what passes
   contrast on it). Violet, the deep end of the lavender, is for links, focus and
   whatever is selected. Plum is the ink, and the greys lean toward it. */

/* ---------- tokens ---------- */
:root {
  --canvas: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F7F3F5;        /* sunken: code, hover, the map's ground */
  --surface-3: #EDE5EA;        /* selected, pressed */
  --surface-raised: #FFFFFF;   /* dialogs */
  --text: #25101F;
  --text-2: #4B3A46;
  --text-muted: #6F5F6B;
  --line: #EAE2E7;             /* dividers */
  --line-strong: #958893;      /* control boundaries, 3:1 against the surface */
  --brand: #F4695C;
  --brand-hover: #EE5B4E;
  --text-on-brand: #2A0B22;
  /* The mark is artwork, so its colours are the same in both themes. */
  --logo-box: #F4695C;  --logo-deep: #D94F43;  --logo-card: #C19CE8;  --logo-play: #FCE9D9;
  --accent: #6A3FB4;
  --accent-hover: #56309A;
  --accent-soft: #F1EAFB;
  --text-on-accent: #FFFFFF;
  --focus: #6A3FB4;
  --ok: #1A6B43;    --ok-soft: #E3F3EA;
  --warn: #7A5200;  --warn-soft: #FBF0D9;
  --err: #B42828;   --err-soft: #FBE9E9;  --text-on-err: #FFFFFF;
  --inverse: #25101F;  --text-on-inverse: #FFFFFF;   /* toasts, tooltips */
  --scrim: rgba(37, 16, 31, .5);
  --shadow-pop: 0 8px 24px rgba(37, 16, 31, .14), 0 1px 2px rgba(37, 16, 31, .08);
  --ios-blue: #2E6BE6;         /* only for the sketch of the Shortcuts editor, where the address really is blue */
  /* The front page's bands: each is the background colour of the illustration on it. */
  --band-hero: #FCF3EC;  --band-save: #ECE1FC;  --band-find: #FDE2D9;  --band-ask: #ECDFFC;
  --art-radius: 0px;
  --art-mask: linear-gradient(to right, transparent, #fff 6%, #fff 94%, transparent), linear-gradient(to bottom, transparent, #fff 6%, #fff 94%, transparent);
  /* Graph marks: a shelf is the coral box, a note is a lavender card in it. Checked as a
     set, every pair, against the canvas in both themes. */
  --graph-cat: #E2574A;  --graph-note: #7448C4;  --graph-topic: #2A9D8F;

  --r-1: 3px;  --r-2: 6px;  --r-3: 8px;
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Outfit", "Nunito Sans", system-ui, sans-serif;   /* the wordmark's face, for headings */
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t: 140ms;
  --gutter: 16px;
  --bar-h: 48px;       /* top bar */
  --tabs-h: 52px;      /* bottom tabs on a phone */
  --control-h: 44px;   /* inputs, and a button sitting beside one: a finger needs the height */
  color-scheme: light;
}
/* Dark is used when the device asks for it, unless the reader has picked a theme with the
   switch in the top bar (data-theme on <html>), which wins either way. The two rules below
   must stay identical: CSS has no way to say this once. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #171116;
    --surface: #171116;
    --surface-2: #211920;
    --surface-3: #2D232B;
    --surface-raised: #241B22;
    --text: #F3ECF1;
    --text-2: #CFC3CB;
    --text-muted: #A3959F;
    --line: #2E242C;
    --line-strong: #7A6C77;
    --accent: #C7ABF3;
    --accent-hover: #D9C4F8;
    --accent-soft: #2C2140;
    --text-on-accent: #24103F;
    --focus: #C7ABF3;
    --ok: #62CF98;    --ok-soft: #12281D;
    --warn: #E5B54B;  --warn-soft: #2B2210;
    --err: #F08A8A;   --err-soft: #331818;  --text-on-err: #2A0C0C;
    --inverse: #F3ECF1;  --text-on-inverse: #25101F;
    --scrim: rgba(0, 0, 0, .6);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
    --ios-blue: #6FA1FF;
    --graph-note: #8F72DD;  --graph-topic: #2FA085;
    --band-hero: transparent;  --band-save: transparent;  --band-find: transparent;  --band-ask: transparent;
    --art-radius: 8px;  --art-mask: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #171116;
  --surface: #171116;
  --surface-2: #211920;
  --surface-3: #2D232B;
  --surface-raised: #241B22;
  --text: #F3ECF1;
  --text-2: #CFC3CB;
  --text-muted: #A3959F;
  --line: #2E242C;
  --line-strong: #7A6C77;
  --accent: #C7ABF3;
  --accent-hover: #D9C4F8;
  --accent-soft: #2C2140;
  --text-on-accent: #24103F;
  --focus: #C7ABF3;
  --ok: #62CF98;    --ok-soft: #12281D;
  --warn: #E5B54B;  --warn-soft: #2B2210;
  --err: #F08A8A;   --err-soft: #331818;  --text-on-err: #2A0C0C;
  --inverse: #F3ECF1;  --text-on-inverse: #25101F;
  --scrim: rgba(0, 0, 0, .6);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
  --ios-blue: #6FA1FF;
  --graph-note: #8F72DD;  --graph-topic: #2FA085;
  --band-hero: transparent;  --band-save: transparent;  --band-find: transparent;  --band-ask: transparent;
  --art-radius: 8px;  --art-mask: none;
  color-scheme: dark;
}
/* A mouse does not need finger-sized fields. */
@media (min-width: 768px) and (pointer: fine) { :root { --control-h: 32px; } }
@media (min-width: 768px) { :root { --gutter: 24px; } }

/* ---------- base ---------- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1, h2 { font-family: var(--font-display); letter-spacing: -0.005em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
ul, ol { margin: 0 0 8px; padding-left: 20px; }
li { margin: 2px 0; }
code, pre, kbd { font-family: var(--font-mono); font-size: 13px; }
pre { margin: 0; background: var(--surface-2); border-radius: var(--r-2); padding: 8px 12px; overflow-x: auto; line-height: 1.5; }
code.inline { background: var(--surface-2); border-radius: var(--r-1); padding: 1px 4px; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
img { max-width: 100%; display: block; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-1); }
::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; }
}
@media (min-width: 768px) {
  body { font-size: 15px; }
  h1 { font-size: 24px; }
  h2 { font-size: 18px; margin-top: 32px; }
}

.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.icon.sm { width: 14px; height: 14px; }
.icon.lg { width: 20px; height: 20px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { from { opacity: 0; } }

.muted { color: var(--text-muted); }
.ink-2 { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); }
.err { color: var(--err); }
.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-raised); padding: 8px 12px; border-radius: var(--r-2); z-index: 1000; }
.skip-link:focus { left: 8px; }

/* ---------- layout ---------- */
.container { width: min(1140px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.container.narrow { width: min(720px, 100% - 2 * var(--gutter)); }
main { padding: 16px 0 32px; }
.has-tabs main { padding-bottom: calc(32px + var(--tabs-h)); }   /* clear the bottom tabs */
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head > div { min-width: 0; }
.page-head .sub { color: var(--text-muted); font-size: 13px; margin: 2px 0 0; max-width: 66ch; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
.prose p, .prose li { max-width: 66ch; }
@media (min-width: 768px) {
  main, .has-tabs main { padding: 24px 0 64px; }
  .page-head { margin-bottom: 16px; }
}
main.flush { padding-top: 0; }   /* a page that opens with a full-width band */

/* ---------- top bar and tabs ---------- */
.nav { position: sticky; top: 0; z-index: 40; height: var(--bar-h); background: var(--canvas); border-bottom: 1px solid var(--line); }
.nav .container { display: flex; align-items: center; gap: 4px; height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { width: 28px; height: 28px; flex: none; }
.logo .box { fill: var(--logo-box); }
.logo .deep { fill: var(--logo-deep); }
.logo .card { fill: var(--logo-card); }
.logo .play { fill: var(--logo-play); stroke: var(--logo-play); }
.nav .item { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 8px; border: 0; border-radius: var(--r-2); background: none; color: var(--text-2); font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.nav .item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav .item.active { color: var(--text); }
.nav > .container > .item.active { background: var(--surface-2); }
.nav .spacer { flex: 1; }
.nav .user { display: none; color: var(--text-muted); font-size: 13px; margin: 0 4px; }
.nav .wide { display: none; }
.nav .roomy { display: none; }   /* shown once the bar has room; the page itself always offers it */
.nav form { display: none; }
/* On a phone the four places you go all day sit under the thumb, each with its name. */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); height: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--canvas); border-top: 1px solid var(--line); }
.nav .tabs .item { flex-direction: column; gap: 2px; height: 100%; padding: 0; border-radius: 0; font-size: 12px; }
.nav .tabs .item.active { color: var(--accent); }
.nav .tabs .item.active::before { content: ""; position: absolute; top: -1px; left: 24px; right: 24px; height: 2px; background: var(--accent); }
@media (min-width: 768px) {
  .tabs { position: static; display: flex; gap: 4px; height: auto; padding: 0; border: 0; background: none; }
  .nav .tabs .item { flex-direction: row; gap: 6px; height: 32px; padding: 0 8px; border-radius: var(--r-2); font-size: 14px; }
  .nav .tabs .item.active { color: var(--text); background: var(--surface-2); }
  .nav .tabs .item.active::before { display: none; }
  .nav form { display: block; }
}
@media (min-width: 400px) { .nav .roomy { display: inline-flex; } }
@media (min-width: 1024px) {
  .nav .user { display: inline; }
  .nav .wide { display: inline; }
}

/* ---------- buttons ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--r-2); background: none; color: var(--text); font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer; touch-action: manipulation; transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease); }
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: progress; pointer-events: none; }
.btn.primary { background: var(--brand); color: var(--text-on-brand); font-weight: 600; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.secondary { background: var(--surface); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); }
.btn.danger-solid { background: var(--err); color: var(--text-on-err); font-weight: 600; }
.btn.sm { height: 28px; padding: 0 8px; font-size: 13px; }
.btn.icon-only { width: 32px; padding: 0; }
.btn.icon-only.sm { width: 28px; }
.btn.match { height: var(--control-h); }   /* sits beside a field */
/* The box stays small; a finger still gets 44px. */
@media (pointer: coarse) {
  .btn::after, .nav > .container > .item::after, .filters button::after {
    content: ""; position: absolute; left: 0; right: 0; top: 50%; height: max(100%, 44px); transform: translateY(-50%);
  }
}

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input, textarea.input, select.input {
  width: 100%; height: var(--control-h); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-2);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
textarea.input { height: auto; min-height: 96px; padding: 8px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: var(--text-muted); }
.input:focus-visible { outline-offset: 0; border-color: var(--accent); }
.input.error { border-color: var(--err); }
.field .help { font-size: 13px; color: var(--text-muted); }
.field .err { font-size: 13px; display: flex; gap: 4px; align-items: center; }
.errorlist { margin: 0; padding: 0; list-style: none; color: var(--err); font-size: 13px; }
.helptext { display: none; }
@media (min-width: 768px) and (pointer: fine) {
  .input, textarea.input, select.input { font-size: 14px; }
}

/* ---------- panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); padding: 12px; }
.card h3 { margin-bottom: 4px; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card .card-head h3 { margin: 0; }
.card h3 .icon { color: var(--text-muted); margin-right: 2px; }
.callout { display: flex; gap: 8px; padding: 8px 12px; border-radius: var(--r-2); background: var(--surface-2); color: var(--text-2); font-size: 14px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.err { background: var(--err-soft); color: var(--err); }
.callout .icon { margin-top: 3px; }
.status { margin: 0; font-size: 13px; color: var(--text-muted); }
.status:empty { display: none; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
@media (min-width: 768px) { .card { padding: 16px; } }

/* ---------- badges and tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: var(--r-1); background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge .icon { width: 12px; height: 12px; }
.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.cat { background: var(--accent-soft); color: var(--accent); }
a.badge.cat:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tags li { margin: 0; }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: var(--r-2); background: var(--surface-2); color: var(--text-2); font-size: 13px; text-decoration: none; }
a.tag:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.tag .count { margin-left: 6px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- saves: the composer ---------- */
.composer { display: grid; gap: 8px; margin-bottom: 16px; }
.composer .inline { display: flex; flex-wrap: wrap; gap: 8px; }
.composer .inline .input { flex: 1 1 100%; min-width: 0; }
.composer .inline .btn { flex: 1; }
.composer .hint { margin: 0; color: var(--text-muted); font-size: 13px; max-width: 66ch; }
.dropzone { position: relative; display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-2); color: var(--text-muted); font-size: 13px; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .file { color: var(--text); font-weight: 500; }
.composer summary { display: inline-flex; align-items: center; gap: 4px; list-style: none; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.composer summary::-webkit-details-marker { display: none; }
.composer summary:hover { color: var(--text); }
.composer details[open] summary .icon { transform: rotate(180deg); }
.composer details .field { margin-top: 8px; }
@media (min-width: 560px) {
  .composer .inline { flex-wrap: nowrap; }
  .composer .inline .input { flex: 1; }
  .composer .inline .btn { flex: none; }
}

/* ---------- saves: the list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 16px 0 4px; }
.list-head .count { margin-left: 4px; color: var(--text-muted); font-size: 13px; font-weight: 400; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 2px; }
.filters button { position: relative; height: 28px; padding: 0 8px; border: 0; border-radius: var(--r-2); background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 500; cursor: pointer; }
.filters button:hover { background: var(--surface-2); color: var(--text); }
.filters button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.saves { list-style: none; margin: 0; padding: 0; }
.save-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.save-row .title { color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.save-row .title.pending { color: var(--text-2); font-size: 14px; font-weight: 400; word-break: break-all; }
.save-row .meta { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; margin-top: 2px; color: var(--text-muted); font-size: 13px; }
.save-row .meta .icon { width: 13px; height: 13px; }
.save-row .err { margin-top: 2px; font-size: 13px; }
.save-row .side { display: flex; align-items: center; gap: 4px; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-muted); }
.empty .icon { width: 24px; height: 24px; margin: 0 auto 8px; }
.empty h3 { color: var(--text); margin-bottom: 2px; }
.empty p { margin: 0; }
.row-enter { animation: appear var(--t) var(--ease); }

/* ---------- a note ---------- */
.detail-head { margin-bottom: 16px; }
.detail-head h1 { font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }
.kicker { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin: 8px 0; color: var(--text-muted); font-size: 13px; }
.kicker .icon { width: 13px; height: 13px; }
.detail-head .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.summary { font-size: 16px; line-height: 1.55; }
.summary p, .summary li { max-width: 66ch; }
.summary ul { margin-top: 8px; }
.stepper { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 12px 0; border-block: 1px solid var(--line); }
.step { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; }
.step .n { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.step .n .icon { width: 12px; height: 12px; }
.step.done { color: var(--text-2); }
.step.done .n { background: var(--ok); border-color: var(--ok); color: var(--canvas); }
.step.active { color: var(--text); font-weight: 600; }
.step.active .n { border-color: var(--accent); color: var(--accent); }
.concepts { display: grid; margin: 0; padding: 0; list-style: none; }
.concepts li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.concepts li > span:not(.ts) { grid-column: 1; }
.concepts li > .ts, .concepts li > form { grid-column: 2; grid-row: 1; }
.concepts li:last-child { border-bottom: 0; padding-bottom: 0; }
.ts { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.section { display: grid; gap: 8px 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.section h3 { font-size: 16px; margin-bottom: 4px; }
.section p { max-width: 66ch; }
.section .lbl { display: block; margin-top: 8px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.section .frame { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-2); background: var(--surface-2); }
.section .frame.portrait { width: auto; max-height: 240px; aspect-ratio: 9 / 16; }
/* Screenshots beside a transcript-only note: a strip that scrolls sideways on a phone. */
.shots { display: flex; gap: 8px; margin-top: 12px; padding-bottom: 4px; overflow-x: auto; }
.shots a { flex: none; }
.shots img { width: auto; height: 160px; border-radius: var(--r-2); background: var(--surface-2); }
.transcript { white-space: pre-wrap; line-height: 1.6; font-size: 14px; }
.transcript .t { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
details.panel { border: 1px solid var(--line); border-radius: var(--r-3); }
details.panel summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; list-style: none; font-size: 14px; cursor: pointer; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary .icon { color: var(--text-muted); }
details.panel[open] summary .icon { transform: rotate(180deg); }
details.panel .body { padding: 0 12px 12px; }
@media (min-width: 768px) {
  .detail-head h1 { font-size: 30px; }
  .section { grid-template-columns: 200px minmax(0, 1fr); }
  .shots img { height: 200px; }
}

/* ---------- search ---------- */
.searchbar { display: flex; flex-wrap: wrap; gap: 8px; }
.searchbar .wrap { position: relative; flex: 1 1 100%; }
.searchbar .wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.searchbar .wrap .input { padding-left: 36px; }
.searchbar select.input { flex: 1; width: auto; min-width: 0; }
.result { padding: 12px 0; border-bottom: 1px solid var(--line); }
.result h3 { margin-bottom: 2px; }
.result p { margin: 0 0 8px; color: var(--text-2); font-size: 14px; max-width: 66ch; }
.result .score { margin-left: 8px; color: var(--text-muted); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
@media (min-width: 560px) {
  .searchbar { flex-wrap: nowrap; }
  .searchbar .wrap { flex: 1; }
  .searchbar select.input { flex: none; }
}

/* ---------- ask ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chat-suggestions .btn { height: auto; min-height: 28px; padding: 4px 8px; white-space: normal; text-align: left; line-height: 1.3; }
/* A question is a short grey block on the right; an answer is plain text on the page. */
.msg { max-width: min(66ch, 92%); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; animation: appear var(--t) var(--ease); }
.msg.user { align-self: flex-end; padding: 6px 12px; border-radius: var(--r-3); background: var(--surface-3); }
.msg.bot { align-self: flex-start; }
.msg.pending { color: var(--text-muted); }
.msg.err { color: var(--err); }
.msg .sources { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; white-space: normal; }
.msg .sources-label { margin-bottom: 2px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.msg .source { padding: 2px 0; }
.msg .source-video { margin-left: 8px; white-space: nowrap; }
.chat-form { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; align-items: flex-end; padding: 8px 0; background: var(--canvas); }
.chat-form textarea.input { flex: 1; min-width: 0; min-height: var(--control-h); max-height: 160px; padding: 9px 12px; resize: none; }
@media (min-width: 768px) { .chat-form { bottom: 0; } }
@media (min-width: 768px) and (pointer: fine) { .chat-form textarea.input { padding: 5px 12px; } }

/* ---------- settings ---------- */
.token { display: flex; align-items: center; gap: 8px; }
.token pre { flex: 1; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.stat .v { font-size: 18px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--text-muted); font-size: 12px; }
.kv { display: grid; border: 1px solid var(--line); border-radius: var(--r-2); }
.kv > div { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv .k { flex: 0 0 120px; color: var(--text-muted); font-size: 13px; }
.kv code { overflow-wrap: anywhere; }
.howto { display: grid; gap: 12px 24px; margin-top: 8px; }
.howto b { display: block; margin-bottom: 2px; }
.howto ol { margin: 0; padding-left: 20px; }
@media (min-width: 560px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .howto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- signed out: log in, sign up, the front page ---------- */
.auth { width: min(360px, 100%); margin: 32px auto; }
.auth h1 { margin-bottom: 12px; }
.auth form { display: grid; gap: 12px; }
.auth form .btn { height: var(--control-h); }
.auth > .icon { margin-bottom: 8px; }
.auth form.consent { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
/* The front page. Each section is a band that runs the full width of the window in the
   background colour of its illustration, so the picture has no edge. The colour is spread
   sideways with a shadow rather than with width, which cannot cause sideways scrolling. */
.band { display: grid; gap: 16px; align-items: center; padding: 32px 0; background: var(--band); box-shadow: 0 0 0 100vmax var(--band); clip-path: inset(0 -100vmax); }
.band-hero { --band: var(--band-hero); }
.band-save { --band: var(--band-save); }
.band-find { --band: var(--band-find); }
.band-ask { --band: var(--band-ask); }
.band .logo { width: 64px; height: 64px; margin-bottom: 12px; }
.band h1 { max-width: 14ch; font-size: 30px; line-height: 1.1; letter-spacing: -0.015em; }
.band h2 { margin: 0 0 4px; font-size: 20px; }
.band p { max-width: 50ch; color: var(--text-2); }
.band .lede { max-width: 44ch; margin: 12px 0 16px; font-size: 16px; }
.band .btn.primary { height: 44px; padding: 0 16px; font-size: 15px; }
/* The picture's edges are feathered, so a background that is a shade off the band's still
   melts into it. In dark mode --art-mask is none and --art-radius rounds the corners. */
.art { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: var(--art-radius); object-fit: cover;
       -webkit-mask-image: var(--art-mask); mask-image: var(--art-mask); -webkit-mask-composite: source-in; mask-composite: intersect; }
.land-list { margin: 8px 0 0; padding-left: 20px; color: var(--text-2); }
.land-list li { margin: 4px 0; max-width: 50ch; }
.land-list b { color: var(--text); }
.land-end { display: grid; gap: 32px; padding: 32px 0 0; }
.land-end h2 { margin: 0 0 4px; font-size: 18px; }
.land-end p { max-width: 50ch; color: var(--text-2); }
.land-end .btn { margin-top: 4px; }
@media (min-width: 768px) {
  .band { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; padding: 48px 0; }
  .band.flip { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
  .band.flip .art { order: -1; }
  .band .logo { width: 80px; height: 80px; }
  .band h1 { font-size: 48px; }
  .band h2 { font-size: 30px; }
  .band .lede { font-size: 18px; }
  .land-end { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 48px; padding-top: 48px; }
}

/* ---------- toast, dialog, flash messages ---------- */
.toast-host { position: fixed; left: 50%; bottom: calc(16px + var(--tabs-h)); z-index: 100; display: grid; gap: 8px; width: max-content; max-width: calc(100% - 32px); transform: translateX(-50%); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-2); background: var(--inverse); color: var(--text-on-inverse); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-pop); pointer-events: auto; animation: appear var(--t) var(--ease); }
.toast.err { background: var(--err); color: var(--text-on-err); }
dialog.confirm { width: min(360px, 100% - 32px); padding: 16px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-pop); }
dialog.confirm::backdrop { background: var(--scrim); }
dialog.confirm h3 { margin-bottom: 4px; }
dialog.confirm p { color: var(--text-2); font-size: 14px; }
dialog.confirm .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.messages { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.messages li { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 8px 12px; border-radius: var(--r-2); background: var(--ok-soft); color: var(--ok); font-size: 14px; }
.messages li.error { background: var(--err-soft); color: var(--err); }
.messages .icon { margin-top: 3px; }

/* ---------- setup checklist (a collapsed bar on Saves) ---------- */
.checklist { margin-bottom: 12px; padding: 8px 12px; }
.checklist > summary { display: flex; align-items: center; gap: 4px 16px; flex-wrap: wrap; list-style: none; font-size: 13px; cursor: pointer; }
.checklist > summary::-webkit-details-marker { display: none; }
.checklist .cl-head { display: flex; align-items: baseline; gap: 8px; }
.checklist .cl-head b { font-size: 14px; }
.checklist .cl-stages { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; flex: 1 1 100%; order: 1; }
.checklist .cl-stage { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); }
.checklist .cl-stage.done { color: var(--text-2); }
.checklist .cl-stage.na { opacity: .6; }
.checklist .cl-chevron { margin-left: auto; color: var(--text-muted); }
.checklist[open] .cl-chevron { transform: rotate(180deg); }
.checklist[open] > summary { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.checklist .mark { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--text-2); font-size: 12px; font-weight: 600; }
.checklist .mark .icon { width: 12px; height: 12px; }
.checklist .done .mark { background: var(--ok); border-color: var(--ok); color: var(--canvas); }
.checklist .opt .mark { border-style: dashed; }
.checklist .steps { list-style: none; margin: 0; padding: 0; }
.checklist .steps li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 4px 8px; align-items: start; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.checklist .steps li:last-child { border-bottom: 0; }
.checklist .steps .mark { margin-top: 2px; }
.checklist li.done .text b { color: var(--text-muted); font-weight: 500; text-decoration: line-through; }
.checklist li.done .text p { display: none; }
.checklist li.na { opacity: .6; }
.checklist .text b { display: block; font-size: 14px; }
.checklist .text p { margin: 2px 0 0; max-width: 66ch; color: var(--text-2); font-size: 13px; }
.checklist .do { grid-column: 2; }
.checklist .do:empty { display: none; }
.checklist .cl-hide { margin-top: 4px; text-align: right; }
@media (min-width: 768px) {
  .checklist .cl-stages { flex: none; order: 0; margin-left: auto; }
  .checklist .cl-chevron { margin-left: 0; }
  .checklist .steps li { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .checklist .do { grid-column: 3; }
}

/* ---------- brain ---------- */
.brain-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.brain-filters select.input { flex: 1 1 140px; width: auto; min-width: 0; }
.shelves { display: grid; gap: 0 24px; }
.shelf { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.shelf:hover { text-decoration: none; }
.shelf:hover b { text-decoration: underline; text-underline-offset: 2px; }
.shelf b { grid-column: 1; grid-row: 1; font-size: 15px; }
.shelf .n { grid-column: 2; grid-row: 1; color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.shelf .hint { grid-column: 1 / -1; overflow: hidden; color: var(--text-muted); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.notes-grid { display: grid; gap: 8px; }
.note-card { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-3); color: var(--text); }
.note-card:hover { border-color: var(--line-strong); text-decoration: none; }
.note-card h3 { line-height: 1.3; overflow-wrap: anywhere; }
.note-card p { flex: 1; margin: 0; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.note-card .meta { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; color: var(--text-muted); font-size: 12px; }
.note-card .tags .tag { height: 20px; padding: 0 6px; font-size: 12px; }
.theme { margin-top: 24px; }
.theme-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.theme-head h2 { margin: 0; }
.theme-head h2 a { color: var(--text); }
.theme-head p { margin: 2px 0 0; max-width: 66ch; }
.section-note { margin: -4px 0 8px; color: var(--text-muted); font-size: 13px; max-width: 66ch; }
@media (min-width: 560px) {
  .brain-filters select.input { flex: none; }
  .shelves { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .notes-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
}

/* ---------- brain graph ---------- */
.graph-panel { display: flex; flex-direction: column; height: 380px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--canvas); overflow: hidden; }
.graph-panel.full { height: calc(100dvh - var(--bar-h) - var(--tabs-h) - 96px); min-height: 320px; }
.graph-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
.graph-bar .input { flex: 1; min-width: 0; height: 32px; padding: 0 8px; }
.graph-bar .zoom { display: flex; gap: 2px; }
.graph-stage { position: relative; flex: 1; min-height: 0; }
.graph-stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
/* On a phone the legend takes its own line under the search box; on a wide screen it leads the bar. */
.graph-legend { order: 2; flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--text-2); font-size: 12px; }
.graph-legend .lg { display: inline-flex; align-items: center; gap: 4px; }
.graph-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.graph-legend i.dash { width: 18px; height: 0; border-radius: 0; border-top: 2px dashed var(--accent); }
.graph-tip { position: absolute; z-index: 5; display: grid; gap: 2px; max-width: 260px; padding: 6px 8px; border-radius: var(--r-2); background: var(--inverse); color: var(--text-on-inverse); font-size: 13px; line-height: 1.3; box-shadow: var(--shadow-pop); pointer-events: none; }
.graph-tip span { font-size: 12px; opacity: .75; }
/* What is selected, with a real link: a tap cannot hover. */
.graph-sel { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 4; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface-raised); box-shadow: var(--shadow-pop); }
.graph-sel .what { flex: 1; min-width: 0; }
.graph-sel b { display: block; overflow: hidden; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.graph-sel span { color: var(--text-muted); font-size: 12px; }
.graph-help { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }
.graph-help .fine { display: none; }
@media (pointer: fine) { .graph-help .fine { display: inline; } .graph-help .coarse { display: none; } }
@media (min-width: 768px) {
  .graph-panel { height: 480px; }
  .graph-panel.full { height: calc(100dvh - var(--bar-h) - 128px); }
  .graph-legend { order: 0; flex: none; margin-right: auto; font-size: 13px; }
  .graph-bar .input { flex: 0 1 200px; }
  .graph-sel { left: auto; width: min(360px, 100% - 16px); }
}

/* ---------- share landing ---------- */
.share-landing { display: grid; gap: 8px; justify-items: center; width: min(400px, 100%); text-align: center; }
.share-landing .state { display: grid; gap: 8px; justify-items: center; }
.share-landing .url { max-width: 100%; word-break: break-all; }
.share-landing .row { justify-content: center; margin-top: 4px; }

/* ---------- phone setup ---------- */
.setup-phone h3 { display: flex; align-items: center; gap: 8px; }
.setup-steps { display: grid; gap: 12px; margin: 8px 0 0; padding-left: 20px; }
.setup-steps li { margin: 0; max-width: 66ch; }
.setup-steps .muted { display: block; margin-top: 2px; font-size: 13px; }
.setup-substeps { margin: 4px 0 8px; padding-left: 20px; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.setup-actions .input { flex: 1 1 220px; width: auto; min-width: 0; }
.setup-phone > h2 { padding-top: 16px; border-top: 1px solid var(--line); }
.setup-phone:first-of-type > h2 { padding-top: 0; border-top: 0; margin-top: 0; }
/* A plain diagram of the four blocks in the Shortcuts editor, so "the blue address" can be found by looking. */
.sc-mock { display: grid; gap: 4px; max-width: 400px; margin: 8px 0; }
.sc-block { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; padding: 6px 12px; border-radius: var(--r-2); background: var(--surface-2); font-size: 13px; }
.sc-block.dim { color: var(--text-muted); }
.sc-block.target { outline: 2px solid var(--ios-blue); outline-offset: -2px; }
.sc-block .sc-url { color: var(--ios-blue); overflow-wrap: anywhere; }
.sc-block .sc-note { color: var(--text-2); font-size: 12px; font-weight: 600; }
.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; padding: 4px 4px 4px 12px; border-radius: var(--r-2); background: var(--surface-2); }
.copy-value { flex: 1 1 200px; min-width: 0; font-family: var(--font-mono); font-size: 13px; word-break: break-all; }
.copy-value.code-big { font-family: var(--font); font-size: 20px; font-weight: 600; letter-spacing: .08em; }
.setup-diy { margin-top: 12px; }
.setup-diy summary { color: var(--text-muted); cursor: pointer; }
.setup-diy summary:hover { color: var(--text); }

/* ---------- recipe: what you need beside what you do ---------- */
.recipe { display: grid; gap: 12px 32px; }
.recipe h3 { margin-bottom: 4px; }
.recipe ul, .recipe ol { margin: 0; }
.recipe li { margin: 4px 0; }
@media (min-width: 768px) { .recipe { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
