:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1d2029;
  --line: #2a2e3a;
  --text: #e9eaf0;
  --muted: #9096a8;
  --accent: #8ab4ff;
  --take: #ffb454;
  --rec: #ff5a4f;
  --ok: #4fd18b;
  --warn: #ffcc4d;
  --radius: 14px;
  --head-w: 300px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; background: rgba(14, 15, 19, .92); backdrop-filter: blur(8px);
}
.brand { color: var(--text); text-decoration: none; font-size: 18px; letter-spacing: .2px; }
.brand b { color: var(--accent); font-weight: 700; }
.top-right { display: flex; gap: 8px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill-local { color: var(--ok); border-color: rgba(79, 209, 139, .35); }

main { max-width: 1280px; margin: 0 auto; padding: 22px 24px 40px; }

.setup { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.num {
  width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}

.drop {
  position: relative; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center;
  text-align: center; min-height: 110px; padding: 14px; border: 1.5px dashed var(--line); border-radius: 12px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(138, 180, 255, .06); }
.drop.has-file { min-height: 70px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-main { font-weight: 600; }
.drop-sub { font-size: 12px; color: var(--muted); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 10px 14px;
  cursor: pointer; font-weight: 600; transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #0b1020; border-color: transparent; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; flex: 1; }
.field select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text);
  font-size: 14px; width: 100%;
}
.field-inline { flex-direction: row; align-items: center; gap: 8px; flex: 0 0 auto; }
.field-inline select { width: auto; }
.row { display: flex; gap: 10px; }

.meters { display: flex; flex-direction: column; gap: 6px; }
.meter { display: grid; grid-template-columns: 14px 1fr 44px 40px; gap: 8px; align-items: center; font-size: 12px; }
.meter[hidden] { display: none; }
.meter-name { color: var(--muted); }
.meter-bar { height: 10px; background: var(--panel-2); border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.meter-bar i {
  display: block; height: 100%; transform-origin: left; transform: scaleX(0);
  background: linear-gradient(90deg, #39c27b 0%, #39c27b 70%, #e8c84a 85%, #ff5a4f 100%);
  background-size: calc(100%) 100%;
}
.meter-db { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.clip {
  font-size: 10px; font-weight: 700; padding: 2px 0; border-radius: 4px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer;
}
.clip.on { background: var(--rec); color: #fff; border-color: var(--rec); }

.check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.facts { margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.big { margin: 0; font-size: 22px; }
.big b { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 13px; }
input[type="range"] { accent-color: var(--accent); width: 100%; }

.transport {
  margin: 18px 0 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
  position: sticky; top: 58px; z-index: 4;
}
.tbtn {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2);
  font-size: 18px; cursor: pointer; display: grid; place-items: center;
}
.tbtn:hover:not(:disabled) { border-color: var(--accent); }
.tbtn-rec { color: var(--rec); font-size: 22px; }
.tbtn-rec.on { background: var(--rec); color: #fff; border-color: var(--rec); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 90, 79, .25); } }
.clock { font-size: 28px; font-variant-numeric: tabular-nums; min-width: 120px; padding: 0 10px; font-weight: 600; }
.is-recording .clock { color: var(--rec); }
.transport-note { color: var(--muted); font-size: 12.5px; margin-left: auto; }

.tracks {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; min-height: 120px;
}
.lane { display: grid; grid-template-columns: var(--head-w) 1fr; border-bottom: 1px solid var(--line); }
.lane:last-of-type { border-bottom: 0; }
.lane[hidden] { display: none; }
.lane-head {
  padding: 10px 12px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px;
  min-width: 0; background: var(--panel); font-size: 13px;
}
.lane-body { position: relative; height: 84px; cursor: pointer; }
.lane-body canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lane-ruler .lane-body { height: 26px; }
.lane-ruler .lane-head { padding: 0; }
.lane-title { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.lane-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-dur { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; flex: none; }
.nudge { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: none; }
.nudge .mini { min-width: 22px; height: 22px; padding: 0 4px; }
.nudge-ms { font-size: 11.5px; color: var(--muted); min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.lane-ctl { display: flex; gap: 6px; align-items: center; }
.lane-ctl input[type="range"] { flex: 1; min-width: 60px; }
.vol-db { width: 38px; text-align: right; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.mini {
  min-width: 26px; height: 24px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted);
}
.mini:hover { color: var(--text); border-color: var(--muted); }
.mini-mute.on { background: #5a4a1f; color: var(--warn); border-color: var(--warn); }
.mini-solo.on { background: #1f4a37; color: var(--ok); border-color: var(--ok); }
.mini-del:hover { color: var(--rec); border-color: var(--rec); }
.lane.silent .lane-name { color: var(--muted); }
.lane-take .lane-name { color: var(--take); }
.lane-backing .lane-name { color: var(--accent); }
.lane-live .lane-head { color: var(--rec); font-weight: 600; flex-direction: row; align-items: center; gap: 8px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

.playhead {
  position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: #fff; pointer-events: none;
  box-shadow: 0 0 8px rgba(255, 255, 255, .5); z-index: 2;
}
.playhead[hidden] { display: none; }
.empty { margin: 0; padding: 26px; text-align: center; color: var(--muted); }
.empty[hidden] { display: none; }

.export { display: flex; gap: 10px; align-items: center; margin: 14px 0 0; flex-wrap: wrap; }
.export .btn-ghost { margin-left: auto; }

.tips {
  margin-top: 28px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), transparent);
}
.tips h3 { margin: 0 0 8px; font-size: 15px; }
.tips ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.tips b { color: var(--text); }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px 24px 32px; }

.toasts {
  position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 20;
  max-width: min(440px, calc(100vw - 36px));
}
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  transition: opacity .35s, transform .35s;
}
.toast.out { opacity: 0; transform: translateY(6px); }
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--rec); }

@media (max-width: 980px) {
  .setup { grid-template-columns: 1fr; }
  :root { --head-w: 200px; }
  .transport-note { display: none; }
}
@media (max-width: 600px) {
  main { padding: 14px 12px 30px; }
  :root { --head-w: 130px; }
  .lane-ctl input[type="range"], .vol-db { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tbtn-rec.on, .rec-dot { animation: none; }
  .toast { transition: none; }
}

/* ── production ─────────────────────────────────────────────────────────── */
.prod { margin-top: 28px; display: flex; flex-direction: column; gap: 16px; }
.prod-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.prod-head h2 { margin: 0; font-size: 20px; }
.prod-head p { margin: 0; flex: 1; }
.prod-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.ctls { display: flex; flex-direction: column; gap: 6px; }
.ctl { display: grid; grid-template-columns: 1fr 1.2fr 74px; gap: 8px; align-items: center; font-size: 13px; }
.ctl-label { color: var(--muted); }
.ctl-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text); }
.ctl select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 6px; font-size: 13px; color: var(--text); }
.ctl input[type="checkbox"] { justify-self: start; accent-color: var(--accent); width: 16px; height: 16px; }
.ctl-preset { grid-template-columns: 1fr 1.2fr; margin-bottom: 4px; }
.grp { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); }
.grp-head { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13.5px; }
.grp.off .ctl { opacity: .4; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.switch input { accent-color: var(--ok); width: 16px; height: 16px; }
.gr { margin-left: auto; font-size: 11.5px; color: var(--warn); font-variant-numeric: tabular-nums; font-weight: 500; }

.card-master { gap: 14px; }
.master-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.master-title h2 { flex: 1; }
.master-title .gr { margin-left: 0; }
.master-grid { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 20px; }
.master-left, .master-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.drop-sm { min-height: 84px; }
.ab { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ab button { flex: 1; padding: 9px 6px; background: var(--panel-2); border: 0; border-right: 1px solid var(--line); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.ab button:last-child { border-right: 0; }
.ab button.on { background: var(--accent); color: #0b1020; }
.curve-wrap { position: relative; }
.curve-wrap canvas { width: 100%; height: 170px; display: block; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.curve-legend { position: absolute; top: 8px; right: 10px; display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 16px; height: 0; margin-right: 6px; vertical-align: middle; border-top: 2px solid; }
.lg-diff::before { border-top: 2px dashed #8ab4ff; }
.lg-eq::before { border-color: #4fd18b; }
.lane-ctl input.pan { flex: 0 0 54px; min-width: 40px; accent-color: var(--take); }

@media (max-width: 1100px) {
  .prod-grid { grid-template-columns: 1fr 1fr; }
  .master-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .prod-grid { grid-template-columns: 1fr; }
}
