/*
 * Vinyl TV components. One block per helper in ui/components.ts; behaviour, where any, lives in a
 * matching module in ui/js/. Uses only the tokens in tokens.css.
 *
 * House rules (checked by tests where possible):
 * - Hover styles only inside @media (hover: hover) and (pointer: fine); touch gets :active.
 * - Interactive controls never select text or open the long-press callout; reading text does.
 * - Links never use the browser's blue/purple; cards and tiles are never underlined.
 * - Motion is transform/opacity, calm, and off under prefers-reduced-motion.
 */

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { background: var(--base); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; display: flex; flex-direction: column;
  /* No background: the fixed ambient layer (z-index -1) shows through. */
  color: var(--ink); font: var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  padding-bottom: max(var(--s5), env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
img { max-width: 100%; }
h1, h2, h3 { text-wrap: balance; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-dim); font-weight: inherit; }
.faint { color: var(--ink-faint); }
.count { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: .88em; }
.mono { font-family: var(--mono); letter-spacing: .04em; }

/* Links: the warm ink in every state, never the browser's blue or visited purple. Zero specificity,
   so every component's own colour wins. Text links in running copy get a quiet underline. */
:where(a), :where(a:link), :where(a:visited) { color: inherit; text-decoration: none; }
:where(p a:not([class]), li a:not([class]), .link) {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: rgb(244 239 230 / .35);
}
@media (hover: hover) and (pointer: fine) {
  :where(p a:not([class]), li a:not([class]), .link):hover { text-decoration-color: var(--focus); }
}

/* Focus: a warm ring that eases in, keyboard only. */
button, a, input, select, textarea, summary, [tabindex] {
  outline: 2px solid transparent; outline-offset: 0;
  transition-property: outline-color, outline-offset, background-color, color, transform, opacity, box-shadow;
  transition-duration: var(--t-fast); transition-timing-function: var(--ease);
}
:focus-visible { outline-color: var(--focus) !important; outline-offset: 3px !important; }

/* Interactive controls: no text selection, no iOS callout, no grey tap flash, no double-tap zoom
   delay. Reading text and copyable values (.code, inputs) stay selectable. */
.btn, .segmented, .segmented > *, .item-link, .icon-link, .back-link, .wordmark, .choice, .candidate,
.chip, .copy-btn, .swatch-btn, .finish-btn, .kind-btn, .radio-row, .tile-button, summary {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}

/* Cross-document View Transitions: a tile's cover floats into its detail page and back. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; }
}

/* ---------- Ambient background: the cover, blurred once, drifting slowly ---------- */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--base); }
.ambient-layer {
  position: absolute; inset: -12%; width: 124%; height: 124%; max-width: none; object-fit: cover;
  filter: blur(64px) saturate(1.45) brightness(.74); opacity: 0;
  transition: opacity 1.4s var(--ease);
  animation: drift 52s var(--ease) infinite alternate; will-change: transform, opacity;
}
.ambient-layer.is-on { opacity: 1; }
.ambient::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 50% 30%, rgb(10 8 9 / 0), rgb(10 8 9 / .55) 85%),
    linear-gradient(to bottom, rgb(10 8 9 / .4), rgb(10 8 9 / .15) 35%, rgb(10 8 9 / .7));
}
/* No cover: a quiet warm ambient instead. */
.ambient:empty {
  background:
    radial-gradient(60% 45% at 25% 20%, rgb(160 75 45 / .55), transparent 70%),
    radial-gradient(55% 40% at 80% 85%, rgb(100 45 75 / .45), transparent 70%),
    var(--base);
}
@keyframes drift {
  0%   { transform: scale(1.08) translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: scale(1.18) translate3d(-3%, 2%, 0) rotate(4deg); }
  100% { transform: scale(1.12) translate3d(3%, -2%, 0) rotate(-3deg); }
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

/* ---------- Page container: the one centred column every page uses ---------- */
.page {
  width: 100%; max-width: calc(var(--page-max) + 2 * var(--gutter)); margin: 0 auto; flex: 1;
  padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right));
  padding-top: var(--s4);
}
.page-title { margin: var(--s3) 0 var(--s4); font-size: var(--fs-title); line-height: 1.1; font-weight: var(--fw-strong); letter-spacing: -.02em; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.title-row .page-title { margin-right: auto; }
.lede { margin: calc(-1 * var(--s2)) 0 var(--s5); max-width: 60ch; color: var(--ink-dim); }

/* ---------- Top bar: sticky, translucent, readable over bright covers ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  /* Darkening scrim under the blur, so light covers never wash out the ink. */
  background: linear-gradient(to bottom, rgb(10 8 9 / .72), rgb(10 8 9 / .5));
  box-shadow: 0 1px 0 var(--hairline);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    background: linear-gradient(to bottom, rgb(10 8 9 / .55), rgb(10 8 9 / .32));
    -webkit-backdrop-filter: var(--bar-blur); backdrop-filter: var(--bar-blur);
  }
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  width: 100%; max-width: calc(var(--page-max) + 2 * var(--gutter)); min-height: var(--bar-h); margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.wordmark {
  display: inline-flex; align-items: center; gap: 9px; min-height: var(--control-h); min-width: var(--control-h); flex: none;
  font-weight: var(--fw-display); font-size: 1.12rem; letter-spacing: -.02em; white-space: nowrap;
}
.wordmark .wm-disc {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: radial-gradient(circle, var(--selected) 0 18%, #17120f 19% 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .14), 0 0 0 1px rgb(0 0 0 / .4);
}
.topbar-right { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
/* Section nav: items sized by their label (the highlight is measured), comfortable inner padding. */
.topbar .nav-seg { grid-auto-columns: auto; }
.topbar .nav-seg a { min-height: var(--control-h); padding: 0 14px; font-size: .95rem; }
.topbar .nav-seg .count { margin-left: 6px; }
.topbar .nav-seg a[aria-current="page"] .count { color: rgb(23 18 15 / .55); }
/* Page navigation: the highlight is part of the current link (right at first paint, no script) and
   carries a view-transition name, so moving to another section morphs it from the old item to the
   new one in one move; browsers without cross-document transitions just show the new page. */
.nav-seg > a .nav-indicator {
  position: absolute; inset: 0; z-index: -1; border-radius: 999px; background: var(--selected);
  box-shadow: 0 6px 18px -6px rgb(0 0 0 / .55), inset 0 1px 0 rgb(255 255 255 / .8);
  view-transition-name: nav-indicator;
}
::view-transition-group(nav-indicator) { animation-duration: .34s; animation-timing-function: cubic-bezier(.22, .8, .24, 1); }
/* Phones (360–430 px): smaller type and gaps so the nav fits with real padding, never clipped. */
@media (max-width: 459px) {
  .topbar-inner { gap: var(--s2); }
  .topbar-right { gap: var(--s1); }
  .topbar .nav-seg { gap: 2px; padding: 3px; }
  .topbar .nav-seg a { padding: 0 10px; font-size: .875rem; }
  .topbar .nav-seg .count { margin-left: 4px; }
}
@media (max-width: 374px) { .topbar .nav-seg a { padding: 0 8px; font-size: .84rem; } }

/* Icon links carry a visible label: under the icon on phones, beside it on wider screens. */
.icon-link {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: var(--control-h); height: var(--control-h); padding: 0 6px; flex: none; border-radius: 14px;
  color: var(--ink-dim); font-size: .68rem; font-weight: 600; line-height: 1; white-space: nowrap;
}
.icon-link svg { width: 20px; height: 20px; flex: none; }
.icon-link .label-long { display: none; }
@media (min-width: 720px) {
  .icon-link { flex-direction: row; gap: 7px; padding: 0 14px; border-radius: 999px; font-size: .95rem; }
  .icon-link .label-short { display: none; }
  .icon-link .label-long { display: inline; }
}
.icon-link[aria-current="page"] { background: var(--selected); color: var(--selected-ink); }
.icon-link:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) { .icon-link:hover { background: var(--glass); color: var(--ink); } }
/* Floating variant (tag page shortcuts): its own glass, for pages without a top bar. */
.icon-link.is-floating {
  flex-direction: row; gap: 6px; padding: 0 14px; border-radius: 999px; font-size: .88rem; color: var(--ink);
  background: rgb(20 16 16 / .55); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .1), 0 6px 16px -8px rgb(0 0 0 / .6);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
}
.icon-link.is-floating svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .icon-link.is-floating:hover { background: rgb(40 34 32 / .6); } }
@media (max-width: 419px) { .wordmark .wm-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }

/* ---------- Back link: "← Collection", a real link to the parent section ---------- */
.back-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--control-h); margin: 0 0 var(--s2) -10px; padding: 0 12px 0 10px;
  border-radius: 999px; color: var(--ink-dim); font-size: .95rem; font-weight: 600; white-space: nowrap;
}
.back-link:active { transform: scale(.97); background: var(--glass); }
@media (hover: hover) and (pointer: fine) { .back-link:hover { color: var(--ink); background: var(--glass); } }

/* ---------- Glass surface and card ---------- */
.glass, .card {
  position: relative; border-radius: var(--radius); background: var(--glass-fallback);
  box-shadow: var(--shadow-card); isolation: isolate;
}
.card { width: 100%; padding: var(--s5); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .card { background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
}
/* Light catching the glass edge, brighter at the top left. */
.glass::before, .card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; z-index: 2;
  background: linear-gradient(140deg, var(--edge-hi), var(--edge-lo) 38%, var(--edge-lo) 70%, rgb(255 255 255 / .14));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.card + .card { margin-top: var(--s4); }
.card > h2, .card-title { margin: 0 0 var(--s3); font-size: 1.05rem; font-weight: var(--fw-strong); }
/* Slow specular sheen sweeping across a card. */
.sheen { overflow: hidden; }
.sheen::after {
  content: ""; position: absolute; inset: -40% -60%; z-index: -1; pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgb(255 255 255 / .07) 48%, rgb(255 255 255 / .02) 54%, transparent 62%);
  animation: sheen 14s ease-in-out infinite;
}
@keyframes sheen { 0%, 15% { transform: translateX(-45%); } 60%, 100% { transform: translateX(45%); } }

/* ---------- Buttons and pills (links and buttons look the same) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); flex: none;
  min-height: var(--control-h); padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .95rem; font-weight: 600; line-height: 1.2; white-space: nowrap;
  color: var(--ink); background: var(--glass-strong); box-shadow: var(--shadow-control);
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease), transform var(--t-press) var(--ease), opacity var(--t-base) var(--ease);
}
.btn:visited { color: var(--ink); }
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(.97); background: var(--glass-hover); }
.btn:disabled, .btn[aria-disabled="true"] { color: var(--ink-faint); cursor: default; }
.btn svg, .back-link svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--selected); color: var(--selected-ink); box-shadow: inset 0 1px 0 rgb(255 255 255 / .8), 0 8px 22px -10px rgb(0 0 0 / .6); }
.btn.primary:active:not(:disabled) { background: #fbf6ee; }
.btn.primary:disabled { opacity: .55; color: var(--selected-ink); }
.btn.quiet { background: transparent; box-shadow: none; padding: 0 12px; color: var(--ink-dim); }
.btn.danger { color: var(--warn); }
.btn.small { position: relative; min-height: 40px; padding: 0 14px; font-size: .9rem; background: var(--glass); }
.btn.small.quiet { background: transparent; }
/* Small pills look 40 px tall; their hit area is 44 px (touch targets). */
.btn.small::before { content: ""; position: absolute; inset: -2px 0; }
.btn.small.primary { background: var(--selected); }
.btn.icon-only { width: var(--control-h); padding: 0; }
.btn[aria-pressed="true"], .btn.is-done { background: var(--selected); color: var(--selected-ink); }
.btn[aria-pressed="true"] .count { color: rgb(23 18 15 / .55); }
.btn .ext-arrow { opacity: .7; font-size: .9em; }
.btn .muted { font-weight: 500; }
/* Brand marks in the site's ink, never brand colours. */
.btn.brand svg { width: 18px; height: 18px; fill: currentColor; }
.btn.brand[data-site="ebay"] svg { width: 40px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--glass-hover); }
  .btn.small:hover:not(:disabled) { background: var(--glass-strong); }
  .btn.primary:hover:not(:disabled) { background: #fbf6ee; }
  .btn.quiet:hover:not(:disabled) { background: var(--glass); color: var(--ink); }
  .btn[aria-pressed="true"]:hover { background: var(--selected); }
}
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
.link-btn {
  border: 0; padding: 0; background: none; font: inherit; color: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgb(244 239 230 / .35);
}
/* Busy: progress lives on the button. */
.btn[data-busy] { position: relative; overflow: hidden; }
.btn[data-busy]::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 40%; background: currentColor; opacity: .35; animation: busy 1.2s ease-in-out infinite; }
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- Segmented control: one highlight slides to the chosen item (js/segmented.js) ---------- */
.segmented {
  --n: 2; --i: 0;
  position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s1);
  padding: var(--s1); border-radius: 999px; background: var(--well); box-shadow: var(--well-shadow);
  isolation: isolate; max-width: 100%;
}
.segmented.is-full { display: grid; width: 100%; }
.segmented > .thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px - (var(--n) - 1) * 4px) / var(--n));
  border-radius: 999px; background: var(--selected);
  box-shadow: 0 6px 18px -6px rgb(0 0 0 / .55), inset 0 1px 0 rgb(255 255 255 / .8);
  transform: translateX(calc(var(--i) * (100% + 4px))) scale(.92); opacity: 0;
  transition: transform .28s var(--spring), opacity .22s var(--ease);
  pointer-events: none;
}
.segmented[data-active] > .thumb { opacity: 1; transform: translateX(calc(var(--i) * (100% + 4px))); }
/* Measured: follows the chosen item anywhere (wrapped rows, unequal widths). */
.segmented[data-measured] > .thumb { top: 0; left: 0; bottom: auto; width: var(--w); height: var(--h); transform: translate(var(--x), var(--y)) scale(.92); }
.segmented[data-measured][data-active] > .thumb { transform: translate(var(--x), var(--y)); }
.segmented[data-instant] > .thumb { transition: none; }
.segmented > button, .segmented > a {
  position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--control-h); min-width: var(--control-h); padding: 0 var(--s4); border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .95rem; font-weight: 600; white-space: nowrap; color: var(--ink); background: transparent;
  transition: color .28s var(--ease), transform var(--t-press) var(--ease), background-color var(--t-base) var(--ease);
}
.segmented > [aria-pressed="true"], .segmented > [aria-current="page"] { color: var(--selected-ink); }
.segmented > button:active:not(:disabled) { transform: scale(.97); }
.segmented > button:disabled { color: var(--ink-faint); cursor: default; }
.segmented > button[aria-pressed="true"]:disabled { color: var(--selected-ink); }
@media (hover: hover) and (pointer: fine) {
  .segmented > button:hover:not(:disabled):not([aria-pressed="true"]), .segmented > a:hover:not([aria-current="page"]) { background: var(--glass); }
}
/* Pending (only when a request is slow): a faint shimmer across the target. */
.segmented > button[data-pending]::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; will-change: transform;
  background: linear-gradient(100deg, transparent 20%, rgb(255 250 242 / .16) 50%, transparent 80%);
  transform: translateX(-100%); animation: shimmer 1.3s var(--ease) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Fields (text, number, dropdown) ---------- */
label.field { display: grid; gap: 6px; font-size: .9rem; font-weight: var(--fw-medium); color: var(--ink-dim); }
.input {
  width: 100%; min-height: var(--control-h); padding: 10px 16px; border: 0; border-radius: var(--radius-field);
  font: inherit; font-size: 1rem; font-weight: 400; color: var(--ink); background: var(--well);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .35), inset 0 0 0 1px rgb(255 255 255 / .08);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--warn); }
.input.pill { border-radius: 999px; }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.4; }
/* Dropdown: multi-option choices (sort, paper size). */
select.input {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%), linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: right 20px top 52%, right 15px top 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
select.input option { color: var(--selected-ink); }
.joined { display: flex; }
.joined .input { border-radius: 999px 0 0 999px; min-width: 0; }
.joined .btn { border-radius: 0 999px 999px 0; }
.hint { margin: 0; font-size: .9rem; font-weight: 400; color: var(--ink-dim); }

/* ---------- Disclosure (details/summary) ---------- */
summary { display: flex; align-items: center; gap: var(--s2); min-height: var(--control-h); cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: ""; width: 7px; height: 7px; flex: none; margin: 0 4px 0 2px; border: solid currentColor; border-width: 0 1.8px 1.8px 0;
  transform: rotate(-45deg); transition: transform var(--t-fast) var(--ease); opacity: .7;
}
details[open] > summary::before { transform: rotate(45deg); }

/* ---------- Status text: plain dim words, never a pill ---------- */
.status-text { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .88rem; color: var(--ink-dim); }
.status-text svg { width: 14px; height: 14px; flex: none; fill: currentColor; opacity: .8; }
.status-text[data-tone="warn"] { color: var(--warn); }

/* ---------- Badge ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; line-height: 1.3; }
.badge.is-quiet { background: var(--glass-strong); color: var(--ink); }
.badge.is-strong { background: var(--selected); color: var(--selected-ink); }

/* ---------- Swatch: one size everywhere, 8 px from its text ---------- */
.swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--vinyl);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .22), inset -3px -3px 6px rgb(0 0 0 / .3);
}
.swatch[data-finish="translucent"] { background: color-mix(in srgb, var(--vinyl) 70%, transparent); }
.swatch[data-finish="marbled"] { background: conic-gradient(var(--vinyl), var(--vinyl2, #f4efe6) 30%, var(--vinyl) 60%, var(--vinyl2, #f4efe6) 85%, var(--vinyl)); }
.swatch[data-finish="splatter"] {
  background:
    radial-gradient(circle at 30% 35%, var(--vinyl2, #f4efe6) 0 14%, transparent 16%),
    radial-gradient(circle at 68% 64%, var(--vinyl2, #f4efe6) 0 11%, transparent 13%),
    var(--vinyl);
}
.swatch[data-finish="picture"] { background: conic-gradient(from 30deg, var(--vinyl), #c9b79a, var(--vinyl2, #8a4b2d), var(--vinyl)); }

/* ---------- Section label ---------- */
.section-label { margin: 0; font-size: var(--fs-label); font-weight: var(--fw-strong); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-dim); }
.section-label .muted { color: var(--ink-faint); }

/* ---------- Facts grid: two columns on every width, label above value ---------- */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) var(--s4); margin: 0; }
@media (min-width: 560px) { .facts { gap: var(--s4) var(--s5); } }
.facts > div { min-width: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: .82rem; color: var(--ink-dim); }
.facts dd {
  display: flex; align-items: center; gap: var(--s2); margin: 2px 0 0; font-size: 1rem; line-height: 1.35;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.facts dd > span:not(.swatch) { min-width: 0; }
/* A swatch sits on the first line when its text wraps. */
.facts dd > .swatch { align-self: flex-start; margin-top: .3em; }
.code-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.catno { font-family: var(--mono); font-size: .95em; letter-spacing: .02em; }

/* ---------- Copyable code (EAN / UPC, tag URL) with an inline copy icon ---------- */
.code-row { display: inline-flex; align-items: center; max-width: 100%; border-radius: var(--radius-small); background: rgb(0 0 0 / .28); box-shadow: var(--well-shadow); }
.code {
  padding: 6px 4px 6px 12px; font-family: var(--mono); font-size: 1rem; letter-spacing: .08em; overflow-wrap: anywhere;
  -webkit-user-select: all; user-select: all;
}
.copy-btn {
  position: relative; display: grid; place-items: center; width: var(--control-h); height: 36px; flex: none; padding: 0; border: 0; border-radius: 10px;
  cursor: pointer; color: var(--ink-dim); background: transparent;
}
.copy-btn svg { width: 18px; height: 18px; }
.copy-btn::before { content: ""; position: absolute; inset: -4px 0; }
.copy-btn .done { display: none; }
.copy-btn.is-done { color: var(--ink); }
.copy-btn.is-done .idle { display: none; }
.copy-btn.is-done .done { display: block; }
.copy-btn:active { transform: scale(.92); }
@media (hover: hover) and (pointer: fine) { .copy-btn:hover { color: var(--ink); background: var(--glass); } }

/* ---------- Disc (CSS; tiles): the record's colour, grooves and a soft sheen ---------- */
.disc {
  --sheen: conic-gradient(from 20deg, rgb(255 255 255 / .14), transparent 10%, transparent 46%, rgb(255 255 255 / .1) 56%, transparent 68%);
  --grooves: repeating-radial-gradient(circle, rgb(255 255 255 / .05) 0 1px, transparent 1px 3px);
  position: absolute; inset: 4%; z-index: 0; border-radius: 50%; display: block;
  background: var(--sheen), var(--grooves), var(--vinyl, var(--vinyl-default));
  box-shadow: 0 12px 30px -12px rgb(0 0 0 / .8), inset 0 0 0 1px rgb(255 255 255 / .06);
  transition: transform .9s var(--ease);
}
.disc[data-finish="translucent"] { background-color: color-mix(in srgb, var(--vinyl) 72%, transparent); }
.disc[data-finish="marbled"] {
  --swirl: var(--vinyl2, color-mix(in srgb, var(--vinyl) 60%, #f4efe6));
  background: var(--sheen), var(--grooves),
    conic-gradient(from 90deg, var(--vinyl), var(--swirl) 18%, var(--vinyl) 36%, color-mix(in srgb, var(--vinyl) 70%, #000) 62%, var(--swirl) 82%, var(--vinyl));
}
.disc[data-finish="splatter"] {
  --speck: var(--vinyl2, #f4efe6);
  background: var(--sheen), var(--grooves),
    radial-gradient(circle at 22% 30%, var(--speck) 0 2.5%, transparent 3%),
    radial-gradient(circle at 70% 18%, var(--speck) 0 1.6%, transparent 2.1%),
    radial-gradient(circle at 80% 62%, var(--speck) 0 3%, transparent 3.5%),
    radial-gradient(circle at 34% 78%, var(--speck) 0 2%, transparent 2.5%),
    radial-gradient(circle at 58% 88%, var(--speck) 0 1.2%, transparent 1.7%),
    radial-gradient(circle at 12% 58%, var(--speck) 0 1.4%, transparent 1.9%),
    radial-gradient(circle at 88% 38%, var(--speck) 0 1.1%, transparent 1.6%),
    radial-gradient(circle at 46% 12%, var(--speck) 0 1.8%, transparent 2.3%),
    var(--vinyl);
}
.disc[data-finish="picture"] {
  background: conic-gradient(from 20deg, rgb(255 255 255 / .18), transparent 10%, transparent 46%, rgb(255 255 255 / .12) 56%, transparent 68%),
    radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--vinyl) 50%, #f4efe6), transparent 45%),
    radial-gradient(circle at 70% 70%, var(--vinyl2, #8a4b2d), transparent 50%), var(--vinyl);
}
/* Centre label (plain) and spindle hole. */
.disc::before { content: ""; position: absolute; inset: 33%; border-radius: 50%; background: color-mix(in srgb, var(--vinyl) 35%, #c9b79a); }
.disc::after { content: ""; position: absolute; inset: 48.6%; z-index: 3; border-radius: 50%; background: var(--base); box-shadow: inset 0 1px 1px rgb(0 0 0 / .8); }
.disc-any { --vinyl: #141214; }
.disc-any::before { background: color-mix(in srgb, #c9b79a 35%, #141214); }

/* ---------- Cover ---------- */
.cover-empty {
  position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: var(--radius-small); overflow: hidden;
  background: rgb(255 250 242 / .06); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .08);
}
.ghost-disc { position: absolute; inset: 14%; border-radius: 50%; box-shadow: inset 0 0 0 2px rgb(244 239 230 / .2); animation: ghost 9s ease-in-out infinite; }
.ghost-disc::after { content: ""; position: absolute; inset: 36%; border-radius: 50%; box-shadow: inset 0 0 0 2px rgb(244 239 230 / .14); }
@keyframes ghost { 50% { transform: translateX(6%); opacity: .6; } }

/* ---------- Tiles and grid: the sleeve with the record behind it; the whole tile is the link ---------- */
.grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s6) var(--s4);
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 42vw), 1fr));
}
@media (min-width: 720px) { .grid { gap: 44px var(--s6); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.item { position: relative; animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.item-link { display: block; border-radius: 14px; text-decoration: none; transition: transform var(--t-base) var(--ease), filter var(--t-base) var(--ease); }
.sleeve { position: relative; display: block; aspect-ratio: 1; margin-bottom: 14px; transition: transform var(--t-base) var(--ease); }
.sleeve .cover {
  position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-tile);
  background: rgb(255 255 255 / .06); box-shadow: var(--shadow-art);
  transition: transform .6s var(--ease), filter var(--t-base) var(--ease);
}
.item-title { display: block; font-weight: var(--fw-strong); font-size: 1.02rem; line-height: 1.25; overflow-wrap: anywhere; }
.item-meta { display: block; margin-top: 3px; color: var(--ink-dim); font-size: .95rem; overflow-wrap: anywhere; }
.item-extra { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s2); }
.item-pressing { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); color: var(--ink-dim); font-size: .88rem; line-height: 1.3; overflow-wrap: anywhere; }
/* Press feedback on touch; on pointers the disc slides out and the cover brightens. Never an underline. */
.item-link:active .sleeve { transform: scale(.97); }
.item-link:focus-visible .disc { transform: translateX(26%) rotate(50deg); }
.item-link:focus-visible .cover { transform: translateX(-3%); }
@media (hover: hover) and (pointer: fine) {
  .item-link:hover .disc { transform: translateX(26%) rotate(50deg); }
  .item-link:hover .cover { transform: translateX(-3%); filter: brightness(1.06); }
  .item-link:hover .item-title { color: #fbf6ee; }
}
/* No cover: the disc itself is the tile. */
.sleeve-bare .disc { inset: 3%; }
.sleeve-bare::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius-tile); pointer-events: none;
  background: rgb(255 250 242 / .04); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .06);
  transition: background-color .4s var(--ease);
}
.item-link:focus-visible .sleeve-bare .disc { transform: rotate(40deg) scale(1.03); }
@media (hover: hover) and (pointer: fine) {
  .item-link:hover .sleeve-bare .disc { transform: rotate(40deg) scale(1.03); }
  .item-link:hover .sleeve-bare::after { background: rgb(255 250 242 / .08); }
}
.item .badge { position: absolute; z-index: 3; left: 8px; top: 8px; padding: 2px 9px; font-size: .74rem; }
.item .badge.is-quiet { color: var(--ink); background: rgb(10 8 9 / .6); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.item .badge.is-strong { box-shadow: 0 4px 12px -4px rgb(0 0 0 / .5); }
/* A tile that opens something in place (a sheet) instead of navigating. */
button.item-link { width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
/* Selectable tiles (grid[data-selecting]): a check on each tile, the art shrinks when chosen. */
.item .check {
  position: absolute; z-index: 3; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; opacity: 0; transform: scale(.8);
  background: rgb(10 8 9 / .45); box-shadow: inset 0 0 0 2px rgb(255 255 255 / .8); pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform .25s var(--spring), background-color var(--t-fast) var(--ease);
}
.grid[data-selecting] .check { opacity: 1; transform: none; }
.grid[data-selecting] li[aria-selected="true"] .check { background: var(--selected); box-shadow: inset 0 0 0 2px var(--selected); }
.grid[data-selecting] li[aria-selected="true"] .check::after { content: ""; position: absolute; left: 10px; top: 6px; width: 6px; height: 11px; border: solid var(--selected-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.grid[data-selecting] li[aria-selected="true"] .sleeve { transform: scale(.94); }
.grid[data-selecting] .item-link .disc { transform: none !important; }

/* ---------- Detail header and sections ---------- */
.detail-head { display: flex; flex-direction: column; align-items: flex-start; }
.detail-head > * { margin: 0; }
.detail-head .badge { margin-bottom: var(--s3); }
.detail-head h1 { font-size: var(--fs-display); line-height: 1.05; letter-spacing: -.03em; font-weight: var(--fw-display); overflow-wrap: anywhere; }
.detail-head .artist { margin-top: var(--s2); font-size: clamp(1.1rem, 2.6vw, 1.35rem); }
.detail-sub { margin-top: var(--s2) !important; color: var(--ink-dim); font-size: .92rem; }
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s5) !important; }
/* Phones: the primary action takes the first row, the secondary pills share the next. */
@media (max-width: 559px) { .detail-actions > .btn.primary { flex: 1 1 100%; } }
/* Destructive actions sit apart, at the end of the card. */
.record-foot { display: flex; padding-top: var(--s4); border-top: 1px solid var(--hairline); }
.record-foot .btn { margin-left: -12px; }
.detail-head > .flash:not(:empty), .detail-head > p:not(.artist):not(.detail-sub):not([hidden]) { margin-top: var(--s3); }
.detail-section { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); min-width: 0; }
.detail-section > * { margin: 0; }
.detail-section > .facts, .detail-section > .tracks, .detail-section > .segmented.is-full { align-self: stretch; }
.detail-text { color: var(--ink-body); max-width: 60ch; }

/* ---------- Record layout: the disc half out of the sleeve, details beside it ---------- */
.record { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s6); padding: var(--s5) var(--s5) var(--s6); animation: rise .7s var(--ease) both; }
@media (min-width: 720px) {
  .record { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--s6); padding: var(--s6); align-items: start; }
  .record-art { position: sticky; top: calc(var(--bar-h) + var(--s6)); }
}
.record-info { display: flex; flex-direction: column; gap: var(--s6); min-width: 0; }
.turntable { position: relative; aspect-ratio: 1.7; container-type: inline-size; }
.turntable > .cover {
  position: absolute; z-index: 2; left: 0; top: 0; width: 58.82cqw; height: 58.82cqw; object-fit: cover; border-radius: 14px;
  background: rgb(255 255 255 / .06); box-shadow: 0 24px 50px -18px rgb(0 0 0 / .8), 0 0 0 1px rgb(255 255 255 / .06);
}
.turntable .cover-empty .ghost-disc { inset: 18%; }
.disc-slot {
  position: absolute; z-index: 1; top: 1.76cqw; left: 1.76cqw; width: 55.29cqw; height: 55.29cqw;
  transform: translateX(42.95cqw); animation: slide-out 1.5s var(--ease) .25s backwards;
}
.disc-turn {
  position: absolute; inset: 0; --turn: 0deg; transform: rotate(var(--turn)); transition: transform 1.2s var(--ease);
  animation: spin-in 1.9s var(--ease) .25s backwards; filter: drop-shadow(0 18px 30px rgb(0 0 0 / .6));
}
.disc-face { position: absolute; inset: 0; opacity: 0; transition: opacity .7s var(--ease); }
.disc-face.is-on { opacity: 1; }
.disc-face svg { display: block; width: 100%; height: 100%; }
.disc-ghost { opacity: .55; filter: saturate(.4); }
@keyframes slide-out { from { transform: translateX(0); } }
@keyframes spin-in { from { transform: rotate(-160deg); } }

/* ---------- Track list (one side at a time, crossfading) ---------- */
.tracks { position: relative; transition: height .32s var(--ease); }
.tracklist { list-style: none; margin: 0; padding: 0; }
.tracklist li {
  display: grid; grid-template-columns: 2.6em 1fr auto; gap: var(--s3); align-items: baseline;
  padding: 10px 12px 10px 0; border-radius: var(--radius-small); font-variant-numeric: tabular-nums;
}
.tracklist li:nth-child(odd) { background: rgb(255 250 242 / .035); }
.tracklist .pos { color: var(--ink-faint); font-size: .88rem; text-align: right; }
.tracklist .t-title { overflow-wrap: anywhere; color: var(--ink-body); }
.tracklist .dur { color: var(--ink-dim); font-size: .9rem; }
.side-list .section-label { margin: 0 0 var(--s2); }
.side-list + .side-list { margin-top: var(--s5); }
.js .side-list + .side-list { margin-top: 0; }
.side-list { transition: opacity .26s var(--ease), transform .3s var(--ease); }
.side-list.leaving { position: absolute; inset: 0 0 auto; opacity: 0; transform: translateY(-6px); pointer-events: none; }
.side-list.entering { opacity: 0; transform: translateY(8px); }

/* ---------- Search field (collapses [data-hero] while in use, see js/search.js) ---------- */
.search-row { display: flex; align-items: center; gap: var(--s2); flex: 1 1 260px; min-width: 0; }
.search { position: relative; flex: 1; display: block; min-width: 0; }
.search svg {
  position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; translate: 0 -50%;
  fill: none; stroke: var(--ink-dim); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.search input {
  width: 100%; min-height: 48px; padding: 0 16px 0 44px; border: 0; border-radius: 999px;
  font: inherit; color: var(--ink); background: var(--well); box-shadow: var(--well-shadow);
  transition: box-shadow var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus { outline: none; background: rgb(0 0 0 / .34); box-shadow: inset 0 0 0 2px var(--focus); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.hero { --hero-ease: cubic-bezier(.2, .8, .2, 1); --fold-ease: cubic-bezier(.45, 0, .2, 1); display: grid; grid-template-rows: 1fr; transition: grid-template-rows .46s var(--fold-ease); }
.hero-inner { min-height: 0; overflow: hidden; transition: opacity .26s var(--hero-ease) .36s, transform .26s var(--hero-ease) .36s, filter .26s var(--hero-ease) .36s; }
.is-searching .hero { grid-template-rows: 0fr; pointer-events: none; transition: grid-template-rows .4s var(--fold-ease) .16s; }
.is-searching .hero-inner { opacity: 0; transform: translateY(-10px); filter: blur(6px); transition: opacity .2s var(--hero-ease), transform .2s var(--hero-ease), filter .2s var(--hero-ease); }
.is-searching [data-tools] {
  position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top) + var(--s2)); z-index: 10;
  /* Only while it sticks over the grid does it need its own glass. */
  margin-inline: calc(-1 * var(--s3)); padding: var(--s3); border-radius: 22px; background: var(--glass-fallback);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.search-anim-in [data-grid], .search-anim-in [data-result] { animation: results-in .42s cubic-bezier(.2, .8, .2, 1) .08s both; }
.search-anim-out [data-grid], .search-anim-out [data-result] { animation: results-back .48s cubic-bezier(.2, .8, .2, 1) .12s both; }
@keyframes results-in { from { opacity: .35; transform: translateY(10px); } }
@keyframes results-back { from { opacity: .35; transform: translateY(-8px); } }
.no-motion .hero, .no-motion .hero-inner { transition: none !important; }
/* Tools panel (search, sort, filters) on glass. */
/* Tools (searchTools()): one flat block, no panel. Search full width; the count and a compact
   sort on the row under it; filters (if any) after. */
.tools { display: grid; gap: var(--s3); margin: 0 0 var(--s5); }
.tools-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); min-height: var(--control-h); }
.tools-count { margin: 0; color: var(--ink-dim); font-size: .92rem; font-variant-numeric: tabular-nums; }
.tools .sort select.input { width: auto; padding: 0 38px 0 16px; border-radius: 999px; font-size: .92rem; font-weight: 600; }
.tools .search-row { flex: none; }

/* ---------- Skeletons: shaped like what loads, with a slow soft shimmer ---------- */
.skeleton { position: relative; overflow: hidden; background: rgb(255 250 242 / .06); border-radius: var(--radius-small); }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(100deg, transparent 20%, rgb(255 250 242 / .07) 50%, transparent 80%);
  animation: shimmer 1.8s ease-in-out infinite;
}

/* ---------- Flash line and inline error: shown only when something happens or fails ---------- */
.flash { min-height: 1.4em; margin: var(--s2) 0 0; font-size: .92rem; color: var(--ink-dim); transition: opacity var(--t-base) var(--ease); }
.flash[data-tone="error"], .error-text { color: var(--warn); }
.flash:empty { min-height: 0; margin: 0; }
.error-text { margin: 0; font-size: .92rem; }
.error-text:empty { display: none; }
.notice-box { padding: var(--s3) 14px; border-radius: var(--radius-field); background: rgb(240 169 154 / .1); color: var(--ink); font-size: .92rem; }

/* ---------- Dialog (confirmations, NFC) ---------- */
dialog.sheet {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100svh - 32px); overflow: auto; padding: 0; border: 0;
  border-radius: var(--radius); color: var(--ink);
  background: rgb(26 22 22 / .92); box-shadow: 0 30px 80px -20px rgb(0 0 0 / .8), inset 0 1px 0 rgb(255 255 255 / .1);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
dialog.sheet[open] { animation: pop .28s var(--spring); }
dialog.sheet::backdrop { background: rgb(5 4 4 / .55); }
dialog.sheet .inner { padding: var(--s5); }
dialog.sheet h2 { margin: 0; font-size: 1.2rem; }
dialog.sheet p { margin: var(--s2) 0 0; color: var(--ink-dim); }
/* Actions: secondary first, primary (or destructive) last on the right. */
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); margin: var(--s5) 0 0; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Empty state ---------- */
.empty-state { padding: var(--s6) var(--s5); }
.empty-state h2, .empty-state h1 { margin: 0; font-size: 1.2rem; font-weight: var(--fw-strong); }
/* A whole page that is only this message: centred on the screen. */
body:has(> .empty-state.is-page) { align-items: center; justify-content: center; padding: var(--s5) var(--gutter); }
.empty-state.is-page { max-width: 420px; }
.empty-state.is-page h1 { font-size: 1.5rem; letter-spacing: -.02em; }
.empty-state p { margin: var(--s2) 0 var(--s4); color: var(--ink-dim); max-width: 52ch; }
.empty-state p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.foot { width: 100%; max-width: calc(var(--page-max) + 2 * var(--gutter)); margin: var(--s7) auto 0; padding: 0 max(var(--gutter), env(safe-area-inset-left)); color: var(--ink-dim); font-size: .92rem; }
.foot p { max-width: 62ch; margin: 0; }
.foot .foot-note { margin-top: var(--s1); color: var(--ink-faint); }

/* ---------- Print: only the content ---------- */
@media print {
  .topbar, .ambient, .back-link { display: none !important; }
  .page { max-width: none !important; margin: 0 !important; padding: 0 !important; }
}

/* ---------- Reduced motion: everything settles instantly ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
  .ambient-layer, .sheen::after, .ghost-disc { animation: none; }
  .sheen::after { display: none; }
  .skeleton::after, .btn[data-busy]::after { display: none; }
  .segmented > button[data-pending]::after { animation: none; transform: none; background: rgb(255 250 242 / .08); }
}
