:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; touch-action: pan-x pan-y; }
body { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #e8f5e0; }
#stage, #stage2d, #stagescope { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
/* Tap ripples: a click-through overlay above whichever view is showing. */
#ripples { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; pointer-events: none; }
#stage.off, #stage2d.off, #stagescope.off { display: none; }
/* 3D-only controls (camera speed, flight mode) exist only in the 3D view. */
body:not(.view-3d) .only3d { display: none; }

/* Reserve room for the exterior tab, including narrow phones and safe areas. */
:root { --controls-width: min(360px, calc(100vw - 44px - env(safe-area-inset-left, 0px))); }
#ui {
  position: fixed; top: 0; right: 0; z-index: 20; width: var(--controls-width);
  max-height: 100dvh; height: 100dvh; overflow-y: auto; overflow-x: hidden;
  scroll-padding-top: 76px;
  padding: 0 18px 24px; padding-right: max(18px, env(safe-area-inset-right, 0px));
  background: rgba(8, 10, 6, 0.92); border-left: 3px solid #b6ff2e;
  transition: transform .3s ease, visibility 0s; touch-action: pan-y;
  overscroll-behavior: contain;
}
body.panel-hidden #ui {
  transform: translateX(100%); pointer-events: none; visibility: hidden;
  transition: transform .3s ease, visibility 0s .3s;
}
#reopen {
  position: fixed; top: 42%; right: var(--controls-width); z-index: 30;
  width: 44px; min-height: 128px; max-height: 50dvh;
  writing-mode: vertical-rl; padding: 12px 10px; font-size: 12px; letter-spacing: .14em;
  background: #b6ff2e; color: #0c0f08; border: 0; border-radius: 8px 0 0 8px;
  transition: transform .3s ease; touch-action: pan-y; cursor: grab;
  user-select: none; -webkit-user-select: none;
}
body.panel-hidden #reopen { transform: translateX(var(--controls-width)); cursor: pointer; }
/* After a swipe-close, hide only the visual tab. Its accessible touch/keyboard
   target remains; focus or deliberate pointer activity restores the visual. */
body.panel-hidden.controls-tab-dormant #reopen { opacity: 0; }
#ui.dragging, #reopen.dragging { transition: none; }
body.panel-hidden #ui.dragging { visibility: visible; transition: none; }
.controls-title { position: sticky; top: 0; z-index: 2; padding: 10px 0; background: #080a06; }
.controls-title h1 { display: flex; align-items: center; gap: 8px; margin: 0; }
#hidepanel { flex: 0 0 44px; min-height: 44px; margin-left: auto; padding: 8px; font-size: 22px; }
button:focus-visible { outline: 3px solid #ff5db1; outline-offset: 2px; }
.discrete-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.discrete-choices button { flex: 1 1 auto; min-height: 44px; background: #23331a; color: #d8ffb0; border: 1px solid #b6ff2e; }
.discrete-choices button[aria-pressed="true"] { background: #b6ff2e; color: #0c0f08; border-color: #b6ff2e; }
/* Account & 2D / 3D switch at the top of the panel. */
.account-panel { border-top: 0; padding-top: 6px; margin-top: 0; }
/* Visible account identifier: first functional section on a fresh opening,
   never covered by the sticky controls title (settled account visibility). */
#account-heading { margin: 0 0 8px; font-size: 15px; color: #ff5db1; }
.sheet-help { border-top: 1px dashed #3d5230; margin-top: 10px; }
.sheet-help summary {
  cursor: pointer; font-size: 12.5px; font-weight: 700; color: #ffe600;
  display: flex; align-items: center; min-height: 44px; padding: 4px 0;
}
.viewswitch { border-top: 1px dashed #3d5230; padding-top: 12px; margin-top: 10px; }
#viewtoggle {
  display: flex; align-items: stretch; width: 100%; padding: 0; gap: 0; font-size: 15px;
  background: #131a0e; color: #e8f5e0; border: 2px solid #b6ff2e; cursor: pointer;
}
#viewtoggle:hover { background: #131a0e; }
#viewtoggle:focus-visible { outline: 3px solid #ff5db1; outline-offset: 2px; }
#viewtoggle .vt-label { flex: 1; text-align: left; padding: 10px 12px; font-weight: 400; letter-spacing: 0.1em; color: #9db98d; }
#viewtoggle .vt-seg { min-width: 64px; text-align: center; padding: 10px 12px; font-weight: 700; color: #d8ffb0; }
#viewtoggle .vt-seg.on { background: #b6ff2e; color: #0c0f08; }
#preset-picker { min-width: 0; }
#preset-navigation { display: flex; align-items: stretch; gap: 6px; min-width: 0; }
#preset-navigation > button, #preset-disclosure {
  flex: 0 0 44px; min-width: 44px; min-height: 44px; padding: 4px;
  background: #131a0e; color: #d8ffb0; border: 1px solid #b6ff2e;
  font-size: 22px; line-height: 1; cursor: pointer;
}
#preset-navigation > button:hover, #preset-disclosure:hover { background: #23331a; }
#preset-current {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 5px 6px;
  border: 1px solid #3d5230; background: #080a06; color: #e8f5e0;
  text-align: center;
}
#preset-current-name { min-width: 0; overflow-wrap: anywhere; font-size: 12px; line-height: 1.25; }
#preset-current-view, #presets button .pv {
  flex: 0 0 auto; color: #b6ff2e; font-size: 10px; letter-spacing: 0.08em;
}
#preset-navigation > #preset-disclosure {
  display: grid; flex: 0 0 48px; place-content: center; justify-items: center; gap: 2px;
  min-width: 48px; min-height: 44px; margin: 0; padding: 3px;
  color: #ffe600; border: 2px solid #b6ff2e; background: #253612;
}
#preset-disclosure-icon { font-size: 19px; line-height: 1; }
#preset-disclosure-caption { font-size: 9px; line-height: 1; letter-spacing: 0; white-space: nowrap; }
#preset-navigation > #preset-disclosure[aria-expanded="true"] {
  color: #0c0f08; background: #b6ff2e;
}
#presets[hidden] { display: none; }
#presets:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 6px; }
#presets button {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; min-width: 0; min-height: 44px; padding: 6px 8px;
  background: #3a1530; color: #ffd7ef; border: 1px solid #ff5db1;
  font-weight: 400; text-align: left; cursor: pointer;
}
#presets button:hover, #presets button[aria-pressed="true"] { background: #ff5db1; color: #160510; }
#presets button[aria-pressed="true"] .pv { color: inherit; }
#presets button .preset-name { min-width: 0; white-space: normal; overflow-wrap: anywhere; }

h1 { font-size: 21px; line-height: 1.15; margin: 2px 0 8px; letter-spacing: 0.04em; color: #ffe600; }
h2 { font-size: 15px; margin: 0 0 6px; color: #ff5db1; }
.sub, p { font-size: 12.5px; line-height: 1.55; color: #cfe8bd; }
.hint { font-size: 11.5px; color: #9db98d; }
.hint code { color: #ffe600; }
.panel { border-top: 1px dashed #3d5230; padding: 14px 0 6px; margin-top: 10px; }
.panel.row { display: flex; flex-wrap: wrap; gap: 8px; }
label { display: block; font-size: 12px; margin: 10px 0 4px; color: #fff; }
label output { color: #ffe600; float: right; }
label.check { display: flex; gap: 8px; align-items: center; margin-top: 14px; cursor: pointer; }

input[type="text"], select {
  width: 100%; padding: 10px; font: inherit; font-size: 14px; color: #fff;
  background: #131a0e; border: 2px solid #b6ff2e; border-radius: 0;
}
input[type="text"]:focus, select:focus { outline: 2px solid #ff5db1; outline-offset: 1px; }
input[type="range"] { width: 100%; accent-color: #ff5db1; height: 26px; }
.slider { margin-bottom: 2px; }

#chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; max-width: 100%; }
button {
  font: inherit; font-size: 12px; padding: 8px 12px; cursor: pointer;
  color: #0c0f08; background: #b6ff2e; border: 0; border-radius: 0; font-weight: 700;
}
button:hover { background: #ffe600; }
#chips button { background: #23331a; color: #d8ffb0; border: 1px solid #b6ff2e; font-weight: 400; padding: 4px 8px; font-size: 11.5px; }
#chips button:hover, #chips button.on { background: #b6ff2e; color: #0c0f08; }

/* Removable shape chip editor */
#shapes-editor {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  background: #131a0e;
  border: 2px solid #b6ff2e;
  cursor: text;
}
#shapes-editor:focus-within {
  outline: 2px solid #ff5db1;
  outline-offset: 1px;
}
#shapes {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
#shape-chips {
  display: contents;
}
.shape-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 34px 4px 10px;
  background: #23331a;
  border: 1px solid #b6ff2e;
  border-radius: 999px;
  color: #ffe600;
  font-size: 12.5px;
  line-height: 1.2;
  max-width: 100%;
}
.shape-chip.inactive {
  opacity: 0.5;
  border-style: dashed;
  color: #9db98d;
}
.shape-chip-text {
  overflow-wrap: anywhere;
}
.shape-chip-x {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 3px 6px 0 0;
  margin: 0;
  display: inline-flex;
  align-items: flex-start;
  justify-content: flex-end;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: #ff5db1;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.shape-chip-x:hover, .shape-chip-x:focus-visible {
  background: rgba(255, 93, 177, 0.22);
  color: #ffe600;
  outline: none;
}
#shapes-input {
  flex: 1 1 110px;
  min-width: 90px;
  width: auto;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 14px;
}
#shapes-input:focus {
  outline: none;
}
a.dl {
  display: inline-block; margin: 4px 6px 4px 0; padding: 10px 14px;
  background: #ff5db1; color: #160510; font-weight: 700; font-size: 13px; text-decoration: none;
}
a.dl.alt { background: #ffe600; }
a.dl:hover { filter: brightness(1.2); }

#glfail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #ffe600; color: #111; padding: 14px 18px;
  font-size: 14px; font-weight: 700; text-align: center;
}
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: #ffe600; color: #111; padding: 10px 16px; font-size: 13px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
#toast.show { opacity: 1; }

/* Audio reactivity panel + patch panel. */
#audiopanel .row { display: flex; gap: 8px; margin: 8px 0; }
#audio-stop { background: #ff3b3b; color: #1a0303; }
#audio-stop:hover { background: #ff7a7a; }
#audio-msg { min-height: 1.4em; margin: 6px 0; }
#audio-mic-input:disabled {
  opacity: 1; color: #a9c196; border-color: #668d3a;
  -webkit-text-fill-color: #a9c196;
}
#audio-mic-permission { margin-top: 5px; margin-bottom: 8px; }
#audio-mic-monitor-label { margin-top: 12px; }
#audio-mic-details { margin-top: 8px; }
#patchpanel summary { cursor: pointer; font-size: 13px; color: #ffe600; margin: 8px 0; }
.patchadd { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: center; }
.patchadd select { padding: 6px; font-size: 12px; }
.patchadd input[type="range"] { grid-column: 1 / 2; }
.patchadd output { color: #ffe600; font-size: 12px; text-align: right; }
#route-add { grid-column: 1 / 3; }
#routes { list-style: none; margin: 8px 0 0; padding: 0; }
#routes li { display: flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 4px 0; border-top: 1px dotted #3d5230; }
#routes li .rdesc { flex: 1; color: #cfe8bd; }
#routes li input[type="range"] { width: 90px; height: 20px; }
#routes li button { padding: 3px 8px; font-size: 11px; }
@media (prefers-reduced-motion: reduce) { #ui, #reopen, body.panel-hidden #ui { transition: none; } }

/* Demo mode (?demo=1): controls permanently hidden from first paint (before WASM loads), no overlays/toasts/ripples/audio UI, cursor hidden, touch-action: auto on canvases so swiping the embed scrolls the parent page. */
html.demo-mode, html.demo-mode *,
body.demo-mode, body.demo-mode * { cursor: none !important; }
html.demo-mode #stage, html.demo-mode #stage2d,
body.demo-mode #stage, body.demo-mode #stage2d { touch-action: auto; }
html.demo-mode #ui,
html.demo-mode #reopen,
html.demo-mode #toast,
html.demo-mode #glfail,
html.demo-mode #ripples,
html.demo-mode #audiopanel,
html.demo-mode #luvcrux-lang-top,
body.demo-mode #ui,
body.demo-mode #reopen,
body.demo-mode #toast,
body.demo-mode #glfail,
body.demo-mode #ripples,
body.demo-mode #audiopanel,
body.demo-mode #luvcrux-lang-top {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}


/* Bounded modular panel; labels remain usable on narrow touch screens. */
.evolution-grid, .osc-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.oscillator, .synthetic-generator { margin:10px 0; border:1px solid #584472; border-radius:8px; padding:8px; }
.oscillator summary, .synthetic-generator summary { cursor:pointer; padding:6px 0; }
.osc-grid label, .osc-links label { display:flex; flex-direction:column; gap:4px; font-size:12px; }
.osc-grid input, .osc-grid select, .osc-links input, .osc-links select { box-sizing:border-box; width:100%; min-width:0; padding:8px; color:#eee; background:#160d25; border:1px solid #584472; border-radius:5px; }
.evolution-grid .check { margin:3px 0; }
@media(max-width:350px) { .osc-grid, .evolution-grid { grid-template-columns:1fr; } }

#scope-view { width:100%; margin-top:8px; }
#scope-view[aria-pressed="true"] { background:#5ce9c4; color:#08151a; }
body:not(.view-scope) #scope-panel { display:none; }
#scope-panel { border-color:#5ce9c4; }
#scope-panel input[type="number"] { width:100%; min-width:0; padding:9px; font:inherit; color:#ecffff; background:#101d24; border:1px solid #5ce9c4; }
#scope-panel fieldset { margin:12px 0; padding:8px; min-width:0; border:1px solid #456068; }
#scope-panel legend { color:#5ce9c4; }
#scope-status { color:#5ce9c4; }
.scope-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:12px; }

.osc-feedback { display: grid; gap: 6px; margin: 8px 0; }
.osc-preview { width: 100%; max-width: 240px; height: 64px; }
.osc-feedback output { font-size: 12px; overflow-wrap: anywhere; }
.osc-links { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.osc-links p { grid-column: 1 / -1; font-size: 12px; margin: 0; }
.osc-links label { min-width: 0; }
.osc-links select, .osc-links input { width: 100%; min-width: 0; min-height: 44px; box-sizing: border-box; }
@media (prefers-reduced-motion: reduce) { .osc-preview { display: none; } }

.osc-connection { min-width:0; margin:10px 0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.osc-connection[hidden], .oscillator [hidden], #mod-config-status[hidden] { display:none !important; }
.osc-connection label { min-width:0; display:flex; flex-direction:column; gap:4px; font-size:12px; }
.osc-connection input, .osc-connection select, .oscillator button, .osc-toolbar button { min-height:44px; min-width:0; max-width:100%; box-sizing:border-box; }
.osc-connection select, .osc-connection input[type=number] { width:100%; padding:8px; color:#eee; background:#160d25; border:1px solid #584472; border-radius:5px; }
.osc-connection .check { flex-direction:row; align-items:center; }
.osc-connection output, .osc-route-help { grid-column:1/-1; font-size:12px; overflow-wrap:anywhere; }
.osc-toolbar { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:8px 0; }
.osc-import-label { display:inline-flex; flex-direction:column; gap:4px; font-size:11.5px; min-width:0; max-width:100%; margin:0; }
.osc-import-label input[type="file"] { max-width:100%; font-size:11.5px; }
.osc-env-editor { margin:8px 0; padding:8px; border:1px solid #584472; border-radius:6px; background:#11091d; min-width:0; }
.osc-env-canvas { display:block; width:100%; max-width:240px; height:88px; border:1px solid #7c5ba6; background:#0b0614; touch-action:none; cursor:crosshair; }
.osc-env-controls { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; margin-top:6px; min-width:0; }
.osc-env-controls label { display:flex; flex-direction:column; gap:4px; font-size:11.5px; min-width:0; margin:0; }
.osc-env-controls input, .osc-env-controls select { width:100%; min-width:0; min-height:44px; padding:6px; color:#eee; background:#160d25; border:1px solid #584472; border-radius:5px; box-sizing:border-box; }
.osc-env-actions { grid-column:1/-1; display:flex; flex-wrap:wrap; gap:6px; }
.osc-row-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
@media(max-width:350px) { .osc-connection, .osc-env-controls { grid-template-columns:1fr; } }

/* The fourth renderer shares the stage and responsive control panel. */
#stagesynth{position:fixed;inset:0;width:100%;height:100%;object-fit:contain;background:#05000d;pointer-events:none}
#stagesynth.off{display:none}
#synth-panel{display:none}
.view-synth #synth-panel{display:block}
#synth-panel input[type=file]{max-width:100%;font-size:12px}
#synth-family{min-width:0;border:1px solid #416849;padding:8px;margin-top:10px}
#synth-family[hidden]{display:none}
#synth-family .family-control{display:flex;flex-wrap:wrap;gap:6px;margin:7px 0}
#synth-family .family-control>*{max-width:100%}
#synth-family .port-list{max-height:260px;overflow:auto}
#synth-family .port-row{display:flex;flex-wrap:wrap;gap:10px}
#synth-family .mixer-row{min-width:0;margin:8px 0}
#synth-status{overflow-wrap:anywhere}
.viewswitch{flex-wrap:wrap}

#synth-view { width:100%; margin-top:8px; }
#synth-view[aria-pressed="true"] { background:#ff5db1; color:#190716; }

/* Foldable User Presets & Community Accounts */
.user-presets {
  margin-top: 12px;
  border: 1px solid #3d5230;
  background: rgba(19, 26, 14, 0.78);
  padding: 8px 10px;
  max-width: 100%;
  min-width: 0;
}
.user-presets summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #ffe600;
  padding: 4px 0;
  user-select: none;
}
.user-presets summary:focus-visible {
  outline: 2px solid #ff5db1;
  outline-offset: 2px;
}
.user-presets-body {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}
.user-presets [hidden], .user-presets-auth [hidden], #account-panel [hidden] {
  display: none !important;
}
.user-presets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.user-preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #1a1026;
  border: 1px solid #584472;
  min-width: 0;
  max-width: 100%;
}
.user-preset-row.permanent {
  border-color: #ffe600;
  background: #241432;
}
/* #168: inline user-name prompt shown when a signed-in user without a
   display name taps the heart on a community preset. */
.lvs-love-name-prompt {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 0 2px;
  border-top: 1px dotted #584472;
}
.lvs-love-name-msg {
  margin: 0;
  font-size: 12px;
  color: #ffe600;
  overflow-wrap: anywhere;
}
.lvs-love-name-prompt .lvs-inline-row button {
  min-height: 44px;
}
.lvs-love-name-prompt .lvs-inline-row input[type="text"] {
  min-height: 44px;
  font-size: 16px;
}
.lvs-love-name-status:empty {
  display: none;
}
.user-preset-apply {
  flex: 1 1 140px;
  min-width: 0;
  text-align: left;
  background: transparent;
  color: #ffd7ef;
  border: 0;
  padding: 4px 2px;
  font-weight: 700;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.user-preset-apply:hover {
  background: rgba(255, 93, 177, 0.18);
  color: #ffe600;
}
.user-preset-star {
  color: #ffe600;
  margin-right: 4px;
}
.user-preset-author {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #9db98d;
  overflow-wrap: anywhere;
}
.user-preset-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.user-preset-love {
  background: #23331a;
  color: #d8ffb0;
  border: 1px solid #b6ff2e;
  padding: 4px 8px;
  font-size: 11.5px;
  min-height: 32px;
}
.user-preset-love[aria-pressed="true"] {
  background: #ff5db1;
  color: #160510;
  border-color: #ff5db1;
}
.user-preset-love:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.user-preset-report, .user-preset-delete, .lvs-secondary-btn {
  background: #23331a;
  color: #cfe8bd;
  border: 1px solid #587046;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 400;
  min-height: 32px;
}
.user-preset-report:hover, .user-preset-delete:hover, .lvs-secondary-btn:hover {
  background: #ff5db1;
  color: #160510;
  border-color: #ff5db1;
}
.lvs-show-more {
  width: 100%;
  margin: 4px 0;
  text-align: center;
  font-weight: 700;
}
.user-preset-report-box {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  min-width: 0;
}
.user-preset-report-box input[type="text"] {
  flex: 1 1 120px;
  min-width: 0;
  padding: 6px;
  font-size: 12px;
}
.lvs-auth-box, .lvs-subpanel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.lvs-subpanel {
  border-top: 1px dotted #3d5230;
  padding-top: 8px;
}
.lvs-subhead {
  font-size: 12px;
  font-weight: 700;
  color: #ffe600;
}
.lvs-signin-row, .lvs-inline-row, .lvs-account-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.lvs-account-bar {
  justify-content: space-between;
}
.lvs-account-label {
  font-size: 12px;
  color: #ffe600;
  overflow-wrap: anywhere;
}
.lvs-auth-btn {
  flex: 1 1 130px;
  min-width: 0;
  min-height: 38px;
  padding: 7px 10px;
  font-size: 12px;
  background: #23331a;
  color: #d8ffb0;
  border: 1px solid #b6ff2e;
}
.lvs-auth-btn:disabled, #lvs-preset-submit-btn:disabled, #lvs-setting-save-btn:disabled, #lvs-display-name-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.lvs-inline-row input[type="text"] {
  flex: 1 1 140px;
  min-width: 0;
  padding: 7px 8px;
  font-size: 13px;
}
.lvs-inline-row button {
  flex: 0 0 auto;
  min-height: 36px;
  max-width: 100%;
}

/* Cap the account-panel lists so a full saved-settings list or many submitted
   presets cannot push the rest of the controls far below on small screens. */
#lvs-saved-settings-list,
#lvs-my-presets-list {
  max-height: 15rem;
  overflow-y: auto;
}

/* The auth wrapper is the keyboard-reachable discovery trigger (R1): tabbing
   into it fires focusin and loads provider state, which enables the buttons. */
.user-presets-auth:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

/* Keep panel form controls at >=16px on touch devices so iOS Safari does not focus-zoom. */
@media (pointer: coarse) {
  input, select, textarea { font-size: max(16px, 1em) !important; }
}

/* ===== Settled mobile framing (parent SETTLED-DESIGN-V1) =====
   Portrait <=540px: bounded bottom sheet (50dvh half, 86dvh expanded),
   visualViewport-aware with a dvh->vh fallback. Short landscape: compact
   right drawer. Desktop: existing drawer, untouched. */
:root { --vvh-unit: 100dvh; }
@supports not (height: 1dvh) { :root { --vvh-unit: 100vh; } }
:root { --vvh: var(--app-vvh, var(--vvh-unit)); --vv-bottom: var(--app-vv-bottom, 0px); }


/* ===== Finite CSS layout facts (parent SETTLED-MATCHMEDIA-FALLBACK /
   SETTLED-HYBRID-TOUCH-DRAG) =====
   These variables are the SAME facts the overlapping media blocks apply:
   P portrait sheet, C compact landscape (primary coarse), Q primary pointer
   code (none 0 / fine 1 / coarse 2 / unknown 3 by omission), R reduced
   motion tri-state (explicit reduce, explicit no-preference, or unknown when
   neither matches), H touch sizing (coarse OR any-coarse). The inert
   sentinel width is 1+mask px, mask = P + 2*C + 4*Qcode + 16*Rreduce +
   32*H + 64*Rno-preference. The 3ce encoding already fixed H at 32, so the
   added no-preference fact takes the free bit 64 rather than remapping H.
   Unknown reduced motion is NOT encoded as
   no-preference: both explicit media blocks stay off, and the product then
   scrolls Auto. JS reads the computed width only when matchMedia observation
   is unavailable; the sentinel never contributes layout, scrolling, focus,
   hit testing or motion. Q stays 12px (code 3 = unknown/invalid) unless a
   real pointer query matches, so an unknown pointer can never arm a gesture. */
:root { --lvs-p: 0px; --lvs-c: 0px; --lvs-q: 12px; --lvs-r: 0px; --lvs-rn: 0px; --lvs-h: 0px; }
@media (pointer: none) { :root { --lvs-q: 0px; } }
@media (pointer: fine) { :root { --lvs-q: 4px; } }
@media (pointer: coarse) { :root { --lvs-q: 8px; } }
@media (prefers-reduced-motion: reduce) { :root { --lvs-r: 16px; } }
@media (prefers-reduced-motion: no-preference) { :root { --lvs-rn: 64px; } }
#lvs-layout-facts {
  position: absolute; top: 0; left: 0;
  width: calc(1px + var(--lvs-p) + var(--lvs-c) + var(--lvs-q) + var(--lvs-r) + var(--lvs-rn) + var(--lvs-h));
  height: 1px; padding: 0; margin: 0; border: 0; overflow: hidden;
  visibility: hidden; pointer-events: none;
}

/* Honest degraded branch B (SETTLED-MATCHMEDIA-FALLBACK): when neither
   supported MQL nor the one sentinel/observer can establish gesture facts the
   draggable affordance is removed; Close, Reopen, Expand, keyboard, scroll,
   account and zoom stay functional and the local note explains why. */
body.drag-unavailable #sheet-bar { cursor: default; touch-action: pan-y; }
body.drag-unavailable #reopen { cursor: pointer; }
#drag-unavailable-note { margin: 0 0 6px; }

/* Scoped >=44x44 effective touch targets (parent SETTLED-MOBILE-TOUCH-TARGETS
   + SETTLED-HYBRID-TOUCH-DRAG). The union query is CAPABILITY SIZING ONLY:
   the primary-pointer drawer classifier above is unchanged, fine-only
   desktop geometry is untouched, and H is defined in this SAME rule as the
   sizing so one CSS change drives both. Native semantics, IDs/listeners, text
   wrapping, the 16px input rule, keyboard/focus, page zoom, artwork pinch and
   synth media pinch/pan/reset are preserved. No document-wide blanket: the
   scope is #ui and #glfail. The drawer tab already meets the minimum. */
@media (pointer: coarse), (any-pointer: coarse) {
  :root { --lvs-h: 32px; }
  #ui button, #glfail button {
    min-height: 44px; min-width: 44px;
  }
  #ui select, #ui input[type="text"], #ui input[type="number"],
  #ui input[type="file"], #ui textarea {
    min-height: 44px;
  }
  #ui input[type="range"] { height: 44px; }
  #ui label.check { min-height: 44px; }
  #ui label.file-label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
  #ui #presets button, #ui #chips button, #ui .discrete-choices button,
  #ui .shape-chip, #ui .shape-chip-x, #ui #routes li button,
  #ui #section-nav-list button { min-height: 44px; min-width: 44px; }
  #ui #oscillators button, #ui #oscillators select,
  #ui #oscillators input[type="range"], #ui #oscillators label.check {
    min-height: 44px;
  }
}
/* The sheet bar is portrait-sheet-only; drawers never show it. */
#sheet-bar { display: none; }

/* View-gated section links: hidden while their target section is absent. */
body:not(.view-synth) #section-nav-list button[data-shows="view-synth"],
body:not(.view-scope) #section-nav-list button[data-shows="view-scope"] { display: none; }
/* Hide the role=listitem wrapper together with its view-gated button, so the
   accessibility tree never exposes a visible-but-empty listitem and keyboard
   order skips the dead row (display:none removes wrapper and button). The
   wrapper carries the same data-shows attribute as its button (index.html),
   so plain attribute selectors do this with no :has() dependency
   (Chrome 105+/Safari 15.4+/Firefox 121+) — identical behavior on every
   engine the product already supports. */
body:not(.view-synth) #section-nav-list [role="listitem"][data-shows="view-synth"],
body:not(.view-scope) #section-nav-list [role="listitem"][data-shows="view-scope"] { display: none; }

.section-nav {
  border-top: 1px dashed #3d5230;
  padding: 8px 0 2px;
  margin-top: 10px;
}
.section-nav summary {
  cursor: pointer; font-size: 12.5px; font-weight: 700; color: #ffe600;
  display: flex; align-items: center; min-height: 44px;
  padding: 4px 0; user-select: none; -webkit-user-select: none;
}
.section-nav summary:focus-visible { outline: 2px solid #ff5db1; outline-offset: 2px; }
#section-nav-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
/* listitem wrappers keep valid list semantics; flex boxes keep the chip look. */
#section-nav-list [role="listitem"] { display: flex; }
#section-nav-list button {
  background: #23331a; color: #d8ffb0; border: 1px solid #b6ff2e;
  font-weight: 400; padding: 10px 14px; min-height: 44px;
}

/* The full-height drawer applies at every size. The alternate layouts below
   are inactive, matching the drawer-only facts in controls_ui.rs. */
@media not all {
  body { --sheet-current: calc(var(--vvh) * 0.5); }
  body.sheet-expanded { --sheet-current: calc(var(--vvh) * 0.86); }
  #ui {
    top: auto;
    bottom: var(--vv-bottom);
    left: 0; right: 0;
    width: 100vw; max-width: 100vw;
    height: var(--sheet-current);
    max-height: calc(var(--vvh) * 0.86);
    border-left: 0; border-right: 0;
    border-top: 3px solid #b6ff2e;
    border-radius: 14px 14px 0 0;
    padding: 0 14px calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    transition: transform .3s ease, height .3s ease, visibility 0s;
    scroll-padding-top: 120px;
  }
  body.panel-hidden #ui {
    transform: translateY(100%);
    transition: transform .3s ease, height .3s ease, visibility 0s .3s;
  }
  #reopen {
    right: 0; top: auto;
    /* Float 8px ABOVE the sheet top edge: the tab never overlaps the sheet
       bar or the 44px expand button while the panel is open. */
    bottom: calc(var(--vv-bottom) + var(--sheet-current) + 8px);
    writing-mode: horizontal-tb;
    width: auto; min-width: 88px; min-height: 44px; max-height: none;
    padding: 10px 14px; font-size: 12px; letter-spacing: .12em;
    border-radius: 10px 0 0 10px;
    transition: transform .3s ease, bottom .3s ease;
  }
  body.panel-hidden #reopen {
    transform: none;
    bottom: calc(var(--vv-bottom) + max(16px, env(safe-area-inset-bottom, 0px)));
  }
  /* Resolved authored-target metadata on the ONE inert sentinel
     (preview correction; parent SETTLED-MOBILE-PREVIEW-SCALAR-RESTORE +
     Carbon 5c44a49e §2 / ea829273). The same body-scoped target expressions
     the real sheet styles use are resolved by the browser into two non-size
     computed lengths the controller can read without parsing calc()/var()
     tokens, without retargeting the live surfaces to measure an endpoint,
     and without a second node, observer, scheduler or polling loop:
       font-size   -> #ui height target (--sheet-current under the current
                      body classes: half or expanded),
       line-height -> #reopen bottom target, open variant
                      (vv-bottom + sheet-current + 8px), with the
                      body.panel-hidden variant below carrying the distinct
                      hidden-tab target (vv-bottom + max(16px, safe-area)).
     Neutrality is unchanged and provable: the sentinel keeps its explicit
     encoded width (the facts rule above), explicit 1px height, no children,
     overflow hidden, visibility hidden and pointer-events none, so these
     lengths contribute nothing to layout, scrolling, hit testing, page
     geometry or the width encoding. Outside portrait neither rule applies,
     the sheet token is legitimately absent, and the controller never reads
     metadata for drawer gestures. The sentinel is created on the supported
     MQL path too (controls_ui.rs) so the metadata stays available there; it
     carries no observer unless the settled fallback path installs one. */
  #lvs-layout-facts {
    font-size: var(--sheet-current);
    line-height: calc(var(--vv-bottom) + var(--sheet-current) + 8px);
  }
  body.panel-hidden #lvs-layout-facts {
    line-height: calc(var(--vv-bottom) + max(16px, env(safe-area-inset-bottom, 0px)));
  }
  #sheet-bar {
    display: flex; align-items: center; gap: 10px;
    min-height: 44px;
    padding: 4px 2px 6px;
    touch-action: none;
    cursor: grab; user-select: none; -webkit-user-select: none;
  }
  #sheet-handle {
    flex: 1 1 auto; height: 5px; border-radius: 3px;
    background: #b6ff2e; opacity: .85;
  }
  #sheet-resize {
    flex: 0 0 44px; min-height: 44px;
    background: #23331a; color: #d8ffb0; border: 1px solid #b6ff2e;
    font-size: 16px;
  }
  /* Two header buttons + the title must fit 320px sheets without overflow. */
  .controls-title h1 { font-size: 17px; }
}

/* Short coarse-pointer landscape: compact right drawer, EXACTLY the settled
   predicate (parent SETTLED-MOBILE-RESPONSIVE-BOUNDARY) — the identical
   literal also lives in controls_ui.rs. Primary pointer only: no width cap,
   no UA/screen/touch-count/any-pointer classifier. Fine/none/unsupported
   pointers keep the ordinary 360px drawer at any size; visualViewport (not
   classification) handles keyboard geometry. */
@media not all {
  :root { --controls-width: min(300px, calc(100vw - 44px - env(safe-area-inset-left, 0px))); }
  #ui { padding: 0 14px 18px; padding-right: max(14px, env(safe-area-inset-right, 0px)); }
}

/* Reduced motion must also win over the portrait sheet rules above: the base
   reduced-motion reset (transition: none) sits earlier in this file, so the
   later equal-specificity portrait transitions would otherwise re-enable
   animation. Same selectors, appended last. */
@media not all {
  #ui, body.panel-hidden #ui, #reopen, body.panel-hidden #reopen { transition: none; }
}
