:root {
  color-scheme: dark;
  --bg: #111111;
  --panel: #1b1b1d;
  --fg: #f0eae8;
  --fg-dim: #8c8885;
  --accent: #cc3322;
  --accent-soft: rgba(204, 51, 34, .16);
  --line: #2c2c2f;
  --wave-bg: #0a0a0b;
  --wave: #8f8a87;
  --playhead: #f0eae8;
  --marker: #cc3322;
  --loop-on: rgba(204, 51, 34, .18);
  --loop-off: rgba(240, 234, 232, .06);
  --sel: #2a1e1c;
  --meter-bg: #1f1f22;
  --grid: #26262a;
  --spec-fill: rgba(204, 51, 34, .22);
  --spec-hold: rgba(240, 234, 232, .3);
  --gonio: rgba(240, 234, 232, .6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.4 'Inter', system-ui, -apple-system, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
header, footer, main { padding: 0 20px; }
header { display: flex; align-items: center; gap: 14px; padding-top: 12px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand svg { height: 36px; width: 36px; display: block; }
.wordmark { font-size: 18px; font-weight: 300; letter-spacing: .12em; line-height: 1; padding-top: 2px; }
.wordmark .p { color: var(--accent); }
.wordmark .s { color: #999999; }
header h1 { border-left: 1px solid var(--line); padding: 3px 0 3px 14px; margin-left: 2px; letter-spacing: .25em; }
h1 { font-size: 12px; font-weight: 500; margin: 0; text-transform: uppercase; color: var(--fg-dim); }
main { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
footer { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 10px 20px 16px; font-size: 12px; border-top: 1px solid var(--line); }
footer a { color: var(--fg); text-decoration: none; }
footer a:hover { color: var(--accent); }
.dim { color: var(--fg-dim); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
kbd {
  font: 11px ui-monospace, Menlo, monospace; color: var(--fg-dim);
  border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 2px;
}

.drop {
  border: 1px dashed var(--line); border-radius: 4px; padding: 14px; text-align: center; color: var(--fg-dim);
}
.drop.over { border-color: var(--accent); color: var(--fg); }
.link { color: var(--fg); cursor: pointer; text-decoration: underline; text-decoration-color: var(--accent); }
.link input { display: none; }

.tracks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tracks li {
  display: flex; align-items: center; gap: 12px; padding: 6px 10px;
  background: var(--panel); border-radius: 3px; cursor: pointer; border: 1px solid transparent;
}
.tracks li.sel { background: var(--sel); border-color: var(--accent); }
.tracks li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks li .meta { color: var(--fg-dim); font-size: 12px; white-space: nowrap; }
.tracks li .meta .hot { color: var(--accent); }
.tracks li .rm { background: none; border: none; color: var(--fg-dim); font-size: 16px; cursor: pointer; padding: 0 4px; }
.tracks li .rm:hover { color: var(--accent); }

.wave-wrap { height: 150px; background: var(--wave-bg); border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
#wave { width: 100%; height: 100%; display: block; touch-action: none; }

.row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.row label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.spacer { flex: 1; }
input[type="number"] { width: 90px; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 3px; padding: 3px 6px; }
select { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 3px; padding: 3px 6px; max-width: 220px; }
input[type="checkbox"] { accent-color: var(--accent); }
button {
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 3px;
  padding: 5px 12px; cursor: pointer; font: inherit;
}
button:hover { border-color: var(--fg-dim); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; min-width: 70px; }
button.on { background: var(--sel); border-color: var(--accent); }
#time { min-width: 190px; }

/* volume */
.vol { display: flex; flex-direction: column; width: 220px; }
.vol-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg-dim); }
.vol-top #volOut { color: var(--fg); }
.vol input[type="range"] { width: 100%; margin: 2px 0 0; accent-color: var(--accent); }
.vol-scale { position: relative; height: 12px; font: 9px ui-monospace, Menlo, monospace; color: var(--fg-dim); margin: 0 7px; }
.vol-scale span { position: absolute; transform: translateX(-50%); }

/* meters */
.meters { display: grid; grid-template-columns: 250px 1fr 210px; gap: 10px; height: 210px; }
.meter-block { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; position: relative; }
.meter-block canvas { width: 100%; height: 100%; display: block; }
.peak-block { display: grid; grid-template-columns: 110px 1fr; }
.readouts { margin: 0; padding: 10px 10px 8px 4px; display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; align-content: start; font-size: 12px; }
.readouts dt { color: var(--fg-dim); }
.readouts dd { margin: 0; text-align: right; white-space: nowrap; }
.readouts dd small { color: var(--fg-dim); font-size: 9px; }
.readouts dd .bad { color: var(--accent); }
@media (max-width: 900px) {
  .meters { grid-template-columns: 1fr 1fr; height: auto; }
  .spec-block { grid-column: 1 / -1; height: 180px; }
  .peak-block, .gonio-block { height: 210px; }
}

.blind { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.abx button { font-size: 18px; font-weight: 700; min-width: 48px; }
.abx button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.vote button { margin-right: 4px; }
#blindResult.ok { color: #3fae5a; }
#blindResult.bad { color: var(--accent); }

/* help */
#helpBtn { border-radius: 50%; width: 28px; height: 28px; padding: 0; font-weight: 700; }
dialog {
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 4px;
  padding: 0; width: min(760px, calc(100vw - 40px)); max-height: calc(100vh - 60px);
  box-shadow: 0 25px 80px rgba(0, 0, 0, .5);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.help-head { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.help-head h2 { margin: 0; font-size: 15px; letter-spacing: .06em; }
.help-head button { font-size: 18px; line-height: 1; padding: 2px 10px; }
.help-body { padding: 8px 20px 20px; overflow-y: auto; max-height: calc(100vh - 130px); }
.help-body h2, .help-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin: 18px 0 4px; }
.help-body p, .help-body li { margin: 0 0 6px; color: #cfcac7; }
.help-body ul { padding-left: 18px; margin: 0; }
.help-body em { font-style: normal; color: var(--fg); }
.keys { border-collapse: collapse; width: 100%; }
.keys td, .keys th { padding: 3px 12px 3px 0; vertical-align: top; text-align: left; }
.keys th { font-weight: 500; color: var(--fg-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.keys td:nth-child(odd), .keys th:nth-child(odd) { white-space: nowrap; }
.keys td:nth-child(even) { color: #cfcac7; }

/* analysis report */
.tracks li .analyze { font-size: 12px; padding: 3px 10px; }
#report { width: min(1040px, calc(100vw - 40px)); }
.report-actions { display: flex; gap: 8px; align-items: center; }
.report-actions button { font-size: 13px; }
#reportName { font-weight: 400; font-size: 13px; margin-left: 10px; }
.report-progress { padding: 14px 20px; display: flex; align-items: center; gap: 12px; }
.report-progress .bar { flex: 1; height: 6px; background: var(--meter-bg); border-radius: 3px; overflow: hidden; }
.report-progress .bar div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.report-body { padding-top: 14px; }
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 900px) { .report-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .report-grid { grid-template-columns: 1fr; } }
#reportInfo { display: block; font-size: 12px; font-weight: 400; margin-top: 2px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px 8px; }
.card h3 { margin: 0 0 6px !important; }
.card table { border-collapse: collapse; width: 100%; font-size: 12px; }
.card td { padding: 2px 6px 2px 0; vertical-align: top; }
.card td:first-child { white-space: nowrap; }
.card td.val { text-align: right; white-space: nowrap; color: var(--fg); }
.card td.note { font-size: 11px; padding-left: 8px; }
.card.plot { margin-top: 10px; }
.card.plot canvas { width: 100%; height: 180px; display: block; }

/* desktop-only gate */
.gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.gate-card { max-width: 420px; width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.gate-card svg { width: 72px; height: 72px; margin-bottom: 4px; }
.gate-card .wordmark { font-size: 22px; }
.gate-sub { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--fg-dim); margin-bottom: 14px; }
.gate-lead { font-size: 16px; color: var(--fg); margin: 0 0 4px; }
.gate-card p { margin: 0; color: #cfcac7; font-size: 14px; line-height: 1.5; }
.gate-actions { display: flex; gap: 16px; align-items: center; margin-top: 14px; }
.gate-link { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--accent); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; padding-bottom: 2px; }
.gate-continue { font-size: 12px; margin-top: 18px; text-decoration: underline; color: var(--fg-dim); }
body.gated > header, body.gated > main, body.gated > footer { display: none; }
