/* Redline — design tokens + all views.
   Color discipline: cyan = the model's perception, gold = downbeats, red = redlines/issues ONLY,
   green = resolved/success. Numbers always tabular mono. The waveform is the hero. */
:root {
  --bg: #0b0e13; --panel: #11151d; --panel2: #161b25; --line: #232a37; --line2: #2d3648;
  --text: #e8edf6; --dim: #8b95a7; --dimmer: #5c6579;
  --cyan: #7fd8f7; --cyan-soft: rgba(127, 216, 247, .14);
  --gold: #ffcd78; --red: #ff4d5e; --red-soft: rgba(255, 77, 94, .12);
  --green: #43d9ad; --amber: #ffb454; --amber-soft: rgba(255, 180, 84, .12);
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, monospace;
  --ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--ui); overflow: hidden; }
.hidden { display: none !important; }
.mono, .time { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease; }
button:hover { background: #1c2230; border-color: var(--line2); }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--cyan-soft); border-color: rgba(127, 216, 247, .4); color: var(--cyan); font-weight: 600; }
button.primary:hover { background: rgba(127, 216, 247, .22); }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { color: var(--text); background: var(--panel2); }
button.tog.on { background: var(--cyan-soft); border-color: rgba(127, 216, 247, .45); color: var(--cyan); }
select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
input[type="range"] { accent-color: var(--cyan); width: 78px; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
.view { height: 100vh; display: flex; flex-direction: column; }

/* ============================ LANDING / PROGRESS ============================ */
.land { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(680px, 92vw); padding-bottom: 8vh; }
.brand-big { font-size: 30px; letter-spacing: .5px; color: var(--dim); }
.brand-big b { color: var(--text); font-weight: 700; }
.logo { color: var(--cyan); }
.tagline { color: var(--dim); font-size: 15px; margin-top: -10px; }
.dropzone { width: 100%; border: 1.5px dashed var(--line2); border-radius: 16px; padding: 56px 24px; text-align: center; cursor: pointer; transition: border-color .15s ease, background .15s ease; outline: none; }
.dropzone:hover, .dropzone.drag, .dropzone:focus-visible { border-color: var(--cyan); background: rgba(127, 216, 247, .04); }
.dz-icon { font-size: 34px; color: var(--cyan); margin-bottom: 8px; }
.dz-main { font-size: 17px; font-weight: 600; }
.dz-sub { color: var(--dimmer); margin-top: 6px; font-size: 13px; }
.land-foot { color: var(--dim); font-size: 13px; display: flex; gap: 12px; align-items: center; }
.land-foot .sep { color: var(--dimmer); }
.mini { color: var(--dim); font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.demolink { margin-left: 6px; }
.prog-name { font-size: 19px; font-weight: 600; }
.progwavewrap { width: 100%; height: 90px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
#progWave { width: 100%; height: 100%; display: block; }
.prog-stage { display: flex; gap: 10px; align-items: center; color: var(--dim); }
.prog-bar { width: 100%; height: 4px; border-radius: 2px; background: var(--panel2); overflow: hidden; }
#progFill { height: 100%; width: 0%; background: var(--cyan); border-radius: 2px; transition: width .4s ease; }
.prog-sub { color: var(--dimmer); font-size: 12.5px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line2); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* result card */
.resultwrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 7, 10, .72); backdrop-filter: blur(3px); z-index: 40; }
.result { width: min(480px, 92vw); background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; padding: 26px 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 24px 80px rgba(0, 0, 0, .5); animation: rise .25s ease; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.res-head { font-size: 18px; font-weight: 700; }
.res-head.ok { color: var(--green); }
.res-head.warn { color: var(--amber); }
.res-stats { color: var(--dim); font-size: 13.5px; }
.res-stats b { color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.res-conf { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--dim); }
.res-conf-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; }
#resConfFill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--green)); border-radius: 3px; }
.res-flags { white-space: nowrap; }
.res-actions { display: flex; gap: 12px; align-items: center; }
.res-actions .big { flex: 1; padding: 12px; font-size: 15px; border-radius: 10px; }
.res-actions .exportwrap { flex: 1; }
.res-actions .exportwrap:has(.ghost) { flex: 0 0 auto; }
.res-actions .exportwrap button:first-child { width: 100%; }

/* ============================ EDITOR ============================ */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; align-items: baseline; gap: 8px; font-size: 15px; min-width: 0; }
.brand b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }
.brand .sub { color: var(--dim); font-size: 12.5px; white-space: nowrap; }
.grow { flex: 1; }
.btngroup { display: inline-flex; }
.btngroup button { border-radius: 0; }
.btngroup button:first-child { border-radius: 8px 0 0 8px; }
.btngroup button:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.exportwrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; z-index: 30; min-width: 230px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.menu button { display: block; width: 100%; text-align: left; border: none; border-radius: 0; background: transparent; padding: 10px 14px; }
.menu button:hover { background: #202737; }

main { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ruler { height: 22px; position: relative; overflow: hidden; background: var(--panel); border-bottom: 1px solid var(--line); font-family: var(--mono); }
.ruler i { position: absolute; top: 14px; bottom: 0; border-left: 1px solid var(--line2); }
.ruler span { position: absolute; top: 2px; transform: translateX(4px); font-size: 10px; color: var(--dimmer); }
.wavewrap { flex: 2 1 0; position: relative; min-height: 140px; cursor: grab; overflow: hidden; }
.wavewrap:active { cursor: grabbing; }
#wave { position: absolute; inset: 0; width: 100%; height: 100%; }
.playline { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; border-left: 2px solid rgba(255, 255, 255, .92); pointer-events: none; box-shadow: 0 0 12px rgba(127, 216, 247, .35); }
.playline::before { content: ""; position: absolute; top: 0; left: -6px; border: 5px solid transparent; border-top-color: #fff; }
.abbadge { position: absolute; top: 10px; left: 50%; transform: translateX(12px); display: flex; gap: 6px; align-items: center; background: rgba(11, 14, 19, .85); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 8px; font-family: var(--mono); font-size: 12px; pointer-events: none; }
.abbadge .ab-a, .abbadge .ab-b { padding: 1px 7px; border-radius: 5px; color: var(--dimmer); }
.abbadge .ab-vs { color: var(--dimmer); font-size: 10px; }
.abbadge.a .ab-a, .abbadge.b .ab-b { background: var(--cyan-soft); color: var(--cyan); font-weight: 700; }
.controls { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-top: 1px solid var(--line); flex-wrap: wrap; }
.caret { color: var(--dimmer); font-size: 10px; }
/* AI-overlay popover */
.popwrap { position: relative; }
.menu.pop { left: 0; right: auto; top: auto; bottom: calc(100% + 8px); width: 360px; padding: 10px 12px; }
.pop-title { color: var(--dim); font-size: 12px; margin: 2px 2px 10px; }
.pop-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; }
.pop-lab { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pop-lab b { font-size: 12.5px; }
.pop-lab span { color: var(--dimmer); font-size: 11px; line-height: 1.3; }
.pop-row input[type="range"] { width: 86px; flex: none; }
.c-cyan { color: var(--cyan); }
.c-gold { color: var(--gold); }
/* toggle switch */
.sw { flex: none; }
.sw input { display: none; }
.sw i { display: block; width: 34px; height: 19px; border-radius: 10px; background: var(--line2); position: relative; cursor: pointer; transition: background .15s ease; }
.sw i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #98a2b5; transition: left .15s ease, background .15s ease; }
.sw input:checked + i { background: rgba(127, 216, 247, .35); }
.sw input:checked + i::after { left: 17px; background: var(--cyan); }
/* review-loop chip */
.loopchip { position: absolute; top: 10px; left: 12px; background: rgba(11, 14, 19, .88); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 10px; font-size: 12px; color: var(--dim); cursor: pointer; user-select: none; transition: border-color .15s ease; }
.loopchip:hover { border-color: var(--cyan); }
.loopchip b { color: var(--cyan); font-weight: 600; }
.vol { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); font-size: 12px; }
.time { color: var(--dim); font-size: 13px; min-width: 84px; text-align: right; }
#tempoStrip { width: 100%; height: 100%; display: block; }
.timebarwrap { height: 56px; background: var(--panel); border-top: 1px solid var(--line); cursor: pointer; }
#timebar { width: 100%; height: 100%; display: block; }

/* sidebar */
.side { width: 360px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: none; border-radius: 0; padding: 10px; color: var(--dim); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--cyan); }
.badge { background: var(--amber); color: #14161c; border-radius: 9px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 4px; }
.badge:empty, .badge2:empty { display: none; }
.badge2 { background: var(--panel2); color: var(--dim); border-radius: 9px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.tabpane { flex: 1; overflow-y: auto; padding: 10px; }
.hint { color: var(--dimmer); font-size: 12.5px; margin: 6px 4px; }

/* review queue cards */
.qprog { color: var(--dimmer); font-size: 12px; margin: 2px 4px 10px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; transition: border-color .15s ease, opacity .2s ease; }
.card:hover { border-color: var(--line2); }
.card.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(127, 216, 247, .25); }
.card.done { opacity: .45; }
.card .c-top { display: flex; align-items: baseline; gap: 8px; }
.card .c-ico { font-size: 13px; }
.card .c-title { font-weight: 600; font-size: 13.5px; flex: 1; }
.card .c-time { color: var(--dimmer); font-family: var(--mono); font-size: 12px; }
.card .c-detail { color: var(--dim); font-size: 12.5px; margin: 7px 0 0; }
.card .c-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.card .c-actions button { font-size: 12.5px; padding: 5px 10px; }
.card .c-actions .fix { background: var(--cyan-soft); border-color: rgba(127, 216, 247, .35); color: var(--cyan); }
.card .c-actions .fix:hover { background: rgba(127, 216, 247, .22); }
.card .c-done-mark { color: var(--green); font-size: 12px; margin-top: 8px; }
.sev2 .c-ico { color: var(--red); }
.sev1 .c-ico { color: var(--amber); }
.sev0 .c-ico { color: var(--dimmer); }
.why { margin-top: 9px; font-size: 12px; }
.why summary { color: var(--dimmer); cursor: pointer; user-select: none; }
.why summary:hover { color: var(--dim); }
.why p { color: var(--dim); margin: 6px 0 0; padding: 8px 10px; background: rgba(0, 0, 0, .18); border-radius: 8px; }
.polishhead { display: flex; align-items: center; gap: 8px; color: var(--dimmer); font-size: 12px; margin: 14px 4px 8px; cursor: pointer; user-select: none; }
.polishhead::before, .polishhead::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.allclear { text-align: center; color: var(--dim); padding: 30px 10px; }
.allclear .big { font-size: 30px; margin-bottom: 8px; }

/* redlines table */
.rl { display: grid; grid-template-columns: 12px 86px 1fr auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.rl:hover { background: var(--panel2); }
.rl.active { background: var(--cyan-soft); }
.rl .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--red); }
.rl .t { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.rl .bpm { font-family: var(--mono); font-size: 13px; }
.rl .meter { color: var(--dimmer); font-family: var(--mono); font-size: 12px; }
.chip { display: inline-block; font-size: 10.5px; font-family: var(--mono); padding: 0 6px; border-radius: 6px; margin-left: 6px; }
.chip.hi { background: rgba(67, 217, 173, .12); color: var(--green); }
.chip.mid { background: var(--amber-soft); color: var(--amber); }
.chip.lo { background: var(--red-soft); color: var(--red); }
.chip.oct { background: var(--cyan-soft); color: var(--cyan); cursor: help; }
/* advanced row editor */
.rladv { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; }
.rladv .row1 { display: flex; align-items: center; gap: 8px; }
.rladv input[type="number"] { font-family: var(--mono); font-size: 12.5px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; width: 86px; }
.rladv input.bpm { width: 76px; }
.rladv select { font-size: 12px; padding: 2px 4px; }
.rladv .row2 { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.rladv .row2 button { font-size: 11.5px; padding: 3px 8px; }
.rladv .del { color: var(--red); }
/* section under the playhead — follows playback */
.rladv.playing { border-color: rgba(127, 216, 247, .55); box-shadow: inset 3px 0 0 var(--cyan); }
.rl.playing { background: var(--panel2); box-shadow: inset 3px 0 0 var(--cyan); }
.addrl { width: 100%; margin-top: 4px; border-style: dashed; color: var(--dim); }

/* toasts */
.toasts { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 16px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); animation: rise .2s ease; }
.toast.err { border-color: rgba(255, 77, 94, .5); color: #ffb3ba; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 5px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* keyboard hint bar */
.kbdhint { color: var(--dimmer); font-size: 11.5px; text-align: center; padding: 3px 0; background: var(--panel); border-top: 1px solid var(--line); user-select: none; }
kbd { font-family: var(--mono); font-size: 10.5px; background: var(--panel2); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; margin: 0 2px; }

/* suggestion-only review cards: guidance line under the A/B buttons */
.c-hint { flex-basis: 100%; margin-top: 6px; font-size: 11.5px; line-height: 1.45;
          color: var(--dim, #9aa3b2); }

/* ---- residual strip (grid deviation) ---- */
/* the residual strip is the primary verify surface — give it real estate */
.residstrip { flex: 1 0 120px; max-height: 230px; background: var(--panel); border-top: 1px solid var(--line); cursor: pointer; }
.residstrip canvas { display: block; width: 100%; height: 100%; }
.timebarwrap canvas { display: block; width: 100%; height: 100%; }

/* ---- verify-existing-timing banner ---- */
.verifyban { background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; margin: 8px 10px; font-size: 13px; color: var(--text); }
.verifyban button { margin: 0 6px; padding: 3px 10px; font-size: 12.5px; background: var(--cyan-soft); border-color: rgba(127,216,247,.4); color: var(--cyan); }
.verifyban .vhint { display: block; margin-top: 6px; color: var(--dim); font-size: 12px; }

button svg { vertical-align: -2px; margin-right: 5px; }
.bpmnow { color: var(--cyan); font-weight: 700; font-size: 15px; padding: 0 4px; }

/* tighten-grid control (Redlines panel) */
.tighten { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tighten label { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
.tighten select { font-size: 12px; padding: 2px 4px; }
.tighten .sw2 { cursor: pointer; }
.tighten button { font-size: 12px; padding: 3px 10px; }
.tighten-note { flex-basis: 100%; font-size: 11.5px; color: var(--dimmer); line-height: 1.45; }
.tighten-note b { color: var(--text); }
