:root {
  --bg: #08090d;
  --bg2: #0d0f15;
  --panel: rgba(20, 22, 31, 0.78);
  --panel-solid: #14161f;
  --line: #232634;
  --line2: #2d3142;
  --text: #e9eaf0;
  --muted: #8a8fa3;
  --dim: #5b6074;
  --base: #22d3ee;
  --vocal: #f472b6;
  --drop: #facc15;
  --accent: #a78bfa;
  --grad: linear-gradient(100deg, #22d3ee 0%, #a78bfa 50%, #f472b6 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --r: 16px;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(900px 500px at 95% -5%, rgba(244, 114, 182, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.45 "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 28px;
  background: rgba(8, 9, 13, 0.75);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; letter-spacing: -0.02em; font-weight: 600; }
.brand b { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-left: 1px; }
.logo { width: 30px; height: 30px; }
.tabs { display: flex; gap: 4px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.tab { background: none; border: 0; padding: 7px 16px; border-radius: 9px; color: var(--muted); cursor: pointer; font-weight: 500; transition: .15s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-solid); color: var(--text); box-shadow: 0 0 0 1px var(--line2) inset, 0 4px 14px rgba(0,0,0,.35); }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.status.ok .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.status.bad .dot { background: var(--bad); }

main { max-width: 1440px; margin: 0 auto; padding: 24px 28px 60px; }
.tabpage { display: none; }
.tabpage.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ------------------------------------------------ cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
  min-width: 0;
}
h2 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 0 0 14px; font-weight: 650; letter-spacing: .01em; color: #cfd2de; }
h3.mt { margin-top: 22px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.dim { color: var(--dim); }
.spacer { flex: 1; }

.tracks { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.track-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; min-height: 42px; }
.track-title { display: flex; gap: 12px; align-items: center; min-width: 0; }
.track-title > div { min-width: 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.base { background: var(--base); box-shadow: 0 0 12px var(--base); }
.swatch.vocal { background: var(--vocal); box-shadow: 0 0 12px var(--vocal); }
.swatch.drop { background: var(--drop); }
.track-title .swatch { width: 12px; height: 34px; border-radius: 6px; }

/* BPM box */
.bpmbox { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 5px 6px 5px 12px; }
.bpmbox label { font-size: 11px; color: var(--muted); letter-spacing: .08em; font-weight: 600; }
.bpmbox .bpm { width: 78px; background: none; border: 0; font: 600 18px var(--mono); text-align: right; outline: none; padding: 0; }
.bpmbox .bpm::-webkit-inner-spin-button { display: none; }
.bpmbox.detecting .bpm { opacity: .4; }
.bpm-tools { display: flex; gap: 3px; }

/* drop zone */
.drop-zone {
  border: 1.5px dashed var(--line2); border-radius: 14px;
  height: 190px; display: grid; place-items: center; cursor: pointer;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.012) 0 10px, transparent 10px 20px);
  transition: .15s;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background-color: rgba(167, 139, 250, .06); }
.dz-inner { text-align: center; display: grid; gap: 6px; justify-items: center; color: var(--muted); }
.dz-inner svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 4px; }
.dz-inner b { color: var(--text); font-weight: 600; font-size: 15px; }
.dz-inner span { font-size: 12.5px; }
.drop-zone.loading .dz-inner b::after { content: " …"; }

/* waveform */
.wave-wrap { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; height: 150px; }
.wave-wrap.tall { height: 200px; }
.wave { display: block; width: 100%; height: 100%; cursor: crosshair; }
.wave.grab { cursor: grabbing; }
.wave-hint { position: absolute; right: 10px; bottom: 6px; font-size: 11px; color: var(--dim); pointer-events: none; }

.track-transport, .transport { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; flex-wrap: wrap; }
.time { font: 500 13px var(--mono); color: #cfd2de; }
.time-big { font: 600 15px var(--mono); }

/* buttons */
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line2); background: var(--panel-solid); display: grid; place-items: center; cursor: pointer; transition: .15s; padding: 0; }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.big { width: 48px; height: 48px; background: var(--grad); border: 0; color: #0b0c10; box-shadow: 0 6px 24px rgba(167,139,250,.35); }
.icon-btn.big svg { width: 20px; height: 20px; }
.icon-btn .i-pause { display: none; }
.icon-btn.playing .i-play { display: none; }
.icon-btn.playing .i-pause { display: block; }
.ghost, .btnlink { background: transparent; border: 1px solid var(--line2); border-radius: 9px; padding: 6px 12px; cursor: pointer; color: #cfd2de; font-size: 12.5px; transition: .15s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ghost:hover, .btnlink:hover { border-color: var(--accent); color: var(--text); background: rgba(167,139,250,.07); }
.mini { background: var(--panel-solid); border: 1px solid var(--line2); border-radius: 7px; padding: 3px 7px; font-size: 11.5px; color: #cfd2de; cursor: pointer; font-family: var(--mono); }
.mini:hover { border-color: var(--accent); }
.primary { background: var(--grad); color: #0b0c10; border: 0; border-radius: 11px; padding: 10px 18px; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; box-shadow: 0 6px 24px rgba(167,139,250,.25); transition: .15s; white-space: nowrap; }
.primary svg { width: 17px; height: 17px; stroke-width: 2.4; }
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary:disabled { opacity: .35; cursor: not-allowed; transform: none; filter: none; }
.primary.wide { width: 100%; margin-top: 18px; padding: 12px; }

/* fields */
.drop-row { display: grid; grid-template-columns: 1fr 110px 110px; gap: 12px; margin-top: 14px; align-items: end; }
.field { display: grid; gap: 6px; min-width: 0; }
.field.grow { flex: 1; }
.field label, .set label { font-size: 12px; color: var(--muted); font-weight: 550; }
.field label i, .set label i { font-style: normal; color: var(--dim); font-weight: 400; margin-left: 4px; }
.drop-field label { color: var(--drop); }
.ts-row { display: flex; gap: 6px; align-items: center; }
input[type=text], input[type=number] {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding: 7px 10px; outline: none; min-width: 0; transition: .15s;
}
input[type=text]:focus, input[type=number]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(167,139,250,.15); }
.ts { font-family: var(--mono); width: 100%; }
.ts.drop { font-size: 15px; font-weight: 600; color: var(--drop); text-align: center; border-color: rgba(250, 204, 21, .35); }
.ts.bad { border-color: var(--bad) !important; }
.ts-row .ts.drop { flex: 1; }

/* tempo */
.tempo { margin-top: 20px; display: flex; align-items: center; gap: 30px; flex-wrap: wrap; padding: 16px 20px; }
.tempo-main { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 300px; flex-wrap: wrap; }
.tempo-num { display: flex; align-items: baseline; gap: 6px; }
.tempo-num .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.tempo-num b { font: 700 24px var(--mono); }
.tempo-num .unit { color: var(--dim); font-size: 12px; }
.tempo-vs { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line2); color: var(--muted); }
.tempo-vs.ok { color: var(--ok); border-color: rgba(52,211,153,.4); }
.tempo-vs.warn { color: var(--warn); border-color: rgba(251,191,36,.4); }
.tempo-vs.bad { color: var(--bad); border-color: rgba(248,113,113,.4); }
.tempo-msg { margin: 0; color: var(--muted); font-size: 13px; flex-basis: 100%; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; max-width: 440px; }
.switch input { display: none; }
.track-sw { width: 44px; height: 24px; border-radius: 99px; background: var(--line2); position: relative; flex: none; transition: .2s; }
.knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #cfd2de; transition: .2s; }
.switch input:checked + .track-sw { background: var(--accent); }
.switch input:checked + .track-sw .knob { left: 23px; background: #fff; }
.sw-txt { display: grid; }
.sw-txt b { font-weight: 600; font-size: 13.5px; }
.sw-txt i { font-style: normal; color: var(--muted); font-size: 12px; }

/* mix grid */
.mixgrid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; margin-top: 20px; }
.set { margin-bottom: 16px; display: grid; gap: 8px; }
.set.two { grid-template-columns: 1fr 1fr; gap: 12px; }
.set.two > div { display: grid; gap: 6px; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.num { display: flex; align-items: center; background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding-right: 9px; }
.num input { border: 0 !important; box-shadow: none !important; width: 62px; background: none; font-family: var(--mono); text-align: right; padding: 6px 4px 6px 8px; }
.num.wide input { width: 100%; }
.num span { color: var(--dim); font-size: 12px; }
input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: var(--line2); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; padding: 6px 11px; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 12.5px; white-space: nowrap; }
.seg button.on { background: var(--panel-solid); color: var(--text); box-shadow: 0 0 0 1px var(--line2) inset; }
.seg.small button { padding: 4px 9px; font-size: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; color: #cfd2de; font-size: 13px; margin-top: 10px; cursor: pointer; }
.check input { accent-color: var(--accent); margin-top: 3px; }

.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.result-head h3 { margin: 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { box-shadow: none; }
.empty-result { border: 1.5px dashed var(--line2); border-radius: 12px; padding: 50px 20px; text-align: center; color: var(--muted); }
.pill-toggle { display: inline-flex; cursor: pointer; }
.pill-toggle input { display: none; }
.pill-toggle span { border: 1px solid var(--line2); border-radius: 99px; padding: 5px 12px; font-size: 12.5px; color: var(--muted); transition: .15s; }
.pill-toggle input:checked + span { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.5); color: #fecaca; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.fact { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; font-size: 12px; color: var(--muted); }
.fact b { color: var(--text); font-family: var(--mono); font-weight: 600; margin-left: 4px; }
.fact.warn { border-color: rgba(251,191,36,.35); color: #fde68a; }
.export { display: flex; gap: 12px; align-items: end; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.export .primary { padding: 10px 20px; height: 40px; }
.export-msg { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 18px; }
.export-msg.ok { color: var(--ok); }
.export-msg.bad { color: var(--bad); }

/* extractor */
.ex-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 20px; align-items: start; }
.ex-file { margin-top: 12px; padding: 10px 14px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
.ex-file span { color: var(--muted); }
.engines { display: grid; gap: 10px; }
.engine { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line2); border-radius: 12px; cursor: pointer; transition: .15s; background: var(--bg2); }
.engine:hover { border-color: var(--accent); }
.engine:has(input:checked) { border-color: var(--accent); background: rgba(167,139,250,.07); box-shadow: 0 0 0 3px rgba(167,139,250,.12); }
.engine input { accent-color: var(--accent); margin-top: 3px; }
.engine b { font-weight: 600; }
.engine p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 99px; background: var(--grad); color: #0b0c10; margin-left: 6px; vertical-align: 1px; }
.tag.dim { background: var(--line2); color: var(--muted); }
.eng-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eng-state.ok { color: var(--ok) !important; }
.progress { margin-top: 16px; display: grid; gap: 8px; }
.progress .bar { height: 8px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .3s; }
.progress .ptxt { font-size: 12.5px; color: var(--muted); }
.ex-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* toast + dialog */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--panel-solid); border: 1px solid var(--line2); padding: 10px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(248,113,113,.5); }
dialog { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line2); border-radius: 16px; padding: 24px; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
dialog h3 { font-size: 17px; margin-bottom: 6px; color: var(--text); }
dialog p { color: var(--muted); margin: 0 0 14px; }
.dl-info { display: grid; grid-template-columns: 80px 1fr; gap: 6px 12px; font-size: 13px; margin: 0 0 18px; }
.dl-info dt { color: var(--muted); }
.dl-info dd { margin: 0; word-break: break-all; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 1100px) {
  .tracks, .mixgrid, .ex-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .drop-row { grid-template-columns: 1fr 1fr; }
  .drop-row .drop-field { grid-column: 1 / -1; }
  .sub { max-width: 200px; }
}
.engines.two { grid-template-columns: 1fr 1fr; margin-top: 12px; }
.note { margin: 10px 0 0; color: var(--dim); font-size: 12px; }
.ghost.wide { width: 100%; justify-content: center; margin-top: 18px; padding: 11px; }
h3 .tag { vertical-align: 1px; }
.eng-state { margin: -6px 0 0; color: var(--muted); font-size: 12.5px; }
