:root {
  color-scheme: dark;
  --bg: #080b0c;
  --surface: #101415;
  --surface-2: #171c1d;
  --line: #2a3132;
  --line-bright: #3b4546;
  --text: #f0f4f2;
  --muted: #8b9693;
  --accent: #d9ff43;
  --accent-dark: #151a08;
  --danger: #ff725e;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 85% -10%, #1b2221 0, transparent 32rem), var(--bg); }
button, input, select { font: inherit; }
button { color: inherit; }
.app-shell { width: min(1440px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 32px 32px; }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 1rem; line-height: 1.1; margin: 0 0 4px; letter-spacing: .08em; text-transform: uppercase; }
.brand p { font-size: .72rem; margin: 0; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.brand-mark { width: 33px; height: 32px; display: flex; align-items: center; gap: 3px; border: 1px solid var(--line-bright); padding: 7px; }
.brand-mark i { width: 2px; background: var(--accent); display: block; }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(5) { height: 7px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 15px; }
.brand-mark i:nth-child(3) { height: 22px; }
.privacy-badge { font: 600 .68rem ui-monospace, SFMono-Regular, Menlo, monospace; color: #aab4b1; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; }
.privacy-badge span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px #d9ff4380; }
main { padding-top: 30px; }
.drop-zone { min-height: 158px; border: 1px dashed #465050; background: linear-gradient(90deg, rgba(217,255,67,.025), transparent 50%); display: flex; align-items: center; gap: 22px; padding: 28px 34px; cursor: pointer; transition: border-color .2s, background .2s, transform .2s; outline: none; }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-dragging { border-color: var(--accent); background: rgba(217,255,67,.04); }
.drop-zone.is-dragging { transform: scale(.997); }
.drop-icon { width: 56px; height: 56px; display: grid; place-items: center; border: 1px solid var(--line-bright); border-radius: 50%; color: var(--accent); }
.drop-icon svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
.drop-copy { display: flex; flex-direction: column; gap: 7px; }
.drop-copy strong { font-size: 1.05rem; font-weight: 600; }
.drop-copy span, .local-note { color: var(--muted); font-size: .85rem; }
.local-note { margin-left: auto; padding-left: 22px; position: relative; }
.local-note::before { content: ""; width: 12px; height: 14px; border: 1px solid var(--muted); position: absolute; left: 0; top: 0; border-radius: 2px; }
.workspace { margin-top: 18px; }
.file-strip { min-height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; background: var(--surface); border: 1px solid var(--line); }
.file-main { display: flex; gap: 13px; align-items: center; min-width: 0; }
.file-icon { font: 700 .62rem ui-monospace, monospace; letter-spacing: .08em; color: var(--accent); border: 1px solid #52601d; padding: 10px 7px; }
.file-copy { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.file-copy strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-copy span { color: var(--muted); font: .75rem ui-monospace, monospace; }
.text-button, .small-button { background: none; border: 1px solid var(--line-bright); padding: 9px 12px; cursor: pointer; font-size: .78rem; }
.text-button:hover, .small-button:hover { border-color: #7b8885; }
.transport-panel { margin-top: 14px; padding: 20px; border: 1px solid var(--line); background: var(--surface); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; }
.play-button { width: 52px; height: 52px; border: 0; display: grid; place-items: center; background: var(--accent); color: #101400; cursor: pointer; }
.play-button:disabled { filter: grayscale(1); opacity: .35; cursor: not-allowed; }
.play-button svg { grid-area: 1/1; width: 23px; fill: currentColor; }
.pause-symbol, .is-playing .play-symbol { display: none; }
.is-playing .pause-symbol { display: block; }
.timeline-area { min-width: 0; }
.time-row { display: flex; justify-content: space-between; color: #c4ccca; font: .76rem ui-monospace, monospace; margin-bottom: 9px; }
.timeline-label { color: #626c69; font-size: .58rem; letter-spacing: .08em; }
input[type="range"] { accent-color: var(--accent); cursor: pointer; }
.seek { --seek-progress: 0%; appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 22px; margin: 0; background: transparent; cursor: ew-resize; }
.seek::-webkit-slider-runnable-track { height: 6px; border-radius: 0; background: linear-gradient(90deg, var(--accent) 0 var(--seek-progress), #303837 var(--seek-progress) 100%); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 4px; height: 18px; margin-top: -6px; border: 0; border-radius: 0; background: #f0f4f2; box-shadow: 0 0 8px #fff8; }
.seek::-moz-range-track { height: 6px; border: 0; border-radius: 0; background: #303837; }
.seek::-moz-range-progress { height: 6px; background: var(--accent); }
.seek::-moz-range-thumb { width: 4px; height: 18px; border: 0; border-radius: 0; background: #f0f4f2; box-shadow: 0 0 8px #fff8; }
.seek:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.master-control { display: grid; grid-template-columns: auto 116px 60px; align-items: center; gap: 10px; }
.master-control label { color: var(--muted); font: .65rem ui-monospace, monospace; letter-spacing: .1em; }
.master-control output { color: #c4ccca; font: .7rem ui-monospace, monospace; text-align: right; }
.meter { height: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 4px 1px 0; overflow: hidden; }
.meter span { display: block; width: 0; background: var(--accent); box-shadow: 0 0 8px #d9ff4355; transition: width .05s linear; }
.analysis-panel { margin-top: 28px; }
.analysis-heading { align-items: center; }
.analysis-controls { display: flex; align-items: center; gap: 22px; }
.analysis-note { color: var(--muted); font: .67rem ui-monospace, monospace; letter-spacing: .05em; }
.display-gain { display: grid; grid-template-columns: auto 100px 50px; align-items: center; gap: 9px; color: #8b9693; font: .65rem ui-monospace, monospace; letter-spacing: .05em; }
.display-gain input { width: 100px; }
.display-gain output { color: var(--accent); text-align: right; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 14px; }
.metric-card { min-width: 0; background: #0d1112; padding: 17px 19px 15px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; left: 0; bottom: 0; width: 100%; height: 2px; background: #38413f; }
.metric-card.metric-primary::after { background: var(--accent); box-shadow: 0 0 12px #d9ff4355; }
.metric-label { color: #8b9693; font: .63rem ui-monospace, monospace; letter-spacing: .1em; }
.metric-label em { color: #66706e; font-style: normal; }
.metric-card div { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.metric-card strong { font: 500 clamp(1.65rem, 3vw, 2.45rem)/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.metric-primary strong { color: var(--accent); }
.metric-card small { color: var(--muted); font: .68rem ui-monospace, monospace; }
.metric-card p { margin: 8px 0 0; color: #66706e; font-size: .68rem; }
.overview-card { margin-top: 12px; background: #0d1112; border: 1px solid var(--line); padding: 18px 20px 14px; }
.overview-title { margin-bottom: 9px; }
.direction-summary { text-align: right; display: flex; flex-direction: column; gap: 5px; }
.direction-summary strong { color: var(--accent); font-size: 1rem; font-weight: 600; }
.direction-summary span { color: var(--muted); font: .64rem ui-monospace, monospace; }
.overview-legend { display: flex; justify-content: flex-end; gap: 15px; padding-bottom: 7px; }
.overview-legend span { position: relative; padding-left: 13px; color: #75807d; font: .6rem ui-monospace, monospace; }
.overview-legend span::before { content: ""; position: absolute; left: 0; top: 4px; width: 8px; height: 2px; background: currentColor; }
.overview-legend .legend-l { color: var(--accent); }
.overview-legend .legend-r { color: #55bfff; }
.overview-legend .legend-position { color: #e5ebe8; }
.overview-card canvas { display: block; width: 100%; background: #090c0d; cursor: crosshair; touch-action: none; }
.overview-card canvas:hover { box-shadow: inset 0 0 0 1px #4b5653; }
.overview-card canvas:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
#overviewCanvas { height: 176px; }
#directionCanvas { height: 78px; margin-top: 3px; }
.overview-axis { display: flex; justify-content: space-between; padding-top: 7px; color: #59625f; font: .58rem ui-monospace, monospace; }
.overview-caption { margin: 9px 0 0; color: #68726f; font-size: .68rem; }
.scope-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 12px; margin-top: 12px; }
.scope-card { min-width: 0; background: #0d1112; border: 1px solid var(--line); padding: 17px 18px 14px; }
.scope-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.scope-title span { color: #697370; font: .6rem ui-monospace, monospace; letter-spacing: .1em; }
.scope-title h3 { margin: 4px 0 0; font-size: .88rem; font-weight: 550; }
.scope-title output { color: var(--accent); font: 500 1.35rem ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.scope-legend { display: flex; gap: 12px; }
.scope-legend span { position: relative; padding-left: 12px; }
.scope-legend span::before { content: ""; position: absolute; left: 0; top: 4px; width: 7px; height: 2px; background: currentColor; }
.scope-legend .legend-l { color: var(--accent); }
.scope-legend .legend-r { color: #55bfff; }
.spectrum-card canvas { display: block; width: 100%; height: 210px; background: #090c0d; }
.frequency-labels { display: flex; justify-content: space-between; padding: 7px 0 0; color: #59625f; font: .58rem ui-monospace, monospace; }
.phase-body { display: grid; grid-template-rows: 210px auto; gap: 12px; }
.phase-card canvas { width: 100%; height: 210px; display: block; background: #090c0d; }
.correlation-scale, .correlation-caption { display: flex; justify-content: space-between; color: #65706d; font: .56rem ui-monospace, monospace; }
.correlation-track { height: 8px; margin: 4px 0 6px; position: relative; background: linear-gradient(90deg, #ff725e 0 48%, #47504e 48% 51%, var(--accent) 51% 100%); }
.correlation-track b { position: absolute; left: 50%; top: -2px; width: 1px; height: 12px; background: #d8dddb; }
.correlation-track i { position: absolute; left: 100%; top: -4px; width: 2px; height: 16px; background: #fff; box-shadow: 0 0 8px #fff; transform: translateX(-1px); transition: left .08s linear; z-index: 1; }
.correlation-caption span:last-child { margin-left: auto; }
.routing-panel { margin-top: 28px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line-bright); }
.eyebrow { margin: 0 0 6px; color: var(--accent); font: 600 .65rem ui-monospace, monospace; letter-spacing: .13em; }
.section-heading h2 { margin: 0; font-size: 1.25rem; font-weight: 550; }
.heading-actions { display: flex; gap: 8px; }
.small-button.accent { color: var(--accent); border-color: #58671b; }
.export-controls { display: flex; gap: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
.export-controls select { color: var(--text); background: var(--surface-2); border: 1px solid var(--line-bright); padding: 8px 28px 8px 10px; font-size: .76rem; }
.export-button { display: flex; align-items: center; gap: 7px; border-color: #728426; color: var(--accent); }
.export-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.export-button:disabled { opacity: .35; cursor: not-allowed; }
.export-status { padding: 12px 14px; border: 1px solid var(--line); border-top: 0; background: #0d1112; }
.export-status div { display: flex; justify-content: space-between; margin-bottom: 8px; color: #9da6a4; font: .68rem ui-monospace, monospace; }
.export-status output { color: var(--accent); }
.export-status progress { display: block; width: 100%; height: 4px; appearance: none; -webkit-appearance: none; border: 0; background: #303837; }
.export-status progress::-webkit-progress-bar { background: #303837; }
.export-status progress::-webkit-progress-value { background: var(--accent); }
.export-status progress::-moz-progress-bar { background: var(--accent); }
.route-labels, .route-row { display: grid; grid-template-columns: 46px minmax(92px, 1fr) minmax(108px, .8fr) minmax(108px, .8fr) minmax(170px, 1.25fr) minmax(110px, 1fr) 36px; gap: 10px; align-items: center; }
.route-labels { padding: 13px 14px 7px; color: #67716f; font: .6rem ui-monospace, monospace; letter-spacing: .08em; }
.route-row { min-height: 68px; padding: 10px 14px; border: 1px solid var(--line); border-top: 0; background: #0d1112; transition: background .15s, border-color .15s; }
.route-row:first-child { border-top: 1px solid var(--line); }
.route-row.enabled { background: linear-gradient(90deg, rgba(217,255,67,.045), #0d1112 25%); border-left-color: var(--accent); }
.route-name strong { display: block; font-size: .9rem; }
.route-name span { color: var(--muted); font: .67rem ui-monospace, monospace; }
.toggle { position: relative; width: 34px; height: 19px; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { display: block; width: 100%; height: 100%; border: 1px solid #4c5654; border-radius: 12px; cursor: pointer; }
.toggle span::after { content: ""; display: block; width: 11px; height: 11px; margin: 3px; border-radius: 50%; background: #68726f; transition: transform .15s, background .15s; }
.toggle input:checked + span { border-color: #738424; }
.toggle input:checked + span::after { transform: translateX(15px); background: var(--accent); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.route-row select { width: 100%; padding: 9px 28px 9px 9px; color: var(--text); background: var(--surface-2); border: 1px solid #343d3c; border-radius: 2px; }
.gain-wrap { display: flex; align-items: center; gap: 7px; }
.gain-wrap input { width: 100%; min-width: 50px; }
.gain-wrap output { width: 45px; color: var(--muted); font: .65rem ui-monospace, monospace; text-align: right; }
.remove-button { border: 0; background: transparent; color: #65706d; font-size: 1.2rem; cursor: pointer; width: 32px; height: 32px; }
.remove-button:hover { color: var(--danger); }
.statusbar { display: flex; justify-content: space-between; padding: 14px 3px; color: #68726f; font: .65rem ui-monospace, monospace; letter-spacing: .04em; }
.statusbar span:first-child { color: #9ba5a2; }
.statusbar i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
.empty-hint { display: flex; justify-content: center; align-items: center; gap: 24px; margin: 40px auto; color: var(--muted); }
.empty-hint div { display: flex; align-items: center; gap: 9px; font-size: .78rem; }
.empty-hint b { font: .7rem ui-monospace, monospace; color: #59615f; }
.empty-hint i { width: 40px; height: 1px; background: var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: calc(100% - 32px); padding: 12px 16px; background: #242a2a; border: 1px solid #4b5653; box-shadow: 0 12px 38px #0009; font-size: .84rem; transition: .2s; z-index: 10; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: #8c483e; color: #ffc0b7; }

@media (max-width: 900px) {
  .analysis-controls { align-items: flex-end; flex-direction: column; gap: 10px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scope-grid { grid-template-columns: 1fr; }
  .route-labels { display: none; }
  .heading-actions { flex-wrap: wrap; }
  .export-controls { width: 100%; padding: 8px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .export-controls select, .export-controls button { flex: 1; }
  .route-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 10px; }
  .route-row, .route-row:first-child { grid-template-columns: 40px 1fr 36px; border: 1px solid var(--line); padding: 14px; gap: 10px; }
  .route-name { grid-column: 2; }
  .route-row .channel-select, .route-row .mode-select, .route-row .gain-wrap { grid-column: 1 / -1; }
  .remove-button { grid-column: 3; grid-row: 1; }
}
@media (max-width: 680px) {
  .app-shell { padding: 0 16px 24px; }
  .topbar { min-height: 76px; }
  .privacy-badge { font-size: 0; }
  .privacy-badge::after { content: "LOCAL ONLY"; font-size: .62rem; }
  .drop-zone { min-height: 180px; padding: 24px; flex-direction: column; text-align: center; gap: 14px; }
  .local-note { margin: 0; }
  .transport-panel { grid-template-columns: auto 1fr; gap: 16px; }
  .master-control { grid-column: 1 / -1; grid-template-columns: auto 1fr 58px; }
  .route-list { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; gap: 12px; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions button { flex: 1; }
  .export-controls { flex-direction: column; }
  .empty-hint { gap: 10px; }
  .empty-hint i { width: 12px; }
  .file-strip { align-items: flex-start; gap: 10px; }
  .text-button { white-space: nowrap; }
  .timeline-label { display: none; }
  .metric-card { padding: 14px; }
  .metric-card strong { font-size: 1.55rem; }
  .analysis-note { display: none; }
  .analysis-controls { width: 100%; align-items: flex-start; }
  .display-gain { width: 100%; grid-template-columns: auto 1fr 50px; }
  .display-gain input { width: 100%; }
  .overview-title { align-items: flex-start; flex-direction: column; gap: 10px; }
  .direction-summary { text-align: left; }
  #overviewCanvas { height: 150px; }
  #directionCanvas { height: 72px; }
  .spectrum-card canvas, .phase-card canvas { height: 180px; }
  .phase-body { grid-template-rows: 180px auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
