/* ---------- theme tokens ---------- */
:root {
  --bg: #202020;
  --ink: #f2f2f2;
  --muted: #8a8a8a;
  --faint: #5c5c5c;
  --line: #3b3b3b;
  --line-hover: #666;
  --btn-hover: #262626;
  --accent: #d9b896;
  --accent-hover: #e6cbaf;
  --on-accent: #1a1a1a;
  --wave-off: #4a4a4a;
  --hint-bg: #2a2a2a;
  --hint-ink: #d9b896;
  --plinth-1: #1c1c1c;
  --plinth-2: #171717;
  --plinth-edge: rgba(255,255,255,.06);
  --plinth-bottom: rgba(0,0,0,.6);
  --plinth-shadow: 0 2px 0 #0d0d0d, 0 30px 60px rgba(0,0,0,.55), 0 10px 20px rgba(0,0,0,.4);
  --plinth-tex: rgba(255,255,255,.012);
  --plinth-tex-blend: screen;
  --label-default: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Ccircle cx='100' cy='100' r='100' fill='%23E8D7C0'/%3E%3Cpath d='M42 100 A58 58 0 0 1 158 100 Z' fill='%23000'/%3E%3Ccircle cx='100' cy='100' r='20' fill='%23E8D7C0'/%3E%3Ccircle cx='100' cy='98' r='2.8' fill='%23000'/%3E%3Ctext x='100' y='140' text-anchor='middle' font-family='Inter,Helvetica,Arial,sans-serif' font-size='23' font-weight='900' fill='%23000' textLength='120' lengthAdjust='spacingAndGlyphs'%3EMYSTERY%3C/text%3E%3Ctext x='100' y='166' text-anchor='middle' font-family='Inter,Helvetica,Arial,sans-serif' font-size='23' font-weight='900' fill='%23000' textLength='76' lengthAdjust='spacingAndGlyphs'%3EVINYL%3C/text%3E%3C/svg%3E");
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #FBF7F1;
  --ink: #1c1a17;
  --muted: #8a8177;
  --faint: #a49a8e;
  --line: #ddd3c5;
  --line-hover: #b8ab99;
  --btn-hover: #f1ebe1;
  --accent: #d9b896;
  --accent-hover: #cfa98a;
  --on-accent: #1c1a17;
  --wave-off: #ddd3c5;
  --hint-bg: #1c1a17;
  --hint-ink: #e8d7c0;
  --plinth-1: #f3ece2;
  --plinth-2: #e8dfd1;
  --plinth-edge: rgba(255,255,255,.9);
  --plinth-bottom: rgba(90,70,50,.08);
  --plinth-shadow: 0 1px 0 rgba(90,70,50,.12), 0 30px 60px rgba(70,50,30,.16), 0 10px 20px rgba(70,50,30,.10);
  --plinth-tex: rgba(0,0,0,.02);
  --plinth-tex-blend: multiply;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  transition: background .35s ease, color .35s ease;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }

/* ---------- header ---------- */
.logo { display: inline-block; margin: 44px 0 0 80px; line-height: 0; }
.logo svg { height: 60px; width: auto; font-family: var(--font); }

.topnav {
  position: absolute; top: 48px; right: 80px;
  display: flex; align-items: center; gap: 6px;
}
.nav-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted);
  transition: color .2s, background .2s;
}
.nav-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn:hover { color: var(--ink); background: var(--btn-hover); }
.nav-btn { position: relative; }
.nav-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 8px); right: 0;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  background: var(--hint-bg); color: var(--hint-ink); font-size: 12px; letter-spacing: .01em;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; translate: 0 -4px; pointer-events: none;
  transition: opacity .15s ease .05s, translate .15s ease .05s;
}
.nav-btn[data-tip]:hover::after, .nav-btn[data-tip]:focus-visible::after { opacity: 1; translate: 0 0; }
.nav-btn[aria-pressed="false"] { opacity: .38; }
.nav-btn[aria-pressed="false"]:hover { opacity: .7; }
.ic-moon, .ic-collapse { display: none; }
:root[data-theme="light"] .ic-sun { display: none; }
:root[data-theme="light"] .ic-moon { display: block; }
body.zen .ic-expand { display: none; }
body.zen .ic-collapse { display: block; }

/* ---------- stage ---------- */
.stage {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(0, 1.05fr);
  align-items: center;
  gap: 48px;
  padding: 0 80px;
}

.panel { max-width: 560px; }

.modes-wrap { position: relative; margin-bottom: 44px; }
.modes { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-yours { display: inline-flex; align-items: center; gap: 6px; padding-left: 11px; }
.mode-yours svg { width: 13px; height: 11px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; fill: none; transition: transform .2s; }
.mode-yours:hover svg { transform: translateY(-1px); }

/* ---------- "Yours" crate popover ---------- */
.crate {
  position: absolute; left: 0; top: calc(100% + 12px); z-index: 5;
  width: min(560px, calc(100vw - 48px));
  padding: 14px; border-radius: 14px;
  background: var(--bg); border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  transform-origin: 24px 0;
  animation: crate-in .18s ease both;
}
.crate[hidden] { display: none; }
@keyframes crate-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.crate-form { display: flex; gap: 8px; }
.crate-form input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--btn-hover); color: var(--ink); font: inherit; font-size: 13px;
}
.crate-form input:focus { outline: none; border-color: var(--accent); }
.crate-add { padding: 0 16px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; }
.crate-add:hover { background: var(--accent-hover); }
.crate-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 220px; overflow: auto; }
.crate-item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-top: 1px solid var(--line); font-size: 13px; }
.crate-kind { flex: none; width: 60px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.crate-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; color: var(--ink); }
.crate-name:hover { color: var(--accent); }
.crate-item.is-playing .crate-name { color: var(--accent); }
.crate-item.is-playing .crate-kind { color: var(--accent); }
.crate-open { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--faint); }
.crate-open svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.crate-open:hover { background: var(--btn-hover); color: var(--ink); }
.crate-remove { flex: none; width: 24px; height: 24px; border-radius: 50%; color: var(--muted); font-size: 16px; line-height: 1; }
.crate-remove:hover { background: var(--btn-hover); color: var(--ink); }
.crate-empty { padding: 10px 4px; font-size: 13px; color: var(--muted); }
.crate-note { margin: 10px 0 0; font-size: 11px; color: var(--faint); }

/* hidden YouTube player: present in the viewport but invisible */
#yt-shell { position: fixed; right: 0; bottom: 0; width: 200px; height: 200px; opacity: 0.001; pointer-events: none; overflow: hidden; z-index: -1; }
#yt-shell iframe { width: 200px; height: 200px; border: 0; }
.mode {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .02em;
  transition: color .2s, border-color .2s, background .2s, transform .2s;
}
.mode:hover { color: var(--ink); border-color: var(--line-hover); }
.mode[aria-selected="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.mode:active { transform: scale(.97); }

.wave { display: block; width: 420px; height: 60px; }
.time { margin-top: 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.title {
  margin: 12px 0 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 560px;
}
.artist { margin: 12px 0 0; font-size: 15px; color: var(--muted); }

.controls { display: flex; align-items: center; gap: 10px; margin-top: 40px; }
.btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink);
  border: 1px solid var(--line);
  transition: border-color .2s, background .2s, transform .15s;
}
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn:hover { border-color: var(--line-hover); background: var(--btn-hover); }
.btn:active { transform: scale(.94); }
.btn-main { width: 56px; height: 56px; background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-main:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-main .ic-pause { display: none; }
body.playing .btn-main .ic-play { display: none; }
body.playing .btn-main .ic-pause { display: block; }

.credit { margin-top: 36px; font-size: 12px; color: var(--faint); }
.credit a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.credit a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- turntable ---------- */
.deck { display: grid; place-items: center; }
.turntable {
  position: relative;
  width: 100%;
  max-width: 840px;
  aspect-ratio: 840 / 680;
  container-type: inline-size;
  --u: 1cqw; /* 1 unit == 1/100 of turntable width; layout below is in 840-wide design px */
}
.turntable > * { position: absolute; }

.plinth {
  inset: 0;
  border-radius: calc(1.6 * var(--u));
  background:
    linear-gradient(160deg, rgba(255,255,255,.035), rgba(255,255,255,0) 40%),
    linear-gradient(var(--plinth-1), var(--plinth-2));
  box-shadow:
    inset 0 1px 0 var(--plinth-edge),
    inset 0 -1px 0 var(--plinth-bottom),
    var(--plinth-shadow);
  transition: background .35s ease, box-shadow .35s ease;
}
.plinth::after { /* faint brushed texture */
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(90deg, var(--plinth-tex) 0 1px, transparent 1px 3px);
  mix-blend-mode: var(--plinth-tex-blend);
}

/* platter: center (340,350), r=300 in 840-wide design */
.platter {
  left: calc(40 / 840 * 100%); top: calc(50 / 680 * 100%);
  width: calc(600 / 840 * 100%); aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, #1a1a1a 0 92%, #101010 92.5% 94%, #2a2a2a 94.5% 95.5%, #151515 96% 100%);
  box-shadow:
    0 0 0 1px #0a0a0a,
    0 12px 30px rgba(0,0,0,.6),
    inset 0 2px 4px rgba(255,255,255,.05);
}
.platter::before { /* rubber mat ribs */
  content: ""; position: absolute; inset: 3%; border-radius: 50%;
  background: repeating-radial-gradient(circle, #1b1b1b 0 6px, #181818 6px 9px);
  opacity: .9;
}
.platter::after { /* strobe dots on the rim */
  content: ""; position: absolute; inset: 1.4%; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, #3a3a3a 0 .6deg, transparent .6deg 3deg);
  -webkit-mask: radial-gradient(circle, transparent 0 96%, #000 96.5% 100%);
          mask: radial-gradient(circle, transparent 0 96%, #000 96.5% 100%);
}

/* record: r=290 */
.record-slot {
  left: calc(50 / 840 * 100%); top: calc(60 / 680 * 100%);
  width: calc(580 / 840 * 100%); aspect-ratio: 1;
  border-radius: 50%;
}
.record {
  position: absolute; inset: 0; border-radius: 50%;
  background: #121212;
  box-shadow: 0 6px 18px rgba(0,0,0,.6), inset 0 0 0 1px #050505;
  will-change: transform;
  transition: opacity .35s ease, scale .35s ease;
}
.record.out { opacity: 0; scale: .96; }
.grooves {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    /* wide "track" bands like a real pressing */
    radial-gradient(circle,
      transparent 0 21%,
      rgba(0,0,0,.35) 21% 21.6%, transparent 21.6% 33%,
      rgba(0,0,0,.35) 33% 33.6%, transparent 33.6% 46%,
      rgba(0,0,0,.35) 46% 46.6%, transparent 46.6% 58%,
      rgba(0,0,0,.35) 58% 58.6%, transparent 58.6% 71%,
      rgba(0,0,0,.35) 71% 71.6%, transparent 71.6% 84%,
      rgba(0,0,0,.35) 84% 84.6%, transparent 84.6% 97%,
      rgba(0,0,0,.6) 97% 100%),
    repeating-radial-gradient(circle, #141414 0 1px, #1b1b1b 1px 2.4px);
}
.grooves::after { /* run-in / run-out smooth areas */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, transparent 0 19.5%, #141414 19.5% 21%, transparent 21% 97.4%, #101010 97.4% 100%);
}
.label {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 37%; aspect-ratio: 1; border-radius: 50%;
  background: #2b2623 center / cover no-repeat;
  background-image: var(--label-default);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.6), inset 0 0 24px rgba(0,0,0,.45);
}
.label::after { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,0,0,.25), transparent 60%); }
.spindle {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 2.2%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #aaa 40%, #555 100%);
  box-shadow: 0 0 0 2px #0e0e0e, 0 1px 3px rgba(0,0,0,.8);
}
.sheen { /* fixed light source: does not rotate with the disc */
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background:
    conic-gradient(from 0deg,
      transparent 0deg 18deg, rgba(255,255,255,.075) 40deg, transparent 62deg 198deg,
      rgba(255,255,255,.075) 220deg, transparent 242deg 360deg),
    radial-gradient(circle at 38% 32%, rgba(255,255,255,.06), transparent 55%);
  -webkit-mask: radial-gradient(circle, transparent 0 20%, #000 22% 97%, transparent 98%);
          mask: radial-gradient(circle, transparent 0 20%, #000 22% 97%, transparent 98%);
}

.knob {
  left: calc(612 / 840 * 100%); top: calc(58 / 680 * 100%);
  width: calc(44 / 840 * 100%); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #333, #1a1a1a 70%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 3px 8px rgba(0,0,0,.35);
  font-size: calc(1.1 * var(--u)); color: var(--muted); display: grid; place-items: center;
}
.knob span { position: absolute; }
.knob span:first-child { left: -55%; top: 12%; }
.knob span:last-child { left: -55%; bottom: 12%; }
.knob i { position: absolute; left: 50%; top: 50%; width: 42%; height: 2px; background: #bbb; transform-origin: 0 50%; transform: rotate(-30deg); }
.power {
  left: calc(692 / 840 * 100%); top: calc(46 / 680 * 100%);
  width: calc(80 / 840 * 100%); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2e2e2e, #1a1a1a 70%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 -2px 4px rgba(0,0,0,.5), 0 4px 10px rgba(0,0,0,.35);
  transition: transform .1s;
}
.power::after { content: ""; position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 22%; aspect-ratio: 1; border-radius: 50%; background: #3a3a3a; box-shadow: inset 0 1px 2px #000; transition: background .3s, box-shadow .3s; }
body.playing .power::after { background: var(--accent); box-shadow: 0 0 10px rgba(217,184,150,.6); }
.power:active { transform: scale(.97); }

.tonearm-svg { inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.arm {
  transform-box: view-box;
  transform-origin: 700px 150px;
  transition: transform 1.1s cubic-bezier(.4, 0, .2, 1), filter .4s;
  will-change: transform;
}
.arm.lifted { filter: url(#armShadow) drop-shadow(0 14px 10px rgba(0,0,0,.5)); }
.arm-wobble { transform-box: view-box; transform-origin: 700px 150px; } /* per-frame wobble, no transition */

/* ---------- footer, hint ---------- */
.foot {
  display: flex; justify-content: space-between;
  padding: 0 80px 36px;
  font-size: 13px; color: var(--faint);
}
.foot a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.foot a:hover { color: var(--accent); border-color: var(--accent); }

.hint {
  position: fixed; left: 50%; bottom: 84px; translate: -50% 0;
  margin: 0; padding: 10px 16px; border-radius: 999px;
  background: var(--hint-bg); color: var(--hint-ink); font-size: 13px; letter-spacing: .02em;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: hint-in .5s ease both;
  pointer-events: none;
}
.hint[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 84px; translate: -50% 0;
  margin: 0; padding: 9px 14px; border-radius: 999px;
  background: var(--hint-bg); color: var(--hint-ink); font-size: 13px; letter-spacing: .02em;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: hint-in .25s ease both; pointer-events: none;
}
.toast[hidden] { display: none; }
.toast.leaving { animation: toast-out .3s ease both; }
@keyframes toast-out { to { opacity: 0; translate: -50% 6px; } }
@keyframes hint-in { from { opacity: 0; translate: -50% 8px; } }
body.armed .btn-main { animation: pulse-btn 1.6s ease-in-out infinite; }
@keyframes pulse-btn { 50% { box-shadow: 0 0 0 10px rgba(217,184,150,.18); } }

/* ---------- zen / full screen ---------- */
body.zen { grid-template-rows: 1fr; }
body.zen .logo, body.zen .foot, body.zen .credit, body.zen .modes-wrap { display: none; }
body.zen .topnav { top: 24px; right: 24px; }
body.zen .topnav > :not(#zen) { display: none; }
body.zen .stage { padding: 0 6vw; gap: 4vw; min-height: 100vh; }
body.zen .turntable { max-width: min(920px, 46vw); }
body.zen .topnav, body.zen .controls, body.zen .time { transition: opacity .5s ease; }
body.zen.idle .topnav, body.zen.idle .controls, body.zen.idle .time { opacity: 0; }
body.zen.idle { cursor: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .logo { margin: 28px 0 0 40px; }
  .topnav { right: 40px; top: 36px; }
  .stage { padding: 0 40px; gap: 32px; }
  .foot { padding: 0 40px 24px; }
  .title { font-size: 24px; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .stage { grid-template-columns: 1fr; padding: 24px 24px 0; align-content: start; }
  .deck { order: -1; }
  .turntable { max-width: 520px; }
  .panel { max-width: none; }
  .wave { width: 100%; }
  .title { white-space: normal; }
  .logo { margin: 20px 0 0 24px; } .logo svg { height: 48px; }
  .topnav { right: 16px; top: 22px; }
  .foot { flex-direction: column; gap: 6px; padding: 32px 24px 24px; }
  body.zen .stage { grid-template-columns: 1fr; padding: 24px; }
  body.zen .turntable { max-width: 520px; }
}
@media (prefers-reduced-motion: reduce) {
  .arm { transition-duration: .01s; }
}
