/* Layout: a lit wall of shelves — cases and books sit on continuous oak planks; filters run down the left, stats share the same filters. */
:root {
  --bg: #eceff4;
  --surface: #ffffff;
  --fg: #161a22;
  --muted: #5b6474;
  --line: #d5dae3;
  --accent: #2c59d4;
  --accent-ink: #ffffff;
  --plank-top: #c79b6c;
  --plank-face: #94693f;
  --plank-shadow: rgba(60, 40, 20, .28);
  --danger: #b4232f;
  --loan: #f0c64a;
  --loan-ink: #2a2006;
  --scrim: rgba(14, 17, 24, .55);
  --c-movie: #2c59d4;   /* chart series: movies */
  --c-book: #a86e0e;    /* chart series: books */
  --c-tv: #1d8a6b;      /* chart series: TV shows */
  --track: #e6e9ef;
  --font-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, monospace;
  --gap: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111419; --surface: #1a1e26; --fg: #e8ebf1; --muted: #98a1b1; --line: #2b313c;
    --accent: #7c9dff; --accent-ink: #0d1220; --plank-top: #6b4f36; --plank-face: #452f1e;
    --plank-shadow: rgba(0, 0, 0, .55); --danger: #ff7a84; --scrim: rgba(0, 0, 0, .7);
    --c-movie: #5c84ee; --c-book: #a8771a; --c-tv: #2e9a7a; --track: #242a34;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111419; --surface: #1a1e26; --fg: #e8ebf1; --muted: #98a1b1; --line: #2b313c;
  --accent: #7c9dff; --accent-ink: #0d1220; --plank-top: #6b4f36; --plank-face: #452f1e;
  --plank-shadow: rgba(0, 0, 0, .55); --danger: #ff7a84; --scrim: rgba(0, 0, 0, .7);
  --c-movie: #5c84ee; --c-book: #a8771a; --c-tv: #2e9a7a; --track: #242a34;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background-color: var(--bg); background-image: var(--wall, none); background-size: var(--wall-size, auto); background-attachment: fixed; color: var(--fg);
  min-height: 100vh; font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 64px;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.brand h1 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(40px, 7vw, 64px); line-height: .9; letter-spacing: .01em; text-transform: uppercase; }
.brand p { margin: 6px 0 0; color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.linkish:hover { text-decoration: underline; }
.banner { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--muted); font-size: 14px; }
.banner strong { color: var(--fg); }

/* Shelf switcher */
.people { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.person { flex: none; display: flex; align-items: center; gap: 8px; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.person .avatar { width: 22px; height: 22px; }
.person .n { font-weight: 500; white-space: nowrap; }
.person .c { color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.person[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* Toolbar */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tabs { display: inline-flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 6px 14px 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-family: var(--font-display); font-size: 20px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 5px 14px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.search { flex: 1 1 200px; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; }
.bar select { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 12px; }
.note { color: var(--muted); font-size: 13.5px; margin: 0; }
.filters-toggle { display: none; }

/* Main layout */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; align-items: start; }
.filters { position: sticky; top: 12px; max-height: calc(100dvh - 24px); overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding-right: 4px; scrollbar-width: thin; }
.filters-head { display: none; }
@media (max-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .filters-toggle { display: inline-block; }
  .filters { display: none; }
  .filters.open { display: flex; position: fixed; inset: 0; z-index: 50; max-height: none; background: var(--bg); padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .filters.open .filters-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--bg); padding-bottom: 8px; z-index: 1; }
}
.facet { display: flex; flex-direction: column; gap: 4px; }
.facet h3 { margin: 0 0 4px; font-family: var(--font-mono); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; }
.facet input[type=search] { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 9px; font-size: 13px; margin-bottom: 4px; width: 100%; }
.fopt { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; padding: 2px 0; min-width: 0; }
.fopt input { margin: 0; accent-color: var(--accent); flex: none; }
.fopt .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fopt .k { color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.fopt.zero { opacity: .45; }
.decades { display: flex; flex-wrap: wrap; gap: 6px; }
.dchip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dchip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.dchip.zero { opacity: .45; }
.minstars { display: flex; gap: 2px; }
.minstars button { border: 0; background: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 2px; color: var(--line); }
.minstars button.on { color: #e0a526; }

.active { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.achip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); color: var(--fg); background: var(--surface); border-radius: 999px; padding: 3px 6px 3px 12px; font-size: 13px; cursor: pointer; }
.achip .x { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--track); font-size: 12px; line-height: 1; }
.achip .f { color: var(--muted); }
.result-count { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* The shelf */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); column-gap: var(--gap); row-gap: 30px; align-items: end; padding-inline: calc(var(--gap) / 2); }
@media (max-width: 520px) { :root { --gap: 16px; } .shelf { grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); } }
.slot { display: flex; flex-direction: column; min-width: 0; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.stand { position: relative; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px; height: 100%; }
.stand::after { content: ""; position: absolute; left: calc(var(--gap) / -2 - 1px); right: calc(var(--gap) / -2 - 1px); bottom: 0; height: 14px;
  background: linear-gradient(var(--plank-top) 0 4px, var(--plank-face) 4px); box-shadow: 0 8px 14px -6px var(--plank-shadow); }
/* Every caption is the same height (2 title lines + 1 detail line), so all planks in a row line up */
.slot .meta { padding-top: 10px; min-width: 0; height: calc(10px + 2 * 13.5px * 1.25 + 2px + 11.5px * 1.5); overflow: hidden; flex: none; }
.slot .t { font-weight: 600; font-size: 13.5px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot .s { color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case { transition: transform .25s ease; }
.slot:hover .case, .slot:focus-visible .case { transform: translateY(-6px) rotate(-.6deg); }
@media (prefers-reduced-motion: reduce) { .case { transition: none; } .slot:hover .case, .slot:focus-visible .case { transform: none; } }
.slot.example { cursor: default; }
.slot.example .case { opacity: .85; }

/* Cases & covers */
.case { position: relative; width: 100%; max-width: 100%; container-type: inline-size; box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 10px 18px -8px rgba(0,0,0,.45); }
.case .art { position: absolute; overflow: hidden; background: #333; }
.case .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.case .art.fit img { object-fit: contain; position: relative; }
.case .art .blurfill { position: absolute; inset: -12%; background-size: cover; background-position: center; filter: blur(10px) brightness(.55) saturate(1.2); }
.case .band { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-body); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: 5.4cqw; }
.plastic::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(118deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.04) 32%, transparent 33%, transparent 100%); }
.f-bluray { aspect-ratio: 135/171; border-radius: 5px; background: linear-gradient(#2f6ae0, #143f9f); }
.f-bluray .band { height: 9%; }
.f-bluray .art { inset: 9% 3.2% 3.2% 3.2%; border-radius: 1px; }
.f-uhd { aspect-ratio: 135/171; border-radius: 5px; background: linear-gradient(#232323, #050505); }
.f-uhd .band { height: 9%; background: linear-gradient(90deg, #000, #2a2a2a 50%, #000); }
.f-uhd .art { inset: 9% 3.2% 3.2% 3.2%; }
.f-dvd { aspect-ratio: 135/190; border-radius: 4px; background: #0b0b0c; }
.f-dvd .art { inset: 2.6% 3.6%; }
.f-steelbook { aspect-ratio: 135/171; border-radius: 8px; background: linear-gradient(135deg, #e9edf1, #8c949d 35%, #f4f6f8 55%, #7b838c); }
.f-steelbook .art { inset: 3%; border-radius: 5px; }
.f-vhs { aspect-ratio: 105/187; border-radius: 2px; background: #eae6dc; }
.f-vhs .art { inset: 3% 4%; }
.f-digital { aspect-ratio: 2/3; border-radius: 6px; background: transparent; }
.f-digital .art { inset: 0; border-radius: 6px; }
.f-hardcover { aspect-ratio: 2/3; border-radius: 2px 5px 5px 2px; background: #222; }
.f-hardcover .art { inset: 0; border-radius: 2px 4px 4px 2px; }
.f-hardcover .art::after, .f-paperback .art::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.42) 0, rgba(255,255,255,.22) 2.6%, rgba(0,0,0,.22) 4.6%, rgba(0,0,0,0) 9%, rgba(0,0,0,0) 92%, rgba(0,0,0,.18) 100%); }
.f-hardcover::before { content: ""; position: absolute; top: 2%; bottom: 2%; right: -4px; width: 4px; border-radius: 0 2px 2px 0; background: repeating-linear-gradient(90deg, #f3eee2 0 1px, #d7d0c0 1px 2px); }
.f-paperback { aspect-ratio: 0.65; border-radius: 1px 3px 3px 1px; background: #222; }
.f-paperback .art { inset: 0; border-radius: inherit; }
.f-paperback .art::after { background: linear-gradient(90deg, rgba(0,0,0,.3) 0, rgba(255,255,255,.18) 1.8%, rgba(0,0,0,0) 6%); }
.f-ebook { aspect-ratio: 0.7; border-radius: 9%/6%; background: linear-gradient(#2b2f36, #15181d); }
.f-ebook .art { inset: 6% 7% 13% 7%; border-radius: 2px; }
.f-ebook::before { content: ""; position: absolute; left: 50%; bottom: 4.5%; width: 16%; height: 3%; transform: translateX(-50%); border-radius: 99px; background: rgba(255,255,255,.14); }
.f-audiobook { aspect-ratio: 1; border-radius: 6px; background: transparent; }
.f-audiobook .art { inset: 0; border-radius: 6px; }
.case .tag { position: absolute; right: 6%; bottom: 5%; background: rgba(0,0,0,.66); color: #fff; font-family: var(--font-mono); font-size: 9cqw; padding: 1px 5px; border-radius: 3px; letter-spacing: .04em; z-index: 1; }
.big .case { max-width: 220px; margin: 0 auto; }
.big .case .tag { font-size: 4.5cqw; }

/* Generated covers */
.gen { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 10% 9%; color: var(--gfg); background: var(--gbg); }
.gen .gt { font-family: var(--font-display); font-weight: 800; text-transform: uppercase; line-height: .92; font-size: 15cqw; overflow-wrap: anywhere; text-wrap: balance; }
.gen .gc { font-family: var(--font-body); font-size: 7.5cqw; opacity: .85; letter-spacing: .04em; }
.gen.book { justify-content: center; text-align: center; gap: 10%; padding-left: 14%; }
.gen.book .gt { font-size: 13cqw; }
.gen.book .rule { height: 1px; background: currentColor; opacity: .5; margin: 0 20%; }
.gen.movie::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 70% at 70% 15%, rgba(255,255,255,.18), transparent 60%); }
.gen > * { position: relative; }

/* Loans */
.ribbon { position: absolute; left: -4px; top: 16%; z-index: 2; background: var(--loan); color: var(--loan-ink); font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px 2px 7px; border-radius: 0 3px 3px 0; box-shadow: 0 2px 6px rgba(0,0,0,.3); max-width: calc(100% + 4px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ribbon.late { background: var(--danger); color: #fff; }

/* Empty state */
.empty { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.empty h2 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 800; font-size: 34px; text-transform: uppercase; line-height: 1; }
.empty p { margin: 0 0 14px; color: var(--muted); max-width: 46ch; }
.empty .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.empty .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ex-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 14px; }
@media (max-width: 720px) { .empty { grid-template-columns: 1fr; padding: 20px; } }

/* Dialogs */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--fg); border-radius: 16px; width: min(780px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
dialog::backdrop { background: var(--scrim); }
.dlg { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; padding: 24px; }
@media (max-width: 620px) { .dlg { grid-template-columns: 1fr; padding: 18px; } .dlg .preview { max-width: 180px; margin: 0 auto; width: 100%; } }
.dlg h2, .pdlg h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1; text-transform: uppercase; text-wrap: balance; }
.pdlg { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 620px) { .pdlg { padding: 18px; } }
.dhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; align-content: start; min-width: 0; }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .lbl { font-size: 11.5px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
.field textarea { resize: vertical; min-height: 64px; }
.hint { font-size: 12px; color: var(--muted); }
.drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 10px; text-align: center; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--accent); }
.stars { display: inline-flex; gap: 2px; }
.stars button { border: 0; background: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 2px; color: var(--line); }
.stars button.on { color: #e0a526; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.actions .grow { flex: 1; }
.status { font-size: 13px; color: var(--muted); }
.status.err { color: var(--danger); }
.preview { display: flex; flex-direction: column; gap: 10px; }
.lookup { display: flex; flex-direction: column; gap: 6px; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.result { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.result:hover { border-color: var(--accent); }
.result img, .result .noimg { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 4px; background: var(--track); display: block; }
.result .rt { font-size: 12px; font-weight: 600; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result .ry { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }

.detail dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 14px 0; }
.detail dt { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 3px; }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.detail .syn { max-width: 60ch; margin: 0 0 12px; }
.kicker { font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.flink { border: 0; background: none; padding: 0; color: var(--fg); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; font: inherit; }
.flink:hover { text-decoration-color: var(--accent); color: var(--accent); }
.lend { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.lend .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.lend .row .field { flex: 1 1 140px; }
.lend .out { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.late-txt { color: var(--danger); }
.hist { color: var(--muted); font-size: 13px; margin: 0; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.plist .pn { font-weight: 600; }
.plist .pd { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.plist .loans { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; background: var(--bg); cursor: pointer; }
.chip.late { border-color: var(--danger); color: var(--danger); }
.progress { height: 6px; background: var(--track); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* Stats */
.stats { display: flex; flex-direction: column; gap: 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .tv { font-family: var(--font-display); font-weight: 800; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .tl { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tile .ts { font-size: 12.5px; color: var(--muted); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 400px) { .panels { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel .sub { font-size: 12.5px; color: var(--muted); margin-top: -8px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.bars { display: flex; flex-direction: column; gap: 3px; }
.brow { display: grid; grid-template-columns: minmax(80px, 38%) minmax(0, 1fr) 3.2em; gap: 10px; align-items: center; border: 0; background: none; padding: 3px 4px; margin: 0 -4px; border-radius: 6px; text-align: left; cursor: pointer; font-size: 13.5px; }
.brow:hover { background: var(--bg); }
.brow.static { cursor: default; }
.brow.static:hover { background: none; }
.brow .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .bt { height: 12px; display: flex; gap: 2px; }
.brow .bt i { display: block; height: 100%; min-width: 2px; }
.brow .bt i:last-child { border-radius: 0 4px 4px 0; }
.brow .bv { text-align: right; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.col { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; height: 100%; justify-content: flex-start; cursor: pointer; min-width: 0; border: 0; background: none; padding: 0; }
.col i { display: block; width: 100%; }
.col i:last-child { border-radius: 4px 4px 0 0; }
.col:hover i { filter: brightness(1.15); }
.col-labels { display: flex; gap: 4px; margin-top: 6px; }
.col-labels span { flex: 1; text-align: center; font-family: var(--font-mono); font-size: 11px; color: var(--muted); min-width: 0; overflow: hidden; white-space: nowrap; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 14px; }
.facts dt { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
details.table summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
details.table .tw { overflow-x: auto; }
details.table table { border-collapse: collapse; font-size: 13px; margin-top: 8px; font-variant-numeric: tabular-nums; }
details.table th, details.table td { padding: 3px 12px 3px 0; text-align: left; border-bottom: 1px solid var(--line); }
.foot { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
#tip { position: fixed; z-index: 100; pointer-events: none; background: var(--fg); color: var(--bg); font-size: 12.5px; padding: 6px 9px; border-radius: 6px; max-width: 260px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.detail dd .names { display: inline; line-height: 1.6; }
.detail dd .more { margin-left: 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 1px 10px; font-size: 13px; cursor: pointer; }
.pill:hover { border-color: var(--accent); color: var(--accent); }
.share { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.linkrow { display: flex; gap: 8px; align-items: center; min-width: 0; }
.linkrow code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.share.off .field, .share.off .linkrow { opacity: .5; }

/* ---------- Styles (skins). Each sets its own complete palette and wall; Gallery (no data-skin) follows light/dark. ---------- */

/* Walnut study: dark wood paneling, a warm lamp glow, brass accents */
:root[data-skin="walnut"] {
  --bg: #241911; --surface: #2e2219; --fg: #f2e7d9; --muted: #c2ad95; --line: #47372b;
  --accent: #e0ae4f; --accent-ink: #241911; --track: #3a2c21; --scrim: rgba(10, 6, 3, .72);
  --plank-top: #8a5f3c; --plank-face: #4f321e; --plank-shadow: rgba(0, 0, 0, .6);
  --c-movie: #5c84ee; --c-book: #a8771a; --c-tv: #2e9a7a; --danger: #ff8a7a;
  --wall:
    radial-gradient(70% 45% at 50% 0%, rgba(255, 196, 120, .16), transparent 70%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .28) 0 2px, rgba(255, 220, 180, .03) 2px 4px, transparent 4px 220px),
    repeating-linear-gradient(90deg, rgba(120, 72, 36, .10) 0 3px, transparent 3px 9px, rgba(0, 0, 0, .06) 9px 11px, transparent 11px 23px),
    linear-gradient(#2b1d14, #1d140d);
  color-scheme: dark;
}
/* Video store: a pegboard wall and metal shelving */
:root[data-skin="video"] {
  --bg: #c9a676; --surface: #ffffff; --fg: #18181d; --muted: #3f3222; --line: #b08d5f;
  --accent: #17337d; --accent-ink: #ffffff; --track: #ece4d6; --scrim: rgba(20, 15, 8, .55);
  --plank-top: #e3e7ec; --plank-face: #8f98a3; --plank-shadow: rgba(40, 30, 15, .4);
  --c-movie: #2c59d4; --c-book: #a86e0e; --c-tv: #1d8a6b; --danger: #a3141f;
  --wall:
    radial-gradient(circle at 11px 11px, rgba(60, 38, 14, .42) 0 2.2px, rgba(255, 240, 210, .22) 2.4px 2.9px, transparent 3.1px),
    linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(0, 0, 0, .08));
  --wall-size: 22px 22px, 100% 100%;  /* pegboard holes repeat every 22px */
  color-scheme: light;
}
/* Home theater: a velvet curtain above, a spotlight, black lacquer shelves */
:root[data-skin="theater"] {
  --bg: #150b0e; --surface: #22131a; --fg: #f5eaec; --muted: #c9a9b1; --line: #3f232b;
  --accent: #e9b54e; --accent-ink: #150b0e; --track: #331c24; --scrim: rgba(6, 2, 3, .75);
  --plank-top: #3a3a3d; --plank-face: #0b0b0c; --plank-shadow: rgba(0, 0, 0, .7);
  --c-movie: #5c84ee; --c-book: #a8771a; --c-tv: #2e9a7a; --danger: #ff8a96;
  --wall:
    radial-gradient(60% 40% at 50% 0%, rgba(255, 210, 160, .14), transparent 70%),
    linear-gradient(180deg, transparent 0 230px, #150b0e 330px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .45) 0, rgba(255, 255, 255, .05) 34px, rgba(0, 0, 0, .45) 68px),
    linear-gradient(#5a0f1d, #2a0810 330px, #150b0e 331px);
  color-scheme: dark;
}
/* Mid-century: a sage wall with teak shelves */
:root[data-skin="sage"] {
  --bg: #c3d0bd; --surface: #f7f9f5; --fg: #17231b; --muted: #3f4d43; --line: #a9b8a3;
  --accent: #275c43; --accent-ink: #ffffff; --track: #e3e9df; --scrim: rgba(15, 25, 18, .5);
  --plank-top: #c4834a; --plank-face: #8a5226; --plank-shadow: rgba(40, 30, 15, .35);
  --c-movie: #2c59d4; --c-book: #a86e0e; --c-tv: #1d8a6b; --danger: #a3141f;
  --wall:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .13) 0 64px, transparent 64px 128px),
    radial-gradient(80% 60% at 50% 0%, rgba(255, 255, 255, .25), transparent 70%);
  color-scheme: light;
}
/* Style picker */
.skins { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.skin { border: 2px solid var(--line); border-radius: 12px; padding: 0; overflow: hidden; cursor: pointer; background: var(--surface); text-align: left; display: flex; flex-direction: column; }
.skin[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.skin .sw { height: 92px; position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 6px; padding-bottom: 8px; }
.skin .sw i { display: block; width: 22px; border-radius: 2px; box-shadow: 0 4px 8px -3px rgba(0,0,0,.5); }
.skin .sw b { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; }
.skin .nm { padding: 8px 10px 10px; font-weight: 600; font-size: 14px; }
.skin .ds { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
/* Video store: small text sits on white shelf labels so the pegboard holes don't run through it */
:root[data-skin="video"] .filters { background: var(--surface); border-radius: 10px; padding: 12px; }
:root[data-skin="video"] .slot .meta { background: var(--surface); border-radius: 4px; padding: 6px 8px; margin-top: 8px; height: calc(12px + 2 * 13.5px * 1.25 + 2px + 11.5px * 1.5); box-shadow: 0 2px 4px rgba(40, 30, 15, .25); }
:root[data-skin="video"] .brand p, :root[data-skin="video"] .result-count { background: var(--surface); border-radius: 4px; padding: 2px 8px; display: inline-block; }
:root[data-skin="video"] .minstars button:not(.on), :root[data-skin="video"] .stars button:not(.on) { color: #d8d4cc; }

/* Hide filters (desktop): the shelf takes the full width */
.layout.nofilters { grid-template-columns: minmax(0, 1fr); }
.layout.nofilters .filters { display: none; }
@media (max-width: 880px) { .hide-filters { display: none; } }
/* Collections bar */
.colls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.colls .lbl { margin-right: 4px; }
.coll { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 8px; padding: 4px 12px; font-size: 13.5px; cursor: pointer; }
.coll[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.coll .k { color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; margin-left: 6px; }
.coll[aria-pressed="true"] .k { color: inherit; opacity: .7; }
/* Wishlist titles look provisional; watched/read titles get a small check */
.slot.wish .case { opacity: .78; }
.slot.wish .stand::before { content: "Wishlist"; position: absolute; z-index: 3; top: 6px; right: 6px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; background: var(--surface); color: var(--fg); border: 1px dashed var(--muted); border-radius: 4px; padding: 1px 6px; }
.seenmark { position: absolute; z-index: 2; right: 5%; top: 12%; width: 22px; height: 22px; border-radius: 50%; background: #1d8a6b; color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.big .seenmark { width: 30px; height: 30px; font-size: 17px; }
.overdue { border-color: var(--danger); color: var(--fg); }
.overdue strong { color: var(--danger); }
.scanner { width: 100%; min-height: 200px; background: #000; border-radius: 10px; overflow: hidden; }
.scanner video { width: 100% !important; display: block; }
/* Space between filter groups, so each label clearly starts a new group */
#facets { display: flex; flex-direction: column; gap: 26px; }

/* Select mode: a check circle on each title, and a bar of actions along the bottom */
.selecting .slot .stand::after { pointer-events: none; }
.selmark { position: absolute; z-index: 4; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.35); box-shadow: 0 1px 4px rgba(0,0,0,.4); display: grid; place-items: center; color: transparent; font-weight: 700; font-size: 13px; }
.slot.selected .selmark { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.selecting .slot.selected .case { outline: 3px solid var(--accent); outline-offset: 3px; }
.selecting .slot:hover .case, .selecting .slot:focus-visible .case { transform: none; }
.selbar { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: min(760px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: 0 16px 40px -10px rgba(0,0,0,.45); }
.selbar .grow { flex: 1; }
body.has-selbar { padding-bottom: 110px; }

/* Account menu */
.menu-wrap { position: relative; }
#accountBtn::after { content: " ▾"; font-size: 11px; opacity: .7; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.45); display: flex; flex-direction: column; }
.menu .mi { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.menu .mi:hover, .menu .mi:focus-visible { background: var(--bg); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; width: auto; }

/* Profile pictures */
.avatar { width: 24px; height: 24px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; overflow: hidden; color: #fff; font-size: 11px; font-weight: 600; background: var(--muted); vertical-align: middle; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 72px; height: 72px; font-size: 28px; }
#accountBtn { display: inline-flex; align-items: center; gap: 8px; padding-left: 6px; }
#accountBtn:not(:has(.avatar)) { padding-left: 16px; }
.avatar-row { display: flex; gap: 16px; align-items: center; }

/* Review scores */
.scores { display: flex; gap: 4px; flex-wrap: nowrap; margin-top: 4px; overflow: hidden; }
.score { font-family: var(--font-mono); font-size: 10.5px; line-height: 1; padding: 3px 5px; border-radius: 4px; background: var(--track); color: var(--fg); white-space: nowrap; font-variant-numeric: tabular-nums; }
.score b { font-weight: 500; color: var(--muted); margin-right: 3px; }
.shelf.with-scores .slot .meta { height: calc(10px + 2 * 13.5px * 1.25 + 2px + 11.5px * 1.5 + 21px); }
:root[data-skin="video"] .shelf.with-scores .slot .meta { height: calc(12px + 2 * 13.5px * 1.25 + 2px + 11.5px * 1.5 + 21px); }
.detail .scores { margin: 0; flex-wrap: wrap; }
.detail .score { font-size: 12.5px; padding: 4px 8px; }
.scorepick { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 13.5px; }
.scorepick select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 8px; }
