/* Code Radio. Built from the Studio's design system (public/styles.css): the
 * same surfaces, text tiers and stem colours, and the one accent, kept for
 * play and for what is live. */

:root {
  color-scheme: dark;
  --bg: #070708;
  --surface-0: #0d0d0f;
  --surface-1: #131315;
  --surface-2: #1c1c1f;
  --surface-3: #26262a;
  --surface-4: #333338;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #f4f4f6;
  --text-2: rgba(235, 235, 245, 0.64);
  --text-3: rgba(235, 235, 245, 0.4);
  --accent: #b8ff2e;
  --accent-rgb: 184, 255, 46;
  --accent-ink: #0d1300;
  --accent-hover: color-mix(in srgb, var(--accent) 86%, #fff);
  --accent-soft: rgba(var(--accent-rgb), 0.12);
  --accent-line: rgba(var(--accent-rgb), 0.4);
  --danger: #ff5a4f;
  --stem-kick: #ff5a4f;
  --stem-clap: #ff9f0a;
  --stem-hats: #ffd60a;
  --stem-perc: #c9a26b;
  --stem-bass: #409cff;
  --stem-chords: #bf5af2;
  --stem-lead: #ff5fa2;
  --stem-arp: #64d2ff;
  --stem-pad: #7d7aff;
  --stem-texture: #66d4cf;
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.3, 1.35, 0.5, 1);
  --dur-1: 0.12s;
  --dur-2: 0.2s;
  --dur-3: 0.34s;
  --shadow-pop: 0 0 0 1px var(--line-strong), 0 12px 40px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --top-h: 56px;
  --dock-h: 84px;
  --dial-w: 292px;
  --side-w: 392px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  grid-template-columns: var(--dial-w) minmax(0, 1fr) 0;
  grid-template-rows: var(--top-h) minmax(0, 1fr) var(--dock-h);
  grid-template-areas: 'top top top' 'dial stage side' 'dial dock side';
  transition: grid-template-columns var(--dur-3) var(--ease);
}
body[data-side='rd-evolving'], body[data-side='rd-custom'], body[data-side='rd-save'] { grid-template-columns: var(--dial-w) minmax(0, 1fr) var(--side-w); }
body[data-side='rd-codepanel'] { grid-template-columns: var(--dial-w) minmax(0, 1fr) min(46vw, 620px); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
::selection { background: rgba(var(--accent-rgb), 0.28); }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }
* { scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
svg { display: block; }

/* ————————————————— top bar ————————————————— */

.rd-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  z-index: 3;
}
.rd-brand { display: flex; align-items: center; gap: 10px; }
.rd-mark { width: 26px; height: 26px; }
.rd-word { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.rd-top-end { display: flex; align-items: center; gap: 14px; }
.rd-link { color: var(--text-2); font-size: 13px; transition: color var(--dur-1); }
.rd-link:hover { color: var(--text); }
.rd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 550;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background var(--dur-1), transform var(--dur-1);
}
.rd-btn:hover { background: var(--surface-3); }
.rd-btn:active { transform: scale(0.98); }
.rd-btn-quiet { background: transparent; }
.rd-btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.rd-btn-primary:hover { background: var(--accent-hover); }
.rd-btn-primary:disabled { opacity: 0.5; cursor: default; }
.rd-btn-wide { width: 100%; height: 44px; font-size: 15px; }

/* ————————————————— the dial ————————————————— */

.rd-dial {
  grid-area: dial;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.rd-dial-head { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 18px 10px; }
.rd-dial-head h2 { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: none; letter-spacing: 0.02em; }
.rd-dial-note { font-size: 12px; color: var(--text-3); }
.rd-stations { list-style: none; margin: 0; padding: 0 8px 16px; overflow-y: auto; flex: 1; }
.rd-station {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--dur-1);
}
.rd-station:hover { background: var(--surface-1); }
.rd-station[aria-current='true'] { background: var(--surface-2); }
.rd-art { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.rd-art canvas { width: 100%; height: 100%; display: block; }
.rd-st-text { min-width: 0; }
.rd-st-name { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; }
.rd-st-freq { font: 500 11px/1 var(--font-mono); color: var(--text-3); font-variant-numeric: tabular-nums; }
.rd-st-line { display: block; margin-top: 3px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-st-end { display: flex; align-items: center; gap: 6px; }
.rd-lock { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 550; }
.rd-lock svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.rd-eq { display: none; gap: 2px; align-items: flex-end; height: 14px; }
.rd-eq i { width: 3px; border-radius: 2px; background: var(--accent); height: 4px; animation: rd-eq 0.9s var(--ease) infinite; }
.rd-eq i:nth-child(2) { animation-delay: -0.3s; }
.rd-eq i:nth-child(3) { animation-delay: -0.6s; }
body[data-state='playing'] .rd-station[aria-current='true'] .rd-eq { display: flex; }
@keyframes rd-eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.rd-dial-sep { margin: 14px 10px 6px; font-size: 12px; font-weight: 600; color: var(--text-3); list-style: none; }

/* ————————————————— the stage ————————————————— */

.rd-stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--surface-0); }
.rd-aura { position: absolute; inset: 0; pointer-events: none; }
.rd-aura canvas { width: 100%; height: 100%; display: block; opacity: 0.9; }
.rd-scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none; }
.rd-scroll::-webkit-scrollbar { display: none; }
.rd-tall { width: 1px; }
.rd-code { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 64px, #000 calc(100% - 56px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 64px, #000 calc(100% - 56px), transparent 100%); }
.rd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: pre; }

.rd-hud { position: absolute; top: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; pointer-events: none; }
.rd-onair, .rd-where {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 10px; border-radius: 999px;
  background: rgba(13, 13, 15, 0.72); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; color: var(--text-2);
}
.rd-live { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
body[data-state='playing'] .rd-live { background: var(--accent); box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5); animation: rd-pulse 2s infinite; }
@keyframes rd-pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); } 70% { box-shadow: 0 0 0 7px rgba(var(--accent-rgb), 0); } 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); } }
.rd-scene { color: var(--text); font-weight: 600; }
.rd-nextscene { color: var(--text-3); }
.rd-nextscene:not(:empty)::before { content: '→ '; }
.rd-where { padding: 0 12px 0 8px; font-variant-numeric: tabular-nums; }
.rd-ring { width: 18px; height: 18px; transform: rotate(-90deg); }
.rd-ring circle { fill: none; stroke-width: 3.5; }
.rd-ring-bg { stroke: var(--surface-4); }
.rd-ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 97.4; stroke-dashoffset: 97.4; }

.rd-tune {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 16px; padding: 14px 26px 14px 14px; border-radius: 999px;
  background: rgba(19, 19, 21, 0.8); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: var(--shadow-pop); text-align: left; transition: transform var(--dur-2) var(--ease), opacity var(--dur-3);
}
.rd-tune:hover { transform: translate(-50%, -50%) scale(1.02); }
.rd-tune-disc { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; }
.rd-tune-disc svg { width: 20px; height: 20px; fill: var(--accent-ink); margin-left: 3px; }
.rd-tune-text { display: flex; flex-direction: column; gap: 2px; }
.rd-tune-text strong { font-size: 17px; font-weight: 650; }
.rd-tune-text span { font-size: 13px; color: var(--text-2); }
body:not([data-state='idle']) .rd-tune { opacity: 0; pointer-events: none; transform: translate(-50%, -46%) scale(0.98); }

/* ————————————————— the dock ————————————————— */

.rd-dock {
  grid-area: dock;
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) minmax(64px, 180px) auto;
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 18px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  z-index: 2;
}
.rd-play {
  position: relative; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); display: grid; place-items: center;
  transition: transform var(--dur-1) var(--ease), background var(--dur-1);
}
.rd-play:hover { background: var(--accent-hover); }
.rd-play:active { transform: scale(0.95); }
.rd-play svg { width: 18px; height: 18px; fill: var(--accent-ink); }
.rd-play .i-play { margin-left: 2px; }
.rd-play .i-stop, .rd-play .i-load { display: none; }
body[data-state='playing'] .rd-play .i-play { display: none; }
body[data-state='playing'] .rd-play .i-stop { display: block; }
body[data-state='loading'] .rd-play .i-play { display: none; }
body[data-state='loading'] .rd-play .i-load { display: block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(13, 19, 0, 0.25); border-top-color: var(--accent-ink); animation: rd-spin 0.8s linear infinite; }
@keyframes rd-spin { to { transform: rotate(360deg); } }
.rd-now { min-width: 0; }
.rd-now-station { display: flex; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; }
.rd-now-station span:last-child { overflow: hidden; text-overflow: ellipsis; }
.rd-now-station span:first-child { font: 500 12px/1 var(--font-mono); color: var(--accent); }
.rd-now-song { margin-top: 3px; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-meter { width: 100%; height: 32px; }
.rd-actions { display: flex; gap: 6px; }
.rd-act {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px;
  color: var(--text-2); font-size: 13px; font-weight: 550; box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background var(--dur-1), color var(--dur-1);
}
.rd-act:hover { background: var(--surface-2); color: var(--text); }
.rd-act[aria-expanded='true'] { background: var(--surface-3); color: var(--text); }
.rd-act svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* the two modes: Evolving (on or off, its controls beside it) and Custom */
.rd-evolve-pair { display: inline-flex; gap: 4px; }
.rd-act-more { width: 40px; padding: 0; justify-content: center; }
body[data-evolving='false'] .rd-act-more { display: none; }
.rd-pip { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-4); transition: background var(--dur-2), box-shadow var(--dur-2); }
.rd-mode[aria-pressed='true'] { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.rd-mode[aria-pressed='true'] .rd-pip { background: var(--accent); box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.8); }
.rd-mode.is-on { color: var(--text); box-shadow: inset 0 0 0 1px var(--text-3); }
.rd-lock-mini { display: inline-flex; color: var(--text-3); }
.rd-lock-mini svg { width: 12px; height: 12px; stroke-width: 1.4; }
.rd-lock-mini[hidden] { display: none; }

/* ————————————————— side panels ————————————————— */

.rd-side { grid-area: side; grid-row: 2 / 4; min-width: 0; min-height: 0; border-left: 1px solid var(--line); background: var(--surface-1); overflow: hidden; z-index: 4; }
.rd-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.rd-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 12px 20px; }
.rd-panel-head h2 { font-size: 16px; font-weight: 650; }
.rd-x { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); }
.rd-x:hover { background: var(--surface-3); color: var(--text); }
.rd-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.rd-panel-body { flex: 1; overflow-y: auto; padding: 4px 20px 28px; overscroll-behavior: contain; }
.rd-panel-note { padding: 0 20px 12px; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.rd-panel-body .rd-panel-note { padding: 0 0 14px; }
.rd-group { padding: 14px 0 18px; border-bottom: 1px solid var(--line); }
.rd-group:last-of-type { border-bottom: 0; }
.rd-group h3 { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 12px; }
.rd-row-head { display: flex; align-items: baseline; justify-content: space-between; }
.rd-row-head output { font: 500 13px/1 var(--font-mono); color: var(--text); font-variant-numeric: tabular-nums; }
.rd-keys { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rd-key { height: 34px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; font-weight: 550; color: var(--text-2); transition: background var(--dur-1), color var(--dur-1); }
.rd-key:hover { background: var(--surface-3); color: var(--text); }
.rd-key[aria-checked='true'] { background: var(--text); color: var(--bg); }
.rd-key small { font-size: 10px; opacity: 0.6; margin-left: 1px; }

.rd-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 2px 0 0; touch-action: pan-y; }
.rd-slider::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--text) var(--fill, 50%), var(--surface-4) var(--fill, 50%)); }
.rd-slider::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-4); }
.rd-slider::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--text); }
.rd-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.rd-slider::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.rd-slider:focus-visible { box-shadow: none; }
.rd-slider:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }
.rd-knob { margin-bottom: 10px; }
.rd-knob-ends { display: grid; grid-template-columns: 1fr auto 1fr; font-size: 12px; color: var(--text-3); }
.rd-knob-ends label { color: var(--text); font-weight: 550; font-size: 13px; }
.rd-knob-ends span:last-child { text-align: right; }
.rd-moves { display: flex; flex-wrap: wrap; gap: 8px; }
.rd-chip { height: 34px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 550; transition: background var(--dur-1), transform var(--dur-1); }
.rd-chip:hover { background: var(--surface-3); }
.rd-chip:active { transform: scale(0.97); }
.rd-chip[aria-pressed='true'], .rd-chip.is-armed { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line); }
.rd-hint { margin-top: 10px; font-size: 12px; color: var(--text-3); line-height: 1.45; }
.rd-hint a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }

.rd-layers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rd-layer { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 0; }
.rd-layer-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--text-3)); opacity: 0.35; transition: opacity var(--dur-2); }
.rd-layer[data-on='true'] .rd-layer-dot { opacity: 1; box-shadow: 0 0 10px var(--c); }
.rd-layer-name { font: 500 13px/1.2 var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-layer-name small { font-family: var(--font-sans); color: var(--text-3); margin-left: 6px; }
.rd-seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-2); }
.rd-seg button { height: 26px; padding: 0 10px; border-radius: 6px; font-size: 12px; color: var(--text-3); }
.rd-seg button[aria-pressed='true'] { background: var(--surface-4); color: var(--text); }
.rd-reset { display: block; margin: 18px auto 0; }

.rd-panel-code .rd-editor { flex: 1; min-height: 0; background: var(--surface-0); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rd-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px calc(12px + var(--safe-b)); }
.rd-status { font-size: 12px; color: var(--text-3); min-height: 1.2em; }
.rd-status[data-level='error'] { color: var(--danger); }
.rd-status[data-level='ok'] { color: var(--text-2); }

.rd-field { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 18px; }
.rd-field span { font-size: 12px; font-weight: 600; color: var(--text-3); }
.rd-field input, .rd-copy input {
  height: 44px; padding: 0 14px; border-radius: var(--r-md); border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 16px; color: var(--text);
}
.rd-field input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.rd-toggle { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 10px 0; cursor: pointer; }
.rd-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.rd-switch { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--surface-4); transition: background var(--dur-2); grid-row: 1 / 3; }
.rd-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform var(--dur-2) var(--ease-spring); }
.rd-toggle input:checked + .rd-switch { background: var(--accent); }
.rd-toggle input:checked + .rd-switch::after { transform: translateX(16px); }
.rd-toggle input:focus-visible + .rd-switch { box-shadow: var(--focus); }
.rd-toggle input:disabled ~ * { opacity: 0.45; }
.rd-toggle strong { display: block; font-size: 14px; font-weight: 600; }
.rd-toggle-big { padding: 4px 0 18px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.rd-toggle-big strong { font-size: 15px; }
body[data-evolving='false'] .rd-evolve-only { opacity: 0.38; pointer-events: none; }
.rd-evolve-only { transition: opacity var(--dur-2); }
body[data-evolving='false'] .rd-seg [data-pin=''] { display: none; }
.rd-custom-go { display: grid; gap: 8px; }
.rd-custom-go .rd-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rd-panel-head h2 { display: flex; align-items: center; gap: 4px; }
.rd-back { display: none; width: 30px; height: 30px; margin-left: -8px; border-radius: 50%; place-items: center; color: var(--text-2); }
.rd-back:hover { background: var(--surface-3); color: var(--text); }
.rd-back svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body[data-signed-in='true'] .rd-back { display: grid; }
.rd-toggle small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
#rd-save-go { margin-top: 18px; }
#rd-save-status { margin-top: 10px; text-align: center; }
.rd-saved-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 650; margin: 8px 0 8px; }
.rd-saved-title svg { width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: var(--accent); fill: none; stroke: var(--accent-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rd-copy { display: flex; gap: 8px; margin: 4px 0 18px; }
.rd-copy input { flex: 1; min-width: 0; font: 13px var(--font-mono); height: 38px; }
.rd-copy .rd-btn { height: 38px; flex: none; }

.rd-toast {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + 16px + var(--safe-b)); transform: translateX(-50%);
  max-width: min(92vw, 440px); padding: 11px 16px; border-radius: var(--r-lg); background: var(--surface-3); box-shadow: var(--shadow-pop);
  font-size: 13px; color: var(--text); z-index: 20; animation: rd-toast var(--dur-3) var(--ease);
}
@keyframes rd-toast { from { opacity: 0; transform: translate(-50%, 6px); } }
.rd-backdrop { display: none; }

/* ————————————————— small screens ————————————————— */

@media (max-width: 1100px) {
  :root { --dial-w: 248px; }
  .rd-meter { visibility: hidden; min-width: 0; }
  .rd-dock { grid-template-columns: auto minmax(120px, 1fr) 0 auto; }
}
/* a panel open beside the stage: the dock keeps to icons */
@media (min-width: 761px) {
  body[data-side] .rd-meter { visibility: hidden; min-width: 0; }
  body[data-side] .rd-dock { grid-template-columns: auto minmax(100px, 1fr) 0 auto; gap: 12px; }
  body[data-side] .rd-mode { padding: 0 12px; }
}

@media (max-width: 760px) {
  :root { --top-h: 52px; --dock-h: calc(124px + var(--safe-b)); }
  body, body[data-side] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top-h) 64px minmax(0, 1fr) var(--dock-h);
    grid-template-areas: 'top' 'dial' 'stage' 'dock';
  }
  .rd-top { padding: 0 12px 0 14px; }
  #rd-studio { display: none; }
  .rd-dial { border-right: 0; border-bottom: 1px solid var(--line); }
  .rd-dial-head { display: none; }
  .rd-stations { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 10px 12px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .rd-stations::-webkit-scrollbar { display: none; }
  .rd-stations > li { flex: none; scroll-snap-align: start; }
  .rd-station { grid-template-columns: 28px auto auto; gap: 8px; height: 44px; padding: 0 12px 0 8px; border-radius: 999px; background: var(--surface-1); }
  .rd-station[aria-current='true'] { background: var(--surface-3); }
  .rd-art { width: 28px; height: 28px; border-radius: 50%; }
  .rd-st-line { display: none; }
  .rd-st-name { font-size: 13px; }
  .rd-lock { padding: 0 5px; }
  .rd-lock span { display: none; }
  .rd-dial-sep { display: none; }
  .rd-hud { top: 10px; left: 10px; right: 10px; }
  .rd-onair, .rd-where { height: 28px; }
  .rd-nextscene { display: none; }
  .rd-dock {
    grid-template-columns: auto minmax(0, 1fr) 64px;
    grid-template-rows: 64px 44px;
    gap: 6px 12px;
    padding: 6px 12px calc(8px + var(--safe-b));
  }
  .rd-meter { height: 28px; visibility: visible; }
  .rd-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .rd-evolve-pair { display: flex; }
  .rd-evolve-pair .rd-mode { flex: 1; }
  .rd-act { width: auto; height: 40px; justify-content: center; padding: 0 6px; font-size: 13px; white-space: nowrap; }
  .rd-act-more { width: 44px; flex: none; }
  .rd-act svg { width: 16px; height: 16px; }
  .rd-tune { padding: 12px 22px 12px 12px; gap: 12px; }
  .rd-tune-disc { width: 46px; height: 46px; }

  .rd-side {
    position: fixed; left: 0; right: 0; bottom: 0; max-height: 86dvh; height: auto; border-left: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 var(--line-strong);
    animation: rd-sheet var(--dur-3) var(--ease); z-index: 30;
  }
  body[data-side='rd-codepanel'] .rd-side { height: 86dvh; }
  .rd-side .rd-panel { max-height: 86dvh; }
  .rd-panel-head { padding-top: 18px; position: relative; }
  .rd-panel-head::before { content: ''; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--surface-4); }
  .rd-panel-body { padding-bottom: calc(28px + var(--safe-b)); }
  .rd-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 29; animation: rd-fade var(--dur-3); }
  .rd-toast { bottom: calc(var(--dock-h) + 12px); }
}

@keyframes rd-sheet { from { transform: translateY(100%); } }
@keyframes rd-fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
