/* HUD Studio chrome. Tokens come from tokens.css; the chrome never takes
   color from the dialect. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg-app); color: var(--text-hi); font: var(--type-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: var(--focus-w) solid var(--accent-soft); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font: var(--type-num); font-variation-settings: "wdth" 87.5; font-variant-numeric: tabular-nums; }
.legend { font: var(--type-legend); font-variation-settings: "wdth" 118; letter-spacing: var(--type-legend-track); text-transform: uppercase; color: var(--text-lo); }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: square; }
.led { width: 6px; height: 6px; border-radius: var(--r-round); background: var(--text-faint); flex: none; }
.led.on { background: var(--accent-soft); }
.led.rec { background: var(--accent-soft); animation: blink 0.8s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.spacer { flex: 1; }
.vsep { width: var(--hair); height: 24px; background: var(--line); flex: none; }
.scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.seg { display: inline-flex; height: var(--ctl-h); border: var(--hair) solid var(--line-strong); border-radius: var(--r-1); overflow: hidden; background: var(--bg-raised); flex: none; }
.seg button { position: relative; border: 0; background: transparent; padding: 0 var(--s-4); color: var(--text-mid); font: var(--type-label); transition: background var(--dur-flip) linear, color var(--dur-flip) linear; }
.seg button + button { border-left: var(--hair) solid var(--line-strong); }
.seg button:hover { color: var(--text-hi); }
.seg button[aria-pressed="true"] { background: var(--bg-active); color: var(--text-hi); }
.seg button[aria-pressed="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent-soft); }

.tbtn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: var(--r-2); background: transparent; color: var(--text-mid); flex: none;
  transition: background var(--dur-quick) var(--ease-precise), color var(--dur-quick) var(--ease-precise); }
.tbtn:hover { background: var(--bg-raised); color: var(--text-hi); }
.tbtn.on { color: var(--accent-text); }
.btn { height: 30px; padding: 0 var(--s-4); border-radius: var(--r-2); border: var(--hair) solid var(--line-strong); background: transparent; color: var(--text-hi); font: var(--type-label); display: inline-flex; align-items: center; justify-content: center; gap: var(--s-3); white-space: nowrap; }
.btn:hover { background: var(--bg-raised); }
.btn.lg { height: 42px; font-size: 13px; padding: 0 var(--s-5); }
.btn.danger:hover { color: var(--accent-text); border-color: var(--accent-line); }
.btn:disabled, .export:disabled { opacity: .5; cursor: default; }

/* ---------- Grid ---------- */
.studio { display: grid; gap: var(--hair); height: 100vh; min-height: 640px; background: var(--bg-app); }
.studio > * { background: var(--bg-panel); min-width: 0; min-height: 0; }
[data-view="simple"] .studio {
  grid-template-columns: minmax(0, 1fr) var(--insp-w);
  grid-template-rows: var(--bar-h) minmax(0, 1fr) var(--play-h) var(--deck-h);
  grid-template-areas: "top top" "mon insp" "play insp" "deck deck";
}
[data-view="advanced"] .studio {
  grid-template-columns: var(--lib-w) minmax(0, 1fr) var(--insp-w);
  grid-template-rows: var(--bar-h) minmax(0, 1fr) var(--play-h) 64px;
  grid-template-areas: "top top top" "lib mon insp" "play play insp" "dock dock dock";
}
[data-view="simple"] .adv-only { display: none !important; }
[data-view="advanced"] .simple-only { display: none !important; }

.topbar { grid-area: top; display: flex; align-items: center; gap: var(--s-5); padding: 0 var(--s-6); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font: 700 13px/1 var(--font-sans); font-variation-settings: "wdth" 125; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
.project { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.project .name { font: var(--type-label); font-size: 13px; }
.project .num { color: var(--text-lo); }

/* ---------- Monitor ---------- */
.monitor { grid-area: mon; background: var(--bg-well); display: grid; grid-template-rows: 36px minmax(0, 1fr);
  --mon-text: oklch(1 0 0 / .62); --mon-lo: oklch(1 0 0 / .5); }
.mon-bar { display: flex; align-items: center; gap: var(--s-5); padding: 0 var(--s-6); color: var(--mon-text); white-space: nowrap; min-width: 0; }
.mon-bar .legend { color: var(--mon-lo); }
.mon-bar .num { color: var(--mon-text); overflow: hidden; text-overflow: ellipsis; }
.mon-foot .tbtn { width: 24px; height: 24px; color: var(--mon-text); }
.mon-foot .tbtn:hover { background: oklch(1 0 0 / .08); }
.mon-foot .tbtn.on { color: var(--accent-soft); }
.foot-tools { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.foot-tools .num { color: var(--mon-lo); }
/* the workspace: the artboard centered, the toolbar floating below it */
.mon-body { container-type: size; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 4px var(--s-6) 12px; min-height: 0; }
.frame-wrap { position: relative; aspect-ratio: 16 / 9; width: min(100%, calc((100cqh - 60px) * 16 / 9)); flex: none; }
.screen { position: absolute; inset: 0; background: #000; overflow: hidden; }
.screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.screen .src { opacity: 1; }
.screen.post-ready .src { opacity: 0; }
.screen .post-canvas { opacity: 0; }
.screen.post-ready .post-canvas { opacity: 1; }

.overlay { position: absolute; inset: 0; cursor: default; touch-action: none; }
.overlay.drag { cursor: grabbing; }
#guides, #selMulti { position: absolute; inset: 0; pointer-events: none; }
.guide { position: absolute; background: #ff3ea5; }
.guide.v { top: 0; bottom: 0; width: 1px; margin-left: -0.5px; }
.guide.h { left: 0; right: 0; height: 1px; margin-top: -0.5px; }
.ghost { position: absolute; outline: 1px dashed var(--accent-soft); outline-offset: 0; }
.marquee { position: absolute; border: 1px solid var(--accent-soft); background: color-mix(in srgb, var(--accent-soft) 12%, transparent); pointer-events: none; }

.alignbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.alignbar .vsep { width: 1px; height: 18px; background: var(--line); margin: 0 8px; }
.keys { font: var(--type-label); color: var(--text-lo); line-height: 1.6; }
.selection { position: absolute; outline: var(--hair) solid var(--accent-soft); pointer-events: none; }
.selection i { position: absolute; width: 9px; height: 9px; background: var(--bg-well); border: var(--hair) solid var(--accent-soft); pointer-events: auto; }
.selection i[data-h="nw"] { left: -5px; top: -5px; cursor: nwse-resize; } .selection i[data-h="ne"] { right: -5px; top: -5px; cursor: nesw-resize; }
.selection i[data-h="sw"] { left: -5px; bottom: -5px; cursor: nesw-resize; } .selection i[data-h="se"] { right: -5px; bottom: -5px; cursor: nwse-resize; }
.selection .tag { position: absolute; left: -1px; bottom: calc(100% + 5px); white-space: nowrap; padding: 2px 8px; background: var(--accent-soft); color: var(--accent-ink); font: 600 10px/14px var(--font-sans); }
.hover-box { position: absolute; outline: var(--hair) dashed oklch(1 0 0 / .35); pointer-events: none; }

/* ---------- Play bar ---------- */
.playbar { grid-area: play; display: grid; grid-template-columns: 232px minmax(0, 1fr) 132px; align-items: center; }
.transport { display: flex; align-items: center; gap: var(--s-4); padding-left: var(--s-6); }
.play { width: 40px; height: 40px; border-radius: var(--r-2); border: var(--hair) solid var(--line-strong); background: var(--bg-raised); color: var(--text-hi); display: grid; place-items: center; flex: none; }
.play:hover { background: var(--bg-active); }
.play .icon { width: 18px; height: 18px; }
.tc { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.tc .now { font: var(--type-num-lg); font-variation-settings: "wdth" 75; font-variant-numeric: tabular-nums; }
.tc .num { color: var(--text-lo); }
.beatline[hidden] { display: block !important; visibility: hidden; }
.beatline { position: relative; display: flex; gap: 4px; height: 40px; margin-right: var(--s-6); cursor: pointer; }
.bt { position: relative; min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; display: grid; grid-template-rows: 18px 6px; align-content: center; gap: 8px; color: var(--text-mid); }
.bt .lbl { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; overflow: hidden; font: var(--type-label); font-size: 13px; }
.bt .lbl .num { color: var(--text-lo); }
.bt .bar { position: relative; background: var(--bg-active); border-radius: 1px; overflow: hidden; }
.bt .bar i { position: absolute; inset: 0 auto 0 0; background: var(--text-lo); }
.bt.now { color: var(--text-hi); }
.bt.now .bar i { background: var(--accent-soft); }
.bt:hover .lbl { color: var(--text-hi); }
.beatline .ph { position: absolute; top: 22px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--text-hi); pointer-events: none; }
.loopctl { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-right: var(--s-6); color: var(--text-mid); font: var(--type-label); }

/* ---------- Simple: deck ---------- */
.deck { grid-area: deck; display: grid; grid-template-columns: 1.15fr 0.85fr 1.2fr; }
.step { padding: 16px var(--s-7); display: grid; grid-template-rows: 26px minmax(0, 1fr); gap: 12px; min-width: 0; min-height: 0; }
.step + .step { border-left: var(--hair) solid var(--line); }
.step-head { display: flex; align-items: center; gap: var(--s-4); min-width: 0; }
.step-no { width: 22px; height: 22px; display: grid; place-items: center; border: var(--hair) solid var(--text-hi); border-radius: var(--r-1); font: 500 11px/1 var(--font-mono); flex: none; }
.step-head h2 { margin: 0; font: var(--type-title); white-space: nowrap; }
.step-head .hint { margin-left: auto; font: var(--type-label); color: var(--text-lo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.recipes { overflow-y: auto; padding-right: 8px; align-content: start; display: grid; gap: 12px; min-height: 0; }
.tgroup { display: grid; gap: 4px; }
.tgroup-head { font: var(--type-label); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-lo); padding: 0 4px; }
.tgroup-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px var(--s-3); }
.recipe { display: flex; align-items: center; gap: var(--s-4); padding: 4px; border: 0; border-radius: var(--r-2); background: transparent; text-align: left; color: var(--text-mid); min-width: 0;
  transition: background var(--dur-quick) var(--ease-precise), color var(--dur-quick) var(--ease-precise); }
.recipe:hover { background: var(--bg-raised); color: var(--text-hi); }
.recipe canvas { width: 72px; height: 40.5px; flex: none; border-radius: var(--r-1); background: #000; outline: var(--hair) solid var(--line-strong); outline-offset: -1px; }
.recipe .rt { display: grid; gap: 2px; min-width: 0; }
.recipe .rn { font: var(--type-label); font-size: 13px; line-height: 16px; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe .ru { font: var(--type-label); font-size: 11px; line-height: 14px; color: var(--text-lo); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recipe[aria-pressed="true"] { background: var(--accent-wash); color: var(--text-hi); }
.recipe[aria-pressed="true"] .rn { font-weight: 600; }
.recipe[aria-pressed="true"] canvas { outline: 2px solid var(--accent-soft); outline-offset: 0; }

.content { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: var(--s-5); align-content: start; padding-right: 4px; }
.content.no-image { grid-template-columns: minmax(0, 1fr); }
.drop { position: relative; width: 132px; height: 132px; border-radius: var(--r-3); overflow: hidden; background: var(--bg-raised); border: var(--hair) dashed var(--line-strong); padding: 0; display: grid; place-items: center; text-align: center; color: var(--text-mid); font: var(--type-label); }
.drop:hover, .drop.over { border-color: var(--accent-soft); color: var(--text-hi); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop .file { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px; background: rgb(12 13 15 / .8); color: #e6e6e6; font: var(--type-label); font-size: 11px; }
.drop .empty { display: grid; gap: 8px; justify-items: center; padding: 8px; }
.drop .empty .icon { width: 22px; height: 22px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4) var(--s-4); align-content: start; min-width: 0; }
.fields .wide { grid-column: 1 / -1; }
.fld { display: grid; gap: 8px; min-width: 0; }
.fld label { font: var(--type-label); color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.input { height: var(--ctl-h-lg); display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); background: var(--bg-raised); border: var(--hair) solid var(--line-strong); border-radius: var(--r-2); min-width: 0;
  transition: border-color var(--dur-quick) var(--ease-precise); }
.input:hover { border-color: var(--text-lo); }
.input:focus-within { border-color: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.fld.long { grid-column: 1 / -1; }
.fld.long .input { height: auto; padding: 8px var(--s-4); }
.input textarea { flex: 1; min-width: 0; resize: vertical; background: transparent; border: 0; outline: 0; padding: 0; font: var(--type-field); color: var(--text-hi); }
.input input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; padding: 0; font: var(--type-field); color: var(--text-hi); }
.input .st { font: var(--type-num); color: var(--text-lo); white-space: nowrap; }
.input .st.live { color: var(--accent-text); }

.style { display: grid; gap: 12px; align-content: start; min-height: 0; overflow-y: auto; }
.export-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dcards { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4); }
.dcard { display: grid; gap: 8px; padding: 0; background: transparent; border: 0; text-align: left; color: var(--text-mid); min-width: 0; }
.dcard canvas { width: 100%; aspect-ratio: 16 / 9; display: block; border-radius: var(--r-2); background: #000; outline: var(--hair) solid var(--line-strong); outline-offset: -1px; transition: outline-color var(--dur-quick) var(--ease-precise); }
.dcard:hover canvas { outline: 2px solid var(--text-lo); outline-offset: 0; }
.dcard[aria-pressed="true"] canvas { outline: 2px solid var(--accent-soft); outline-offset: 0; }
.dcard .nm { display: flex; align-items: baseline; gap: 8px; font: var(--type-label); font-size: 13px; }
.dcard[aria-pressed="true"] .nm { color: var(--text-hi); font-weight: 600; }
.export-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3); }
.export { height: 42px; border-radius: var(--r-2); border: 0; background: var(--accent); color: var(--accent-ink); font: 600 14px/1 var(--font-sans); display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
.export:hover:not(:disabled) { background: oklch(from var(--accent) calc(l - .04) c h); }
.export .icon { stroke-width: 1.5; }
.export-meta { color: var(--text-lo); }

/* ---------- Advanced: library ---------- */
.library { grid-area: lib; display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 var(--s-5); border-bottom: var(--hair) solid var(--line); flex: none; }
.group { padding: var(--s-3) 0; }
.group + .group { border-top: var(--hair) solid var(--line); }
.group-head { padding: var(--s-2) var(--s-5); }
.mod { width: 100%; display: flex; align-items: center; gap: 12px; height: var(--row-h); padding: 0 var(--s-5); background: transparent; border: 0; color: var(--text-mid); font: var(--type-label); font-size: 13px; text-align: left; transition: background var(--dur-quick) var(--ease-precise); }
.mod span { flex: 1; }
.mod .icon { opacity: 0; color: var(--accent-text); }
.mod:hover { background: var(--bg-raised); color: var(--text-hi); }
.mod:hover .icon { opacity: 1; }

/* ---------- Advanced: inspector ---------- */
.inspector { grid-area: insp; display: flex; flex-direction: column; overflow: hidden; }
.insp-title { display: flex; align-items: center; gap: 12px; height: var(--bar-h); padding: 0 var(--s-5); border-bottom: var(--hair) solid var(--line); flex: none; }
.insp-title h2 { margin: 0; font: var(--type-title); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insp-title .num { color: var(--text-lo); }
.sect { padding: var(--s-4) var(--s-5) var(--s-5); border-bottom: var(--hair) solid var(--line); }
.sect-head { display: flex; align-items: center; justify-content: space-between; height: 24px; margin-bottom: var(--s-3); }
.sect-head .aside { font: var(--type-label); font-size: 11px; color: var(--text-lo); }
.sect p { margin: 0 0 var(--s-3); font: var(--type-label); color: var(--text-mid); }
.row { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: var(--s-3); min-height: var(--row-h); }
.row > .lbl { font: var(--type-label); color: var(--text-mid); overflow-wrap: anywhere; line-height: 1.3; }
.row.top { align-items: start; } .row.top > .lbl { padding-top: 8px; }
.field { height: var(--ctl-h); display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-3); background: var(--bg-raised); border: var(--hair) solid var(--line); border-radius: var(--r-1); min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; background: transparent; border: 0; outline: 0; padding: 0; font: var(--type-label); color: var(--text-hi); }
.field select option { background: var(--bg-raised); }
.field input.num { font: var(--type-num); font-variation-settings: "wdth" 87.5; }
.field .unit { color: var(--text-lo); font: var(--type-label); font-size: 10px; }
.field:focus-within { border-color: var(--accent-soft); }
textarea.area { width: 100%; min-height: 88px; resize: vertical; padding: 8px var(--s-3); background: var(--bg-raised); border: var(--hair) solid var(--line); border-radius: var(--r-1); color: var(--text-hi); font: var(--type-num); font-variation-settings: "wdth" 87.5; line-height: 17px; outline: 0; }
textarea.area:focus { border-color: var(--accent-soft); }
.quad { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.quad .field { padding: 0 8px; }
.quad .field .unit { font-size: 9px; }
.chips { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.chip { width: 30px; height: 26px; border-radius: var(--r-1); border: var(--hair) solid var(--line-strong); padding: 4px; background: transparent; }
.chip i { display: block; width: 100%; height: 100%; border-radius: 1px; }
.chip[aria-pressed="true"] { border-color: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.toggle { width: 34px; height: 18px; border-radius: 9px; border: var(--hair) solid var(--line-strong); background: var(--bg-raised); position: relative; padding: 0; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-lo); transition: transform var(--dur-quick) var(--ease-precise), background var(--dur-quick); }
.toggle[aria-pressed="true"] { border-color: var(--accent-soft); }
.toggle[aria-pressed="true"]::after { transform: translateX(16px); background: var(--accent-soft); }
.slider { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: var(--s-3); }
.slider input[type=range] { width: 100%; accent-color: var(--accent-soft); }
.slider .num { text-align: right; color: var(--text-hi); }
.actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.hint { font: var(--type-label); color: var(--text-lo); }

/* ---------- Advanced: lanes ---------- */
.lanes-panel { grid-area: lanes; display: flex; flex-direction: column; }
.lanes-scroll { flex: 1; padding: var(--s-3) 0; }
.lanes { position: relative; display: grid; grid-template-columns: 232px minmax(0, 1fr) 24px; }
.lane-row { display: contents; cursor: pointer; }
.lane-row .ln { height: 22px; display: flex; align-items: center; gap: 8px; padding: 0 var(--s-6); font: var(--type-label); color: var(--text-mid); white-space: nowrap; overflow: hidden; }
.lane-row .ln .num { color: var(--text-lo); }
.lane-row .lt { position: relative; height: 22px; }
.lane-row .lt i { position: absolute; top: 8px; height: 6px; background: var(--line-strong); border-radius: 1px; }
.lane-row .lt i::before { content: ""; position: absolute; left: 0; top: -3px; width: 2px; height: 12px; background: var(--text-lo); }
.lane-row.sel .ln { color: var(--text-hi); background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent-soft); }
.lane-row.sel .lt { background: var(--accent-wash); }
.lane-row.sel .lt i { background: var(--accent-line); }
.lane-row.sel .lt i::before { background: var(--accent-soft); }
.lane-row:hover .ln { color: var(--text-hi); }
.lanes .ph { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text-hi); pointer-events: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--bg-raised); color: var(--text-hi); border: var(--hair) solid var(--line-strong); border-radius: var(--r-2); padding: 12px 12px; font: var(--type-label); z-index: 20; }

/* ---------- Narrow ---------- */
@media (max-width: 900px) {
  .studio { height: auto; min-height: 0; }
  [data-view] .studio { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  [data-view="simple"] .studio { grid-template-areas: "top" "mon" "play" "deck"; }
  [data-view="advanced"] .studio { grid-template-areas: "top" "mon" "play" "insp" "lib"; }
  .topbar { flex-wrap: wrap; padding: var(--s-4) var(--s-5); min-height: var(--bar-h); gap: var(--s-3); }
  .hide-narrow { display: none !important; }
  .mon-body { container-type: normal; padding: 0 var(--s-5); }
  .frame-wrap { width: 100%; }
  .playbar { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); padding: var(--s-4) 0; }
  .beatline { margin: 0 var(--s-5); }
  .bt .lbl .num { display: none; }
  .loopctl { display: none; }
  .deck { grid-template-columns: minmax(0, 1fr); }
  .step { padding: 24px var(--s-5); }
  .step + .step { border-left: 0; border-top: var(--hair) solid var(--line); }
  .content, .fields { grid-template-columns: minmax(0, 1fr); }
  .lanes { grid-template-columns: 120px minmax(0, 1fr) 8px; }
  .lane-row .ln { padding: 0 var(--s-4); }
  .inspector { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { .led.rec { animation: none; } }

.toplink { font: var(--type-label); color: var(--text-mid); text-decoration: none; padding: 8px 8px; border-radius: var(--r-2); }
.toplink:hover { color: var(--text-hi); background: var(--bg-raised); }

/* history buttons in the top bar */
.hist { display: flex; gap: 2px; }
.hist .tbtn:disabled { opacity: 0.35; cursor: default; }
/* transparent background: a checkerboard shows through the alpha */
.screen.alpha { background: repeating-conic-gradient(#2a2d31 0 25%, #1c1e21 0 50%) 0 0 / 24px 24px; }
.check { display: flex; align-items: center; gap: 8px; font: 500 12px/16px var(--font-sans); color: var(--text-mid, var(--text-lo)); cursor: pointer; }
/* multi-selection can be resized as a group */
.selection.multi i { display: block; }

/* ambient: the monitor alone, fullscreen, no interface */
.btn.sm { height: 24px; padding: 0 12px; font-size: 11px; color: var(--mon-text); border-color: rgba(255,255,255,.16); }
html.ambient .monitor { position: fixed; inset: 0; z-index: 40; background: #000; grid-template-rows: minmax(0, 1fr); }
html.ambient .monitor > .mon-bar { display: none; }
html.ambient .mon-body { padding: 0 !important; }
html.ambient .overlay, html.ambient .ws-foot, html.ambient .deck-grip { display: none !important; }
html.ambient .screen.alpha { background: #000; }
html.ambient.idle, html.ambient.idle * { cursor: none !important; }

/* wallpaper and OBS help */
dialog.help { width: min(640px, calc(100vw - 32px)); padding: 24px 24px 24px; border: var(--hair) solid var(--line-strong); border-radius: var(--r-3, 10px); background: var(--bg-panel, var(--bg-raised)); color: var(--text-hi); font: 400 14px/1.5 var(--font-sans); }
dialog.help::backdrop { background: rgba(0,0,0,.55); }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.help h2 { font: 600 17px/1.3 var(--font-sans); margin: 0; }
.help p { margin: 12px 0; color: var(--text-mid); }
.help .uses { margin: 12px 0; padding-left: 24px; display: grid; gap: 12px; color: var(--text-mid); }
.help .uses b { color: var(--text-hi); font-weight: 600; }
.help code { font: var(--type-num); font-size: 12px; color: var(--text-hi); }
.help .fine { font-size: 12px; color: var(--text-lo); }
.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; min-width: 0; height: 30px; padding: 0 12px; border-radius: var(--r-2); border: var(--hair) solid var(--line-strong); background: var(--bg-well); color: var(--text-mid); font: var(--type-num); font-size: 12px; }
a.btn { text-decoration: none; }
html.ambient, html.ambient body { overflow: hidden; }

/* frame option */
.opts-row { display: flex; align-items: center; gap: 12px; }
.seg-lbl { font: 500 12px/16px var(--font-sans); color: var(--text-lo); padding: 0 8px 0 2px; align-self: center; }

/* ---------- One editing model ---------- */
.studio { position: relative; }
/* visual pickers */
.chips.glass .chip { width: 26px; height: 26px; padding: 4px; }
.chips.glass .chip i { border-radius: 3px; }
.chip.outline i { border: 1px solid var(--text-lo); }
.seg.fill { display: flex; width: 100%; }
.seg.fill button { flex: 1; padding: 0 var(--s-2); }
.choices { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.choices button { height: 26px; padding: 0 var(--s-3); border-radius: var(--r-1); border: var(--hair) solid var(--line); background: transparent; color: var(--text-mid); font: var(--type-label); font-size: 11px; }
.choices button:hover { color: var(--text-hi); border-color: var(--line-strong); }
.choices button[aria-pressed="true"] { color: var(--text-hi); border-color: var(--accent-line); background: var(--accent-wash); }

/* sliders: thin track, a tick at the default, editable value */
.slider { grid-template-columns: minmax(0, 1fr) 48px; }
.track { position: relative; height: 20px; cursor: ew-resize; touch-action: none; outline-offset: 4px; }
.track b { position: absolute; left: 0; right: 0; top: 9px; height: 2px; border-radius: 1px; background: var(--line-strong); }
.track .fill { position: absolute; left: 0; top: 9px; height: 2px; border-radius: 1px; background: var(--text-mid); }
.track .tick { position: absolute; top: 5px; width: 1px; height: 10px; margin-left: -0.5px; background: var(--text-lo); }
.track .knob { position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--text-hi); box-shadow: 0 0 0 3px var(--bg-panel); transition: transform var(--dur-quick) var(--ease-precise); }
.track:hover .knob, .track.on .knob { transform: scale(1.15); }
.track:focus-visible .knob { box-shadow: 0 0 0 3px var(--bg-panel), 0 0 0 5px var(--accent-soft); }
.slider .val { width: 100%; height: 22px; border: 0; border-radius: var(--r-1); background: transparent; color: var(--text-hi); text-align: right; padding: 0 2px; outline: 0; }
.slider .val:hover { background: var(--bg-raised); }
.slider .val:focus { background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--accent-soft); }

/* gallery */
.library .panel-head .hint { font-size: 11px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); padding: 0 var(--s-4) var(--s-2); }
.tile { display: grid; gap: 6px; padding: 6px; border: var(--hair) solid transparent; border-radius: var(--r-2); background: transparent; color: var(--text-mid); font: var(--type-label); font-size: 11px; text-align: left; }
.tile canvas { width: 100%; aspect-ratio: 16 / 9; height: auto; display: block; border-radius: var(--r-1); background: #000; }
.tile span { padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile:hover { border-color: var(--line-strong); color: var(--text-hi); background: var(--bg-raised); }
.newlayout .hint { margin: 0 var(--s-5) var(--s-3); font-size: 11px; }
.layouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); padding: 0 var(--s-4) var(--s-2); }
.lay { display: grid; gap: 4px; justify-items: center; padding: 8px 4px; border: var(--hair) solid var(--line); border-radius: var(--r-2); background: transparent; color: var(--text-mid); font: var(--type-label); font-size: 10px; }
.lay:hover { border-color: var(--line-strong); color: var(--text-hi); background: var(--bg-raised); }
.lay-pic { position: relative; width: 48px; height: 27px; border-radius: 2px; background: var(--bg-active); outline: 1px solid var(--line); }
.lay-pic i { position: absolute; border-radius: 2px; background: var(--text-lo); }
.lay-pic.tube { border-radius: 4px; }
.lay-pic.tube i { border-radius: 0; background: transparent; outline: 1px solid var(--text-lo); outline-offset: -1px; }
.lay[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-wash); color: var(--text-hi); }
.lay[aria-pressed="true"] .lay-pic i { background: var(--accent-soft); }
.lay[aria-pressed="true"] .lay-pic.tube i { background: transparent; outline-color: var(--accent-soft); }

/* inline text editing */
.inline-edit { position: absolute; z-index: 3; min-height: 32px; padding: 4px 8px; border: 1px solid var(--accent-soft); border-radius: 2px; background: rgba(0,0,0,.82); color: #fff; font: var(--type-num); font-size: 14px; outline: 0; resize: none; }

/* context menu */
.ctxmenu { position: fixed; z-index: 30; min-width: 220px; padding: 4px; border: var(--hair) solid var(--line-strong); border-radius: var(--r-2); background: var(--bg-raised); box-shadow: 0 12px 32px rgba(0,0,0,.4); }
.ctxmenu .mh { padding: 8px 12px 4px; font: var(--type-legend); font-variation-settings: "wdth" 118; letter-spacing: var(--type-legend-track); text-transform: uppercase; color: var(--text-lo); }
.ctxmenu .mlbl { padding: 8px 12px 2px; font: var(--type-label); font-size: 11px; color: var(--text-lo); }
.ctxmenu .mrow { padding: 2px 12px 8px; }
.ctxmenu .mi { width: 100%; height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 12px; border: 0; border-radius: var(--r-1); background: transparent; color: var(--text-hi); font: var(--type-label); text-align: left; }
.ctxmenu .mi:hover, .ctxmenu .mi:focus-visible { background: var(--bg-active); outline: 0; }
.ctxmenu .mi:disabled { color: var(--text-faint); cursor: default; background: transparent; }
.ctxmenu .mi.danger:hover { color: var(--accent-text); }
.ctxmenu .msep { height: 1px; margin: 4px 8px; background: var(--line); }
kbd { font: var(--type-num); font-size: 10px; color: var(--text-lo); }

/* tooltips */
.tip { position: fixed; z-index: 50; max-width: 260px; display: grid; gap: 2px; padding: 6px 8px; border-radius: var(--r-1); background: var(--text-hi); color: var(--bg-panel); font: var(--type-label); font-size: 11px; line-height: 15px; pointer-events: none; }
.tip .t2 { font: var(--type-num); font-size: 10px; opacity: .62; }

/* coach marks */
.coach { position: fixed; inset: 0; z-index: 45; pointer-events: none; }
.coach-ring { position: fixed; border-radius: var(--r-2); box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 9999px rgba(0,0,0,.45); }
.coach-card { position: fixed; width: 300px; padding: 12px 16px; border-radius: var(--r-2); border: var(--hair) solid var(--line-strong); background: var(--bg-panel); color: var(--text-hi); pointer-events: auto; box-shadow: 0 16px 40px rgba(0,0,0,.4); }
.coach-card h3 { margin: 4px 0 8px; font: var(--type-title); }
.coach-card p { margin: 0 0 12px; font: var(--type-label); color: var(--text-mid); line-height: 1.5; }
.coach-step { color: var(--text-lo); }
.coach-act { display: flex; justify-content: flex-end; gap: 8px; }
.btn.primary { background: var(--accent-wash); border-color: var(--accent-line); }
@media (prefers-reduced-motion: reduce) { .track .knob { transition: none; } }

/* ---------- Devices, workspace tools (run 4) ---------- */
.mon-bar .btn.sm:hover { background: oklch(1 0 0 / .1); color: oklch(1 0 0 / .92); border-color: oklch(1 0 0 / .28); }
.mon-bar .btn.sm:active { background: oklch(1 0 0 / .16); }
.mon-bar .btn.sm:focus-visible { outline-color: var(--accent-soft); }
.topbar .export { height: 32px; padding: 0 var(--s-5); font-size: 13px; gap: 8px; flex: none; }
.topbar .btn { height: 32px; flex: none; }

.dchip { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 4px; border-radius: var(--r-2); background: oklch(0.2 0 0 / .92); border: 1px solid oklch(1 0 0 / .12); color: oklch(1 0 0 / .6); font: var(--type-label); }
.dchip canvas { width: 48px; height: 27px; border-radius: 3px; background: #000; display: block; }
.dchip:hover { color: oklch(1 0 0 / .9); border-color: oklch(1 0 0 / .25); }
.dchip[aria-pressed="true"] { color: oklch(1 0 0 / .95); border-color: var(--accent-soft); }
.ws-foot { position: relative; align-self: stretch; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 40px; flex: none; max-width: 100%; }
.toolbar { display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 6px; border-radius: var(--r-2); background: oklch(0.2 0 0 / .92); border: 1px solid oklch(1 0 0 / .12); color: oklch(1 0 0 / .7); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toolbar .tbtn { width: 32px; height: 32px; color: oklch(1 0 0 / .7); }
.toolbar .tbtn:hover:not(:disabled) { background: oklch(1 0 0 / .1); color: #fff; }
.toolbar .tbtn:disabled { opacity: .35; cursor: default; }
/* the toolbar is always dark, so it keeps the dark-mode soft accent in both modes */
.toolbar { --tb-accent: oklch(from var(--accent) 0.74 calc(c * 0.55) h); }
.toolbar .tbtn.tog[aria-pressed="true"] { background: oklch(1 0 0 / .14); color: var(--tb-accent); box-shadow: inset 0 -2px 0 var(--tb-accent); }
.toolbar .tsep { width: 1px; height: 20px; margin: 0 6px; background: oklch(1 0 0 / .14); }
.toolbar .num { color: oklch(1 0 0 / .55); padding: 0 8px; min-width: 150px; white-space: nowrap; }
.gsize { display: flex; gap: 2px; }
.gsize button { height: 26px; min-width: 32px; padding: 0 6px; border: 0; border-radius: var(--r-1); background: transparent; color: oklch(1 0 0 / .6); font: var(--type-num); font-size: 11px; }
.gsize button:hover { background: oklch(1 0 0 / .1); color: #fff; }
.gsize button[aria-pressed="true"] { background: oklch(1 0 0 / .14); color: #fff; }
.empty-hint { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-2); border: 1px dashed oklch(1 0 0 / .22); color: oklch(1 0 0 / .7); font: var(--type-label); }
.empty-hint b { font-weight: 600; color: #fff; }

.screen-sel { position: absolute; outline: 1px dashed var(--accent-soft); outline-offset: 2px; pointer-events: none; }
.screen-sel .tag { position: absolute; left: -3px; bottom: calc(100% + 6px); white-space: nowrap; padding: 2px 8px; background: var(--accent-soft); color: var(--accent-ink); font: 600 10px/14px var(--font-sans); }

.lib-tabs { display: flex; height: 40px; border-bottom: var(--hair) solid var(--line); flex: none; }
.lib-tabs button { flex: 1; position: relative; border: 0; background: transparent; color: var(--text-mid); font: var(--type-label); }
.lib-tabs button:hover { color: var(--text-hi); }
.lib-tabs button[aria-selected="true"] { color: var(--text-hi); }
.lib-tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent-soft); }
#libTemplates { padding: 12px 8px; }
#libTemplates .tgroup { margin-bottom: 12px; }
#libTemplates .tgroup-list { grid-template-columns: minmax(0, 1fr); }

.device-row { display: grid; gap: 8px; }
.device-row .row { grid-template-columns: 72px minmax(0, 1fr); }
.device-row .layouts, .inspector .layouts { grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 0; }
.inspector .layouts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lay span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.drops { display: grid; grid-template-columns: repeat(auto-fill, 132px); gap: 8px; margin-bottom: 12px; }
.inspector .drops.one { grid-template-columns: minmax(0, 1fr); }
.inspector .drops .drop { width: 100%; height: 120px; }
.inspector .fields { grid-template-columns: minmax(0, 1fr); }
.content .drops { margin: 0; grid-template-columns: 132px; align-content: start; }
.row > .lbl[data-tip] { cursor: help; text-decoration: underline dotted var(--line-strong); text-underline-offset: 3px; }
.btn.sm.plain { color: var(--text-mid); border-color: var(--line-strong); }

/* grid, guides, measuring, live dimensions, layers */
.gridcv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.guide { position: absolute; background: #ff3ea5; }
.guide.v { width: 1px; margin-left: -0.5px; }
.guide.h { height: 1px; margin-top: -0.5px; }
.guide.screen { background: #3ad1ff; }
#measure { position: absolute; inset: 0; pointer-events: none; }
.mline { position: absolute; }
.mline.h { border-top: 1px solid #ff5d55; height: 0 !important; }
.mline.v { border-left: 1px solid #ff5d55; width: 0 !important; }
.mline span { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 1px 5px; border-radius: 2px; background: #ff5d55; color: #fff; font: 600 10px/14px var(--font-mono); white-space: nowrap; }
.mtarget { position: absolute; outline: 1px solid #ff5d55; }
.selection .dim { position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); white-space: nowrap; padding: 2px 6px; border-radius: 2px; background: var(--accent-soft); color: var(--accent-ink); font-size: 10px; line-height: 14px; }
#layers { padding: 8px 0; }
.lgroup { padding: 4px 0 8px; }
.lgroup + .lgroup { border-top: var(--hair) solid var(--line); }
.lhead { width: 100%; display: flex; align-items: center; justify-content: space-between; height: 28px; padding: 0 var(--s-5); border: 0; background: transparent; color: var(--text-lo); }
.lhead:hover { background: var(--bg-raised); }
.lhead.sel { background: var(--accent-wash); }
.lhead .num { color: var(--text-lo); }
.layer { display: flex; align-items: center; gap: 2px; height: 30px; padding: 0 var(--s-3) 0 var(--s-6); cursor: pointer; border-top: 1px solid transparent; border-bottom: 1px solid transparent; }
.layer:hover { background: var(--bg-raised); }
.layer.sel { background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent-soft); }
.layer .ln { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; overflow: hidden; white-space: nowrap; font: var(--type-label); color: var(--text-mid); }
.layer .ln b { font-weight: 500; color: var(--text-hi); }
.layer .ln span { overflow: hidden; text-overflow: ellipsis; color: var(--text-lo); font-size: 11px; }
.layer .tbtn { width: 24px; height: 24px; opacity: 0; }
.layer:hover .tbtn, .layer .tbtn.on, .layer .tbtn:focus-visible { opacity: 1; }
.layer .tbtn.on { color: var(--accent-text); }
.layer.is-hidden .ln, .layer.is-off .ln { opacity: .45; }
.layer.is-locked .ln b::after { content: " · locked"; font-weight: 400; color: var(--text-lo); }
.layer.drop-above { border-top-color: var(--accent-soft); }
.layer.drop-below { border-bottom-color: var(--accent-soft); }
.layer.dragging { opacity: .4; }
.lempty { margin: 4px var(--s-6) 4px; font-size: 11px; }
.lhead.off { cursor: default; }
.lhead.off:hover { background: transparent; }

/* inspector breathing room: stacked labels for tall controls, space between rows */
.inspector .sect { padding: 20px 20px 24px; }
.inspector .sect-head { margin-bottom: 12px; }
.inspector .row.top { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.inspector .row.top > .lbl { padding-top: 0; }
.inspector .sect .row + .row { margin-top: 8px; }
.inspector .sect .row.top + .row, .inspector .sect .row + .row.top { margin-top: 16px; }
.inspector .layouts { gap: 8px; }
.inspector .layouts .lay { padding: 10px 4px 8px; gap: 6px; }
.inspector .sect p.hint { margin-bottom: 16px; }
.device-row { gap: 12px; }
.device-row .layouts { gap: 8px; }

/* Simple: grab handle on the top edge of the play bar resizes the bottom panel */
.playbar { position: relative; }
.deck-grip { position: absolute; left: 50%; top: -6px; width: 120px; height: 12px; transform: translateX(-50%); cursor: ns-resize; z-index: 5; display: grid; place-items: center; touch-action: none; }
.deck-grip::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); opacity: .7; transition: background var(--dur-quick), width var(--dur-quick), opacity var(--dur-quick); }
.deck-grip:hover::before, .deck-grip.on::before, .deck-grip:focus-visible::before { width: 64px; opacity: 1; background: var(--accent-soft); }
.choices.stack { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
.choices.stack button { height: auto; min-height: 30px; padding: 6px 10px; text-align: left; white-space: normal; line-height: 16px; }
.inspector .row:has(> .choices.stack) { grid-template-columns: minmax(0, 1fr); gap: 8px; }

/* Ambient exit: only in ambient, hidden with the cursor when idle */
.amb-exit { display: none; }
html.ambient .amb-exit { display: block; position: fixed; top: 20px; right: 20px; z-index: 60; height: 32px; padding: 0 14px; border-radius: var(--r-1); border: 1px solid oklch(1 0 0 / .25); background: oklch(0 0 0 / .55); color: #e8eef0; font: var(--type-label); cursor: pointer; transition: opacity .3s; }
html.ambient .amb-exit:hover { background: oklch(0 0 0 / .8); border-color: oklch(1 0 0 / .5); }
html.ambient.idle .amb-exit { opacity: 0; pointer-events: none; }

/* ==========================================================================
   Design pass (round 11): one rhythm, room to breathe, quiet controls.
   8px steps; labels sit on the first line of their control (sliders are
   centred); every pressable thing answers a press; motion is short ease-out
   on transform, opacity and colour only.
   ========================================================================== */

/* brand: a CRT screen with an orbit round it; wordmark in the wide face */
.brand { gap: 10px; }
.brand-mark { width: 28px; height: 28px; flex: none; overflow: visible; }
.brand-mark .orbit { fill: none; stroke: var(--text-mid); stroke-width: 1.4; stroke-linecap: round; }
.brand-mark .glass { fill: var(--bg-panel); stroke: var(--text-hi); stroke-width: 1.6; }
.brand-mark .scan { fill: none; stroke: var(--text-hi); stroke-width: 1.4; stroke-linecap: round; opacity: .55; }
.brand-mark .sat { fill: var(--accent); }
.brand-name { display: flex; align-items: baseline; gap: 7px; font: 400 12px/1 "Michroma", var(--font-sans); letter-spacing: .14em; text-transform: uppercase; }
.brand-name span { color: var(--text-lo); }
.topbar { gap: 12px; padding: 0 20px; }
.topbar .seg { height: 32px; }
.topbar .vsep { margin: 0 4px; }

/* press feedback and motion */
.btn, .export, .tbtn, .play, .seg button, .choices button, .lay, .dcard, .dchip, .recipe, .tile, .chip, .lib-tabs button {
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 160ms var(--ease-out);
}
.btn:active:not(:disabled), .export:active:not(:disabled), .tbtn:active:not(:disabled), .play:active, .lay:active, .dchip:active, .tile:active, .chip:active, .choices button:active { transform: scale(0.97); }
@media (prefers-reduced-motion: reduce) { .btn:active, .export:active, .tbtn:active, .play:active, .lay:active, .dchip:active, .tile:active, .chip:active, .choices button:active { transform: none; } }

/* rows: label beside its control, both from the top */
.row { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; min-height: 0; }
.row > .lbl { padding-top: 7px; line-height: 16px; }
.row:has(> .slider), .row:has(> .toggle) { align-items: center; }
.row:has(> .slider) > .lbl, .row:has(> .toggle) > .lbl { padding-top: 0; }
.row > .lbl[data-tip] { text-decoration: none; }
.row > .lbl[data-tip]:hover { color: var(--text-hi); }

/* segmented controls and choice grids share one look */
.seg { height: 30px; border-radius: var(--r-2); border-color: var(--line); padding: 2px; gap: 2px; background: var(--bg-app); }
.seg button { border-radius: 3px; padding: 0 12px; }
.seg button + button { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--bg-active); color: var(--text-hi); box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg button[aria-pressed="true"]::after { left: 10px; right: 10px; bottom: 2px; height: 2px; border-radius: 1px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.choices button { height: 30px; border-radius: var(--r-2); font-size: 12px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.choices.stack { display: grid; grid-template-columns: minmax(0, 1fr); }

/* the right panel */
.inspector .insp-title { padding: 0 24px; }
.inspector .sect { padding: 24px 24px 28px; }
.inspector .sect-head { height: 20px; margin-bottom: 16px; }
.inspector .sect .row + .row { margin-top: 12px; }
.inspector .sect .row.top + .row, .inspector .sect .row + .row.top { margin-top: 20px; }
.inspector .sect p, .inspector .sect p.hint { line-height: 1.55; margin-bottom: 16px; }
.inspector .sect p.hint:last-child, .inspector .sect p:last-child { margin-bottom: 0; }
.inspector .layouts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.inspector .layouts .lay { padding: 12px 4px 10px; gap: 8px; }
.inspector .fields { gap: 16px; }
.field { height: 30px; border-radius: var(--r-2); }

/* the library: a clear switch for Templates, Gallery and Layers */
.lib-tabs { height: auto; padding: 16px; border-bottom: var(--hair) solid var(--line); gap: 4px; }
.lib-tabs > button { height: 36px; border-radius: var(--r-2); font: 500 13px/1 var(--font-sans); color: var(--text-mid); }
.lib-tabs > button[aria-selected="true"] { background: var(--bg-active); color: var(--text-hi); box-shadow: inset 0 0 0 1px var(--line-strong); }
.lib-tabs > button[aria-selected="true"]::after { left: 16px; right: 16px; bottom: 5px; border-radius: 1px; }
.lib-tabs > button:hover:not([aria-selected="true"]) { background: var(--bg-raised); color: var(--text-hi); }
.group { padding: 12px 0; }
.group-head { padding: 4px 20px 8px; }
.tiles { gap: 8px; padding: 0 16px 8px; }
.tile { padding: 6px 6px 8px; gap: 8px; font-size: 12px; }
#libTemplates { padding: 16px 12px; }
#libTemplates .tgroup { margin-bottom: 20px; }
#libTemplates .tgroup-head { padding: 0 8px 6px; }
#libTemplates .recipe { padding: 8px; gap: 12px; }
.newlayout .hint { margin: 0 20px 12px; line-height: 1.5; }
.library .layouts { gap: 8px; padding: 0 16px 8px; }
#layers { padding: 12px 0; }

/* the dialect dock along the bottom of the app (advanced) */
.dock { grid-area: dock; display: flex; align-items: center; gap: 16px; padding: 0 20px; min-width: 0; }
.dock-lbl { font: var(--type-legend); font-variation-settings: "wdth" 118; letter-spacing: var(--type-legend-track); text-transform: uppercase; color: var(--text-lo); }
.dbar { display: flex; gap: 8px; }
.dchip { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px 0 5px; border-radius: var(--r-2); background: transparent; border: var(--hair) solid var(--line); color: var(--text-mid); font: 500 13px/1 var(--font-sans); }
.dchip canvas { width: 59px; height: 33px; border-radius: 3px; background: #000; display: block; }
.dchip .nm { display: flex; align-items: baseline; gap: 8px; }
.dchip .nm .num { color: var(--text-lo); }
.dchip:hover { color: var(--text-hi); border-color: var(--line-strong); background: var(--bg-raised); }
.dchip[aria-pressed="true"] { color: var(--text-hi); border-color: var(--accent-line); background: var(--accent-wash); }
.dock-note { margin-left: auto; font: var(--type-label); color: var(--text-lo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* simple view: the deck gets room; step 3 lays its tiles 4 to a row */
.step { padding: 20px 32px 16px; gap: 16px; }
.deck .dcards { grid-template-columns: repeat(2, minmax(0, 168px)); gap: 16px; }
.deck .device-row .layouts { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.style { gap: 16px; padding-right: 4px; }
.tgroup-list { gap: 4px 12px; }
.recipe { padding: 6px; }
.fields { gap: 16px; }

/* dialogs */
dialog.help { padding: 28px; border-radius: 12px; box-shadow: 0 24px 64px rgba(0,0,0,.45); }
dialog.help[open] { animation: dlg-in 220ms var(--ease-out); }
@keyframes dlg-in { from { opacity: 0; transform: scale(0.97); } }
@media (prefers-reduced-motion: reduce) { dialog.help[open] { animation: none; } }
.saver-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0 8px; }
.saver-card { display: grid; gap: 12px; align-content: start; padding: 20px; border: var(--hair) solid var(--line); border-radius: 10px; background: var(--bg-app); }
.saver-card h3 { margin: 0; font: 600 14px/1.3 var(--font-sans); }
.saver-card ol { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--text-mid); font-size: 13px; line-height: 1.5; }
.saver-card .btn { justify-self: start; }
@media (max-width: 700px) { .saver-grid { grid-template-columns: 1fr; } }

/* step 3: dialect cards in their own column, layouts beside them */
.deck .style { grid-template-columns: 156px minmax(0, 1fr); column-gap: 32px; row-gap: 16px; align-items: start; }
.deck .style .dcards { grid-row: 1 / span 2; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.deck .style .device-row, .deck .style .export-line { grid-column: 2; }
.deck .device-row .row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.deck .device-row .row > .lbl { padding-top: 0; color: var(--text-lo); }
.help a:not(.btn) { color: var(--text-hi); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.help a:not(.btn):hover { text-decoration-color: var(--text-hi); }
.toplink { white-space: nowrap; }
.deck .style { overflow-x: hidden; }
@media (max-width: 1400px) { .deck .style { grid-template-columns: 116px minmax(0, 1fr); column-gap: 20px; } }
@media (max-width: 1240px) { .toplink { display: none; } }

/* ==========================================================================
   Aesthetic pass (round 12). Surfaces and spacing do the grouping; lines
   only where two surfaces meet. Nothing gets an outline just to exist.
   Selection is a quiet fill, never a ring. Radii: 6 controls, 10 cards.
   ========================================================================== */
:root { --rc: 6px; --rk: 10px; }

/* top bar: brand, project, view, mode, one Export */
.topbar { gap: 16px; padding: 0 16px 0 20px; }
.topbar .vsep { display: none; }
.project .num { font-size: 11px; }
.toplink { color: var(--text-lo); font-size: 12px; }
.seg.icons button { width: 32px; padding: 0; display: grid; place-items: center; }
.seg.icons .icon { width: 15px; height: 15px; }
.export { border-radius: var(--rc); }
.topbar .export { height: 34px; padding: 0 12px 0 16px; gap: 8px; }
.export .chev { width: 14px; height: 14px; margin-left: 2px; opacity: .8; }
.ctxmenu.export-menu { min-width: 260px; padding: 6px; border-radius: var(--rk); border-color: var(--line); }
.ctxmenu .mi { height: 32px; border-radius: var(--rc); }

/* segmented controls: a sunken track with a raised thumb, no rules */
.seg { border: 0; background: var(--bg-app); padding: 3px; gap: 2px; border-radius: 8px; height: 34px; }
.topbar .seg { height: 34px; }
.seg button { border-radius: 5px; color: var(--text-lo); }
.seg button:hover { color: var(--text-hi); }
.seg button[aria-pressed="true"] { background: var(--bg-active); color: var(--text-hi); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.seg button[aria-pressed="true"]::after { content: none; }
.lib-tabs { padding: 16px; border-bottom: 0; }
.lib-tabs { background: transparent; }
.lib-tabs > button { height: 34px; border-radius: 5px; color: var(--text-lo); }
.lib-tabs { gap: 2px; }
.lib-tabs > button[aria-selected="true"] { background: var(--bg-active); color: var(--text-hi); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.lib-tabs > button[aria-selected="true"]::after { content: none; }
.library .lib-tabs { margin: 0; }
.lib-tabs { position: relative; }
.lib-tabs::after { content: ""; position: absolute; inset: 16px; border-radius: 8px; background: var(--bg-app); z-index: -1; }
.library { isolation: isolate; }

/* buttons: filled, no outline */
.btn { border: 0; background: var(--bg-raised); border-radius: var(--rc); color: var(--text-hi); }
.btn:hover { background: var(--bg-active); }
.btn.primary { background: var(--accent-wash); color: var(--accent-text); border: 0; }
.btn.primary:hover { background: oklch(from var(--accent-soft) l c h / 0.22); }
.mon-bar .btn.sm { border: 0; background: oklch(1 0 0 / .07); border-radius: var(--rc); }
.choices button { border: 0; background: var(--bg-raised); color: var(--text-mid); border-radius: var(--rc); }
.choices button:hover { background: var(--bg-active); color: var(--text-hi); }
.choices button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-text); border: 0; }

/* inputs: a soft fill; the focus ring is the only edge */
.input, .field, textarea.area { border: 0; background: var(--bg-raised); border-radius: var(--rc); box-shadow: none; }
.input:hover, .field:hover { background: var(--bg-active); }
.input:focus-within, .field:focus-within, textarea.area:focus { box-shadow: 0 0 0 2px var(--accent-line); }
.input { height: 40px; }
.drop { border: 0; background: var(--bg-raised); border-radius: var(--rk); }
.drop:hover, .drop.over { box-shadow: 0 0 0 2px var(--accent-line); }
.chip { border: 0; background: var(--bg-raised); border-radius: var(--rc); }
.chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent-soft); }

/* thumbnails: rounded, no outline */
.recipe canvas, .tile canvas, .dcard canvas, .dchip canvas { outline: 0 !important; border-radius: var(--rc); }
.recipe { border-radius: 8px; padding: 6px; gap: 14px; }
.recipe canvas { width: 80px; height: 45px; }
.recipe .rt { flex: 1; min-width: 0; }
.recipe .rn { font-weight: 500; color: var(--text-hi); }
.recipe .ru { color: var(--text-lo); }
.recipe:hover { background: var(--bg-raised); }
.recipe[aria-pressed="true"] { background: var(--bg-raised); }
.recipe[aria-pressed="true"] .rn { color: var(--accent-text); font-weight: 600; }
.recipe[aria-pressed="true"] canvas { outline: 0; box-shadow: 0 0 0 2px var(--accent-soft); }
.tgroup-head { font: var(--type-legend); font-variation-settings: "wdth" 118; letter-spacing: var(--type-legend-track); color: var(--text-lo); padding: 0 6px 4px; }
.tile { border: 0; border-radius: 8px; }
.tile:hover { background: var(--bg-raised); }

/* layout tiles: a picture and a name, a fill when chosen */
.lay { border: 0; background: transparent; border-radius: 8px; padding: 10px 4px 8px; gap: 8px; color: var(--text-lo); }
.lay:hover { background: var(--bg-raised); color: var(--text-hi); }
.lay[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-text); border: 0; }
.lay-pic { outline: 0; background: transparent; width: 52px; height: 29px; }
.lay-pic i { background: var(--line-strong); border-radius: 3px; }
.lay:hover .lay-pic i { background: var(--text-lo); }
.lay[aria-pressed="true"] .lay-pic i { background: var(--accent-soft); }

/* ---- simple view: three calm steps ---- */
.deck { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 0; }
.step { padding: 24px 28px 16px; gap: 16px; grid-template-rows: auto minmax(0, 1fr); }
.step + .step { border-left: 0; box-shadow: inset 1px 0 0 var(--line); }
.step-head { gap: 10px; }
.step-no { width: auto; height: auto; border: 0; border-radius: 0; font: 500 11px/1 var(--font-mono); color: var(--text-lo); letter-spacing: .04em; }
.step-head h2 { font: 600 14px/20px var(--font-sans); }
.step-head .hint { font-size: 12px; }
.recipes { gap: 20px; padding-right: 12px; }
.tgroup-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 12px; }
.fld { gap: 6px; }
.fld label { color: var(--text-lo); font-size: 12px; }

/* step 3: dialect cards beside the layouts */
.deck .style { grid-template-columns: 148px minmax(0, 1fr); column-gap: 28px; row-gap: 20px; }
.deck .style .dcards { gap: 8px; }
.dcard { gap: 8px; padding: 6px 6px 10px; border-radius: var(--rk); }
.dcard canvas { transition: opacity 150ms ease; }
.dcard:hover { background: var(--bg-raised); }
.dcard:hover canvas { outline: 0; }
.dcard[aria-pressed="true"] { background: var(--bg-raised); }
.dcard[aria-pressed="true"] canvas { outline: 0; box-shadow: none; }
.dcard .nm { padding: 0 2px; gap: 6px; color: var(--text-lo); font-size: 13px; }
.dcard .nm .num { font-size: 10px; color: var(--text-lo); }
.dcard[aria-pressed="true"] .nm { color: var(--text-hi); font-weight: 600; }
.dcard[aria-pressed="true"] .nm::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-soft); align-self: center; }
.deck .device-row .layouts { gap: 4px; }
.deck .device-row .row > .lbl { font: var(--type-legend); font-variation-settings: "wdth" 118; letter-spacing: var(--type-legend-track); text-transform: uppercase; color: var(--text-lo); }
.export-line { padding-top: 4px; }
.export-meta { font-size: 10px; }

/* ---- right panel ---- */
.insp-title { border-bottom: 0; }
.inspector .sect { border-bottom: 0; padding: 20px 24px 24px; }
.inspector .sect + .sect { box-shadow: inset 0 1px 0 var(--line); }
.sect-head .legend, .sect-head h3 { color: var(--text-lo); }

/* ---- library ---- */
.group + .group { border-top: 0; }
.panel-head { border-bottom: 0; }
.lgroup + .lgroup { border-top: 0; }

/* ---- monitor and play bar ---- */
.mon-bar { gap: 12px; }
.play { border: 0; background: var(--bg-raised); border-radius: 50%; width: 40px; height: 40px; }
.play:hover { background: var(--bg-active); }
.toolbar { border: 0; border-radius: 10px; background: oklch(0.22 0 0 / .94); box-shadow: 0 8px 28px rgba(0,0,0,.35); }

/* ---- dialect dock ---- */
.dchip { border: 0; background: transparent; border-radius: var(--rk); padding: 0 14px 0 6px; height: 46px; color: var(--text-lo); }
.dchip:hover { background: var(--bg-raised); color: var(--text-hi); }
.dchip[aria-pressed="true"] { background: var(--bg-raised); color: var(--text-hi); }
.dchip[aria-pressed="true"] .nm::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-soft); align-self: center; }

/* dialogs */
dialog.help { border: 0; background: var(--bg-panel); }
.saver-card { border: 0; background: var(--bg-raised); }
.linkrow input { border: 0; background: var(--bg-raised); border-radius: var(--rc); }
.tip { border-radius: var(--rc); }
.toast { border: 0; border-radius: var(--rk); box-shadow: 0 12px 32px rgba(0,0,0,.35); }
.row-note { margin: 0 !important; padding-top: 7px; line-height: 1.5; }

/* ---- Round 13: the artboard toolbar follows the UI; one focus ring ---- */
.toolbar { background: var(--bg-raised); color: var(--text-mid); box-shadow: 0 10px 30px rgba(0,0,0,.3); padding: 0 4px; height: 42px; }
.toolbar .tbtn { color: var(--text-mid); border-radius: var(--rc); }
.toolbar .tbtn:hover:not(:disabled) { background: var(--bg-active); color: var(--text-hi); }
.toolbar .tbtn.tog[aria-pressed="true"] { background: var(--bg-active); color: var(--accent-text); box-shadow: none; }
.toolbar .tsep { background: var(--line-strong); height: 18px; margin: 0 4px; }
.toolbar .num { color: var(--text-lo); }
.gsize button { color: var(--text-lo); border-radius: 5px; }
.gsize button:hover { background: var(--bg-active); color: var(--text-hi); }
.gsize button[aria-pressed="true"] { background: var(--bg-active); color: var(--text-hi); }
.empty-hint { border: 0; background: var(--bg-raised); color: var(--text-mid); border-radius: var(--rc); }
.empty-hint b { color: var(--text-hi); }
.mon-foot .tbtn.on, .tbtn.on { color: var(--accent-text); }

/* focus: the field shows one ring; the text box inside it shows none */
.input input:focus-visible, .input textarea:focus-visible, .field input:focus-visible, .field select:focus-visible, textarea.area:focus-visible, .slider .val:focus-visible { outline: none; }
.input:focus-within, .field:focus-within, textarea.area:focus { box-shadow: 0 0 0 1.5px var(--accent-soft); background: var(--bg-raised); }
.input, .field, .drop { transition: background-color 150ms ease, box-shadow 150ms ease; }
.drop:hover { box-shadow: none; background: var(--bg-active); color: var(--text-hi); }
.drop.over { box-shadow: 0 0 0 1.5px var(--accent-soft); }
.drop:focus-visible { outline: none; box-shadow: 0 0 0 1.5px var(--accent-soft); }
button:focus-visible { outline-offset: 1px; }

/* live: a soft phosphor lamp, the one retro cue in the chrome */
.led.on { background: var(--lamp); box-shadow: 0 0 6px var(--lamp); }

/* ==========================================================================
   Help panel (round 14): slides in from the right over a soft scrim.
   ========================================================================== */
.helpbtn { height: 34px; padding: 0 14px 0 10px; display: inline-flex; align-items: center; gap: 7px; font: 500 13px/1 var(--font-sans); border: 0; border-radius: var(--rc, 6px); background: var(--bg-raised); color: var(--text-hi); cursor: pointer; transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 120ms var(--ease-out); }
.helpbtn:hover, .helpbtn[aria-expanded="true"] { background: var(--bg-active); }
.helpbtn svg { color: var(--accent-text); }
.helpbtn:active { transform: scale(0.97); }
.helpbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.helpbtn svg .dot { fill: currentColor; stroke: none; }

.hp { position: fixed; inset: 0; z-index: 900; }
.hp-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.42); opacity: 0; transition: opacity 280ms var(--ease-out); }
.hp-panel { position: absolute; top: 8px; right: 8px; bottom: 8px; width: min(420px, calc(100vw - 16px)); display: flex; flex-direction: column; background: var(--bg-panel); color: var(--text-hi); border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,.4), 0 0 0 1px var(--line); transform: translateX(calc(100% + 16px)); transition: transform 320ms var(--ease-out); outline: 0; font: 400 13px/1.55 var(--font-sans); }
.hp.in .hp-scrim { opacity: 1; }
.hp.in .hp-panel { transform: none; }
.hp-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px 24px; }
.hp-head h2 { margin: 0; font: 600 15px/20px var(--font-sans); }
.hp-x { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-lo); cursor: pointer; transition: background-color 150ms, color 150ms; }
.hp-x:hover { background: var(--bg-raised); color: var(--text-hi); }
.hp-x svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.hp-body { flex: 1; overflow-y: auto; padding: 6px 24px 28px; display: grid; gap: 28px; align-content: start; scrollbar-width: thin; }
.hp-body section > * + * { margin-top: 10px; }
.hp-kicker { font: var(--type-legend); font-variation-settings: "wdth" 118; letter-spacing: var(--type-legend-track); text-transform: uppercase; color: var(--text-lo); display: flex; gap: 8px; align-items: baseline; }
.hp-note { text-transform: none; letter-spacing: 0; font: 400 11px/1 var(--font-sans); opacity: .8; }
.hp-now { background: var(--bg-raised); border-radius: 12px; padding: 18px 18px 16px; }
.hp-now h3 { margin: 6px 0 0; font: 600 18px/24px var(--font-sans); }
.hp-now p { margin: 4px 0 0; color: var(--text-mid); }
.hp-meta { display: flex; gap: 6px; }
.hp-meta span { font: 500 11px/1 var(--font-mono); padding: 5px 8px; border-radius: 6px; background: var(--bg-app); color: var(--text-mid); }
.hp-meta span:first-child { color: var(--accent-text); }
.hp-now .hp-kicker { margin-top: 18px; }
.hp-ideas { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.hp-ideas li { position: relative; padding-left: 16px; color: var(--text-mid); }
.hp-ideas li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-soft); }
.hp-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.hp-steps li { counter-increment: s; display: grid; grid-template-columns: 24px 1fr; column-gap: 10px; }
.hp-steps li::before { content: counter(s, decimal-leading-zero); grid-row: span 2; font: 500 11px/20px var(--font-mono); color: var(--text-lo); }
.hp-steps b { font-weight: 600; } .hp-steps span { color: var(--text-mid); }
.hp-tour { margin-top: 16px !important; height: 34px; padding: 0 14px; border: 0; border-radius: var(--rc, 6px); background: var(--accent-wash); color: var(--accent-text); font: 500 13px/1 var(--font-sans); cursor: pointer; transition: background-color 150ms, transform 120ms var(--ease-out); }
.hp-tour:hover { background: oklch(from var(--accent-soft) l c h / 0.22); }
.hp-tour:active, .hp-q > button:active { transform: scale(0.97); }
.hp-faq { display: grid; gap: 2px; }
.hp-q { border-radius: 10px; transition: background-color 200ms var(--ease-out); }
.hp-q.open { background: var(--bg-raised); }
.hp-q > button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text-hi); font: 500 13px/18px var(--font-sans); text-align: left; cursor: pointer; transition: background-color 150ms, transform 120ms var(--ease-out); }
.hp-q:not(.open) > button:hover { background: var(--bg-raised); }
.hp-q > button svg { flex: none; width: 14px; height: 14px; fill: none; stroke: var(--text-lo); stroke-width: 1.5; stroke-linecap: round; transition: transform 260ms var(--ease-out); }
.hp-q.open > button svg { transform: rotate(180deg); }
.hp-a { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 260ms var(--ease-out); }
.hp-q.open .hp-a { grid-template-rows: 1fr; }
.hp-a > div { overflow: hidden; }
.hp-a p { margin: 0; padding: 0 12px 14px; color: var(--text-mid); opacity: 0; transition: opacity 200ms var(--ease-out); }
.hp-q.open .hp-a p { opacity: 1; transition-delay: 60ms; }
.hp-keys { margin: 10px 0 0; display: grid; gap: 2px; }
.hp-keys div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; }
.hp-keys dt { color: var(--text-lo); } .hp-keys dd { margin: 0; color: var(--text-mid); text-align: right; }
.hp-keys kbd { display: inline-block; min-width: 22px; padding: 3px 6px; margin-right: 3px; border-radius: 5px; background: var(--bg-raised); color: var(--text-hi); font: 500 11px/1 var(--font-mono); text-align: center; box-shadow: inset 0 -1px 0 var(--line); }
@media (prefers-reduced-motion: reduce) { .hp-panel, .hp-scrim, .hp-a, .hp-a p, .hp-q > button svg { transition: none !important; } }


/* ==========================================================================
   Type system (round 15). One family at its normal width for all words;
   mono only for numbers. Three sizes (15 title, 13 body, 12 small), two
   weights (400, 600). Section headings are small, semibold, sentence case:
   no capitals, no tracking, no wide cut. Hierarchy comes from colour.
   ========================================================================== */
:root {
  --type-legend: 600 12px/16px var(--font-sans);
  --type-legend-track: 0;
  --type-label: 400 12px/16px var(--font-sans);
  --type-body: 400 13px/20px var(--font-sans);
  --type-title: 600 15px/20px var(--font-sans);
}
.legend, .ctxmenu .mh, .dock-lbl, .tgroup-head, .deck .device-row .row > .lbl, .hp-kicker {
  font: var(--type-legend); font-variation-settings: normal; letter-spacing: 0; text-transform: none; color: var(--text-mid);
}
.tgroup-head { padding: 0 6px 6px; }
/* words that were set in mono read as words again */
#saveState, #monName, #monDialect, #monState, #inspId, .dchip .nm .num, .dcard .nm .num, .drop .empty .num, .export-meta {
  font: 400 12px/16px var(--font-sans); font-variation-settings: normal; letter-spacing: 0; color: var(--text-lo);
}
#monName, #monDialect, #monState { color: var(--mon-text); }
.step-no { font: 400 12px/1 var(--font-sans); letter-spacing: 0; }
.step-head h2, .insp-title, .insp-title h2, .panel-head h2 { font: var(--type-title); }
.recipe .rn, .dcard .nm, .dchip .nm { font-size: 13px; }
.recipe .ru { font-size: 12px; line-height: 16px; }

/* help panel: same three sizes, nothing extra */
.hp-panel { font: var(--type-body); }
.hp-head h2, .hp-now h3 { font: var(--type-title); }
.hp-now h3 { margin-top: 4px; }
.hp-now p, .hp-steps span, .hp-ideas li, .hp-a p, .hp-keys dd { font-size: 13px; }
.hp-meta { display: none; }
.hp-steps li::before { font: 400 13px/20px var(--font-sans); content: counter(s); }
.hp-steps b, .hp-q > button { font-weight: 600; font-size: 13px; }
.hp-q > button { font-weight: 400; color: var(--text-hi); }
.hp-ideas { margin-top: 14px !important; }
.hp-tour { font: 600 13px/1 var(--font-sans); }
.hp-keys kbd { font: 400 12px/1 var(--font-sans); }
.hp-keys dt { font-size: 12px; }
/* the dialect's name is enough; its tag only adds a second style */
.dchip .nm .num, .dcard .nm .num { display: none; }

/* image drops are fields like the rest: label on the same line as the other
   labels, the box spanning from the first input's top to the last one's bottom */
.content { align-items: stretch; }
.content .drops { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); gap: 16px; }
.img-fld { grid-template-rows: auto minmax(0, 1fr); }
.img-fld .drop { width: 100%; height: auto; min-height: 96px; }
.inspector .img-fld .drop { height: 120px; }
.drop .empty { gap: 6px; font: 400 12px/16px var(--font-sans); color: var(--text-lo); }
.drop .empty .icon { width: 20px; height: 20px; }
/* hover fills bleed outward so the content inside lines up with the step's edge */
.deck .recipes .tgroup-list { margin-inline: -6px; }
.deck .tgroup-head { padding-inline: 0; }

/* ==========================================================================
   One gutter (round 15): 24px from every outer edge, in every panel. Hover
   fills bleed outward so content, not its padding, sits on the gutter.
   ========================================================================== */
.topbar { padding: 0 24px; }
.dock { padding: 0 24px; }
.lib-tabs { padding: 16px 24px; }
.lib-tabs::after { inset: 16px 24px; }
#libTemplates { padding: 16px 14px 16px 24px; } /* + the 10px scrollbar = 24 */
#libTemplates .tgroup-list { margin-inline: -8px; }
#libTemplates .tgroup-head { padding: 0 0 6px; }
/* the right panel's title band matches the artboard's bar beside it */
.insp-title { height: 36px; min-height: 36px; }
#library .group-head { padding: 4px 24px 8px; }
#library .group > .hint { padding-inline: 24px; margin-inline: 0; }
#library .layouts { padding: 0 14px 8px 24px; }
#library .tiles { padding: 0 8px 8px 18px; } /* tile padding 6: thumbnails start on the gutter */
.lhead { padding: 0 24px; }
.layer { padding: 0 20px 0 36px; } /* names indent one step under their pane; icons end on the gutter */
.layer .ln span { font-size: 12px; }
/* library switch = the same segmented control as Simple/Advanced: a 34px
   sunken track, 3px inset, 28px buttons, the same type */
.lib-tabs { padding: 19px 27px; gap: 2px; }
.lib-tabs::after { inset: 16px 24px; border-radius: 8px; }
.lib-tabs > button { height: 28px; border-radius: 5px; font: var(--type-label); }

/* Three dialects (round 16): in Simple's step 3 the cards sit in a row of
   three above the device controls, so none falls below the fold. */
.deck .style { grid-template-columns: minmax(0, 1fr); row-gap: 16px; }
.deck .style .dcards { grid-row: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.deck .style .device-row, .deck .style .export-line { grid-column: 1; }
/* the layout tiles and the color option (phosphor, scheme) side by side */
.deck .style .device-row { grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; align-items: start; }
/* six or seven layouts wrap to two rows: smaller cards and tighter tiles */
.deck .style { row-gap: 12px; }
.deck .style .dcards { grid-template-columns: repeat(3, minmax(0, 148px)); }
.deck .style .device-row .lay { padding: 6px 4px 4px; gap: 4px; }
.deck .style { row-gap: 8px; }
.deck .style .dcards { grid-template-columns: repeat(3, minmax(0, 132px)); }
.deck .style .device-row .lay-pic { width: 44px; height: 25px; }

/* the list scrolls, so its hover fills need room inside the scroll box
   (overflow clips at the padding edge): pad it out by the bleed plus the
   focus ring, and pull it back by the same amount */
.deck .recipes { margin-left: -9px; padding-left: 9px; margin-right: -9px; padding-right: 21px; }
.field select { cursor: pointer; }
.field select option, .field select optgroup { background: var(--bg-raised); color: var(--text-hi); }

/* dropdown: a field that opens a menu in the context menu's style */
.field.dd { width: 100%; justify-content: space-between; cursor: pointer; text-align: left; font: var(--type-label); color: var(--text-hi); }
.field.dd:hover { border-color: var(--line-strong); }
.field.dd:focus-visible { outline: var(--hair) solid var(--accent-soft); outline-offset: 1px; }
.field.dd .dd-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field.dd .icon { width: 12px; height: 12px; flex: none; color: var(--text-lo); transform: rotate(90deg); transition: transform .12s; }
.field.dd[aria-expanded="true"] { border-color: var(--line-strong); }
.field.dd[aria-expanded="true"] .icon { transform: rotate(-90deg); }
.ctxmenu.dd-menu { overflow-y: auto; overscroll-behavior: contain; }
.ctxmenu.dd-menu .mh:not(:first-child) { margin-top: 4px; border-top: var(--hair) solid var(--line); padding-top: 10px; }
.ctxmenu.dd-menu .mi[aria-selected="true"] { color: var(--accent-text); }
.dd-tick { width: 8px; height: 4px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg) translateY(-1px); flex: none; }
@media (prefers-reduced-motion: reduce) { .field.dd .icon { transition: none; } }

/* ==========================================================================
   Phones (under 760 px; html.phone is set in app.js). Simple view as an app:
   a slim bar, the live screen pinned under it, then the three steps as tabs
   whose panel scrolls. The artboard is view-only (no accidental drags while
   scrolling); words are edited in the Words tab.
   ========================================================================== */
html.phone, html.phone body { height: 100%; overflow: hidden; }
html.phone[data-view] .studio { display: flex; flex-direction: column; height: 100svh; min-height: 0; gap: 0; background: var(--bg-panel); }
html.phone .studio > * { flex: none; }
html.phone .library, html.phone .inspector, html.phone .dock, html.phone .playbar,
html.phone #modeSeg, html.phone #viewSeg, html.phone .topbar .vsep, html.phone .ws-foot,
html.phone .deck-grip, html.phone .step-head, html.phone .mon-bar .legend, html.phone .mon-bar .num { display: none !important; }

/* top bar: brand, help, export */
html.phone .topbar { flex-wrap: nowrap; height: 56px; min-height: 0; padding: 0 16px; gap: 8px; }
html.phone .helpbtn { width: 44px; height: 44px; padding: 0; justify-content: center; }
html.phone .helpbtn span { display: none; }
html.phone .export { height: 40px; }

/* the screen, full width, with its name and a full-screen button */
html.phone .monitor { display: block; background: var(--bg-well); }
html.phone .mon-bar { height: 44px; padding: 0 8px 0 16px; gap: 8px; }
html.phone .mon-bar #monName { display: block !important; flex: 1; min-width: 0; color: var(--mon-text); font: 600 13px/1 var(--font-sans); }
html.phone .mon-bar .led { display: none; }
html.phone #ambientBtn { height: 32px; padding: 0 12px; }
html.phone .mon-body { container-type: normal; display: block; padding: 0 0 12px; }
html.phone .frame-wrap { width: 100%; }
html.phone .overlay { pointer-events: none; }
html.phone .selection, html.phone .screen-sel, html.phone #selMulti { display: none !important; }

/* tabs + the scrolling panel */
html.phone .deck { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }
html.phone .ph-tabs { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 12px 16px; background: var(--bg-panel); }
html.phone .ph-tabs button { height: 40px; border: 0; border-radius: 8px; background: var(--bg-app); color: var(--text-mid); font: 600 13px/1 var(--font-sans); }
html.phone .ph-tabs button[aria-selected="true"] { background: var(--bg-raised); color: var(--text-hi); box-shadow: inset 0 -2px 0 var(--accent); }
html.phone .deck > .step { display: none; padding: 4px 16px 16px; border: 0; box-shadow: none; min-height: 0; }
html.phone .deck > .step.ph-on { display: block; }
html.phone .ph-desk { margin: 8px 16px 0; padding: 12px 0 0; border-top: var(--hair) solid var(--line); color: var(--text-lo); font: var(--type-label); font-size: 12px; }
html:not(.phone) .ph-tabs, html:not(.phone) .ph-desk { display: none; }

/* Screen: the template list, one per row, thumbnails a little bigger */
html.phone .deck .recipes { overflow: visible; margin: 0; padding: 0; display: grid; gap: 16px; }
html.phone .tgroup-list { grid-template-columns: minmax(0, 1fr); gap: 2px; }
html.phone .recipe { padding: 6px; min-height: 56px; }
html.phone .recipe canvas { width: 88px; height: 49.5px; }

/* Words: one column, comfortable fields */
html.phone .content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; overflow: visible; padding: 0; }
html.phone .content .drops { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; }
html.phone .fields { grid-template-columns: minmax(0, 1fr); }
html.phone .field input, html.phone .field textarea { font-size: 16px; } /* 16 px: iOS doesn't zoom on focus */

/* Look: dialect cards in a row, then the device controls stacked */
html.phone .deck .style { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 20px; }
html.phone .deck .style .dcards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
html.phone .deck .style .device-row { grid-template-columns: minmax(0, 1fr); row-gap: 16px; }
html.phone .deck .device-row .layouts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
html.phone .deck .style .device-row .lay { min-height: 56px; }
html.phone .export-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* menus and dialogs fit the phone */
html.phone .ctxmenu { max-width: calc(100vw - 16px); }
html.phone dialog.help { width: calc(100vw - 24px); max-width: none; max-height: calc(100svh - 24px); overflow-y: auto; }
html.phone .linkrow { flex-wrap: wrap; }
html.phone .linkrow input { flex: 1 1 100%; }

/* full screen from the phone: the monitor covers the page; a tap returns */
html.phone.ambient .mon-body { padding: 0; height: 100%; display: flex; align-items: center; }

/* a phone on its side: the screen on the left, the tabs on the right */
@media (orientation: landscape) {
  html.phone[data-view] .studio { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); grid-template-rows: 48px minmax(0, 1fr); }
  html.phone .topbar { grid-column: 1 / -1; height: 48px; }
  html.phone .monitor { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; min-height: 0; }
  html.phone .mon-body { flex: 1; display: flex; align-items: center; padding: 0 0 8px; min-height: 0; }
  html.phone .deck { grid-column: 2; grid-row: 2; }
  html.phone .ph-tabs { padding: 8px 12px; }
  html.phone .deck > .step { padding: 4px 12px 12px; }
}
/* help on a phone: no tour or keyboard shortcuts (they belong to the desktop layout) */
html.phone .hp-tour, html.phone .hp-body section:has(.hp-keys) { display: none; }

/* ---------- focus rings never get clipped (round 23) ----------
   The deck's three columns scroll, and a scroll box clips at its padding
   edge. Rings sit outside the control (1.5-2px ring + 1-2px offset), so
   every scroll box gets 6px of room on all sides, pulled back by the same
   margin so nothing moves. Segmented buttons live inside a clipped frame,
   so their ring is drawn inside the button instead. */
.deck .content { margin: -6px; padding: 6px 10px 6px 6px; }
.deck .style { margin: -6px; padding: 6px 10px 6px 6px; }
.deck .recipes { margin: -6px -11px; padding: 6px 23px 6px 11px; }
.seg button:focus-visible { outline-offset: -2px; }
html.phone .deck .content, html.phone .deck .style { overflow: visible; margin: 0; padding: 0; }
html.phone .deck .recipes { margin: 0; padding: 0; }
