/* Jothop design system. The :root block below is generated from
   packages/shared/tokens.json (pnpm tokens:build) — every other rule is
   hand-written; those rules reference the variables, never a raw hex value.
   CSP forbids inline styles, so anything that varies per row is a class. */
/* --- Tokens (generated from packages/shared/tokens.json, do not edit) --- */
:root {
  --paper: #f5f0e8;                             /* Paper — screen ground */
  --sidebar: #efe9df;                           /* Nav rail ground */
  --surface: #fffdfa;                           /* Page — cards, sheets */
  --dropzone-bg: #fbf8f3;                       /* Drop zone ground */
  --ink: #201c17;                               /* Primary text */
  --ink-2: #5c554c;                             /* Secondary text, body copy in cards */
  --muted: #6e665c;                             /* Nav labels, tag chips */
  --muted-2: #746c60;                           /* Ash — dates, locations, counts (4.6:1 on Paper) */
  --faint: #a69e92;                             /* Ash light — placeholders and glyphs only, never running text */
  --ink-inverse: #ede7dd;                       /* Text on the ink-dark token box */
  --white: #ffffff;                             /* Text on amber or ink fills */
  --border: #e4ddd1;                            /* Hairline on cards, inputs, rows */
  --border-2: #ede7dc;                          /* Softer hairline inside a card */
  --border-strong: #d2c8b8;                     /* Secondary button border, toggle track, dropzone dash */
  --accent: #a8432f;                            /* Ribbon — the one accent */
  --accent-hover: #8a3524;                      /* Pressed / active amber */
  --accent-soft: #f7e9e4;                       /* Amber wash */
  --accent-line: #d9cbb4;                       /* Amber hairline, note rule */
  --web-fg: #3d6b4f;                            /* Web-source green */
  --web-bg: #e9f2ec;                            /* Web-source wash */
  --capture-fg: #5b4636;                        /* Screenshot / Photo badge text */
  --capture-bg: #efe6dc;                        /* Screenshot / Photo badge wash */
  --cover-book: #7a4a21;                        /* Book cover tile ground */
  --cover-book-fg: #f7e8d4;                     /* Book cover tile initials */
  --cover-web: #44584e;                         /* Web cover tile ground */
  --cover-web-fg: #dfe9e4;                      /* Web cover tile initials */
  --cover-capture: #6b5a4a;                     /* Capture cover tile ground */
  --cover-capture-fg: #f3ece3;                  /* Capture cover tile initials */
  --danger: #b3261e;                            /* Destructive text and borders */
  --danger-line: #f1d6d2;                       /* Danger button border */
  --kept: #587a5e;                              /* Kept, synced — Sage */
  --kept-soft: #e8f0e9;                         /* Sage wash */
  --dot-idle: #e4ddd1;                          /* Unvisited progress dot */
  --quote-mark: #e9dccb;                        /* Decorative quote glyph */
  --scrim: #1c1a17;                             /* Lightbox backdrop, painted at 92% */
  --r-4: 4px;                                   /* Badges, cover tiles */
  --r-8: 8px;                                   /* Buttons, rows, inputs, photo */
  --r-12: 12px;                                 /* Controls, fields, segmented pickers */
  --r-16: 16px;                                 /* Grouped list cards, players, menus */
  --r-22: 22px;                                 /* Feature cards: review card, entry cards, Today hero */
  --shadow-card: 0 1px 2px rgba(32, 28, 23, .04);  /* Highlight card, panel, auth card */
  --shadow-review: 0 2px 8px rgba(32, 28, 23, .06);  /* Review card */
  --shadow-row: 0 1px 2px rgba(32, 28, 23, .05);  /* Selected source row */
  --shadow-primary: 0 1px 3px rgba(168, 67, 47, .22);  /* Primary button */
  --shadow-overlay: 0 6px 20px rgba(32, 28, 23, .1);  /* Anchored panel: card editor, tag adder, review note */
  --shadow-knob: 0 1px 2px rgba(0, 0, 0, .2);   /* Toggle knob */
  --shadow-cover-spine: inset 3px 0 0 rgba(0, 0, 0, .18);  /* Cover tile spine */
  --shadow-cover-spine-sm: inset 2px 0 0 rgba(0, 0, 0, .2);  /* Small cover tile spine */
  --shadow-lift: 0 1px 2px rgba(32, 28, 23, .04);  /* Feature cards and covers, near layer */
  --shadow-lift-far: 0 12px 32px rgba(32, 28, 23, .06);  /* Feature cards and covers, far layer (used together with lift) */
  --serif: 'Literata', 'Iowan Old Style', Georgia, serif;  /* Words a reader reads: quotes, titles, notes */
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;  /* Everything that is interface — the platform face */
}
/* --- /Tokens --- */

/* --- Base -------------------------------------------------------------- */
* { box-sizing: border-box; }
/* Without this, `.btn { display: inline-flex }` and `.auth-card { display:
   flex }` (and anything else with its own `display`) win over the HTML
   `hidden` attribute, so a passkey control meant to stay hidden shows anyway. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-4); }
button { font: inherit; cursor: pointer; }
summary { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* --- Shell: sidebar + main -------------------------------------------- */
.shell { display: flex; min-height: 100vh; align-items: stretch; }
/* Each column scrolls on its own: the sidebar stays put, the sources list and
   the highlights pane keep their own positions. */
@media (min-width: 900px) {
  .shell { height: 100vh; height: 100dvh; overflow: hidden; }
  .sidebar, .col-sources, .pane, .main { overflow-y: auto; min-height: 0; }
}
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
  gap: 24px; padding: 32px 44px; }
.main-narrow { max-width: 860px; }

.sidebar { width: 232px; flex-shrink: 0; display: flex; flex-direction: column; gap: 24px;
  padding: 24px 16px; background: var(--sidebar); border-right: 1px solid var(--border); }
.sidebar-spacer { flex-grow: 1; }
.wordmark { display: flex; align-items: center; gap: 8px; padding: 0 12px; line-height: 1;
  font-family: var(--serif); font-size: 23px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.wordmark:hover { color: var(--ink); }
.wordmark.sm { font-size: 19px; gap: 7px; padding: 0; }
.wordmark svg { flex-shrink: 0; transform: translateY(-1px); }

/* Nav rows: 44px tall, active row gets the amber wash. */
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px;
  border-radius: var(--r-8); color: var(--muted); font-size: 14px; }
.nav:hover { background: color-mix(in srgb, var(--border) 55%, transparent); color: var(--ink-2); }
.nav.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--accent); color: var(--white);
  font-size: 11px; font-weight: 600; border-radius: 9px; padding: 2px 7px; }

/* Signed-in identity, pinned to the bottom of the rail. */
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--r-8); border: 1px solid var(--border); background: var(--surface); }
.user-avatar { width: 32px; height: 32px; flex-shrink: 0; border-radius: 16px; background: var(--accent);
  color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.user-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.user-plan { font-size: 12px; color: var(--muted-2); }
.user-lines { min-width: 0; display: flex; flex-direction: column; }
.user-lines > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Phone chrome: top bar + bottom tabs (hidden ≥ 900px, see above) --- */
.mobile-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--paper); }
.mobile-bar-right { display: flex; align-items: center; gap: 10px; }
.mobile-review { position: relative; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-8); color: var(--muted); }
.mobile-review .nav-badge { position: absolute; top: 2px; right: 2px; margin-left: 0; }
.mobile-avatar { width: 32px; height: 32px; flex-shrink: 0; border-radius: 16px; background: var(--accent);
  color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }

.tabbar { display: flex; align-items: stretch; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1 1 0; min-width: 0; min-height: 44px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; color: var(--muted); font-size: 11px; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.active { color: var(--accent-hover); font-weight: 600; }

/* --- Library: sources column ------------------------------------------ */
.col-sources { width: 312px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px;
  padding: 28px 20px; border-right: 1px solid var(--border); }
.col-head { display: flex; flex-direction: column; gap: 4px; }
.search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px;
  border-radius: var(--r-8); border: 1px solid var(--border); background: var(--surface); }
.search input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent;
  font: inherit; color: var(--ink); padding: 0; }
.search input:focus { outline: none; }
.search input::placeholder { color: var(--muted-2); }
.search:focus-within { border-color: var(--accent-line); }

.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: -2px 0 4px; }
.nav.sub { height: 36px; padding-left: 40px; font-size: 13.5px; }
.nav.sub.soon { color: var(--faint); cursor: default; }
.nav.sub.soon:hover { background: none; color: var(--faint); }
.nav-soon { margin-left: auto; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.pills { display: flex; gap: 8px; }
.pill { display: inline-flex; align-items: center; height: 44px; padding: 0 18px; border-radius: 22px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; }
.pill:hover { color: var(--ink-2); }
.pill.active { background: var(--ink); border-color: var(--ink); color: var(--white); font-weight: 500; }
.pill.active:hover { color: var(--white); }

/* Library collections row (phone only, see above): the sidebar's LIBRARY_SUB
 * as a horizontally-scrolling pill strip. */
.collections { display: flex; gap: 8px; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; }
.collections::-webkit-scrollbar { display: none; }
.collections .pill { height: 36px; padding: 0 16px; flex-shrink: 0; }
.collections .pill.soon { color: var(--faint); gap: 6px; }

.source-list { display: flex; flex-direction: column; gap: 6px; }
.source-row { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px;
  border-radius: var(--r-8); border: 1px solid transparent; color: var(--ink); }
.source-row:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--ink); }
.source-row.selected { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-row); }
.source-row-top { display: flex; align-items: center; gap: 8px; }
.source-row-title { flex-grow: 1; font-size: 14px; font-weight: 500; }
.source-row.selected .source-row-title { font-weight: 600; }
.source-row-meta { font-size: 12.5px; color: var(--muted-2); }

.badge-kindle, .badge-web { font-size: 11px; font-weight: 500; border-radius: var(--r-4); padding: 2px 6px; }
.badge-kindle { color: var(--accent-hover); background: var(--accent-soft); }
.badge-web { color: var(--web-fg); background: var(--web-bg); }
.badge-capture { font-size: 11px; font-weight: 500; border-radius: var(--r-4); padding: 2px 6px; color: var(--capture-fg); background: var(--capture-bg); }
.badge-photo { font-size: 11px; font-weight: 500; border-radius: var(--r-4); padding: 2px 6px; color: var(--capture-fg); background: var(--capture-bg); }
.badge-voice { font-size: 11px; font-weight: 500; border-radius: var(--r-4); padding: 2px 6px; color: var(--accent-hover); background: var(--accent-soft); }
.cover.capture { background: var(--cover-capture); color: var(--cover-capture-fg); }

/* --- Source header ----------------------------------------------------- */
.pane { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 20px; padding: 28px 40px; }
/* Library's phone-only detail screen: the way back to the source list. */
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted-2); }
.source-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.source-head-body { display: flex; flex-direction: column; gap: 4px; flex: 1 1 260px; min-width: 0; }

/* Spine-shadowed initials block standing in for a cover image. */
.cover { width: 52px; height: 74px; flex-shrink: 0; border-radius: var(--r-4); background: var(--cover-book);
  color: var(--cover-book-fg); display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 19px; font-weight: 600; box-shadow: var(--shadow-cover-spine); }
.cover.web { background: var(--cover-web); color: var(--cover-web-fg); }
.cover.sm { width: 38px; height: 54px; border-radius: 3px; font-size: 14px;
  box-shadow: var(--shadow-cover-spine-sm); }
/* The real artwork, in the same hole the initials tile fills: crop to the
   spine's aspect ratio rather than letterboxing or stretching. */
img.cover { object-fit: cover; display: block; }

/* "Change cover": the same anchored <details> panel the card editors use, so
   the page still ships no JavaScript. */
.cover-menu { position: relative; margin-top: 6px; }
.cover-menu summary { list-style: none; cursor: pointer; }
.cover-menu summary::-webkit-details-marker { display: none; }
.cover-menu-panel { position: absolute; left: 0; top: 28px; z-index: 20; width: 300px;
  max-width: calc(100vw - 48px); display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-12);
  padding: 16px; box-shadow: var(--shadow-overlay); }
.cover-menu-panel form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cover-menu-panel input { width: 100%; }
.cover-menu-panel .btn-row form { flex-direction: row; }
.cover-error { color: var(--danger); }
/* "Looking for a cover…" — its own line under the source's meta line. */
.cover-pending { display: block; margin-top: 2px; }

.page-title { font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.01em; }
.col-title { font-family: var(--serif); font-size: 25px; font-weight: 600; }
.meta { font-size: 14px; color: var(--muted-2); }
.meta-sm { font-size: 13px; color: var(--muted-2); }

.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 4px 11px; }
.tag.add { color: var(--accent); border: 1px dashed var(--accent-line); background: transparent; }
.tag button { border: 0; background: none; color: var(--muted-2); padding: 0 0 0 2px; font-size: 13px; line-height: 1; }
.tag button:hover { color: var(--danger); }

/* --- Highlight card ---------------------------------------------------- */
.cards { display: flex; flex-direction: column; gap: 14px; }
.card { display: flex; flex-direction: column; gap: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-12); padding: 26px 30px; box-shadow: var(--shadow-card); }
.quote { font-family: var(--serif); font-size: 18.5px; line-height: 1.62; color: var(--ink); margin: 0; }
.note { display: flex; flex-direction: column; gap: 6px; border-left: 2px solid var(--accent-line); padding: 2px 0 2px 14px; }
.note-label { font-size: 11.5px; font-weight: 600; color: var(--accent-hover); letter-spacing: .05em; text-transform: uppercase; }
.note-body { font-size: 14px; line-height: 1.5; color: var(--ink-2); margin: 0; }

.card-tags { margin: 2px 0 0; }
.card-tags .tag a { color: inherit; text-decoration: none; }
.card-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.card-foot .meta-sm { flex-grow: 1; }
.card-actions { display: flex; align-items: center; margin: -13px -13px -13px 0; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--muted-2); border-radius: var(--r-8); }
.icon-btn:hover { color: var(--ink-2); background: var(--paper); }
.icon-btn.on { color: var(--accent); }
/* Note and tag editors: a <details> panel anchored under its icon, since the
   page ships no JavaScript. */
.card-actions details { position: relative; }
.card-actions summary { list-style: none; }
.card-actions summary::-webkit-details-marker { display: none; }
.act-panel { position: absolute; right: 0; top: 46px; z-index: 20; width: 300px;
  max-width: calc(100vw - 48px); display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-12);
  padding: 16px; box-shadow: var(--shadow-overlay); }
.act-panel form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.act-panel textarea { width: 100%; min-height: 76px; resize: vertical; }
.act-panel .inline-form { flex-direction: row; align-items: center; }
.tag form { display: inline-flex; }

/* "+ tag" opens the same kind of anchored panel as the card editors. */
.tag-adder { position: relative; display: inline-flex; }
.tag-adder summary { list-style: none; cursor: pointer; }
.tag-adder summary::-webkit-details-marker { display: none; }
.tag-adder form { position: absolute; left: 0; top: 34px; z-index: 20; width: 300px;
  max-width: calc(100vw - 48px); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-12); padding: 14px; box-shadow: var(--shadow-overlay); }

/* Screenshot thumbnail + JS-free lightbox: a <details> disclosure whose
   <summary> is the thumbnail, revealing an always-`open` <dialog> only once
   the browser renders the <details> content — i.e. on click, no script.
   The lightbox covers the summary while open, so the summary itself becomes
   the close control: pinned to the top-right corner above the dialog
   (z-index 60 > .lightbox's 50), showing a "Close ×" pill instead of the
   thumbnail. Clicking it toggles the <details> shut again. */
.thumb { width: 44px; height: 62px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; vertical-align: middle; cursor: zoom-in; }
.thumb-wrap summary { list-style: none; display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.thumb-wrap summary::-webkit-details-marker { display: none; }
.thumb-close { display: none; }
.lightbox { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; padding: 24px; background: color-mix(in srgb, var(--scrim) 92%, transparent); display: flex; align-items: center; justify-content: center; z-index: 50; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.thumb-wrap[open] > summary { position: fixed; top: 16px; right: 16px; z-index: 60; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; }
.thumb-wrap[open] > summary .thumb { display: none; }
.thumb-wrap[open] > summary .thumb-label { display: none; }
.thumb-wrap[open] > summary .thumb-close { display: inline; }
.thumb-wrap[open] > summary .photo { display: none; }

/* A photo highlight (no text) renders inline at card width instead of the
   small .thumb above — it IS the highlight, not an attachment to a quote.
   Opens the same lightbox, via the same <details>/<dialog> the thumb uses. */
.photo { margin: 0; }
.photo img { display: block; max-width: 480px; width: 100%; border-radius: var(--r-8); border: 1px solid var(--border); cursor: zoom-in; }
.audio { display: block; width: 100%; max-width: 480px; margin-top: 10px; }

/* --- Forms and buttons ------------------------------------------------- */
input, textarea, select { font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-8); padding: 0 14px; height: 44px; }
textarea { padding: 10px 14px; height: auto; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, textarea:focus, select:focus { border-color: var(--accent-line); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field-row { display: flex; flex-wrap: wrap; gap: 14px; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px;
  padding: 0 20px; border-radius: var(--r-8); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; background: var(--surface); color: var(--ink-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { height: 48px; padding: 0 28px; border-radius: var(--r-12); background: var(--accent);
  color: var(--white); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-primary); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--white); }
.btn-secondary { height: 48px; padding: 0 28px; border-radius: var(--r-12); border-color: var(--border-strong);
  color: var(--ink-2); font-size: 14px; font-weight: 600; }
.btn-ghost { height: 48px; padding: 0 24px; border-radius: var(--r-12); border-color: var(--border); color: var(--muted-2); font-size: 14px; }
.btn-ghost:hover { color: var(--ink-2); }
.btn-plain { border-color: var(--border); color: var(--ink-2); }
.btn-danger { border-color: var(--danger-line); color: var(--danger); }
.btn-soft { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.btn-soft:hover { color: var(--accent-hover); }
.btn-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Real checkbox styled as the 46×26 switch drawn in the Import artboard. */
.toggle { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; flex-shrink: 0;
  padding: 0; border: 0; border-radius: 13px; background: var(--border-strong); position: relative; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 10px; background: var(--white); box-shadow: var(--shadow-knob); }
.toggle:checked, .toggle.on { background: var(--accent); }
.toggle:checked::after, .toggle.on::after { left: 23px; }
.switch-row { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--ink-2); }

/* --- Status, key/value, dropzone, token ------------------------------- */
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--web-fg); background: var(--web-bg); border-radius: 12px; padding: 4px 12px; }
.status-pill.off { color: var(--muted-2); background: var(--paper); }
.status-dot { width: 7px; height: 7px; border-radius: 4px; background: currentColor; }

.kv { display: flex; flex-direction: column; gap: 8px; background: var(--paper); border-radius: var(--r-8); padding: 14px 16px; }
.kv-row { display: flex; align-items: center; flex-wrap: wrap; font-size: 13px; gap: 8px; }
.kv-row form { margin-left: auto; }
.kv-key { color: var(--muted-2); width: 110px; flex-shrink: 0; }
.kv-val { font-weight: 500; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-8); padding: 26px 20px; background: var(--dropzone-bg);
  text-align: center; cursor: pointer; }
.dropzone:hover { border-color: var(--accent-line); }
.dropzone-title { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.dropzone input[type='file'] { max-width: 100%; height: auto; border: 0; background: none; padding: 0; font-size: 13px; }

.token-box { display: flex; align-items: center; gap: 10px; background: var(--ink);
  border-radius: var(--r-8); padding: 14px 16px; }
.token-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; color: var(--ink-inverse);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13.5px; letter-spacing: .04em; }
.token-copy { color: var(--faint); display: inline-flex; align-items: center; }

/* --- Cards grid (Import, Settings) ------------------------------------ */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-2 .span-2 { grid-column: span 2; }
.panel { display: flex; flex-direction: column; gap: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-12); padding: 26px 28px; box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: center; gap: 12px; }
.panel-title { font-size: 15.5px; font-weight: 600; flex-grow: 1; }
.panel-body { font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.panel-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 22px 28px; }
.panel-lines { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.hint { font-size: 12.5px; line-height: 1.5; color: var(--faint); }
.upload { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.upload .dropzone { width: 100%; }
.prefs-form { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }

/* --- Daily Review ------------------------------------------------------ */
.review-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 40px; }
.topbar-spacer { flex-grow: 1; }
.streak { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent-hover); font-size: 13px; font-weight: 600; }
.review-body { flex-grow: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 28px; padding: 0 24px 40px; }
.review-head { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.review-title { font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: -.01em; }

.dots { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 5px; background: var(--dot-idle); }
.dot.done { background: var(--accent); }
.dot.current { width: 12px; height: 12px; border-radius: 6px; background: var(--surface); border: 2.5px solid var(--accent); }
.dots .meta-sm { margin-left: 6px; }

.review-card { width: 720px; max-width: 100%; display: flex; flex-direction: column; gap: 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-16);
  padding: 52px 60px; box-shadow: var(--shadow-review); }
.review-quote { font-family: var(--serif); font-size: 26px; line-height: 1.55; letter-spacing: -.005em; margin: 0; }
.review-source { display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--border-2); padding-top: 22px; }
.review-source-title { font-size: 14.5px; font-weight: 600; }
.review-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.review-foot { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.kbd-hints { font-size: 12.5px; color: var(--faint); }
.review-source-lines { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* "Add a note" opens over the page rather than pushing the card around. */
.review-note { position: relative; }
.review-note summary { list-style: none; font-size: 13.5px; font-weight: 500; color: var(--accent); }
.review-note summary::-webkit-details-marker { display: none; }
.review-note form { position: absolute; left: 50%; transform: translateX(-50%); top: 30px; z-index: 20;
  width: 360px; max-width: calc(100vw - 48px); display: flex; flex-direction: column; gap: 10px;
  align-items: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-12); padding: 16px; box-shadow: var(--shadow-overlay); }
.review-note textarea { width: 100%; min-height: 90px; resize: vertical; }

/* --- Timeline views (Favorites, Trash, a tag) ------------------------- */
.timeline { display: flex; flex-direction: column; gap: 32px; }
.day-label { font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted-2); margin: 0 0 14px; }
.source-group { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.source-group-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.source-group-title { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--ink); }
.source-group-title:hover { color: var(--accent); }
.show-earlier { display: inline-flex; align-items: center; height: 44px; padding: 0 20px; align-self: flex-start;
  border: 1px solid var(--border); border-radius: 22px; background: var(--surface); font-size: 13px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-count { color: var(--muted-2); font-size: 12px; }

/* --- Empty states, errors, auth --------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  color: var(--muted-2); font-size: 14px; }
.error { color: var(--danger); font-size: 13.5px; margin: 0; }
.notice { max-width: 460px; margin: 0 auto; padding: 56px 24px; }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 40px 24px; }
.auth-card { width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-16);
  padding: 36px 34px; box-shadow: var(--shadow-card); }
.auth-card h1 { font-family: var(--serif); font-size: 24px; font-weight: 600; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .btn-primary { width: 100%; }

/* --- Responsive: phone chrome under 900px ------------------------------
   Non-overlapping with the min-width: 900px block above (899.98 vs. 900). */
@media (max-width: 899.98px) {
  /* The nav rail is replaced below this width by the top bar + bottom tabs
     (rendered by Layout, hidden ≥ 900px in the block above); the account
     card they don't repeat is still reachable from Settings. */
  .sidebar { display: none; }
  /* Top bar, then the page, stacked — the desktop row layout only makes sense
     with a rail to sit beside. */
  .shell { flex-direction: column; }
  /* The fixed tabbar would otherwise cover the end of the page. */
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  /* Library as two screens: the source list, or one source's highlights —
     never both panels at once. */
  [data-mobile="list"] .pane { display: none; }
  /* The list screen has no open source, so the desktop's auto-selected row
     must not look chosen. */
  [data-mobile="list"] .source-row.selected { background: transparent; border-color: transparent; box-shadow: none; }
  [data-mobile="list"] .source-row.selected .source-row-title { font-weight: 500; }
  [data-mobile="detail"] .col-sources { display: none; }

  .col-sources { width: auto; border-right: 0; padding: 16px; }
  .pane, .main { padding: 16px; }
  .card { padding: 20px 22px; }
  .review-card { padding: 32px 26px; gap: 22px; }
  .review-quote { font-size: 22px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 .span-2 { grid-column: span 1; }
  .topbar { padding: 16px; }
}

/* Phone-only chrome, hidden on desktop. Last in the file on purpose: the
   base rules above give these `display: flex`, and only a later rule of
   equal specificity can switch them off. */
@media (min-width: 900px) {
  .mobile-bar, .tabbar, .collections, .back { display: none; }
}
