/* Crate. A record shop counter: concrete wall, wooden crate, a black deck.
   Light by day, dark by night. */
:root {
  --wall: #e7e3da; --wall-2: #dcd7cc; --card: #f5f2eb; --ink: #1b1a17; --muted: #6b675e; --line: #cdc7ba;
  --accent: #2443d1; --accent-ink: #ffffff; --accent-soft: #dfe4fb;
  --deck: #1d1e1d; --deck-2: #2a2b2a; --metal: #d9d7d0; --led: #ff4b2b;
  --wood-1: #bb834b; --wood-2: #8f5a2c;
  --danger: #b4261b;
  --wide: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "DM Mono", ui-monospace, Menlo, monospace;
  --radius: 14px; --bar-h: 76px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wall: #121318; --wall-2: #191b22; --card: #1d2028; --ink: #ece9e1; --muted: #9b978d; --line: #2c2f39;
    --accent: #8ea2ff; --accent-ink: #0d0f16; --accent-soft: #22284a;
    --deck: #0d0e10; --deck-2: #1c1d20;
    --wood-1: #9c6a3a; --wood-2: #6e4320; --danger: #ff7a6b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--wall); color: var(--ink); font: 400 16px/1.55 var(--wide); font-stretch: 100%; padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px)); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--wall); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.eyebrow { font: 500 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0; }
.small { font-size: 13px; color: var(--muted); }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; border-style: dashed; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.icon { padding: 8px; width: 38px; height: 38px; justify-content: center; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--wall) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.top-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 800 24px/1 var(--wide); font-stretch: 125%; letter-spacing: -.02em; }
.logo-disc { width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle, var(--wall) 0 7%, var(--accent) 8% 30%, #111 31% 100%); box-shadow: inset 0 0 0 2px #333; }
.search { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; background: none; outline: none; padding: 9px 0; width: 100%; min-width: 0; color: var(--ink); }
.top-actions { margin-left: auto; display: flex; gap: 8px; position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; width: 260px; box-shadow: 0 20px 40px -20px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 2px; }
.menu[hidden] { display: none; }
.menu p { margin: 4px 8px 8px; font: 12px var(--mono); color: var(--muted); }
.menu button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.menu button:hover { background: var(--wall-2); }
.menu .danger { color: var(--danger); }

/* stage */
main { padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.stage { max-width: 1240px; margin: 24px auto 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); gap: 22px; }
.crate-panel { background: var(--wall-2); border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; position: relative; }

/* crate */
.crate { --s: min(300px, 64vw); position: relative; height: calc(var(--s) + clamp(100px, calc(var(--s) * .45), 140px)); perspective: 1100px; perspective-origin: 50% 8%; overflow: hidden; border-radius: 12px; touch-action: pan-y; cursor: grab; }
.crate[hidden] { display: none; }
.sleeve { position: absolute; left: 50%; top: 56px; width: var(--s); height: var(--s); margin-left: calc(var(--s) / -2); transform-origin: 50% 100%; transition: transform .5s cubic-bezier(.2,.75,.2,1), filter .5s; border-radius: 3px; overflow: hidden; background: #333; box-shadow: 0 2px 0 rgba(0,0,0,.25), 0 18px 30px -18px rgba(0,0,0,.8); }
.sleeve img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.sleeve.cur { cursor: pointer; }
.sleeve.cur::after { content: "Play album"; position: absolute; left: 10px; bottom: 10px; font: 500 12px var(--mono); background: #111; color: #f2efe6; padding: 4px 8px; border-radius: 4px; opacity: 0; transition: opacity .2s; }
.sleeve.cur:hover::after { opacity: 1; }
.sleeve.playing::before { content: "ON THE DECK"; position: absolute; right: 10px; top: 10px; z-index: 1; font: 500 10px var(--mono); letter-spacing: .08em; background: var(--led); color: #fff; padding: 3px 7px; border-radius: 3px; }
.box { position: absolute; left: 50%; bottom: 0; width: calc(var(--s) + 56px); margin-left: calc((var(--s) + 56px) / -2); height: clamp(64px, calc(var(--s) * .34), 112px); border-radius: 6px; pointer-events: none; transform: translateZ(60px);
  background: repeating-linear-gradient(90deg, rgba(0,0,0,.06) 0 3px, transparent 3px 11px), linear-gradient(var(--wood-1), var(--wood-2));
  box-shadow: inset 0 3px 0 rgba(255,255,255,.18), 0 16px 30px -12px rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; }
.box b { font: 800 26px/1 var(--wide); font-stretch: 125%; letter-spacing: .2em; color: rgba(30,15,5,.42); text-transform: uppercase; }
.now { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.now[hidden] { display: none; }
.now-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.now-text strong { font: 800 22px/1.15 var(--wide); font-stretch: 112%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-text span { font: 13px var(--mono); color: var(--muted); }

/* empty state */
.empty { display: flex; flex-direction: column; gap: 14px; padding: 18px 6px 6px; }
.empty[hidden] { display: none; }
.empty h1 { margin: 0; font: 800 clamp(30px, 4.2vw, 46px)/1 var(--wide); font-stretch: 118%; letter-spacing: -.02em; text-wrap: balance; }
.empty p { margin: 0; max-width: 56ch; }

/* deck */
.deck { background: linear-gradient(160deg, var(--deck-2), var(--deck)); color: #e9e6de; border-radius: 22px; padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr) 70px; grid-template-rows: auto auto; gap: 16px 18px; box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 30px 60px -30px rgba(0,0,0,.8); min-width: 0; align-self: start; }
.plat-wrap { position: relative; aspect-ratio: 1; width: 100%; }
.viz { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.platter { position: absolute; inset: 6%; border-radius: 50%; background: repeating-radial-gradient(circle, #3a3d3b 0 2px, #2e3130 2px 4px); box-shadow: 0 0 0 6px #111, 0 12px 30px rgba(0,0,0,.6); }
.record { position: absolute; inset: 8%; width: 84%; height: 84%; border-radius: 50%; cursor: grab; touch-action: none; }
.record.grab { cursor: grabbing; }
.spindle { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; background: #d9d9d9; box-shadow: 0 0 0 2px #888; pointer-events: none; }
.arm { position: absolute; right: -2%; top: -1%; width: 44%; height: 84%; pointer-events: none; transform-origin: 78% 12%; transform: rotate(-13deg); transition: transform .9s cubic-bezier(.3,.7,.2,1); }
.arm-base { position: absolute; right: 8%; top: 4%; width: 26%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, #c4c4c4 0 30%, #5d605e 31% 60%, #3b3e3c 61%); box-shadow: 0 6px 12px rgba(0,0,0,.6); }
.arm-rod { position: absolute; right: 20%; top: 14%; width: 5px; height: 78%; background: linear-gradient(90deg, #9a9a9a, #ececec, #9a9a9a); border-radius: 3px; transform: rotate(14deg); transform-origin: top; }
.arm-head { position: absolute; left: 47%; bottom: 3%; width: 15%; height: 12%; background: #e7e7e7; border-radius: 3px; transform: rotate(14deg); box-shadow: 0 4px 8px rgba(0,0,0,.6); }
.deck-side { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ss { width: 70px; height: 46px; border-radius: 6px; border: 0; background: #d9d6cc; color: #151515; font: 500 11px var(--mono); box-shadow: 0 3px 0 #7b786f; }
.ss:active { transform: translateY(2px); box-shadow: 0 1px 0 #7b786f; }
.ss.on { background: #ffb547; }
.speed { display: flex; flex-direction: column; gap: 6px; }
.speed button { width: 70px; border-radius: 5px; border: 1px solid #3d403e; background: #232524; color: #e9e6de; font: 500 12px var(--mono); padding: 5px 0; }
.speed button[aria-pressed="true"] { border-color: var(--led); color: #fff; box-shadow: inset 0 0 0 1px var(--led); }
.pitch { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-height: 130px; }
.pitch input { writing-mode: vertical-lr; direction: rtl; width: 28px; flex: 1; accent-color: #ffb547; }
.pitch label, .pitch output, .reset { font: 11px var(--mono); color: #b9b6ae; font-variant-numeric: tabular-nums; }
.reset { background: none; border: 1px solid #3d403e; border-radius: 4px; padding: 3px 8px; }
.deck-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font: 12px var(--mono); color: #c9c6be; min-width: 0; }
.led { width: 8px; height: 8px; border-radius: 50%; background: #4a1d16; flex: none; }
.led.on { background: var(--led); box-shadow: 0 0 10px var(--led); }
.status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock { font-variant-numeric: tabular-nums; flex: none; }

/* library */
.library { max-width: 1240px; margin: 34px auto 0; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--ink); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: 700 15px var(--wide); font-stretch: 112%; color: var(--muted); border-radius: 10px 10px 0 0; white-space: nowrap; }
.tabs button span { font: 12px var(--mono); margin-left: 4px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--wall); }
.view { padding: 22px 0 40px; min-height: 200px; }
.view .hint { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px 16px; }
.card { background: none; border: 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; box-shadow: 0 10px 20px -14px rgba(0,0,0,.7); background: var(--wall-2); transition: transform .2s; }
.card:hover img { transform: translateY(-3px) rotate(-1deg); }
.card strong { font-weight: 700; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks { width: 100%; border-collapse: collapse; font-size: 15px; }
.tracks-wrap { overflow-x: auto; }
.tracks th { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tracks td { padding: 9px 10px; border-bottom: 1px solid var(--line); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks tr { cursor: pointer; }
.tracks tbody tr:hover { background: var(--wall-2); }
.tracks tr.on { background: var(--accent-soft); }
.tracks tr.on td:first-child { color: var(--accent); font-weight: 700; }
.tracks .n, .tracks .t { font: 13px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; width: 1%; }
.tracks .t { text-align: right; }
.tracks .act { width: 1%; text-align: right; }
.tracks .act button { background: none; border: 1px solid var(--line); border-radius: 999px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.tracks .act svg { width: 16px; height: 16px; }
.album-head { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: end; margin-bottom: 22px; }
.album-head img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; box-shadow: 0 18px 30px -18px rgba(0,0,0,.8); }
.album-head h2 { margin: 4px 0 6px; font: 800 clamp(28px, 4vw, 44px)/1.02 var(--wide); font-stretch: 115%; letter-spacing: -.02em; text-wrap: balance; }
.album-head p { margin: 0 0 14px; color: var(--muted); }
.back { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0; margin-bottom: 14px; }
.artists { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.artist { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: left; min-width: 0; }
.artist img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; }
.artist div { display: flex; flex-direction: column; min-width: 0; }
.artist strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artist span { font-size: 13px; color: var(--muted); }
.foot { max-width: 1240px; margin: 0 auto; padding: 22px 0 30px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.foot a { color: inherit; }

/* bottom bar */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -10px 30px -20px rgba(0,0,0,.4); }
.bar[hidden] { display: none; }
.seek { position: absolute; left: 0; right: 0; top: -7px; width: 100%; margin: 0; height: 14px; background: none; accent-color: var(--accent); cursor: pointer; }
.bar-in { max-width: 1240px; margin: 0 auto; height: var(--bar-h); display: grid; grid-template-columns: 48px minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 14px; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.bar-in > .bar-art { display: block; width: 48px; height: 48px; border-radius: 4px; object-fit: cover; background: var(--wall-2); }
.bar-text { display: flex; flex-direction: column; min-width: 0; }
.bar-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-text span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-ctl { display: flex; align-items: center; gap: 6px; }
.ic { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; position: relative; color: var(--ink); }
.ic:hover { background: var(--wall-2); }
.ic[aria-pressed="true"] { color: var(--accent); }
.ic.big { width: 48px; height: 48px; background: var(--ink); color: var(--wall); }
.ic.big:hover { background: var(--accent); color: var(--accent-ink); }
.ic.big svg path { fill: currentColor; stroke: none; }
.ic b { position: absolute; right: 6px; top: 6px; font: 700 9px var(--mono); }
.bar-right { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.bar-time { font: 12px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.vol { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.vol input { width: 100px; accent-color: var(--accent); }

/* overlays */
.drop { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--accent) 86%, transparent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.drop[hidden] { display: none; }
.drop p { font: 800 clamp(28px, 5vw, 52px)/1 var(--wide); font-stretch: 120%; margin: 18px 0 8px; }
.drop-disc { display: inline-block; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, transparent 0 6%, var(--accent-ink) 7% 28%, #111 29% 100%); animation: spin 1.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(var(--bar-h) + 18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--wall); padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }
.toast[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border-radius: 16px; padding: 22px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.modal-card h2 { margin: 0; font: 800 22px var(--wide); font-stretch: 112%; }
.modal-card p { margin: 0; color: var(--muted); }

@media (max-width: 960px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .deck { max-width: 560px; width: 100%; justify-self: center; }
  #addFolder { display: none; }
}
@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .bar-in { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; }
  .bar-in > .bar-art { width: 44px; height: 44px; }
  .bar-right, #shuffle, #repeat { display: none; }
  .album-head { grid-template-columns: 110px minmax(0, 1fr); gap: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .deck { padding: 16px; grid-template-columns: minmax(0, 1fr) 58px; gap: 12px; }
  .ss, .speed button { width: 58px; }
  .tracks .hide-sm { display: none; }
  .crate-panel { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .sleeve, .arm, .card img { transition: none; }
  .drop-disc { animation: none; }
}
