/* Machine room. The picture takes the page: one dark, glowing stage (dark in both looks: it carries data-theme="dark")
   that keeps every drag (data-swipe="off"). Under it one row of layer words. The list of everything is behind the "List"
   button: a panel over the picture (a sheet from the bottom on phones) that scrolls inside itself. Colours: tokens only. */
.machine { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: var(--s-2); }
.machine-stage { position: relative; grid-column: 1; grid-row: 1; min-height: 0; min-width: 0; overflow: hidden; border-radius: var(--r-3, var(--r-2)); background: var(--bg); color: var(--ink); touch-action: none; cursor: grab; outline: none; -webkit-user-select: none; user-select: none; }
.machine-stage:active { cursor: grabbing; }
.machine-stage:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.machine-still { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }      /* the still drawing: until the room is built, and all there is without WebGL */
.machine-stage.is-flat { cursor: default; }
.machine-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.machine-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.node-tag { position: absolute; left: 0; top: 0; display: grid; justify-items: center; white-space: nowrap; font-size: .6875rem; line-height: 1.25; color: var(--ink-2); will-change: transform; transition: opacity var(--med); text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg); }
.node-tag b { color: var(--ink-2); font-weight: 500; }
.node-tag.is-main b { color: var(--ink); font-weight: 600; font-size: .75rem; }
.node-tag .sub { display: none; }

.care-tag b { color: var(--accent); }
.net-tag b { color: var(--ink); }
.tray-tag { display: flex; gap: .4rem; align-items: baseline; padding: 0 .35rem; }
.tray-tag b { color: var(--ink); }
.tray-tag .n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tray-tag.is-on b, .tray-tag.is-on .n { color: var(--accent); font-weight: 600; }
.unit-tag b { color: var(--ink-2); font-weight: 500; }
.unit-tag.is-on b { color: var(--accent); font-weight: 600; }

/* the layers: the house from the outside in. One row of words; on a narrow screen it wraps to a second row (11-14: nothing wider than its box) */
.machine-layers { grid-column: 1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .35rem; min-width: 0; }
.machine-layers[hidden] { display: none; }
.mr-layer { flex: none; min-height: var(--tap); padding: 0 .85rem; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--glass); color: var(--ink-2); font: inherit; font-size: var(--t-small); white-space: nowrap; cursor: pointer; transition: border-color var(--fast), color var(--fast), background var(--fast); }
.mr-layer:hover { border-color: var(--line-strong); color: var(--ink); }
.mr-layer[aria-pressed="true"] { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft); color: var(--ink); }

.machine-panel { grid-column: 1; grid-row: 1; z-index: 2; justify-self: end; align-self: stretch; width: min(21rem, 100%); margin: var(--s-2); padding: var(--s-3); display: grid; grid-template-rows: auto minmax(0, 1fr); gap: var(--s-2); min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--bg-raise); box-shadow: var(--shadow); }      /* opaque: nothing of the picture shows through it (QA 15 Nov) */
.machine-panel[hidden] { display: none; }
.machine-side { display: grid; gap: var(--s-3); min-width: 0; min-height: 0; align-content: start; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.mr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mr-row { width: 100%; min-height: var(--tap); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: 0 .75rem; border: 1px solid transparent; border-radius: var(--r-2); background: none; color: var(--ink-2); font: inherit; font-size: var(--t-small); text-align: left; cursor: pointer; transition: background var(--fast), border-color var(--fast), color var(--fast); }
.mr-row:hover { background: var(--glass); color: var(--ink); }
.mr-row[aria-pressed="true"] { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft); color: var(--ink); }
.mr-row .mr-name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-row b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-quiet); }
.mr-dot[data-state="up"] { background: var(--c-good); }
.mr-dot[data-state="down"] { background: var(--c-warn); }
.mr-head { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.mr-head h3 { font-size: 1rem; font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-back { min-height: var(--tap); flex: none; }
.mr-meta { display: flex; flex-wrap: wrap; gap: .15rem var(--s-4); font-size: var(--t-small); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mr-none { font-size: var(--t-small); color: var(--ink-2); }
.mr-fact { min-height: var(--tap); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: 0 .75rem; font-size: var(--t-small); color: var(--ink-2); }
.mr-fact .mr-name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-fact b { font-weight: 600; color: var(--ink); }
.mr-facts { display: flex; flex-wrap: wrap; gap: .1rem var(--s-4); padding: .1rem .75rem .5rem 2.1rem; font-size: var(--t-small); color: var(--ink-2); }
.mr-counts { list-style: none; margin: 0; padding: 0; display: grid; font-size: var(--t-small); color: var(--ink-2); }
.mr-counts li { display: grid; grid-template-columns: minmax(0, 1fr) auto 4.6rem; gap: .6rem; min-height: 2rem; align-items: center; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.mr-counts span:first-child { color: var(--ink); }
.mr-counts b { color: var(--ink); font-weight: 500; }

.machine-by { display: grid; gap: var(--s-2); min-width: 0; }
.machine-kinds { display: none; flex-wrap: wrap; gap: .4rem; }      /* chips where a screen is tall enough for them; one select otherwise */
.kind { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); padding: 0 .8rem 0 .9rem; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--glass); font-size: var(--t-small); color: var(--ink-2); transition: border-color var(--fast), color var(--fast), background var(--fast), transform var(--fast) var(--ease); }
.kind b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.kind:hover { border-color: var(--line-strong); color: var(--ink); }
.kind:active { transform: scale(.96); }
.kind[aria-pressed="true"] { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft); color: var(--ink); }
.machine-pick { display: block; width: 100%; height: var(--tap); padding: 0 2.2rem 0 1rem; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--glass); color: var(--ink); font: inherit; font-size: 1rem; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 1.25rem) 55%, calc(100% - .95rem) 55%; background-size: .3rem .3rem; background-repeat: no-repeat; }
.machine-pick option { background: var(--bg-raise); color: var(--ink); }
.machine-where { min-height: 1.4rem; display: flex; flex-wrap: wrap; gap: .1rem var(--s-4); font-size: var(--t-small); color: var(--ink-2); }
.machine-where b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.machine-sample { position: absolute; left: var(--s-2); top: var(--s-2); z-index: 1; pointer-events: none; display: inline-flex; align-items: center; gap: .45rem; min-height: 1.75rem; padding: 0 .7rem; margin: 0; border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent); border-radius: var(--r-pill); background: color-mix(in srgb, var(--bg) 70%, transparent); font-size: var(--t-small); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

.machine-time[hidden] { display: none; }

@media (max-width: 720px) {
  .machine-panel { justify-self: stretch; align-self: end; width: auto; max-height: max(50%, 15rem); margin: 0; padding: var(--s-2) var(--s-3) var(--s-3); border-radius: var(--r-3, var(--r-2)) var(--r-3, var(--r-2)) 0 0; }      /* a half-height sheet: the picture keeps the top half */
  .machine-list-btn { min-width: var(--tap); justify-content: center; padding: 0 .9rem; }      /* the word, never the ≡ alone: that is the Index's mark */
  .mr-layer { padding: 0 .7rem; }
}
/* the narrowest phones: the title gives the two buttons beside it their room */
@media (max-width: 380px) { .scene-machine .scene-head { gap: var(--s-1, .25rem); } .scene-machine .scene-head h2 { font-size: calc(var(--t-display) * .9); } .scene-machine .scene-tools { gap: var(--s-1, .25rem); } }
/* inside a machine: one way back ("‹ House"), at the picture's top left; the Live / Sample tag steps down under it */
.machine-stage:has(> .machine-back:not([hidden])) .machine-sample { top: calc(var(--s-2) * 2 + var(--tap)); }
.machine-back { position: absolute; left: var(--s-2); top: var(--s-2); z-index: 1; min-height: var(--tap); min-width: var(--tap); padding: 0 .9rem 0 .55rem; border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent); border-radius: var(--r-pill); background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--ink); font: inherit; font-size: var(--t-small); cursor: pointer; }
.machine-back[hidden] { display: none; }
/* one "‹ House": the picture's, at its top left (the control stack + - tilt home is at the top right); the list's own is for the
   flat form only, where the picture's is not shown (11-16) */
.machine:has(> .machine-stage:not(.is-flat)) .mr-head > .mr-back { display: none; }
.machine-stage.is-flat .machine-ctl { display: none; }
.machine-stage.is-flat .machine-back { display: none; }      /* without the room the list is open and has its own way back */

/* the caretaker's diary on the last day: a mark under the track per moment, the chosen slot in words, Play */
.machine-time { display: grid; gap: 2px; min-width: 0; }
.machine-ts .ts-play[hidden] { display: none; }
.machine-marks { position: absolute; left: 0; right: 0; bottom: -3px; height: 6px; pointer-events: none; z-index: 1; }
.machine-marks i { position: absolute; top: 0; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); opacity: .75; }
.machine-did { display: flex; flex-wrap: wrap; gap: .1rem var(--s-3); min-height: 1.3rem; margin: -.2rem 0 .2rem; font-size: var(--t-small); color: var(--accent); }
.machine-did:empty { display: none; }
.mr-diary .mr-row { grid-template-columns: 3.2rem minmax(0, 1fr) auto; }
.mr-diary .mr-t { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mr-diary .mr-row[aria-pressed="true"] .mr-name { color: var(--accent); }
.moment-tag b { color: var(--accent); font-weight: 600; font-size: .75rem; }

/* inside a machine: three quiet level marks at the foot of the picture (a word and a soft bar: no figure, no scale) */
.machine-levels { position: absolute; left: 50%; bottom: var(--s-2); transform: translateX(-50%); z-index: 1; display: flex; gap: .3rem; max-width: calc(100% - 2 * var(--s-2)); }
.machine-levels[hidden], .machine-stage.is-flat .machine-levels { display: none; }
.mr-level { display: grid; align-content: center; gap: .3rem; min-height: var(--tap); min-width: 5.2rem; padding: .3rem .75rem; border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); border-radius: var(--r-2, 12px); background: color-mix(in srgb, var(--bg) 66%, transparent); color: var(--ink-2); font: inherit; font-size: var(--t-small); line-height: 1.1; text-align: left; cursor: pointer; }
.mr-level[aria-pressed="true"] { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.mr-bar { display: block; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.mr-bar i { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, color-mix(in srgb, var(--c-good) 70%, transparent), color-mix(in srgb, var(--accent) 80%, transparent)); transition: width 1.2s var(--ease, ease); }
.mr-level[aria-pressed="true"] .mr-bar i { background: var(--accent); }
@media (max-width: 380px) { .mr-level { min-width: 4.6rem; padding: .3rem .55rem; } }

/* a machine's state when the house does not watch it: a quiet word, the dot left out (QA 15 Nov: a grey dot with no state) */
.mr-row b.mr-quiet, .mr-meta .mr-quiet { color: var(--ink-3); font-weight: 400; }
.mr-row .mr-hint { color: var(--ink-3); font-weight: 400; }      /* the house view's quiet "· Streaming" after a machine's name */
.mr-row:has(b.mr-quiet) .mr-dot { visibility: hidden; }
/* a link's soft meter: how much flows there, no figure */
.mr-links .mr-row b { display: grid; justify-items: end; gap: .25rem; font-weight: 500; }
.mr-meter { width: 3.2rem; }
/* inside a machine, over the level marks: what it is doing now, in a few role words */
.machine-now { position: absolute; left: var(--s-2); right: var(--s-2); bottom: calc(var(--s-2) * 2 + var(--tap)); z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem; pointer-events: none; }
.machine-now[hidden], .machine-stage.is-flat .machine-now { display: none; }
.mr-now { pointer-events: auto; display: inline-flex; align-items: center; gap: .45rem; min-height: 2rem; padding: 0 .75rem; border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); border-radius: var(--r-pill); background: color-mix(in srgb, var(--bg) 66%, transparent); color: var(--ink-2); font: inherit; font-size: var(--t-small); white-space: nowrap; }
.mr-now b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
button.mr-now { min-height: var(--tap); cursor: pointer; }
button.mr-now:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.machine-levels:not([hidden]) ~ .machine-now { bottom: calc(var(--s-2) * 2 + var(--tap) + .2rem); }
.machine-levels[hidden] ~ .machine-now { bottom: var(--s-2); }
.machine-panel.is-deep .machine-time { display: none; }      /* inside a shelf or one thing: its rows, not the day */
/* while the list is open on a phone or a tablet, the level marks and the "now" line step away: they would sit under its rows */
@media (max-width: 1000px) { .machine:has(> .machine-panel:not([hidden])) .machine-levels, .machine:has(> .machine-panel:not([hidden])) .machine-now { display: none; } }
/* the control stack (+ - tilt home) steps left of the List panel while it is open on a wide screen; on a phone the panel is a sheet at the foot */
@media (min-width: 721px) { .machine:has(> .machine-panel:not([hidden])) .machine-ctl { right: calc(min(21rem, 100%) + var(--s-2) * 2); } }
@media (min-width: 1001px) { .machine:has(> .machine-panel:not([hidden])) .machine-now { right: calc(min(21rem, 100%) + var(--s-2) * 3); } }      /* the list floats on the right: what is on now stays beside it, never under it (11-16: up to five pills) */
