:root {
  --bg: #0f1012;
  --panel: #17181b;
  --panel-2: #1e2024;
  --line: #2a2c31;
  --text: #ececee;
  --muted: #8b8d94;
  --accent: #f2f2f2;
  --meta-w: clamp(290px, 34vw, 400px);
  --row-h: 40px;
  --gap: 3px;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { -webkit-font-smoothing: antialiased; }
#app { max-width: 1400px; margin: 0 auto; padding: 14px 24px 24px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.top { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; }
.brand { color: var(--muted); text-decoration: none; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.brand:hover { color: var(--text); }

#landing { padding: 80px 0; text-align: center; }

.titles { margin-bottom: 6px; }
.artist { margin: 0 0 2px; color: var(--muted); font-size: 13px; letter-spacing: .04em; }
h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
.notes { margin: 6px 0 0; color: var(--muted); white-space: pre-wrap; max-width: 70ch; line-height: 1.45; font-size: 14px; }

.loading { padding: 40px 0; max-width: 480px; }
.loading .bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
#loadbar { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.loading p { font-size: 13px; margin-top: 10px; }
.error { color: #ff8787; }

/* transport */
.transport {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0; margin-bottom: 4px;
  background: var(--bg);
}
button { font: inherit; color: inherit; cursor: pointer; }
.play {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: var(--accent); color: #111; display: grid; place-items: center; flex: none;
}
.play svg { width: 20px; height: 20px; fill: currentColor; }
.play .i-pause, .playing .play .i-play { display: none; }
.playing .play .i-pause { display: block; }
.time { font-variant-numeric: tabular-nums; font-size: 15px; min-width: 96px; }
.time .sep { color: var(--muted); margin: 0 6px; }
.seg { display: flex; background: var(--panel-2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--accent); color: #111; font-weight: 600; }
.seg button:not(.on):hover { color: var(--text); }
.zoom { margin-left: auto; }
.zoom button { padding: 6px 11px; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.ghost:hover { color: var(--text); border-color: var(--muted); }

/* tracks */
#tracks { display: flex; flex-direction: column; gap: var(--gap); --p: 0; }
.track {
  display: grid; grid-template-columns: var(--meta-w) 1fr; height: var(--row-h);
  background: var(--panel); border-radius: 6px; overflow: hidden;
  transition: opacity .15s;
  position: relative;
}
.track.mixrow { height: calc(var(--row-h) * 1.5); background: var(--panel-2); margin-bottom: 5px; }
.track.dragging { z-index: 4; opacity: 1 !important; box-shadow: 0 6px 24px rgba(0,0,0,.6); outline: 1px solid var(--line); transition: none; }
.meta {
  display: flex; align-items: center; gap: 7px; padding: 0 10px 0 4px; min-width: 0;
  border-right: 1px solid var(--line);
  --ctl-h: min(22px, calc(var(--row-h) - 6px));
}
.grip {
  width: 16px; flex: none; align-self: stretch; display: grid; place-items: center;
  color: #62656c; cursor: grab; user-select: none; touch-action: none; font-size: 0;
}
.grip::before {
  content: ""; width: 7px; height: 12px;
  background-image: radial-gradient(circle, currentColor 1.1px, transparent 1.4px);
  background-size: 3.5px 4px;
}
.grip:hover { color: var(--text); }
.mixrow .grip { cursor: default; visibility: hidden; }
.dragging .grip { cursor: grabbing; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.name { flex: 1; min-width: 0; font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mixrow .name { font-size: 14px; }
.meta button {
  flex: none; width: 24px; height: var(--ctl-h); border-radius: 4px; border: 1px solid var(--line);
  background: none; font-size: 10px; font-weight: 700; color: var(--muted); padding: 0;
}
.meta .m.on { background: #e8590c; border-color: #e8590c; color: #fff; }
.meta .s.on { background: #fcc419; border-color: #fcc419; color: #111; }
.vol { flex: none; width: clamp(64px, 7.5vw, 110px); accent-color: var(--c); height: 14px; margin: 0; }
.db {
  flex: none; width: 46px; text-align: right; font: 11px ui-monospace, Menlo, monospace;
  color: var(--muted); font-variant-numeric: tabular-nums; transition: color .3s;
}
.db.unity { color: #6b6e75; }
.db.hot { color: var(--text); transition: none; }

.wave { position: relative; cursor: pointer; touch-action: none; }
.wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.played { position: absolute; inset: 0 auto 0 0; width: calc(var(--p) * 100%); overflow: hidden; }
.played canvas { width: var(--ww); }
.head { position: absolute; top: 0; bottom: 0; left: calc(var(--p) * 100%); width: 1px; background: #fff; opacity: .8; pointer-events: none; }

.track.silent { opacity: .35; }
.mode-mix .track:not(.mixrow) { opacity: .45; }
.mode-mix .track.silent:not(.mixrow) { opacity: .25; }
.mode-stems .track.mixrow { opacity: .45; }

.hint { margin: 10px 0 0; font-size: 11.5px; line-height: 1.9; }
kbd { font: 10.5px ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin: 0 1px; }

@media (max-width: 720px) {
  :root { --meta-w: 1fr; }
  #app { padding: 10px 10px 30px; }
  h1 { font-size: 22px; }
  .track, .track.mixrow { grid-template-columns: 1fr; grid-template-rows: 30px 1fr; height: calc(var(--row-h) + 30px); }
  .track.mixrow { height: calc(var(--row-h) * 1.5 + 30px); }
  .meta { border-right: 0; border-bottom: 1px solid var(--line); --ctl-h: 22px; }
  .vol { width: 90px; }
  .transport { gap: 8px; flex-wrap: wrap; }
  .zoom { margin-left: 0; }
  .hint { display: none; }
}

/* buffering indicator */
.buffering .time::after { content: "Loading…"; margin-left: 10px; color: var(--muted); font-size: 12px; }
.buffering .play { opacity: .7; }

/* send levels */
.primary { background: var(--accent); color: #111; border: 0; border-radius: 8px; padding: 7px 13px; font-size: 13px; font-weight: 600; }
.primary:disabled { opacity: .5; cursor: default; }
dialog#sendbox {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
}
dialog#sendbox::backdrop { background: rgba(0,0,0,.55); }
#sendbox h2 { margin: 0 0 4px; font-size: 18px; }
#sendbox .small { font-size: 12.5px; margin: 0 0 12px; }
#sendbox label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
#sendbox input, #sendbox textarea {
  display: block; width: 100%; margin-top: 4px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: 14px inherit; font-family: inherit; resize: vertical;
}
.sendpreview { max-height: 210px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin-bottom: 10px; font-size: 12.5px; }
.sendpreview div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.sendpreview .db { width: auto; }
.sendpreview .flag { color: #e8590c; font-weight: 700; font-size: 11px; margin-left: 6px; }
.sendpreview .same { color: var(--muted); }
.sendbtns { display: flex; justify-content: flex-end; gap: 8px; }
#sendstatus.ok { color: #69db7c; }
#sendstatus.err { color: #ff8787; }
