/* Dark, poster-first design. */
:root {
  --bg: #14181c;
  --surface: #1c2228;
  --surface-2: #2a323b;
  --line: #2f3843;
  --text: #e9eef2;
  --text-2: #b8c4cf;
  --muted: #8494a3;
  --accent: #2bb3a3;
  --accent-text: #06201d;
  --accent-soft: rgb(43 179 163 / .16);
  --star: #f5b42a;
  --wish: #40bcf4;
  --lent: #ff8a4c;
  --warn-soft: #3a2f14;
  --warn-text: #f3c56b;
  --ok-soft: #143329;
  --ok-text: #8fd9b6;
  --danger: #ff6b5e;
  --radius: 12px;
  --poster-radius: 6px;
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Top bar and sections ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: baseline; gap: 10px; }
.brand { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.count { color: var(--muted); font-size: 13px; flex: 1; }

.sections {
  display: flex; gap: 22px; overflow-x: auto; margin: 6px -16px 0; padding: 0 16px;
  scrollbar-width: none;
}
.sections::-webkit-scrollbar { display: none; }
.sections button {
  flex: none; background: none; border: 0; padding: 10px 0 11px; color: var(--muted);
  font-size: 14px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  border-bottom: 2px solid transparent;
}
.sections button.on { color: var(--text); border-bottom-color: var(--accent); }
.sections .n { font-weight: 400; color: var(--muted); margin-left: 4px; font-size: 12px; }

/* ---------- Library ---------- */

.page { display: none; padding: 12px 16px 0; }
.page.active { display: block; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: 10px; padding: 0 12px; color: var(--muted);
}
.search input { flex: 1; border: 0; background: none; padding: 10px 0; outline: none; min-width: 0; color: var(--text); }

.subchips { display: flex; gap: 6px; margin-top: 10px; }
.subchip {
  border: 1px solid var(--line); background: none; border-radius: 999px; padding: 5px 12px;
  font-size: 13px; color: var(--text-2);
}
.subchip.on { background: var(--surface-2); color: var(--text); border-color: var(--surface-2); }

.toolbar { display: flex; align-items: center; gap: 6px; margin: 10px 0 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  font-size: 13px; color: var(--text-2); text-decoration: none; white-space: nowrap;
}
.pill.icon { width: 34px; padding: 0; justify-content: center; font-size: 15px; }
.pill.ghost { background: none; }
.pill svg { width: 16px; height: 16px; flex: none; }
.pill.select { padding-right: 4px; }
.pill.select span { color: var(--muted); }
.pill.select select { border: 0; background: none; color: var(--text); outline: none; max-width: 10em; padding: 0 2px; font-size: 13px; }
.pill.select select option { background: var(--surface); }
.badge {
  background: var(--accent); color: var(--accent-text); border-radius: 999px; font-weight: 700;
  font-size: 11px; min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px;
}

.group-head {
  margin: 20px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.group-head span { font-weight: 400; margin-left: 4px; }

/* Poster (shared by grid, list, picker, detail) */
.poster {
  position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--poster-radius);
  aspect-ratio: 2 / 3; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .08);
}
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster .ph { font-size: 28px; opacity: .45; }
.poster.square { aspect-ratio: 1; }
/* Release cover art keeps its own shape (cases, slipcovers and packshots aren't 2:3). */
.poster.natural { aspect-ratio: auto; min-height: 60px; background: none; box-shadow: none; }
.poster.natural img { position: static; display: block; height: auto; border-radius: var(--poster-radius); }
.poster.natural .ph { position: absolute; }

.grid .group-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 14px 10px; }
.tile { background: none; border: 0; padding: 0; text-align: left; min-width: 0; display: flex; flex-direction: column; color: inherit; }
.tile:active .poster { outline: 2px solid var(--accent); }
.tile-title { font-size: 12.5px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.tile-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Badges over posters */
.marks { position: absolute; left: 5px; right: 5px; bottom: 5px; display: flex; gap: 4px; justify-content: flex-end; z-index: 1; }
.mark {
  height: 20px; min-width: 20px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center;
  background: rgb(10 12 14 / .78); font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
}
.mark svg { width: 13px; height: 13px; }
.mark.done { color: var(--accent); }
.mark.wishlist { color: var(--wish); }
.mark.preorder { color: var(--star); }
.mark.loaned { color: var(--lent); }

.list .group-items { display: flex; flex-direction: column; }
.row {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 0; color: inherit;
}
.row .poster { width: 52px; flex: none; }
.row .marks { display: none; } /* list rows already show status as text */
.meta { min-width: 0; flex: 1; }
.row-title { font-weight: 650; overflow-wrap: anywhere; }
.row-title .yr { color: var(--muted); font-weight: 400; margin-left: 4px; }
.row-sub { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.row-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip-s { font-size: 11.5px; background: var(--surface-2); color: var(--text-2); border-radius: 5px; padding: 2px 7px; }
.chip-s.wishlist { color: var(--wish); }
.chip-s.preorder { color: var(--star); }
.chip-s.loaned { color: var(--lent); }
.chip-s.done { color: var(--accent); }
.stars { color: var(--star); letter-spacing: 1px; white-space: nowrap; font-size: 13px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 8px 0 6px; font-size: 19px; }
.empty p { margin: 0 auto 18px; max-width: 32ch; }
.empty-icon { font-size: 44px; }

/* ---------- Panels, stats ---------- */

.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.panel h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.panel p { margin: 0 0 12px; }
.btn-row { display: flex; flex-direction: column; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 12px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 14px; }
.kpi b { display: block; font-size: 26px; letter-spacing: -.02em; }
.kpi span { color: var(--muted); font-size: 12.5px; }
.bar { display: grid; grid-template-columns: minmax(0, 9em) 1fr 2.5em; gap: 10px; align-items: center; padding: 4px 0; font-size: 13.5px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */

.btn {
  border: 0; background: var(--accent); color: var(--accent-text); border-radius: 10px;
  padding: 12px 18px; font-weight: 700; font-size: 15px;
}
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); color: #1a0705; }
.btn.danger.ghost { background: none; color: var(--danger); border: 1px solid currentColor; }
.link { background: none; border: 0; color: var(--accent); padding: 8px 4px; font-size: 15px; text-decoration: none; }
.link.strong { font-weight: 700; }
.link.center { display: block; margin: 0 auto; }

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  background: none; border: 0; color: var(--muted); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--text); }
.tabbar .fab {
  width: 56px; height: 56px; border-radius: 50%; justify-self: center; margin-top: -24px;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 20px rgb(0 0 0 / .45);
  justify-content: center;
}
.tabbar .fab svg { width: 27px; height: 27px; }

/* ---------- Sheets ---------- */

dialog.sheet {
  border: 0; padding: 0; margin: 0; background: var(--bg); color: var(--text);
  max-width: none; max-height: none;
}
dialog.sheet::backdrop { background: rgb(0 0 0 / .6); }
dialog.sheet.full { width: 100vw; height: 100dvh; }
dialog.sheet.full[open] { display: flex; flex-direction: column; }
#item-form { display: flex; flex-direction: column; height: 100%; }
dialog.sheet.bottom {
  position: fixed; top: auto; bottom: 0; width: 100vw; max-height: 80dvh; border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface);
}
dialog.sheet.bottom[open] { display: flex; flex-direction: column; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30%); opacity: 0; } }

@media (min-width: 700px) {
  dialog.sheet.full { width: min(640px, 100vw); height: min(920px, 100dvh); margin: auto; border-radius: 18px; overflow: hidden; }
  dialog.sheet.bottom { width: min(640px, 100vw); left: 0; right: 0; margin: 0 auto; }
}

.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.sheet-head h2 { margin: 0; font-size: 16px; }
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; overscroll-behavior: contain; }
dialog.bottom .sheet-head { background: none; padding-top: 8px; }

/* ---------- Item detail ---------- */

.detail-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; position: relative; }
.detail-hero-wrap { position: relative; overflow: hidden; }
.detail-hero {
  position: relative; height: 230px; background: var(--surface) center / cover no-repeat;
}
.detail-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgb(20 24 28 / .1) 0%, rgb(20 24 28 / .55) 55%, var(--bg) 100%);
}
/* No background chosen: just enough room for the back and Edit buttons above the cover. */
.detail-hero.plain { height: calc(env(safe-area-inset-top) + 190px); background: var(--bg); }
.detail-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 14px;
}
.round-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgb(10 12 14 / .6); color: #fff;
  display: grid; place-items: center; font-size: 16px; backdrop-filter: blur(6px);
}
.detail-top-right { display: flex; gap: 8px; }
.round-btn.wide { width: auto; padding: 0 16px; border-radius: 999px; font-size: 14px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.detail-body { position: relative; z-index: 1; padding: 0 16px 32px; margin-top: -120px; }
.detail-head { display: flex; gap: 14px; align-items: flex-end; }
.detail-head .poster { width: 116px; flex: none; box-shadow: 0 8px 24px rgb(0 0 0 / .5), inset 0 0 0 1px rgb(255 255 255 / .1); border: 0; padding: 0; }
.detail-head .poster .change {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px; font-size: 10.5px; text-align: center;
  background: rgb(10 12 14 / .7); color: var(--text-2); z-index: 1;
}
.detail-title { min-width: 0; padding-bottom: 4px; }
.detail-title h2 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.detail-title .yr { color: var(--text-2); font-weight: 400; font-size: 17px; }
.detail-title .by { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.detail-title .kind { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-top: 6px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 6px; }
.action {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; color: var(--text-2);
}
.action svg { width: 20px; height: 20px; }
.action.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.action select { background: none; border: 0; color: inherit; font-weight: 600; outline: none; text-align: center; }
.action select option { background: var(--surface); }

.dsec { margin-top: 22px; }
.dsec h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; white-space: pre-line; }
.cover-label { margin: 14px 0 6px; }
.cover-variants { display: flex; gap: 10px; overflow-x: auto; }
.cover-variants button { flex: 0 0 78px; background: none; border: 0; padding: 0; color: var(--muted); font-size: 11.5px; text-align: center; }
.cover-variants button.on { color: var(--accent); }
.cover-variants button.on .poster img { outline: 2px solid var(--accent); outline-offset: 2px; }
.copies { display: flex; flex-direction: column; gap: 6px; }
.copy {
  display: flex; gap: 10px; align-items: center; text-align: left; width: 100%; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px;
}
.copy .poster { width: 34px; flex: none; }
.copy .meta { display: flex; flex-direction: column; }
.copy .row-title { font-size: 13.5px; font-weight: 600; }
.link.inline { padding: 0; font-size: inherit; text-decoration: underline; }
.share-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.share-head .poster { width: 110px; flex: none; }
.share-head h3 { margin: 0 0 4px; font-size: 19px; }
.share-head .row-sub { margin-top: 3px; }
.extras { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 14px; }
.extras li { margin: 3px 0; }
.notes { white-space: pre-wrap; color: var(--text-2); font-size: 14px; margin: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.links-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Poster picker ---------- */

.chip-wrap.picker-langs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.picker-langs .chip { flex: none; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.picker-grid button { background: none; border: 0; padding: 0; position: relative; }
.picker-grid button.current .poster { outline: 3px solid var(--accent); outline-offset: 2px; }
.picker-sort { margin-bottom: 10px; }
.picker-grid.stills { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.poster.wide { aspect-ratio: 16 / 9; }
.picker-grid .default { position: absolute; top: 4px; right: 4px; z-index: 1; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; background: var(--accent); color: var(--accent-text); padding: 1px 5px; border-radius: 4px; }
.picker-grid .votes { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; text-align: left; }
.picker-grid .lang { position: absolute; top: 4px; left: 4px; z-index: 1; font-size: 10px; font-weight: 700; text-transform: uppercase; background: rgb(10 12 14 / .75); padding: 1px 5px; border-radius: 4px; color: var(--text-2); }

/* ---------- Item form ---------- */

.form-group { margin-top: 18px; }
.form-group h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; flex: 1; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field small { font-weight: 400; opacity: .8; }
.field input:not([type=checkbox]), .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 10px 12px; outline: none; min-height: 44px; color: var(--text);
}
.field select option { background: var(--surface); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.8); }
.row2 { display: flex; gap: 10px; }
.row2.align-end { align-items: flex-end; }
.row2 .narrow { flex: 0 0 7.5em; }
.check { flex-direction: row; align-items: center; gap: 8px; min-height: 44px; flex: 0 0 auto; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.check span { font-size: 14px !important; color: var(--text) !important; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 8px 4px; border-radius: 8px; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--line); white-space: nowrap; color: var(--text-2);
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.cover-row { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.cover-preview { width: 86px; flex: none; }
.cover-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.notice { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: var(--surface); font-size: 14px; }
.notice.warn { background: var(--warn-soft); color: var(--warn-text); }
.notice.ok { background: var(--ok-soft); color: var(--ok-text); }
.notice .link { padding: 0 4px; font-size: 14px; color: inherit; text-decoration: underline; }
.alt-results { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 12px; }
.title-search { margin: -4px 0 14px; }
.title-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 340px; overflow-y: auto; }
.title-results p { margin: 4px 2px; }
.title-hit {
  display: flex; gap: 10px; align-items: center; text-align: left; width: 100%; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px;
}
.title-hit .poster { width: 36px; flex: none; }
.title-hit .ph { font-size: 15px; }
.title-hit .meta { display: flex; flex-direction: column; }
.release-box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 14px; }
.release-box > span { display: block; margin-bottom: 8px; }
.release-links { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.inline-field { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.inline-field input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 9px 10px; color: var(--text); outline: none; min-height: 40px;
}
.inline-field input:focus { border-color: var(--accent); }
.release-status { margin-top: 10px; font-size: 13.5px; color: var(--text-2); }
.release-status .notice { margin: 8px 0 0; }
.form-actions { display: flex; flex-direction: column; gap: 10px; margin: 22px 0 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--text-2);
}
.chip .n { color: var(--muted); font-size: 11.5px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.on .n { color: inherit; opacity: .75; }

.spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Music pressings ---------- */

.pressing-picker { margin-bottom: 8px; }
.pressing-picker p { margin: 0 0 8px; }
.pressing-picker .copies { max-height: 320px; overflow-y: auto; }
.pressing-picker .copy .poster { width: 42px; }
.tracks { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.tracks li { display: grid; grid-template-columns: 2.6em 1fr auto; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--text-2); }
.tracks .pos, .tracks .dur { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Find a film and its release ---------- */

.find-search { margin-bottom: 10px; }
.find-kinds { margin: 0 0 12px; flex-wrap: wrap; }
.find-group { margin-bottom: 16px; }
.find-group h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.find-group .title-hit, .find-list .title-hit { margin-bottom: 6px; }
.find-group .link { font-size: 13px; padding: 2px 0; }
.title-hit.loading { opacity: .5; pointer-events: none; }
.title-results.find-list { max-height: none; overflow: visible; }
#find-filter { flex: 1; border: 0; background: none; padding: 10px 0; outline: none; min-width: 0; color: var(--text); }
.title-hit .poster.square { aspect-ratio: 1; }
.find-films { max-height: none; }
.find-film { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.find-film .poster { width: 44px; flex: none; }
.find-seg { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
.release-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); align-items: end; }
.release-grid button.loading { opacity: .5; pointer-events: none; }
.release-grid .votes { text-align: center; }
.find-preview { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.find-preview .poster { width: 130px; flex: none; }
.find-preview h3 { margin: 0 0 6px; font-size: 19px; }
.find-preview .row-sub { margin-top: 3px; }
.find-facts { margin-top: 16px; }

/* ---------- Add sheet ---------- */

.add-options { display: flex; flex-direction: column; gap: 8px; padding-bottom: 20px; }
.add-option {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; width: 100%; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 0;
}
button.add-option:active { border-color: var(--accent); }
.add-option > svg { width: 24px; height: 24px; flex: none; color: var(--accent); margin-top: 1px; }
.add-option > span { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.add-option b { font-size: 15px; }
.add-option small { color: var(--muted); font-size: 12.5px; }
.add-option .inline-field input { background: var(--surface); }

/* ---------- Filters ---------- */

.facet h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 0 8px; }
.facet { margin-bottom: 16px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Scanner ---------- */

dialog.scanner { background: #000; color: #fff; }
.scanner-view { position: relative; flex: 1; overflow: hidden; }
.scanner-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; left: 50%; top: 45%; width: min(78vw, 360px); aspect-ratio: 2 / 1;
  transform: translate(-50%, -50%); border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / .5); border: 2px solid rgb(255 255 255 / .9);
}
.scan-line { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #ff4d4d; box-shadow: 0 0 8px #ff4d4d; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.scanner-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 14px;
}
.scanner-hint {
  position: absolute; left: 16px; right: 16px; top: calc(45% + min(39vw, 180px) / 2 + 22px);
  text-align: center; margin: 0; text-shadow: 0 1px 4px #000;
}
.scanner-manual { display: flex; gap: 8px; padding: 14px 16px 6px; background: #111; }
.scanner-manual input {
  flex: 1; min-width: 0; border: 1px solid #333; background: #1d1d1d; color: #fff; border-radius: 10px; padding: 12px; font-size: 16px;
}
dialog.scanner .link.center { color: #9ee6dc; background: #111; width: 100%; padding: 10px 0 calc(env(safe-area-inset-bottom) + 14px); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / .4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.danger-zone h2 { color: var(--danger); }
.danger-text { color: var(--danger); }
.panel .inline-field input { background: var(--bg); }

/* ---------- Shelf view: spines on shelves ---------- */

.page.has-rail { padding-right: 28px; } /* room for the A–Z rail */
.view-pick { align-self: center; height: 30px; }
/* Every spine sits in a cell of the same height, so each row of the wrap ends on a plank. */
.shelf {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 2px; margin-bottom: 8px;
  background: repeating-linear-gradient(to bottom, transparent 0 178px, #3d342a 178px 181px, #261f18 181px 186px, transparent 186px 200px);
}
.spine {
  flex: none; height: 186px; padding: 0 0 8px; border: 0; background: none; display: flex; align-items: flex-end; color: inherit;
}
.spine:focus-visible { outline: none; }
.spine:focus-visible .sp { outline: 2px solid var(--accent); outline-offset: 1px; }
.sp {
  position: relative; width: var(--w); height: var(--h); border-radius: 2px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; color: var(--ink, #f2f2f2);
  background-color: var(--c); background-size: cover; background-position: center;
  box-shadow: inset 0 9px 0 var(--band, transparent), inset -2px 0 0 rgb(0 0 0 / .18);
  transition: transform .18s ease-out, opacity .18s;
}
.sp.photo { background-size: 100% 100%; box-shadow: none; }
.sp.art::before { content: ''; position: absolute; inset: 9px 0 0; background: linear-gradient(rgb(0 0 0 / .4), rgb(0 0 0 / .58)); }
.sp-t, .sp-s {
  position: relative; writing-mode: vertical-rl; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-t { font-size: 9px; font-weight: 650; letter-spacing: .02em; padding-top: 12px; max-height: calc(100% - 8px); }
.sp-s { font-size: 7px; font-weight: 500; opacity: .8; margin-top: auto; padding: 4px 0 6px; max-height: 38%; }
.sp-t:has(+ .sp-s) { max-height: 64%; }
.sp.art .sp-t, .sp.art .sp-s { color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / .7); }
.spine.divider .sp { --w: 22px; --h: 150px; --c: #e9eef2; --ink: #14181c; }
.spine.divider .sp-t { font-size: 12px; font-weight: 800; padding-top: 8px; }
.spine.ghost .sp { opacity: .5; outline: 1px dashed var(--muted); outline-offset: -1px; }
.spine:active .sp { filter: brightness(1.25); }
.has-pulled .spine:not(.pulled) .sp { opacity: .38; }
.spine.pulled .sp {
  transform: translateY(-22px);
  box-shadow: inset 0 9px 0 var(--band, transparent), 0 0 0 2px var(--accent), 0 10px 20px rgb(0 0 0 / .6);
}

/* A–Z rail */
.rail {
  position: fixed; right: 0; z-index: 4; width: 24px; padding: 4px 0;
  top: calc(var(--topbar-h, 110px) + 10px); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  font-size: 9.5px; font-weight: 700; color: var(--text-2); touch-action: none; user-select: none; -webkit-user-select: none;
}
.rail .off { opacity: .28; }
.rail-bubble {
  position: fixed; right: 46px; z-index: 8; width: 84px; height: 84px; margin-top: -42px; pointer-events: none;
  border-radius: 42px 42px 6px 42px; background: var(--accent); color: var(--accent-text);
  display: grid; place-content: center; text-align: center; box-shadow: 0 12px 30px rgb(0 0 0 / .5);
}
.rail-bubble b { font-size: 34px; line-height: 1; }
.rail-bubble span { font-size: 11px; font-weight: 600; margin-top: 3px; }

/* Pull-out card */
.pullout {
  position: fixed; left: 10px; right: 10px; z-index: 7; max-width: 620px; margin: 0 auto;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  display: flex; gap: 12px; padding: 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 16px 40px rgb(0 0 0 / .6);
  animation: up .18s ease-out;
}
.pullout .poster { width: 84px; flex: none; align-self: flex-start; }
.po-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.po-title { font-weight: 700; font-size: 17px; line-height: 1.25; }
.po-title span { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 4px; }
.po-sub { font-size: 13px; color: var(--text-2); }
.po-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.po-actions .btn { padding: 9px 10px; font-size: 13.5px; flex: 1; white-space: nowrap; }

/* Record crate */
.crate { display: flex; flex-direction: column; align-items: center; }
/* The front record shrinks on short screens so the stack, the flip arrows and the tab bar all fit. */
.crate-stack {
  width: min(100%, 330px, max(200px, calc(100dvh - var(--topbar-h, 110px) - var(--tabbar-h) - 400px))); display: flex; flex-direction: column; align-items: center;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.crate-rec {
  position: relative; flex: none; height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 10px; border: 0; border-top: 1px solid rgb(255 255 255 / .2); border-radius: 3px 3px 0 0; overflow: hidden;
  background-color: var(--c); background-size: 100% auto; background-position: top center;
  box-shadow: 0 -2px 6px rgb(0 0 0 / .5); color: #fff; font-size: 10.5px;
}
.crate-rec::before { content: ''; position: absolute; inset: 0; background: rgb(0 0 0 / .5); }
.crate-rec > span { position: relative; }
.cr-t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-f { flex: none; font-size: 9px; font-weight: 700; opacity: .85; }
.crate-front {
  position: relative; width: 100%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; overflow: hidden; color: #fff;
  background: var(--c); box-shadow: 0 -6px 18px rgb(0 0 0 / .55); animation: crate-in .2s ease-out; transition: transform .18s;
}
.crate-front img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.crate-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 14px 12px; text-align: left;
  display: flex; flex-direction: column; background: linear-gradient(transparent, rgb(0 0 0 / .78));
}
.crate-cap b { font-size: 19px; line-height: 1.2; }
.crate-cap span { font-size: 13.5px; opacity: .85; }
.crate-fmt { position: absolute; top: 10px; right: 10px; font-size: 10.5px; font-weight: 700; background: rgb(10 12 14 / .8); border-radius: 4px; padding: 3px 7px; }
.crate-front.pulled { transform: translateY(-10px); box-shadow: 0 0 0 2px var(--accent), 0 14px 30px rgb(0 0 0 / .6); }
@keyframes crate-in { from { transform: translateY(16px); opacity: .5; } }
.crate-sub { margin: 10px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.crate-nav { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; font-size: 12.5px; color: var(--muted); }
.crate-nav .pill { width: 40px; justify-content: center; font-size: 18px; }
.crate-nav .pill:disabled { opacity: .35; }

/* 3D inspect */
dialog.inspect { background: radial-gradient(circle at 50% 36%, #26313b, var(--bg) 62%); }
.inspect-stage {
  flex: 1; min-height: 280px; perspective: 1100px; display: grid; place-items: center; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.case3d { position: relative; transform-style: preserve-3d; }
.case3d.snap { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
.case3d .face { position: absolute; left: 0; top: 0; overflow: hidden; background: var(--c); backface-visibility: hidden; }
.case3d .face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.case3d .f-front, .case3d .f-back { border-radius: 2px; }
.case3d .f-spine { box-shadow: inset 0 9px 0 var(--band, transparent); }
.case3d .f-spine.photo { box-shadow: none; }

/* The lid is the front cover, hinged at the spine; opening swings it round to the left. */
.case3d .lid {
  position: absolute; left: 0; top: 0; transform-style: preserve-3d; transform-origin: left center;
  transform: translateZ(var(--z)); transition: transform .9s cubic-bezier(.3, .7, .2, 1);
}
.case3d .f-inside { transform: rotateY(180deg); background: color-mix(in srgb, var(--c) 45%, #0c0c0c); }
.case3d.open .lid { transform: translateZ(var(--z)) rotateY(-162deg); }
.case3d .f-tray { background: #15191d; box-shadow: inset 0 0 0 4px rgb(255 255 255 / .05); }
.case3d .f-tray.sleeve, .case3d .f-tray.gatefold { background: color-mix(in srgb, var(--c) 45%, #0c0c0c); }

/* Discs: inside the case until they come out. Records slide out of the open side and spin;
   discs in a case lift off the tray. */
.case3d .discs { position: absolute; left: 0; top: 0; transform-style: preserve-3d; pointer-events: none; }
.disc {
  position: absolute; border-radius: 50%; transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(.3, .7, .2, 1);
}
.opens-lid .disc { transform: translateZ(calc(var(--d) / -2 + 2px)); }
.opens-lid.out .disc[data-i="0"] { transform: translateZ(34px) translateX(calc(var(--disc) * .78)); }
.opens-lid.out .disc[data-i="1"] { transform: translateZ(22px) translateX(calc(var(--disc) * .42)); }
.opens-lid.out .disc[data-i="2"] { transform: translateZ(10px) translateX(calc(var(--disc) * .12)); }
.opens-sleeve.out .disc[data-i="0"], .opens-gatefold.out .disc[data-i="0"] { transform: translateX(calc(var(--disc) * .72)) translateZ(1px); }
.opens-sleeve.out .disc[data-i="1"], .opens-gatefold.out .disc[data-i="1"] { transform: translateX(calc(var(--disc) * .36)) translateZ(-1px); transition-delay: .25s; }
.opens-sleeve.out .disc[data-i="2"], .opens-gatefold.out .disc[data-i="2"] { transform: translateX(calc(var(--disc) * .12)) translateZ(-2px); transition-delay: .4s; }
.disc-face { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; }
.case3d.out .disc-face { animation: disc-spin 1.8s linear 1s infinite; } /* 33⅓ rpm */
@keyframes disc-spin { to { transform: rotate(360deg); } }
.disc.vinyl .disc-face {
  background: repeating-radial-gradient(circle, var(--vinyl) 0 1.1px, color-mix(in srgb, var(--vinyl) 78%, #000) 1.1px 2px);
  box-shadow: 0 0 0 1px rgb(0 0 0 / .45);
}
/* The light catching the grooves stays still while the record turns. */
.disc.vinyl::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 20deg, transparent, rgb(255 255 255 / .13) 8%, transparent 18%, transparent 50%, rgb(255 255 255 / .1) 58%, transparent 68%);
}
.disc.optical .disc-face {
  background: radial-gradient(circle, transparent 0 6.5%, rgb(225 230 235 / .75) 7% 15%, transparent 15.5%),
    conic-gradient(#c9ccd1, #eceef0, #b8d4e6, #e6d6f0, #f2ecd0, #cfd3d8, #c9ccd1);
  box-shadow: 0 0 0 1px rgb(0 0 0 / .3);
}
.disc-label {
  position: relative; width: 33%; aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; padding: 12% 8% 0; text-align: center;
  background: var(--c); color: #fff; font-size: 7px; line-height: 1.2;
}
.disc-label b { font-size: 7.5px; }
.disc-label::after { content: ''; position: absolute; left: 50%; top: 50%; width: 7%; aspect-ratio: 1; margin: -3.5% 0 0 -3.5%; border-radius: 50%; background: #0d0f11; }
.disc.optical .disc-label { width: 64%; background: none; color: #23272b; padding-top: 6%; }
.disc.optical .disc-label::after { display: none; }
.disc.card { border-radius: 4px; background: #2b2b2b; color: #fff; font-size: 6px; display: grid; place-items: center; text-align: center; padding: 2px; }
.case3d.opens-lid .disc.card { transform: translateZ(calc(var(--d) / -2 + 2px)); }
.case3d.opens-lid.out .disc.card { transform: translateZ(30px) translateX(60px); }
/* Labels in Find */
.find-label-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 8px 0 0; font-size: 13px; color: var(--text-2); }
.find-label-chip .link { padding: 2px 0; font-size: 13px; }
.release-grid button.label-match .poster { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Prices from label shops */
.offers { display: flex; flex-direction: column; margin-bottom: 6px; }
.offer {
  display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.offer .poster { width: 40px; flex: none; }
.offer .meta { flex: 1; min-width: 0; }
.offer .row-title { font-size: 14px; }
.offer-price { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 13px; white-space: nowrap; }
.offer-price b { font-size: 15px; }
.offer.gone { opacity: .5; }
.sale { color: var(--star); }
.price-line { color: var(--accent); }
/* Album wishlist, watched pages and your shops */
.wish-box, .watch-box {
  display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; padding: 12px;
  background: var(--surface); border-radius: var(--radius);
}
.btn-row-inline { display: flex; gap: 8px; }
.btn-row-inline .btn { flex: 1; }
.watch-link { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: 13.5px; min-width: 0; }
.watch-link a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.release-line { margin: 0 0 10px; }
.local { color: var(--accent); }
.shop-prefs h3 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.shop-pref { display: grid; grid-template-columns: 1fr auto 5.5em; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.shop-pref .check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.shop-pref .postage { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--text); }
.shop-pref .postage:disabled { opacity: .4; }
.price-history { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.spark { width: 60px; height: 16px; flex: none; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.notice.deal { display: block; margin: 0 0 10px; color: var(--ok-text); background: var(--ok-soft); text-decoration: none; }
.mark.deal { color: #14181c; background: var(--accent); }
#wishlist-tab { position: relative; }
#wishlist-tab.has-deals::after {
  content: ''; position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--bg);
}

.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* Photo straightening */
.photo-body { flex: 1; overflow-y: auto; padding: 12px 16px calc(env(safe-area-inset-bottom) + 16px); }
.photo-body > p { margin: 0 0 10px; }
.photo-stage { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; margin: 0 auto; }
.photo-stage canvas { display: block; border-radius: 6px; }
.photo-outline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.photo-outline polygon { fill: rgb(43 179 163 / .14); stroke: var(--accent); stroke-width: 2; }
.ph-handle {
  position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; padding: 0;
  border: 3px solid #fff; background: rgb(0 0 0 / .35); box-shadow: 0 2px 8px rgb(0 0 0 / .5); touch-action: none;
}
.ph-handle.top { border-color: var(--accent); }
.photo-tools { margin-top: 14px; }

.inspect-actions { display: flex; gap: 8px; }
.inspect-actions .btn { flex: 1; padding: 10px; font-size: 14px; }
.inspect-photos { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.inspect-photos .pill.on { border-color: var(--accent); color: var(--text); }
.no-back {
  height: 100%; padding: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-weight: 700; color: #fff; background: linear-gradient(rgb(0 0 0 / .2), rgb(0 0 0 / .5));
}
.no-back small { font-weight: 400; opacity: .75; margin-top: 6px; }
.inspect-controls { padding: 12px 16px calc(env(safe-area-inset-bottom) + 16px); display: flex; flex-direction: column; gap: 10px; }
.inspect-views { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-radius: 10px; padding: 3px; }
.inspect-views button { border: 0; background: none; border-radius: 8px; padding: 8px 0; color: var(--text-2); font-size: 13.5px; }
.inspect-views button.on { background: var(--text); color: var(--bg); font-weight: 600; }
.inspect-hint { margin: 0; text-align: center; font-size: 12.5px; color: var(--muted); }
.inspect-facts { background: var(--surface); border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.inspect-facts div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.inspect-facts span:first-child { color: var(--muted); }
.inspect-facts span:last-child { text-align: right; }
