/* Studio Remote — Studio One-style dark console. States are told apart by
   brightness + label, never by hue alone (the owner is colour blind). */
:root {
  --bg: #16181b;
  --panel: #23262b;
  --panel-2: #2b2f35;
  --raise: #353a41;
  --line: #0f1113;
  --line-soft: #3a3f46;
  --text: #d7dde4;
  --text-dim: #8b939c;
  --text-faint: #5f666e;
  --accent: #8fb8e8;      /* active, pale blue: bright against the dark panels */
  --accent-ink: #0d1520;
  --on: #e9eef3;          /* lit button face */
  --on-ink: #121417;
  --meter: #9cc6ee;
  --meter-hot: #e9f2fb;
  --danger: #f0a8a0;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.35 var(--font); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
kbd { font: 11px var(--font); color: var(--text-faint); margin-left: 4px; }
.spacer { flex: 1; }

/* flex, not grid rows: the banner comes and goes, and a hidden grid item shifts every row after it */
.app { display: flex; flex-direction: column; height: 100vh; }

/* ---------------------------------------------------------------- top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; }
.song { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.conn { display: flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 3px; background: var(--panel-2); color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
.conn[data-state="live"] { color: var(--on); }
.conn[data-state="live"] .dot { background: var(--on); }
.conn[data-state="offline"] .dot { border-style: dotted; }
.views { display: flex; gap: 2px; background: var(--line); padding: 2px; border-radius: 4px; }
.view-tab { background: transparent; border: 0; padding: 4px 12px; border-radius: 3px; color: var(--text-dim); }
.view-tab[aria-selected="true"] { background: var(--raise); color: var(--text); }

.tbtn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 4px 10px; white-space: nowrap; }
.tbtn:hover { background: var(--raise); }
.tbtn[aria-pressed="true"] { background: var(--on); color: var(--on-ink); border-color: var(--on); }
.tbtn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.listen { display: flex; align-items: center; gap: 8px; }
.listen input[type=range] { width: 80px; accent-color: var(--accent); }
.audio-info { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 9em; white-space: nowrap; }

.banner { padding: 6px 12px; background: #2f3338; border-bottom: 1px solid var(--line); color: var(--text); font-size: 12px; }
.banner b { font-weight: 600; }

/* ---------------------------------------------------------------- layout */
.main { flex: 1; display: flex; min-height: 0; }
.view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- console */
.console { flex: 1; display: flex; min-height: 0; background: var(--bg); }
.strips { flex: 1; display: flex; gap: 2px; padding: 6px; overflow-x: auto; overflow-y: hidden; align-items: stretch; }
.master-wrap { display: flex; padding: 6px; border-left: 2px solid var(--line); background: #1b1d21; }
.empty { margin: auto; color: var(--text-dim); text-align: center; max-width: 420px; line-height: 1.6; }

.strip { width: 78px; flex: 0 0 78px; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 1fr auto; background: var(--panel); border: 1px solid var(--line); border-radius: 2px; min-height: 0; }
.strip.selected { background: #2c3138; outline: 1px solid var(--accent); outline-offset: -1px; }
.strip .num { display: flex; justify-content: space-between; padding: 3px 5px 0; color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.strip .pan { margin: 4px 5px 2px; height: 18px; position: relative; background: var(--line); border-radius: 2px; cursor: ew-resize; touch-action: none; }
.strip .pan .pan-fill { position: absolute; top: 3px; bottom: 3px; background: var(--accent); border-radius: 1px; }
.strip .pan .pan-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; color: var(--text); text-shadow: 0 0 3px #000; font-variant-numeric: tabular-nums; }
.strip .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px 5px; }
.sbtn { height: 20px; padding: 0; border: 1px solid var(--line); background: var(--panel-2); border-radius: 2px; font-size: 11px; font-weight: 600; color: var(--text-dim); }
.sbtn:hover { background: var(--raise); }
.sbtn[aria-pressed="true"] { background: var(--on); color: var(--on-ink); border-color: var(--on); }
/* record arm: lit face + a ring so it differs from M/S even in greyscale */
.sbtn.arm[aria-pressed="true"] { background: var(--danger); color: #2a0d0a; box-shadow: inset 0 0 0 2px #2a0d0a; }
.sbtn:disabled { opacity: .35; cursor: default; }

.strip .fader-area { display: grid; grid-template-columns: 1fr auto; gap: 4px; padding: 4px 6px; min-height: 120px; }
.fader { position: relative; touch-action: none; cursor: ns-resize; }
.fader .track { position: absolute; left: 50%; top: 6px; bottom: 6px; width: 4px; transform: translateX(-50%); background: var(--line); border-radius: 2px; }
.fader .unity { position: absolute; left: 20%; right: 20%; height: 1px; background: var(--text-faint); }
.fader .cap { position: absolute; left: 50%; width: 30px; height: 14px; transform: translate(-50%, 50%); background: linear-gradient(#cfd5dc, #9aa2ab); border: 1px solid #0b0c0e; border-radius: 2px; }
.fader .cap::after { content: ""; position: absolute; left: 3px; right: 3px; top: 6px; height: 1px; background: #0b0c0e; }
.fader.disabled { cursor: default; opacity: .4; }
.meter { display: flex; gap: 2px; padding: 6px 0; }
.meter .bar { width: 5px; background: #0b0c0e; position: relative; overflow: hidden; border-radius: 1px; }
.meter .fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(to top, #4f7699 0%, var(--meter) 70%, var(--meter-hot) 100%); }
.meter .peak { position: absolute; left: 0; right: 0; height: 2px; background: var(--meter-hot); }
.strip .db { text-align: center; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; padding-bottom: 2px; }
.strip .name { padding: 4px 4px; font-size: 11.5px; font-weight: 500; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 4px solid var(--tc, var(--text-faint)); background: var(--panel-2); }
.strip.master .name { border-top-color: var(--text); }

/* ---------------------------------------------------------------- screen */
.screen-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.win-list { display: flex; gap: 4px; flex-wrap: wrap; }
.win-list button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 3px 9px; color: var(--text-dim); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-list button[aria-pressed="true"] { background: var(--on); color: var(--on-ink); }
.win-list button.modal::before { content: "Dialog · "; font-weight: 600; }
.check { display: inline-flex; gap: 5px; align-items: center; color: var(--text-dim); }
.screen-hint { padding: 4px 10px; color: var(--text-faint); font-size: 12px; }
.screen-stage { flex: 1; overflow: auto; padding: 6px; min-height: 0; }
.screen-stage img { max-width: 100%; display: block; cursor: crosshair; user-select: none; -webkit-user-drag: none; }

/* ---------------------------------------------------------------- browser */
.browser { width: 280px; flex: 0 0 280px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; padding: 8px; min-height: 0; }
.panel-head { font-weight: 600; color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: .06em; margin-top: 4px; }
.seg { display: flex; gap: 2px; background: var(--line); padding: 2px; border-radius: 4px; }
.seg button { flex: 1; background: transparent; border: 0; padding: 4px; border-radius: 3px; color: var(--text-dim); }
.seg button[aria-selected="true"] { background: var(--raise); color: var(--text); }
.browser input[type=search], .browser select { width: 100%; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 3px; padding: 5px 7px; }
.effect-target { display: grid; gap: 3px; color: var(--text-dim); font-size: 12px; }
.plugin-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 80px; border: 1px solid var(--line); border-radius: 3px; background: var(--bg); }
.plugin-list li { display: flex; align-items: center; gap: 6px; padding: 5px 7px; border-bottom: 1px solid #1d2024; }
.plugin-list li .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plugin-list li .pv { color: var(--text-faint); font-size: 11px; }
.plugin-list li button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 2px 8px; font-size: 12px; }
.plugin-list li button:hover { background: var(--on); color: var(--on-ink); }
.plugin-list .hint { color: var(--text-faint); justify-content: center; border: 0; }
.add-tracks { display: flex; flex-wrap: wrap; gap: 4px; }
.add-tracks button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 3px 8px; font-size: 12px; }
.browser-note { color: var(--text-faint); font-size: 11.5px; }

/* ---------------------------------------------------------------- transport */
.transport { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 6px 10px; background: var(--panel); border-top: 1px solid var(--line); }
.tp-left, .tp-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tp-right { justify-content: flex-end; }
.tp-center { display: flex; align-items: center; gap: 14px; }
.k { color: var(--text-faint); font-size: 11px; margin-right: 5px; }
.tp-stat { display: flex; align-items: center; }
.tempo { width: 64px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 3px; padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums; cursor: ns-resize; }
.time { background: #0e1012; border: 1px solid var(--line); border-radius: 3px; padding: 3px 12px; min-width: 170px; text-align: center; }
.time-main { font-size: 22px; font-weight: 500; letter-spacing: .02em; font-variant-numeric: tabular-nums; color: var(--on); }
.time-sub { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.time-sub .sep { color: var(--text-faint); }
.tp-buttons { display: flex; gap: 3px; }
.tp { width: 34px; height: 30px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; color: var(--text); padding: 0; }
.tp svg { width: 16px; height: 16px; fill: currentColor; }
.tp.big { width: 42px; }
.tp:hover { background: var(--raise); }
.tp[aria-pressed="true"] { background: var(--on); color: var(--on-ink); border-color: var(--on); }
.tp.rec[aria-pressed="true"] { background: var(--danger); color: #2a0d0a; box-shadow: inset 0 0 0 2px #2a0d0a; }
.loop-range { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-dim); line-height: 1.5; }
.locate input { width: 92px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 3px; padding: 4px 6px; }

/* ---------------------------------------------------------------- palette */
.palette { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; z-index: 10; }
.palette-box { width: min(560px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line-soft); border-radius: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.5); overflow: hidden; }
.palette-box input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: var(--panel-2); padding: 11px 14px; font-size: 15px; outline: none; }
.palette-box ul { list-style: none; margin: 0; padding: 4px 0; max-height: 50vh; overflow-y: auto; }
.palette-box li { padding: 6px 14px; display: flex; gap: 8px; cursor: pointer; }
.palette-box li .c { color: var(--text-faint); min-width: 90px; }
.palette-box li[aria-selected="true"] { background: var(--on); color: var(--on-ink); }
.palette-box li[aria-selected="true"] .c { color: #3b4148; }
.palette-note { padding: 7px 14px; color: var(--text-faint); font-size: 11.5px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 12px; bottom: 64px; display: flex; flex-direction: column; gap: 6px; z-index: 20; max-width: min(420px, calc(100vw - 24px)); }
.toast { background: #30353b; border: 1px solid var(--line-soft); border-left: 4px solid var(--text-dim); padding: 7px 10px; border-radius: 3px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.err { border-left: 4px dashed var(--danger); }
.toast.err::before { content: "Error · "; font-weight: 600; }

/* ---------------------------------------------------------------- login */
.login-page { display: grid; place-items: center; padding: 16px; }
.login { width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 24px; display: grid; gap: 8px; }
.login h1 { margin: 4px 0 0; font-size: 20px; font-weight: 600; }
.login p { margin: 0 0 8px; color: var(--text-dim); }
.login label { color: var(--text-dim); font-size: 12px; }
.login input { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 3px; padding: 8px 10px; }
.login button { margin-top: 6px; background: var(--on); color: var(--on-ink); border: 0; border-radius: 3px; padding: 8px; font-weight: 600; }
.login-error { min-height: 1.3em; color: var(--danger); }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 1100px) {
  .browser { position: fixed; right: 0; top: 44px; bottom: 58px; z-index: 5; box-shadow: -8px 0 24px rgba(0,0,0,.4); }
  .transport { grid-template-columns: 1fr; justify-items: center; }
  .tp-left, .tp-right { justify-content: center; }
  .song, kbd { display: none; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .brand span, .listen input, .audio-info { display: none; }
  .tp-center { flex-wrap: wrap; justify-content: center; }
  .browser { width: 100%; }
}
.login-hint { margin: 4px 0 0; color: var(--text-faint); font-size: 12px; }
