/* One dark look by design: lights read best against night. --accent follows the playing sequence's occasion.
   Wide screens: an app layout, sequence list on the left, player on the right, no page scroll.
   Narrow screens: the player sticks to the top and the list scrolls under it. */
:root {
  --night: #0b0a09;
  --panel: #151210;
  --raised: #1e1a16;
  --line: #2e2721;
  --ink: #f2ebe2;
  --muted: #a3968a;
  --accent: #ff6a1f;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --side: 340px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--night); color: var(--ink); }
body { font-family: var(--body); font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }

/* ---------- shared pieces ---------- */
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.brand span { font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 1; text-transform: uppercase; letter-spacing: 0.01em; }
.brand b { color: var(--accent); font-weight: 900; transition: color 0.4s; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spec { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.02em; margin: 0; }
select {
  font: 500 13px var(--body); color: var(--ink); background: var(--raised);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; min-width: 0;
}
button {
  font: 500 13px var(--body); color: var(--ink); background: var(--raised);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { width: 100%; min-width: 0; accent-color: var(--accent); }

/* player */
.player { display: grid; gap: 10px; }
.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #060504; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none;
}
.stage:active { cursor: grabbing; }
.stage canvas { display: block; width: 100%; height: 100%; }
.now { position: absolute; left: 16px; top: 14px; pointer-events: none; display: grid; gap: 2px; max-width: 60%; }
.now .code { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: 0.12em; }
.now .name { font-family: var(--display); font-weight: 700; font-size: clamp(20px, 3vw, 34px); text-transform: uppercase; line-height: 1; }
.views { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
.views button { background: rgba(21, 18, 16, 0.78); }
.hint { position: absolute; left: 16px; bottom: 12px; font-size: 12px; color: var(--muted); pointer-events: none; }
.status {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; padding: 20px;
  text-align: center; font-family: var(--mono); font-size: 13px; color: var(--muted);
}
.transport {
  display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.time { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.time b { color: var(--ink); font-weight: 500; }
.exposure { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.exposure output { font-family: var(--mono); color: var(--ink); width: 3.2em; }
.exposure input { width: 100px; }
.dl {
  font: 500 13px var(--body); color: var(--ink); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px; background: var(--raised);
}
.dl:hover { border-color: var(--accent); color: var(--accent); }
.play {
  width: 42px; height: 42px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); border-color: var(--accent); color: #140b05;
}
.play:hover { border-color: var(--ink); }
.play svg { width: 18px; height: 18px; fill: currentColor; }

/* extras */
.extras { display: grid; gap: 16px; }
.about { margin: 0; color: var(--ink); max-width: 75ch; }
.drop {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px;
  border: 1px dashed var(--line); border-radius: 10px; padding: 14px 16px; color: var(--muted); font-size: 13px;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--ink); font-weight: 600; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.err { color: #ff8a6a; }
footer { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 14px; }
footer p { margin: 0 0 8px; max-width: 75ch; }

/* library */
.library { display: flex; flex-direction: column; min-height: 0; }
.filters { display: grid; gap: 10px; padding-bottom: 12px; }
.libhead { display: flex; align-items: baseline; gap: 10px; }
h2, h3 { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin: 0; }
h2 { font-size: 24px; }
.count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
input[type="search"] {
  width: 100%; font: 15px var(--body); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
input[type="search"]::placeholder { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border-radius: 999px; padding: 5px 11px; }
.chips button[aria-pressed="true"] { border-color: var(--c, var(--accent)); color: var(--c, var(--accent)); }
.chips .n { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 4px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; background: var(--panel); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); }

.list { display: grid; gap: 2px; align-content: start; }
.group { display: grid; gap: 2px; }
.group h3 {
  position: sticky; top: 0; z-index: 1; background: var(--night);
  font-size: 17px; display: flex; align-items: center; gap: 8px; padding: 10px 2px 6px;
}
.group h3::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.item {
  display: grid; gap: 1px; width: 100%; text-align: left; padding: 8px 10px;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
}
.item:hover { background: var(--panel); border-color: var(--line); }
.item[aria-current="true"] {
  background: linear-gradient(color-mix(in srgb, var(--c) 14%, transparent), color-mix(in srgb, var(--c) 6%, transparent)), var(--panel);
  border-color: color-mix(in srgb, var(--c) 60%, transparent);
}
.item .r1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.item .c { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; flex: none; width: 3.4em; }
.item[aria-current="true"] .c { color: var(--c); }
.item .t { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dur { font-family: var(--mono); font-size: 11px; color: var(--muted); flex: none; }
.item .d {
  font-size: 12.5px; color: var(--muted); line-height: 1.4; padding-left: calc(3.4em * 11 / 12.5 + 8px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item[aria-current="true"] .d { white-space: normal; }
.item .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; flex: none; }
.empty { color: var(--muted); padding: 8px 2px; }

/* ---------- wide: sidebar + player, fills the window ---------- */
@media (min-width: 760px) {
  body { height: 100vh; height: 100dvh; overflow: hidden; }
  .app {
    height: 100%; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top main" "lib main";
  }
  .top { grid-area: top; padding: 16px 16px 12px max(16px, env(safe-area-inset-left)); border-right: 1px solid var(--line); }
  .library { grid-area: lib; border-right: 1px solid var(--line); padding: 0 8px 0 max(16px, env(safe-area-inset-left)); }
  .filters { padding-right: 8px; }
  .list { overflow-y: auto; min-height: 0; flex: 1; padding: 0 6px 20px 0; overscroll-behavior: contain; }
  .main {
    grid-area: main; overflow-y: auto; display: grid; gap: 16px; align-content: start;
    padding: 16px max(20px, env(safe-area-inset-right)) 32px 20px;
  }
  .main > * { width: 100%; max-width: 1240px; margin: 0 auto; }
  /* keep the stage plus transport inside the window on short screens */
  .stage { max-height: calc(100dvh - 130px); }
}
@media (min-width: 760px) and (max-width: 1100px) {
  :root { --side: 290px; }
  .hint { display: none; }
  .transport { grid-template-columns: auto 1fr auto; gap: 8px 12px; }
  .exposure { grid-column: 1 / 3; grid-row: 2; }
  .exposure input { width: 100%; }
  .dl { grid-column: 3; grid-row: 2; }
}

/* ---------- narrow: sticky player, list scrolls under it ---------- */
@media (max-width: 759.98px) {
  .app { display: flex; flex-direction: column; }
  .main { display: contents; }
  .top { order: 0; padding: max(12px, env(safe-area-inset-top)) 16px 10px; }
  .brand span { font-size: 26px; }
  .brand svg { width: 26px; height: 26px; }
  .player {
    order: 1; position: sticky; top: 0; z-index: 5; gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 12px 10px; background: var(--night);
    box-shadow: 0 10px 18px -8px rgba(0, 0, 0, 0.9); border-bottom: 1px solid var(--line);
  }
  .library { order: 2; padding: 14px 16px 8px; }
  .extras { order: 3; padding: 8px 16px max(32px, env(safe-area-inset-bottom)); }
  .about { display: none; }
  .stage { border-radius: 8px; max-height: 42vh; }
  .now { left: 12px; top: 10px; }
  .now .name { font-size: 20px; }
  .views { right: 8px; top: 8px; gap: 4px; }
  .views button { padding: 4px 8px; font-size: 12px; }
  .hint { display: none; }
  .transport { grid-template-columns: auto 1fr auto; gap: 6px 10px; padding: 8px 10px; border-radius: 8px; }
  .play { width: 38px; height: 38px; }
  .exposure { grid-column: 1 / 3; grid-row: 2; }
  .exposure input { width: 100%; }
  .dl { grid-column: 3; grid-row: 2; padding: 4px 10px; font-size: 12px; }
  .time { font-size: 12px; }
  .item { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
