:root {
  --bg: #0d0f0d;
  --panel: #131513;
  --panel-sunken: #080908;
  --line: #3a352e;
  --line-bright: #5f594f;
  --text: #ece9df;
  --muted: #a6a195;
  --dim: #6c665b;
  --green: #72d06c;
  --green-dim: #183817;
  --green-bd: #2d6b2d;
  --purple: #d06cff;
  --purple-dim: #241334;
  --purple-bd: #6f35a4;
  --gold: #e1c241;
  --gold-dim: #2d2810;
  --gold-bd: #7c691b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, "Cascadia Code", "Roboto Mono", monospace;
  font-size: var(--fs-body, 10px);
  line-height: 1.5;
  padding: 16px;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 1px solid var(--line-bright);
  outline-offset: 2px;
}

.top {
  max-width: 880px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-nav, 11px);
}
.top a { color: var(--green); letter-spacing: 0.04em; transition: color 0.12s ease; }
.top a:hover, .top a:active { color: var(--purple); }
.top a:first-child:hover, .top a:first-child:active { color: var(--gold); }
.top .nr-theme-switch { margin-left: auto; }

.studio-shell { max-width: 820px; margin: 0 auto; }
.studio-panel {
  overflow: hidden;
  border: 0.5px solid var(--line-bright);
  border-radius: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--purple) 4%, transparent), transparent 42%), var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}
.studio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-bottom: 0.5px solid var(--line);
}
h1, h2, p { margin: 0; }
h1 { color: var(--gold); font-size: 12px; font-weight: 500; letter-spacing: 0.08em; }
h2 { color: var(--purple); font-size: 10px; font-weight: 500; letter-spacing: 0.1em; margin-bottom: 9px; }
.studio-head p { margin-top: 3px; color: var(--dim); font-size: 9px; }

.power {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 22px;
  padding: 3px 8px;
  border: 0.5px solid var(--line);
  border-radius: 6px;
  background: var(--panel-sunken);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
}
.power[aria-pressed="true"] { border-color: var(--gold-bd); color: var(--gold); background: color-mix(in srgb, var(--gold-dim) 84%, var(--panel)); }
/* record-style indicator: green normally, red on the blood theme (where --green
   is remapped to red) — reads as "armed/recording" against the gold button. */
.led { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.power[aria-pressed="true"] .led { background: var(--green); box-shadow: 0 0 8px var(--green); }

.module { padding: 12px; border-bottom: 0.5px solid var(--line); }
.status-module { background: color-mix(in srgb, var(--panel-sunken) 40%, transparent); }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.status-grid div, .diagnostics div { display: grid; gap: 2px; }
.status-grid span, .diagnostics span { color: var(--dim); font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; }
.status-grid strong, .diagnostics strong { color: var(--green); font-size: 10px; font-weight: 500; }

.control { margin-top: 9px; }
.control:first-of-type { margin-top: 0; }
.control-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
label { color: var(--muted); font-size: 10px; letter-spacing: 0.04em; }
.control-head label { flex: 1; }
.value { flex: none; color: var(--text); font-size: 10px; font-variant-numeric: tabular-nums; }
input[type="range"] {
  width: 100%;
  appearance: none;
  height: 3px;
  border: 0;
  border-radius: 3px;
  background: var(--line);
  cursor: pointer;
  display: block;
}
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 0; }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 0; }

.choice-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
select {
  min-height: 25px;
  padding: 3px 22px 3px 7px;
  border: 0.5px solid var(--line);
  border-radius: 5px;
  background: var(--panel-sunken);
  color: var(--green);
}
.route-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.route-buttons button, .quiet-button {
  min-height: 24px;
  padding: 3px 8px;
  border: 0.5px solid var(--line);
  border-radius: 5px;
  background: var(--panel-sunken);
  color: var(--muted);
}
.route-buttons button:hover, .route-buttons button:focus-visible, .quiet-button:hover, .quiet-button:focus-visible { color: var(--green); border-color: var(--green-bd); }
.route-buttons button[aria-pressed="true"] { color: var(--gold); border-color: var(--gold-bd); }

.meters { display: grid; gap: 6px; }
.meter-row { display: grid; grid-template-columns: 76px minmax(80px, 1fr) 48px minmax(70px, 120px); align-items: center; gap: 8px; }
.meter-row > span { color: var(--muted); }
.meter-row i { display: block; height: 4px; overflow: hidden; border-radius: 4px; background: var(--panel-sunken); }
.meter-row b { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width 0.1s linear; }
.meter-row strong { color: var(--dim); font-size: 9px; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

.module-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.module-head h2 { margin-bottom: 0; }
.quiet-button { font-size: 9px; }
.sequencer { display: grid; grid-template-columns: repeat(32, 1fr); gap: 2px; margin-top: 10px; }
.sequencer i { height: 22px; border: 0.5px solid var(--line); background: var(--panel-sunken); }
.sequencer i:nth-child(8n + 1) { border-left-color: var(--line-bright); }
.sequencer i.note { background: color-mix(in srgb, var(--green) 58%, var(--panel-sunken)); }
.sequencer i.hover-phrase { box-shadow: inset 0 -4px var(--purple); }
.sequencer i.click-phrase { box-shadow: inset 0 -4px var(--gold); }
.sequencer i.nav-kick { border-bottom-color: var(--gold); border-bottom-width: 3px; }
.sequencer i.active { outline: 1px solid var(--text); outline-offset: -2px; }
.summary { margin-top: 7px; color: var(--dim); font-size: 9px; }

.advanced summary {
  padding: 10px 12px;
  color: var(--purple);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.1em;
}
.diagnostics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 12px 12px; }
.diagnostics strong { color: var(--muted); word-break: break-word; }

@media (max-width: 620px) {
  body { padding: 12px; }
  .studio-head { align-items: flex-start; flex-direction: column; }
  .status-grid, .diagnostics { grid-template-columns: repeat(2, 1fr); }
  .sequencer { grid-template-columns: repeat(16, 1fr); }
  .sequencer i { height: 18px; }
  .meter-row { grid-template-columns: 62px minmax(60px, 1fr) 42px; }
  .meter-row input { grid-column: 2 / 4; }
}
