:root {
  color-scheme: light;
  --paper: #eae4d9;
  --panel: #f5f0e6;
  --ink: #26231e;
  --muted: #655d51;
  --line: #d9cfc0;
  --amber: #ffc06c;
  --rust: #a04a22;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.45 system-ui, sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #af5b27; outline-offset: 4px; }

.shell {
  max-width: 1144px;
  padding: 0 clamp(20px, 5vw, 64px) 44px;
  margin: auto;
}
.masthead, .intro, .display-head, .display-foot, .range-label, .volume {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.masthead { min-height: 72px; border-bottom: 1px solid #cfc4b2; }
.brand { display: flex; gap: 11px; align-items: center; font-weight: 740; font-size: 17px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: var(--ink);
}
.brand-mark i { width: 2px; height: 6px; background: var(--amber); }
.brand-mark i:nth-child(even) { height: 11px; }
.brand-mark i:nth-child(3) { height: 16px; }
.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 11px var(--mono); }
.connection i { width: 6px; height: 6px; border: 1px solid var(--rust); border-radius: 50%; }

.intro { align-items: end; gap: 20px; padding: 32px 0 27px; }
.label { font: 600 11px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .12em; }
.intro-label { margin: 0 0 10px; color: var(--rust); }
h1 {
  margin: 0;
  font: 400 clamp(44px, 6.6vw, 86px)/.98 Georgia, serif;
  letter-spacing: -.07em;
}
h1 span { color: var(--rust); }
.intro-copy { margin: 0 1px 2px 0; color: var(--muted); font-size: 13px; }

.instrument {
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #cfc4b2;
  border-radius: 18px;
  box-shadow: 0 23px 45px -29px #5946227d;
}
.display {
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: 17px;
  padding: 23px 24px 20px;
  background: radial-gradient(ellipse at 50% 50%, #393027, #242019 78%);
  color: #e5c9a6;
}
.display-head, .display-foot { width: 100%; }
.display-head { flex-wrap: wrap; gap: 8px; }
.display-title { display: inline-flex; align-items: center; gap: 9px; }
.pilot { width: 7px; height: 7px; border-radius: 50%; background: #8b6d4e; }
.display[data-live="true"] .pilot { background: var(--amber); box-shadow: 0 0 12px #ffad55b3; }
.display-controls { display: flex; gap: 6px; align-items: stretch; margin-left: auto; }
.display-modes { display: flex; gap: 2px; padding: 3px; background: #1a1713; border: 1px solid #514436; border-radius: 7px; }
.display-controls button {
  min-height: 24px;
  padding: 5px 9px;
  border: 0;
  border-radius: 4px;
  color: #cdb395;
  background: transparent;
  font: 11px var(--mono);
}
.display-controls #walker { border: 1px solid #705137; border-radius: 7px; background: #1a1713; }
.display-controls button[aria-pressed="true"],
.display-controls #walker[aria-pressed="true"] { color: #20180f; background: #ddaa70; }
.display-controls button:focus-visible { outline-color: var(--amber); }
.dial-stage { width: 100%; align-self: center; display: grid; justify-items: center; gap: 20px; }
.display-options { min-height: 32px; display: grid; place-items: center; }
.display-switch:not([hidden]) { display: inline-flex; align-items: center; gap: 12px; min-height: 32px; cursor: pointer; font: 11px var(--mono); }
.display-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.display-switch .toggle { background: #63513f; }
.display-switch input:checked + .toggle { background: #b4793f; }
.display-switch input:checked + .toggle::before { transform: translateX(14px); }
.display-switch input:focus-visible + .toggle { outline: 2px solid var(--amber); outline-offset: 4px; }
.dial-bezel {
  align-self: center;
  width: min(100%, 350px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 13px;
  background: linear-gradient(145deg, #715c43 0%, #3c3024 34%, #232018 65%, #695237);
  border: 1px solid #786044;
  box-shadow: 0 16px 24px #16110db3, inset 0 1px #9f83614f;
}
.dial-window {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid #120d08;
  box-shadow: 0 0 0 4px #18140f;
  background: #201810;
}
.dial-window::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse at 35% 21%, #ffba6515, transparent 50%),
    repeating-linear-gradient(0deg, #120d081a 0 1px, transparent 1px 4px);
  box-shadow: inset 0 0 24px 7px #130e0a98;
  pointer-events: none;
}
canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#pixel-display { position: absolute; inset: 0; pointer-events: none; }
.display-foot { gap: 14px; padding-top: 15px; border-top: 1px solid #544637; }
.display-foot span { display: inline-flex; align-items: baseline; gap: 8px; }
.caption { color: #bb9d7d; }
.display-foot output { color: var(--amber); font-variant-numeric: tabular-nums; }

.console { min-width: 0; padding: 25px 27px 21px; background: var(--panel); }
.ensemble-control { margin-top: 15px; }
#ensemble { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--paper); font: 13px var(--mono); }
.ensemble-control .field-help { margin-bottom: 0; }
.performance-control { margin: 13px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.performance-control summary { cursor: pointer; font: 12px var(--mono); }
#performance-pad { width: 100%; height: 112px; border-radius: 6px; touch-action: none; cursor: crosshair; }
.performance-range { display: block; margin: 8px 0; font: 12px var(--mono); }
.performance-range span { display: flex; justify-content: space-between; }
.performance-range output { color: var(--rust); font-variant-numeric: tabular-nums; }
.performance-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#motion-toggle[aria-pressed="true"] { border-color: var(--rust); color: var(--rust); }
.play {
  width: 100%;
  min-height: 51px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff3df;
  font-weight: 660;
}
.play:hover { background: #3d3024; }
.play:disabled { cursor: wait; opacity: .7; }
.transport-icon {
  width: 0;
  height: 0;
  border-block: 6px solid transparent;
  border-left: 9px solid var(--amber);
}
.play[data-live="true"] .transport-icon { width: 10px; height: 10px; border: 0; background: var(--amber); }
#audio-error, #control-error { color: #8a371f; font-size: 13px; margin-bottom: 0; }
.sustain-control { margin-top: 15px; }
.timbre { min-width: 0; margin: 0 0 9px; padding: 0; border: 0; }
.timbre legend { color: var(--muted); padding: 0; }
.timbre-presets { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 8px; }
.timbre-presets label { flex: 1 1 auto; cursor: pointer; }
.timbre-presets input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.timbre-presets span {
  display: block;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.timbre-presets input:checked + span { background: #eed8bb; border-color: #b68456; color: #4a2a16; }
.timbre-presets input:focus-visible + span { outline: 2px solid var(--rust); outline-offset: 2px; }
.timbre-display {
  padding: 8px 10px 5px;
  border: 1px solid #4e3b29;
  border-radius: 7px;
  background: #2a221a;
  color: #dfba90;
}
.timbre-display .label { display: block; font-size: 9px; }
#timbre-wave, #harmonic-curve { height: auto; image-rendering: auto; }
#harmonic-help { margin: 8px 0 4px; color: var(--muted); font-size: 12px; }
#harmonic-curve { border: 1px solid var(--line); border-radius: 7px; background: #efe5d7; cursor: ns-resize; touch-action: none; }
.harmonic-levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px 11px; margin: 4px 0 10px; }
.harmonic-levels label { display: flex; align-items: center; gap: 5px; color: var(--muted); font: 10px var(--mono); }
.harmonic-levels input { flex: 1; min-width: 0; }
.hold-note {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #ae7b4b;
  border-radius: 8px;
  background: #f1debf;
  color: #5c331c;
  font-weight: 660;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.hold-note::after { content: ""; width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 50%; }
.hold-note:disabled { cursor: default; color: var(--muted); background: transparent; border-color: var(--line); }
.hold-note:not(:disabled):hover { background: #f2d4a6; }
.hold-note[data-held="true"]:not(:disabled) { background: var(--amber); color: #382414; box-shadow: inset 0 0 0 1px #ae6a38; }
.hold-note[data-held="true"]::after { background: currentColor; }
#hold-help { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.voices { margin: 22px 0 0; padding: 0; min-width: 0; border: 0; }
.voices legend, .range-label label, .volume label { color: var(--muted); }
.voice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
}
.voice {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.voice strong, .voice small { display: block; }
.voice strong { font-size: 14px; font-weight: 660; }
.voice small { color: var(--muted); font-size: 12px; }
.voice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle { width: 33px; height: 19px; border-radius: 20px; background: #9f9587; padding: 3px; }
.toggle::before { content: ""; display: block; width: 13px; height: 13px; border-radius: 50%; background: #fff8e9; }
.voice input:checked + .toggle { background: #a4532a; }
.voice input:checked + .toggle::before { transform: translateX(14px); }
.voice input:focus-visible + .toggle { outline: 2px solid var(--rust); outline-offset: 4px; }
.audience { padding: 17px 0 13px; border-bottom: 1px solid var(--line); }
.range-label { gap: 8px; }
.range-label output { color: var(--rust); font: 650 23px/1 var(--mono); }
input[type="range"] { accent-color: var(--rust); width: 100%; margin: 0; cursor: pointer; }
.audience input { margin-top: 10px; }
.audience p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.volume { gap: 12px; padding-top: 14px; }
.volume input { flex: 1; min-width: 30px; }
.volume output { flex: 0 0 4ch; font: 12px var(--mono); text-align: right; }

@media (max-width: 740px) {
  .masthead { min-height: 60px; }
  .intro { align-items: start; flex-direction: column; gap: 12px; padding: 24px 0 20px; }
  .intro-copy br { display: none; }
  .instrument { grid-template-columns: minmax(0, 1fr); }
  .display, .console { padding-inline: clamp(15px, 5vw, 28px); }
  .dial-bezel { width: min(100%, 310px); }
}
@media (min-width: 741px) and (max-width: 1000px), (max-width: 430px) {
  .voice small { display: none; }
  .voice { min-height: 43px; gap: 7px; }
  .voice-grid { column-gap: 12px; }
}

[hidden] { display: none !important; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171918;
  --panel: #222522;
  --ink: #eee7db;
  --muted: #b7b7a9;
  --line: #3a3f38;
  --rust: #e2a677;
}
.masthead { border-color: var(--line); }
.masthead-actions, .session-actions { display: flex; gap: 15px; align-items: center; }
.quiet-button, .action-button, .text-button {
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 12px;
  font: 12px/1.4 var(--mono);
}
.quiet-button { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.quiet-button:hover, .quiet-button[aria-expanded="true"] { background: var(--panel); border-color: var(--rust); }
.action-button { border: 1px solid #9b643d; color: #26190e; background: #dfb084; }
.action-button:hover { background: #edc297; }
.text-button { border: 0; background: transparent; color: var(--rust); }
button:disabled { opacity: .5; cursor: default; }
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.room-readout { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: baseline; min-width: 0; }
#current-room { font: 600 15px var(--mono); overflow-wrap: anywhere; }
#room-countdown, .presence-readout { font: 11px var(--mono); color: var(--muted); }
#room-countdown { color: var(--rust); font-variant-numeric: tabular-nums; }
.session-actions { flex-shrink: 0; gap: 7px; }
.rooms-panel:not([hidden]) { display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; padding: 23px; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.rooms-panel h2, .recording-panel h2, .console-heading { margin: 0; font-size: 16px; font-weight: 650; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-help { color: var(--muted); font-size: 12px; margin: 8px 0 15px; }
.room-list { padding: 0; margin: 0; list-style: none; max-height: 270px; overflow-y: auto; }
.room-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.room-description { min-width: 0; }
.room-description strong { display: block; font: 600 12px var(--mono); overflow-wrap: anywhere; }
.room-description small { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; }
.room-list button { flex-shrink: 0; }
.room-create { border-left: 1px solid var(--line); padding-left: 26px; }
.room-create h2 { margin-bottom: 15px; }
.room-create form > label, .join-form > label { display: block; font-size: 12px; margin-bottom: 7px; }
.room-name-field { display: flex; align-items: center; gap: 7px; padding-left: 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--rust); }
.room-name-field input { min-width: 0; width: 100%; border: 0; padding: 10px 10px 10px 0; background: transparent; color: var(--ink); font: 13px var(--mono); }
.room-create form > .private-option { display: flex; align-items: center; gap: 7px; margin: 14px 0; }
.private-option input { accent-color: var(--rust); }
.room-invite { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); }
#invite-code { display: block; font: 600 28px var(--mono); letter-spacing: .2em; margin-top: 7px; color: var(--rust); }
#invite-copy { margin-top: 12px; }
.join-form { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.input-action { display: flex; gap: 7px; flex-wrap: wrap; }
#room-code { padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); width: 120px; font: 15px var(--mono); letter-spacing: .15em; }
.form-error, #audio-error, #control-error { color: #a43c2c; font-size: 13px; }
.community-notice { color: var(--muted); font-size: 13px; }
.instrument { border-color: var(--line); }
.display { min-height: 600px; grid-template-rows: auto 1fr auto auto; }
.display .transport { width: min(100%, 350px); }
.display .play { background: #ddaa70; color: #21180f; }
.display .play:hover { background: #efbd84; }
.display .transport-icon { border-left-color: #533720; }
.display .play[data-live="true"] .transport-icon { background: #533720; }
.display #audio-error { color: #ffba9b; }
.instrument[data-settings="closed"] { grid-template-columns: minmax(0, 1fr); }
.instrument[data-settings="closed"] .display { min-height: 620px; }
.instrument[data-settings="closed"] .dial-bezel { width: min(100%, 390px); }
.console-heading { margin-bottom: 18px; }
.console .sustain-control { margin-top: 0; }
.recording-panel { margin-top: 18px; padding: 20px 23px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.pixel-panel { margin-top: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.pixel-panel summary { cursor: pointer; padding: 16px 20px; font-weight: 650; }
.pixel-panel h2 { margin: 0 0 10px; font-size: 15px; }
.pixel-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 22px; padding: 0 20px 18px; }
.pixel-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 7px; }
.pixel-preset { display: flex; gap: 8px; align-items: center; padding: 6px 8px; text-align: left; }
.pixel-preset canvas { width: 24px; height: 24px; flex: 0 0 24px; background: #2b1e14; border-radius: 3px; }
.pixel-grid { display: grid; grid-template-columns: repeat(8, 1fr); width: min(100%, 256px); aspect-ratio: 1; touch-action: none; user-select: none; background: #30241a; }
.pixel-grid button { min-width: 0; padding: 0; border: 1px solid #533b29; border-radius: 0; background: #2b2119; }
.pixel-grid button[aria-pressed="true"] { background: #ffc775; border-color: #a37449; }
.pixel-grid button:focus-visible { position: relative; outline: 2px solid #fff0cb; outline-offset: -3px; }
.pixel-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#pixel-erase[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
#pixel-status { margin: 8px 0 0; min-height: 1.4em; color: var(--muted); font-size: 12px; }
@media (max-width: 620px) { .pixel-layout { grid-template-columns: minmax(0, 1fr); } }
.recording-heading { display: flex; gap: 14px; justify-content: space-between; align-items: center; }
.queue-readout { font: 11px var(--mono); color: var(--muted); }
.recording-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
#record-preview { width: min(100%, 300px); height: 40px; }
#record-status { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
#record-status:empty { display: none; }
:root[data-theme="dark"] .brand-mark { background: #dfb084; }
:root[data-theme="dark"] .brand-mark i { background: #27251d; }
:root[data-theme="dark"] .timbre-presets input:checked + span { background: #4d3d2d; border-color: #a78059; color: #f7d7b1; }
:root[data-theme="dark"] #harmonic-curve { background: #493e31; }
:root[data-theme="dark"] .hold-note { background: #46382a; color: #f1c89a; }
:root[data-theme="dark"] .hold-note:disabled { background: transparent; color: var(--muted); }
:root[data-theme="dark"] .hold-note:not(:disabled):hover { background: #594431; }
:root[data-theme="dark"] .hold-note[data-held="true"]:not(:disabled) { background: #dba36b; color: #251b10; }
:root[data-theme="dark"] .form-error, :root[data-theme="dark"] #control-error { color: #ffb09a; }
@media (max-width: 740px) {
  .masthead { gap: 12px; flex-wrap: wrap; padding-block: 12px; }
  .masthead-actions { gap: 8px; }
  .masthead .connection { font-size: 10px; }
  .masthead #theme-toggle { padding: 6px 8px; font-size: 10px; min-height: 32px; }
  .session-bar { align-items: start; flex-direction: column; gap: 14px; }
  .session-actions { width: 100%; }
  .session-actions button { flex: 1; }
  .rooms-panel:not([hidden]) { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 22px; }
  .room-create { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 20px; }
  .display, .instrument[data-settings="closed"] .display { min-height: 510px; }
  .instrument[data-settings="closed"] .dial-bezel { width: min(100%, 310px); }
  .recording-panel { padding: 18px; }
}
@media (prefers-reduced-motion: no-preference) {
  .quiet-button, .action-button { transition: background-color .15s, border-color .15s; }
}
