/* Layout: a three-step workbench. A hero whose headline sets the grid size, beside a fanned
   stack of sleeves; then 01 Pick (board + rail), 02 Style (poster preview + controls, with
   03 Share under the preview), then the shelf of most-picked albums. */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --sunken: #e8eaee;
  --sunken-2: #dcdfe5;
  --ink: #111216;
  --ink-2: #474b55;
  --muted: #656972;
  --line: #e0e3e8;
  --line-strong: #c5c9d2;
  --accent: #2f45ff;
  --accent-hover: #1f33e0;
  --accent-text: #2f45ff; /* accent used as text: links, selected labels */
  --accent-ink: #ffffff;
  --accent-soft: #e3e7ff;
  --sticker: #ffd23f;
  --sticker-ink: #211a00;
  --toast-action: #ffd23f; /* on the inverted (--ink) toast */
  --chip-edge: rgb(0 0 0 / 0.14); /* keeps swatches as dark or light as the page visible */
  --star: #b97c00; /* filled rating stars: 3.5:1 on white */
  --img-outline: rgb(0 0 0 / 0.1); /* hairline edge on cover art, so white and black covers keep their shape */
  --ok: #17924d;
  --warn: #c27400;
  --danger: #cc373a;
  --shadow-sm: 0 1px 2px rgb(17 18 22 / 0.08);
  --shadow: 0 1px 2px rgb(17 18 22 / 0.06), 0 18px 40px -20px rgb(17 18 22 / 0.3);
  --scrim: rgb(17 18 22 / 0.3);

  --display: 'Bricolage Grotesque', 'Arial Narrow', Arial, sans-serif;
  --font: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-lg: 22px;
  --r: 14px;
  color-scheme: light;
}

/* Dark mode: switched on with the toggle in the top bar (see js/theme.js). */
:root[data-theme="dark"] {
  --bg: #0e0f12;
  --surface: #17181c;
  --sunken: #202227;
  --sunken-2: #2a2d33;
  --ink: #f2f3f5;
  --ink-2: #c4c7cf;
  --muted: #8c909a;
  --line: #2a2c32;
  --line-strong: #3b3e46;
  --accent: #5263f0;
  --accent-hover: #4455e0;
  --accent-text: #7a88ff;
  --toast-action: #2f45ff;
  --chip-edge: rgb(255 255 255 / 0.22);
  --star: #ffd23f;
  --img-outline: rgb(255 255 255 / 0.1);
  --accent-ink: #ffffff;
  --accent-soft: #1f2450;
  --ok: #4cc685;
  --warn: #e7a53c;
  --danger: #f06a6d;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 18px 40px -20px rgb(0 0 0 / 0.7);
  --scrim: rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font: 400 15.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
svg { flex: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; } /* the skip link's target, not a control */
.skip-link {
  position: fixed;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

.page { max-width: 1240px; margin: 0 auto; padding-inline: clamp(16px, 4vw, 40px); }

/* ---- Buttons and inputs ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms, border-color 120ms, scale 120ms cubic-bezier(0.2, 0, 0, 1);
}
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn:active:not(:disabled) { scale: 0.96; }
/* Every tappable control gets the same small press. */
:is(.tt-play, .theme-toggle, .size-stepper button, .sizes button, .track-play, .player-btn, .tool, .reset-btn, .tracklist .play, .gcard-more, .toast-close) {
  transition: scale 120ms cubic-bezier(0.2, 0, 0, 1);
}
:is(.tt-play, .tt-arrow, .theme-toggle, .size-stepper button, .sizes button, .result-add, .track-play, .player-btn, .tool, .reset-btn, .tracklist .play, .gcard-more, .toast-close, .swatch, .font-opt, .layout-opt, .seg button, .check span):active:not(:disabled) { scale: 0.96; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { padding: 14px 24px; font-size: 16.5px; }
.btn-block { width: 100%; }
.btn.is-busy { cursor: progress; opacity: 0.7; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-text);
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.link-btn.danger { color: var(--danger); }

.input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15.5px;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

.seg {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--sunken);
}
.seg button {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.seg button small { font: 500 11.5px var(--mono); color: var(--muted); margin-inline-start: 4px; }
/* Phones: the ratio drops under its name so three sizes fit side by side at 320px. */
@media (max-width: 400px) {
  .seg button { padding-inline: 8px; }
  .seg button small { display: block; margin-inline-start: 0; }
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-sm button { padding: 6px 12px; font-size: 13px; }

/* ---- Top bar ---------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font: 800 23px/1 var(--display);
  letter-spacing: -0.03em;
}
.steps-nav { display: flex; align-items: center; gap: 4px; }
.steps-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14.5px;
  text-decoration: none;
}
.steps-nav a:hover { background: var(--surface); color: var(--ink); }
.steps-nav .mono { font-size: 12px; color: var(--accent-text); }

/* ---- Hero ------------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
  padding-block: clamp(36px, 6vw, 72px) clamp(40px, 6vw, 80px);
}
.hero h1 {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 85%;
  font-size: clamp(48px, 8.4vw, 116px);
  line-height: 0.92;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
.nowrap { white-space: nowrap; }
.hero-sub { margin-top: 24px; max-width: 38rem; color: var(--ink-2); font-size: clamp(16px, 1.5vw, 18.5px); line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 28px; }
.hero-note { color: var(--muted); font-size: 13px; }

/* A fanned hand of sleeves from your grid. The one in front has its record pulled up out of
   the sleeve: the vinyl is tinted with the cover's main color and the label is the cover art. */
.turntable { margin: 0; width: clamp(300px, 36vw, 480px); display: grid; gap: 20px; }
.tt-stage { position: relative; aspect-ratio: 1.32; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.tt-stage:focus-within { outline: none; }
.tt-card {
  position: absolute;
  left: 30%;
  bottom: 12%;
  width: 40%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--sunken-2);
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.18), 0 26px 44px -22px rgb(0 0 0 / 0.55);
  transform-origin: 50% 100%;
  transform: var(--fan) translateY(var(--lift, 0px));
  transition: transform 650ms cubic-bezier(.65, 0, .35, 1), opacity 450ms, filter 300ms, box-shadow 300ms;
  cursor: pointer;
}
.turntable.is-fast .tt-card { transition-duration: 360ms, 300ms, 300ms, 300ms; }
.tt-card img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tt-card:not(.is-front) { filter: saturate(0.85) brightness(0.92); }
@media (hover: hover) {
  .tt-card:not(.is-front):hover { --lift: -9px; filter: none; box-shadow: 0 2px 4px rgb(0 0 0 / 0.16), 0 30px 44px -20px rgb(0 0 0 / 0.6); }
}
.tt-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tt-record {
  position: absolute;
  left: 31.5%;
  top: 36.5%;
  width: 37%;
  aspect-ratio: 1;
  z-index: 9;
  transform: translateY(var(--out, -66%));
  transition: transform 600ms cubic-bezier(.65, 0, .35, 1);
}
.turntable.is-swapping .tt-record { --out: 0%; }
.turntable.is-fast .tt-record { transition-duration: 200ms; }
/* Hidden while the sleeves move, so it never shows over another cover. */
.turntable.record-off .tt-record { visibility: hidden; }
.tt-disc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  --vinyl: #141414;
  background:
    radial-gradient(circle, transparent 0 31%, rgb(0 0 0 / 0.35) 31.5% 32.5%, transparent 33%),
    repeating-radial-gradient(circle, rgb(255 255 255 / 0.05) 0 1px, rgb(0 0 0 / 0.12) 1px 2.6px),
    radial-gradient(circle, var(--vinyl) 0 100%);
  box-shadow: 0 20px 40px -18px rgb(0 0 0 / 0.6), inset 0 0 0 2px rgb(0 0 0 / 0.25);
  animation: spin 7.2s linear infinite;
  transition: background-color 600ms;
}
.tt-disc::after { /* sheen that catches the light */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 30deg, transparent 0 10%, rgb(255 255 255 / 0.16) 15%, transparent 22% 58%, rgb(255 255 255 / 0.1) 64%, transparent 71%);
  animation: spin 7.2s linear infinite reverse; /* cancels the disc's turn so the sheen holds still */
}
.tt-label {
  position: absolute;
  inset: 31%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--sticker);
  box-shadow: 0 0 0 3px rgb(0 0 0 / 0.25);
}
.tt-label img { width: 100%; height: 100%; object-fit: cover; }
.tt-label::after { /* spindle hole */
  content: '';
  position: absolute;
  inset: 45%;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.5);
}
@keyframes spin { to { transform: rotate(360deg); } }
.tt-caption { display: flex; align-items: center; gap: 12px; min-width: 0; padding-inline: 4px; }
.tt-nav { display: flex; gap: 6px; margin-left: auto; flex: none; }
.tt-arrow {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  transition: border-color 120ms, color 120ms, scale 120ms cubic-bezier(0.2, 0, 0, 1);
}
.tt-arrow:hover { border-color: var(--ink-2); color: var(--ink); }
/* On: filled, like a lit switch. Off: plain outline. */
.tt-auto[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.tt-auto[aria-pressed="true"]:hover { border-color: var(--ink-2); background: var(--ink-2); color: var(--bg); }
.tt-play {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 16px -6px rgb(47 69 255 / 0.6);
}
.tt-play svg { width: 16px; height: 16px; }
.tt-play:hover { background: var(--accent-hover); }
.tt-text { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.tt-text b, .tt-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-kicker { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.tt-text b { font-size: 15.5px; }
.tt-text #ttArtist { color: var(--ink-2); font-size: 14px; }
.turntable.is-offscreen .tt-disc, .turntable.is-offscreen .tt-disc::after { animation-play-state: paused; }

/* ---- Sections ------------------------------------------------------------------ */
.section { padding-block: 28px 40px; scroll-margin-top: 12px; }
.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 22px; }
.section-head h2, .share-head h2 {
  text-wrap: balance;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 90%;
  font-size: clamp(28px, 3.4vw, 40px);
  letter-spacing: -0.035em;
  line-height: 1.05;
}
.section-num {
  padding: 4px 10px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
}
.size-stepper {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  padding: 3px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.size-stepper button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--sunken);
  color: var(--ink);
}
.size-stepper button:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.size-stepper button:disabled { opacity: 0.35; cursor: default; }
.size-stepper output { min-width: 4.6ch; text-align: center; font-size: 14.5px; font-weight: 700; }
.count-sticker {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--sticker);
  color: var(--sticker-ink);
  font-size: 14px;
  font-weight: 700;
  transform: rotate(-4deg);
  box-shadow: 0 2px 6px -2px rgb(0 0 0 / 0.3);
}

/* ---- 01 Pick -------------------------------------------------------------------- */
@media (min-width: 1021px) { #pick { width: fit-content; max-width: 100%; } }
/* The board is capped by screen height so the whole grid, and its resize corner, fit on screen. */
.pick-layout { display: grid; grid-template-columns: minmax(0, max(440px, calc(78dvh - 60px))) 290px; gap: 28px; align-items: start; }
.board {
  position: relative;
  --board-pad: clamp(12px, 2vw, 24px);
  padding: var(--board-pad);
  border: 1px solid var(--line);
  border-radius: calc(6px + var(--board-pad)); /* cover radius 6 + padding */
  background: var(--surface);
  box-shadow: var(--shadow);
}
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: calc(var(--gap, 14px) * 1.3) var(--gap, 14px);
  align-items: start;
}
.slot {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  container-type: inline-size;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.slot-cover { position: relative; aspect-ratio: 1; }
.slot-main {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}
.slot.is-empty .slot-main { background: var(--sunken); transition: background-color 120ms; }
.slot.is-empty .slot-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 clamp(14px, 30cqi, 64px)/1 var(--display);
  color: var(--sunken-2);
  letter-spacing: -0.04em;
  transition: opacity 120ms;
}
.slot-add {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--accent-text);
  font-weight: 700;
  font-size: clamp(12px, 9cqi, 16px);
  opacity: 0;
  transition: opacity 120ms;
}
.slot-add svg { width: 1.2em; height: 1.2em; }
.slot.is-empty .slot-main:hover, .slot.is-empty .slot-main:focus-visible { background: var(--accent-soft); }
.slot.is-empty .slot-main:hover .slot-num, .slot.is-empty .slot-main:focus-visible .slot-num { opacity: 0; }
.slot.is-empty .slot-main:hover .slot-add, .slot.is-empty .slot-main:focus-visible .slot-add { opacity: 1; }

.slot.is-filled .slot-main {
  overflow: hidden;
  background: var(--sunken);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.14), 0 14px 26px -14px rgb(0 0 0 / 0.55);
  cursor: pointer;
  touch-action: manipulation;
}
.slot.is-filled img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
/* A hairline edge on cover art, inside the image so it never changes the layout. */
.slot.is-filled .slot-main, .tt-card, .result-art, .current-art, .player-art, .song-art, .parked-list img, .shelf-item img, .poster-thumb, .mosaic img, .tracklist .art {
  outline: 1px solid var(--img-outline);
  outline-offset: -1px;
}
.num-chip {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgb(12 12 14 / 0.66);
  color: rgb(255 255 255 / 0.92);
  font: 500 10.5px/1.3 var(--mono);
  letter-spacing: 0.02em;
}
.slot-change {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.94);
  color: #111216;
  font-size: 13.5px;
  font-weight: 700;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  transition: opacity 140ms, transform 140ms;
  pointer-events: none;
  white-space: nowrap;
}
.slot-main:hover .slot-change, .slot-main:focus-visible .slot-change { opacity: 1; transform: translate(-50%, -50%); }
.slot-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12%;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  color: var(--ink-2);
  background: repeating-linear-gradient(135deg, var(--sunken) 0 8px, var(--sunken-2) 8px 16px);
}
/* Floating toolbar over the bottom of the cover. */
.slot-tools {
  position: absolute;
  left: 50%;
  bottom: 7px;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  border-radius: 999px;
  background: rgb(17 18 22 / 0.9);
  color: #fff;
  transform: translate(-50%, 4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms, transform 140ms, visibility 0s 140ms;
}
.slot.is-filled:hover .slot-tools, .slot.is-filled:focus-within .slot-tools { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.tool, .grip {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
}
.tool:hover:not(:disabled), .grip:hover { background: rgb(255 255 255 / 0.18); }
.tool:disabled { opacity: 0.3; cursor: default; }
.grip { cursor: grab; touch-action: none; opacity: 0.8; }
.tool-remove { margin-left: 2px; }
@media (hover: none) {
  .slot-tools { opacity: 1; transform: translate(-50%, 0); }
  .slot-change { display: none; }
}
.slot-info { display: grid; gap: 1px; min-width: 0; }
.slot-title, .slot-artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-title { font-weight: 600; font-size: clamp(9.5px, 6.6cqi, 15.5px); }
.slot-artist { color: var(--ink-2); font-size: clamp(9px, 6cqi, 14.5px); }
.slot-song {
  justify-self: start;
  max-width: 100%;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-size: clamp(9px, 6cqi, 14px);
  font-weight: 600;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot-song:hover { text-decoration: underline; }
.slot-song.is-empty { color: var(--muted); opacity: 0; transition: opacity 120ms; }
.slot:hover .slot-song.is-empty, .slot-song.is-empty:focus-visible { opacity: 1; }
@media (hover: none) { .slot-song.is-empty { opacity: 1; } }

/* Narrow cells drop the toolbar, then names, then the sticker. */
/* Small covers keep the essentials (song and remove) and drop the rest. */
@container (max-width: 200px) { .grip { display: none; } }
@container (max-width: 160px) { .tool-left, .tool-right { display: none; } .slot-change { font-size: 12px; padding: 5px 10px; } }
@container (max-width: 96px) { .slot-tools, .slot-change { display: none; } }
@container (max-width: 48px) { .num-chip { display: none; } }

.slot.is-drag-source { opacity: 0.3; }
.slot.is-drop-target .slot-main { outline: 3px solid var(--accent); outline-offset: 3px; }
.slot.is-new .slot-main { animation: drop-in 320ms cubic-bezier(.2, .9, .3, 1.2); }
@keyframes drop-in { from { transform: scale(0.86) rotate(-2deg); opacity: 0.4; } }
.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 24px 48px -12px rgb(0 0 0 / 0.5);
  transform: translate(-50%, -50%) scale(1.06) rotate(-3deg);
}
.drag-ghost img { width: 100%; height: 100%; object-fit: cover; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
body.is-resizing { user-select: none; -webkit-user-select: none; }

/* Corner resize handle and the lattice that previews the new size. */
.handle {
  position: absolute;
  right: -13px;
  bottom: -13px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 4px var(--bg), 0 6px 14px -4px rgb(47 69 255 / 0.6);
  cursor: nwse-resize;
  touch-action: none;
  transition: transform 140ms;
}
.handle:hover, .board.is-resizing .handle { transform: scale(1.12); }
.board.is-resizing .grid { opacity: 0.3; transition: opacity 120ms; }
.resize-ghost { position: absolute; z-index: 4; pointer-events: none; }
.ghost-cell {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.ghost-cell.filled { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.resize-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.board-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; margin-top: 18px; color: var(--muted); font-size: 14px; }
.board-hint { flex: 1 1 260px; min-width: 0; text-wrap: pretty; }
.foot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-inline-start: auto; }
.foot-actions > * { white-space: nowrap; flex: none; }
.sort { position: relative; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.sort select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  field-sizing: content;
}
.sort:hover { color: var(--ink); }
.sort:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.reset-btn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 2px; border: 0; background: none; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.reset-btn:hover:not(:disabled) { color: var(--danger); }
.reset-btn:disabled { opacity: 0.4; cursor: default; }

/* Rail */
.rail { display: grid; gap: 16px; position: sticky; top: 16px; }
.card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.card-title { font-size: 15px; font-weight: 700; }
.card-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sizes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sizes button {
  padding: 9px 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font: 600 12.5px var(--mono);
}
.sizes button:hover { border-color: var(--line-strong); }
.sizes button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.presets button {
  padding: 8px 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font: 600 13px var(--mono);
}
.presets button:hover { border-color: var(--line-strong); }
.presets button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.picker { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; touch-action: none; }
.picker button { aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; background: var(--sunken); }
.picker button.current { background: var(--accent); }
.picker button.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.picker button.on.current { background: var(--accent); }
.picker-readout { color: var(--ink-2); font-size: 13px; }
.progress-row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.progress-row .mono { font-size: 13.5px; color: var(--ink-2); }
.bar { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width 260ms cubic-bezier(.2, .8, .2, 1); }
#progressCard.ready .bar i { background: var(--sticker); }
.fit { color: var(--ink-2); font-size: 13.5px; }
.parked p { color: var(--ink-2); font-size: 13.5px; }
.parked-list { display: flex; flex-wrap: wrap; gap: 6px; }
.parked-list img { width: 42px; height: 42px; object-fit: cover; border-radius: 3px; box-shadow: var(--shadow-sm); }
.parked .link-btn { justify-self: start; font-size: 13.5px; }

/* ---- 02 Style ------------------------------------------------------------------- */
.style-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
.preview-col { position: sticky; top: 16px; display: grid; gap: 32px; } /* 2× the 14px inside the share group, so it reads as its own section */
.preview-stage {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: clamp(18px, 3vw, 34px);
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle, var(--line-strong) 1px, transparent 1.5px) 0 0 / 18px 18px,
    var(--sunken);
}
.preview-stage canvas { display: block; max-width: 100%; border-radius: 2px; box-shadow: 0 2px 4px rgb(0 0 0 / 0.12), 0 30px 50px -24px rgb(0 0 0 / 0.55); }

.share { display: grid; gap: 14px; scroll-margin-top: 16px; }
.share-head { display: flex; align-items: center; gap: 12px; }
.share-head h2 { font-size: clamp(22px, 2.4vw, 28px); }
.share-note { color: var(--ink-2); font-size: 14px; }
.share-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 8px; }
/* Download is the main action; sending options sit in an even grid below it. */
.share-actions #downloadBtn { grid-column: 1 / -1; }
.share-actions:has(#videoBtn[hidden]) .save-grid { grid-column: 1 / -1; }
/* Wallpapers: one labelled row, so each button only has to say which screen. */
.wall-row { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 8px; }
.wall-label { padding-inline: 4px 6px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.share-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.share-link .input { font-size: 13.5px; padding-block: 9px; border-radius: 999px; }

.controls { display: grid; gap: 26px; }
.field { display: grid; gap: 10px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field > label, .field > .label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14.5px; font-weight: 700; }
.opt { color: var(--muted); font-weight: 400; font-size: 13px; }

.fonts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.font-opt {
  min-width: 0;
  height: 56px;
  padding: 0 8px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  /* --fit shrinks a name that still overflows after wrapping (fitFontNames in app.js). */
  font-size: calc(19px * var(--fs, 1) * var(--fit, 1));
  line-height: 1.08;
  overflow: hidden;
}
.font-opt > span { display: block; text-wrap: balance; }
.font-opt:hover { border-color: var(--line-strong); }
.font-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--accent-text); }
.font-opt[data-font="pixel"] { font-size: calc(10.5px * var(--fit, 1)); line-height: 1.4; }
.font-opt[data-font="wide"], .font-opt[data-font="marquee"], .font-opt[data-font="neon"] { font-size: calc(14px * var(--fit, 1)); }
.font-opt[data-font="mono"] { font-size: calc(15px * var(--fit, 1)); }
.font-opt[data-font="ballet"] { font-size: calc(25px * var(--fit, 1)); }
/* Any Google font: a search box under the picker, with suggestions set in their own faces. */
.font-search { position: relative; margin-top: 10px; }
.font-search > svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.font-search .input { height: 44px; padding-inline: 40px 14px; border-radius: 12px; font-size: 16px; }
.font-search .input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.font-results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 30;
  max-height: min(360px, 60vh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 12px 32px rgb(0 0 0 / 0.14);
}
.font-results li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.font-results li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); }
@media (hover: hover) { .font-results li:hover { background: var(--sunken); } .font-results li[aria-selected="true"]:hover { background: var(--accent-soft); } }
.font-results .fr-name { min-width: 0; overflow: hidden; font-size: 21px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
.font-results .fr-cat { flex: none; color: var(--muted); font-size: 12.5px; }
.font-results .fr-empty { justify-content: flex-start; color: var(--muted); font-size: 14px; cursor: default; }
.font-style { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.font-style select { width: auto; padding-block: 8px; font-size: 16px; }

.layouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.layout-opt {
  display: grid;
  gap: 2px;
  padding: 10px 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  text-align: left;
}
.layout-opt:hover { border-color: var(--line-strong); }
.layout-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.layout-opt b { margin-top: 8px; font-size: 14.5px; }
.layout-opt small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.layout-art { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-content: start; aspect-ratio: 4 / 3; padding: 12%; border-radius: calc(var(--r) - 10px); /* option radius − padding */ background: var(--sunken); overflow: hidden; }
.layout-art i { aspect-ratio: 1; border-radius: 2px; background: var(--ink-2); opacity: 0.55; }
.layout-opt[aria-checked="true"] .layout-art i { background: var(--accent); opacity: 0.85; }
.notes-art i:nth-child(n + 4) { grid-column: 1 / -1; aspect-ratio: auto; height: 3px; margin-top: 1px; opacity: 0.35; }
.notes-art i:nth-child(5) { width: 80%; }
.notes-art i:nth-child(6) { width: 60%; }
.wall-art { gap: 0; padding: 0 0 26%; }
.wall-art i { border-radius: 0; }
.wall-art i:nth-child(even) { opacity: 0.4; }

.bg-groups { display: grid; gap: 10px; }
.bg-group { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 10px; }
.bg-group-label { color: var(--muted); font: 500 11.5px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: none; }
.swatch .chip { position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--chip-edge); transition: transform 120ms; }
.swatch:hover .chip { transform: scale(1.08); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.haze-chip { background: radial-gradient(circle at 28% 30%, #e2875f, transparent 60%), radial-gradient(circle at 75% 72%, #4f6fa8, transparent 60%), radial-gradient(circle at 80% 18%, #a3c97a, transparent 50%), #3a3540; }
.custom-chip { background: conic-gradient(#ff3b30, #ffcc00, #34c759, #00c7be, #2f45ff, #af52de, #ff3b30); }
.custom-chip::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--custom, #fff); box-shadow: 0 0 0 2px var(--surface); }

.color-panel {
  display: grid;
  gap: 14px;
  margin-top: 4px;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.color-panel-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.btn-sm { padding: 6px 12px; font-size: 13px; gap: 6px; }
.pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pickers.single { grid-template-columns: minmax(0, 1fr); }
.picker-col { display: grid; gap: 10px; min-width: 0; }
.picker-label { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.sv {
  position: relative;
  height: 140px;
  border-radius: 12px;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue, red));
  cursor: crosshair;
  touch-action: none;
}
.sv-knob {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25), 0 2px 6px rgb(0 0 0 / 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.hue {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.hue::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.3), 0 2px 6px rgb(0 0 0 / 0.35); cursor: pointer; }
.hue::-moz-range-thumb { width: 16px; height: 16px; border: 3px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.3); cursor: pointer; }
.rgb { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rgb .hex { grid-column: 1 / -1; }
.pickers.single .rgb { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr); }
.pickers.single .rgb .hex { grid-column: auto; }
.rgb label { display: flex; align-items: center; gap: 5px; min-width: 0; }
.rgb label span { color: var(--muted); font-size: 12px; font-weight: 600; }
.rgb .input { min-width: 0; padding: 7px 6px; font-size: 13px; border-radius: 9px; -moz-appearance: textfield; }
.rgb .input::-webkit-inner-spin-button, .rgb .input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.angle { display: grid; grid-template-columns: auto minmax(0, 1fr) 3.5ch; align-items: center; gap: 12px; font-size: 13.5px; font-weight: 600; }
.angle input { accent-color: var(--accent); }
.angle output { font-size: 13px; color: var(--ink-2); text-align: right; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { position: relative; cursor: pointer; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}
.check span::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg) center / 12px no-repeat;
}
.check input:checked + span { border-color: var(--accent); color: var(--ink); }
.check input:checked + span::before {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4.5 10.5 3.5 3.5 7.5-8'/%3E%3C/svg%3E");
}
.check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggles { display: grid; gap: 14px; padding-top: 4px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--sunken-2); transition: background-color 150ms; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); transition: transform 150ms; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(18px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-note { margin-top: -8px; color: var(--muted); font-size: 13px; }

/* ---- Shelf -------------------------------------------------------------------------- */
.shelf-sub { margin: -12px 0 20px; color: var(--ink-2); }
.shelf-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(124px, 1fr);
  gap: 16px;
  margin: 0;
  padding: 4px 0 12px;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}
.shelf-list li { scroll-snap-align: start; min-width: 0; }
.shelf-item { position: relative; display: grid; gap: 3px; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.shelf-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; box-shadow: var(--shadow-sm), 0 10px 20px -10px rgb(0 0 0 / 0.45); transition: transform 150ms; }
.shelf-item:hover img { transform: translateY(-3px) rotate(-1deg); }
.shelf-item .num-chip { top: 8px; left: 8px; }
.shelf-item b { margin-top: 8px; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-item .artist { color: var(--ink-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-item .count { color: var(--muted); font: 500 12px var(--mono); }

/* ---- Footer ------------------------------------------------------------------------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 40px;
  padding-block: 22px 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.save-status::before { content: '●'; margin-right: 7px; color: var(--ok); font-size: 10px; vertical-align: 1px; }
.save-status.error { color: var(--danger); }
.save-status.error::before { color: var(--danger); }

/* ---- My Grids ------------------------------------------------------------------------ */
.steps-nav .nav-grids { margin-left: 6px; border: 1.5px solid var(--line-strong); color: var(--ink); }
.steps-nav .nav-grids:hover { border-color: var(--ink-2); }
.steps-nav .nav-grids[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.steps-nav .nav-grids svg { flex: none; }
.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-inline-start: 6px;
  padding: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: none;
  color: var(--ink);
}
.theme-toggle:hover { border-color: var(--ink-2); }
.theme-toggle .ic-sun, .theme-toggle[aria-pressed="true"] .ic-moon { display: none; }
.theme-toggle[aria-pressed="true"] .ic-sun { display: block; }
.nav-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--sticker);
  color: var(--sticker-ink) !important;
  font-size: 11.5px !important;
  font-weight: 700;
  text-align: center;
}
.save-grid svg { flex: none; }
/* Icons beside semibold (600) labels use a 2-unit stroke, like the text's weight. */
:is(.btn, .reset-btn, .sort, .nav-grids, .result-songs) svg[stroke-width] { stroke-width: 2; }
.save-grid.is-saved svg { fill: currentColor; }
.reset-btn.save-grid:hover:not(:disabled) { color: var(--accent-text); }
.reset-btn.save-grid.is-saved { color: var(--accent-text); }
.btn.save-grid.is-saved { border-color: var(--accent); color: var(--accent-text); }

.grids-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 32px;
  padding-block: clamp(24px, 4vw, 48px) 28px;
}
.grids-head h1 {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 85%;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 0.95;
  letter-spacing: -0.045em;
}
.grids-sub { margin-top: 12px; max-width: 34rem; color: var(--ink-2); font-size: 16px; line-height: 1.5; }
.grids-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.unsaved {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.unsaved-thumb { flex: none; width: 72px; }
.unsaved-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.unsaved-text b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unsaved-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.grids-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
  padding: 0;
  list-style: none;
}
.gcard {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow 160ms, transform 160ms;
}
.gcard:hover { box-shadow: var(--shadow); }
.gcard.is-open { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.gcard-thumb {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  aspect-ratio: 1;
  padding: 18px;
  border: 0;
  background: var(--sunken);
  cursor: pointer;
}
.gcard-thumb:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.poster-thumb {
  display: block;
  max-width: 100%;
  max-height: 100%;
}
.gcard-thumb .poster-thumb {
  /* Centered at its own aspect ratio, whatever the poster size. */
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: calc(100% - 36px);
  max-height: calc(100% - 36px);
  border-radius: 3px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.14), 0 18px 30px -16px rgb(0 0 0 / 0.5);
  transition: transform 200ms;
}
.gcard-thumb:hover .poster-thumb { transform: translateY(-3px); }
.unsaved-thumb .poster-thumb { border-radius: 8px; box-shadow: var(--shadow-sm); } /* card radius 22 − padding 14 */
.mosaic {
  display: grid;
  grid-template-columns: repeat(var(--side), 1fr);
  gap: 3px;
  width: 78%;
  aspect-ratio: 1;
}
.unsaved-thumb .mosaic { width: 100%; gap: 2px; }
.mosaic img, .mosaic i { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 2px; background: var(--sunken-2); }
.gcard-body { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 6px; padding: 14px 16px 0; min-width: 0; }
.gcard-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gcard-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcard-badge {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.gcard-meta { color: var(--muted); font-size: 12px; }
.gcard .gcard-meta { display: flex; flex-wrap: wrap; }
.gcard-meta span { white-space: nowrap; }
.gcard-meta span + span::before { content: "·"; margin-inline: 0.6ch; }
.gcard { cursor: pointer; }
.gcard-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 14px 16px; }
.gcard-more {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
}
.gcard-more:hover, .gcard-more[aria-expanded="true"] { background: var(--sunken); color: var(--ink); }
.gcard-strip { display: none; }

/* Count on the leading edge, view switch on the trailing one. */
.grids-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.grids-bar[hidden] { display: none; }
.grids-count { color: var(--muted); font-size: 13px; }
#viewSwitch button { display: inline-flex; align-items: center; gap: 6px; }

/* ---- List view: one row per grid ---- */
.grids-list.is-list { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.is-list .gcard {
  /* Eight 32px covers with 4px gaps: a fixed column, so every strip starts on one edge. */
  grid-template-columns: 64px minmax(0, 1fr) 284px auto;
  grid-template-rows: auto;
  align-items: center;
  gap: 16px;
  padding: 10px 10px 10px 12px;
  border-radius: 16px;
}
.is-list .gcard-thumb { width: 64px; padding: 0; border-radius: 6px; background: var(--sunken); }
.is-list .gcard-thumb .poster-thumb { max-width: calc(100% - 10px); max-height: calc(100% - 10px); border-radius: 2px; box-shadow: 0 1px 3px rgb(0 0 0 / 0.2); }
.is-list .gcard-thumb:hover .poster-thumb { transform: none; }
.is-list .gcard-thumb .mosaic { width: 84%; gap: 1px; }
.is-list .gcard-body { padding: 0; gap: 2px; }
.is-list .gcard-strip { display: flex; gap: 4px; }
.is-list .gcard-strip img { width: 32px; height: 32px; border-radius: 3px; object-fit: cover; outline: 1px solid var(--img-outline); outline-offset: -1px; }
.is-list .gcard-actions { padding: 0; }
/* Medium widths: four covers, so the name keeps its room. */
@media (max-width: 1000px) {
  .is-list .gcard { grid-template-columns: 64px minmax(0, 1fr) 140px auto; }
  .is-list .gcard-strip img:nth-child(n + 5) { display: none; }
}

/* ---- The ⋯ menu ---- */
.grid-menu {
  position: fixed;
  inset: auto;
  min-width: 170px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.grid-menu:popover-open { display: grid; }
.grid-menu button { padding: 9px 12px; border: 0; border-radius: 8px; /* menu radius 14 − padding 6 */ background: none; color: inherit; font: inherit; font-size: 14.5px; text-align: start; }
.grid-menu button:hover, .grid-menu button:focus-visible { background: var(--sunken); outline: none; }
.grid-menu button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.grid-menu .danger { color: var(--danger); }
.grid-menu hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--line); }

.grids-empty { display: grid; justify-items: center; gap: 12px; padding: 56px 16px; text-align: center; }
.grids-empty h2 { font: 800 28px/1.1 var(--display); font-stretch: 90%; letter-spacing: -0.03em; }
.grids-empty p { max-width: 26rem; color: var(--ink-2); line-height: 1.5; }
.grids-empty .btn { margin-top: 6px; }
.grids-empty-art { display: grid; grid-template-columns: repeat(2, 34px); gap: 5px; transform: rotate(-6deg); margin-bottom: 8px; }
.grids-empty-art i { aspect-ratio: 1; border-radius: 4px; background: var(--sunken-2); }
.grids-empty-art i:nth-child(1) { background: var(--sticker); }
.grids-empty-art i:nth-child(4) { background: var(--accent); }
.drop-hint { margin-top: 26px; color: var(--muted); font-size: 13px; }
.drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 50;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  color: var(--accent-text);
  font: 800 32px var(--display);
  pointer-events: none;
}
@media (max-width: 720px) {
  .grids-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .gcard-thumb { padding: 12px; }
  .gcard-thumb .poster-thumb { max-width: calc(100% - 24px); max-height: calc(100% - 24px); }
  .gcard-body { padding: 12px 12px 0; }
  .gcard-actions { padding: 10px 8px 10px 12px; }
  /* Rows drop the cover strip first; the name needs the room more. */
  .is-list .gcard { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; }
  .is-list .gcard-thumb { width: 56px; }
  .is-list .gcard-strip { display: none; }
  .is-list .gcard-body { padding: 0; }
  .is-list .gcard-actions { padding: 0; }
  .unsaved { flex-wrap: wrap; }
  .unsaved-actions { width: 100%; justify-content: flex-start; }
  .steps-nav .nav-grids { margin-left: 2px; }
}
@media (max-width: 520px) {
  .steps-nav { gap: 0; }
  .theme-toggle { width: 34px; height: 34px; margin-inline-start: 2px; }
  .steps-nav a { padding-inline: 8px; }
  .steps-nav .nav-grids { padding-inline: 9px; }
  .topbar .brand span { font-size: 0.92em; }
  .nav-grids .nav-label { display: none; }
}
@media (max-width: 480px) {
  /* The steps are one scroll away on a phone; keep the top bar to My Grids and the theme. */
  .steps-nav a[href^="#"] { display: none; }
}
@media (max-width: 420px) {
  /* Gallery stays two across: with Open and ⋯ as the only actions, a 138px card still fits. */
  .gcard-thumb { padding: 10px; }
  .gcard-body { padding: 10px 10px 0; }
  .gcard-actions { padding: 8px 4px 8px 10px; }
  /* Two short lines instead of one wrapped line: album count, then when. The cover
     already shows the size. */
  .grids-list:not(.is-list) .gcard-meta { flex-direction: column; }
  .grids-list:not(.is-list) .gcard-meta .m-size { display: none; }
  .grids-list:not(.is-list) .gcard-meta span::before { display: none; }
  /* In a narrow row, Open is the row itself (the cover); the menu keeps the rest. */
  .is-list .gcard-actions .btn { display: none; }
}

/* ---- Share pages (/p/<id>) ------------------------------------------------------------ */
.shared {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  grid-template-areas: "poster head" "poster list";
  grid-template-rows: auto 1fr;
  gap: 0 clamp(28px, 5vw, 64px);
  align-items: start;
  padding-block: 32px 48px;
}
.shared-poster { grid-area: poster; position: sticky; top: 24px; }
.shared-head { grid-area: head; }
.shared-list { grid-area: list; }
.shared-poster img { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow); }
.shared h1 { font: 800 clamp(36px, 5vw, 60px)/1 var(--display); font-stretch: 85%; letter-spacing: -0.04em; text-wrap: balance; }
.shared .sub { margin-top: 12px; color: var(--ink-2); font-size: 17px; }
.shared-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.remix-note { margin-top: 12px; max-width: 30rem; color: var(--muted); font-size: 14px; line-height: 1.5; text-wrap: pretty; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 36px; }
.list-head .list-title { margin-top: 0; }
.list-title { margin-top: 36px; font: 700 13px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tracklist { margin: 12px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.tracklist li { display: grid; grid-template-columns: 2.4ch 48px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tracklist .n { color: var(--muted); font-size: 12.5px; }
.tracklist .art { width: 48px; height: 48px; border-radius: 3px; object-fit: cover; background: var(--sunken); }
.tracklist .meta { display: grid; min-width: 0; line-height: 1.35; }
.tracklist b { font-weight: 600; overflow-wrap: anywhere; }
.tracklist b a { color: inherit; text-decoration: none; }
.tracklist b a:hover { text-decoration: underline; text-underline-offset: 3px; }
.tracklist .meta span { color: var(--ink-2); font-size: 14px; }
.tracklist .meta .song { color: var(--accent-text); font-weight: 600; }
.tracklist .meta .stars { color: var(--star); letter-spacing: 0.06em; margin-inline-end: 8px; }
.tracklist .meta .stars .off { opacity: 0.28; }
.tracklist .meta .note { color: var(--muted); font-style: italic; text-wrap: pretty; }
.tracklist .play {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
}
.tracklist .play:hover, .tracklist .play.is-playing { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.report { margin-top: 36px; color: var(--muted); font-size: 14px; }
.report summary { width: fit-content; cursor: pointer; }
.report form { display: grid; gap: 14px; margin-top: 14px; }
.report fieldset { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.report legend { margin-bottom: 8px; color: var(--ink-2); font-weight: 600; }
.report .check { color: var(--ink); }
.report .btn { justify-self: start; }
@media (max-width: 760px) {
  /* Phones: title and Remix first, then the poster, then the albums. */
  .shared { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "poster" "list"; gap: 24px; padding-block: 16px 32px; }
  .shared-poster { position: static; }
  .list-title { margin-top: 8px; }
}

/* ---- Privacy and stats pages ------------------------------------------------------- */
.foot a { color: inherit; text-underline-offset: 3px; }
.foot a:hover { color: var(--ink); }
.prose { max-width: 42rem; padding-block: clamp(24px, 4vw, 48px) 24px; line-height: 1.6; }
.prose h1, .stats h1 { font: 800 clamp(40px, 6vw, 72px)/0.95 var(--display); font-stretch: 85%; letter-spacing: -0.045em; text-wrap: balance; }
.prose .lede { margin-top: 16px; color: var(--ink-2); font-size: 18px; text-wrap: pretty; }
.prose h2, .stats h2 { margin-top: 40px; font: 800 24px/1.15 var(--display); font-stretch: 90%; letter-spacing: -0.02em; }
.prose p, .prose ul { margin-top: 12px; color: var(--ink-2); text-wrap: pretty; }
.prose ul { display: grid; gap: 8px; padding-inline-start: 20px; }
.prose b { color: var(--ink); }
.prose a { color: var(--accent-text); text-underline-offset: 3px; }
.prose .updated { margin-top: 40px; color: var(--muted); font-size: 14px; }
.stats main { padding-block: 24px 48px; }
.stats-sub { margin-top: 12px; max-width: 44rem; color: var(--ink-2); text-wrap: pretty; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 112px), 1fr)); gap: 12px; margin: 24px 0 0; padding: 0; list-style: none; }
.stat-tiles li { display: grid; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.stat-tiles span { color: var(--ink-2); font-size: 14px; font-weight: 600; }
.stat-tiles b { font: 800 34px/1 var(--display); font-variant-numeric: tabular-nums; }
.stat-tiles small { color: var(--muted); font-size: 13px; }
.funnel { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.funnel b { font-variant-numeric: tabular-nums; }
.funnel span { margin-inline-start: 8px; color: var(--muted); font-size: 14px; }
.table-wrap { margin-top: 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.stats table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats th, .stats td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: end; white-space: nowrap; }
.stats thead th { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stats thead th:first-child { text-align: start; }
.stats tbody th { text-align: start; font-weight: 600; }
.stats td { font-variant-numeric: tabular-nums; }
.stats tbody tr:last-child > * { border-bottom: 0; }
.stats .errors th { white-space: normal; }
.stats .errors code { font: 500 13px var(--mono); overflow-wrap: anywhere; }
.stats .errors small { display: block; margin-top: 2px; color: var(--muted); font-weight: 400; }

/* ---- 404 ---------------------------------------------------------------------------- */
.missing { display: grid; justify-items: center; gap: 16px; padding-block: clamp(32px, 8vh, 96px); text-align: center; }
.missing-record { width: min(220px, 56vw); height: auto; filter: drop-shadow(0 24px 30px rgb(0 0 0 / 0.3)); }
.missing h1 { margin-top: 8px; font: 800 clamp(40px, 7vw, 76px)/0.95 var(--display); font-stretch: 85%; letter-spacing: -0.045em; text-wrap: balance; }
.missing p { max-width: 30rem; color: var(--ink-2); font-size: 18px; line-height: 1.5; text-wrap: pretty; }
.missing-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }

/* ---- Search drawer --------------------------------------------------------------------- */
.drawer {
  inset: 0 0 0 auto;
  width: min(470px, 100vw);
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: -40px 0 80px -40px rgb(0 0 0 / 0.4);
}
.drawer[open] { display: flex; flex-direction: column; animation: drawer-in 240ms cubic-bezier(.2, .8, .2, 1); }
.drawer::backdrop { background: var(--scrim); }
@keyframes drawer-in { from { transform: translateX(48px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: calc(env(safe-area-inset-top, 0px) + 18px) 22px 16px; }
.slot-sticker {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--sticker);
  color: var(--sticker-ink);
  font-size: 15px;
  font-weight: 700;
  transform: rotate(-8deg);
  box-shadow: 0 3px 8px -3px rgb(0 0 0 / 0.35);
}
.drawer-titles { flex: 1; min-width: 0; display: grid; }
.drawer-titles h2 { font: 800 24px/1.1 var(--display); font-stretch: 90%; letter-spacing: -0.03em; }
.drawer-sub { color: var(--muted); font-size: 13.5px; }

.search-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.search-top { padding: 0 22px; }
.search-field { position: relative; }
.search-field > svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field .input { height: 50px; padding: 0 46px; border-radius: 999px; background: var(--sunken); border-color: transparent; font-size: 16px; }
.search-field .input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-field .input:focus { background: var(--surface); border-color: var(--accent); }
.spinner, .clear-btn { position: absolute; top: 50%; right: 14px; }
.spinner {
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.clear-btn { display: grid; place-items: center; width: 26px; height: 26px; margin-top: -13px; padding: 0; border: 0; border-radius: 50%; background: var(--sunken-2); color: var(--ink-2); }
.search-help { margin-top: 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.source-status { display: flex; flex-wrap: wrap; gap: 4px 14px; min-height: 20px; margin-top: 10px; color: var(--ink-2); font-size: 12.5px; }
.source-status .s { display: inline-flex; align-items: center; gap: 6px; }
.source-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.source-status .s.ok .dot { background: var(--ok); }
.source-status .s.err .dot { background: var(--warn); }
.source-status .s.wait .dot { animation: pulse 900ms ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.3; } }

.results-scroll { flex: 1; min-height: 0; padding: 18px 22px 20px; overflow-y: auto; overscroll-behavior: contain; }
.list-label { margin-bottom: 10px; color: var(--muted); font: 500 11.5px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
.results { display: grid; gap: 2px; margin: 0 -10px; padding: 0; list-style: none; }
.result {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 7px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.result.is-active { background: var(--sunken); }
.result-art { width: 52px; height: 52px; border-radius: 5px; /* row radius 12 − padding 7 */ object-fit: cover; background: var(--sunken); box-shadow: 0 1px 2px rgb(0 0 0 / 0.14), 0 6px 12px -6px rgb(0 0 0 / 0.4); }
.result-art.missing { display: grid; place-items: center; color: var(--muted); font: 500 9.5px var(--mono); text-align: center; background: repeating-linear-gradient(135deg, var(--sunken) 0 6px, var(--sunken-2) 6px 12px); }
.result-title { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-sub { color: var(--ink-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-add {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  transition: background-color 120ms, border-color 120ms, scale 120ms cubic-bezier(0.2, 0, 0, 1);
}
.result-add svg { width: 17px; height: 17px; }
.result.is-active .result-add, .result:hover .result-add { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.result.is-picked .result-add { background: var(--sticker); border-color: var(--sticker); color: var(--sticker-ink); }
.result.is-picked .result-art, .result.is-picked .result-text { opacity: 0.5; }
/* Suggestions show as a wall of covers. */
.results.tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px; margin: 0; }
.results.tiles .result { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 0; border-radius: 0; }
.results.tiles .result.is-active { background: none; }
.results.tiles .result-art { width: 100%; height: auto; aspect-ratio: 1; border-radius: 4px; }
.results.tiles .result-add { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 0; box-shadow: var(--shadow-sm); }
.results.tiles .result-title { font-size: 13.5px; }
.results.tiles .result-sub { font-size: 12.5px; }
.results.tiles .result.is-active .result-art { outline: 3px solid var(--accent); outline-offset: 2px; }
.results.tiles .result.is-fresh { animation: tile-in 320ms cubic-bezier(.2, .8, .2, 1); }
@keyframes tile-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } }
.results-empty { color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.results-empty h3 { margin-bottom: 4px; color: var(--ink); font-size: 16px; font-weight: 700; }
.list-label.is-loading { animation: pulse 900ms ease-in-out infinite alternate; }
.result-why { margin-top: 2px; color: var(--accent-text); font-size: 12px; font-weight: 600; }
.results-more { margin-top: 18px; color: var(--muted); font-size: 13.5px; }
.skeleton { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center; padding: 7px 10px; }
.skeleton i { display: block; border-radius: 6px; background: var(--sunken); animation: pulse 900ms ease-in-out infinite alternate; }
.skeleton i:first-child { width: 52px; height: 52px; border-radius: 3px; }
.skeleton span { display: grid; gap: 8px; }
.skeleton span i { height: 12px; }

.manual { flex: 1; display: grid; gap: 16px; align-content: start; padding: 4px 22px 20px; overflow-y: auto; }
.manual-note { color: var(--ink-2); font-size: 14.5px; }
.drop {
  position: relative;
  display: grid;
  place-items: center;
  width: min(220px, 100%);
  aspect-ratio: 1;
  padding: 16px;
  border: 2px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.manual-fields { display: grid; gap: 12px; }
.manual-fields label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.manual-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-error { color: var(--danger); font-size: 13.5px; }

.drawer-foot { display: flex; align-items: center; gap: 16px; padding: 14px 22px calc(env(safe-area-inset-bottom, 0px) + 16px); border-top: 1px solid var(--line); }
.mini-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.mini-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 260ms; }

/* Swap panel: the album currently in the slot */
.current {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 6px 14px;
  align-items: center;
  margin: 0 22px 16px;
  padding: 12px;
  border-radius: 16px;
  background: var(--sunken);
}
.current-art { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; box-shadow: var(--shadow-sm); }
.current-text { display: grid; min-width: 0; }
.current-text b, .current-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.current-text span { color: var(--ink-2); font-size: 14px; }
.current-text .current-song { color: var(--accent-text); font-weight: 600; }
.current-text .current-song:empty { display: none; }
.current-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.current-actions .btn { flex: 1; }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }

/* ---- Favorite song dialog -------------------------------------------------------------- */
.sheet {
  width: min(480px, calc(100vw - 24px));
  max-height: min(680px, calc(100dvh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 40px 80px -30px rgb(0 0 0 / 0.5);
}
.sheet[open] { display: flex; animation: sheet-pop 200ms cubic-bezier(.2, .8, .2, 1); }
.sheet::backdrop { background: var(--scrim); }
@keyframes sheet-pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } }
.song-form { display: flex; flex-direction: column; gap: 12px; width: 100%; min-height: 0; padding: 20px 22px; }
.song-head { display: flex; align-items: center; gap: 14px; }
.song-art { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; box-shadow: var(--shadow-sm), 0 8px 16px -8px rgb(0 0 0 / 0.4); }
.song-titles { flex: 1; min-width: 0; display: grid; }
.song-titles h2 { font: 800 22px/1.15 var(--display); font-stretch: 90%; letter-spacing: -0.03em; }
.song-album { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-status { min-height: 1.2em; margin-top: -4px; color: var(--muted); font-size: 13px; }
.song-status:empty { display: none; }
.track-list { flex: 1; min-height: 120px; margin: 0 -8px; padding: 0 16px 0 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; list-style: none; }
.track-list li { display: flex; gap: 12px; align-items: baseline; padding: 9px 8px; border-radius: 10px; cursor: pointer; font-size: 15px; }
.track-list li { align-items: center; }
.track-list li .mono { flex: none; width: 2.2ch; color: var(--muted); font-size: 12.5px; }
.track-list li .track-play { flex: none; margin-right: -2px; background: var(--sunken); }
.track-list li .track-play:hover, .track-list li .track-play.is-playing { background: var(--accent); color: var(--accent-ink); }
.track-list li:hover, .track-list li.is-active { background: var(--sunken); }
.track-list .track-name { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.track-list li.is-current { color: var(--accent-text); font-weight: 600; }
.track-list li .track-name { flex: 1; min-width: 0; }
.track-list li .track-len { width: auto; margin-left: 12px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.track-list li.is-current .track-name::after { content: ' ♪'; }
.track-list:empty { display: none; }
/* Album details dialog: rating and note above the favorite song. */
.detail-row { display: grid; gap: 6px; }
.rating { display: flex; align-items: center; gap: 12px; }
.stars { display: flex; gap: 2px; }
.star { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); transition: color 120ms, scale 120ms cubic-bezier(0.2, 0, 0, 1); }
/* Empty stars are outlines, filled ones solid: the shape carries the state, not just color. */
.star svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.star.is-on { color: var(--star); }
.star.is-on svg { fill: currentColor; }
@media (hover: hover) { .star:hover { color: var(--star); } }
.star:active { scale: 0.96; }
.note-input { min-height: 0; resize: none; font: inherit; line-height: 1.4; }
.slot-stars { margin-inline-end: 6px; color: var(--star); letter-spacing: 0.04em; }
.song-form .label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14.5px; font-weight: 700; }
.song-actions { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.song-actions .spacer { flex: 1; }

/* Songs on an album, opened from a search result */
.result-songs {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-self: start;
  margin-top: 4px;
  padding: 3px 9px 3px 7px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}
.result-songs:hover, .result-songs[aria-expanded="true"] { border-color: var(--accent); color: var(--accent-text); }
.result-text { display: grid; min-width: 0; }
.tracks-panel {
  grid-column: 1 / -1;
  margin: 2px 0 10px;
  padding: 12px 8px 8px;
  border-radius: 14px;
  background: var(--sunken);
  list-style: none;
  cursor: default;
}
.tracks-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 6px; }
.tracks-head > span { display: grid; min-width: 0; }
.tracks-head b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks-hint { color: var(--muted); font-size: 12.5px; }
.tracks-close { flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: var(--surface); color: var(--ink-2); font-size: 17px; line-height: 1; }
.tracks { margin: 0; padding: 0; list-style: none; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }
.track { display: grid; grid-template-columns: 28px 2.4ch minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; /* panel radius 14 − padding 8 */ }
.track:hover { background: var(--surface); }
.track-play {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
}
.track-play svg { width: 11px; height: 11px; }
.track-play:hover, .track-play.is-playing { background: var(--accent); color: var(--accent-ink); }
.track-play.is-empty { background: none; }
.track-n { color: var(--muted); font-size: 11.5px; }
.track-pick {
  min-width: 0;
  padding: 5px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-pick:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.track-time { color: var(--muted); font-size: 11.5px; }
.tracks-note { padding: 8px 4px; color: var(--muted); font-size: 13.5px; }

/* ---- Preview player ------------------------------------------------------------------ */
.ic-pause { display: none; }
.is-playing > .ic-play, .is-playing .play-icons .ic-play { display: none; }
.is-playing > .ic-pause, .is-playing .play-icons .ic-pause { display: block; }
.play-icons { display: inline-grid; }
.player {
  position: fixed;
  inset: auto auto calc(env(safe-area-inset-bottom, 0px) + 16px) 16px;
  z-index: 190;
  display: none;
  align-items: center;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  margin: 0;
  padding: 8px 8px 8px 8px;
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.player.show { display: flex; }
/* Playing through a grid adds previous and next, so the bar grows to keep the title readable. */
.player:has(.player-skip:not([hidden])) { width: min(460px, calc(100vw - 32px)); gap: 6px; }
.player:has(.player-skip:not([hidden])) .player-text { margin-inline: 6px; }
/* Narrow screens: title on the first row, controls centered on a second, so the song
   name isn't squeezed to a few letters by four buttons. */
@media (max-width: 440px) {
  .player:has(.player-skip:not([hidden])) { flex-wrap: wrap; justify-content: center; row-gap: 4px; }
  .player:has(.player-skip:not([hidden])) .player-text { flex: 1 1 calc(100% - 68px); }
  .player:has(.player-skip:not([hidden])) .player-btn { margin-bottom: 2px; }
  .player:has(.player-skip:not([hidden])) #playerClose { margin-inline-start: auto; }
  .player:has(.player-skip:not([hidden])) #playerPrev { margin-inline-start: 50px; }
}
.player[popover]:not(:popover-open) { display: none; }
.player-art { width: 44px; height: 44px; border-radius: 8px; /* player radius 16 − padding 8 */ object-fit: cover; flex: none; }
.player-text { flex: 1; min-width: 0; display: grid; }
.player-text b, .player-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-text b { font-size: 14px; }
.player-text span { font-size: 12.5px; opacity: 0.7; }
.player-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.12);
  color: inherit;
}
:root[data-theme="dark"] .player-btn { background: rgb(0 0 0 / 0.1); }
.player-btn:hover { background: var(--accent); color: var(--accent-ink); }
.player-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--sticker); transform: scaleX(0); transform-origin: left; }
body.has-player .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 88px); }

/* Play button on search results: over the cover. */
.result-play {
  position: absolute;
  left: 18px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-top: -17px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(12 12 14 / 0.72);
  color: #fff;
  opacity: 0;
  transition: opacity 120ms;
}
.result:hover .result-play, .result-play:focus-visible, .result-play.is-playing { opacity: 1; }
@media (hover: none) { .result-play { opacity: 0.9; } }
.results.tiles .result-play { left: 6px; top: 6px; width: 30px; height: 30px; margin-top: 0; }
.result-play:hover { background: var(--accent); }

/* ---- Toast ---------------------------------------------------------------------------- */
.toast {
  position: fixed;
  inset: auto auto calc(env(safe-area-inset-bottom, 0px) + 24px) 50%;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  overflow: visible;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms, transform 160ms;
}
.toast[popover]:not(:popover-open) { display: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-action { padding: 0; border: 0; background: none; color: var(--toast-action); font-weight: 700; font-size: 14px; }
.toast-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -4px -8px -4px -4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  opacity: 0.7;
}
.toast-close:hover { opacity: 1; }

/* ---- Responsive ----------------------------------------------------------------------- */
@media (max-width: 1020px) {
  .pick-layout { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .style-layout { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
  .preview-stage canvas { max-height: 70vh; width: auto !important; }
}
@media (max-width: 720px) {
  .steps-nav a { padding: 6px 9px; font-size: 13.5px; }
  .steps-nav a > .mono:not(.nav-count) { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .turntable { width: min(92vw, 400px); justify-self: center; order: -1; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .layouts { gap: 8px; }
  .layout-opt small { display: none; }
  .bg-group { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .board-foot { flex-direction: column; align-items: flex-start; }
  .pickers { gap: 10px; }
  .sv { height: 120px; }
  .pickers:not(.single) .rgb label:not(.hex) span { display: none; }
  .fonts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pickers:not(.single) .rgb .input { padding-inline: 4px; text-align: center; }
  .drawer { inset: auto 0 0 0; width: 100vw; height: 92dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; }
  .drawer[open] { animation-name: sheet-in; }
  .sheet, .sheet.guess { inset: auto 0 0 0; width: 100vw; max-width: 100vw; max-height: 85dvh; margin: 0; border-radius: 22px 22px 0 0; }
  .sheet[open] { animation-name: sheet-in; }
  .song-form { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); }
  .section-head h2 { flex: 1 1 calc(100% - 70px); min-width: 0; }
  .size-stepper { margin-left: 0; }
  .size-stepper button { width: 38px; height: 38px; }
  .count-sticker { margin-left: auto; }

  .drawer-head { padding-top: 18px; }
}
@keyframes sheet-in { from { transform: translateY(60px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* Subtitle font choices, each set in its own face. */
#captionFonts .cap-serif { font-family: "Instrument Serif", Georgia, serif; font-style: italic; font-size: 1.12em; }
#captionFonts .cap-mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.92em; }

.player-skip:disabled { opacity: 0.35; cursor: default; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---- Guess the album ------------------------------------------------------------------- */
.guess { width: min(440px, calc(100vw - 24px)); }
.guess-body { display: flex; flex-direction: column; gap: 14px; width: 100%; min-height: 0; padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; overscroll-behavior: contain; }
/* Short screens: the cover gives up height before the guess field does. */
.guess-art { width: min(100%, 46dvh); margin-inline: auto; }
.guess-top { display: flex; align-items: center; gap: 12px; }
.guess-top h2 { flex: 1; font: 800 22px/1.15 var(--display); font-stretch: 90%; letter-spacing: -0.03em; }
.guess-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.guess-play, .guess-end { display: flex; flex-direction: column; gap: 14px; }
.guess-play[hidden], .guess-end[hidden] { display: none; }
.guess-art { aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--sunken); outline: 1px solid var(--img-outline); outline-offset: -1px; }
/* Scaled up a little so the blur never shows soft, see-through edges. */
.guess-art img { display: block; width: 100%; height: 100%; object-fit: cover; filter: blur(var(--blur, 30px)); scale: 1.15; transition: filter 450ms cubic-bezier(0.2, 0, 0, 1), scale 450ms cubic-bezier(0.2, 0, 0, 1); }
.guess-art img.is-clear { filter: none; scale: 1; }
.guess-pips { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.guess-pips li { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.guess-pips li.is-used { background: var(--danger); }
.guess-msg { min-height: 2.6em; color: var(--ink-2); font-size: 14.5px; line-height: 1.45; text-wrap: pretty; }
.guess-form { display: flex; gap: 8px; }
.guess-form[hidden] { display: none; }
.guess-form .input { flex: 1; min-width: 0; font-size: 16px; }
.guess-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.guess-actions .btn[hidden], .guess-actions .link-btn[hidden] { display: none; }
.guess-actions #guessNext { margin-inline-start: auto; }
.guess-end { align-items: center; padding: 12px 0 4px; text-align: center; }
.guess-score { font: 800 64px/1 var(--display); font-stretch: 85%; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.guess-grid { font-size: 22px; letter-spacing: 0.08em; }
.guess-sub { color: var(--ink-2); }
.guess-end .guess-actions { width: 100%; }
.guess-end .guess-actions .btn { flex: 1; }
@media (prefers-reduced-motion: reduce) { .guess-art img { transition: none; } }

/* The game's own page (/p/<id>?guess): just the invitation, nothing that gives answers away. */
.guess-page { display: grid; justify-items: start; gap: 12px; max-width: 34rem; padding-block: clamp(40px, 10vh, 120px) 64px; }
.guess-page h1 { font: 800 clamp(40px, 7vw, 72px)/1 var(--display); font-stretch: 85%; letter-spacing: -0.04em; text-wrap: balance; }
.guess-page .sub { color: var(--ink-2); font-size: 17px; }
.guess-intro { color: var(--ink-2); line-height: 1.55; text-wrap: pretty; }
.guess-page .shared-actions { margin-top: 12px; }
.guess-end .guess-actions { flex-wrap: wrap; }

/* Undo and redo under the grid: icon-only, kept together as one group. */
.history-btns { display: flex; gap: 2px; }
.reset-btn.icon-only { width: 36px; height: 36px; justify-content: center; padding: 0; border-radius: 50%; }
.reset-btn.icon-only:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }

/* Shown on the old address after a move (move.js). */
.move-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 14px 16px; background: var(--ink); color: var(--bg); }
.move-banner p { flex: 1 1 22rem; line-height: 1.45; }
.move-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.move-banner .btn:not(.btn-accent) { background: transparent; border-color: color-mix(in srgb, var(--bg) 40%, transparent); color: var(--bg); }
