/* Isophone Lab · project library (proposed, Package 3b): a light table. The catalogue of base maps is the drawer on the
   left, the chosen map lies whole on the table in the middle, and its preparation ledger runs down the right with the
   next step on one instrument readout. Every size is rem, so the reader's text size and the lab's density carry
   through; projects.js picks the layout (data-layout, data-bar, data-pin, data-scale) from the width actually there. */

:root {
  color-scheme: light dark;
  --paper: light-dark(#ecebe6, #0d0e0d);
  --plate: light-dark(#f7f6f2, #151715);
  --plate-2: light-dark(#dddcd5, #1f221f);
  --field: light-dark(#ffffff, #0f110f);
  --ink: light-dark(#121412, #edece5);
  --ink-2: light-dark(#3d403a, #c6c5bd);
  --ink-3: light-dark(#5f625b, #93948c);
  --rule: light-dark(rgb(18 20 18 / .11), rgb(237 236 229 / .1));
  --rule-2: light-dark(rgb(18 20 18 / .26), rgb(237 236 229 / .24));
  --slab: light-dark(#121412, #2a2e2a);
  --on-slab: #edece5;
  --signal: light-dark(#c4ee2c, #d4f347);
  --on-signal: #121412;
  --alert: light-dark(#b93a0b, #ff7a2e);
  --ok: light-dark(#12704f, #4ade9a);
  --on-ok: light-dark(#ffffff, #0d0e0d);
  --warn: light-dark(#855300, #ffc23d);
  --scope: light-dark(#0f120f, #090b09);
  --wash: light-dark(rgb(196 238 44 / .24), rgb(212 243 71 / .1));
  --f-display: Bahnschrift, "DIN Alternate", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --f-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Microsoft YaHei UI", sans-serif;
  --f-num: "Cascadia Mono", "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --hit: 2.75rem;
  --r: .375rem;
  --gut: 1.5rem;
  --gut-i: 1rem;
  --row: .875rem;
  --lh: var(--noise-line-height, 1.55);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
html:is(:lang(ja), :lang(zh)) { --lh: var(--noise-line-height, 1.65); }
:root[data-noise-density="compact"] { --gut: 1rem; --gut-i: .75rem; --row: .5rem; }
:root[data-noise-contrast="high"] { --rule: light-dark(rgb(18 20 18 / .42), rgb(237 236 229 / .42)); --ink-3: var(--ink-2); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font-family: var(--f-ui); }
:where(.pl) :where(h1, h2, h3, p, ul, ol, figure) { margin: 0; }
:where(.pl) :where(button, select) { font: inherit; color: inherit; }
:where(.pl) a { color: inherit; }

.pl {
  --fz-xs: .9375rem; --fz-s: 1rem; --fz-m: 1.125rem; --fz-l: 1.25rem; --fz-xl: 2rem; --fz-xxl: 3rem;
  --ic: 1.25rem; --thumb: 5rem; --bar-h: 0px;
  min-height: 100dvh;
  padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: var(--fz-m);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
}
/* Space follows the available width; type follows only the reader's text size. */
.pl[data-scale="wide"] { --thumb: 6rem; --gut: 2rem; }
:root[data-noise-density="compact"] .pl[data-scale="wide"] { --gut: 1.25rem; }
.pl[data-layout="stack"] { --gut: 1rem; }

.pl-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.pl-ic { width: var(--ic); height: var(--ic); flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pl :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pl [tabindex="-1"]:focus { outline: none; }

/* ---- controls: one height, one radius, one weight; the primary is the only lime surface on the page */
.pl-btn, .pl-add, .pl-theme, .pl-lang, .pl-prefs > .noise-settings-entry {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-width: 0; min-height: var(--hit); padding: .5rem .875rem;
  border: 1px solid var(--rule-2); border-radius: var(--r);
  background: var(--plate); color: var(--ink);
  font: 600 var(--fz-s)/1.25 var(--f-ui); text-align: start; text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .12s var(--ease-out);
}
.pl-btn:active, .pl-add:active, .pl-theme:active { transform: scale(.97); }
.pl-btn.is-primary { background: var(--signal); border-color: color-mix(in oklab, #121412 22%, var(--signal)); color: var(--on-signal); }
.pl-btn.is-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.pl-btn.is-small { gap: .375rem; padding: .375rem .75rem; }
.pl-btn.is-lit { background: var(--field); border-color: var(--ink); }
@media (pointer: fine) { .pl-btn.is-small { min-height: 2.25rem; } }

/* ---- bar: home, title, the shared workspace rail, other interfaces, presentation */
.pl-bar:not(.wc-head) {
  position: relative; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
  padding: .625rem var(--gut-i);
  background: var(--plate); border-bottom: 1px solid var(--rule);
}
.pl[data-layout="split"][data-pin="on"] .pl-bar:not(.wc-head) { position: sticky; top: 0; }
/* Home is the way out, drawn as a quiet outline; the filled mark belongs to the destination the reader is in */
.pl-home {
  order: 1; display: inline-flex; align-items: center; gap: .5rem;
  min-height: var(--hit); padding: .375rem .875rem .375rem .625rem; border: 1px solid var(--rule-2); border-radius: 999px;
  background: transparent; color: var(--ink-2); font: 600 var(--fz-s)/1.2 var(--f-ui); text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.pl-home .pl-ic { color: var(--ink-3); }
.pl-title { order: 2; flex: 1 1 8rem; min-width: 0; }
.pl-title h1 { font: 600 var(--fz-l)/1.25 var(--f-display); letter-spacing: 0; overflow-wrap: anywhere; }
.pl-modes { order: 4; display: flex; align-items: center; gap: .125rem; }
.pl-modes a {
  display: inline-flex; align-items: center; min-height: var(--hit); padding: .375rem .625rem; border-radius: var(--r);
  color: var(--ink-2); font: 500 var(--fz-s)/1.2 var(--f-ui); text-decoration: none; transition: background-color .15s ease, color .15s ease;
}
.pl-prefs { order: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.pl-lang { gap: .25rem; padding: 0 .375rem 0 .75rem; color: var(--ink-2); cursor: default; }
.pl-lang select {
  min-height: calc(var(--hit) - 2px); padding: 0 .25rem; border: 0; background: transparent;
  color: var(--ink); font: 600 var(--fz-s)/1.2 var(--f-ui); cursor: pointer;
}
.pl-lang select:focus-visible { outline: none; }
.pl-lang:has(select:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.pl-theme { color: var(--ink-2); }
.pl-theme > span { color: var(--ink); }
.pl-prefs > .noise-settings-entry { min-width: var(--hit); padding: .5rem; color: var(--ink-2); }
.pl-prefs > .noise-settings-entry svg { width: var(--ic); height: var(--ic); }

.pl-bar:not(.wc-head) > .workspace-flow { --workspace-accent: var(--ok); --workspace-line: var(--rule-2); --workspace-surface: var(--plate); --workspace-ink: var(--ink); color: var(--ink); }
.pl .pl-bar:not(.wc-head) > .workspace-flow[data-embedded] { border-top-color: var(--rule); }
.pl-bar:not(.wc-head) .workspace-rail > a { color: var(--ink-2); font-size: var(--fz-s); font-weight: 500; transition: background-color .15s ease, color .15s ease; }
/* the shared shortcut to the next room is navigation, like the switcher beside it; the project's own next step is the
   readout's filled button, the only accent action on the page */
.pl-bar:not(.wc-head) .workspace-next { border-color: var(--rule-2); background: transparent; color: var(--ink-2); font-weight: 500; transition: background-color .15s ease, color .15s ease; }
.pl-bar:not(.wc-head) .workspace-next > svg { color: var(--ink-3); }
.pl-bar:not(.wc-head) .workspace-jump > summary { color: var(--ink-2); transition: background-color .15s ease, color .15s ease; }

/* the whole bar on one row, only when projects.js measured that it fits */
.pl[data-bar="inline"] .pl-bar:not(.wc-head) { flex-wrap: nowrap; }
.pl[data-bar="inline"] .pl-title { flex: 0 0 auto; }
.pl[data-bar="inline"] .pl-title h1 { white-space: nowrap; }
.pl[data-bar="inline"] .pl-bar:not(.wc-head) > .workspace-flow[data-embedded] {
  order: 3; flex: 1 0 auto; width: auto; min-width: 0; margin: 0;
  padding: 0 0 0 .75rem; border-top: 0; border-inline-start: 1px solid var(--rule);
}
.pl[data-bar="inline"] .pl-bar:not(.wc-head) .workspace-rail { flex-wrap: nowrap; }
.pl[data-bar="inline"] .pl-bar:not(.wc-head) .workspace-rail > a { white-space: nowrap; }

/* stacked: one identity row (home, title, presentation) above the workspace row. The title gives way and wraps before
   the presentation controls are pushed onto a half-empty row of their own. */
.pl[data-layout="stack"] .pl-bar:not(.wc-head) { column-gap: .5rem; }
.pl[data-layout="stack"] .pl-title { flex: 1 1 5rem; }
.pl[data-layout="stack"] .pl-title h1 { text-wrap: balance; }
.pl[data-layout="stack"] .pl-prefs { flex: 0 0 auto; gap: .375rem; margin-inline-start: auto; }
.pl[data-layout="stack"] .pl-lang { padding-inline: .625rem .25rem; }
.pl[data-layout="stack"] .pl-modes { display: none; }
.pl[data-layout="stack"] #plThemeLabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pl[data-layout="stack"] .pl-theme { min-width: var(--hit); padding: .5rem; }
@media (max-width: 26rem) {
  .pl-home { min-width: var(--hit); padding: .5rem; justify-content: center; }
  .pl-home > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---- the table: drawer | map + ledger */
.pl-main { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; overflow-x: clip; }
.pl[data-layout="split"] .pl-main { grid-template-columns: clamp(18rem, 18%, 25rem) minmax(0, 1fr); min-height: calc(100dvh - var(--bar-h)); }
.pl[data-layout="split"][data-scale="wide"] .pl-main { grid-template-columns: clamp(20rem, 18%, 28rem) minmax(0, 1fr); }
.pl:is([data-state="empty"], [data-state="error"]) .pl-main { grid-template-columns: minmax(0, 1fr); }
.pl:is([data-state="empty"], [data-state="error"]) .pl-index { display: none; }

/* ---- drawer: the catalogue */
.pl-index { min-width: 0; }
.pl[data-layout="split"] .pl-index {
  position: sticky; top: var(--bar-h); height: calc(100dvh - var(--bar-h)); overflow: auto; overscroll-behavior: contain;
  background: var(--plate); border-inline-end: 1px solid var(--rule); scrollbar-width: thin; scrollbar-gutter: stable;
}
.pl-index-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem;
  padding: 1rem var(--gut-i) .875rem; background: var(--plate); border-bottom: 1px solid var(--rule);
}
.pl[data-layout="split"] .pl-index-head { position: sticky; top: 0; z-index: 2; }
.pl-index-head h2 { display: flex; align-items: baseline; gap: .5rem; font: 600 var(--fz-m)/1.3 var(--f-ui); }
.pl-count { color: var(--ink-3); font: 500 var(--fz-xs)/1 var(--f-num); }
.pl-count:empty { display: none; }
.pl-sync { display: none; flex-basis: 100%; align-items: center; gap: .5rem; color: var(--ink-2); font-size: var(--fz-xs); }
.pl[data-refreshing] .pl-sync { display: flex; }
.pl-list { margin: 0; padding: 0; list-style: none; }

.pr {
  position: relative; display: grid; grid-template-columns: var(--thumb) minmax(0, 1fr); align-items: start; gap: .875rem;
  width: 100%; padding: var(--row) var(--gut-i); border: 0; border-bottom: 1px solid var(--rule);
  background: transparent; color: var(--ink); text-align: start; cursor: pointer; transition: background-color .15s ease;
}
.pr::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: .1875rem;
  background: var(--signal); opacity: 0; transition: opacity .15s ease;
}
.pr[aria-pressed="true"] { background: var(--field); }
.pr[aria-pressed="true"]::before { opacity: 1; }
.pr:focus-visible { outline-offset: -2px; }
.pr-thumb, .ds-frame {
  background-color: var(--field);
  background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px);
}
.pr-thumb {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden;
  border: 1px solid var(--rule-2); border-radius: .25rem; background-size: .625rem .625rem; color: var(--ink-3);
}
.pr-thumb img {
  position: absolute; inset: .25rem; width: calc(100% - .5rem); height: calc(100% - .5rem);
  object-fit: contain; opacity: 0; transition: opacity .2s ease;
}
.pr-thumb[data-img="ready"] img { opacity: 1; }
.pr-thumb[data-img="ready"] > .pl-ic { visibility: hidden; }
.pr-thumb[data-img="error"] img { display: none; }
.pr-body { display: grid; gap: .25rem; min-width: 0; }
.pr-name { font: 600 var(--fz-m)/1.3 var(--f-ui); overflow-wrap: anywhere; }
.pr-meta { color: var(--ink-2); font-size: var(--fz-s); line-height: 1.4; }
/* runs of facts: every item carries its own leading dot inside a clipped strip, so the dot of an item that starts a
   line falls outside the strip and a wrapped line never opens with a separator */
:is(.pr-meta, .ds-cap-meta, .ws-meta) { display: block; min-width: 0; overflow: hidden; }
.dots { display: flex; flex-wrap: wrap; margin-inline-start: -1.125rem; }
.dots > * { min-width: 0; overflow-wrap: anywhere; }
.dots > *::before { content: "·"; display: inline-block; width: 1.125rem; color: var(--ink-3); font-weight: 400; text-align: center; }
.pr-line { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .625rem; margin-top: .125rem; }
.pr-tally { color: var(--ink-2); font: 500 var(--fz-xs)/1 var(--f-num); }
.pr-go { display: none; align-self: center; color: var(--ink-3); }
.pl[data-layout="stack"] .pr { grid-template-columns: calc(var(--thumb) + 1rem) minmax(0, 1fr) auto; }
.pl[data-layout="stack"] .pr-go { display: block; }

.pr-tag {
  display: inline-flex; align-items: center; gap: .375rem; padding: .125rem .5rem;
  border: 1px solid var(--rule-2); border-radius: 999px; color: var(--ink-2); font: 600 var(--fz-xs)/1.3 var(--f-ui);
}
.pr-tag::before { content: ""; flex: none; width: .4375rem; height: .4375rem; border-radius: 50%; background: var(--ok); }

/* readiness ticks. The counted cells come first, as many as the tally's denominator: done is filled, needed is a solid
   warn box. Behind a tick follow the checks outside the count (alignment, anything unreported): open, dashed, never
   filled — so they read as neither done nor needed. */
.meter { display: inline-flex; align-items: center; gap: .1875rem; }
.meter-req, .meter-extra { display: contents; }
.meter i { flex: none; width: 1rem; height: .375rem; border-radius: 1px; background: var(--plate-2); }
.meter i[data-s="done"] { background: var(--ok); }
.meter i[data-s="missing"] { background: transparent; box-shadow: inset 0 0 0 1.5px var(--warn); }
.meter :is(.meter-extra i, i[data-s="unknown"]) { background: transparent; border: 1px dashed var(--ink-3); box-shadow: none; }
.meter-extra::before { content: ""; flex: none; align-self: stretch; width: 1px; margin: -.1875rem .1875rem; background: var(--ink-3); opacity: .6; }
.meter-req:empty + .meter-extra::before { display: none; }
.meter.is-wide { display: flex; width: 100%; gap: .25rem; }
.meter.is-wide i { flex: 1 1 0; height: .5rem; }

/* ---- dossier: one grid, rearranged by the room it has */
.pl-dossier { container: ds / inline-size; min-width: 0; }
.ds { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "back" "head" "next" "map" "st" "work" "more"; }
.ds-plate, .ds-ledger { display: contents; }
.ds-back-bar { grid-area: back; display: none; }
.ds-head { grid-area: head; }
.ds-map { grid-area: map; }
.ds-next { grid-area: next; }
.ds-stations { grid-area: st; }
.ds-work { grid-area: work; }
.ds-more { grid-area: more; }

.ds-head { display: grid; align-content: start; gap: .5rem; min-width: 0; padding: 1.5rem var(--gut) 1rem; }
.ds-tags { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .625rem; color: var(--ink-3); font-size: var(--fz-xs); font-weight: 600; }
.ds-head h2 { font: 600 var(--fz-xl)/1.18 var(--f-display); letter-spacing: 0; overflow-wrap: anywhere; text-wrap: balance; }
.ds-figs { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; color: var(--ink-2); font-size: var(--fz-s); }
.ds-figs b { color: var(--ink); font-family: var(--f-num); font-weight: 600; }
.ds-notice {
  display: flex; align-items: flex-start; gap: .5rem; margin-top: .25rem; padding: .625rem .75rem;
  border: 1px solid color-mix(in oklab, var(--warn) 45%, transparent); border-radius: var(--r);
  background: color-mix(in oklab, var(--warn) 10%, transparent); font-size: var(--fz-s);
}
.ds-notice .pl-ic { margin-top: .125rem; color: var(--warn); }

/* the map, whole: contained on a measured grid, never cropped */
.ds-map { min-width: 0; padding: 0 var(--gut) 1.25rem; }
.ds-frame {
  position: relative; width: 100%; aspect-ratio: var(--ar, 4 / 3); min-height: 12rem; max-height: 72dvh; overflow: hidden;
  border: 1px solid var(--rule-2); border-radius: var(--r); background-size: 2.5rem 2.5rem; background-position: -1px -1px;
}
.ds-frame::before {
  content: ""; position: absolute; inset: .625rem; pointer-events: none;
  --c: var(--ink-3); --l: .875rem;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) 1px, linear-gradient(var(--c), var(--c)) top left / 1px var(--l),
    linear-gradient(var(--c), var(--c)) top right / var(--l) 1px, linear-gradient(var(--c), var(--c)) top right / 1px var(--l),
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) 1px, linear-gradient(var(--c), var(--c)) bottom left / 1px var(--l),
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) 1px, linear-gradient(var(--c), var(--c)) bottom right / 1px var(--l);
  background-repeat: no-repeat;
}
.ds-frame img {
  position: absolute; inset: 1.5rem; width: calc(100% - 3rem); height: calc(100% - 3rem);
  object-fit: contain; opacity: 0; transition: opacity .24s var(--ease-out);
}
.ds-frame[data-img="ready"] img { opacity: 1; }
.ds-frame[data-img="error"] img { visibility: hidden; }
.ds-noimg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .625rem;
  padding: 1rem; color: var(--ink-3); font-size: var(--fz-s); text-align: center;
}
.ds-noimg > .pl-ic { width: 2rem; height: 2rem; stroke-width: 1.4; }
.ds-noimg > :is(.is-load, .is-err, [data-img-retry]) { display: none; }
.ds-frame[data-img="loading"] .is-load { display: block; }
.ds-frame[data-img="error"] .is-err { display: block; color: var(--ink); font-weight: 600; }
.ds-frame[data-img="error"] [data-img-retry] { display: inline-flex; }
.ds-frame[data-img="error"] .ds-noimg > .pl-ic { color: var(--alert); }
.ds-frame[data-img="ready"] .ds-noimg { display: none; }
.ds-cap { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; padding-top: .5rem; color: var(--ink-2); font-size: var(--fz-s); }
.ds-cap-meta { flex: 1 1 14rem; }
.ds-cap-meta .dots { align-items: baseline; }
.ds-dims, .ds-scale { font-family: var(--f-num); font-size: var(--fz-xs); }
.ds-dims:empty { display: none; }
.ds-full {
  display: inline-flex; align-items: center; gap: .375rem; min-height: 2.5rem; margin-inline-start: auto; padding: 0 .625rem;
  border-radius: var(--r); color: var(--ink); font-weight: 600; text-decoration: none; transition: background-color .15s ease;
}

/* the readout: what is reported ready, and the one step that comes next. A raised sheet in the page's own scheme (the
   white field under an ink top rule in light, the scope's near black in dark), so it never reads as a dark block left
   in the light page */
.ds-next {
  container: next / inline-size;
  margin: 0 var(--gut) 1.25rem; padding: 1.125rem 1.25rem 1.25rem;
  border: 1px solid var(--rule-2); border-radius: .5rem; background: light-dark(var(--field), var(--scope)); color: var(--ink);
  box-shadow: inset 0 2px 0 light-dark(var(--ink), transparent);
}
.ds-ready { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: .875rem .75rem; }
.ds-ready.is-unreported { grid-template-columns: minmax(0, 1fr); }
.ds-ready > .meter { grid-column: 1 / -1; }
.ds-tally { color: var(--ink); font: 600 var(--fz-xxl)/1 var(--f-num); letter-spacing: 0; white-space: nowrap; }
.ds-tally > span { margin-inline-start: .25em; color: var(--ink-3); font-size: .5em; font-weight: 500; letter-spacing: 0; }
.ds-ready-k { color: var(--ink-2); font-size: var(--fz-s); line-height: 1.3; }
/* the legend for the dashed cells: which checks stand outside the count, by name */
.ds-ready-x { grid-column: 1 / -1; display: flex; align-items: baseline; gap: .5rem; margin-top: -.375rem; color: var(--ink-2); font-size: var(--fz-xs); line-height: 1.4; }
.ds-ready-x > i { flex: none; width: 1rem; height: .5rem; border: 1px dashed var(--ink-3); border-radius: 1px; }
.ds-act { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.ds-act-k { margin-bottom: .625rem; color: var(--ink-2); font-size: var(--fz-xs); font-weight: 600; letter-spacing: 0; }
.pl-btn.ds-cta { justify-content: flex-start; gap: .75rem; width: 100%; min-height: 3.25rem; padding: .75rem 1rem; font-size: var(--fz-m); }
.ds-cta > span { flex: 1 1 auto; min-width: 0; text-wrap: balance; }
.ds-cta-go { transition: transform .15s var(--ease-out); }
@container next (max-width: 18rem) {
  .ds-ready { grid-template-columns: minmax(0, 1fr); }
  .ds-ready-k { overflow-wrap: anywhere; }
  .pl-btn.ds-cta { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: .5rem; }
  .ds-cta > .ds-cta-go { display: none; }
}

/* ---- ledger sections */
.ds-sect { min-width: 0; padding: 1.25rem var(--gut) 1.5rem; border-top: 1px solid var(--rule); }
.ds-h { font: 600 var(--fz-m)/1.3 var(--f-ui); }
.ds-stations > .ds-h, .ds-more > .ds-h { margin-bottom: .5rem; }
.ds-h-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem .75rem; margin-bottom: .5rem; }
.ds-count { margin-inline-start: .5rem; color: var(--ink-3); font: 500 var(--fz-xs)/1 var(--f-num); }

/* preparation as a track: one node per stage, the line turns green behind what is done. The rows share one column grid
   (subgrid), so every status lines up in one column and every command in another, whatever the language. */
.ds-stations { container: st / inline-size; }
.st-list { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto auto; column-gap: .875rem; margin: 0; padding: 0; list-style: none; }
.st {
  position: relative; grid-column: 1 / -1; display: grid; align-items: start;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto auto; grid-template-columns: subgrid; column-gap: .875rem;
  padding-block: var(--row);
}
.st-node { grid-column: 1; grid-row: 1; }
.st-body { grid-column: 2; grid-row: 1; align-self: first baseline; }
.st-state { grid-column: 3; grid-row: 1; align-self: first baseline; }
.st-act { grid-column: 4; grid-row: 1; }
.st::after {
  content: ""; position: absolute; inset-inline-start: calc(.75rem - 1px);
  top: calc(var(--row) + 1.3125rem); bottom: calc(-1 * var(--row) - .1875rem); width: 2px; background: var(--rule-2);
}
.st:last-child::after { display: none; }
.st[data-state="done"]::after { background: var(--ok); }
.st-node {
  position: relative; z-index: 1; display: grid; place-items: center;
  width: 1.125rem; height: 1.125rem; margin: .1875rem auto 0; border: 2px solid var(--ink-3); border-radius: 50%;
}
.st[data-state="done"] .st-node { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.st[data-state="missing"] .st-node { border-color: var(--warn); }
.st[data-state="unknown"] .st-node { border-style: dashed; }
.st-check { width: .75rem; height: .75rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* the next row's wash bleeds to the section edges without moving the shared columns (border-image outset paints only) */
.st.is-next { border-image: linear-gradient(90deg, var(--wash), transparent 85%) 0 fill / 0 / 0 var(--gut); }
.st.is-next::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: calc(-1 * var(--gut)); width: .1875rem; background: var(--signal); }
.st.is-next .st-node { background: var(--signal); border-color: var(--ink); color: var(--on-signal); }
.st-body { min-width: 0; }
.st-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .125rem .625rem; }
.st-name { font-size: var(--fz-m); font-weight: 600; }
.st-kind { color: var(--ink-3); font-size: var(--fz-xs); }
.st-state { color: var(--ink-3); font-size: var(--fz-xs); font-weight: 600; white-space: nowrap; }
.st[data-state="done"] .st-state { color: var(--ok); }
.st[data-state="missing"] .st-state { color: var(--warn); }
.st.is-next .st-state { color: var(--ink); }
.st.is-next .st-state::before {
  content: ""; display: inline-block; width: .5rem; height: .5rem; margin-inline-end: .375rem; vertical-align: .0625em;
  border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 1px color-mix(in oklab, var(--ink) 40%, transparent);
}
.st-detail { margin-top: .125rem; color: var(--ink-2); font-size: var(--fz-s); text-wrap: pretty; }
/* commands share one width in their column, icon and verb starting on the same line */
.st-act { align-self: start; margin-top: -.25rem; }
.st-act > .pl-btn { width: 100%; justify-content: flex-start; }
@container st (max-width: 24rem) {
  .st-list { grid-template-columns: 1.5rem minmax(0, 1fr) auto; }
  .st { grid-template-columns: 1.5rem minmax(0, 1fr) auto; grid-template-columns: subgrid; }
  .st-act { grid-column: 2 / -1; grid-row: 2; justify-self: start; margin-top: .5rem; }
  .st-act > .pl-btn { width: auto; }
}

/* access workspaces */
.ds-work { container: work / inline-size; }
.ws-list { margin: 0; padding: 0; list-style: none; }
.ws { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) auto; align-items: center; gap: .75rem; padding: .75rem 0; }
.ws + .ws { border-top: 1px solid var(--rule); }
.ws-glyph { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: var(--r); background: var(--plate-2); color: var(--ink-2); }
.ws[data-ready="true"] .ws-glyph { background: color-mix(in oklab, var(--ok) 16%, transparent); color: var(--ok); }
.ws-body { display: grid; gap: .125rem; min-width: 0; }
.ws-body b { font-weight: 600; overflow-wrap: anywhere; }
.ws-body small { color: var(--ink-2); font-size: var(--fz-s); line-height: 1.4; }
.ws[data-ready="true"] .ws-state { color: var(--ok); font-weight: 600; }
@container work (max-width: 22rem) {
  .ws { grid-template-columns: 2.25rem minmax(0, 1fr); }
  .ws > .pl-btn { grid-column: 1 / -1; justify-self: start; max-width: 100%; }
}
.ws-msg { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding-block: .25rem; color: var(--ink-2); font-size: var(--fz-s); }
.ws-msg > span:not(.pl-spin) { flex: 1 1 14rem; min-width: 0; }
.ws-msg[data-tone="error"] {
  padding: .75rem; border: 1px solid color-mix(in oklab, var(--alert) 45%, transparent); border-radius: var(--r);
  background: color-mix(in oklab, var(--alert) 8%, transparent); color: var(--ink);
}
.ws-msg[data-tone="error"] > .pl-ic { color: var(--alert); }

/* more doors for this project */
.doors { margin: 0 calc(-1 * var(--gut)); padding: 0; list-style: none; }
.door {
  display: grid; grid-template-columns: var(--ic) minmax(0, 1fr) auto; align-items: center; gap: .875rem;
  min-height: 3.5rem; padding: .625rem var(--gut); border-top: 1px solid var(--rule);
  color: var(--ink); text-decoration: none; transition: background-color .15s ease;
}
.doors > li:first-child .door { border-top: 0; }
.door > .pl-ic:first-child { color: var(--ink-2); }
.door:focus-visible { outline-offset: -2px; }
.door-t { display: grid; gap: .125rem; min-width: 0; }
.door-t b { font-weight: 600; }
.door-t small { color: var(--ink-2); font-size: var(--fz-s); }
.door-go { color: var(--ink-3); transition: transform .15s var(--ease-out), color .15s ease; }
.pl-mobile-modes { display: none; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.pl[data-layout="stack"] .pl-mobile-modes { display: flex; }

/* ---- the dossier at its own width */
@container ds (min-width: 48rem) and (max-width: 59.99rem) {
  .ds {
    grid-template-columns: minmax(0, 1fr) minmax(17rem, 21rem); grid-template-rows: repeat(4, auto) 1fr;
    grid-template-areas: "back back" "head next" "map map" "st work" "st more";
  }
  .ds-next { align-self: start; margin: 1.5rem var(--gut) 1rem 0; }
  .ds-stations { border-inline-end: 1px solid var(--rule); }
}
@container ds (min-width: 60rem) {
  .ds { grid-template-columns: minmax(0, 1fr) clamp(25rem, 30%, 34rem); grid-template-areas: "back back" "plate ledger"; }
  .ds-plate { grid-area: plate; display: flex; flex-direction: column; min-width: 0; align-self: start; }
  .ds-ledger { grid-area: ledger; display: block; min-width: 0; align-self: stretch; background: var(--plate); border-inline-start: 1px solid var(--rule); }
  .ds-head { padding: 1.25rem var(--gut) .875rem; }
  .ds-next { margin: var(--gut); }
  .pl[data-scale="wide"] .ds { grid-template-columns: minmax(0, 1fr) clamp(28rem, 28%, 38rem); }
  /* split: the map plate holds still at the window's height while the ledger scrolls past it */
  .pl[data-layout="split"] .ds-plate { position: sticky; top: var(--bar-h); height: calc(100dvh - var(--bar-h)); overflow: auto; scrollbar-width: thin; }
  .pl[data-layout="split"] .ds-ledger { min-height: calc(100dvh - var(--bar-h)); }
  .pl[data-layout="split"] .ds-map { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
  .pl[data-layout="split"] .ds-frame { flex: 1 1 auto; aspect-ratio: auto; max-height: none; min-height: 16rem; }
}

/* ---- states: loading outline, empty, error */
.pl-state {
  display: grid; justify-items: center; align-content: center; gap: .75rem;
  width: min(100%, 38rem); min-height: 60dvh; margin-inline: auto; padding: 3rem var(--gut); text-align: center;
}
.pl[data-layout="split"] .pl-state { min-height: calc(100dvh - var(--bar-h)); }
.pl-state-ic { display: grid; place-items: center; width: 3.25rem; height: 3.25rem; border-radius: 50%; background: var(--plate-2); color: var(--ink-2); }
.pl-state-ic .pl-ic { width: 1.5rem; height: 1.5rem; }
.pl-state[data-tone="alert"] .pl-state-ic { background: color-mix(in oklab, var(--alert) 14%, transparent); color: var(--alert); }
.pl-state h3 { font: 600 var(--fz-xl)/1.25 var(--f-display); text-wrap: balance; }
.pl-state p { max-width: 34em; color: var(--ink-2); text-wrap: pretty; }
.pl-state-code { padding: .25rem .5rem; border-radius: .25rem; background: var(--plate-2); color: var(--ink-2); font: var(--fz-xs)/1.4 var(--f-num); overflow-wrap: anywhere; }
.pl-state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: .5rem; }

.sk { display: block; border-radius: .25rem; background: var(--plate-2); animation: pl-breathe 1.6s ease-in-out infinite; }
.pr-skel { display: grid; grid-template-columns: var(--thumb) minmax(0, 1fr); gap: .875rem; padding: var(--row) var(--gut-i); border-bottom: 1px solid var(--rule); }
.pr-skel:nth-child(2) .sk { animation-delay: .12s; }
.pr-skel:nth-child(3) .sk { animation-delay: .24s; }
.pr-skel .pr-body { gap: .5rem; padding-top: .25rem; }
.sk-thumb { aspect-ratio: 4 / 3; }
.sk-line { width: 85%; height: .75rem; }
.sk-line.is-short { width: 50%; }
.sk-line.is-tiny { width: 30%; }
.sk-title { width: 60%; height: 1.75rem; }
.sk-fill { position: absolute; inset: 1.5rem; }
.sk-num { width: 7rem; height: 2.5rem; }
.sk-cta { height: 3.25rem; }
.sk-row { height: 3rem; margin-top: .75rem; }
.is-skeleton .ds-head { gap: .75rem; }
.is-skeleton .ds-next { display: grid; gap: .875rem; }
.pl-spin { display: inline-block; flex: none; width: 1em; height: 1em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: pl-spin .8s linear infinite; }

/* ---- stacked: list, then one project with a visible way back */
.pl[data-layout="stack"][data-view="list"]:not([data-state="error"], [data-state="empty"]) .pl-dossier { display: none; }
.pl[data-layout="stack"][data-view="detail"] .pl-index { display: none; }
.pl[data-layout="stack"] .ds-back-bar {
  position: sticky; top: 0; z-index: 6; display: block; padding: .375rem calc(var(--gut) - .5rem);
  background: color-mix(in oklab, var(--plate) 94%, transparent); border-bottom: 1px solid var(--rule);
}
.pl[data-layout="stack"] .ds-head { padding-top: 1.125rem; }
.pl[data-layout="stack"] .ds :is(a, button, select) { scroll-margin-block-start: calc(var(--hit) + 1.75rem); }

/* ---- pointer feedback, fine pointers only */
@media (hover: hover) and (pointer: fine) {
  :is(.pl-btn, .pl-add, .pl-theme, .pl-prefs > .noise-settings-entry):hover { background: var(--plate-2); border-color: var(--ink-3); }
  .pl-btn.is-primary:hover { background: color-mix(in oklab, var(--signal) 84%, #121412); border-color: color-mix(in oklab, #121412 30%, var(--signal)); }
  .pl-btn.is-quiet:hover { background: var(--plate-2); border-color: transparent; color: var(--ink); }
  .pl-btn.is-primary:hover .ds-cta-go { transform: translateX(.1875rem); }
  .pl-home:hover { background: var(--plate-2); border-color: var(--ink-3); color: var(--ink); }
  .pl-modes a:hover { background: var(--plate-2); color: var(--ink); }
  .pl-bar:not(.wc-head) .workspace-rail > a:hover { background: var(--plate-2); border-color: transparent; color: var(--ink); }
  .pl-bar:not(.wc-head) :is(.workspace-next, .workspace-jump > summary):hover { background: var(--plate-2); color: var(--ink); }
  .pr:hover { background: var(--plate-2); }
  .pr[aria-pressed="true"]:hover { background: var(--field); }
  .door:hover { background: var(--plate-2); }
  .door:hover .door-go { transform: translateX(.125rem); color: var(--ink); }
  .ds-full:hover { background: var(--plate-2); }
}
/* the current workspace in the shared rail (after hover, so it keeps its mark under the pointer) */
.pl-bar:not(.wc-head) .workspace-rail > a[aria-current="page"] { background: color-mix(in oklab, var(--ok) 12%, var(--field)); border-color: var(--ok); color: var(--ink); font-weight: 600; }
.pl-bar:not(.wc-head) .workspace-rail > a[aria-current="page"] > svg { color: var(--ok); }

/* ---- motion: short, ease-out, transform and opacity only */
@keyframes pl-rise { from { opacity: 0; transform: translateY(.5rem); } }
@keyframes pl-push { from { opacity: 0; transform: translateX(1.25rem); } }
@keyframes pl-fade { from { opacity: 0; } }
@keyframes pl-breathe { 50% { opacity: .5; } }
@keyframes pl-spin { to { transform: rotate(1turn); } }
.pl[data-layout="split"] .ds.is-entering { animation: pl-rise .24s var(--ease-out); }
.pl[data-layout="stack"][data-view="detail"] .pl-dossier { animation: pl-push .28s var(--ease-out); }
.pl[data-layout="stack"][data-view="list"] .pl-index { animation: pl-fade .2s ease-out; }
:root:is([data-motion="reduced"], [data-noise-motion="reduced"]) :is(.pl[data-layout="split"] .ds.is-entering, .pl[data-layout="stack"][data-view="detail"] .pl-dossier) { animation: pl-fade .2s ease-out; }
:root:is([data-motion="reduced"], [data-noise-motion="reduced"]) .sk { animation: none; }
:root:is([data-motion="reduced"], [data-noise-motion="reduced"]) .pl-spin { animation: pl-breathe 1.2s ease-in-out infinite; }
:root:is([data-motion="reduced"], [data-noise-motion="reduced"]) :is(.pl-btn, .pl-add, .pl-theme):active { transform: none; }
:root:is([data-motion="reduced"], [data-noise-motion="reduced"]) :is(.door-go, .ds-cta-go) { transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-noise-motion="full"]) :is(.pl[data-layout="split"] .ds.is-entering, .pl[data-layout="stack"][data-view="detail"] .pl-dossier) { animation: pl-fade .2s ease-out; }
  :root:not([data-noise-motion="full"]) .sk { animation: none; }
  :root:not([data-noise-motion="full"]) :is(.pl-btn, .pl-add, .pl-theme):active { transform: none; }
  :root:not([data-noise-motion="full"]) :is(.door-go, .ds-cta-go) { transform: none !important; }
}
:root[data-noise-motion="static"] :is(.pl, .pl *, .pl *::before, .pl *::after) { animation: none !important; transition: none !important; }

/* ---- forced colours: selection, the next step and readiness keep their shape without colour */
@media (forced-colors: active) {
  .pr[aria-pressed="true"], .st.is-next { outline: 2px solid Highlight; outline-offset: -2px; }
  .st.is-next { border-image: none; }
  .ds-next { border-color: CanvasText; }
  .st::after { background: CanvasText; }
  .st-node { forced-color-adjust: none; border-color: CanvasText; background: Canvas; color: CanvasText; }
  .st[data-state="done"] .st-node { background: CanvasText; color: Canvas; }
  .meter { forced-color-adjust: none; }
  .meter i { border: 1px solid CanvasText; background: Canvas; box-shadow: none; opacity: 1; }
  .meter i[data-s="done"] { background: CanvasText; }
  .meter :is(.meter-extra i, i[data-s="unknown"]) { border: 1px dashed CanvasText; background: Canvas; }
  .meter-extra::before { background: CanvasText; opacity: 1; }
  .ds-ready-x > i { border-color: CanvasText; }
  .ds-frame img, .pr-thumb img { opacity: 1; }
}

/* The room owns Home and interface modes; page preferences remain reachable. */
:root[data-lab-host] :is(.pl-home, .pl-modes, .pl-mobile-modes) { display: none; }

.pl-noscript { margin: 0; padding: 1.5rem; font: 1rem/1.5 var(--f-ui); }
