html, body { height: 100%; margin: 0; background: #000; overflow: hidden; }
#create-view { position: fixed; inset: 0; }
#create-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#create-hud { position: absolute; top: 8px; left: 8px; display: flex; gap: 12px; padding: 3px 8px;
  background: rgba(0,0,0,0.55); border: 1px solid var(--border); border-radius: 4px;
  font: 12px var(--mono); color: var(--ok); pointer-events: none; }
#create-bar { position: absolute; top: 8px; right: 8px; bottom: 60px; width: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  padding: 4px; background: rgba(0,0,0,0.55); border: 1px solid var(--border); border-radius: 4px; font: 12px var(--mono); color: #ddd; }
#create-bar button { font: inherit; color: inherit; background: #111; border: 1px solid var(--border); border-radius: 3px; padding: 2px 8px; cursor: pointer; }
#create-bar button[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); }
#create-bar button:disabled { opacity: 0.4; cursor: default; }
#create-bar .panel > summary { cursor: pointer; color: var(--ok); padding: 2px 0; }
#create-bar .panel-body { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0 6px; }
#create-bar .row { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
#create-bar label { display: flex; gap: 6px; align-items: center; width: 100%; }
#create-bar input[type="range"] { flex: 1; min-width: 0; }
#shape-tiles, #material-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 100%; }
#shape-tiles button, #material-tiles button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 2px !important; font-size: 10px; }
#shape-tiles svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 1.5; }
#material-tiles .swatch { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #666; }
#shape-params, #material-sliders { width: 100%; }
#mode-toggle { border-color: var(--ok) !important; color: var(--ok) !important; }
#create-help { position: absolute; bottom: 8px; left: 300px; right: 140px; font: 12px var(--mono); color: #aaa; pointer-events: none; } /* P6 fix: right of the budget bar (left 8, at least 260 + 18 wide), clear of the fps badge */
#create-note { position: absolute; bottom: 8px; left: 8px; right: 8px; padding: 6px 10px; display: none;
  background: rgba(120,50,50,0.85); border: 1px solid var(--bad); border-radius: 4px; font: 12px var(--mono); }
#move-gizmo { position: absolute; display: none; width: 28px; height: 28px; margin: -15px 0 0 -15px; pointer-events: none;
  border: 2px solid var(--ok); border-radius: 50%; opacity: 0.6; }
#move-gizmo::before, #move-gizmo::after { content: ''; position: absolute; background: var(--ok); }
#move-gizmo::before { left: -10px; right: -10px; top: 13px; height: 2px; }
#move-gizmo::after { top: -10px; bottom: -10px; left: 13px; width: 2px; }
#move-gizmo.active { opacity: 1; }
#create-hint { position: absolute; top: 158px; left: 50%; transform: translateX(-50%); padding: 4px 6px 4px 12px; pointer-events: none;
  background: rgba(30,40,60,0.9); border: 1px solid #567; border-radius: 4px; font: 13px var(--mono); color: #eee; white-space: nowrap; }
#create-tour { position: absolute; top: 192px; left: 50%; transform: translateX(-50%); padding: 4px 6px 4px 12px; pointer-events: none;
  background: rgba(30,50,40,0.9); border: 1px solid #586; border-radius: 4px; font: 13px var(--mono); color: #eee; white-space: nowrap; }
#create-tour button { pointer-events: auto; background: none; border: 1px solid #586; border-radius: 3px; color: #cdc; font: 12px var(--mono); cursor: pointer; }
#create-hint button { pointer-events: auto; background: none; border: 0; color: #aaa; font: 14px var(--mono); cursor: pointer; }

#object-shelf { display: flex; width: 100%; flex-direction: column; gap: 4px; }
#object-shelf button { font: inherit; color: inherit; background: #111; border: 1px solid var(--border); border-radius: 3px; padding: 2px 8px; cursor: pointer; text-align: left; }
#object-shelf button:disabled { opacity: 0.4; cursor: default; }
#object-settings { position: absolute; left: 8px; bottom: 52px; display: none; background: #111c; border: 1px solid var(--border); border-radius: 3px; padding: 4px 8px; }
#object-settings label { display: block; }
#wire-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; }
#wire-overlay .wire-line { stroke: #8fb8ff; stroke-width: 2; fill: none; opacity: 0.8; }
#wire-overlay .wire-line.active { stroke: #ffe066; stroke-width: 3; opacity: 1; }
#wire-overlay .wire-line.selected { stroke: #ff7a59; stroke-width: 3; }
#wire-overlay .shot-frustum { stroke: #c9a2ff; stroke-width: 1.5; fill: none; opacity: 0.85; stroke-dasharray: 4 3; pointer-events: none; }
#wire-overlay .wire-hit { stroke: transparent; stroke-width: 12; fill: none; pointer-events: stroke; cursor: pointer; }
#wire-overlay .wire-dot { fill: #1b2a44; stroke: #8fb8ff; stroke-width: 2; pointer-events: all; cursor: crosshair; }
#wire-overlay .wire-dot.out { fill: #8fb8ff; }
#wire-overlay .channel-link { stroke: #9fd3ff; stroke-width: 1.5; fill: none; opacity: 0.45; stroke-dasharray: 3 5; pointer-events: none; } /* H11.10 */
#wire-overlay .wire-drag { stroke: #ffe066; stroke-width: 2; stroke-dasharray: 4 3; }
#wire-note { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); display: none; padding: 3px 10px; pointer-events: none;
  background: rgba(60,30,30,0.92); border: 1px solid #a66; border-radius: 4px; font: 13px var(--mono); color: #fdd; }
#wire-readout { position: absolute; pointer-events: none; padding: 2px 6px; font: 12px/1.3 monospace; background: rgba(12, 20, 36, 0.85); color: #dfe8ff; border-radius: 4px; white-space: nowrap; }
#wire-readout .wire-delete { pointer-events: auto; margin-left: 8px; min-height: 32px; padding: 2px 10px; font: 12px monospace; } /* H6.2 */
@media (pointer: coarse) { #wire-readout .wire-delete { min-height: 44px; } } /* H10.1: a thumb-sized delete on touch screens */
@media (pointer: coarse) { #wire-overlay .wire-hit { stroke-width: 44; } #wire-overlay .wire-dot { stroke-width: 3; } } /* H6.2: 22 px either side */
#create-note:empty, #wire-note:empty, #wire-readout:empty { display: none !important; }
#stroke-box { width: 100%; } #stroke-presets { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; } #stroke-dials label { display: block; }
#stroke-tips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
#stroke-presets svg, #stroke-tips svg { width: 20px; height: 20px; vertical-align: middle; margin-right: 3px; } /* H4.12 brush swatches */

/* E4.5: the music picker's pattern field */
#music-pattern-host { flex-basis: 100%; }
#music-pattern-host .music-pattern textarea { width: 100%; box-sizing: border-box; font-family: ui-monospace, monospace; font-size: 12px; }
#music-pattern-host .music-pattern-error { font-size: 12px; min-height: 1em; opacity: 0.85; }
#music-pattern-host .music-pattern textarea[aria-invalid="true"] { outline: 1px solid #c55; }
#music-pattern-host .music-sections { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; }
#music-pattern-host .note-pad-bar { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 12px; }
#music-pattern-host .note-pad-oct { min-width: 2.5em; text-align: center; font-family: ui-monospace, monospace; }
#music-pattern-host .note-pad-bar button[aria-pressed="true"] { outline: 1px solid currentColor; }
#music-pattern-host .drum-grid { margin-top: 6px; font-size: 12px; }
#music-pattern-host .drum-grid-bar { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
#music-pattern-host .drum-grid-row { display: flex; gap: 1px; align-items: center; margin-top: 2px; }
#music-pattern-host .drum-grid-name { width: 4.5em; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, monospace; }
#music-pattern-host .drum-grid-row button { flex: 1; min-width: 0; height: 16px; padding: 0; border-radius: 2px; }
#music-pattern-host .drum-grid-row button:nth-of-type(4n+1) { margin-left: 3px; }
#music-pattern-host .drum-grid-row button[data-level="1"] { background: #5a6a80; }
#music-pattern-host .drum-grid-row button[data-level="2"] { background: #7b8fae; }
#music-pattern-host .drum-grid-row button[data-level="3"] { background: #a7bde0; }
#music-pattern-host .drum-grid-row button[data-level="4"] { background: #e3eefc; }
#music-pattern-host .note-pad-keys { display: flex; gap: 2px; margin-top: 6px; }
#music-pattern-host .note-pad-keys button { flex: 1; min-width: 0; padding: 14px 0 4px; font-size: 10px; border-radius: 3px; touch-action: none; }
#music-pattern-host .note-pad-keys button.black { background: #222; color: #ddd; }
#music-pattern-host .note-pad-keys button.on { filter: brightness(1.4); }
#music-pattern-host .note-pad-msg { font-size: 12px; min-height: 1em; opacity: 0.85; }
/* H12.3: the melody step grid; on a phone (gridFit: under 700 px) every grid cell, page button and
   key is at least 44 px, the drum rows carry their name above the cells, the keys wrap to rows */
#music-pattern-host .melody-grid { margin-top: 6px; font-size: 12px; }
#music-pattern-host .melody-grid-bar, #music-pattern-host .grid-pages { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
#music-pattern-host .grid-pages button[aria-pressed="true"], #music-pattern-host .melody-grid-bar button[aria-pressed="true"] { outline: 1px solid currentColor; }
#music-pattern-host .melody-grid-row { display: flex; gap: 1px; margin-top: 1px; }
#music-pattern-host .melody-cell { flex: 1; min-width: 0; height: 16px; padding: 0; font-size: 9px; border-radius: 2px; background: #2a2f3a; color: #bbb; overflow: hidden; touch-action: pan-y; }
#music-pattern-host .melody-cell.bar-start { margin-left: 2px; }
#music-pattern-host .melody-cell[data-note="start"] { background: #e0b860; color: #000; }
#music-pattern-host .melody-cell[data-note="hold"] { background: #a8894a; }
#music-pattern-host .melody-cell[data-off="true"] { box-shadow: inset 0 0 0 2px #d0604c; }
#music-pattern-host .drum-cell { touch-action: pan-y; }
#music-pattern-host .phone .drum-grid-row { flex-wrap: wrap; gap: 0; }
#music-pattern-host .phone .drum-grid-name { flex-basis: 100%; width: auto; }
#music-pattern-host .phone .drum-grid-row button, #music-pattern-host .phone .melody-cell { min-width: 44px; height: 44px; margin-left: 0; font-size: 11px; }
#music-pattern-host .phone .melody-grid-row { gap: 0; }
#music-pattern-host .phone .grid-pages button, #music-pattern-host .phone .melody-grid-bar button, #music-pattern-host .phone .drum-grid-bar button,
#music-pattern-host .phone .melody-grid-bar select, #music-pattern-host .phone .drum-grid-bar select { min-width: 44px; min-height: 44px; }
#music-pattern-host .note-pad-keys.wrap { display: grid; grid-template-columns: repeat(var(--pad-cols, 7), minmax(44px, 1fr)); }
#music-pattern-host .note-pad-keys.wrap button { min-height: 44px; }
/* C1.4: the pointer tools */
#create-bar .tool-icon { width: 1em; height: 1em; vertical-align: -0.15em; }
#create-canvas[data-tool="cursor"] { cursor: default; }
#create-canvas[data-tool="hand"] { cursor: grab; }
#wire-overlay.cursor-tool .wire-hit, #wire-overlay.cursor-tool .wire-dot { pointer-events: none; }
/* D2.5: the Render panel over the viewport; pointer events pass to the editor canvas below */
#render-panel { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#render-panel[hidden] { display: none; }
#render-canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
#render-bar { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center;
  padding: 4px 10px; border-radius: 6px; background: rgba(20, 22, 28, 0.82); color: #eee; font: 12px system-ui, sans-serif; pointer-events: auto; }
/* H1.3: the Hand's turn ring and scale grip, on the wire overlay */
#wire-overlay .hand-ring { fill: none; stroke: var(--ok); stroke-width: 2; opacity: 0.7; }
#wire-overlay .hand-ring.active { opacity: 1; stroke-width: 3; }
#wire-overlay .hand-spoke { stroke: var(--ok); stroke-width: 2; }
#wire-overlay .hand-guide { stroke: var(--ok); stroke-width: 1; stroke-dasharray: 4 3; } /* H7.5 face snap */
#wire-overlay .hand-snap-readout { fill: var(--ok); font-size: 12px; paint-order: stroke; stroke: rgba(0, 0, 0, 0.6); stroke-width: 3px; }
#wire-overlay .hand-grip { fill: #1b2a44; stroke: var(--ok); stroke-width: 2; }
#wire-overlay .hand-grip.active { fill: var(--ok); }
/* H2.6: the selection box and a mark on every other selected object */
#wire-overlay .hand-box { fill: rgba(120, 200, 140, 0.08); stroke: var(--ok); stroke-width: 1; stroke-dasharray: 4 3; }
#wire-overlay .hand-mark { fill: none; stroke: var(--ok); stroke-width: 2; stroke-dasharray: 3 3; }
#wire-overlay .hand-axis { stroke-width: 2; opacity: 0.7; }
#wire-overlay .axis-x { stroke: #e5534b; }
#wire-overlay .axis-y { stroke: #57ab5a; }
#wire-overlay .axis-z { stroke: #539bf5; }
#wire-overlay .hand-grip.axis-x.active { fill: #e5534b; }
#wire-overlay .hand-grip.axis-y.active { fill: #57ab5a; }
#wire-overlay .hand-grip.axis-z.active { fill: #539bf5; }
/* H3.11: live wire values and the signal trace while playing */
#wire-overlay .wire-value { fill: #8fb8ff; font: 11px ui-monospace, monospace; text-anchor: middle; paint-order: stroke; stroke: #0b1220; stroke-width: 3px; }
#wire-overlay .wire-value.active { fill: #ffe066; }
#signal-watch { position: absolute; right: 80px; bottom: 8px; padding: 4px 6px; background: rgba(11, 18, 32, 0.8); border-radius: 4px; font: 11px ui-monospace, monospace; color: #c8d3e6; pointer-events: none; }
#signal-watch .signal-controls { display: flex; gap: 6px; margin-top: 4px; }
#signal-watch .signal-controls button { pointer-events: auto; min-width: 56px; min-height: 36px; touch-action: manipulation; }
.touch-edit-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0; }
.touch-edit-row button { min-height: 40px; touch-action: manipulation; }
#signal-watch .signal-trace { display: flex; align-items: center; gap: 6px; }
#signal-watch .signal-trace span { min-width: 6em; }
#signal-watch .trace-line { fill: none; stroke: #ffe066; stroke-width: 1.5; }
/* M1.2, M1.3: the studio on a phone (under 700 px). The bar is the bottom sheet of
   ../shared/mobile.css (opened by the Menu button); every fixed box wraps inside the
   screen, stays clear of the Menu button (top right) and the pad and its latches (bottom 190 px), and
   the hint, tour and error line close with their button or a tap outside. */
@media (max-width: 699px) {
  #create-help { display: none !important; }
  #create-bar .panel > summary { min-height: 44px; display: flex; align-items: center; font-size: 15px; }
  #create-hud { top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); right: 64px; flex-wrap: wrap; gap: 2px 10px; font-size: 11px; }
  #create-hud > span:nth-child(2), #create-hud > span:nth-child(3), #create-hud > span:nth-child(6), #create-hud > span:nth-child(7), #create-hud > span:nth-child(8) { display: none; }
  #fps-badge { top: calc(64px + env(safe-area-inset-top)); bottom: auto; right: calc(8px + env(safe-area-inset-right)); width: 48px; min-width: 48px; padding: 0 2px; font-size: 10px; } /* P1.4: under the Menu button, clear of the pad */
  #budget-bar { top: calc(130px + env(safe-area-inset-top)); bottom: auto !important; left: 8px !important; right: 64px; width: auto !important; min-width: 0 !important; white-space: normal !important; font-size: 11px !important; }
  #create-hint, #create-tour, #create-note { left: 8px; right: 64px; transform: none; white-space: normal; box-sizing: border-box; pointer-events: auto; font-size: 13px; }
  #create-hint, #create-tour { display: flex; align-items: flex-start; gap: 6px; }
  #create-hint { top: calc(150px + env(safe-area-inset-top)); } /* H13.1: below the top bar (bar/model.js barLayout().below) */
  #create-tour { top: calc(244px + env(safe-area-inset-top)); flex-wrap: wrap; }
  #create-note { top: calc(150px + env(safe-area-inset-top)); bottom: auto; z-index: 46; }
  #create-note .m-close { float: right; }
  #create-hint .hint-text, #create-tour .tour-text, #create-note .note-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  #object-settings { left: 8px; right: 8px; bottom: calc(190px + env(safe-area-inset-bottom)); max-height: 30vh; overflow-y: auto; }
  #wire-note { bottom: calc(190px + env(safe-area-inset-bottom)); white-space: normal; max-width: calc(100% - 16px); box-sizing: border-box; }
  #signal-watch .signal-trace, #signal-watch .signal-status { display: none; } /* M1.18: a trace plot no finger can close; H6.1: Pause and Step stay */
  #render-bar { left: 8px; right: 64px; transform: none; flex-wrap: wrap; }
}
/* M1.6: the Free and Add latches (touch screens, edit mode), in a row above the stick */
@media (pointer: coarse) {
  #touch-latches { position: absolute; left: calc(14px + env(safe-area-inset-left)); bottom: 128px; display: flex; gap: 6px; pointer-events: auto; opacity: .8; }
  #touch-latches[hidden] { display: none; }
  #touch-latches button { min-width: 56px; height: 44px; border-radius: 10px; background: rgba(10, 8, 24, .55); border: 1px solid rgba(180, 76, 255, .55);
    color: #e6e0ff; font: 600 13px system-ui, sans-serif; touch-action: manipulation; }
  #touch-latches button[aria-pressed="true"] { background: rgba(34, 230, 255, .3); border-color: #22e6ff; color: #fff; }
}
/* H7.3: the timeline by finger. The ease picker and Delete keys stay on one line on a 360-px sheet;
   the band shows a range drag; the bend ring and lift arrow sit on the picked part in the view. */
#create-bar .motion-keyrow { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; max-width: 100%; min-width: 0; }
#create-bar .motion-keyrow label { display: flex; gap: 4px; align-items: center; min-width: 0; }
#create-bar .motion-keyrow select { min-width: 0; max-width: 9em; }
#create-bar .motion-band { position: absolute; top: 0; bottom: 0; background: rgba(34, 230, 255, .2); border: 1px solid #22e6ff; pointer-events: none; }
#create-bar .motion-band[hidden] { display: none; }
@media (pointer: coarse) { #motion-keys { height: 2.4em !important; } #create-bar .motion-keyrow button { min-height: 40px; } }
#wire-overlay .pose-ring { fill: none; stroke: #ffb347; stroke-width: 3; pointer-events: none; }
#wire-overlay .pose-arrow { stroke: #22e6ff; stroke-width: 3; pointer-events: none; }
#wire-overlay .pose-tip { fill: #22e6ff; pointer-events: none; }
#wire-overlay .pose-ring.active, #wire-overlay .pose-arrow.active, #wire-overlay .pose-tip.active { stroke-width: 5; }
#wire-overlay .pose-spoke { stroke: #ffb347; stroke-width: 2; pointer-events: none; }
#wire-overlay .pose-value { fill: #fff; font: 600 13px system-ui, sans-serif; pointer-events: none; }
@media (pointer: coarse) { #wire-overlay .pose-ring { stroke-width: 6; } }
/* H8.1: the thumb rail (thumb-rail.js places every box from railLayout). The pad becomes one
   row beside its stick in the other bottom corner; the sheet's copies of the rail hide; a
   short landscape view gets a side sheet on the other edge and the pad hides while it is open. */
#rail-hand-row, #rail-lift { display: none; }
@media (pointer: coarse) { #rail-hand-row { display: inline-flex; align-items: center; gap: 4px; } #rail-lift { display: inline-block; } }
#thumb-rail { position: fixed; inset: 0; z-index: 21; pointer-events: none; }
#thumb-rail[hidden] { display: none; }
#thumb-rail .rail-btn, #thumb-rail .rail-dial { position: fixed; box-sizing: border-box; pointer-events: auto; touch-action: none; }
#thumb-rail .rail-btn { min-width: 0; min-height: 0; padding: 0; border-radius: 10px; background: rgba(10, 8, 24, .6); border: 1px solid rgba(180, 76, 255, .55);
  color: #e6e0ff; font: 600 10px system-ui, sans-serif; opacity: .85; }
#thumb-rail .rail-btn[aria-pressed="true"] { background: rgba(34, 230, 255, .3); border-color: #22e6ff; color: #fff; }
#thumb-rail .rail-btn:disabled { opacity: .35; }
#thumb-rail .rail-dial { border-radius: 10px; background: rgba(10, 8, 24, .45); border: 1px solid rgba(34, 230, 255, .45); overflow: hidden; }
#thumb-rail .rail-dial[hidden] { display: none; }
#thumb-rail .rail-dial-fill { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(34, 230, 255, .18); pointer-events: none; }
/* H8.2: the ring menu (ring-menu.js): eight slots around a held finger, the one under it lit. */
#ring-menu { position: fixed; width: 0; height: 0; z-index: 23; pointer-events: none; }
#ring-menu[hidden] { display: none; }
#ring-menu .ring-slot { position: absolute; width: 48px; height: 48px; box-sizing: border-box; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  text-align: center; font: 600 11px/1.1 system-ui, sans-serif; color: #e8e4ff; background: rgba(10, 8, 24, .78); border: 1px solid rgba(180, 76, 255, .6); }
#ring-menu .ring-slot[data-on] { background: rgba(34, 230, 255, .45); border-color: #22e6ff; color: #fff; transform: scale(1.12); }
#thumb-rail .rail-dial-thumb { position: absolute; left: 0; width: 100%; height: 44px; box-sizing: border-box; border-radius: 10px; background: rgba(34, 230, 255, .35); border: 1px solid #22e6ff; pointer-events: none; }
#thumb-rail .rail-dial-label { position: absolute; left: 0; right: 0; top: 2px; text-align: center; color: #e6e0ff; font: 600 9px system-ui, sans-serif; pointer-events: none; }
body.rail-on .m-stick, body.rail-on .m-pad-buttons, body.rail-on #touch-latches { position: fixed !important; }
body.rail-on .m-pad-buttons { grid-template-columns: repeat(4, 44px) !important; grid-template-areas: "tl up dn tr" !important; }
@media (max-width: 699px) {
  body.rail-side #create-bar.m-sheet { top: 0 !important; bottom: 0 !important; left: var(--rail-sheet-x) !important; right: auto !important;
    width: var(--rail-sheet-w) !important; max-height: none !important; border-radius: 0 !important; transform: translateX(var(--rail-sheet-off, -105%)); }
  body.rail-side #create-bar.m-sheet[data-open] { transform: none; }
  body.rail-side:has(#create-bar[data-open]) .m-pad { visibility: hidden; }
}
/* H11.1: the view gizmo (axis dots, centre Frame) and Home, top corner opposite the thumb rail */
#view-gizmo { position: absolute; left: 8px; top: 158px; width: 80px; height: 80px; border-radius: 50%; container-type: size; z-index: 5;
  background: rgba(0,0,0,0.35); border: 1px solid var(--border); box-sizing: border-box; touch-action: none; cursor: pointer; }
#view-home { position: absolute; left: 94px; top: 158px; width: 44px; height: 44px; z-index: 5; padding: 0; box-sizing: border-box;
  background: rgba(0,0,0,0.55); border: 1px solid var(--border); border-radius: 50%; color: #ddd; font: 18px var(--mono); cursor: pointer; }
#view-gizmo .vg-dot { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; pointer-events: none;
  display: flex; align-items: center; justify-content: center; font: bold 10px var(--mono); color: #000; }
#view-gizmo .vg-x { background: #e5534b; } #view-gizmo .vg-y { background: #57c35a; } #view-gizmo .vg-z { background: #4a8fe7; }
#view-gizmo .vg-neg { width: 12px; height: 12px; margin: -6px 0 0 -6px; filter: brightness(0.6); }
#view-gizmo .vg-frame { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: none; border: 2px solid #ddd; box-sizing: border-box; z-index: 0; }
body.rail-left #view-gizmo { left: auto; right: 8px; }
body.rail-left #view-home { left: auto; right: 94px; }
@media (max-width: 699px) {
  #view-gizmo, #view-home { top: calc(150px + env(safe-area-inset-top)); } /* H13.1: below the top bar and the budget line; the hint sits beside */
  body.rail-side:has(#create-bar[data-open]) #view-gizmo, body.rail-side:has(#create-bar[data-open]) #view-home { visibility: hidden; }
}
@media (max-width: 699px) and (orientation: portrait) {
  #view-home { left: 8px; top: calc(236px + env(safe-area-inset-top)); } /* under the gizmo: a narrow upright rail can start at x 118 */
  body.rail-left #view-home { left: auto; right: 8px; }
}

/* H12.2: the lifted cursor's ring and the loupe (finger-loupe.js places both; neither takes the pointer). */
#finger-ring { position: fixed; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2px solid #22e6ff;
  box-shadow: 0 0 0 1px rgba(10, 8, 24, .8); pointer-events: none; z-index: 22; }
#finger-loupe { position: fixed; width: 120px; height: 120px; border: 2px solid rgba(180, 76, 255, .8);
  background: radial-gradient(circle closest-side, transparent calc(100% - 3px), rgba(10, 8, 24, .95) calc(100% - 2px)); pointer-events: none; z-index: 22; box-sizing: border-box; }
#finger-loupe::after { content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2px solid #22e6ff; box-sizing: border-box; }
#finger-ring[hidden], #finger-loupe[hidden] { display: none; }

/* H12.4: the Isolate banner (the count, a tap shows all), beside Home, opposite the thumb rail */
#isolate-bar { position: absolute; left: 146px; top: 158px; width: 200px; height: 44px; z-index: 5; padding: 0 10px; box-sizing: border-box;
  background: rgba(0,0,0,0.6); border: 1px solid var(--border); border-radius: 22px; color: #ddd; font: 12px var(--mono); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#isolate-bar[hidden] { display: none; }
body.rail-left #isolate-bar { left: auto; right: 146px; }
@media (max-width: 699px) {
  #isolate-bar { top: calc(150px + env(safe-area-inset-top)); }
  body.rail-side:has(#create-bar[data-open]) #isolate-bar { visibility: hidden; }
}
@media (max-width: 699px) and (orientation: portrait) {
  #isolate-bar { left: 8px; top: calc(288px + env(safe-area-inset-top)); width: 104px; height: 56px; white-space: normal; line-height: 1.25; border-radius: 12px; }
  body.rail-left #isolate-bar { left: auto; right: 8px; }
}

/* H13.1: on a phone the hint and the tour card sit beside the gizmo column (upright) or beside the
   gizmo, Home and Isolate row (landscape), below the top bar; mirrored for the left hand. */
@media (max-width: 699px) and (orientation: portrait) {
  #create-hint, #create-tour { left: 96px; }
  body.rail-left #create-hint, body.rail-left #create-tour { left: 8px; right: 96px; }
}
@media (max-width: 699px) and (orientation: landscape) {
  #create-hint, #create-tour { left: 354px; }
  #create-tour { top: calc(216px + env(safe-area-inset-top)); }
  body.rail-left #create-hint, body.rail-left #create-tour { left: 8px; right: 354px; }
}

/* H13.5: a phone with the thumb rail. The hint and the tour card share one slot clear of the rail
   (108 px = thumb-rail.js RAIL_MAX_W + 14 from the hand's edge), beside the gizmo column (upright)
   or under the gizmo, Home and Isolate row (landscape), never taller than hints.js CARD_MAX_H; the
   tour card replaces the hint while it runs, and both step aside while the loupe shows. The ring's
   slots are the bar's current row, in the bar's colours. */
@media (max-width: 699px) and (orientation: portrait) {
  body.rail-on #create-hint, body.rail-on #create-tour { left: 96px; right: 108px; top: calc(150px + env(safe-area-inset-top)); max-height: 132px; overflow-y: auto; }
  body.rail-on.rail-left #create-hint, body.rail-on.rail-left #create-tour { left: 108px; right: 96px; }
}
@media (max-width: 699px) and (orientation: landscape) {
  body.rail-on #create-hint, body.rail-on #create-tour { left: 146px; right: 108px; top: calc(200px + env(safe-area-inset-top)); max-height: 46px; overflow-y: auto; }
  body.rail-on.rail-left #create-hint, body.rail-on.rail-left #create-tour { left: 108px; right: 146px; }
}
body.rail-on.tour-on #create-hint { display: none; }
body.loupe-on #create-hint, body.loupe-on #create-tour { visibility: hidden; }
#ring-menu .ring-slot { flex-direction: column; gap: 1px; background: var(--tb-fill, rgba(10, 8, 24, .78)); border-color: var(--tb-rim, rgba(180, 76, 255, .6)); color: #1e1a2e; }
#ring-menu .ring-slot .tb-icon { width: 22px; height: 22px; pointer-events: none; }
#ring-menu .ring-label { max-width: 46px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 8px/1 system-ui, sans-serif; }

/* H15.5: Scene stats (stats-modal.js builds it on its first open). Below the top bar, above the
   view; it scrolls inside; its text is selectable here only; close, Esc or a tap outside closes it. */
#stats-modal { position: fixed; z-index: 30; top: 158px; right: 12px; width: 360px; max-height: calc(100% - 170px); overflow-y: auto; box-sizing: border-box;
  padding: 6px 10px 10px; background: rgba(10, 8, 24, .95); color: #e6e0ff; border: 1px solid #3a3456; border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .55); font: 12px/1.35 system-ui, sans-serif; overscroll-behavior: contain;
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
#stats-modal[hidden] { display: none; }
#stats-modal * { -webkit-user-select: text; user-select: text; }
#stats-modal .sm-head { display: flex; align-items: center; gap: 6px; }
#stats-modal .sm-head h2 { flex: 1; margin: 0; font-size: 14px; }
#stats-modal .sm-head button { min-width: 44px; min-height: 44px; -webkit-user-select: none; user-select: none; }
#stats-modal h3 { margin: 8px 0 2px; font-size: 12px; color: #b5a6f2; }
#stats-modal table { width: 100%; border-collapse: collapse; }
#stats-modal th { text-align: left; font-weight: 400; padding: 1px 6px 1px 0; color: #c8c0e8; }
#stats-modal td { text-align: right; padding: 1px 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
#stats-modal .sm-kind { width: 2.5em; color: #8f86b3; }
@media (max-width: 699px) {
  #stats-modal { top: calc(150px + env(safe-area-inset-top)); left: 8px; right: 8px; bottom: 8px; width: auto; max-height: none; }
}

/* S1.5: the Sky panel; every control a 44 px target (the phone layout guard) */
#sky-body .sky-group { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
#sky-body button, #sky-body input { min-width: 44px; min-height: 44px; box-sizing: border-box; }
#sky-body label { display: flex; align-items: center; gap: 6px; }
