* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); }
button, input { font: inherit; }
button { min-height: 44px; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
main { max-width: calc(var(--instrument-max-size) + 40px); margin: auto; padding: 22px 20px; }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
h1 { margin: 0; line-height: 1; }
.name { font-weight: 750; font-size: 25px; letter-spacing: -1px; color: var(--ink); text-decoration: none; }
.name-dot { color: var(--accent); }
.tagline { font-size: 11px; color: var(--muted); margin: 0; }
.instrument { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 10px; background: var(--panel); }
.stage { position: relative; width: 100%; aspect-ratio: 1; max-width: var(--wheel-max-size); margin: 8px auto; }
.ring, .inner-ring { position: absolute; border: var(--ring-width) solid var(--line); border-radius: 50%; inset: calc(50% - var(--wheel-radius)); }
.inner-ring { inset: 22%; border-style: dashed; opacity: .45; }
.hand { position: absolute; left: calc(50% - var(--hand-width) / 2); bottom: 50%; width: var(--hand-width); height: var(--wheel-radius); background: var(--accent); transform-origin: bottom; opacity: .65; }
.hub { position: absolute; inset: 35%; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 0; color: var(--ink); cursor: pointer; }
.hub span { color: var(--muted); font-size: 8px; }
.hub strong { font-size: clamp(22px, 4vw, 40px); font-weight: 400; letter-spacing: -2px; }
.node { position: absolute; transform: translate(-50%, -50%); width: var(--node-size); height: var(--node-size); padding: 0; border-radius: 50%; border: 1px solid var(--sound-color); background: var(--node-idle); color: var(--sound-color); font-size: 10px; font-weight: 650; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.node[aria-pressed="true"] { background: var(--sound-color); color: var(--accent-ink); border-color: var(--sound-color); box-shadow: none; border-color: var(--ink); }
.node.playing { box-shadow: none; border-color: var(--ink); outline: 3px solid var(--accent); outline-offset: 2px; }
.node:focus-visible { outline: 3px solid var(--ink); outline-offset: 5px; }
/* ADR-0005: persistent sound tool, shared instrument tokens, native radio behavior. */
.sound-tool { border: 0; padding: 0; margin: 24px 0 8px; min-width: 0; }
.sound-tool legend { color: var(--muted); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; padding: 0; margin-bottom: 10px; }
.sound-options { display: flex; flex-wrap: wrap; gap: 8px; }
.sound-option { position: relative; display: flex; flex: 1 1 auto; align-items: center; justify-content: center; min-height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 12px; }
.sound-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.sound-option:has(input:checked) { border-color: var(--accent); color: var(--ink); background: var(--node-idle); }
.sound-option:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.sound-option-name { display: inline-flex; align-items: center; gap: 7px; }
.sound-option-name::before { content: ''; width: 8px; height: 8px; border: 1px solid var(--ink); border-radius: 50%; background: var(--sound-color); }

.sound-tool { margin: 0; }
.sound-options { gap: 6px; }
.sound-option { padding: 9px; font-size: 11px; }
.controls { max-width: var(--wheel-max-size); margin: 0 auto; border-top: 1px solid var(--line); padding-top: 10px; }
.control-group { padding: 5px 0; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 20px; font-size: 12px; }
output { color: var(--ink); font-size: 12px; }
input[type="range"] { width: 100%; min-height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.node { min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.node-position { font-size: 8px; font-weight: 450; }
.node-sound { font-size: 10px; letter-spacing: .4px; }
.compact-nodes .node-position { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.status.visible { position: static; width: auto; height: auto; padding: 10px 0; margin: 0; overflow: visible; clip-path: none; white-space: normal; font-size: 12px; color: var(--ink); line-height: 1.5; }
footer { display: grid; grid-template-columns: 1fr; align-items: start; gap: 16px; margin-top: 10px; font-size: 10px; color: var(--muted); }
details { text-align: right; }
details[open] { grid-column: 1 / -1; }
summary { min-height: 44px; padding: 14px 0; cursor: pointer; }
.help-content { text-align: left; font-size: 12px; line-height: 1.6; }
.help-content p { margin: 0 0 12px; }
@media (max-width: 400px) { :root { --wheel-radius: 42%; } main { padding: 16px 12px; } .instrument { padding-inline: 10px; } .stage.is-dense { --wheel-radius: 46%; } .hub span { font-size: 7px; letter-spacing: 1px; } .hub strong { font-size: 26px; } .tagline { font-size: 10px; } }
@media (prefers-reduced-motion: reduce) { .stage.is-playing .hand { visibility: hidden; } }
/* SPEC-007: inactive nodes expose state through a plain neutral-grey circle. */
.node[aria-pressed="false"] { background: var(--node-inactive-fill); border-color: var(--node-inactive-border); box-shadow: none; }
.node[aria-pressed="false"] > span { display: none; }

/* SPEC-003: the existing RPM hub is the single transport control. */
.hub .hub-action { color: var(--ink); font-weight: 700; }
.hub:hover { border-color: var(--accent); }
.hub[aria-pressed="true"] { border-color: var(--accent); }
.hub:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
.hub:disabled { cursor: wait; opacity: .7; }
@media (max-width: 400px) { .sound-option { flex-basis: 28%; } }

/* SPEC-009: compact native preset control; existing palette and focus treatment. */
.preset-control { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.help-content a { color: var(--ink); }

.hub strong, output { font-variant-numeric: tabular-nums; }

/* SPEC-008: short-laptop fit without scaling text or clipping controls. */
main { padding-block: 12px; }
header { margin-bottom: 10px; }
.instrument { padding: 12px 16px 8px; }
.preset-control { margin-bottom: 8px; }
.stage { margin-block: 4px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding-top: 6px; }
.control-group { padding: 0; min-width: 0; }
footer { margin-top: 4px; gap: 0; }
@media (min-width: 600px) { :root { --wheel-max-size: clamp(180px, calc(100svh - 340px), 300px); } }
@media (max-width: 599px) { :root { --wheel-max-size: 300px; } }
@media (max-width: 400px) { .instrument { padding-inline: 10px; } .controls { gap: 14px; } }

.hub { gap: 3px; }
.hub strong { font-size: clamp(22px, calc(var(--wheel-max-size) * .1), 32px); line-height: 1.05; letter-spacing: -1px; }
/* Embedded frames resize to content: keep their wheel independent of frame height. */
@media (min-width: 600px) { :root.embedded { --wheel-max-size: 280px; } }

/* SPEC-009: loading is an action, not a persistent pattern identity. */
#load-beat { flex: 1 1 auto; width: auto; padding: 9px; font-size: 11px; white-space: nowrap; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-weight: 700; }
#beat-dialog { width: min(420px, calc(100vw - 32px)); max-height: calc(100svh - 32px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 16px; }
#beat-dialog::backdrop { background: color-mix(in srgb, var(--ink) 30%, transparent); }
.beat-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.beat-dialog-heading h2 { margin: 0; font-size: 20px; }
#close-beats { border: 1px solid var(--line); border-radius: 8px; background: var(--page); color: var(--ink); padding: 8px 14px; }
#beat-list { list-style: none; padding: 4px; margin: 0; max-height: min(55svh, 320px); overflow-y: auto; overscroll-behavior: contain; }
#beat-list li + li { margin-top: 6px; }
#beat-list button { width: 100%; min-height: 54px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); text-align: left; }
#beat-list button:hover { background: var(--page); border-color: var(--accent); }
#beat-list strong, #beat-list span { display: block; }
#beat-list strong { font-size: 13px; font-weight: 700; }
#beat-list span { font-size: 11px; margin-top: 2px; }

@media (max-width: 400px) { #load-beat { flex-basis: 28%; } }

#load-beat:hover { border-color: var(--accent); }
#load-beat:active { background: var(--page); }

/* SPEC-014: existing tokens, unavailable tools, and read-only preview state. */
.sound-option[data-locked="true"] { color: var(--muted); background: var(--page); cursor: help; }
.sound-option[data-locked="true"] .sound-option-name::before { background: var(--node-idle); border-color: var(--line); }
.sound-option:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.sound-tooltip { display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 5; width: 190px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-size: 12px; box-shadow: 0 4px 12px color-mix(in srgb, var(--ink) 12%, transparent); }
.sound-option:hover .sound-tooltip, .sound-option:focus-visible .sound-tooltip { display: block; }
.node:disabled { opacity: 1; cursor: default; }
input[type="range"]:disabled { opacity: .45; cursor: default; }
.preview-note { margin: 6px 0; text-align: center; color: var(--muted); font-size: 11px; }
