[hidden] { display: none !important; }
:root {
  --bg: #0b0d10; --panel: #0e1114; --raise: #14181d; --hover: #191e24;
  --line: #1e232a; --line-2: #2b313a;
  --text: #dfe3e8; --dim: #8a929c; --faint: #5a626c; --accent: #ffb454;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--bg); color: var(--text);
  font: 13px/1.45 var(--sans); -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 500; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
kbd { font: 11px var(--mono); color: var(--faint); border: 1px solid var(--line-2); border-radius: 3px; padding: 0 5px; }

/* ---- Header ---- */
header {
  display: flex; align-items: center; gap: 20px; padding: 0 16px; height: 52px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 9px; padding-right: 20px; border-right: 1px solid var(--line); height: 100%; }
.brand h1 { font-size: 14px; letter-spacing: 0.01em; }
.mark { width: 18px; height: 18px; fill: none; stroke-width: 1.4; }
.mark rect { stroke: var(--faint); }
.mark path { stroke: var(--accent); }
.field { display: flex; align-items: center; gap: 10px; }
.field-label, .knob, .aside-head h2, .cols {
  font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500;
}
select {
  appearance: none; -webkit-appearance: none; background: transparent; border: 0; padding: 4px 18px 4px 0;
  max-width: 300px; text-overflow: ellipsis; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a929c' stroke-width='1.3'/%3E%3C/svg%3E") right center / 9px no-repeat;
}
select option { background: var(--raise); }
#search {
  flex: 1 1 220px; max-width: 400px; display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg);
}
#search:focus-within { border-color: var(--faint); }
#search svg { width: 14px; height: 14px; fill: none; stroke: var(--faint); stroke-width: 1.5; flex: none; }
#q { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 0; }
#q::placeholder { color: var(--faint); }
#search:focus-within kbd { display: none; }
.tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.knob { display: flex; align-items: center; gap: 10px; }
input[type="range"]#haze { width: 88px; accent-color: var(--dim); }
button.ghost, button.primary {
  height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-2); background: transparent;
}
button.ghost:hover { background: var(--hover); }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 500; }
button.primary:hover { background: #fff; }
button.primary:disabled { opacity: 0.5; cursor: default; }
button.icon {
  width: 30px; height: 30px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 6px; background: transparent; color: var(--dim);
}
button.icon:hover { background: var(--hover); color: var(--text); }

/* ---- Stage ---- */
main { display: grid; grid-template-columns: 1fr 300px; min-height: 0; }
#stage { position: relative; min-width: 0; min-height: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#status {
  position: absolute; left: 16px; top: 12px; margin: 0; pointer-events: none;
  font: 11px var(--mono); color: var(--faint); letter-spacing: 0.02em;
}
#views {
  position: absolute; right: 16px; bottom: 16px; display: flex; padding: 2px; gap: 2px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px;
}
#views button { height: 26px; padding: 0 11px; border: 0; border-radius: 4px; background: transparent; color: var(--dim); font-size: 12px; }
#views button:hover { color: var(--text); }
#views button.on { background: var(--hover); color: var(--text); }
#tip {
  position: absolute; pointer-events: none; white-space: nowrap;
  background: var(--raise); border: 1px solid var(--line-2); border-radius: 4px; padding: 4px 8px;
  font: 11px var(--mono); color: var(--text);
}
#loading, #nothing {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); margin: 0;
  display: flex; align-items: center; gap: 8px; color: var(--dim);
  background: var(--raise); border: 1px solid var(--line-2); border-radius: 4px; padding: 5px 10px; font-size: 12px;
}
.spinner { width: 11px; height: 11px; border: 1.5px solid var(--line-2); border-top-color: var(--dim); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.sheet {
  position: absolute; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 18px; box-shadow: 0 16px 40px rgb(0 0 0 / 0.5); display: grid; gap: 12px;
}
.sheet h2 { font-size: 14px; color: var(--text); }
.sheet p { margin: 0; color: var(--dim); }
.sheet .small, .small { font-size: 12px; color: var(--faint); }
.sheet .row { display: flex; gap: 8px; align-items: center; }
.sheet .row.between { justify-content: space-between; }
#intro { left: 16px; bottom: 16px; width: min(400px, calc(100% - 32px)); }
#intro ol { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
#intro li { counter-increment: s; display: grid; grid-template-columns: 22px 1fr; color: var(--dim); }
#intro li::before { content: counter(s, decimal-leading-zero); font: 11px/1.9 var(--mono); color: var(--faint); }
#intro b { color: var(--text); font-weight: 500; }
#upload { right: 16px; top: 16px; width: min(380px, calc(100% - 32px)); }
#upload-file { color: var(--dim); font-size: 12px; }
#upload-file::file-selector-button {
  margin-right: 10px; height: 28px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px;
  background: transparent; color: var(--text); cursor: pointer;
}
#upload .check { display: flex; gap: 8px; align-items: flex-start; }
#upload .check input { accent-color: var(--accent); margin-top: 3px; }
#upload-status { color: var(--accent); min-height: 1.2em; font-size: 12px; }
#upload-status:empty { display: none; }
progress { width: 100%; height: 4px; appearance: none; border: 0; background: var(--line-2); border-radius: 2px; }
progress::-webkit-progress-bar { background: var(--line-2); border-radius: 2px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }

/* ---- Side panel ---- */
aside { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 14px 0 20px; }
.aside-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 16px 10px; }
.aside-head h2 { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
#tracks-count { font: 11px var(--mono); color: var(--faint); }
#search-note { margin: 0 16px 10px; font-size: 12px; color: var(--dim); }
.cols, #tracks li { display: grid; grid-template-columns: 14px 1fr 52px 56px; gap: 10px; align-items: center; padding: 0 16px; }
.cols { padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 10px; }
.cols span:nth-child(n+3) { text-align: right; }
#tracks, #others { list-style: none; margin: 0; padding: 0; }
#tracks li { padding-top: 9px; padding-bottom: 9px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
#tracks li:hover { background: var(--hover); }
#tracks li.on { background: var(--raise); }
#tracks li.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--c); }
#tracks li.off { opacity: 0.35; }
.sw { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.who { min-width: 0; }
.who b { display: block; font-weight: 500; }
.who small { display: block; color: var(--faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num { font: 12px var(--mono); text-align: right; color: var(--dim); }
.num.strong { color: var(--text); }
.span { grid-column: 2 / -1; height: 2px; background: var(--line); position: relative; margin-top: 2px; }
.span > i { position: absolute; top: 0; bottom: 0; background: var(--c); opacity: 0.8; }
#tracks li:has(.match) .span { display: none; }
.match { grid-column: 2 / -1; display: flex; align-items: center; gap: 8px; font: 10px var(--mono); color: var(--faint); }
.match > span { flex: 1; height: 2px; background: var(--line); position: relative; }
.match > span > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--text); }
#empty { margin: 12px 16px; color: var(--faint); }
#elsewhere { margin-top: 22px; }
#others li { border-bottom: 1px solid var(--line); }
#others li:first-child { border-top: 1px solid var(--line); }
#others button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left;
  padding: 9px 16px; background: none; border: 0;
}
#others button:hover { background: var(--hover); }
#others b { font-weight: 500; text-transform: capitalize; }
#others small { font: 12px var(--mono); color: var(--dim); text-align: right; }
#others .match { grid-column: 1 / -1; }

/* ---- Timeline ---- */
footer {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px 8px;
  border-top: 1px solid var(--line); background: var(--panel);
}
#play svg { width: 14px; height: 14px; fill: currentColor; }
#play .i-pause, #play.on .i-play { display: none; }
#play.on .i-pause { display: block; }
#timeline { position: relative; flex: 1; height: 50px; }
#bars { position: absolute; left: 0; right: 0; top: 0; height: 34px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
#bars i { position: absolute; height: 3px; border-radius: 1px; background: var(--c); min-width: 2px; opacity: 0.9; }
#ruler { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; }
#ruler span { position: absolute; top: 0; transform: translateX(-50%); font: 10px var(--mono); color: var(--faint); }
#ruler span:first-child { transform: none; }
#ruler span::before { content: ""; position: absolute; left: 50%; top: -5px; height: 3px; border-left: 1px solid var(--line-2); }
#ruler span:first-child::before { left: 0; }
#scrub { position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 34px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: ew-resize; }
#scrub::-webkit-slider-runnable-track { background: transparent; height: 100%; }
#scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 2px; height: 34px; background: var(--text); box-shadow: 0 0 0 3px rgb(11 13 16 / 0.6); cursor: ew-resize; }
#scrub::-moz-range-track { background: transparent; }
#scrub::-moz-range-thumb { width: 2px; height: 34px; background: var(--text); border: 0; border-radius: 0; cursor: ew-resize; }
.clock { width: 110px; text-align: right; font: 12px var(--mono); white-space: nowrap; }
#clock { color: var(--text); }
#dur { color: var(--faint); }

@media (max-width: 900px) {
  .knob, kbd, .clip-field .field-label { display: none; }
  .brand { padding-right: 12px; }
  header { gap: 12px; }
}
@media (max-width: 760px) {
  header { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 10px; }
  .brand { border: 0; padding: 0; }
  #search { flex-basis: 100%; max-width: none; order: 5; }
  select { max-width: 52vw; }
  main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  aside { border-left: 0; border-top: 1px solid var(--line); max-height: 34vh; }
  .clock { width: auto; }
}
