:root {
  color-scheme: light dark;
  --bg: #14110d;
  --bg-2: #1c1813;
  --ink: #f3eee0;
  --ink-soft: #a89e87;
  --ink-faint: #6a6052;
  --rule: #2e2a23;
  --accent: #e96846;
  --paper: #f6f3ec;
  --paper-ink: #181410;
  --paper-rule: #cdc6b9;
  --serif: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

html, body { background: var(--bg); color: var(--ink); }
body { margin: 0; font-family: var(--sans); -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }

.page { min-height: 100vh; padding: 0 0 96px; position: relative; overflow-x: hidden; }

/* ───── HEADER ───── */
.site-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: end;
  padding: 56px 56px 22px;
  border-bottom: 1px solid var(--rule);
}
.site-head h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(48px, 7vw, 96px);
  letter-spacing: -0.025em;
  line-height: 0.95;
  margin: 0;
}
.site-head h1 .dot { font-style: normal; color: var(--accent); }
.site-head .meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 14px;
}
.site-head .meta b { color: var(--ink); font-weight: 600; }
.site-head .meta .sep {
  display: inline-block;
  width: 16px; height: 1px;
  background: currentColor;
  vertical-align: middle;
  margin: 0 12px;
  opacity: .6;
}
.site-head .right { display: flex; flex-direction: column; align-items: flex-end; gap: 14px; }
.site-head .tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  text-align: right;
  line-height: 1.45;
  max-width: 320px;
}
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.btn-pick {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: filter .15s, transform .15s;
}
.btn-pick:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-pick:active { transform: translateY(0); }
.btn-pick svg { transition: transform .35s; }
.btn-pick:hover svg { transform: rotate(180deg); }

/* mode toggle (segmented) */
.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px;
  background: rgba(255,255,255,.02);
}
.mode-toggle button {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mode-toggle button:hover { color: var(--ink); }
.mode-toggle button[data-active="true"] { background: var(--ink); color: var(--bg); }
.mode-toggle button .reroll { transition: transform .4s cubic-bezier(.2,.7,.3,1); }
.mode-toggle button.spinning .reroll { transform: rotate(360deg); }

/* Library ⇄ Wishlist — the higher-level "which collection" switch. Same pill
   shape as the mode toggle, but the active state is the warm accent so it reads
   as a different tier of control. */
.library-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px;
  background: rgba(255,255,255,.02);
}
.library-toggle button {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.library-toggle button:hover { color: var(--ink); }
.library-toggle button[data-active="true"] { background: var(--accent); color: #fff; }

/* sort dropdown */
.sort-select {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background-color: rgba(255,255,255,.02);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 30px 8px 14px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%23a89e87' fill='none' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: color .15s, border-color .15s;
}
.sort-select:hover { color: var(--ink); border-color: var(--ink-faint); }
.sort-select option { background: var(--bg-2); color: var(--ink); }

/* search bar */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 13px;
  color: var(--ink-faint);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  background: rgba(255,255,255,.02);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 30px 8px 32px;
  outline: none;
  width: 264px;
  transition: border-color .15s, color .15s;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-input:focus { border-color: var(--ink-faint); }
.search-clear {
  position: absolute;
  right: 11px;
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  transition: color .12s;
}
.search-clear:hover { color: var(--ink); }
.search-row { position: relative; display: flex; align-items: center; gap: 8px; }
.search-hint-btn {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(255,255,255,.02);
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 999px;
  width: 29px; height: 29px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.search-hint-btn:hover,
.search-hint-btn[data-active="true"] { color: var(--ink); border-color: var(--ink-faint); }
.search-hint-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.search-hint-row {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-hint-row code {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  background: rgba(233,104,70,.13);
  border-radius: 4px;
  padding: 2px 6px;
}
.search-results-msg {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  padding: 0 56px;
  margin-top: 18px;
}
.search-results-msg b { color: var(--ink); }
.search-results-msg button {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
}
.search-results-msg button:hover { color: var(--ink); }
@media (max-width: 768px) {
  .search-input { width: 200px; }
  .search-results-msg { padding: 0 24px; }
}

/* ───── INTRO ───── */
.intro {
  padding: 28px 56px 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 760px;
}
.intro b { color: var(--ink); font-style: normal; font-weight: 600; font-family: var(--sans); }

/* ───── SHELVES ───── */
.shelf { padding: 36px 0 0; position: relative; }
.shelf-head {
  padding: 0 56px 14px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.shelf-head .num { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.shelf-head .name { color: var(--ink); font-weight: 600; letter-spacing: 0.12em; }
.shelf-head .ct { color: var(--ink-soft); }
.shelf-head .pos {
  margin-left: auto;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* isolate: items use z-index up to ~600 (one per spine) to stack their overlap;
   without a local stacking context those would compete with — and bleed over —
   the Stats/Reader modals. Isolating the rail keeps all item z-indexes contained
   below the modals. */
.shelf-rail { position: relative; overflow: visible; isolation: isolate; }
.shelf-scroll {
  display: flex;
  align-items: center;
  padding: 24px 56px 24px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  min-height: 220px;
  /* Default left-aligned (used for spines mode) */
  justify-content: flex-start;
}
.shelf-scroll::-webkit-scrollbar { display: none; }
.shelf-scroll.dragging { cursor: grabbing; user-select: none; }
.shelf-scroll.dragging * { pointer-events: none; }

/* sort/filter change — quick, GPU-cheap fade (animates the scroller, not the
   hundreds of items inside it) so large shelves re-order without popping. */
@keyframes sort-fade {
  0%   { opacity: .12; transform: translateY(6px); }
  100% { opacity: 1;   transform: translateY(0); }
}
.shelf.sorting .shelf-scroll { animation: sort-fade .4s cubic-bezier(.2,.7,.3,1); }

.shelf-rail::after,
.shelf-rail::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 56px;
  pointer-events: none;
  z-index: 2;
}
.shelf-rail::before { left: 0;  background: linear-gradient(90deg,  var(--bg) 30%, transparent); }
.shelf-rail::after  { right: 0; background: linear-gradient(270deg, var(--bg) 30%, transparent); }

.shelf-thumb {
  position: absolute;
  bottom: 0;
  left: 56px; right: 56px;
  height: 1px;
  background: var(--rule);
  z-index: 1;
}
.shelf-thumb .bar {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--ink-soft);
  opacity: 0;
  transition: opacity .2s;   /* left/width updated imperatively each frame — no transition so the thumb tracks the drag exactly */
}
.shelf:hover .shelf-thumb .bar { opacity: 1; }

/* Hover arrows — click to glide ~one screenful via native smooth scroll.
   A smooth alternative to click-dragging on big rows. Hidden on touch. */
.shelf-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 99999;          /* above every item: covers can stack up to ~item-count (1000+) in mix mode */
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: var(--ink-soft);
  font-family: var(--sans); font-size: 22px; line-height: 1; padding-bottom: 2px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, color .15s, border-color .15s, background .15s;
}
.shelf-arrow.left  { left: 10px; }
.shelf-arrow.right { right: 10px; }
/* Tie visibility to the whole section, not the rail: a hovered item lifts above
   the rail box, so rail:hover would flicker off as the cursor follows it up. */
.shelf:hover .shelf-arrow { opacity: 1; pointer-events: auto; }
.shelf-arrow:hover { color: var(--ink); border-color: var(--ink-faint); background: var(--bg-2); }
.shelf-arrow:active { transform: translateY(-50%) scale(.92); }
@media (max-width: 768px) { .shelf-arrow { display: none; } }

/* ───── ITEM (cover or spine) ───── */
.item {
  position: relative;
  flex: 0 0 auto;
  height: 144px;
  cursor: pointer;
  border-radius: 2px;
  overflow: hidden;
  background: var(--spine-color, #2a2520);
  box-shadow: 0 1px 0 rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.35);
  transition: width .55s cubic-bezier(.2,.7,.3,1),
              margin .55s cubic-bezier(.2,.7,.3,1),
              transform .35s cubic-bezier(.2,.7,.3,1),
              box-shadow .25s,
              opacity .25s;
  --fan: 30px;
}
.item.as-cover { width: 96px; margin-right: -38px; }
.item.as-spine { width: var(--spine-w, 24px); margin-right: 0; --fan: 12px; }

.layer-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  display: block;
  transition: opacity .4s ease;
}
.as-spine .layer-img { opacity: 0; }

.layer-spine {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
.as-spine .layer-spine { opacity: 1; }

/* paper-tape head + foot bindings */
.spine-band {
  position: absolute;
  left: 0; right: 0;
  height: 18px;
  background: var(--spine-band, rgba(0,0,0,.32));
  pointer-events: none;
}
.spine-band.top    { top: 0;    box-shadow: inset 0 -1px 0 rgba(0,0,0,.18); }
.spine-band.bottom { bottom: 0; box-shadow: inset 0  1px 0 rgba(0,0,0,.18); }
/* a hairline at the inside edge of each band */
.spine-band.top::after, .spine-band.bottom::after {
  content: '';
  position: absolute;
  left: 6%; right: 6%;
  height: 1px;
  background: rgba(255,255,255,.10);
}
.spine-band.top::after    { bottom: 3px; }
.spine-band.bottom::after { top: 3px; }

.spine-glyph {
  position: absolute;
  bottom: 2px;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,.78);
  pointer-events: none;
  z-index: 2;
}

/* lighter foot number when it's a community average (vs a bold personal score) */
.spine-glyph.is-avg { color: rgba(255,255,255,.6); font-weight: 500; }

/* standout "what makes it sublime" marks — monochrome, laid out horizontally
   across the spine top so they read as a quiet row of glyphs, not a colour clash. */
.spine-highlights {
  position: absolute;
  top: 3px; left: 0; right: 0;
  display: flex; flex-direction: row; flex-wrap: nowrap;
  align-items: center; justify-content: center; gap: 2px;
  pointer-events: none;
  z-index: 3;
}
.spine-highlight {
  font-size: 8.5px; line-height: 1;
  /* desaturate to a single grey tone + lift onto the dark band */
  filter: grayscale(1) brightness(1.35) contrast(.85) drop-shadow(0 1px 1px rgba(0,0,0,.6));
  opacity: .92;
}

.spine-label {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  color: rgba(255,255,255,.94);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
  letter-spacing: 0.02em;
  white-space: nowrap;
  max-height: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 0;
}

/* PICKED state — a small accent dot lives in the corner.
   Visible for covers in both layouts; on spines it sits at the very top. */
.pick-dot {
  position: absolute;
  top: 5px; left: 5px; right: auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,0,0,.35);
  z-index: 3;
  opacity: 0;
  transform: scale(.4);
  transition: opacity .25s, transform .35s cubic-bezier(.2,.7,.3,1);
}
.item.picked .pick-dot { opacity: 1; transform: scale(1); }
.as-spine .pick-dot {
  top: 3px;
  left: 50%; right: auto;
  margin-left: -3px; margin-right: 0;
  width: 6px; height: 6px;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.4);
}

/* CENTRE (rank-0) item — gently lifted with a small accent line below.
   We only show the accent line in COVERS / MIX mode; spine mode is
   left-aligned so the centre concept does not apply. */
.item[data-rank="0"][data-mode="covers"],
.item[data-rank="0"][data-mode="mix"] {
  transform: translateY(-6px);
  box-shadow: 0 1px 0 rgba(0,0,0,.4),
              0 18px 28px -10px rgba(0,0,0,.6),
              0 3px 10px rgba(0,0,0,.45);
}
.item[data-rank="0"][data-mode="covers"]::after,
.item[data-rank="0"][data-mode="mix"]::after {
  content: '';
  position: absolute;
  left: 18%; right: 18%;
  bottom: -10px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  opacity: .9;
}

/* Hover state — pure CSS so hovering never re-renders the row (large spine rows
   have hundreds of items; a React re-render per hover was the source of the lag).
   No `:has()` neighbor fan-out: `:has()` re-evaluates on every hover change and
   added measurable mouse-hover cost for no real benefit. The hovered item lifts
   in every mode; neighbors stay put. */
.item:hover {
  transform: translateY(-18px) scale(1.18) !important;
  z-index: 200;
  box-shadow: 0 24px 50px -8px rgba(0,0,0,.7),
              0 4px 12px rgba(0,0,0,.5),
              0 0 0 1px rgba(255,255,255,.06) !important;
}

/* Just-picked lift — applies for a clear, lasting highlight. */
.item[data-pos="just-picked"] {
  transform: translateY(-20px) scale(1.22) !important;
  box-shadow: 0 0 0 3px var(--accent),
              0 0 0 7px rgba(233,104,70,.25),
              0 28px 56px -8px rgba(0,0,0,.75) !important;
  animation: cover-glow 3s ease-out;
}
@keyframes cover-glow {
  0%   { box-shadow: 0 0 0 4px var(--accent), 0 0 24px 10px rgba(233,104,70,.55), 0 28px 56px -8px rgba(0,0,0,.75); }
  50%  { box-shadow: 0 0 0 3px var(--accent), 0 0 12px 5px rgba(233,104,70,.3),  0 28px 56px -8px rgba(0,0,0,.75); }
  100% { box-shadow: 0 0 0 3px var(--accent), 0 0 0   0   rgba(233,104,70,.0),  0 28px 56px -8px rgba(0,0,0,.75); }
}
/* While a "Pick one for me" result is highlighted, dim the rest of its row
   so the chosen item is the only thing lit. Clears with justPickedId. */
.shelf.is-picking .item:not([data-pos="just-picked"]) {
  opacity: 0.28;
}

/* Mix-mode re-roll animation */
.item.reshuffling { animation: reshuffle .6s cubic-bezier(.2,.7,.3,1); }
@keyframes reshuffle {
  0%   { transform: scale(.85) rotate(-3deg); opacity: .3; }
  60%  { transform: scale(1.04) rotate(.5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ───── POPUP ───── */
.popup {
  position: fixed;
  top: 0; left: 0;
  width: 280px;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 4px;
  padding: 16px 18px 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(0,0,0,.08);
  z-index: 1000;
  pointer-events: auto;
  transform-origin: bottom center;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(0) scale(.95);
  transition: opacity .18s, transform .22s cubic-bezier(.2,.7,.3,1);
  font-family: var(--sans);
  overflow: hidden;
}
.popup.on {
  opacity: 1;
  transform: translate(-50%, -100%) translateY(-14px) scale(1);
}
.popup.below {
  transform-origin: top center;
  transform: translate(-50%, 0) translateY(0) scale(.95);
}
.popup.below.on {
  transform: translate(-50%, 0) translateY(14px) scale(1);
}
.popup::after {
  content: '';
  position: absolute;
  bottom: -6px; left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px; height: 12px;
  background: var(--paper);
  z-index: -1;
}
.popup.below::after { bottom: auto; top: -6px; }
/* Invisible hit-area bridging the gap between the item and the popup, so
   moving the cursor up into the popup doesn't trip the close timer. */
.popup-bridge {
  position: absolute;
  left: 0; right: 0;
  bottom: -22px;
  height: 24px;
  background: transparent;
}
.popup.below .popup-bridge { bottom: auto; top: -22px; }
.popup .meta {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a8175;
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.popup .meta .pip { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.popup .t {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--paper-ink);
}
.popup .t {
  overflow-wrap: break-word;
}
.popup .blurb {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  line-height: 1.42;
  color: #4a443c;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--paper-rule);
  max-height: 8em;
  overflow: hidden;
  overflow-wrap: break-word;
}
.popup .blurb.empty { color: #98908a; font-size: 12px; }
.popup .hint {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ───── READER MODAL ───── */
.reader-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  opacity: 0;
  transition: opacity .25s;
}
.reader-backdrop.on { opacity: 1; }
.reader {
  width: min(960px, 100%);
  max-height: calc(100vh - 80px);
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 6px;
  display: grid;
  grid-template-columns: 320px 1fr;
  /* Bound the single row to the modal height (minmax(0,…) lets it shrink below
     content) so .reader-body becomes its own scroller on tall content. */
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  transform: translateY(20px) scale(.97);
  opacity: 0;
  transition: transform .3s cubic-bezier(.2,.7,.3,1), opacity .25s;
}
.reader-backdrop.on .reader { transform: translateY(0) scale(1); opacity: 1; }
.reader-poster { position: relative; background: #222; }
.reader-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 28px; text-align: center;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.10), transparent 60%),
    linear-gradient(160deg, color-mix(in oklab, var(--pf-bg, #2a2520) 82%, #ffffff 8%), var(--pf-bg, #2a2520));
}
.poster-fallback .pf-title {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: 28px; line-height: 1.12; color: rgba(255,255,255,.94);
  text-shadow: 0 1px 3px rgba(0,0,0,.45); overflow-wrap: break-word;
}
.poster-fallback .pf-meta {
  font-family: var(--mono); font-size: 10px; letter-spacing: .2em;
  text-transform: uppercase; color: rgba(255,255,255,.62);
}
.reader-body {
  padding: 36px 38px 32px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  /* In the 2-col grid the body is a grid item; default min-height:auto makes it
     grow to its content and overflow the clipped .reader instead of scrolling.
     min-height:0 lets the track bound it to the modal height so it scrolls. */
  min-height: 0;
  /* Scrollbar lives here but stays invisible until the cursor is over the reader
     (thumb fades in — no layout shift since the gutter width is constant). */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color .2s;
}
.reader-body::-webkit-scrollbar { width: 8px; }
.reader-body::-webkit-scrollbar-track { background: transparent; }
.reader-body::-webkit-scrollbar-thumb { background: transparent; border-radius: 8px; transition: background .2s; }
.reader:hover .reader-body { scrollbar-color: rgba(0,0,0,.26) transparent; }
.reader:hover .reader-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.22); }
.reader:hover .reader-body::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.4); }
.reader-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(4px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper-ink);
  z-index: 4;
  transition: background .15s, color .15s;
}
.reader-close:hover { background: var(--paper-ink); color: var(--paper); }
.reader-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #6a6052;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  row-gap: 6px;
  align-items: center;
  margin-bottom: 16px;
}
.reader-meta .sep { width: 18px; height: 1px; background: currentColor; }
.reader-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 56px;
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  color: var(--paper-ink);
  text-wrap: pretty;
}
.reader-title .dot { font-style: normal; color: var(--accent); }
/* original / localized title under the English headline */
.reader-orig {
  font-family: var(--serif); font-style: italic; font-size: 15px;
  color: #8a8175; margin: 2px 0 12px;
}
.reader-where {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #98908a;
  margin-bottom: 22px;
}
.reader-quote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1.45;
  color: var(--paper-ink);
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 18px;
  margin: 0 0 22px;
}
.reader-quote.empty { color: #98908a; font-size: 14px; }
/* Click-to-translate (PL↔EN) with a matrix-style vertical letter cascade */
.reader-quote.translatable { cursor: pointer; position: relative; transition: border-color .3s; }
.reader-quote.translatable:hover { border-left-color: var(--paper-ink); }
.reader-quote .qc {
  display: inline-block; white-space: pre;
  animation: matrixRoll .6s cubic-bezier(.16,.8,.3,1) backwards;
}
@keyframes matrixRoll {
  0%   { opacity: 0; transform: translateY(-1.15em) scaleY(1.6); filter: blur(3px); }
  45%  { opacity: 1; filter: blur(.3px); }
  72%  { transform: translateY(.09em) scaleY(.96); }
  100% { opacity: 1; transform: none; filter: none; }
}
.quote-flip {
  display: inline-block; margin-left: 8px; font-style: normal;
  font-family: var(--mono); font-size: 9px; letter-spacing: .12em;
  color: var(--ink-soft); opacity: .45; vertical-align: middle;
  transition: opacity .2s;
}
.reader-quote.translatable:hover .quote-flip { opacity: .8; }
.reader-summary {
  font-size: 13px; line-height: 1.55; color: var(--ink-faint);
  margin: -10px 0 22px; font-family: var(--mono);
  animation: summaryFade .32s ease;
}
@keyframes summaryFade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
/* Subtle inline IMDb⇄TMDB source flip at the end of the description (same spirit
   as the PL⇄EN quote flip). */
.summary-flip {
  margin-left: 8px; cursor: pointer; white-space: nowrap;
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); opacity: .5; transition: opacity .2s;
}
.summary-flip:hover { opacity: .9; }
/* Critic scores collection */
.reader-scores {
  display: flex; flex-wrap: wrap; gap: 6px 8px;
  margin: -8px 0 16px; font-family: var(--mono); font-size: 11px;
}
.reader-scores .score {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink-soft); background: rgba(255,255,255,.02);
}
.reader-scores .score b { font-weight: 600; color: var(--ink-faint); letter-spacing: .04em; }
/* Parsed award chips share the scores line; full OMDb sentence on hover. */
.reader-scores .reader-awards {
  display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center;
  cursor: help; padding-left: 8px; margin-left: 2px;
  border-left: 1px solid var(--rule);
}
.reader-awards .award-chip {
  padding: 4px 9px; border-radius: 999px; font-size: 10.5px;
  background: rgba(224,161,18,.10); color: var(--paper-ink-faint, #98908a);
  border: 1px solid rgba(224,161,18,.22);
}
.reader-crew {
  display: flex; flex-wrap: wrap; gap: 6px 20px;
  margin: 4px 0 10px; font-size: 12px; color: var(--paper-ink-faint, #98908a);
}
.reader-crew .crew-role {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent); margin-right: 4px;
}
.reader-cast {
  font-size: 12px; color: var(--paper-ink-faint, #98908a);
  margin: 8px 0 10px; line-height: 1.6;
}
.reader-cast-label {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent); margin-right: 8px;
}
.reader-tags {
  display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 16px;
}
.reader-tag {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: lowercase;
  background: var(--rule, rgba(0,0,0,.08)); color: var(--paper-ink-faint, #98908a);
  padding: 3px 7px; border-radius: 2px;
}
.meta-link { cursor: pointer; transition: opacity .15s; }
.meta-link:hover { opacity: 0.55; }

/* standout highlight chips in the reader */
.reader-highlights { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 16px; }
.reader-highlight {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--paper-ink); background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 4px 9px; border-radius: 999px;
}
.reader-highlight .rh-emoji { font-size: 12px; line-height: 1; }
.reader-actions {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.reader-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 11px 16px;
  border: 1px solid var(--paper-ink);
  background: transparent;
  color: var(--paper-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 2px;
  transition: all .15s;
}
.reader-btn:hover { background: var(--paper-ink); color: var(--paper); }
.reader-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.reader-btn.primary:hover { background: var(--paper-ink); border-color: var(--paper-ink); }

/* Morphing Filmweb⇄IMDb "Open on …" button. Hover the left/right half to flip
   the destination; the label slides across, a highlight follows the cursor, and
   the IMDb side adopts IMDb's yellow + heavier wordmark styling. */
.reader-btn.source-switch {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: background .28s ease, color .28s ease, border-color .28s ease;
}
.reader-btn.source-switch:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* IMDb side — a deep amber/gold, darker and warmer than the bright IMDb yellow. */
.reader-btn.source-switch[data-side="imdb"],
.reader-btn.source-switch[data-side="imdb"]:hover {
  background: #e0a112;
  color: #0a0a0a;
  border-color: #bf850a;
}
.source-switch .ss-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 50%;
  background: rgba(255,255,255,.16);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1), background .28s ease;
  z-index: -1;
  pointer-events: none;
}
.reader-btn.source-switch[data-side="imdb"] .ss-fill {
  transform: translateX(0);
  background: rgba(0,0,0,.12);
}
/* Two labels share one grid cell so the button is sized to the wider one and
   they can cross-slide without reflowing the layout. */
.source-switch .ss-labels {
  display: grid;
  overflow: hidden;
}
.source-switch .ss-label {
  grid-area: 1 / 1;
  white-space: nowrap;
  transition: transform .28s cubic-bezier(.4,0,.2,1), opacity .2s ease;
}
.source-switch[data-side="primary"] .ss-a { transform: translateX(0);    opacity: 1; }
.source-switch[data-side="primary"] .ss-b { transform: translateX(55%);  opacity: 0; }
.source-switch[data-side="imdb"]    .ss-a { transform: translateX(-55%); opacity: 0; }
.source-switch[data-side="imdb"]    .ss-b { transform: translateX(0);    opacity: 1; }
.reader-adjacent {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--paper-rule);
}
.reader-adjacent .lbl {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a8175;
  margin-bottom: 10px;
}
.reader-adjacent .row { display: flex; gap: 6px; overflow-x: auto; cursor: grab; scrollbar-width: none; }
.reader-adjacent .row::-webkit-scrollbar { display: none; }
.reader-adjacent .row.dragging { cursor: grabbing; user-select: none; }
.reader-adjacent .row.dragging * { pointer-events: none; }
.reader-adjacent .row a {
  width: 56px;
  aspect-ratio: 2/3;
  flex-shrink: 0;
  background: #ccc;
  cursor: pointer;
  border-radius: 1px;
  overflow: hidden;
  transition: transform .15s;
  position: relative;
}
.reader-adjacent .row a:hover { transform: translateY(-3px); }
.reader-adjacent .row a img { width:100%; height:100%; object-fit:cover; display:block; }
.reader-adjacent .row a .thumb-fallback {
  width:100%; height:100%; display:flex; align-items:center; justify-content:center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: rgba(255,255,255,.82); background: var(--pf-bg, #2a2520);
}

/* Crossover row — the seen↔unseen "similar in the other collection" strip. */
.reader-crossover .lbl { color: var(--accent); }
.reader-crossover .row a .crossover-badge {
  position: absolute;
  top: 3px; right: 3px;
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1;
  color: #fff;
  background: rgba(20,17,13,.72);
  border-radius: 50%;
  pointer-events: none;
}

/* ───── FOOTER ───── */
.site-foot {
  margin-top: 64px;
  padding: 24px 56px 0;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  flex-wrap: wrap;
}
.site-foot a { color: var(--accent); text-decoration: none; }
.site-foot a:hover { color: var(--ink); }
.site-foot .links { display: flex; gap: 20px; }

@media (max-width: 768px) {
  .site-head { padding: 32px 24px 18px; grid-template-columns: 1fr; }
  .site-head .right { align-items: flex-start; }
  .site-head .tagline { text-align: left; }
  .intro { padding: 24px 24px 0; font-size: 16px; }
  .shelf-head { padding: 0 24px 12px; }
  .shelf-scroll { padding: 18px 24px 18px; }
  .shelf-rail::before, .shelf-rail::after { width: 24px; }
  .shelf-thumb { left: 24px; right: 24px; }
  .site-foot { padding: 24px 24px 0; }
  .reader-backdrop { padding: 12px; }
  /* Whole reader scrolls as one column — poster included. dvh (not vh) so the
     mobile address bar doesn't mis-size the box and appear to pin the poster.
     Both children are flex: 0 0 auto so neither becomes its own scroller. */
  .reader { grid-template-columns: 1fr; max-height: calc(100dvh - 24px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: flex; flex-direction: column; }
  .reader-poster { position: static; aspect-ratio: initial; height: 260px; flex: 0 0 auto; display: flex; justify-content: center; align-items: flex-start; overflow: hidden; }
  .reader-poster img { width: auto; height: 100%; object-fit: cover; object-position: top center; }
  .reader-body { overflow: visible; flex: 0 0 auto; }
  .reader-title { font-size: 40px; }
  .yr-chips-section { padding: 24px 24px 0; }
}

/* sort direction button */
.sort-dir-btn {
  font-family: var(--mono);
  font-size: 13px;
  background: rgba(255,255,255,.02);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  line-height: 1;
  transition: color .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
}
.sort-dir-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-faint); }
.sort-dir-btn:disabled { opacity: .3; cursor: default; }

/* year chips strip */
.yr-chips-section {
  padding: 28px 56px 0;
  border-top: 1px solid var(--rule);
  margin-top: 16px;
}
.yr-chips-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.yr-chips-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
}
.yr-chips-scroll::-webkit-scrollbar { display: none; }
.yr-chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 14px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.yr-chip:hover:not(.unavailable) { color: var(--ink); border-color: var(--ink-faint); }
.yr-chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.yr-chip.selected:hover { filter: brightness(1.08); }
.yr-chip.unavailable { opacity: .2; cursor: default; pointer-events: none; }

/* ───── ACTIVE FILTER PILLS ───── */
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 56px 0; }
.filter-pill {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--accent); border-radius: 999px;
  color: var(--accent); padding: 4px 10px; white-space: nowrap;
}
.filter-pill button {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0; opacity: .7;
}
.filter-pill button:hover { opacity: 1; }
.filter-pill-clear {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  background: none; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink-faint); padding: 4px 10px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.filter-pill-clear:hover { color: var(--ink); border-color: var(--ink-faint); }
@media (max-width: 768px) { .active-filters { padding: 10px 24px 0; } }

/* ───── STATS MODAL ───── */
.stats-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  z-index: 300; overflow-y: auto; padding: 32px 24px 64px;
}
.stats-modal {
  max-width: 1080px; margin: 0 auto;
  background: var(--bg-2); border: 1px solid var(--rule);
  border-radius: 16px; padding: 40px 40px 48px; position: relative;
}
.stats-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink-soft); cursor: pointer; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center; transition: color .15s;
}
.stats-close:hover { color: var(--ink); }
.stats-head { margin-bottom: 28px; }
.stats-head h2 {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 36px; margin: 0 0 4px; letter-spacing: -0.02em;
}
.stats-head h2 .dot { font-style: normal; color: var(--accent); }
.stats-subtitle { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.stats-medium-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 36px; padding-bottom: 28px; border-bottom: 1px solid var(--rule); }
.stats-medium-tab {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink-soft); padding: 6px 14px; cursor: pointer; transition: all .15s;
}
.stats-medium-tab:hover { color: var(--ink); border-color: var(--ink-faint); }
.stats-medium-tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Charts ⇄ Taste profile tab bar */
.stats-tabs { display: flex; gap: 22px; margin: 4px 0 24px; border-bottom: 1px solid var(--rule); }
.stats-tab {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-faint); padding: 0 0 12px; margin-bottom: -1px; cursor: pointer; transition: color .15s, border-color .15s;
}
.stats-tab:hover { color: var(--ink); }
.stats-tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* Taste profile */
.taste-two { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.taste-col-head { font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 10px; }
.taste-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.taste-row:hover .taste-row-title { color: var(--accent); }
.taste-row-title { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.taste-row-scores { display: inline-flex; gap: 8px; flex-shrink: 0; font-family: var(--mono); font-size: 10px; }
.taste-row-scores .me  { color: var(--ink-soft); }
.taste-row-scores .vs  { color: var(--ink-faint); }
.taste-row-scores .delta.pos { color: #6fbf73; }
.taste-row-scores .delta.neg { color: #d3776b; }
.taste-empty { color: var(--ink-faint); font-family: var(--mono); font-size: 11px; }
.taste-time-total { font-size: 28px; font-family: var(--serif, serif); color: var(--ink); margin-bottom: 14px; }
.taste-time-list, .taste-fp { display: flex; flex-direction: column; gap: 7px; }
.taste-time-row, .taste-fp > div { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 11px; color: var(--ink-soft); border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.taste-fp .k { color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.12em; font-size: 9px; }
.taste-fp .v { color: var(--ink); text-align: right; }
.taste-timeline { width: 100%; height: auto; display: block; }
.wl-pick-row { margin-bottom: 14px; }
.wl-pick-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.wl-pick-sub { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); }
.wl-pick-row .explorer-wall { max-height: none; }
.taste-growth-layout { display: flex; gap: 12px; align-items: flex-start; }
.taste-growth-chart { flex: 1; min-width: 0; }
.taste-growth-legend { width: 130px; flex-shrink: 0; display: flex; flex-direction: column; gap: 3px; }
.growth-leg { display: flex; align-items: center; gap: 6px; cursor: pointer; font-family: var(--mono); font-size: 9px; color: var(--ink-soft); transition: opacity .12s; }
.growth-leg.off { opacity: .38; }
.growth-leg:hover { color: var(--ink); }
.growth-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.growth-leg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.growth-leg-cnt { color: var(--ink-faint); }
@media (max-width: 640px) { .taste-growth-layout { flex-direction: column; } .taste-growth-legend { width: 100%; flex-flow: row wrap; } }

/* Summon-search palette ("/" or Cmd/Ctrl-K) */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(8,6,4,.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 18vh;
}
.palette {
  width: min(640px, 90vw);
  background: var(--bg, #1b1712); border: 1px solid var(--rule);
  border-radius: 14px; padding: 8px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.palette-input {
  width: 100%; box-sizing: border-box;
  background: transparent; border: 0; outline: 0;
  color: var(--ink); font-family: var(--serif, serif); font-size: 22px;
  padding: 14px 16px;
}
.palette-input::placeholder { color: var(--ink-faint); }
.palette-hints {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 16px 12px; border-top: 1px solid var(--rule);
}
.palette-hints code {
  font-family: var(--mono); font-size: 10px; color: var(--ink-soft);
  background: rgba(255,255,255,.05); padding: 2px 6px; border-radius: 5px;
}
.palette-enter { margin-left: auto; font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); }

.stats-section { margin-bottom: 44px; }
.stats-section-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 18px;
}
/* Section header row with a control parked at the right end (e.g. the rating
   source toggle). The title keeps its own margin; the row aligns them. */
.stats-section-title-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.stats-section-title-row .stats-section-title { margin-bottom: 18px; }
.rating-source-toggle {
  display: inline-flex; flex-shrink: 0;
  border: 1px solid var(--rule); border-radius: 999px; padding: 2px;
}
.rating-source-toggle button {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  background: transparent; border: 0; color: var(--ink-soft);
  padding: 5px 10px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s;
}
.rating-source-toggle button:hover { color: var(--ink); }
.rating-source-toggle button[data-active="true"] { background: var(--ink); color: var(--bg); }
/* Filmweb-avg view is display-only (library filter is on personal rating). */
.rating-hist.static .rating-col { cursor: default; }
.rating-hist.static .rating-col:hover .rating-bar { opacity: 1; }
.stats-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 44px; }
.stats-two-col .stats-section { margin-bottom: 0; }
/* The whole header is the dropdown target: the <select> overlays it invisibly so a
   click anywhere on the title/chevron opens the native menu. */
.stats-view-head { position: relative; display: flex; align-items: center; gap: 8px; margin-bottom: 18px; cursor: pointer; width: fit-content; max-width: 100%; }
.stats-view-head .stats-section-title { margin-bottom: 0; }
.stats-view-chevron { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); line-height: 1; user-select: none; }
.stats-view-head:hover .stats-section-title,
.stats-view-head:hover .stats-view-chevron { color: var(--ink); }
.stats-view-select-overlay { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; margin: 0; cursor: pointer; }
@media (max-width: 768px) {
  .stats-modal { padding: 24px; }
  .stats-two-col { grid-template-columns: 1fr; gap: 28px; }
}

/* rating histogram */
.rating-hist { display: flex; align-items: flex-end; gap: 5px; height: 120px; }
.rating-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; cursor: pointer; }
.rating-col:hover .rating-bar { opacity: .75; }
.rating-bar {
  width: 100%; border-radius: 3px 3px 0 0;
  transition: background .15s, opacity .15s, height .42s cubic-bezier(.4,0,.2,1);
  background: var(--rule); min-height: 3px;
}
.rating-col.active .rating-bar { background: var(--accent); }
.rating-lbl { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); }
.rating-cnt { font-family: var(--mono); font-size: 9px; color: var(--ink-soft); }

/* horizontal bar histograms (directors / studios) */
.hbar-list { display: flex; flex-direction: column; gap: 5px; overflow-y: auto; max-height: 460px; }
.hbar-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.hbar-row:hover .hbar-fill { opacity: .75; }
.hbar-row.active .hbar-fill { background: var(--accent); }
.hbar-name { font-family: var(--mono); font-size: 9px; color: var(--ink-soft); width: 140px; min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { flex: 1; height: 10px; background: rgba(255,255,255,.04); border-radius: 2px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--rule); border-radius: 2px; transition: background .15s, opacity .15s; }
.hbar-cnt { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); width: 24px; text-align: right; flex-shrink: 0; }

/* activity heatmap */
.heatmap-wrap { overflow-x: auto; }
.heatmap-inner { display: inline-block; min-width: 100%; }
.heatmap-months { display: grid; gap: 2px; margin-bottom: 4px; }
.heatmap-month-lbl { font-family: var(--mono); font-size: 8px; color: var(--ink-faint); }
.heatmap-rows { display: flex; flex-direction: column; gap: 2px; }
.heatmap-row { display: flex; align-items: center; gap: 2px; }
.heatmap-year-lbl { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); width: 34px; flex-shrink: 0; }
.heatmap-cell {
  width: 11px; height: 11px; border-radius: 2px; flex-shrink: 0; cursor: pointer;
  transition: opacity .1s; background: rgba(255,255,255,.05);
}
.heatmap-cell:hover { opacity: .7; }
.heatmap-cell.selected { outline: 1.5px solid var(--ink); outline-offset: 1px; }
.heatmap-month-row { display: flex; gap: 2px; margin-bottom: 4px; padding-left: 36px; }
.heatmap-month-cell { width: 11px; flex-shrink: 0; font-family: var(--mono); font-size: 8px; color: var(--ink-faint); text-align: center; }
/* On wide screens the calendar stretches to fill the panel — cells become rectangles. */
@media (min-width: 820px) {
  .heatmap-wrap { overflow-x: visible; }
  .heatmap-inner { display: block; min-width: 0; }
  .heatmap-row, .heatmap-month-row { gap: 3px; }
  .heatmap-cell, .heatmap-month-cell { flex: 1 1 0; width: auto; min-width: 0; }
}
.heatmap-tooltip {
  position: fixed; background: var(--bg-2); border: 1px solid var(--rule);
  border-radius: 6px; padding: 6px 10px; font-family: var(--mono); font-size: 10px;
  color: var(--ink); pointer-events: none; z-index: 500; white-space: nowrap;
}

/* choropleth map */
.world-map-layout { display: flex; gap: 14px; align-items: flex-start; }
.world-map-layout .world-map-wrap { flex: 1; min-width: 0; }
.world-map-wrap { position: relative; background: rgba(255,255,255,.02); border-radius: 8px; overflow: hidden; }
.world-map-svg { display: block; width: 100%; height: auto; }
/* Clickable country ranking beside the map — reaches countries too small to click. */
.country-list { width: 190px; flex-shrink: 0; max-height: 430px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.country-row { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; font-family: var(--mono); font-size: 10px; color: var(--ink-soft); padding: 3px 7px; border-radius: 3px; }
.country-row:hover { background: rgba(255,255,255,.05); color: var(--ink); }
.country-row.active { background: var(--accent); color: #fff; }
.country-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-cnt { color: var(--ink-faint); flex-shrink: 0; }
.country-row.active .country-cnt { color: #fff; }
@media (max-width: 700px) {
  .world-map-layout { flex-direction: column; }
  .country-list { width: 100%; max-height: 190px; flex-flow: row wrap; }
  .country-row { flex: 0 0 auto; }
}
.map-path { transition: opacity .15s; }

/* ── Palette explorer (Taste tab) ── */
.explorer-hint { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-bottom: 8px; }
.explorer-hint b { color: var(--ink-soft); font-weight: 600; }
.explorer-rail, .explorer-cloud { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; align-items: center; }
.explorer-cloud { max-height: 150px; overflow-y: auto; padding: 2px; }
.xchip {
  font-family: var(--mono); font-size: 10px; color: var(--ink-soft); line-height: 1;
  background: rgba(255,255,255,.04); border: 1px solid var(--rule); border-radius: 999px;
  padding: 4px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  transition: background .15s, border-color .15s, color .15s;
}
.xchip:hover { color: var(--ink); border-color: var(--ink-soft); }
.xchip .xc { color: var(--ink-faint); font-size: 8.5px; }
.xchip.sel.and { background: var(--accent); color: #fff; border-color: var(--accent); }
.xchip.sel.or  { background: #2f6f5e; color: #fff; border-color: #2f6f5e; }
.xchip.sel .xc { color: rgba(255,255,255,.7); }
.xchip.tag.notable:not(.sel) { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); color: var(--ink); }
.xchip.tag.notable:not(.sel) .xc { color: var(--accent); }
.taste-timeline-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 7px; color: var(--ink-faint); margin-top: 2px; }
.xop { font-weight: 700; opacity: .9; margin-right: 1px; }
.explorer-query { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin: 2px 0 6px; line-height: 1.5; }
.explorer-query b { color: var(--ink-soft); font-weight: 600; }
.explorer-query .qjoin { color: var(--accent); font-weight: 700; }
.explorer-count { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); margin: 4px 0 8px; display: flex; align-items: center; gap: 10px; }
.xclear { font-family: var(--mono); font-size: 9px; background: none; border: 1px solid var(--rule); color: var(--ink-faint); border-radius: 999px; padding: 2px 8px; cursor: pointer; }
.xclear:hover { color: var(--ink); }
.explorer-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; max-height: 360px; overflow-y: auto; }
.xcover { aspect-ratio: 2/3; border-radius: 3px; overflow: hidden; cursor: pointer; background: rgba(255,255,255,.03); display: block; transition: outline-color .12s, filter .12s; outline: 2px solid transparent; outline-offset: -2px; }
.xcover:hover { outline-color: var(--accent); filter: brightness(1.08); }
.xcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.xcover-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--pf-bg, #2a2520); }
@media (min-width: 700px) { .explorer-wall { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); } }
.map-path.clickable { cursor: pointer; }
.map-path.clickable:hover { opacity: .7; }
.map-path.selected { stroke: var(--ink); stroke-width: 0.5px; }
.map-tooltip {
  position: fixed; background: var(--bg-2); border: 1px solid var(--rule);
  border-radius: 6px; padding: 6px 10px; font-family: var(--mono); font-size: 10px;
  color: var(--ink); pointer-events: none; z-index: 500; white-space: nowrap;
}
/* stats button in header */
.btn-stats {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  background: rgba(255,255,255,.03); color: var(--ink-soft);
  border: 1px solid var(--rule); padding: 10px 16px; border-radius: 999px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s, border-color .15s;
}
.btn-stats:hover { color: var(--ink); border-color: var(--ink-faint); }
