@font-face { font-family: "Newsreader"; src: url("/fonts/Newsreader.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/fonts/Newsreader-Italic.woff2") format("woff2"); font-weight: 400 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("/fonts/InstrumentSans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

/* Card Catalogue: paper and ink, status colours paired with glyphs. */
:root {
  --paper: #f3eee4; --paper-2: #ebe4d6; --surface: #fbf9f4;
  --ink: #1b1916; --ink-2: #5b554c; --muted: #6b655b;
  --line: #d9d1c3; --line-2: #c8bfae;
  --read: #1f6f4f; --want: #245f9e; --reading: #6d3fa3; --never: #6a645b; --out: #8f5a12;
  --stamp: #b43a2a; --gold: #c99a2e; --warn: #b3261e; --on-color: #ffffff; --focus: #1b1916;
  --rail: rgb(27 25 22 / 62%); --rail-ink: #ffffff;
  --shadow-1: 0 1px 2px rgb(40 30 10 / 12%), 0 2px 6px rgb(40 30 10 / 8%);
  --shadow-2: 0 2px 4px rgb(40 30 10 / 8%), 0 8px 24px rgb(40 30 10 / 12%);
  --shadow-3: 0 6px 12px rgb(40 30 10 / 10%), 0 24px 60px rgb(40 30 10 / 22%);
  --grain-opacity: 0.055; --grain-blend: multiply;
  --r-1: 3px; --r-2: 6px; --r-3: 10px; --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --sans: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --t-fast: 80ms; --t-base: 150ms; --t-page: 220ms; --t-joy: 420ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1); --ease-in: cubic-bezier(0.5, 0, 0.8, 0.4);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161411; --paper-2: #1d1a16; --surface: #211e1a;
    --ink: #ece6da; --ink-2: #b5ada0; --muted: #a39b8e;
    --line: #3a352e; --line-2: #4a443b;
    --read: #5fc090; --want: #7fb0ea; --reading: #c3a2ee; --never: #9a9388; --out: #e3b05e;
    --stamp: #e5705c; --gold: #f0c454; --warn: #f08f7d; --on-color: #161411; --focus: #ece6da;
    --rail: rgb(236 230 218 / 18%); --rail-ink: #ffffff;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 50%), 0 2px 6px rgb(0 0 0 / 35%);
    --shadow-2: 0 2px 4px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 45%);
    --shadow-3: 0 6px 12px rgb(0 0 0 / 40%), 0 24px 60px rgb(0 0 0 / 60%);
    --grain-opacity: 0.035; --grain-blend: screen;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* Paper grain: one 160px noise tile, fixed, behind everything; rasterised once. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.2 0 0 0 0 0.15 0 0 0 0 0.1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

button, input, textarea, select { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 8px; font: 600 19px var(--serif); letter-spacing: -0.01em; white-space: nowrap; }
.ribbon { width: 12px; height: 18px; border-radius: 1px 1px 0 0; background: var(--stamp); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }

.tabs { display: flex; gap: 2px; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
}

.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.count { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.count:empty { display: none; }
.tab .count { padding: 1px 6px; border-radius: var(--r-pill); background: var(--paper-2); }
.tab[aria-selected="true"] .count { background: var(--paper); }

.search { position: relative; margin-left: auto; width: min(360px, 40vw); }

.search input {
  width: 100%;
  padding: 7px 36px 7px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface);
}

.search input::placeholder { color: var(--muted); }
.search-key { position: absolute; top: 7px; right: 9px; margin: 0; pointer-events: none; }
.search input:focus ~ .search-key, .search input:not(:placeholder-shown) ~ .search-key { display: none; }
.search-open { display: none; }

.results {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(460px, calc(100vw - 32px));
  max-height: 70vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-2);
  padding: 6px;
}

.result {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--r-2);
}

.result:hover { background: var(--paper-2); }
.result.active { background: var(--paper-2); outline: 1.5px solid var(--focus); outline-offset: -1.5px; }
.result .mini { width: 34px; aspect-ratio: 2 / 3; border-radius: 2px; overflow: hidden; background: var(--line); box-shadow: var(--shadow-1); cursor: pointer; }
.result .mini img { display: block; width: 100%; height: 100%; object-fit: cover; }
.result .t { font: 500 14px/1.2 var(--serif); cursor: pointer; }
.result .a { color: var(--muted); font-size: 12px; }
.result .chip { padding: 3px 9px; font-size: 12px; }
.result .chip kbd { display: none; padding: 2px 4px; font-size: 9.5px; }
.result.active .chip kbd { display: inline; }
.result-foot { display: flex; gap: 14px; margin-top: 4px; padding: 8px 8px 4px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.result-foot kbd { margin: 0 2px 0 0; }
.results:not(:has(.result)) .result-foot { border-top: 0; }
.results:not(:has(.result)) .result-foot .key { display: none; }
.search-note { margin-left: auto; }

main { padding: 16px 20px 96px; max-width: 1400px; margin: 0 auto; }

/* Filter panels fold away behind a Filters button; folded, an active filter shows as one chip. */
.view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.filters-toggle, .how-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; font-size: 13px; }
.filters-toggle::after, .how-toggle::after { content: "▾"; color: var(--muted); transition: transform var(--t-base); }
.filters-toggle[aria-expanded="true"]::after, .how-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }

/* Sort's stats strip, and How it picks: the ranker's heaviest weights as bars. */
.stats { display: flex; align-items: baseline; gap: 10px; margin-right: auto; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats b { margin-right: 4px; color: var(--ink); font: 500 18px/1 var(--serif); }
.stats .sep { color: var(--line-2); }
.how[hidden] { display: none; }

.how {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 20px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
  font-size: 12.5px;
}

.how .t { grid-column: 1 / -1; color: var(--ink-2); }
.how .w { display: grid; grid-template-columns: 1fr 44px; gap: 4px 8px; align-items: center; }
.how .w span:last-of-type { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.how .w i { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.how .w b { display: block; height: 100%; background: var(--read); }
.how .w b.neg { background: var(--warn); }
.filters .active-filter { margin-left: auto; }
.filters .active-filter[hidden] + .filters-toggle { margin-left: auto; }

.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 3px 3px 11px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
}

.active-filter[hidden] { display: none; }
.active-filter button { padding: 0 7px; border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.active-filter button:hover { color: var(--ink); }

/* Year range: histogram + two-handle slider (live readout while dragging, typed years,
   presets). Bars and ticks are positioned by layoutYearTrack() under the thumb centres. */
.year-range { max-width: 720px; margin-bottom: 14px; padding: 12px 14px 10px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); }
.yr-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.yr-label { color: var(--muted); font-size: 13px; margin-right: 2px; }
.yr-value {
  width: 4ch;
  padding: 2px 0;
  border: 0;
  border-bottom: 1.5px dashed var(--line-2);
  background: none;
  font: 500 20px var(--serif);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.yr-value::placeholder { color: var(--ink); opacity: 1; }
.yr-value:focus { outline: none; border-bottom-color: var(--focus); }
.yr-dash { font-weight: 650; }
.yr-count { color: var(--muted); font-size: 13px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.yr-clear { padding: 3px 10px; font-size: 12.5px; margin-left: auto; }

.yr-track { position: relative; height: 56px; isolation: isolate; }
.yr-bars { position: absolute; top: 0; height: 38px; display: flex; align-items: flex-end; gap: 2px; }
.yr-bars span {
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: var(--line);
  transition: background-color 0.1s;
}
.yr-bars span.on { background: color-mix(in srgb, var(--read) 70%, transparent); }

.yr-thumb {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  width: 100%;
  height: 22px;
  margin: 0;
  background: none;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
}
.yr-thumb::-webkit-slider-runnable-track { height: 22px; background: none; }
.yr-thumb::-moz-range-track { height: 22px; background: none; }
.yr-thumb::-webkit-slider-thumb {
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--read);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  cursor: grab;
}
.yr-thumb::-moz-range-thumb {
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--read);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  cursor: grab;
}
.yr-thumb:focus { outline: none; }
.yr-thumb:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.1); }
.yr-thumb:focus-visible::-webkit-slider-thumb { outline: 3px solid color-mix(in srgb, var(--read) 40%, transparent); }
.yr-track::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 14px;
  height: 2px;
  background: var(--line-2);
  z-index: -1;
}

.yr-line { position: absolute; bottom: 14px; height: 2px; background: var(--read); }

.yr-ticks { position: relative; height: 16px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.yr-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.yr-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.yr-presets .chip { padding: 3px 10px; font-size: 12.5px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 18px 14px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  min-height: 0; /* without clipping, aspect-ratio would otherwise grow to fit a tall image */
  border-radius: var(--r-1);
  background: var(--line);
  box-shadow: var(--shadow-1);
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: transform var(--t-fast) var(--ease-out), outline-color var(--t-base), box-shadow var(--t-base);
}

.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* The cover itself doesn't clip, so a hover label can run past its edge. */
.cover > img, .cover > .placeholder { border-radius: inherit; }

/* A faint spine and top light, so a cover reads as a book. */
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, rgb(0 0 0 / 16%) 0, rgb(0 0 0 / 0%) 5%), linear-gradient(180deg, rgb(255 255 255 / 10%), transparent 30%);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%);
}

.placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  color: #fff;
}

@media (hover: hover) { .tile:hover .cover { transform: translateY(-1px); box-shadow: var(--shadow-2); } }
.tile:active .cover { transform: scale(0.97); }
.tile.focused .cover { outline-color: var(--focus); outline-offset: 3px; transform: translateY(-2px); box-shadow: var(--shadow-2); }
.tile.is-read .cover { outline-color: var(--read); }
.tile.is-want .cover { outline-color: var(--want); }
.tile.is-reading .cover { outline-color: var(--reading); }
.tile.is-never .cover { outline-color: var(--never); }
.tile.is-never .cover img, .tile.is-never .cover .placeholder { filter: grayscale(1); opacity: 0.45; }

/* One badge for every status: glyph and word, bottom-left, in the status colour. */
.badge {
  position: absolute;
  left: 5px;
  bottom: 5px;
  z-index: 2;
  display: none;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px 0 5px;
  border-radius: var(--r-pill);
  font: 700 10.5px/1 var(--sans);
  letter-spacing: 0.02em;
  color: var(--on-color);
  box-shadow: var(--shadow-1);
}

.badge svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.tile.is-read .badge, .tile.is-want .badge, .tile.is-reading .badge, .tile.is-never .badge { display: inline-flex; }
.tile.is-read .badge { background: var(--read); }
.tile.is-want .badge { background: var(--want); }
.tile.is-reading .badge { background: var(--reading); }
.tile.is-never .badge { background: var(--never); }

/* Saving: pulsing gold ring and badge. Saved: solid colour, and the badge pops. */
.tile.saving.saving .cover { outline-color: var(--gold); animation: saving 0.9s ease-in-out infinite; }
.tile.saving.saving .badge { background: var(--gold); }
.tile.saved .badge { animation: pop var(--t-joy) var(--ease-out); }
.tile.saved .cover { transition: outline-color 0.25s ease; }
.tile.failed.failed .cover { outline-color: var(--warn); outline-style: dashed; }

@keyframes saving { 50% { outline-color: color-mix(in srgb, var(--gold) 35%, transparent); } }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shimmer { 40% { filter: brightness(1.5) drop-shadow(0 0 4px var(--gold)); } }

.save-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stamp { display: inline-block; padding: 4px 6px; border: 2px solid var(--stamp); border-radius: 4px; color: var(--stamp); font: 700 11px/1 var(--serif); letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.9; transform: rotate(-4deg); animation: stamp var(--t-joy) var(--ease-out); }
@keyframes stamp { from { opacity: 0; transform: rotate(-4deg) scale(1.6); } }
.tapped .tally::before { content: none; }
.tally { display: inline-flex; gap: 3px; margin-left: 8px; vertical-align: -1px; }
.tally i { display: inline-block; width: 2px; height: 11px; border-radius: 1px; background: var(--ink-2); }
.save-state svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.save-state:empty { display: none; }
.save-state[data-state="saving"] { color: var(--gold); }
.save-state[data-state="saved"] { color: var(--read); }
.save-state[data-state="failed"] { color: var(--warn); }

/* Next page: the covers settle and fade, the new ones arrive top-down (the last within 250 ms). */
.grid.leaving .tile { animation: shelve var(--t-page) var(--ease-in) forwards; }
.grid.arriving .tile { animation: arrive 160ms var(--ease-out) backwards; animation-delay: calc(min(var(--i), 20) * 4ms); }
@keyframes shelve { to { transform: translateY(6px); opacity: 0; } }
@keyframes arrive { from { transform: translateY(-4px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .tile.saving.saving .cover, .tile.saved .badge, .stars .star::before, .grid.leaving .tile, .grid.arriving .tile, .stamp { animation: none; }
  .cover, .pick, .info { transition: none; }
}

/* The corner rail: frosted buttons that show on hover or focus (on touch, on the last cover
   tapped); hovering one names it in a strip inside the cover. */
.pick, .info {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 25%);
  background: var(--rail);
  color: var(--rail-ink);
  backdrop-filter: blur(4px);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-base), background-color var(--t-fast);
}

.pick { left: 5px; width: 26px; height: 26px; }
.pick-want { top: 5px; }
.pick-reading { top: 36px; }
.pick-never { top: 67px; }
.pick svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.info { top: 5px; right: 5px; width: 24px; height: 24px; font: italic 600 13px/1 var(--serif); }

@media (hover: hover) {
  .tile:hover .pick, .tile:hover .info { opacity: 1; }
  .pick-want:hover { background: var(--want); }
  .pick-reading:hover { background: var(--reading); }
  .pick-never:hover { background: var(--never); }
}

.tile.focused .pick, .tile.focused .info { opacity: 1; }
.tile.is-want .pick-want { opacity: 1; background: var(--want); }
.tile.is-reading .pick-reading { opacity: 1; background: var(--reading); }
.tile.is-never .pick-never { opacity: 1; background: var(--never); }
.pick:hover, .tile.is-want .pick-want, .tile.is-reading .pick-reading, .tile.is-never .pick-never { border-color: transparent; color: var(--on-color); }
.tile.is-want .pick-want svg { fill: currentColor; }

.hint {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 14px 6px 5px;
  border-radius: 0 0 var(--r-1) var(--r-1);
  background: linear-gradient(transparent, rgb(0 0 0 / 70%));
  color: var(--rail-ink);
  font: 600 10.5px/1.2 var(--sans);
  pointer-events: none;
}

.hint[hidden] { display: none; }
.hint span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint kbd { margin: 0; background: rgb(255 255 255 / 15%); border: 1px solid rgb(255 255 255 / 30%); color: var(--rail-ink); }

/* Touch: hidden buttons must not catch a tap meant for the cover. */
@media (hover: none) {
  .pick { pointer-events: none; }
  .tile.touched .pick { pointer-events: auto; opacity: 1; }
  .info { opacity: 1; }
  .hint { display: none; }
}

/* Stars: in a tile's caption (the reason line on Sort, its own row on the Shelf) and the drawer. */
.stars { display: inline-flex; align-items: center; gap: 1px; min-height: 16px; font-size: 14px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.drawer-stars .stars { font-size: 28px; gap: 3px; }
.stars-row { display: flex; margin-top: -2px; }
.quick-rate.saving { opacity: 0.55; }
.quick-rate.saved .star::before { animation: pop 0.35s ease-out; }
.quick-rate.five .star::before { animation: shimmer var(--t-joy) var(--ease-out); }
.quick-rate.failed .star { color: color-mix(in srgb, var(--warn) 40%, transparent); }

.star {
  position: relative;
  color: var(--line-2);
  --w: 0%;
}

.star::before {
  content: "★";
  position: absolute;
  inset: 0;
  width: var(--w);
  overflow: hidden;
  color: var(--gold);
}

.drawer-stars { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.rating-label { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--r-3);
  background: var(--warn);
  color: var(--on-color);
  box-shadow: var(--shadow-2);
}

/* ---- Accounts (hosted): the avatar menu, sign-in, the Account and Privacy pages, the
   first-run offer and the Delete account dialog ---- */
.toast.note { background: var(--ink); color: var(--paper); }
.account { position: relative; flex: none; margin-left: -6px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1.5px solid var(--line-2); border-radius: 50%; background: var(--paper-2); color: var(--ink); font: 600 13px var(--serif); cursor: pointer; }
.avatar[aria-expanded="true"] { border-color: var(--ink); }
.menu { position: absolute; right: 0; top: calc(100% + 10px); z-index: 20; min-width: 190px; max-width: calc(100vw - 24px); padding: 6px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); box-shadow: var(--shadow-3); }
.menu[hidden] { display: none; }
.menu a, .menu button { display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--r-2); background: none; color: var(--ink); font-size: 13.5px; text-align: left; text-decoration: none; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--paper-2); }
.menu .who { margin-bottom: 4px; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.offer { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 8px 6px 8px 14px; border: 1px solid var(--line); border-left: 3px solid var(--stamp); border-radius: var(--r-2); background: var(--surface); font-size: 13.5px; }
.offer[hidden] { display: none; }
.offer a { color: var(--ink); }
.offer button { flex: none; margin-left: auto; padding: 2px 8px; }

.page { max-width: 980px; }
.page a, .signin a { color: var(--ink-2); }
.pagetitle { margin: 4px 0 14px; font: 500 26px/1.1 var(--serif); }
.muted { color: var(--muted); font-size: 12.5px; }
.note { margin: 6px 0 0; }
.kv { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-of-type { border-top: 0; }
.kv button { margin-left: auto; }
.kv .ghost { padding: 5px 12px; font-size: 13px; }
.kv .ghost.quiet { padding: 4px 10px; }
.linkish.danger { color: var(--warn); font-size: 13.5px; }
.linkish:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.page-foot { margin-top: 14px; }
.field { display: block; margin-bottom: 12px; color: var(--ink-2); font-size: 12.5px; }
.field span { display: block; margin-bottom: 4px; }
.field input, .input { display: block; width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--paper); color: var(--ink); font: 14px var(--sans); }
.field input:focus-visible, .input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.field-error { color: var(--warn); font-size: 13px; }
.field-error[hidden] { display: none; }
.inline-form { max-width: 420px; margin-top: 8px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Signed out (sign-in, or Privacy from the sign-in card) the page has no header. */
.bare .top { display: none; }
.bare-only { display: none; }
.bare p.bare-only { display: block; }
.bare .brand.bare-only { display: inline-flex; margin: 8px 0 18px; color: var(--ink); text-decoration: none; }
#view-privacy { max-width: 760px; }
.bare #view-privacy { margin: 24px auto 0; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin-bottom: 10px; font-size: 14.5px; line-height: 1.55; }
.prose li:last-child { margin-bottom: 0; }

.signin-page:not([hidden]) { display: grid; place-items: center; min-height: calc(100svh - 112px); }
.signin { width: min(360px, 100%); padding: 24px 24px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--shadow-2); }
.brand.big { font-size: 24px; }
.signin .tag { margin: 4px 0 18px; font-size: 13px; }
.signin .lead { margin: 0 0 12px; font: 500 17px var(--serif); }
.signin .field-error { margin: 0 0 12px; }
.signin .small { margin: 12px 0 0; font-size: 12px; }
.signin-foot { padding-top: 10px; border-top: 1px solid var(--line); text-align: center; }
.primary.wide { display: flex; justify-content: center; width: 100%; margin-top: 4px; }
.sent { padding: 10px 0 4px; text-align: center; }
.sent > b { font: 500 18px var(--serif); }
.sent p { margin: 8px 0 0; font-size: 13.5px; }
.sent .linkish { font-size: inherit; }
.sent-icon { display: grid; place-items: center; width: 36px; height: 36px; margin: 0 auto 10px; border-radius: 50%; background: var(--paper-2); color: var(--ink-2); font-size: 18px; }

.dialog .field-error { margin: 0 0 10px; }
.dialog code { padding: 1px 5px; border-radius: 4px; background: var(--paper-2); font: 12.5px ui-monospace, "SF Mono", Menlo, monospace; }
.steps .input { margin-top: 6px; }
.steps .linkish { font-size: 12.5px; }
.steps [hidden] { display: none; }
.small-button { display: inline-block; margin: 6px 8px 0 0; padding: 4px 12px; font-size: 13px; text-decoration: none; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog .foot a { text-decoration: none; }
.primary.danger { background: var(--warn); color: var(--on-color); }
.primary.danger:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 640px) {
  .account { margin-left: 0; }
  .avatar { width: 28px; height: 28px; font-size: 12px; }
  .page .kv { flex-wrap: wrap; }
  .signin-page:not([hidden]) { min-height: calc(100svh - 108px); }
}

.title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  min-height: 2.4em; /* two lines always, so tileTextHeight() measures a full caption */
  font: 500 13.5px/1.2 var(--serif);
}

.author, .reason { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.author { color: var(--muted); font-size: 12px; margin-top: -2px; }
.reason { height: 16px; color: var(--read); font-size: 11.5px; line-height: 16px; margin-top: -2px; }
.reason .stars { vertical-align: top; }

/* An out-there pick: amber reason and a dashed ring until it's picked. */
.tile.out-there .reason { color: var(--out); font-weight: 600; }
.tile.out-there .reason:not(:has(.stars))::before { content: "✦ "; }
.tile.out-there.is-read .reason:has(.stars)::after { content: "✦ hit"; margin-left: 6px; vertical-align: top; }
.tile.out-there:not(.is-read, .is-want, .is-reading, .is-never, .saving) .cover {
  outline: 2px dashed var(--out);
}

.bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 18px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-2);
  max-width: calc(100vw - 32px);
}

/* This page's taps, each count after a dot in its status colour (a ring for not read). */
.tapped { display: flex; gap: 10px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tapped > span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--line-2); }
.tapped .read::before { background: var(--read); }
.tapped .reading::before { background: var(--reading); }
.tapped .want::before { background: var(--want); }
.tapped .never::before { background: var(--never); }
.tapped .not::before { background: none; box-shadow: inset 0 0 0 1.5px var(--line-2); }

.primary, .ghost {
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.primary { border: 0; background: var(--ink); color: var(--paper); font-weight: 600; }
.primary:disabled { opacity: 0.6; cursor: wait; }
.ghost { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 500; }
.ghost.quiet { border-color: transparent; background: none; color: var(--ink-2); }

kbd {
  margin-left: 4px;
  padding: 3px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-2);
  font: 600 10.5px/1 var(--sans);
  letter-spacing: 0.02em;
}

.primary kbd { background: color-mix(in srgb, var(--paper) 18%, transparent); border-color: color-mix(in srgb, var(--paper) 30%, transparent); color: var(--paper); }

.filters { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.status-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip[aria-pressed="true"] .count { color: color-mix(in srgb, var(--paper) 70%, transparent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip[data-status="read"] .dot { background: var(--read); }
.chip[data-status="reading"] .dot { background: var(--reading); }
.chip[data-status="want"] .dot { background: var(--want); }
.chip[data-status="never"] .dot { background: var(--never); }

/* Shelf toolbar (after Letterboxd's film lists): count and ratings on the left, menus on the right. */
.shelf-tools[hidden] { display: none; }
.shelf-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 18px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); }
.shelf-count { font: 500 16px var(--serif); font-variant-numeric: tabular-nums; }
.shelf-count small { color: var(--muted); font: 12.5px var(--sans); }
.shelf-clear { padding: 3px 10px; font-size: 12.5px; }
.shelf-menus { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-left: auto; }

.shelf-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.shelf-select select {
  appearance: none;
  max-width: 190px;
  padding: 5px 26px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.shelf-select::after { content: "▾"; position: absolute; right: 10px; bottom: 6px; font-size: 13px; color: var(--muted); pointer-events: none; }

.rating-bars { display: inline-flex; align-items: flex-end; gap: 6px; padding-top: 14px; }
.rating-bars .rb-star { color: var(--gold); font-size: 11px; line-height: 1; letter-spacing: -1px; }
.rb-bars { display: flex; align-items: flex-end; gap: 3px; height: 40px; }

.rb-bars button {
  display: flex;
  align-items: flex-end;
  width: 16px;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.rb-bars span {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
}

.rb-bars button:hover span { background: var(--muted); }
.rb-bars button[aria-pressed="true"] span { position: relative; background: var(--gold); }
.rb-bars button[aria-pressed="true"] span::after { content: attr(data-n); position: absolute; top: -16px; left: 50%; transform: translateX(-50%); color: var(--ink); font: 600 10.5px var(--sans); }

/* Empty states: an empty shelf with two bookends, a sentence, one action. */
.empty { grid-column: 1 / -1; padding: 48px 20px; color: var(--ink-2); text-align: center; }
.empty b { display: block; color: var(--ink); font: 500 18px var(--serif); }
.shelfline { position: relative; width: 180px; height: 10px; margin: 0 auto 16px; border-bottom: 3px solid var(--line-2); }
.shelfline::before, .shelfline::after { content: ""; position: absolute; bottom: 0; width: 6px; height: 22px; border-radius: 1px 1px 0 0; background: var(--line-2); }
.shelfline::before { left: 0; }
.shelfline::after { right: 0; transform: rotate(14deg); transform-origin: bottom; }
.linkish { padding: 0; border: 0; background: none; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Cards: Your data's three, and the import preview and summary. */
.cards { display: grid; gap: 14px; }
.cards[hidden], .card[hidden] { display: none; }
.card { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); box-shadow: var(--shadow-1); }
.card h3 { margin: 0 0 4px; font: 500 18px/1.2 var(--serif); }
.card > p.a { margin: 0 0 12px; }
.card.quiet { border-style: dashed; background: none; box-shadow: none; }
.card.wide h3 { margin-bottom: 10px; }
.card.busy { opacity: 0.6; transition: opacity var(--t-base); }
.card.busy button, .card.busy input { pointer-events: none; }
.danger-link { padding: 0; border: 0; background: none; color: var(--warn); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
a.ghost, a.primary { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }

/* Your data: one ambient line, then the cards. */
.data { max-width: 980px; }
:is(.data, .dialog) .a { color: var(--muted); font-size: 12.5px; }
.ambient { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-height: 19px; margin-bottom: 16px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.ambient b { color: var(--ink); font: 500 16px/1 var(--serif); }
.ambient .sep { color: var(--line-2); }
.data-note { margin: -6px 0 14px; color: var(--ink-2); font-size: 13px; }
.card .data-note { margin: 0 0 10px; }
.data-note[hidden], .data-error[hidden] { display: none; }
.data-error { margin: 10px 0 0; color: var(--warn); font-size: 13px; }
.data .ghost, .dialog .ghost { padding: 5px 12px; font-size: 13px; }

.file-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.file-row .t { font: 500 14px/1.2 var(--sans); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.file-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-2); background: var(--paper-2); color: var(--ink-2); font: 600 11px var(--sans); letter-spacing: 0.04em; }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.links .linkish { color: var(--ink-2); font-size: 12.5px; }
.links select { padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); font-size: 12.5px; cursor: pointer; }
.copy-note { margin-left: 4px; color: var(--read); }
.copy-fallback { width: 100%; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--paper); font-size: 12.5px; }
.copy-fallback[hidden] { display: none; }

.drop { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1.5px dashed var(--line-2); border-radius: var(--r-3); background: var(--paper); transition: border-color var(--t-base), background-color var(--t-base); }
.drop.over { border-color: var(--read); background: color-mix(in srgb, var(--read) 8%, var(--paper)); }
.drop-icon { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--paper-2); color: var(--ink-2); font-size: 18px; }
.or { margin: 10px 0 6px; color: var(--muted); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.paste textarea { display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--paper); font: 13.5px/1.4 var(--sans); resize: vertical; }
.paste textarea::placeholder { color: var(--muted); }
.paste .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.paste .primary { margin-left: auto; }
.seg.small button { padding: 5px 10px; font-size: 12.5px; }

/* The preview: what the file holds, the conflict rule, the rows to check. */
.filechip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--paper); font-size: 13px; }
.filechip .file-icon { width: 28px; height: 28px; font-size: 9.5px; }
.filechip b { overflow-wrap: anywhere; }
.filechip .change { margin-left: auto; }
.countstrip { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding: 10px 0; border-block: 1px solid var(--line); color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.countstrip b { margin-right: 3px; color: var(--ink); font: 500 18px/1 var(--serif); }
.countstrip .c b { color: var(--out); }
.countstrip .aside { margin-left: auto; }
.rulepick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 0; }
.rulepick .lab { font-size: 13px; }
.data-h { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 6px; font: 500 15px var(--serif); }
.data-h .n { padding: 1px 7px; border-radius: var(--r-pill); background: var(--paper-2); color: var(--ink-2); font: 500 11.5px var(--sans); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 4px 8px 6px 0; border-bottom: 1px solid var(--line); color: var(--muted); font: 600 10.5px var(--sans); letter-spacing: 0.08em; text-align: left; text-transform: uppercase; }
.table td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td:first-child { width: 22px; }
.table .t { font: 500 13.5px/1.2 var(--serif); }
.table .res { color: var(--ink-2); }
.table.conflicts td:nth-child(n+3), .table.conflicts td:nth-child(n+3) .a { white-space: nowrap; }
.table .res.theirs { color: var(--want); }
.table .res.mine { color: var(--read); }
.table .res.out { color: var(--muted); }
.table tr.left-out td:not(:first-child, .res) { opacity: 0.5; }
.table input[type="checkbox"] { margin: 2px 0 0; accent-color: var(--ink); }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.foot > .a { margin-right: auto; }
.foot kbd { margin: 0 2px; }
.donehead { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 10px; }
.donehead h3 { margin: 0; overflow-wrap: anywhere; }
.donehead #import-undo { margin-left: auto; }
.donehead #import-undo[hidden] + .ghost { margin-left: auto; }
.card > p.list-intro { margin: 12px 0 6px; }
.list { margin: 0; padding-left: 18px; font-size: 13.5px; }
.list li { margin-bottom: 4px; }
.card > p.after { margin: 12px 0 0; }

/* Delete my library: two steps in one dialog (a bottom sheet on a phone). */
.dialog { width: min(520px, calc(100vw - 32px)); padding: 18px 22px 20px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
.dialog::backdrop { background: rgb(0 0 0 / 35%); }
.dialog h3 { margin: 0 0 8px; font: 500 21px/1.2 var(--serif); }
.dialog p { margin: 0 0 10px; font-size: 13.5px; }
.steps { margin: 0 0 10px; padding-left: 20px; font-size: 13.5px; }
.steps li { margin-bottom: 12px; }
.steps li.done::marker { color: var(--read); }
.steps li.done > b::after { content: " ✓"; color: var(--read); }
.step-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 8px; }
.step-actions [hidden] { display: none; }
.steps .a { display: block; margin-top: 2px; }
.steps .a[hidden] { display: none; }
.quiet-link { color: var(--muted); font-size: 12.5px; }
.steps code { padding: 1px 5px; border-radius: var(--r-1); background: var(--paper-2); font-size: 12.5px; }
.input { display: block; width: 100%; margin-top: 6px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--paper); font-size: 14px; }
.input:disabled { opacity: 0.5; }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.primary.danger { background: var(--warn); color: var(--on-color); }
.primary.danger:disabled { opacity: 0.45; cursor: not-allowed; }

.drawer {
  position: fixed;
  inset: auto 0 0 auto;
  top: 0;
  z-index: 10;
  width: min(420px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  overflow: auto;
  padding: 20px 22px;
}

.drawer .close { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; }
.drawer-body { display: grid; gap: 16px; }

/* The whole cover, whatever its shape, on a paper backing. */
.drawer-cover { display: grid; place-items: center; width: 150px; aspect-ratio: 2 / 3; border-radius: var(--r-1); background: var(--paper-2); box-shadow: var(--shadow-2); overflow: hidden; }
.drawer-cover img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.drawer h2 { margin: 0 0 4px; font: 500 23px/1.15 var(--serif); }
.meta { margin: 0 0 12px; color: var(--ink-2); font-size: 13.5px; }
.meta .more { color: var(--muted); }
.rule { height: 3px; margin: 14px 0; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.summary { margin: 0; white-space: pre-line; font: 15.5px/1.55 var(--serif); }
.summary.empty { color: var(--muted); font-style: italic; }
.status-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.status-buttons .chip { font-size: 13px; }

/* Status as one segmented control; read fills green, the others ink. */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); overflow: hidden; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 7px 10px; white-space: nowrap; border: 0; border-right: 1px solid var(--line); background: none; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button[aria-pressed="true"][data-status="read"] { background: var(--read); color: var(--on-color); }
.seg svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.clearlink { display: block; margin: 8px 0 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.scrim { display: none; }

@media (max-width: 640px) {
  /* One header row: the search is an icon that opens a field over the row. */
  .top { gap: 6px; padding: 8px 12px; }
  .brand { font-size: 17px; }
  .tabs { gap: 0; }
  .tab { padding: 5px 7px; font-size: 13px; }
  .tab .count { display: none; }
  .search { width: auto; position: static; }
  .search input, .search-key { display: none; }
  .search-open { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); cursor: pointer; }
  .search-open svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
  .top.searching .search { position: absolute; inset: 7px 12px auto; }
  .top.searching .search input { display: block; }
  .top.searching .search-open { display: none; }
  .results { left: 0; right: 0; width: auto; }
  .result-foot .key { display: none; }
  .drawer {
    inset: auto 0 0 0;
    top: auto;
    width: 100%;
    max-height: 72vh;
    border-left: 0;
    border-radius: 18px 18px 0 0;
    padding: 10px 18px 20px;
  }
  .drawer::before { content: ""; display: block; width: 36px; height: 4px; margin: 0 auto 12px; border-radius: 2px; background: var(--line-2); }
  .drawer-body { grid-template-columns: 84px 1fr; gap: 14px; }
  .drawer-cover { width: 84px; }
  .drawer-rest { grid-column: 1 / -1; }
  .drawer h2 { padding-right: 30px; font-size: 19px; }
  .drawer .meta { font-size: 12.5px; margin-bottom: 8px; }
  .drawer-stars .stars { font-size: 24px; }
  .seg { display: flex; }
  .seg button { flex: 1; padding: 9px 4px; font-size: 12px; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 9; background: rgb(0 0 0 / 35%); }
  main { padding: 12px 16px 96px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 10px; }
  .reason:not(:has(.stars)) { visibility: hidden; }
  .stats { gap: 8px; font-size: 12px; }
  .stats b { font-size: 16px; }
  .stats > :nth-child(n+4) { display: none; }
  .view-head { gap: 8px 4px; }
  .how-toggle, .filters-toggle { padding: 4px 9px; font-size: 12.5px; }
  .how-toggle { padding-inline: 6px; }
  .filters { flex-wrap: nowrap; }
  .filters > * { flex: none; }
  .status-chips { flex: 1 1 auto; flex-wrap: nowrap; min-width: 0; margin-left: -16px; padding-left: 16px; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); }
  .status-chips > * { flex: none; }
  .shelf-menus { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; margin-left: 0; }
  .shelf-select { flex-direction: column; align-items: stretch; gap: 4px; }
  .shelf-select select { max-width: none; width: 100%; }
  kbd { display: none; }
  .bar { width: calc(100vw - 24px); bottom: 12px; justify-content: space-between; gap: 6px; padding: 7px 7px 7px 14px; }
  .bar:has(.save-state:not(:empty)) .tapped { display: none; }
  .bar .primary, .bar .ghost { padding: 7px 12px; }
  .tapped { gap: 9px; font-size: 12.5px; }
  .tapped .word { display: none; }
  .countstrip { gap: 6px 10px; }
  .countstrip .aside { margin-left: 0; width: 100%; }
  .table.conflicts :is(th, td):nth-child(3) { display: none; }
  .table.conflicts td:nth-child(n+3) { white-space: normal; }
  .foot .keys { display: none; }
  .rulepick .seg { width: 100%; }
  .paste .row .seg { flex: 1 1 100%; order: 1; }
  .paste .primary { order: 2; }
  .dialog { width: 100vw; max-width: 100vw; max-height: 88svh; margin: auto 0 0; border: 0; border-radius: 18px 18px 0 0; padding: 10px 18px 20px; }
  .dialog::before { content: ""; display: block; width: 36px; height: 4px; margin: 0 auto 12px; border-radius: 2px; background: var(--line-2); }
}
