/* tubebot — editorial refresh.
   Drop-in replacement for src/web/style.css. Variable names and all class
   names are unchanged from the current stylesheet, so views.ts needs no edits.

   Add to the <head> in views.ts layout():
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..700;1,6..72,400&family=Karla:ital,wght@0,300..700;1,400&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
*/

:root {
  --bg: #fcfcfa;
  --surface: #fff;
  --text: #1c1e1a;
  --muted: #6e7268;
  --faint: #f0f0e9;
  --line: #e6e6df;
  --accent: #5f7c43;
  --accent-tint: color-mix(in srgb, var(--accent) 13%, transparent);
  --mark: #f2ecc4;
  --radius: 12px;

  /* Reading column width. The handoff specified 38rem; widened to use the
     space on large displays, then trimmed 20% and a further 10% twice over
     for line length. Note: .excerpt carries its own ch cap that binds
     before this one — scale both together. */
  --measure: 49.4rem;

  --serif: Newsreader, Georgia, "Times New Roman", serif;
  --sans: Karla, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

/* Dark tokens are applied in two cases: the OS asks for dark and the reader has
   not overridden it, or the reader has explicitly chosen dark. The blocks are
   duplicated rather than shared because a media query cannot be OR-ed with an
   attribute selector in plain CSS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141510;
    --surface: #1c1d17;
    --text: #ecece4;
    --muted: #969a8c;
    --faint: #24261d;
    --line: #2b2c24;
    --accent: #a8c98a;
    --mark: #4a4a1e;

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141510;
  --surface: #1c1d17;
  --text: #ecece4;
  --muted: #969a8c;
  --faint: #24261d;
  --line: #2b2c24;
  --accent: #a8c98a;
  --mark: #4a4a1e;

  color-scheme: dark;
}

/* --- theme toggle -------------------------------------------------------- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--faint); }

.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.theme-toggle svg { width: 15px; height: 15px; display: block; }

/* Each icon shows only in the mode it switches away from, so the button always
   depicts the destination rather than the current state. */
.theme-toggle .icon-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: block; }
}
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
:root[data-theme="light"] .theme-toggle .icon-light { display: block; }
:root[data-theme="light"] .theme-toggle .icon-dark { display: none; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.75 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* Video titles and model output both carry the odd unbreakable run — a bare
     URL, a long hyphen-free compound. On a phone one of those is enough to
     widen the page and set the whole document scrolling sideways. */
  overflow-wrap: break-word;
}

a { color: inherit; }

/* --- chrome ------------------------------------------------------------- */

header.site {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.5rem;
  padding: 0 1.75rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* Sized by flex rather than by the input, so the field is the part of the
   header that gives when the viewport is too narrow for brand + search +
   toggle. A fixed width on the input would overflow the header instead. */
.search {
  margin-left: auto;
  flex: 0 1 240px;
  min-width: 5rem;
}

.search input {
  font: inherit;
  font-size: 0.84rem;
  padding: 0.44rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

nav.cats {
  position: relative;
  padding: 0.85rem 1.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
}

.cats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

nav.cats a,
.cats-group > summary { white-space: nowrap; }

.cats-group { position: relative; }

.cats-group > summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.cats-group > summary::-webkit-details-marker { display: none; }
.cats-group > summary::after { content: " ▾"; font-size: 0.8em; opacity: 0.6; }
.cats-group[open] > summary::after { content: " ▴"; }
.cats-group > summary:hover,
.cats-group[open] > summary { background: var(--faint); color: var(--text); }
.cats-group.is-active > summary {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}
.cats-sub { font-weight: 400; }

.cats-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 13rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
}

.cats-menu a { border-radius: 8px; }

/* "All Business" heads its menu, set off from the categories beneath it. */
.cats-menu a:first-child {
  margin-bottom: 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
}

/* On a phone the row scrolls sideways rather than wrapping, with the trailing
   edge faded so a clipped entry reads as "scroll for more". A menu anchored to
   its pill would be clipped by that scrolling row, so here the menus anchor to
   the nav instead — a full-width panel beneath it. */
@media (max-width: 640px) {
  .cats-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: 1.5rem;
  }

  /* An overlay rather than a mask on the row: a mask would clip the open
     menu too, which paints inside the row's subtree. */
  nav.cats::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 2.5rem;
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none;
  }
  .cats-row::-webkit-scrollbar { display: none; }

  .cats-group { position: static; }

  .cats-menu {
    top: calc(100% - 0.35rem);
    left: 1.15rem;
    right: 1.15rem;
  }
}

nav.cats a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

nav.cats a:hover { background: var(--faint); color: var(--text); }
nav.cats a[aria-current="page"] {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}
nav.cats .count { opacity: 0.5; font-size: 0.85em; }

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.75rem 1.75rem 6rem;
}

/* The display sizes interpolate between a phone and the full measure instead
   of stepping at one breakpoint: the clamp floor is the narrow-screen size,
   the ceiling the desktop one. */
.page-title {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 1.2rem + 1vw, 1.7rem);
  font-weight: 500;
  line-height: 1.26;
  letter-spacing: -0.008em;
  margin: 0 0 1.5rem;
}

/* --- feed --------------------------------------------------------------- */

/* --- day grouping -------------------------------------------------------- */

.day-label {
  position: sticky;
  top: 3.5rem; /* clears the sticky header */
  z-index: 2;
  margin: 0;
  padding: 1.5rem 0 0.6rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
}

/* The first label sits under the read bar's rule rather than under a card, so
   it needs its own clearance — at zero it read as part of the bar. */
.day:first-of-type .day-label { padding-top: 1.25rem; }

/* --- feed cards ---------------------------------------------------------- */

.card {
  /* Named so the pinned star can align itself to the meta line without the
     two drifting apart if the padding is ever retuned. */
  --card-pad: 1.65rem;
  --card-pad-top: var(--card-pad);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: var(--card-pad-top) 0 var(--card-pad);
  border-bottom: 1px solid var(--line);
  position: relative;
}

.day:last-of-type .card:last-of-type { border-bottom: 0; }

/* A day label belongs to the cards beneath it, so it sits closer to them than
   to the day above — with full card padding it floated midway between. */
.day-label + .card { --card-pad-top: 0.85rem; }

/* Read articles recede rather than disappear — still findable, clearly done.
   The title keeps full contrast on hover so it stays comfortably readable. */
.card.is-read h2 a { color: var(--muted); }
.card.is-read h2 a:hover { color: var(--accent); }
.card.is-read .excerpt { opacity: 0.62; }
.card.is-read .meta .chan { font-weight: 400; color: var(--muted); }

/* --- read bar ------------------------------------------------------------ */

/* Wraps rather than overflows: at 320px the two filter pills and "Mark all
   read" together are wider than the column, so the button drops to its own
   row instead of pushing the page sideways. */
.readbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
}

.readbar-filter { display: flex; gap: 0.35rem; }

/* Direct children only — the nested count span is not a pill of its own. */
.readbar-filter > a,
.readbar-filter > span {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
}

.readbar-filter > a:hover { background: var(--faint); color: var(--text); }
.readbar-filter [aria-current] {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}

.readbar-filter .count { opacity: 0.65; font-size: 0.85em; }

.readbar form { margin-left: auto; }

.readbar-action {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.readbar-action:hover { border-color: var(--accent); color: var(--accent); }

.card h2 {
  font-family: var(--serif);
  margin: 0;
  font-size: clamp(1.35rem, 1.17rem + 0.73vw, 1.55rem);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.008em;
}

.card h2 a { text-decoration: none; }
.card h2 a:hover { color: var(--accent); }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.62rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.meta a { text-decoration: none; }
.meta .chan { font-weight: 600; color: color-mix(in srgb, var(--text) 82%, var(--bg)); }
.meta .chan:hover { color: var(--accent); }
.meta > * + *::before { content: "·"; margin-right: 0.62rem; opacity: 0.4; }
.meta > .badge + .badge::before,
.meta > *:has(+ .badge)::before { }
.meta .badge::before { content: none; }

.badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.02em;
  padding: 0.14rem 0.44rem;
  border-radius: 999px;
  background: var(--faint);
  color: var(--muted);
  white-space: nowrap;
}

/* Whisper is the notable case — our own transcription, not YouTube's. */
.badge-whisper { color: var(--accent); background: var(--accent-tint); }
.badge-auto { }
.badge-manual { display: none; } /* the unremarkable default */

/* --- star ---------------------------------------------------------------- */

/* Pushed to the end of the meta line rather than given a row of its own: it is
   an aside to the card, not a second headline. `margin-left: auto` puts it at
   the right of whichever line it lands on when the meta wraps. */
.star-form { margin-left: auto; display: flex; }
.meta .star-form::before { content: none; }

.star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  /* Negative margins keep the touch target from stretching the meta line. */
  margin: -0.45rem -0.35rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.star svg { width: 16px; height: 16px; display: block; fill: none; }
.star:hover { color: var(--accent); background: var(--faint); }

.star:focus-visible {
  outline: none;
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* A star that is on is filled — the one place in the card that says "kept". */
.star[aria-pressed="true"] { color: var(--accent); }
.star[aria-pressed="true"] svg { fill: currentColor; }

.star[disabled] { opacity: 0.5; cursor: default; }

.excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.65;
  /* Raised from 60ch with the wider column, but still capped: an excerpt
     running the full column would be ~150 characters a line. Scaled with
     --measure so excerpts narrow along with the column. */
  max-width: 77ch;
  text-wrap: pretty;
}

.excerpt mark { background: var(--mark); color: inherit; padding: 0 0.12em; border-radius: 2px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.25rem;
  font-size: 0.875rem;
}

.pager a { text-decoration: none; color: var(--accent); font-weight: 600; }

.pager-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pager-step,
.pager-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Square-ish targets on a shared baseline, so the row reads as one control
     rather than a line of links of varying width. */
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.45rem;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}

.pager-page:hover,
.pager-step:hover { background: var(--mark); }

.pager-page.is-current {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.pager-page.is-current:hover { background: var(--accent); }

.pager-step.is-disabled { color: var(--muted); opacity: 0.35; }

.pager-gap {
  padding: 0 0.15rem;
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 5rem 0;
  color: var(--muted);
}

.empty h1 {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 1.2rem + 1vw, 1.7rem);
  font-weight: 500;
  margin: 0 0 0.4rem;
  color: var(--text);
}

/* --- article ------------------------------------------------------------ */

.full h1 {
  font-family: var(--serif);
  font-size: clamp(1.85rem, 1.26rem + 2.36vw, 2.5rem);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.014em;
  margin: 0 0 0.85rem;
}

.full .meta { padding-bottom: 1.6rem; border-bottom: 1px solid var(--line); }

/* rem tracks the root, not body's 17px, so this is an absolute size rather
   than a multiple of the surrounding text. 1.0625rem = 17px. */
.prose { font-size: 1.0625rem; line-height: 1.75; }

/* Headings sit at body size on purpose — em keeps them there as prose moves. */
.prose h1, .prose h2, .prose h3 {
  font-family: var(--sans);
  font-size: 1em;
  font-weight: 700;
  margin: 2.1rem 0 0.7rem;
  letter-spacing: -0.005em;
}

.prose p { margin: 0 0 1.15rem; text-wrap: pretty; }
.prose ul, .prose ol {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  padding-left: 1.35rem;
  margin: 0 0 1.25rem;
}
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 700; }

/* The haiku the prompt asks for, rendered as the pull-quote it is. */
.prose > p > em:first-child {
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
}

.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.25rem 0; }

.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--faint);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* The prompt asks for prose, so these are the exceptions rather than the rule
   — but a single fenced block or wide table from the model would otherwise
   set the whole page scrolling sideways on a phone. Each scrolls in its own
   box instead. */
.prose pre {
  margin: 0 0 1.25rem;
  padding: 0.9rem 1.05rem;
  overflow-x: auto;
  background: var(--faint);
  border-radius: var(--radius);
}

.prose pre code { background: none; padding: 0; }

.prose table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
}

.prose th, .prose td {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
}

.prose img { max-width: 100%; height: auto; }

/* Source link, at the foot of the summary rather than an embed above it. */
.source {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  margin-top: 2.75rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.source:hover { border-color: var(--accent); background: var(--faint); }

.source-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.source-label::after { content: " →"; }

.source-title {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Step to the neighbouring article. Two fixed columns rather than a flex row
   with space-between: at either end of the feed only one link exists, and it
   has to stay on its own side so "older" never appears where "newer" was. */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.article-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding: 0.85rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.article-nav-link:hover { border-color: var(--accent); background: var(--faint); }

.article-nav-link.is-newer { grid-column: 1; }
.article-nav-link.is-older { grid-column: 2; align-items: flex-end; text-align: right; }

.article-nav-dir {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.article-nav-link.is-newer .article-nav-dir::before { content: "← "; }
.article-nav-link.is-older .article-nav-dir::after { content: " →"; }

/* Two lines at most: this is a signpost, and a long headline given its full
   height would tower over the source link it sits beneath. */
.article-nav-title {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

footer.site {
  padding: 2rem 1.75rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

footer.site a { text-decoration: none; }
footer.site a:hover { color: var(--accent); }

/* --- sharing ------------------------------------------------------------- */

/* Set off from the article above it: this is machinery, not reading. */
.sharing {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}

.sharing > summary {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  padding: 0.35rem 0;
  width: fit-content;
}

.sharing > summary:hover { color: var(--accent); }
.sharing > summary .count { opacity: 0.65; }

.sharing-lead {
  color: var(--muted);
  margin: 0.5rem 0 1rem;
  max-width: 42rem;
}

/* Wraps rather than overflows — at 320px the note field, the menu and the
   button do not fit on one line. */
.sharing-new {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.sharing-new input[name="note"] {
  /* Grows into the row but may shrink past its intrinsic width, which a text
     input will not do on its own. */
  flex: 1 1 12rem;
  min-width: 0;
}

.sharing-new input,
.sharing-new select,
.share-url {
  font: inherit;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.sharing-new input:focus,
.sharing-new select:focus,
.share-url:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.sharing-new button,
.copy,
.share-revoke {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.sharing-new button {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

.copy:hover,
.share-revoke:hover,
.sharing-new button:hover { border-color: var(--accent); color: var(--accent); }

.share-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0;
  margin: 0;
}

.share-item {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* The link just created. Marked for the moment you land back on the page,
   which is the one time the list has an answer you are looking for. */
.share-item.is-new { border-color: var(--accent); background: var(--accent-tint); }

.share-article {
  display: block;
  font-family: var(--serif);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
}

.share-article:hover { color: var(--accent); }

.share-link {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.share-link form { display: contents; }

/* A share URL is one 22-character unbreakable token. Without min-width:0 the
   field claims its full intrinsic width and takes the page sideways with it;
   the value scrolls inside the field instead. */
.share-url {
  flex: 1 1 18rem;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.share-facts {
  margin-top: 0.55rem;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.4rem;
}

.share-facts strong { color: var(--text); font-weight: 600; }
.share-facts .is-expired { color: var(--accent); }
.share-facts code { font-family: var(--mono); font-size: 0.72rem; }

/* --- settings ------------------------------------------------------------ */

.settings-section { margin-bottom: 2.5rem; }

.settings-section h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.settings-empty { color: var(--muted); margin: 0; }

/* Outcome of a follow attempt. The error carries real information — a handle
   that did not resolve, a rate-limited lookup — so it is not a toast. */
.settings-error,
.settings-added {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.settings-error {
  border: 1px solid var(--danger, #b3261e);
  color: var(--danger, #b3261e);
}

.settings-added {
  border: 1px solid var(--accent);
  background: var(--accent-tint);
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}

.category-list .count { color: var(--muted); font-size: 0.85em; }
.category-list .sharing-new { margin: 0; flex-wrap: nowrap; }
.category-list input[name="group"] { width: 12rem; }

/* Channels recorded for attribution but never polled. Collapsed, because the
   list grows with every one-off request and is not the point of the page. */
.settings-unfollowed { margin-top: 1.5rem; }

.settings-unfollowed summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.token-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.token-label { font-size: 0.95rem; }

/* The one moment a token is visible. Tinted like a freshly created share, for
   the same reason: it is the answer you came back to the page for. */
.token-created {
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-tint);
}

.token-created h2 { margin: 0 0 0.25rem; font-size: 1rem; }

.token-created p {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 42rem;
}

@media (max-width: 640px) {
  body { font-size: 16.5px; }
  main { padding: 1.85rem 1.15rem 4rem; }
  header.site, nav.cats { padding-left: 1.15rem; padding-right: 1.15rem; }
  header.site { gap: 0.75rem; }

  /* Anything under 16px makes iOS Safari zoom the page in when the field takes
     focus, and it does not zoom back out afterwards. */
  .search input,
  .sharing-new input,
  .sharing-new select { font-size: 16px; padding: 0.4rem 0.85rem; }

  /* The share URL stays small — it is read at a glance and copied by button,
     never typed into, so the iOS zoom-on-focus rule above does not apply. */
  .share-url { flex-basis: 100%; }

  /* The kicker nearly always wraps at this width, and a separator dot cannot
     know it has landed at the start of a line — the second row opens with a
     stranded "·". Spacing carries the separation instead. */
  .meta { gap: 0.35rem 0.8rem; }
  .meta > * + *::before { content: none; }

  /* Side by side these become two narrow columns of clamped headline. Stacked,
     each keeps the full width — and the order still reads newer then older. */
  .article-nav { grid-template-columns: 1fr; }
  .article-nav-link.is-older { grid-column: 1; align-items: flex-start; text-align: left; }
}

/* Touch input, at any width: the pills and icon buttons are sized for a
   cursor, which leaves them at 30-34px — under any reasonable fingertip
   target. Keyed to the pointer rather than the viewport, so a tablet gets
   them too and a narrow desktop window does not.

   40px rather than the 44px of the platform guidelines: the category and
   filter rows both sit above the first headline, and at 44 the navigation
   takes over a phone screen before a single article. The pills grow by padding, not by
   inline-flex — flex would drop the space before each count, running the
   label into its number. */
@media (pointer: coarse) {
  .theme-toggle { width: 2.5rem; height: 2.5rem; }

  .star { width: 2.5rem; height: 2.5rem; margin: -0.75rem -0.65rem; }

  /* On a phone the kicker already fills the line, so a star in flow wraps to a
     row of its own — a 40px band of nothing between the meta and the headline,
     on every card. Pinned to the card's corner it costs no height at all and
     lands where a bookmark is looked for anyway.

     Only on a coarse pointer: with a cursor the meta line has room to spare
     and the star sits at the same place in normal flow, so there is nothing to
     fix and no positioning to get wrong. */
  .card .star-form {
    position: absolute;
    /* Half the star's overhang above the 0.78rem/1.75 meta line it aligns to. */
    top: calc(var(--card-pad-top) - 0.57rem);
    right: 0;
    margin: 0;
  }

  .card .star { margin: 0; }

  /* Reserve the corner, so a long kicker wraps rather than running underneath. */
  .card .meta { padding-right: 2.75rem; }

  nav.cats a,
  .cats-group > summary,
  .readbar-filter > a,
  .readbar-filter > span {
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .readbar-action {
    min-height: 2.5rem;
    padding-inline: 0.9rem;
  }

  .pager-step,
  .pager-page {
    min-width: 2.5rem;
    height: 2.5rem;
  }

  .sharing > summary,
  .sharing-new button,
  .sharing-new input,
  .sharing-new select,
  .copy,
  .share-revoke {
    min-height: 2.5rem;
  }
}

/* --- sign-in and account (src/web/auth-views.ts) --------------------------- */

main.auth { max-width: 26rem; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.auth-form label.auth-check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.auth-form button,
.button-link {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  text-decoration: none;
  align-self: flex-start;
  display: inline-block;
}

.auth-hint { font-size: 0.8rem; }
.auth-alt { margin: 0.5rem 0 0; font-size: 0.9rem; }

/* A form button that reads as a link: sign-out has to be a POST. */
.link-button {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.inline-form { display: inline; }

.totp-qr svg {
  width: 12rem;
  height: 12rem;
  background: #fff;
  border-radius: 8px;
}

.totp-secret { margin: 0.75rem 0 1.25rem; font-size: 0.9rem; }
.totp-secret code { display: block; margin-top: 0.4rem; font-family: var(--mono); letter-spacing: 0.04em; }

.backup-codes {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 0.4rem 2rem;
  font-family: var(--mono);
  font-size: 1.05rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
}
