/* The instrument casing, its rail and the corner readout. Render coordinates stay intact.
   Art direction v2 "Light, not chrome": the rail is a line of sentence-case words; the chosen
   one lights up behind a glowing point of the scene's colour. */
body.instrument-frame #light-canvas,body.instrument-frame #shared-pool-canvas,body.instrument-frame #paper-canvas,body.instrument-frame #ink-canvas,body.instrument-frame #prism-canvas,body.instrument-frame #sketch-canvas,body.instrument-frame #signal-canvas,body.instrument-frame #passage-canvas,body.instrument-frame #aquarium-canvas,body.instrument-frame #garden-canvas,body.instrument-frame #skate-canvas,body.instrument-frame #constellation-canvas{cursor:crosshair;clip-path:inset(var(--frame-t) var(--frame-r) var(--visual-bottom) var(--frame-l) round var(--note-radius-frame));transition:clip-path var(--note-dur-frame) var(--note-ease)}
#instrument-rim{position:fixed;z-index:8;inset:var(--frame-t) var(--frame-r) var(--visual-bottom) var(--frame-l);border:1px solid var(--note-rule);border-radius:var(--note-radius-frame);box-shadow:0 0 0 1px var(--note-casing);pointer-events:none;transition:bottom var(--note-dur-frame) var(--note-ease)}

/* ---------- Rail: every rail button, including the ones inside the record popover ---------- */
body.instrument-frame #instrument-rail button{border:0;border-radius:0;background:none;box-shadow:none;backdrop-filter:none;font-family:var(--note-font);cursor:pointer}
body.instrument-frame #instrument-rail button:disabled{cursor:default}
body.instrument-frame #instrument-rail :where(#record-menu) button:disabled{opacity:.3}
body.instrument-frame #record-menu{top:auto;bottom:calc(100% + 12px);max-height:60vh;overflow:auto}

/* ---------- Rail: the words (art direction v2, "Light, not chrome") ----------
   Sentence-case words at 14px, normal tracking. The active or open word lights up and a
   glowing point of the scene's light hangs before it. One id outranks the class-only
   .field-action/.session-button word styles in field-ui.css and session-ui.css. */
body.instrument-frame #instrument-rail{position:fixed;z-index:40;left:max(26px,calc(var(--safe-l) + 12px));right:max(26px,calc(var(--safe-r) + 12px));bottom:var(--key-space);height:var(--rail-h);display:flex;flex-wrap:nowrap;align-items:center;align-content:center;justify-content:flex-start;gap:0 22px;padding:0;overflow:visible;color:var(--note-text);font:var(--note-weight-text) var(--note-text-sm)/var(--note-leading) var(--note-font);transition:bottom var(--note-dur-frame) var(--note-ease)}
body.instrument-frame #instrument-rail>#corner-bl,body.instrument-frame #instrument-rail>#corner-br{display:contents}
body.instrument-frame #instrument-rail>#corner-tr{position:relative;inset:auto;z-index:45;display:flex;align-items:center;width:auto;min-width:0;margin:0;gap:0;transition:none}
body.instrument-frame #instrument-rail>button,body.instrument-frame #instrument-rail>#corner-bl>button,body.instrument-frame #instrument-rail>#corner-br>button,body.instrument-frame #instrument-rail>#corner-tr>button{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;box-sizing:border-box;width:auto;min-width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:2px;background:none;box-shadow:none;backdrop-filter:none;transform:none;opacity:1;color:var(--note-text-faint);font:var(--note-weight-text) var(--note-text-sm)/1 var(--note-font);letter-spacing:0;text-transform:none;text-decoration:none;white-space:nowrap;transition:color var(--note-dur) var(--note-ease)}
body.instrument-frame #instrument-rail>button:hover,body.instrument-frame #instrument-rail>#corner-bl>button:hover,body.instrument-frame #instrument-rail>#corner-br>button:hover,body.instrument-frame #instrument-rail>#corner-tr>button:hover{color:var(--note-text);background:none;box-shadow:none;text-decoration:none;padding:0}
body.instrument-frame #instrument-rail>button:is([aria-expanded=true],[aria-pressed=true],.on),body.instrument-frame #instrument-rail>#corner-bl>button[aria-expanded=true],body.instrument-frame #instrument-rail>#corner-tr>button[aria-expanded=true],body.instrument-frame #instrument-rail>#loop-toggle:is([data-state=playing],[data-state=overdubbing],[data-state=recording]){color:var(--note-text);font-weight:var(--note-weight-label);background:none;box-shadow:none;text-decoration:none;padding:0}
body.instrument-frame #instrument-rail>button::before,body.instrument-frame #instrument-rail>#corner-bl>button::before,body.instrument-frame #instrument-rail>#corner-br>button::before,body.instrument-frame #instrument-rail>#corner-tr>button::before,body.instrument-frame #instrument-rail>button::after,body.instrument-frame #instrument-rail>#corner-bl>button::after,body.instrument-frame #instrument-rail>#corner-br>button::after,body.instrument-frame #instrument-rail>#corner-tr>button::after{content:none}
body.instrument-frame #instrument-rail>button[hidden],body.instrument-frame #instrument-rail>#corner-bl>button[hidden],body.instrument-frame #instrument-rail>#corner-br>button[hidden],body.instrument-frame #instrument-rail>#corner-tr>button[hidden],body.instrument-frame #instrument-rail>#corner-br>#kb-restore,body.instrument-frame.kb-min #instrument-rail>#corner-br>#kb-collapse{display:none}
body.instrument-frame.kb-min #instrument-rail>#corner-br>#kb-restore{display:inline-flex}
/* The point of light hangs in the gap before the word, so the word never shifts. */
body.instrument-frame #instrument-rail>button:is([aria-expanded=true],[aria-pressed=true],.on)::before,body.instrument-frame #instrument-rail>#corner-bl>button[aria-expanded=true]::before,body.instrument-frame #instrument-rail>#corner-tr>button[aria-expanded=true]::before,body.instrument-frame #instrument-rail>#loop-toggle:is([data-state=playing],[data-state=overdubbing],[data-state=recording])::before{content:'';position:absolute;left:-11px;top:50%;width:6px;height:6px;margin-top:-3px;border-radius:50%;background:var(--scene-accent);box-shadow:var(--note-glow);pointer-events:none;animation:rail-light-in var(--note-dur-fade) var(--note-ease)}
body.instrument-frame #instrument-rail>#loop-toggle[data-state=recording]::before{background:var(--note-danger);box-shadow:0 0 10px 1px var(--note-danger)}
@keyframes rail-light-in{from{opacity:0}to{opacity:1}}
/* NOTE mark: the only picture in the rail. */
body.instrument-frame #instrument-rail>#about-toggle{gap:8px;color:var(--note-text);font-weight:var(--note-weight-label)}
body.instrument-frame #instrument-rail>#about-toggle img{display:block;width:20px;height:20px}
body.instrument-frame #instrument-rail>#about-toggle span{display:inline}
body.instrument-frame #instrument-rail>#corner-bl>#visual-toggle svg{width:18px;height:18px}
/* Record: word + light. The red point sits quiet at rest and breathes while recording. */
body.instrument-frame #instrument-rail>#corner-tr>#record-toggle{flex-direction:row-reverse;gap:8px}
body.instrument-frame #instrument-rail>#corner-tr>#record-toggle .led{display:block;flex:none;width:6px;height:6px;margin:0;border-radius:50%;background:var(--note-danger);box-shadow:none;opacity:.7;animation:none}
body.instrument-frame #instrument-rail>#corner-tr>#record-toggle.recording{color:var(--note-text);font-weight:var(--note-weight-label);background:none;border:0;padding:0}
body.instrument-frame #instrument-rail>#corner-tr>#record-toggle.recording .led{opacity:1;box-shadow:0 0 10px 1px var(--note-danger);animation:rail-record-breathe 1.8s ease-in-out infinite}
@keyframes rail-record-breathe{0%,100%{opacity:1;box-shadow:0 0 12px 2px var(--note-danger)}50%{opacity:.5;box-shadow:0 0 4px 0 var(--note-danger)}}
body.instrument-frame #instrument-rail>#corner-tr>#record-toggle .deck-label{font:inherit;letter-spacing:inherit;text-transform:none}
body.instrument-frame #instrument-rail>:is(button,#corner-bl>button,#corner-br>button,#corner-tr>button):focus-visible{outline:1px solid var(--note-text);outline-offset:3px;border-radius:2px;box-shadow:none}
/* Instrument words left, transport words right. */
body.instrument-frame #instrument-rail>#rail-metronome{margin-left:auto}

/* ---------- Rail: ≤700px, two lines of words ---------- */
@media(max-width:700px){
  body.instrument-frame #instrument-rail{left:calc(12px + var(--safe-l));right:calc(12px + var(--safe-r));flex-wrap:wrap;row-gap:0;column-gap:8px;justify-content:space-between;align-content:center}
  body.instrument-frame #instrument-rail::after{content:'';order:6;flex:0 0 100%;height:0}
  body.instrument-frame #instrument-rail>#about-toggle{order:1}
  body.instrument-frame #instrument-rail>#about-toggle span{display:none}
  body.instrument-frame #instrument-rail>#corner-bl>button{order:2}
  body.instrument-frame #instrument-rail>#play-toggle{order:3}
  body.instrument-frame #instrument-rail>#library-toggle{order:4}
  body.instrument-frame #instrument-rail>#loop-toggle{order:5}
  body.instrument-frame #instrument-rail>#rail-metronome{order:7;margin-left:0}
  body.instrument-frame #instrument-rail>#corner-tr{order:8}
  body.instrument-frame #instrument-rail>#corner-br>button{order:9}
  body.instrument-frame #record-menu{position:fixed;left:18px;right:18px;bottom:calc(var(--key-space) + var(--rail-h) + 8px);width:auto}
}

/* ---------- Corner readout: sentence-case label over a light numeral, no pill ---------- */
body.instrument-frame #corner-tl{position:fixed;top:calc(var(--frame-t) + 18px);right:calc(var(--frame-r) + 24px);left:auto;display:flex;align-items:flex-start;gap:14px;overflow:visible;border:0;border-radius:0;background:none;backdrop-filter:none;box-shadow:none;z-index:20}
body.instrument-frame #corner-tl .chip{position:relative;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;gap:4px;box-sizing:border-box;min-width:44px;min-height:44px;height:auto;margin:0;padding:0;border:0;border-radius:2px;background:none;box-shadow:none;backdrop-filter:none;color:var(--note-text);font:var(--note-weight-light) var(--note-text-md)/1.1 var(--note-font);font-variant-numeric:var(--note-numeric);letter-spacing:0;text-transform:none;text-shadow:0 0 12px #0008}
body.instrument-frame #corner-tl .readout-label{order:-1;color:var(--note-text-muted);font:var(--note-weight-text) var(--note-text-xs)/1.2 var(--note-font);letter-spacing:0;text-transform:none}
body.instrument-frame #corner-tl #note-box{min-width:0}
body.instrument-frame #corner-tl #hud{cursor:pointer}
body.instrument-frame #corner-tl #hud:hover,body.instrument-frame #corner-tl #hud[aria-expanded=true]{background:none}
body.instrument-frame #corner-tl #hud:is(:hover,[aria-expanded=true]) .readout-label{color:var(--note-text)}
body.instrument-frame #corner-tl #hud[aria-expanded=true]::before{content:'';position:absolute;left:-11px;top:4px;width:6px;height:6px;border-radius:50%;background:var(--scene-accent);box-shadow:var(--note-glow)}
body.instrument-frame #corner-tl #hud:focus-visible{outline:1px solid var(--note-text);outline-offset:3px;border-radius:2px}
/* Over the pale scenes (Pool, Ink, Aquarium Day) the light type needs a firmer halo; still no box. */
body.instrument-frame.pale-scene #corner-tl .chip{text-shadow:0 0 12px #000a,0 0 2px #0008}
@media(max-width:700px){
  body.instrument-frame #corner-tl{top:calc(var(--frame-t) + 12px);right:calc(var(--frame-r) + 16px);gap:14px}
  body.instrument-frame #corner-tl #note-box{min-width:0}
}
/* Narrow phones: the pair stacks into one right-aligned column so the scene name keeps the top line. */
@media(max-width:420px){
  body.instrument-frame #corner-tl{flex-direction:column;align-items:flex-end;gap:8px}
  body.instrument-frame #corner-tl .chip{align-items:flex-end;min-height:0;text-align:right}
  body.instrument-frame #corner-tl .chip>*{text-align:right}
  body.instrument-frame #corner-tl #hud{min-height:44px}
}

/* ---------- Keyboard console and panels sit in the same casing ---------- */
body.instrument-frame #console{background:var(--note-casing);opacity:1;pointer-events:auto;transition:transform var(--note-dur-frame) var(--note-ease),opacity 300ms;z-index:30}
body.instrument-frame.kb-min #console{opacity:0;pointer-events:none;transform:translateY(110%)}
body.instrument-frame #panel-audio.spatial-ui,body.instrument-frame #panel-visual.spatial-ui{inset:var(--frame-t) var(--frame-r) var(--visual-bottom) var(--frame-l);width:auto;height:auto;overflow:hidden;border-radius:var(--note-radius-frame);transition:bottom var(--note-dur-frame) var(--note-ease),visibility 440ms}
body.instrument-frame .space-stage,body.instrument-frame #panel-visual .space-stage{inset:72px 20px 64px;max-width:none;align-content:safe center;margin:0;overflow-y:auto}
body.instrument-frame #panel-audio #sound-close.space-close,body.instrument-frame #panel-visual #scene-close.space-close{bottom:14px;background:none;box-shadow:none;border:0;color:var(--note-text);font-size:var(--note-text-xs);height:44px;padding:0 10px}
body.instrument-frame #panel-overlay{inset:var(--frame-t) var(--frame-r) var(--visual-bottom) var(--frame-l);border-radius:var(--note-radius-frame)}
body.instrument-frame #audio-status{bottom:calc(var(--visual-bottom) + 12px);left:32px}
body.instrument-frame #sample-strip{bottom:calc(var(--visual-bottom) + 12px)}
@media(max-width:700px){body.instrument-frame .space-stage,body.instrument-frame #panel-visual .space-stage{inset:48px 8px 54px;align-content:start}}
@media(prefers-reduced-motion:reduce){
  body.instrument-frame #instrument-rail,body.instrument-frame #instrument-rim,body.instrument-frame #corner-tr,body.instrument-frame canvas,body.instrument-frame #console,body.instrument-frame .spatial-ui{transition:none!important}
  body.instrument-frame #instrument-rail button{transition:none}
  body.instrument-frame #instrument-rail button::before{animation:none}
  body.instrument-frame #instrument-rail>#corner-tr>#record-toggle.recording .led{animation:none}
}

/* Walk renders into the actual scene opening instead of cropping a window-sized camera. */
body.instrument-frame #signal-canvas,body.instrument-frame #passage-canvas,body.instrument-frame #aquarium-canvas,body.instrument-frame #garden-canvas,body.instrument-frame #skate-canvas,body.instrument-frame #constellation-canvas{inset:var(--frame-t) var(--frame-r) var(--visual-bottom) var(--frame-l)!important;width:calc(100% - var(--frame-l) - var(--frame-r))!important;height:calc(100% - var(--visual-bottom) - var(--frame-t))!important;clip-path:inset(0 round var(--note-radius-frame))}

/* Film transport belongs to the Shorts playlist only. */
body.instrument-frame #panel-visual #preview-signal-playlist-controls[hidden],#signal-playlist-controls[hidden]{display:none!important;}
