/* saintjustus.xyz — refinement concept
   voices: existing cables light (warm, diffuse) · digit field (cold, quantized)
           · plain grotesk names · crt glass containment · rgb as state only */

:root {
    --sans: "Helvetica Neue", Helvetica, Arimo, Arial, sans-serif;
    --bitmap: "VT323", "Share Tech Mono", monospace;
    --gutter: 28px;
    --deck-h: 76px;
    color-scheme: dark;
}

body.theme-dark {
    --ink: #d9f1ee;
    --ink-dim: rgba(217, 241, 238, 0.5);
    --ink-faint: rgba(217, 241, 238, 0.22);
    --rule: rgba(217, 241, 238, 0.32);
    --rule-faint: rgba(217, 241, 238, 0.12);
    --panel: rgba(0, 3, 3, 0.56);
    --panel-solid: rgba(0, 2, 2, 0.94);
    --bin: rgba(0, 3, 3, 0.26);
    --red: #ff6b6b;
    --green: #7cf29c;
    --blue: #6ea8ff;
    --glow: 0 0 6px rgba(150, 240, 228, 0.32);
    --canvas-bg: #000;
    --bg-filter: none; /* the scene's paper is removed by the dark view (scene-view.js) */
}

body.theme-light {
    color-scheme: light;
    --ink: #10201e;
    --ink-dim: rgba(16, 32, 30, 0.62);
    --ink-faint: rgba(16, 32, 30, 0.28);
    --rule: rgba(16, 32, 30, 0.5);
    --rule-faint: rgba(16, 32, 30, 0.15);
    --panel: rgba(240, 244, 241, 0.56);
    --panel-solid: rgba(240, 244, 241, 0.95);
    --bin: rgba(240, 244, 241, 0.3);
    --red: #c2262b;
    --green: #16803b;
    --blue: #1d4fc4;
    --glow: 0 0 5px rgba(20, 120, 108, 0.35);
    --canvas-bg: #eef1ee;
    --bg-filter: none;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
    background: var(--canvas-bg);
    color: var(--ink);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    transition: background 0.6s;
}
body.is-window-dragging { user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
.bm { font-family: var(--bitmap); font-weight: 400; letter-spacing: 0.02em; text-shadow: var(--glow); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

/* ---------- 1. background (unchanged patches) ---------- */
.canvas-stack {
    position: fixed; inset: 0; z-index: 0;
    /* dark: crush the patch's grey floor toward true black, keep its light; pulse brightens */
    filter: var(--bg-filter) brightness(calc(1 + var(--bg-pulse, 0) * 0.9)) saturate(calc(1 + var(--bg-pulse, 0) * 0.6));
}
.canvas-stack canvas { position: absolute; inset: 0; width: 100vw; height: 100vh; display: block; opacity: 0; pointer-events: none; transition: opacity 1.2s ease; }
/* only the visible patch may receive input (the hidden light canvas used to swallow it) */
.canvas-stack canvas.is-active { opacity: 1; pointer-events: auto; z-index: 1; }
/* dark view of the same scene: drawn over it, never takes input, cross-fades on theme change */
.canvas-stack canvas.scene-view { z-index: 2; pointer-events: none; transition: opacity 0.6s ease; }
.canvas-stack canvas.scene-view.is-active { pointer-events: none; }
/* no WebGL2 for the view: approximate the dark paper with a filter on the scene itself */
.canvas-stack canvas.is-dark-fallback { filter: brightness(0.3) contrast(1.6) saturate(2); }

/* ---------- 2. glass over the bg: vignette + phosphor bias (both themes) ---------- */
.glass-tint {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(130% 110% at 50% 45%, transparent 50%, rgba(0, 0, 0, 0.72) 100%);
}
.glass-tint::after {
    content: ""; position: absolute; inset: 0;
    background: rgba(110, 210, 200, 0.06);
    mix-blend-mode: soft-light;
}
body.theme-light .glass-tint {
    background: radial-gradient(130% 110% at 50% 45%, transparent 55%, rgba(20, 50, 46, 0.2) 100%);
}
body.theme-light .glass-tint::after { background: rgba(60, 170, 155, 0.08); mix-blend-mode: multiply; }

.glass-lines {
    position: fixed; inset: 0; z-index: 100; pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
    box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.5); /* square: the scanlines fill the whole canvas */
}
body.theme-light .glass-lines {
    background: repeating-linear-gradient(0deg, rgba(10, 40, 36, 0.075) 0 1px, transparent 1px 3px);
    box-shadow: inset 0 0 140px rgba(20, 60, 55, 0.2);
}

/* ---------- 3. field ---------- */
.field { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

/* ---------- boot ---------- */
.hud, .bins, .deck { transition: opacity 0.7s steps(5), transform 0.7s steps(5); }
body:not(.is-booted) .hud, body:not(.is-booted) .bins, body:not(.is-booted) .deck { opacity: 0; }
body:not(.is-booted) .bins { transform: translateY(8px); }

/* ---------- hud ---------- */
.hud {
    position: fixed; z-index: 5; top: 20px; left: var(--gutter); right: var(--gutter);
    display: flex; align-items: baseline; gap: 28px;
}
.hud__brand { font-size: 17px; letter-spacing: -0.01em; text-decoration: none; }
.hud__brand .bm { font-size: 21px; color: var(--ink-dim); margin-left: 1px; }
.hud__readout { margin: 0; font-size: 19px; color: var(--ink-dim); display: flex; gap: 10px; }
.hud__controls { margin-left: auto; display: flex; gap: 4px; }
.hud__btn { font-size: 20px; padding: 2px 8px; color: var(--ink-dim); text-decoration: none; border: 1px solid transparent; }
.hud__btn:hover, .hud__btn:focus-visible { color: var(--ink); border-color: var(--rule); }

/* ---------- bins (semi-transparent) ---------- */
.bins {
    position: fixed; z-index: 5;
    left: var(--gutter); bottom: calc(var(--deck-h) + 30px);
    display: grid; grid-template-columns: repeat(3, 168px);
}
.bin {
    position: relative; display: grid; gap: 10px; text-align: left;
    padding: 20px 14px 16px; min-height: 76px; align-content: start;
    background: var(--bin);
    border: 1px solid var(--rule);
    backdrop-filter: blur(3px);
    transition: background 0.25s, transform 0.4s ease;
}
.bin + .bin { border-left: 0; }
.bin[data-state="red"] { --state: var(--red); }
.bin[data-state="green"] { --state: var(--green); }
.bin[data-state="blue"] { --state: var(--blue); }
.bin__lid { position: absolute; left: -1px; right: -1px; top: -1px; height: 0; display: flex; }
.bin__lid i { flex: 1; height: 3px; background: var(--ink); transition: transform 0.35s cubic-bezier(.2, .9, .2, 1.2), background 0.2s; }
.bin__lid i:first-child { transform-origin: 0 50%; }
.bin__lid i:last-child { transform-origin: 100% 50%; }
.bin__row { display: flex; align-items: baseline; gap: 10px; }
.bin__idx { font-size: 19px; color: var(--ink-dim); }
.bin__label { font-size: 23px; letter-spacing: -0.01em; }

.bin:hover, .bin:focus-visible { background: color-mix(in srgb, var(--bin) 85%, var(--state) 10%); }
.bin:hover .bin__lid i, .bin:focus-visible .bin__lid i { background: var(--state); }
.bin:hover .bin__lid i:first-child, .bin:focus-visible .bin__lid i:first-child, .bin.is-receiving .bin__lid i:first-child { transform: rotate(-7deg); }
.bin:hover .bin__lid i:last-child, .bin:focus-visible .bin__lid i:last-child, .bin.is-receiving .bin__lid i:last-child { transform: rotate(7deg); }
.bin.is-receiving .bin__lid i, .bin.is-spilling .bin__lid i, .bin.is-open .bin__lid i { background: var(--state); }
.bin.is-receiving .bin__lid i:first-child { transform: rotate(-32deg); }
.bin.is-receiving .bin__lid i:last-child { transform: rotate(32deg); }
/* the box tips: lid flips open, the bin leans toward the window */
.bin.is-spilling { transform: rotate(-3.5deg) translateY(-4px); transition: transform 0.25s cubic-bezier(.2,.9,.2,1.3); z-index: 2; }
.bin.is-spilling .bin__lid i:first-child { transform: rotate(-150deg); }
.bin.is-spilling .bin__lid i:last-child { transform: rotate(-24deg); }
.bin.is-gulp { animation: gulp 0.12s steps(2); }
@keyframes gulp { 50% { background: color-mix(in srgb, var(--bin) 70%, var(--state) 24%); } }
.bin.is-open .bin__label::after { content: " ·"; color: var(--state); }

/* ---------- windows (same glass in both themes) ---------- */
.window-layer { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.term-window {
    position: absolute; pointer-events: auto;
    display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
    background: var(--panel);
    border: 1px solid var(--rule);
    backdrop-filter: blur(8px) saturate(0.7);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 28px 80px rgba(0, 0, 0, 0.5);
}
body.theme-light .term-window { box-shadow: 0 0 0 1px rgba(10, 30, 28, 0.12), 0 24px 60px rgba(10, 40, 36, 0.18); }
.term-window.is-hidden { visibility: hidden; }
/* coalescence: the lit tile footprint merges into the window as its glass and content blend in */
.term-window.is-coalescing { animation: tw-coalesce var(--coalesce-ms, 420ms) cubic-bezier(0.3, 0, 0.2, 1) both; }
.term-window.is-coalescing .tw__body, .term-window.is-coalescing .tw__foot { animation: tw-coalesce-content var(--coalesce-ms, 420ms) ease-in both; }
@keyframes tw-coalesce { from { opacity: 0; backdrop-filter: blur(0) saturate(1); } to { opacity: 1; } }
@keyframes tw-coalesce-content { 0%, 35% { opacity: 0; } to { opacity: 1; } }
/* close = exact time reverse of the coalesce (mirrored easing, content leaves first); opacity only */
.term-window.is-dissolving { animation: tw-dissolve var(--coalesce-ms, 420ms) cubic-bezier(0.8, 0, 0.7, 1) both; pointer-events: none; }
.term-window.is-dissolving .tw__body, .term-window.is-dissolving .tw__foot { animation: tw-dissolve-content var(--coalesce-ms, 420ms) ease-out both; }
@keyframes tw-dissolve { from { opacity: 1; } to { opacity: 0; } }
@keyframes tw-dissolve-content { from { opacity: 1; } 65%, to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .term-window.is-coalescing, .term-window.is-coalescing .tw__body, .term-window.is-coalescing .tw__foot, .term-window.is-dissolving, .term-window.is-dissolving .tw__body, .term-window.is-dissolving .tw__foot { animation: none; } }
/* opening/closing snap to the lit tile block (also over the compact sheet's !important box) */
.term-window.is-snapped:not(.is-max) { left: var(--snap-l) !important; top: var(--snap-t) !important; width: var(--snap-w) !important; height: var(--snap-h) !important; right: auto !important; bottom: auto !important; }
.term-window.is-max { position: fixed; inset: 0 !important; width: auto !important; height: auto !important; border: 0; box-shadow: none; }
/* a maximised window covers the header, bins and player */
body.has-max-window .window-layer { z-index: 90; }
.term-window.is-moving, .term-window.is-resizing { box-shadow: 0 0 0 1px var(--rule), 0 28px 80px rgba(0, 0, 0, 0.5); }
.term-window.is-moving iframe, .term-window.is-resizing iframe { pointer-events: none; }

/* resize grips: invisible hit areas on every edge and corner */
.tw__grip { position: absolute; z-index: 4; touch-action: none; }
.tw__grip--n, .tw__grip--s { left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.tw__grip--e, .tw__grip--w { top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.tw__grip--n { top: -4px; } .tw__grip--s { bottom: -4px; }
.tw__grip--e { right: -4px; } .tw__grip--w { left: -4px; }
.tw__grip--ne, .tw__grip--se, .tw__grip--sw, .tw__grip--nw { width: 16px; height: 16px; }
.tw__grip--ne { top: -5px; right: -5px; cursor: nesw-resize; }
.tw__grip--sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.tw__grip--nw { top: -5px; left: -5px; cursor: nwse-resize; }
.tw__grip--se { bottom: -5px; right: -5px; cursor: nwse-resize; }
/* the one visible affordance: a quantized corner tick, terminal-style */
.tw__grip--se::after {
    content: ""; position: absolute; right: 6px; bottom: 6px; width: 7px; height: 7px;
    border-right: 1px solid var(--ink-dim); border-bottom: 1px solid var(--ink-dim);
}
.tw__grip--se:hover::after { border-color: var(--ink); }
.is-max .tw__grip, .is-hidden .tw__grip { display: none; }

.tw__bar {
    display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
    padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--rule);
    user-select: none; cursor: move; touch-action: none;
}
.is-max .tw__bar { cursor: default; }
.tw__path { font-size: 18px; color: var(--ink-dim); white-space: nowrap; }
.tw__path b { font-weight: 400; color: var(--ink); }
.tw__title { margin: 0; font-size: 20px; font-weight: 400; letter-spacing: -0.01em; }
.tw__title:focus { outline: none; }
.tw__tags { list-style: none; display: flex; flex-wrap: nowrap; gap: 12px; margin: 0; padding: 0; min-width: 0; overflow: hidden; }
.tw__tags li { display: inline-flex; align-items: center; gap: 6px; font-size: 17px; color: var(--ink-dim); white-space: nowrap; }
.preview__meta .tw__tags { flex-wrap: wrap; }
.tw__tags i, .dir__tags i { width: 7px; height: 7px; display: inline-block; background: var(--state-c, var(--ink)); }
[data-state="red"] { --state-c: var(--red); }
[data-state="green"] { --state-c: var(--green); }
[data-state="blue"] { --state-c: var(--blue); }
.tw__ctl { display: flex; gap: 4px; }
.tw__ctl button { font-size: 18px; padding: 1px 8px; border: 1px solid var(--rule-faint); color: var(--ink-dim); cursor: pointer; }
.tw__ctl button:hover, .tw__ctl button:focus-visible { background: var(--ink); color: var(--panel-solid); text-shadow: none; border-color: var(--ink); }

.tw__body, .tw__veil { grid-row: 2; grid-column: 1; min-height: 0; }
.tw__body { overflow: auto; position: relative; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.tw__veil {
    z-index: 2; display: none; margin: 0; padding: 6px 10px; overflow: hidden; white-space: pre;
    font-size: 20px; line-height: 20px; color: var(--ink-dim);
    background: var(--panel-solid);
}

.tw__foot {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 6px 12px 7px; border-top: 1px solid var(--rule-faint);
    font-size: 18px; color: var(--ink-dim);
}

/* split body: file tree left, preview right (same for work, art, music) */
.tw__body--split { display: grid; grid-template-columns: minmax(230px, 26%) 1fr; }
.dir__tags { display: inline-flex; gap: 3px; }
.dir__tags i { width: 6px; height: 6px; }
.dir__state { color: var(--green); font-size: 17px; }
.tree__file[aria-current="true"] .dir__state { color: var(--panel-solid); text-shadow: none; }

/* work: ide file tree */
.tree { border-right: 1px solid var(--rule-faint); overflow: auto; padding: 6px 0 12px; font-size: 14.5px; }
.tree__root { margin: 2px 0 4px; padding: 0 12px; font-size: 18px; color: var(--ink-dim); }
.tree__dir, .tree__file {
    position: relative; width: 100%; display: grid; align-items: center; gap: 7px; text-align: left;
    padding: 3px 12px; line-height: 20px;
}
.tree__dir { grid-template-columns: 10px 14px 1fr auto; padding-left: 14px; }
.tree__file { grid-template-columns: 14px 1fr auto; padding-left: 46px; color: var(--ink); }
.tree__files { position: relative; }
.tree__files::before { /* indent guide */
    content: ""; position: absolute; left: 22px; top: 0; bottom: 4px; width: 1px; background: var(--rule-faint);
}
.tree__folder:not(.is-open) .tree__files { display: none; }
.tree__caret { width: 0; height: 0; border: 4px solid transparent; border-left: 5px solid var(--ink-dim); justify-self: center; transform: translateX(2px); transition: transform 0.12s; }
.tree__folder.is-open .tree__caret { transform: translate(0, 2px) rotate(90deg); }
.tree__ficon { /* folder glyph */
    width: 14px; height: 10px; position: relative; border: 1px solid var(--ink-dim); border-radius: 1px; justify-self: center;
}
.tree__ficon::before { content: ""; position: absolute; left: -1px; top: -4px; width: 6px; height: 3px; border: 1px solid var(--ink-dim); border-bottom: 0; }
.tree__folder.is-open .tree__ficon { border-color: var(--ink); }
.tree__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree__ext { color: var(--ink-dim); }
.tree__count { font-size: 16px; color: var(--ink-faint); }
.tree__icon { font-size: 15px; color: var(--ink-dim); text-align: center; }
.tree__dir:hover, .tree__file:hover { background: var(--rule-faint); }
.tree__file[aria-current="true"] { background: var(--ink); color: var(--panel-solid); }
.tree__file[aria-current="true"] .tree__ext, .tree__file[aria-current="true"] .tree__icon { color: var(--panel-solid); text-shadow: none; }

.preview { padding: 14px; display: flex; flex-direction: column; gap: 14px; overflow: auto; min-height: 0; }
.preview > * { flex-shrink: 0; }
/* sized in js to the content's own aspect ratio, fitted above the caption */
.preview__media { align-self: center; box-sizing: border-box; width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--rule-faint); background: rgba(0, 0, 0, 0.35); display: grid; place-items: center; overflow: hidden; }
.preview__media:has(> video) { background: #000; }
.preview__media > * { width: 100%; height: 100%; min-width: 0; min-height: 0; border: 0; object-fit: contain; display: block; }
.preview__media > p, .preview__warn > * { width: auto; height: auto; }
/* tall media in a wide pane: caption sits beside the frame */
.preview--side { flex-direction: row; align-items: flex-start; }
.preview--side .preview__media { align-self: flex-start; }
.preview--side .preview__meta { flex: 1 1 0; min-width: 0; max-width: 320px; }
.preview__warn { gap: 10px; align-content: center; }
.preview__warn button { border: 1px solid var(--red); color: var(--red); padding: 2px 10px; font-size: 19px; }
.preview__empty { margin: 0; color: var(--ink-dim); font-size: 19px; }
.preview > .preview__empty { margin: auto; text-align: center; }
.preview__meta .bm { font-size: 17px; color: var(--ink-dim); }
.preview__meta h3 { margin: 2px 0 6px; font-size: 24px; font-weight: 400; letter-spacing: -0.015em; }
.preview__meta p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; color: var(--ink-dim); max-width: 52ch; }

/* art stage */
.preview--stage { padding: 0; gap: 0; }
.preview--stage .preview__meta { padding: 12px 14px 14px; }
.stage { position: relative; flex: 1 1 auto !important; min-height: 240px; background: #000; overflow: hidden; }
.stage > canvas { display: block; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage .moth-export {
    position: absolute; right: 10px; bottom: 10px; font-family: var(--bitmap); font-size: 18px;
    padding: 1px 8px; border: 1px solid rgba(217, 241, 238, 0.34); color: #d9f1ee; background: rgba(0, 0, 0, 0.4);
}
.stage .oscilloscope-status { position: absolute; left: 12px; bottom: 10px; font-family: var(--bitmap); font-size: 17px; color: rgba(217, 241, 238, 0.5); }
.gate { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 20px; text-align: center; color: #d9f1ee; }
.gate__line { margin: 0; font-size: 22px; }
.gate__btn { font-size: 22px; padding: 4px 16px; border: 1px solid #d9f1ee; color: #d9f1ee; }
.gate__btn:hover, .gate__btn:focus-visible { background: #d9f1ee; color: #000; text-shadow: none; }
.gate__note { margin: 0; font-size: 17px; color: rgba(217, 241, 238, 0.55); max-width: 46ch; line-height: 1.15; }
.gate__note b { font-weight: 400; color: #ff6b6b; }
.np { display: flex; align-items: center; gap: 14px; }
.np__btn { font-size: 22px; padding: 3px 16px; border: 1px solid var(--rule); }
.np__btn:hover, .np__btn:focus-visible { background: var(--ink); color: var(--panel-solid); text-shadow: none; }
.np__state { font-size: 19px; color: var(--ink-dim); }
/* gallery viewer: prev / next + counter docked at one fixed spot, the bottom-left of the
   preview pane, for every slide and gallery (they never move with the media's aspect) */
.preview--gallery { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; align-content: stretch; }
.preview--gallery > .preview__media { justify-self: center; }
.preview--gallery > .gal { grid-row: 3; align-self: end; justify-self: start; margin: 0; position: sticky; bottom: 0; z-index: 1;
    padding: 0; background: transparent; }
.preview--gallery.preview--side { grid-template-columns: auto minmax(0, 320px); grid-template-rows: 1fr auto; justify-content: start; }
.preview--gallery.preview--side > .preview__media { grid-column: 1; grid-row: 1; align-self: start; justify-self: start; }
.preview--gallery.preview--side > .preview__meta { grid-column: 2; grid-row: 1; align-self: start; max-width: 320px; }
.preview--gallery.preview--side > .gal { grid-column: 1 / -1; grid-row: 2; }
/* vimeo background player: black behind it, hidden until the player paints (no white flash),
   and very slightly overscanned so no light edge lines show at the frame sides */
.preview__media--vimeo { background: #000; }
.preview__media--vimeo > iframe { background: #000; color-scheme: dark; opacity: 0; transform: scale(1.015); transition: opacity 0.45s ease; }
.preview__media--vimeo > iframe.is-ready { opacity: 1; }
.preview__media--gallery:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
.gal { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.gal__btn { font-size: 20px; padding: 2px 14px; border: 1px solid var(--rule); background: var(--panel-solid); }
.gal__btn:hover, .gal__btn:focus-visible { background: var(--ink); color: var(--panel-solid); text-shadow: none; }
.gal__count { font-size: 19px; color: var(--ink-dim); min-width: 5ch; text-align: center; background: var(--panel-solid); }

/* about */
.readme { padding: 18px 22px 24px; max-width: 62ch; font-size: 15.5px; line-height: 1.55; }
.readme p { margin: 0 0 14px; }
.readme em { font-style: normal; box-shadow: inset 0 -2px 0 var(--state-c); }

/* ---------- UI slabs on the tile grid (js/terminal/ui-blocks.js) ----------
   The hud title, readout, about / github / theme and the three bins are fixed-size single slabs on the
   tile grid; ui-blocks.js positions each element (position: fixed + left/top/width/height inline) to
   exactly its slab's outer bounds. The slab paints the panel (frosted, raised, hover colour), so the
   elements drop their own background, border, blur and movement transforms and just centre their text
   inside the box. The deck is a dense run of frosted tiles under a crisp 1px top edge line that sits
   exactly on the deck block's top grid edge (the deck box top). */
body.has-tile-blocks { --deck-edge: color-mix(in srgb, var(--rule) 55%, var(--ink) 45%); }
body.has-tile-blocks .bin,
body.has-tile-blocks .bin:hover, body.has-tile-blocks .bin:focus-visible,
body.has-tile-blocks .deck,
body.has-tile-blocks .hud__brand, body.has-tile-blocks .hud__readout, body.has-tile-blocks .hud__btn {
    background: transparent; border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.has-tile-blocks .hud__brand, body.has-tile-blocks .hud__readout, body.has-tile-blocks .hud__btn {
    position: fixed; z-index: 5; margin: 0; display: flex; align-items: center; justify-content: center;
    white-space: nowrap; line-height: 1; overflow: visible;
}
body.has-tile-blocks .hud__readout { gap: 10px; }
body.has-tile-blocks .hud__btn { padding: 0 8px; border: 0; }
body.has-tile-blocks .hud__btn:hover, body.has-tile-blocks .hud__btn:focus-visible { color: var(--ink); }
body.has-tile-blocks .bins { position: fixed; display: block; transform: none; transition: opacity 0.7s steps(5); } /* baked into the grid: fade in, never slide off its slabs */
body.has-tile-blocks .bin { position: absolute; min-height: 0; border: 0; align-content: center; transform: none; }
body.has-tile-blocks .bin__row { white-space: nowrap; }
body.has-tile-blocks .bin__lid { left: 0; right: 0; top: 0; }
body.has-tile-blocks .bin.is-gulp { animation: none; }
body.has-tile-blocks .hud__btn:focus-visible, body.has-tile-blocks .bin:focus-visible, body.has-tile-blocks .hud__brand:focus-visible { outline: 1px solid var(--ink); outline-offset: -4px; }
body.has-tile-blocks .deck { border-top: 1px solid var(--deck-edge); }

/* ---------- deck ---------- */
.deck {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; height: var(--deck-h);
    display: block; padding: 0; background: color-mix(in srgb, var(--panel-solid) 82%, transparent);
    border-top: 1px solid var(--rule); backdrop-filter: blur(10px);
    --deck-cell: 34px;
}
.deck__id { display: grid; align-content: center; gap: 0; min-width: 0; padding: 0 4px; overflow: hidden; }
.deck__code { font-size: 15px; line-height: 1; color: var(--ink-dim); }
.deck__title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck__track { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.deck__time { flex: 0 0 calc(2 * var(--deck-cell) - 2px); height: calc(var(--deck-cell) - 2px); display: flex; align-items: center; justify-content: center; font-size: 17px; text-align: center; color: var(--ink-dim); background: color-mix(in srgb, var(--panel-solid) 72%, transparent); border: 1px solid var(--rule-faint); }
.deck__digits { flex: 1; min-width: 0; display: flex; overflow: hidden; font-family: var(--bitmap); font-size: 21px; line-height: 1; }
.deck__digits i { flex: 0 0 var(--deck-cell); display: flex; align-items: center; justify-content: center; font-style: normal; text-align: center; color: var(--ink-faint); background: color-mix(in srgb, var(--timeline-hue) 24%, var(--panel-solid)); transition: background-color 120ms linear, outline-color 120ms linear; }
.deck__digits i.on { color: var(--ink); background: color-mix(in srgb, var(--timeline-hue) 46%, var(--panel-solid)); text-shadow: 0 0 6px var(--timeline-hue); }
.deck__digits i.head { color: var(--ink); background: color-mix(in srgb, var(--timeline-hue) 35%, var(--panel-solid)); outline: 1px solid var(--timeline-hue); outline-offset: -2px; }
.deck__digits i.head.is-live { background: color-mix(in srgb, var(--timeline-hue) 62%, var(--panel-solid)); outline-color: var(--timeline-hue); text-shadow: 0 0 8px var(--timeline-hue); }
@media (min-width: 641px) {
    .deck__digits > i { display: block; height: 1em; overflow: hidden; }
    .deck__roll { display: block; height: 1em; width: 100%; }
    .deck__roll > b { display: block; height: 1em; line-height: 1; font-weight: inherit; }
}
.deck__seek { position: absolute; left: calc(2 * var(--deck-cell)); right: calc(2 * var(--deck-cell)); width: auto; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.deck__track:has(.deck__seek:focus-visible) .deck__digits { outline: 1px solid var(--ink); outline-offset: -2px; }
.deck__fx, .deck__transport { display: contents; }
.deck__knob { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 16px minmax(0, 1fr); align-items: center; min-width: 0; overflow: hidden; padding: 2px; font-size: 14px; color: var(--ink-dim); isolation: isolate; }
.deck__knob-label, .deck__knob output, .deck__knob input { position: relative; z-index: 1; }
.deck__knob-label { grid-column: 1; grid-row: 1; justify-self: start; padding-left: 3px; font-size: 14px; line-height: 1; }
.deck__knob output { grid-column: 2; grid-row: 1; justify-self: end; padding-right: 3px; color: var(--ink); font-size: 14px; line-height: 1; white-space: nowrap; max-width: 100%; }
.deck__levels { position: absolute; top: 14px; left: 2px; right: 2px; height: 14px; z-index: -1; display: grid; grid-template-columns: repeat(3, 1fr); pointer-events: none; }
.deck__levels i.is-active { background: color-mix(in srgb, var(--green) 32%, transparent); box-shadow: inset 0 0 0 1px var(--green); }
.deck__knob input { grid-column: 1 / -1; grid-row: 2; writing-mode: horizontal-tb; direction: ltr; appearance: none; width: calc(4 * var(--deck-cell) - 8px); height: 14px; min-width: 0; margin: 0; background: linear-gradient(var(--rule), var(--rule)) center / 100% 1px no-repeat; cursor: ew-resize; }
.deck__knob input::-webkit-slider-thumb { appearance: none; width: 5px; height: 18px; border: 0; background: var(--ink); }
.deck__knob input::-moz-range-thumb { width: 5px; height: 18px; border: 0; border-radius: 0; background: var(--ink); }
.deck__btn { font-size: 20px; color: var(--ink-dim); background: color-mix(in srgb, var(--panel-solid) 62%, transparent); border: 1px solid var(--rule-faint); }
.deck__btn:hover, .deck__btn:focus-visible { color: var(--ink); border-color: var(--rule); background: color-mix(in srgb, var(--green) 18%, var(--panel-solid)); }
.deck__btn--play { color: var(--ink); border-color: var(--rule); }
.deck.is-playing .deck__btn--play { color: var(--green); border-color: var(--green); }
.deck__status { position: absolute; right: var(--gutter); top: -28px; margin: 0; font-size: 18px; color: var(--ink-dim); }
body.has-tile-blocks .deck__id { background: color-mix(in srgb, var(--panel-solid) 72%, transparent); border: 1px solid var(--rule-faint); }
body.has-tile-blocks .deck__btn { backdrop-filter: blur(3px); }

/* ---------- compact ---------- */
@media (max-width: 640px) {
    :root { --gutter: 14px; --deck-h: 128px; }
    .hud { top: 12px; gap: 12px; }
    .hud__readout { display: none; }
    .hud__btn { font-size: 19px; padding: 2px 5px; }
    body.has-tile-blocks .hud__btn { font-size: 17px; padding: 0 5px; }
    body.has-tile-blocks .bin { padding: 10px 10px 8px; }
    body.has-tile-blocks .hud__readout { display: none; }
    .bins { left: 0; right: 0; bottom: var(--deck-h); grid-template-columns: repeat(3, 1fr); }
    .bin { padding: 14px 10px 8px; min-height: 84px; gap: 6px; border-bottom: 0; }
    .bin__label { font-size: 19px; }
    .term-window { position: fixed; left: 8px !important; right: 8px; top: 50px !important; bottom: calc(var(--deck-h) + 92px); width: auto !important; height: auto !important; }
    .term-window.is-max { inset: 0 !important; }
    .tw__grip { display: none; }
    .tw__bar { grid-template-columns: 1fr auto; gap: 6px 10px; cursor: default; }
    .tw__bar > span:empty { display: none; }
    .tw__path { grid-column: 1 / -1; }
    .tw__tags { display: none; }
    .tw__foot [data-foot-left] { display: none; }
    .tw__foot [data-foot-right] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tw__body--split { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    .tw__body--split .tree { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--rule); }
    .deck { height: auto; min-height: var(--deck-h); padding: 0; display: block; }
    .deck__code { display: none; }
    .deck__title { font-size: 14px; }
    .deck__time { font-size: 15px; }
    .deck__fx, .deck__transport { display: contents; }
    .deck__knob { display: grid; grid-template-columns: 1fr; grid-template-rows: 14px minmax(0, 1fr) 14px; justify-items: center; padding: 2px; }
    .deck__knob-label { grid-column: 1; grid-row: 1; }
    .deck__knob output { grid-column: 1; grid-row: 3; }
    .deck__knob-label, .deck__knob output { justify-self: center; padding: 0; font-size: 14px; }
    .deck__levels { top: calc(var(--deck-cell) - 4px); height: 14px; }
    .deck__knob input { width: calc(4 * var(--deck-cell) - 8px); height: 20px; min-width: 0; }
    .deck__btn { font-size: 18px; padding: 0; }
    .deck__status { top: -24px; font-size: 16px; }
}

/* ---------- reduced motion ---------- */
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation: none !important; transition: none !important; }
