:root {
  --bg: #0e0e0e;
  --panel: #171717;
  --panel-2: #1e1e1e;
  --line: #2a2a2a;
  --line-2: #383838;
  --text: #ededed;
  --muted: #9a9a9a;
  --acid: #d7ff3a;
  --acid-ink: #141a00;
  --warn: #ff8a5c;
  --paper: #ffffff;
  --radius: 10px;
  --sans: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --cond: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bass-on: 1;
  --drums-on: 1;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding: 0 16px 24px;
  max-width: 1600px;
  margin: 0 auto;
}
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }

/* ---------- header ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0 12px;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.logo {
  font: 800 34px/0.95 var(--cond);
  letter-spacing: 0.01em;
}
.tag { color: var(--muted); font-size: 12.5px; }
.transport { display: flex; align-items: center; gap: 12px; }
.play {
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 20px 0 16px;
  border-radius: 999px; border: 0;
  background: var(--acid); color: var(--acid-ink);
  font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
  cursor: pointer;
}
.play svg { width: 20px; height: 20px; fill: currentColor; }
.play .i-stop { display: none; }
.play[aria-pressed="true"] { background: var(--text); color: #111; }
.play[aria-pressed="true"] .i-play { display: none; }
.play[aria-pressed="true"] .i-stop { display: block; }
.scope {
  width: 200px; height: 48px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.print-link {
  color: var(--text); text-decoration: none;
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; white-space: nowrap;
}
.print-link:hover { border-color: var(--acid); color: var(--acid); }

/* ---------- mix crossfader ---------- */
.xfade {
  display: grid; grid-template-columns: auto minmax(120px, 190px) auto; align-items: center;
  column-gap: 8px; row-gap: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px 4px;
}
.xf-end { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; transition: color 0.15s; }
.xf-bass { color: color-mix(in srgb, var(--acid) calc(var(--bass-on) * 100%), #555); }
.xf-drums { color: color-mix(in srgb, var(--acid) calc(var(--drums-on) * 100%), #555); }
.xfade input { width: 100%; margin: 0; }
.xf-label { grid-column: 1 / -1; text-align: center; font: 11px var(--mono); color: var(--muted); }

/* ---------- knobs ---------- */
.knob-row { display: flex; gap: 4px; flex-wrap: wrap; }
.knob {
  position: relative;
  width: 68px;
  display: flex; flex-direction: column; align-items: center;
  user-select: none; touch-action: none; cursor: ns-resize;
  border-radius: 8px; padding: 2px 0 4px;
}
.knob svg { width: 46px; height: 46px; display: block; }
.knob .k-body { fill: #262626; stroke: #333; stroke-width: 1; }
.knob .k-track { fill: none; stroke: #3a3a3a; stroke-width: 3.5; stroke-linecap: round; }
.knob .k-val { fill: none; stroke: var(--acid); stroke-width: 3.5; stroke-linecap: round; }
.knob .k-ptr { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }
.knob .k-label { font-size: 10.5px; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; margin-top: 1px; white-space: nowrap; }
.knob .k-value { font: 11px var(--mono); color: var(--text); white-space: nowrap; }
.knob:hover .k-body { stroke: #555; }
.knob.small { width: 62px; }
.knob.small svg { width: 38px; height: 38px; }
.k-badge {
  position: absolute; top: 0; right: 4px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  font: 700 10px/15px var(--sans); text-align: center;
  border: 1px solid var(--acid); color: var(--acid); background: var(--bg);
}
.k-badge[hidden] { display: none; }
.k-badge.live { background: var(--acid); color: var(--acid-ink); }
.picker { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 4px 22px 0 4px; }
.picker select { max-width: 170px; }
.picker .k-badge { top: 2px; right: 0; }

/* ---------- controls ---------- */
.seg { display: inline-flex; background: #111; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px;
  color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600;
}
.seg button[aria-checked="true"] { background: var(--text); color: #111; }
.btn {
  border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center;
}
.btn:hover { border-color: #5a5a5a; }
.btn.primary { background: var(--acid); color: var(--acid-ink); border-color: var(--acid); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 11px; font-size: 12px; }
select {
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; max-width: 100%;
}
input[type="range"] { accent-color: var(--acid); width: 130px; }

/* ---------- panels ---------- */
.main, .lower {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 14px;
}
.lower { margin-top: 14px; align-items: start; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-head h2, .rack h2 { margin: 0; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.status { margin: 0; font-size: 13px; color: var(--muted); text-align: right; flex: 1 1 200px; }
.status.ok { color: var(--acid); }
.status.warn { color: var(--warn); }
.fine { margin: 0; color: var(--muted); font-size: 12.5px; }

.stage {
  position: relative; background: #0a0a0a; border-radius: 8px; overflow: hidden;
  aspect-ratio: 297 / 210; border: 1px solid var(--line);
}
.view { width: 100%; height: 100%; display: block; }
.cam-intro {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  gap: 14px; padding: 24px clamp(16px, 4vw, 40px); overflow: auto;
  background: radial-gradient(120% 120% at 0% 0%, #1d1d1d 0%, #0b0b0b 70%);
}
.cam-intro[hidden] { display: none; }
.cam-intro .lead { margin: 0; font-size: 17px; line-height: 1.4; max-width: 34em; }
.cam-intro .hint { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 46em; }
.intro-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cam-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.field { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.field select { max-width: 220px; color: var(--text); }
.field.midi.on select { border-color: var(--acid); color: var(--acid); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { accent-color: var(--acid); }

/* ---------- sheet ---------- */
.paper {
  background: var(--paper); border-radius: 6px; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.paper svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.paper .well { cursor: pointer; }
.paper .well:hover .w-bg { fill: #7d7d7d; }
.paper .well:focus { outline: none; }
.paper .well:focus-visible .w-bg { stroke: #111; stroke-width: 0.6; }
.paper.readonly .well, .paper.readonly .slider { cursor: copy; }
.paper .w-bead, .paper .w-hole { display: none; }
.paper .well[data-s="1"] .w-bead { display: inline; fill: #fff; stroke: #1a1a1a; stroke-width: 0.35; }
.paper .well[data-s="2"] .w-bead { display: inline; fill: #111; stroke: #000; stroke-width: 0.2; }
.paper .well[data-s="1"] .w-hole, .paper .well[data-s="2"] .w-hole { display: inline; fill: #9a9a9a; }
.paper .slider { cursor: ew-resize; touch-action: none; }
.paper .slider:hover .s-track { fill: #7d7d7d; }
.paper .s-ring { fill: #fff; stroke: #1a1a1a; stroke-width: 0.35; }
.paper .s-hole { fill: #9a9a9a; }
.paper.readonly .s-ring { stroke: #5d7a00; stroke-width: 0.7; }
.paper .playhead { fill: var(--acid); opacity: 0; transition: opacity 0.12s; }
.paper .playhead.on { opacity: 0.55; }
.sheet-hint { margin: 0; color: var(--muted); font-size: 12.5px; min-height: 1.4em; }

/* ---------- paper sliders ---------- */
.bay-rows { display: flex; flex-direction: column; gap: 6px; }
.bay-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.25fr) 112px;
  align-items: center; gap: 10px;
}
.bay-id {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font: 800 14px var(--cond); letter-spacing: 0.02em;
  border: 1.5px solid #555; color: var(--muted);
}
.bay-row.mix .bay-id { font-size: 10px; }
.bay-row.live .bay-id { background: var(--acid); border-color: var(--acid); color: var(--acid-ink); }
.bay-row.occluded .bay-id { border-color: var(--warn); color: var(--warn); background: transparent; }
.bay-row select { width: 100%; }
.bay-fixed { font-size: 13px; padding: 0 12px; color: var(--text); }
.bay-row input[type="range"] { width: 100%; }
.bay-row input[type="range"]:disabled { opacity: 1; cursor: not-allowed; }
.bay-row:not(.live) input[type="range"] { opacity: 0.55; }
.bay-val { font: 12px var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- pattern lane ---------- */
.readout {
  display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 4px;
}
.cell {
  background: #111; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 2px 5px; text-align: center; min-width: 0;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.cell:nth-child(4n+1) { border-color: var(--line-2); }
.cell .n { font: 11px var(--mono); color: var(--muted); }
.cell .note { font: 700 13px var(--mono); letter-spacing: -0.03em; }
.cell.rest .note { color: #4a4a4a; }
.cell.beyond { opacity: 0.3; }
.cell .tags { display: flex; gap: 2px; min-height: 15px; flex-wrap: wrap; justify-content: center; }
.tagx { font: 700 9px var(--sans); letter-spacing: 0.04em; padding: 1px 3px; border-radius: 4px; background: #262626; color: var(--muted); }
.tagx.acc { background: var(--text); color: #111; }
.tagx.sl { background: transparent; border: 1px solid #555; color: var(--text); }
.cell.conflict { border-color: var(--warn); }
.cell.now { background: var(--acid); border-color: var(--acid); color: var(--acid-ink); }
.cell.now .n, .cell.now .note { color: var(--acid-ink); }
.cell.now .tagx { background: rgba(0, 0, 0, 0.15); color: var(--acid-ink); border-color: rgba(0,0,0,0.3); }
.cell.now .tagx.acc { background: var(--acid-ink); color: var(--acid); }
.lane-info { display: flex; gap: 18px; justify-content: space-between; flex-wrap: wrap; }
.keyinfo, .warnings { margin: 0; font-size: 13px; }
.keyinfo { color: var(--text); }
.keyinfo .dim { color: var(--muted); }
.warnings { color: var(--warn); }

/* ---------- sound rack ---------- */
.rack { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.rack-group {
  flex: 1 1 auto; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 8px;
}
.rack-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rack-group:nth-child(1) { flex-basis: 640px; }
.rack-group:nth-child(1) h2 { opacity: calc(0.45 + 0.55 * var(--bass-on)); }
.rack-group:nth-child(2) h2 { opacity: calc(0.45 + 0.55 * var(--drums-on)); }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  background: var(--text); color: #111; padding: 10px 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; max-width: min(560px, calc(100vw - 32px));
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { color: #6d6d6d; font-size: 12px; padding-top: 14px; }
.foot p { margin: 0; }

/* ---------- smaller screens ---------- */
@media (max-width: 1240px) {
  .scope { display: none; }
}
@media (max-width: 1100px) {
  .main, .lower { grid-template-columns: minmax(0, 1fr); }
  body.src-screen .sheet-panel { order: -1; }
}
@media (max-width: 720px) {
  .readout { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .knob { width: 62px; }
  .knob svg { width: 40px; height: 40px; }
  .logo { font-size: 28px; }
  .tag { display: none; }
  .xfade { width: 100%; grid-template-columns: auto minmax(0, 1fr) auto; }
  .bay-row { grid-template-columns: 30px minmax(0, 1fr) 92px; }
  .bay-row input[type="range"] { grid-column: 2 / -1; grid-row: 2; }
  .bay-id { grid-row: 1 / span 2; }
  .print-link { order: 5; }
}
