/* Memex Design System — colour, type, spacing, radii, shadows.
   Source of truth: ripple.css + brand brief, ported from
   memex-design-system/project/colors_and_type.css. */

@import url("fonts.3a5f5f7e2a3a.css");

:root {
  --paper:              #fbfaf7;
  --paper-raised:       #ffffff;
  --paper-sunken:       #f4f2ed;
  --paper-edge:         #ebe8e0;

  --ink:                #1a1a1a;
  --ink-soft:           #3d3a36;
  --ink-muted:          #6b6763;
  --ink-faint:          #b0adae;
  --ink-ghost:          #d9d5ce;

  --highlight:          #ffd200;
  --highlight-wash:     rgba(255, 210, 0, 0.38);
  --highlight-faint:    rgba(255, 210, 0, 0.16);

  --ok: #3f7d4e;            /* live, available, done (spec 0086) */
  --fail: #7d3b2e;          /* a failed row in a run (spec 0089) */
  --warn: #8a6a1f;          /* needs the reader soon: a payment retrying (spec 0129) */
  --danger:             #8a2f2a;

  --font-serif:   "EB Garamond", "Garamond", "Georgia", ui-serif, serif;
  --font-sans:    "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --text-sm:     14px;
  --text-base:   16px;
  --text-md:     18px;
  --text-lg:     22px;
  --text-xl:     28px;
  --text-2xl:    36px;

  --leading-tight:  1.15;
  --leading-snug:   1.35;
  --leading-normal: 1.5;

  --tracking-snug:  -0.01em;
  --tracking-normal: 0;

  --radius-image: 1px;
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius-lg:  12px;   /* the collection ask card (spec 0131 § 2.5) */

  --dur-fast:    120ms;
}

* { box-sizing: border-box; }
/* Issue #334 — `hidden` is only a DEFAULT style, so any `display` rule on the
   element outranks it and the element never hides, whatever the JS sets. The
   control that toggles it then looks dead, because setting `hidden = false` on
   something already visible changes nothing.

   `!important` is deliberate, and is what the HTML spec's own suggested UA
   stylesheet uses: outranking a component's `display` is the entire job. Before
   this, ten components each carried their own `.x[hidden] { display: none }`,
   and the two that forgot shipped a permanently-open form with dead buttons. */
[hidden] { display: none !important; }
html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
/* Belt-and-suspenders: any user-supplied image (in note bodies,
   summaries, marginalia notes) is capped to its container so a
   native-sized photo can't blow the layout out. More specific rules
   in component scopes still win. */
img { max-width: 100%; height: auto; }

/* ---------- Top nav ---------- */
.nav {
  display: flex; align-items: center; gap: 4px;
  padding: 16px 40px;
  border-bottom: 1px solid var(--paper-edge);
  background: var(--paper);
  position: sticky; top: 0; z-index: 30;
}
.nav .spacer { flex: 1; }

/* ---------- The wordmark (#630) ----------
   One logo everywhere: "Everett" in the serif over a highlighter stroke. Every
   rendering is `<… class="wordmark"><span>Everett</span></…>`; each context
   sets only its size. */
.wordmark {
  font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.wordmark > span {
  background: linear-gradient(transparent 58%, var(--highlight-wash) 58%, var(--highlight-wash) 94%, transparent 94%);
  padding: 0 2px;
}

/* ---------- Wordmark with a menu (spec 0112 § 5; #546 option A) ----------
   Ported from the design project's `nav.css` brand variant. The wordmark links
   home; the chevron opens every page, marked where the reader is. */
.nav-app { gap: 14px; padding: 12px 40px 12px 32px; }
.nav.bm-open { z-index: 90; }
.nav .bm-left { display: flex; align-items: center; gap: 2px; flex: none; }
.nav .bm-word {
  font-size: 22px; line-height: 1;
  padding: 6px 8px; border-radius: var(--radius-sm);
}
.nav .bm-word:hover { background: var(--paper-sunken); color: var(--ink); }
.nav .bm-chev {
  width: 28px; height: 28px; border: 0; background: none; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-muted); cursor: pointer;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.nav .bm-chev svg { transition: transform 160ms ease; }
.nav .bm-chev:hover, .nav.bm-open .bm-chev { background: var(--paper-sunken); color: var(--ink); }
.nav.bm-open .bm-chev svg { transform: rotate(180deg); }
.nav .bm-menu {
  position: absolute; left: 18px; top: calc(100% - 4px); z-index: 42;
  width: 260px; display: none;
  background: var(--paper-raised); border: 1px solid var(--paper-edge); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(26, 26, 26, 0.10);
  padding: 8px;
}
.nav.bm-open .bm-menu { display: block; }
.nav .bm-grab, .nav .bm-scrim { display: none; }
.nav .bm-grp {
  font-family: var(--font-sans); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-muted);
  padding: 10px 10px 4px;
}
.nav .bm-item {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 10px; border-radius: 7px;
  font-family: var(--font-sans); font-size: 14px; color: var(--ink-soft); text-decoration: none;
}
.nav .bm-item svg { color: var(--ink-muted); flex: none; }
.nav .bm-item:hover { background: var(--paper-sunken); color: var(--ink); }
.nav .bm-item.cur { background: var(--paper-sunken); color: var(--ink); font-weight: 500; }
.nav .bm-item.cur::after {
  content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-soft);
}

/* ---------- Account: the photo, and the menu under it (spec 0086 § 5) ----------
   Ported from the design project's `chrome/nav.css`. The avatar is the only
   element in the chrome that is about the person rather than the library, so
   it sits alone at the end of the bar. */
.nav .nav-account {
  flex: none; width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 1px solid var(--paper-edge); background: var(--paper-sunken); color: var(--ink-soft);
  cursor: pointer; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 15px; font-weight: 500; line-height: 1;
  transition: box-shadow var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.nav .nav-account img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav .nav-account:hover { border-color: var(--ink-ghost); }
.nav .nav-account:focus-visible { outline: 2px solid var(--ink-ghost); outline-offset: 2px; }
/* Open reads as the highlighter about to be laid down, not as a colour change. */
.nav .nav-account[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--highlight-wash); }

.nav .account-menu {
  position: absolute; top: 100%; right: 22px; margin-top: 8px; width: 250px;
  display: none;
  background: var(--paper-raised); border: 1px solid var(--paper-edge); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(26,26,26,.10), 0 2px 6px rgba(26,26,26,.04);
  padding: 5px; z-index: 42;
}
.nav.account-open .account-menu { display: block; }
.nav .account-menu .am-who {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px 12px; margin-bottom: 5px; border-bottom: 1px solid var(--paper-edge);
}
.nav .account-menu .am-face {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--paper-edge); background: var(--paper-sunken); color: var(--ink-soft);
  overflow: hidden; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 17px;
}
.nav .account-menu .am-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav .account-menu .am-name { font-family: var(--font-sans); font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.nav .account-menu .am-addr { font-family: var(--font-sans); font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; margin-top: 1px; }
.nav .account-menu a, .nav .account-menu button, .nav .add-menu a {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 11px; border: 0; border-radius: 6px; background: none; cursor: pointer;
  text-align: left; text-decoration: none;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
}
.nav .account-menu a:hover, .nav .account-menu button:hover,
.nav .add-menu a:hover { background: var(--paper-sunken); color: var(--ink); }
.nav .account-menu i, .nav .add-menu i { color: var(--ink-muted); flex: none; }
.nav .account-menu .am-sep, .nav .add-menu .am-sep { border: none; border-top: 1px solid var(--paper-edge); margin: 6px 2px; }
.nav .account-menu .am-signout { color: var(--ink-muted); }
/* ---------- Add: one menu in the bar for every way in (#736) ----------
   Design `Everett mobile header`: `Add` beside the avatar on desktop, a bare
   bordered + on a phone. The menu is the account menu's twin; one is open at
   a time (nav_menu.js). */
.nav .nav-add { position: relative; flex: none; }
/* Spec 0140 R30 — icon-only: a 34px square +. */
.nav .nav-add-btn {
  height: 34px; width: 34px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 1px solid var(--ink-ghost); border-radius: var(--radius-sm);
  background: var(--paper-raised); color: var(--ink); cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  transition: background var(--dur-fast) ease;
}
.nav .nav-add-btn:hover, .nav.add-open .nav-add-btn { background: var(--paper-sunken); }
.nav .nav-add-btn:focus-visible { outline: 2px solid var(--ink-ghost); outline-offset: 2px; }
.nav .add-menu {
  position: absolute; top: 100%; right: 0; margin-top: 8px; width: 260px;
  display: none;
  background: var(--paper-raised); border: 1px solid var(--paper-edge); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(26,26,26,.10), 0 2px 6px rgba(26,26,26,.04);
  padding: 5px; z-index: 42;
}
.nav.add-open .add-menu { display: block; }
.nav .bm-ic-phone { display: none; }

/* A username is only claimed once a user has a public address (spec 2), so the
   two links that need it stay hidden until then. Spec 2 sets the attribute;
   the rows themselves are not rendered until it does. */
.nav[data-nav-username=""] .am-needs-username,
.nav:not([data-nav-username]) .am-needs-username { display: none; }

/* Signed-out bar (spec 0086 § 5; `Shared Item.dc.html` artboard 02): the
   wordmark, then Log in and Sign up. */
.nav .brand { font-size: 22px; line-height: 1; }
.nav .nav-auth {
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  color: var(--ink-muted); padding: 7px 12px; border-radius: var(--radius-sm);
  text-decoration: none;
}
.nav .nav-auth:hover { background: var(--paper-sunken); color: var(--ink); }
.nav .nav-auth-primary {
  color: var(--ink); background: var(--paper-raised);
  border: 1px solid var(--paper-edge); padding: 7px 14px;
}
.nav .nav-auth-primary:hover { background: var(--paper-sunken); }


/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--paper-edge); background: var(--paper-raised);
  color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-fast) ease;
  text-decoration: none;
}
.btn:hover { background: var(--paper-sunken); }
.btn:focus-visible { outline: 2px solid var(--ink-ghost); outline-offset: 2px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(138, 47, 42, 0.06); }
/* The compact button — the design's `.btn.sm`, for a row carrying several
   actions at once (`saved-page.html`'s action cluster, the figure page's
   stepper). One size below the primary is what lets six controls share a line
   with the reading stats; the difference reads as hierarchy rather than as two
   button sizes. `.ico` drops the label and squares the padding up.

   Promoted from `figure.css`, which had re-implemented it scoped to its own
   page — a global that isn't there yet looks exactly like that from inside the
   second page to want it.

   The icon-label gap is 4px, not the 6 this started at: at 6 the item page's
   sixth control still fell to a second line, and 2px across five buttons is the
   difference. Measured on the page, then pushed back to the design project's
   `saved-page.html`, so the two agree — this is not a divergence to preserve. */
.btn.sm { padding: 7px 11px; font-size: 12.5px; gap: 4px; }
.btn.sm.ico { padding: 7px 8px; }
/* The confirming button in a dialog or an action row. Dark on light, matching
   the `form button[type="submit"]` treatment below, because a reader has learnt
   that the black button is the one that commits.
 
   It lived in `collections.css` — which loads on two routes — with a note
   calling it "a candidate to promote once a second feature wants it". Two now
   do, and both were shipping it unstyled: the bulk collection picker on /items
   and /explore, and the shelf-full refusal, which base.html puts on EVERY page.
   Three white buttons in one dialog invites a click on the wrong one. */
/* The ink-filled button (spec 0086; `settings.css` and `Shared Item.dc.html`):
   the one emphatic action on a page — Save to read, Save changes. */
.btn-ink {
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  padding: 9px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-ink:hover { opacity: .92; }

.btn-primary {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink); opacity: 0.92; }
/* Moved here with `.btn-primary`, and for the same reason: the picker's Add and
   Create both START disabled, so on any page without collections.css a dark
   button sat at full strength claiming to be clickable. The primary keeps its
   fill on hover — a disabled button that turns white on hover reads as an
   invitation. */
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--paper-raised); }
.btn-primary[disabled]:hover { background: var(--ink); }

/* Icon button (square, transparent at rest, paper-raised on hover) */
.ibtn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--ink-ghost); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.ibtn:hover, .ibtn:focus-visible {
  color: var(--ink); background: var(--paper-raised);
  border-color: var(--paper-edge);
  outline: none;
}
.ibtn.danger:hover, .ibtn.danger:focus-visible {
  color: var(--danger); border-color: rgba(138, 47, 42, 0.25);
}
.ibtn.sm { width: 28px; height: 28px; }

/* ---------- Type indicator chip (kind) ---------- */
.kind {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-muted);
  padding: 2px 8px; border-radius: var(--radius-xs);
  background: var(--paper-sunken);
  flex-shrink: 0;
}
.kind.note    { color: #6a4f0f; background: rgba(255, 210, 0, 0.18); }
.kind.voice   { color: #6a4f0f; background: rgba(255, 210, 0, 0.18); }  /* spec 0092: a blog as a voice */
.kind.pdf     { color: #5a4634; background: #efe9df; }
.kind.webpage { color: #4a4a4a; background: #ececec; }

.kind.processing {
  color: var(--ink-muted);
  background: var(--paper-sunken);
  animation: chip-pulse 1.6s ease-in-out infinite;
}
.kind.processing svg { animation: chip-spin 1.6s linear infinite; }
@keyframes chip-pulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}
@keyframes chip-spin { to { transform: rotate(360deg); } }

/* Waiting dots: the text never carries its own, the animation counts them up
   from none, 0.5 s a step — "Working", "Working.", "Working..", "Working...".
   `{% waiting_dots %}` sets --dots-phase from the clock, so a line redrawn by a
   poll carries on instead of restarting (apps/core/templatetags/waiting.py). */
.dots::after {
  content: "";
  animation: dots 2s steps(1, end) infinite;
  animation-delay: var(--dots-phase, 0s);
}
@keyframes dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}
@media (prefers-reduced-motion: reduce) {
  .dots::after { animation: none; content: "..."; }
}

/* ---------- Messages (Django flash messages) ---------- */
.message {
  font-family: var(--font-sans); font-size: 13px;
  padding: 10px 14px;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  margin: 16px 40px 0;
}
.message.error { color: var(--danger); border-color: rgba(138, 47, 42, 0.25); }

/* ---------- Generic prose (used by note bodies and the summary) ---------- */
.prose {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink);
}
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.05em; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--font-serif);
  color: var(--ink-soft);
  font-weight: 500;
  line-height: var(--leading-snug);
  margin: 1.4em 0 0.5em;
}
.prose h1 { font-size: var(--text-2xl); }
.prose h2 { font-size: var(--text-xl); }
.prose h3 { font-size: var(--text-lg); }
.prose h4, .prose h5, .prose h6 { font-size: var(--text-md); }
.prose img {
  max-width: 100%;
  display: block;
  margin: 1.4em auto;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-image);
  background: var(--paper-raised);
  padding: 6px;
}
.prose ul, .prose ol { padding-left: 1.5rem; margin: 0.75rem 0; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin-bottom: 0.35rem; }
.prose li p { margin: 0; }
.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--ink-ghost);
  text-underline-offset: 3px;
}
.prose a:hover { text-decoration-color: var(--highlight); }
.prose .img-page {
  display: inline-block; margin-left: 0.5rem;
  font-family: var(--font-sans); font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.prose a.summary-img-link { display: inline-block; }
.prose code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--paper-sunken);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-xs);
  color: var(--ink-soft);
}
/* Inside <pre>, the inline-code styling above produces a per-line
   pill effect (one rectangle per visual line of preformatted content).
   Reset to a single block-level treatment on the <pre> itself. */
.prose pre {
  background: var(--paper-sunken);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  overflow-x: auto;
}
.prose pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.prose p:has(img + img) { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.prose p:has(img + img) img { flex: 1 1 calc((100% - 12px) / 2); max-width: calc((100% - 12px) / 2); height: auto; }

/* ---------- KaTeX math ----------
   Display math (`$$…$$` / `\[…\]`) is wrapped by the renderer in .math-block.
   KaTeX supplies its own typography via katex.min.css; we only need to keep a
   wide equation from breaking the page — scroll it instead. Applies on every
   surface that renders markdown (summaries, notes, agent answers).
   These two overrides share katex.min.css's specificity, so base.html loads
   that sheet BEFORE this one — the other way round, KaTeX's own 1.21em and
   1em margins win and the nudge below never applies (#450). */
.math-block { overflow-x: auto; overflow-y: hidden; margin: 1.1em 0; }
.katex-display { margin: 0; }        /* our .math-block owns the vertical rhythm */
/* KaTeX_Main's x-height is well above EB Garamond's; 0.95em is where a_n
   sits level with the word beside it (checked on the reader, #450). */
.katex { font-size: 0.95em; }

/* ---------- Plain-text uploads ----------
   .txt files are rendered as escaped text inside this container so leading
   whitespace, asterisks, hashes, and brackets survive verbatim — no
   markdown2 interpretation. Monospace because .txt files commonly rely on
   column alignment (screenplays, ASCII tables, fixed-width logs). */
.plain-text {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ---------- Inline note editor (spec 0042) ----------
   The Milkdown editing surface reuses .prose (added in the template) so edit and
   read look identical. These classes style the Memex chrome around it (status,
   images drawer) with design tokens; Milkdown's own slash menu / toolbar / block
   handle come from editor.min.css (Crepe), lightly aligned to our paper/ink below. */
.note-editor {
  position: relative;
}
/* Autosave status lives in the page's top row (masthead meta-row / create-page
   eyebrow), not above the editor — set by note_editor.js. */
.note-editor-status {
  font-family: var(--font-sans);
  font-size: 12px; /* match the inline meta-row text exactly (same size/metrics → aligned) */
  color: var(--ink-faint);
  transition: color var(--dur-fast) ease;
}
.note-editor-status[data-state="error"] { color: var(--danger); }
/* Create page: "New note" eyebrow left, autosave status right, on one compact row. */
.note-create-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.note-editor-surface { outline: none; }
/* A UserItemNote (note on a PDF/webpage) is marginalia: the editor carries the
   same gray left rule as the 1A empty affordance and the rendered .note-block, so
   the bar stays consistent across empty → editing → saved. */
.note-editor--margin {
  border-left: 2px solid var(--ink-ghost);
  padding-left: 22px;
  margin: 0 0 32px;
}
/* Crepe paints its own frame + theme; strip the frame and align the EDITING
   content (not the menus/toolbar, which stay in Crepe's sans UI font) to the
   .prose type scale. Selectors are scoped under .note-editor so they out-specify
   Crepe's `.milkdown …` rules, which load after design.css. */
.note-editor .milkdown {
  background: transparent;
  box-shadow: none;
  --crepe-font-code: var(--font-mono);
  --crepe-color-background: transparent;
  --crepe-color-on-background: var(--ink);
}
/* Full-width editing surface — Crepe defaults to `padding:60px 120px`; drop the
   horizontal inset so the body fills the .prose column (the block handle then
   sits in the page's left margin). */
.note-editor .milkdown .ProseMirror {
  padding: 8px 0;
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink);
}
/* Mirror .prose block spacing so what you type renders identically to the display
   (Crepe's paragraph/heading sizes AND margins differ from .prose). */
.note-editor .milkdown .ProseMirror > :first-child {
  margin-top: 0;
}
/* Crepe sets `.ProseMirror p { font-size:16px; line-height:24px; padding:4px 0 }`
   directly on the paragraph, out-specifying the 19px on .ProseMirror above — so
   restate the .prose body metrics (19px / 1.65) on the paragraph itself, or note
   text renders two sizes smaller than summaries and highlights. Applies to list
   paragraphs too (they're `.ProseMirror p`), so bullet text matches as well. */
.note-editor .milkdown .ProseMirror p {
  font-size: 19px;
  line-height: 1.65;
  padding: 0;
  margin: 0 0 1.05em;
}
.note-editor .milkdown .ProseMirror h1,
.note-editor .milkdown .ProseMirror h2,
.note-editor .milkdown .ProseMirror h3,
.note-editor .milkdown .ProseMirror h4,
.note-editor .milkdown .ProseMirror h5,
.note-editor .milkdown .ProseMirror h6 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--ink-soft);
  line-height: var(--leading-snug);
  margin: 1.4em 0 0.5em;
  padding: 0;
}
.note-editor .milkdown .ProseMirror h1 { font-size: var(--text-2xl); }
.note-editor .milkdown .ProseMirror h2 { font-size: var(--text-xl); }
.note-editor .milkdown .ProseMirror h3 { font-size: var(--text-lg); }
.note-editor .milkdown .ProseMirror h4,
.note-editor .milkdown .ProseMirror h5,
.note-editor .milkdown .ProseMirror h6 {
  font-size: var(--text-md);
}
/* List markers. Baseline-align the row so an ordered number (real text) sits on
   the text baseline. Make the label a block with the .prose line-height so its
   baseline IS the text line's baseline. The unordered bullet is a 24×24 SVG with
   its dot centered (cy=12) — baseline-aligning would land the SVG's bottom edge on
   the text baseline and float the dot ~12px too high, so `vertical-align: middle`
   drops the dot onto the text's x-height. One rule set handles ol and ul. */
.note-editor .milkdown milkdown-list-item-block > .list-item {
  align-items: baseline;
}
.note-editor .milkdown milkdown-list-item-block li .label-wrapper {
  display: block;
  height: auto;
  padding: 0;
  line-height: 1.65;
  text-align: right;
}
.note-editor .milkdown milkdown-list-item-block li .label-wrapper .label {
  height: auto;
  padding: 0;
}
.note-editor .milkdown milkdown-list-item-block li .label-wrapper .label svg {
  vertical-align: middle;
}
/* List spacing: mirror `.prose` (`li p { margin: 0 }` + `li { margin-bottom:
   0.35rem }`). Without the paragraph reset, each list item's inner paragraph
   inherits the 1.05em block margin above and every bullet balloons apart — the
   summary prose packs tight, so the note editor should too. */
.note-editor .milkdown .ProseMirror milkdown-list-item-block p {
  margin: 0;
}
.note-editor .milkdown .ProseMirror milkdown-list-item-block {
  margin-bottom: 0.35rem;
}

/* Click-to-edit title (spec 0042). The h1 itself is the affordance. */
.editable-title {
  cursor: text;
  border-radius: var(--radius-xs);
  transition: background var(--dur-fast) ease;
}
.editable-title:hover { background: var(--paper-sunken); }
.editable-title.is-empty { color: var(--ink-faint); font-style: italic; }
.title-edit-input {
  font: inherit;
  /* The input lives inside the h1, which is still `.is-empty` (italic, muted)
     until a title is saved — reset both so typing renders as a normal title. */
  font-style: normal;
  color: var(--ink);
  width: 100%;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  outline: none;
}
.note-format-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.note-body-editor { margin: 16px 0; }
/* Spec 0127 § 5: a highlight on a note, drawn as an editor decoration — the
   reader's highlighter wash (reader.css .reader-highlight). */
.note-highlight {
  background: var(--highlight-wash);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: pointer;
}

/* Design 1A "The empty note" — the Add-a-note affordance for saved items
   (spec 0042). An empty marginalia note: a left rule + serif-italic prompt that
   blooms to ink + a faint-highlight wash on hover, previewing what a filled note
   becomes. Rendered as a full-width button; reset the browser chrome. */
.note-empty {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: none;
  border-left: 2px solid var(--ink-ghost);
  background: transparent;
  padding: 10px 0 10px 22px;
  margin: 0 0 32px;
  cursor: text;
  transition: border-color 120ms ease, background 120ms ease;
}
.note-empty:hover {
  border-left-color: var(--ink);
  background: var(--highlight-faint);
}
.note-empty-inner {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink-faint);
}
.note-empty-inner svg { flex: none; }

/* A written note-on-item is click-to-edit (like the title): the whole marginalia
   block opens the editor, blooming to an ink rule + faint-highlight wash on hover —
   the same gesture as the 1A empty affordance. No separate Edit button. */
.note-block--edit {
  cursor: text;
  transition: border-color 120ms ease, background 120ms ease;
}
.note-block--edit:hover,
.note-block--edit:focus-visible {
  border-left-color: var(--ink);
  background: var(--highlight-faint);
  outline: none;
}

/* ---------- Forms (overrides for design system) ---------- */
input[type="text"], input[type="url"], input[type="email"],
input[type="password"], input[type="file"], textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink);
}
textarea { min-height: 280px; font-family: var(--font-mono); font-size: 14px; line-height: 1.5; }
input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ink-ghost); outline-offset: 1px;
}
label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.error { color: var(--danger); font-size: 13px; }
/* Checkboxes need to defeat the generic input + label rules above. */
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
}
.checkbox-field label {
  display: inline;
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
}
/* Spec 0041: a disabled (unverified-email) opt-in reads muted, with a teaching
   hint below carrying an inline "Resend verification" button styled as a link
   (an explicit colour so it doesn't inherit the browser-default purple). */
.checkbox-field input[type="checkbox"]:disabled + label { color: var(--ink-faint); }
.checkbox-hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}
.checkbox-hint .linklike {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
}
.checkbox-hint .linklike:hover { color: var(--ink-soft); }
/* The "Sent ✓" acknowledgement after a resend. A fresh node is swapped in on
   every click, so this highlight-fade replays each time — the signal that a
   repeated "Send again" actually fired. */
.checkbox-hint .resend-flash {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 3px;
  border-radius: 3px;
  color: var(--ink);
  animation: resend-flash 0.8s ease-out;
}
@keyframes resend-flash {
  from { background-color: rgba(255, 210, 0, 0.6); }
  to { background-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .checkbox-hint .resend-flash { animation: none; }
}
form button[type="submit"] {
  margin-top: 16px;
  padding: 9px 18px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  cursor: pointer;
}
form button[type="submit"]:hover { opacity: 0.92; }
form button[type="submit"]:disabled { opacity: 0.45; cursor: default; }

/* ---------- Generic page wrapper ---------- */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 28px 96px;
}
.page-form {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 28px 96px;
}
.page-form h1 {
  font-family: var(--font-serif); font-weight: 500;
  font-size: var(--text-2xl); line-height: var(--leading-tight);
  letter-spacing: var(--tracking-snug);
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.page-form .lede {
  font-family: var(--font-sans); font-size: 13px;
  color: var(--ink-muted);
  margin: 0 0 28px;
}
.page-form form > div { margin-bottom: 18px; }

/* ---------- Form action row (submit + cancel) ---------- */
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}
.form-actions a.cancel {
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.form-actions a.cancel:hover { color: var(--ink); background: var(--paper-sunken); }

/* Surrounding form's default-styled submit button (set by the global
   `form button[type="submit"]` rule) needs no extra margin when it
   lives inside .form-actions. */
.form-actions form button[type="submit"],
.form-actions button[type="submit"] { margin-top: 0; }

/* Sign-in action row: providers on the left, primary actions kept right.
   margin-left:auto keeps the primary group right even when no provider is
   configured, so the base .form-actions justify-content is left untouched. */
.auth-providers { display: flex; align-items: center; gap: 12px; }
/* Sign in (#709): "Forgot your password?" is the form's last element, so it
   is tabbed to after Sign in, and is drawn on the Password label's row. Every
   item spans both columns but that label; dense packing drops the link into
   the one free cell, beside it. A quiet link: a faint underline in the voice
   of the help text, not the highlighter. */
.auth-form { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; grid-auto-flow: row dense; }
.auth-form > *, .auth-password > * { grid-column: 1 / -1; }
.auth-password { display: contents; }
.auth-password > label { grid-column: 1; }
.auth-password > :last-child { margin-bottom: 18px; }
.auth-forgot {
  grid-column: 2; align-self: center; margin-bottom: 6px;
  font-family: var(--font-sans); font-size: 13px; color: var(--ink-muted);
  text-decoration: underline; text-decoration-color: var(--ink-ghost); text-underline-offset: 2px;
}
.auth-forgot:hover { color: var(--ink); text-decoration-color: currentColor; }
.form-actions .form-actions-primary {
  display: flex; align-items: center; gap: 12px; margin-left: auto;
}

/* On mobile the three sign-in actions (Google / Create account / Sign in)
   cram onto one row and wrap their labels ("Sign / in") — issue #211.
   Stack them full-width instead. */
@media (max-width: 640px) {
  .form-actions.auth-actions { flex-direction: column; align-items: stretch; gap: 12px; }
  .auth-actions .auth-providers,
  .auth-actions .form-actions-primary { flex-direction: column; align-items: stretch; margin-left: 0; gap: 12px; }
  .auth-actions .btn-google,
  .auth-actions .form-actions-primary button[type="submit"] { width: 100%; }
  .auth-actions .form-actions-primary a.cancel { text-align: center; }
}

/* ---------- Google sign-in button (Google brand guidelines, light theme) ----------
   The whites/greys here are Google's mandated identity colors, not theme tokens,
   so they're intentionally hardcoded. Selectors are container-scoped so they beat
   the global `form button[type="submit"]` dark styling on the POST-form variant. */
.btn-google,
.form-actions .btn-google,
.auth-card .btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 40px; padding: 0 12px; margin: 0;
  background: #ffffff; color: #1f1f1f;
  border: 1px solid #747775; border-radius: 6px;
  font-family: 'Roboto', var(--font-sans); font-weight: 500; font-size: 14px;
  letter-spacing: 0.25px; text-decoration: none; cursor: pointer;
  transition: background var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.btn-google:hover,
.form-actions .btn-google:hover,
.auth-card .btn-google:hover {
  background: #f7f8f8; box-shadow: 0 1px 2px rgba(60, 64, 67, 0.20);
}
.btn-google svg { display: block; flex: none; }

/* ---------- Sign in via Google (allauth socialaccount/login.html) ---------- */
.auth-card {
  width: 100%; max-width: 440px; margin: 24px auto 0;
  background: var(--paper-raised); border: 1px solid var(--paper-edge);
  border-radius: 8px; padding: 40px; text-align: center; box-sizing: border-box;
}
.auth-card .auth-bridge {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 26px;
}
.auth-card .auth-bridge .auth-wordmark { font-size: 24px; }
.auth-card h1 {
  font-family: var(--font-serif); font-weight: 500; font-size: 30px;
  line-height: 1.15; letter-spacing: -0.01em; color: var(--ink-soft);
  margin: 0 0 14px;
}
.auth-card .auth-lede {
  font-family: var(--font-sans); font-size: 15px; line-height: 1.55;
  color: var(--ink-muted); margin: 0 0 30px;
}
/* Full-width 44px continue variant (overrides the inline base sizing above). */
.auth-card .btn-google { width: 100%; height: 44px; padding: 0 16px; }
.auth-card .auth-cancel {
  display: inline-block; margin-top: 20px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  color: var(--ink-muted); text-decoration: none;
}
.auth-card .auth-cancel:hover { color: var(--ink); }

/* ---------- Warning / dedup blocks on capture forms ---------- */
.warning {
  background: rgba(255, 210, 0, 0.10);
  border: 1px solid rgba(255, 210, 0, 0.4);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 24px;
}
.warning p:first-child { margin-top: 0; }
.warning p:last-child { margin-bottom: 0; }
.warning ul { padding-left: 1.25rem; margin: 8px 0; }
.warning a { color: var(--ink); text-decoration-color: var(--highlight); }

/* ── Global lexical search box, in the nav (spec 0033, Direction A) ─────── */
.nav-search { position: relative; flex: 1; min-width: 0; display: flex; justify-content: center; padding: 0 22px; }
.search-field { position: relative; display: flex; align-items: center; gap: 9px; width: 100%; max-width: 360px;
  background: var(--paper-raised); border: 1px solid var(--paper-edge); border-radius: 9px; padding: 7px 10px 7px 12px;
  cursor: text; transition: max-width 200ms cubic-bezier(.2,.7,.3,1), border-color 120ms ease, box-shadow 120ms ease; }
.search-field:hover { border-color: var(--ink-ghost); }
.nav-search.is-open .search-field { max-width: 600px; border-color: var(--ink-ghost); box-shadow: 0 0 0 4px var(--highlight-faint); }
.search-lead { color: var(--ink-faint); flex: none; display: inline-flex; transition: color 120ms ease; }
.nav-search.is-open .search-lead { color: var(--ink-muted); }
/* `.search-field` in the selector: the bare form-field rule (`input[type="text"]`)
   outranks a lone class and drew a second box inside the field (#736). */
.search-field .search-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-family: var(--font-sans); font-size: 14px; line-height: 1.45; color: var(--ink); padding: 1px 0; }
.search-input::placeholder { color: var(--ink-faint); }
.search-kbd { flex: none; font-family: var(--font-sans); font-size: 11px; font-weight: 500; color: var(--ink-faint);
  border: 1px solid var(--paper-edge); border-radius: 5px; padding: 0 6px; line-height: 18px; min-width: 18px;
  text-align: center; background: var(--paper-sunken); }
.nav-search.is-open .search-kbd, .nav-search.has-text .search-kbd { display: none; }
.search-clear { display: none; flex: none; width: 22px; height: 22px; border-radius: 5px; border: 0; background: none;
  cursor: pointer; color: var(--ink-faint); align-items: center; justify-content: center; transition: background 120ms ease; }
.search-clear:hover { background: var(--paper-sunken); color: var(--ink-muted); }
.nav-search.has-text .search-clear { display: inline-flex; }

.search-panel { position: absolute; top: calc(100% + 9px); left: 50%; transform: translateX(-50%); z-index: 60;
  width: 600px; max-width: calc(100vw - 48px); max-height: min(74vh, 612px); overflow-y: auto;
  background: var(--paper-raised); border: 1px solid var(--paper-edge); border-radius: 13px;
  box-shadow: 0 16px 40px rgba(26,22,18,0.11), 0 3px 10px rgba(26,22,18,0.05); padding: 7px; }

.search-panel .ask { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 9px;
  background: var(--highlight-wash); border: 1px solid rgba(202,168,58,0.4); text-decoration: none; }
.search-panel .ask .aico { color: #9a7d12; flex: none; display: inline-flex; }
.search-panel .ask .abody { flex: 1; min-width: 0; }
.search-panel .ask .aline { display: block; font-family: var(--font-sans); font-size: 14px; color: var(--ink-soft); }
.search-panel .ask .aline b { font-weight: 600; color: var(--ink); }
.search-panel .ask .asub { display: block; font-family: var(--font-sans); font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }
.search-panel .ask .akbd kbd { font-family: var(--font-sans); font-size: 11px; border: 1px solid rgba(154,125,18,0.3);
  border-radius: 5px; background: var(--paper-raised); padding: 0 6px; line-height: 18px; color: #9a7d12; }

.search-panel .sec { padding: 4px 2px; }
.search-panel .ask + .sec, .search-panel .sec + .sec { border-top: 1px solid var(--paper-edge); margin-top: 5px; padding-top: 8px; }
.search-panel .shead { display: flex; align-items: baseline; gap: 8px; padding: 4px 10px 6px; }
.search-panel .slabel { font-family: var(--font-sans); font-size: 10.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-faint); }
.search-panel .scount { font-family: var(--font-sans); font-size: 11px; color: var(--ink-ghost); }

.search-panel .row { display: flex; gap: 11px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; text-decoration: none; }
.search-panel .row:hover, .search-panel .row.hi { background: var(--highlight-faint); }
.search-panel .ico { flex: none; width: 22px; color: var(--ink-muted); display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.search-panel .main { min-width: 0; flex: 1; }
.search-panel .trow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.search-panel .title { font-family: var(--font-sans); font-weight: 500; font-size: 14px; line-height: 1.3; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-panel .snippet { font-family: var(--font-serif); font-size: 14px; line-height: 1.45; color: var(--ink-muted); margin: 2px 0 0; }
.search-panel .snippet mark, .search-panel .title mark, .search-panel .matched mark { background: var(--highlight-wash); border-radius: 2px; padding: 0 1px; color: inherit; }
/* Spec 0138 § 4.5 — a highlight found through its claim: the claim, read (serif), under a sans label. */
.search-panel .matched { font-family: var(--font-serif); font-size: 13px; line-height: 1.4; color: var(--ink-muted); margin: 3px 0 0; }
.search-panel .matched .matched-label { font-family: var(--font-sans); font-size: 12px; margin-right: 4px; }
.search-panel .chip { flex: none; font-family: var(--font-sans); font-size: 9.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-muted); background: var(--paper-sunken); padding: 1px 6px; border-radius: 4px; }
.search-panel .chip.claim { color: #4a4a4a; background: #ececec; }
.search-panel .chip.highlight { color: #6a4f0f; background: rgba(255,210,0,0.2); }
.search-panel .chip.concept { color: #3f5c6b; background: rgba(63,92,107,0.1); }
.search-panel .quiet { display: flex; align-items: center; gap: 11px; padding: 10px; font-family: var(--font-sans);
  font-size: 13.5px; color: var(--ink-muted); }
.search-panel .thumb { flex: none; width: 110px; height: 110px; border: 1px solid var(--paper-edge);
  border-radius: 3px; overflow: hidden; background: var(--paper-sunken); }
.search-panel .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Image rows: larger thumbnail, title centered against it, allowed to wrap. */
.search-panel .row.image { align-items: center; }
.search-panel .row.image .title { white-space: normal; }
/* Issue #632 C — a followed row names its collection; the section's searching state. */
.search-panel .from { display: block; font-family: var(--font-sans); font-size: 12px; color: var(--ink-muted); margin-top: 3px; }
.search-panel .quiet .spin { display: inline-flex; animation: chip-spin 900ms linear infinite; }

/* ── Responsive header (spec 0033; the menu per spec 0112 § 5) ──
   Below 760px the wordmark hides, the page menu becomes a bottom sheet, and the
   search box fills the bar with its results as a pinned
   full-width sheet (not a field-centered popover). Placed last so these rules
   win on source order — media queries don't add specificity. */
@media (max-width: 760px) {
  .nav { padding: 12px 14px; gap: 8px; }
  /* Spec 0112 § 5 — the wordmark gives way to search; the chevron becomes a
     button that opens the pages as a two-column bottom sheet. */
  .nav-app { padding: 10px 14px; gap: 10px; }
  .nav .bm-word { display: none; }
  .nav .bm-chev {
    width: 40px; height: 40px; border: 1px solid var(--paper-edge);
    background: var(--paper-raised); border-radius: 8px;
  }
  .nav .bm-scrim { position: fixed; inset: 0; background: rgba(26, 26, 26, 0.28); z-index: 41; }
  .nav.bm-open .bm-scrim { display: block; }
  .nav .bm-menu {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto;
    border-radius: 18px 18px 0 0; border-width: 1px 0 0; padding: 8px 12px 26px;
  }
  .nav .bm-grab {
    display: block; width: 38px; height: 4px; border-radius: 2px;
    background: var(--ink-ghost); margin: 2px auto 8px;
  }
  .nav .bm-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; }
  .nav .bm-item { font-size: 16px; padding: 11px 10px; min-height: 44px; }
  /* The photo stays in the bar: it is the account, not a destination. */
  .nav .account-menu { right: 10px; left: 10px; width: auto; }
  .nav .account-menu a, .nav .account-menu button { font-size: 16px; min-height: 44px; }
  /* #736 — the menu's glyph, a bare +, and its menu the bar's full width. */
  .nav .bm-ic-desk { display: none; }
  .nav .bm-ic-phone { display: block; }
  .nav .nav-add { position: static; }
  .nav .nav-add-btn { width: 40px; height: 40px; padding: 0; justify-content: center; border-color: var(--paper-edge); border-radius: 8px; }
  .nav .add-menu { right: 10px; left: 10px; width: auto; }
  .nav .add-menu a { font-size: 16px; min-height: 44px; }
  .search-kbd { display: none; }

  .nav-search { padding: 0; }
  .nav-search .search-field,
  .nav-search.is-open .search-field { max-width: none; }

  /* Results become a full-width sheet pinned under the bar with equal gutters
     — not centered on the (right-shifted) field. --nav-h is set by nav_menu.js. */
  .search-panel {
    position: fixed;
    top: var(--nav-h, 61px);
    left: 10px; right: 10px;
    width: auto; max-width: none;
    transform: none;
    max-height: calc(100vh - var(--nav-h, 61px) - 16px);
  }

  /* Mobile browsers (iOS Safari especially) auto-zoom the viewport when a
     focused field's font-size is under 16px — which shoved the search results
     off the left edge. Render text-entry fields at exactly 16px on mobile to
     remove the zoom trigger; the deliberate desktop sizing is untouched.
     `!important` because every page stylesheet that sizes its own field
     (`.search-field .search-input`, `.composer input`, `.pp-field input`, …)
     outranks or follows this rule, and the zoom came back that way (#890).
     Pinned by test_field_polish.py. */
  .search-input,
  input[type="text"], input[type="search"], input[type="url"],
  input[type="email"], input[type="password"], input[type="tel"],
  input[type="number"], input:not([type]), textarea, select {
    font-size: 16px !important;
  }
}

/* ---------- Question list (spec 0073) ----------
 * The agent's suggested questions, wherever they appear: the collection page,
 * the item page, and each answer turn in /explore. Global rather than
 * page-scoped because it is now the default treatment for "questions you could
 * ask" — it lived in `collections.css` and, under a second name (`.q-card`), in
 * `main.css`, and two copies of one component is how they drift.
 *
 * Ported from the design's `collections.css` + `saved-page.html`, whose own
 * comment says the item page is "structurally identical to the collection
 * page's .q-list". Shape: sparkle → question → arrow, in a bordered card, with
 * an optional sunken ask row closing it.
 *
 * (The home-deck card keeps its own `.item-questions` treatment in `main.css`
 * until the deck refactor; it is a denser context and adopting this is that
 * spec's call, not this one's.) */
.q-list {
  display: flex;
  flex-direction: column;
  background: var(--paper-raised);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  overflow: hidden;
}
/* Dividers between children rather than on each row. A row is wrapped in its
 * own <form> (CSRF + the question's pk), so the design's `.q-row:last-of-type`
 * would match EVERY row — each is the only one of its type inside its form. */
.q-list > * + * { border-top: 1px solid var(--paper-edge); }
.q-list .q-row-form { margin: 0; }
/* (0,2,0), so it outranks design.css's own `form button[type="submit"]`
 * (0,1,2) primary style — otherwise every question renders as a solid black
 * pill. The three properties that rule sets and this must undo are `background`,
 * `margin-top` and `padding`. */
.q-list .q-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 0;
  padding: 14px 16px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-weight: 400;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.q-list .q-row:hover { background: var(--highlight-faint); }
.q-list .q-spark { flex: none; color: var(--ink-faint); }
.q-list .q-row:hover .q-spark { color: var(--ink-soft); }
.q-list .q-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink-soft);
  text-wrap: pretty;
}
.q-list .q-row:hover .q-text { color: var(--ink); }
.q-list .q-go { flex: none; margin-left: auto; color: var(--ink-ghost); }
.q-list .q-row:hover .q-go { color: var(--ink-soft); }
/* Ask-your-own — a sunken row closing the card, so it reads as the last row of
 * the list rather than a separate control. */
.q-list .q-ask {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 16px;
  background: var(--paper-sunken);
}
.q-list .q-ask input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.q-list .q-ask input::placeholder { color: var(--ink-faint); }
.q-list .q-ask input:focus { outline: none; border-color: var(--ink-muted); }
.q-list .q-ask .ask {
  flex: none;
  width: auto;
  margin-top: 0;
  padding: 9px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.q-list .q-ask .ask:hover { opacity: 0.88; }
/* A line under the card saying where the questions came from. */
.q-foot {
  margin: 9px 2px 0;
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ---------- Dialogs (moved here in spec 0071) ----------
   Floating UI, so this is one of the few places a shadow belongs (design rule 6).

   Global rather than page-scoped: the shelf-cap refusal is a dialog and it can
   fire from any surface that shelves an item — a list row, the item page, the
   reader, a collection page. It shipped inside `collections.css`, which loads on
   two routes.

   `.scrim` is display:none until `.open`, rather than relying on the `hidden`
   attribute: a stylesheet that sets `display` on its own children beats the
   attribute — which is exactly how the collections page first shipped with its
   "new collection" form permanently visible. */
.scrim {
  position: fixed; inset: 0;
  background: rgba(26, 26, 26, 0.35);
  display: none; align-items: center; justify-content: center;
  z-index: 80; padding: 24px;
}
.scrim.open { display: flex; }
.dialog {
  background: var(--paper-raised);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(26, 26, 26, 0.22);
  padding: 22px 24px 20px;
  width: 100%; max-width: 470px;
  font-family: var(--font-sans);
  margin: 0;
}
.dialog h3 {
  font-family: var(--font-sans); font-weight: 500; font-size: 16px;
  margin: 0 0 6px; color: var(--ink-soft);
}
.dialog .sub {
  margin: 0 0 14px;
  font-size: 13.5px; line-height: 1.5; color: var(--ink-muted);
}
.dlg-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 16px; }
/* Same reset, same reason, as `.form-actions` above: `form button[type="submit"]`
   carries a 16px top margin and out-specifies the button classes, so without
   this the confirming button hangs below the Cancel beside it in every dialog. */
.dlg-actions button[type="submit"] { margin-top: 0; }
/* The destructive confirm, ported from `share-item.html` (design project
   d1094e75…), which has specified it since the dialog was drawn. Without it
   `.btn.danger`'s red text out-specifies `.btn-primary`'s paper text and the
   button renders dark red on near-black — about 1.7:1, and it reads as a
   mistake rather than a warning. The fill keeps the "filled button commits"
   convention while saying which kind of commit it is. */
.dialog .btn-primary.danger {
  background: var(--danger); border-color: var(--danger); color: var(--paper-raised);
}
.dialog .btn-primary.danger:hover {
  background: var(--danger); color: var(--paper-raised); opacity: 0.92;
}

/* ---------- The Sounding Board's start box (spec 0140 V1) ----------
   Global because both doors are: the home card's Start and the + menu's
   New sounding board, on every page. Ported from the canvas's StartModal. */
.sb-start-scrim { align-items: flex-start; padding-top: 120px; }
.dialog.sb-start { max-width: 560px; }
.sb-dlg-label {
  display: block; margin: 0 0 6px; font-family: var(--font-sans); font-size: 13px;
  font-weight: 600; color: var(--ink-muted); text-transform: none; letter-spacing: 0;
}
.sb-dlg-input {
  display: block; width: 100%; box-sizing: border-box; min-height: 132px; padding: 10px 12px;
  border: 1px solid var(--paper-edge); border-radius: 8px; background: var(--paper-raised);
  font-family: var(--font-serif); font-size: 18px; line-height: 1.5; color: var(--ink); resize: vertical;
}
.sb-dlg-input::placeholder { color: var(--ink-faint); }
.sb-dlg-input:focus { outline: none; border-color: var(--ink-ghost); }
.sb-dlg-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
.sb-dlg-foot .dlg-actions { margin-top: 0; }
.dialog .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.sb-grab { display: none; }
@media (max-width: 640px) {
  .sb-start-scrim { align-items: flex-end; padding: 0; }
  .dialog.sb-start { max-width: none; border-radius: 12px 12px 0 0; border-bottom: 0; padding: 10px 16px 24px; }
  .sb-grab { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--ink-ghost); margin: 0 auto 14px; }
  .sb-dlg-input { font-size: 17px; min-height: 150px; }
  .sb-dlg-foot .dlg-actions { width: 100%; }
  .sb-dlg-foot .dlg-actions .btn { flex: 1; min-height: 44px; font-size: 15px; }
}

/* ---------- The collection picker (moved here in spec 0075) ----------
   One row shape, two dialogs: the item page's `+` (0072 § 5.1) and the /items
   bulk picker (0075 § 4). It lived in `collections.css`, which loads on two
   routes — so on /items the rows fell all the way through to browser defaults,
   which on iOS renders a bare `<button>` in link blue. Exactly what the design
   rule about never shipping an unstyled control exists to catch. */
.coll-opt-form { margin: 0; }
.coll-opt {
  display: flex; align-items: flex-start; gap: 11px; width: 100%;
  padding: 9px 8px; border: 0; border-radius: var(--radius-sm);
  background: none; text-align: left; cursor: pointer;
  font-family: var(--font-sans);
}
.coll-opt:hover { background: var(--paper-sunken); }
.coll-opt .box {
  flex: none; width: 17px; height: 17px; margin-top: 1px;
  border-radius: var(--radius-xs); border: 1px solid var(--ink-ghost);
  background: var(--paper-raised);
  display: grid; place-items: center; color: transparent;
}
.coll-opt[aria-pressed="true"] .box {
  background: var(--ink); border-color: var(--ink); color: var(--paper);
}
.coll-opt-main { min-width: 0; flex: 1; }
.coll-opt-name { display: block; font-size: 14px; color: var(--ink-soft); line-height: 1.35; }
.coll-opt-desc {
  display: block; font-family: var(--font-serif); font-size: 13px;
  color: var(--ink-muted); line-height: 1.4; margin-top: 2px;
}
.coll-opt-n { flex: none; font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.coll-new-inline {
  display: flex; gap: 8px;
  border-top: 1px solid var(--paper-edge);
  margin-top: 12px; padding-top: 12px;
}
.coll-new-inline input {
  flex: 1; min-width: 0;
  font-family: var(--font-sans); font-size: 14px; color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--ink-ghost); border-radius: var(--radius-sm);
  background: var(--paper-raised);
}


/* The picker's scroll region. Long enough to browse, bounded so the dialog
   cannot outgrow a phone. */
.dlg-list { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; }
.dlg-list .coll-opt-desc {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Initials avatar (spec 0089): a face stands in when there is a photo. */
.av {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--paper-sunken); border: 1px solid var(--paper-edge);
  font-family: var(--font-sans); font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--ink-muted); overflow: hidden;
}
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Selection actions (issue #485, design "Selection Actions") ----------
   Global since spec 0127: the reader and a note's own page share it.
   One component, two placements, chosen by the input that made the selection:
   `.is-dock` at the bottom of the screen for touch (the system edit menu owns the
   space next to a touch selection), `.is-popover` next to the selection for a
   mouse. Same buttons, labels and order in both. Floating UI, so it may cast the
   popover shadow (memex-design rule 6). */
.sel-actions {
  position: fixed;
  z-index: 2000;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px;
  font-family: var(--font-sans);
  background: var(--paper-raised);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(26, 26, 26, 0.14);
}
.sel-actions.is-visible { display: flex; }
.sel-actions .sel-count { display: none; }
.sel-actions .sel-btn {
  height: 32px;
  margin: 0;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.sel-actions .sel-btn:hover { background: var(--paper-edge); }
.sel-actions .sel-highlight { background: var(--highlight-wash); }
.sel-actions .sel-highlight:hover { background: var(--highlight); }
.sel-actions .sel-btn:focus-visible { outline: 2px solid var(--ink-ghost); outline-offset: 2px; }

.sel-actions.is-dock {
  left: 10px;
  right: 10px;
  gap: 8px;
  padding: 8px;
}
.sel-actions.is-dock .sel-count {
  display: block;
  flex: 1;
  padding-left: 8px;
  font-size: 13px;
  color: var(--ink-muted);
}
.sel-actions.is-dock .sel-btn { height: 44px; padding: 0 14px; font-size: 15px; }
