/* The main app's frame (design/ui-layout.md): a top bar, the program on the left, the stage in
   the middle with its caption under it, the output on the right, and the player (the moments,
   the controls) along the whole bottom; on a phone, the stage on top, time under it, and a bottom
   sheet with the rest. The page itself never scrolls; each panel scrolls inside itself. Colours from css/theme.css, components from css/ui.css and
   css/components.css, drawings from css/views.css. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--md-on-surface);
  background: var(--md-surface);
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
select { padding: 4px 8px; border-radius: var(--radius-s); border: 1px solid var(--md-outline-variant); background: var(--md-surface-high); }
[hidden] { display: none !important; }

/* ---- the frame: desktop ------------------------------------------------------------------- */
.app { display: grid; grid-template-rows: 56px minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); height: 100dvh; }
.app.desktop { grid-template-rows: 56px minmax(0, 1fr) auto; }
.work {
  display: grid;
  grid-template-columns: var(--left, 320px) 1px minmax(0, 1fr) 1px var(--right, 340px);
  min-height: 0;
}
.work.left-closed { grid-template-columns: var(--rail) 1px minmax(0, 1fr) 1px var(--right, 340px); }
.work.right-closed { grid-template-columns: var(--left, 320px) 1px minmax(0, 1fr) 1px var(--rail); }
.work.left-closed.right-closed { grid-template-columns: var(--rail) 1px minmax(0, 1fr) 1px var(--rail); }
.app { --rail: 52px; }
/* the edges: 1 px drawn, 11 px to grab; blue while hovered, dragged or focused */
.edge { position: relative; z-index: 6; background: var(--md-outline-variant); cursor: col-resize; touch-action: none; outline: none; transition: background 120ms var(--ease); }
.edge::before { content: ""; position: absolute; inset: 0 -5px; }
.edge:hover, .edge:focus-visible, .edge:active { background: var(--md-primary); }
/* focused by the keyboard, a bar 5 px wide, not only the 1 px line in another colour */
.edge:focus-visible::after { content: ""; position: absolute; inset: 0 -2px; background: var(--md-primary); border-radius: 2px; }
body.resizing { cursor: col-resize; }
body.resizing .stage { pointer-events: none; }
/* a closed panel is a rail, with the button that opens it */
.panel .rail { display: none; }
.panel.closed > :not(.rail) { display: none !important; }
.panel.closed > .rail { display: inline-flex; align-self: center; margin-top: 8px; }

/* ---- the top bar ---------------------------------------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 4px; padding: 0 8px 0 12px; background: var(--md-surface-low); border-bottom: 1px solid var(--md-outline-variant); min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--md-on-surface); text-decoration: none; font-size: 16px; font-weight: 620; margin-right: 12px; }
.brand img { width: 40px; height: 32px; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.workspaces { display: flex; align-self: stretch; }
.workspaces .tab { flex: none; padding: 0 16px; font-size: 14px; }
.topbar .btn.has-icon { color: var(--md-on-surface-variant); }
.lang-btn { gap: 6px; padding: 0 10px; font-weight: 600; }

/* ---- the panels beside the stage -------------------------------------------------------------- */
.panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--md-surface-low); }
.panel-head { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 4px 6px 4px 14px; border-bottom: 1px solid var(--md-outline-variant); background: var(--md-surface-mid); }
.panel-head h2 { flex: 1; margin: 0; font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--md-on-surface-variant); white-space: nowrap; }
.panel-head .btn.icon-only { width: 34px; height: 34px; }
.panel-head .icon { width: 18px; height: 18px; }
.bench-slot { flex: 0 0 auto; height: clamp(150px, 26%, 230px); padding: 8px 10px 0; }
.chain-slot { flex: 1 1 auto; min-height: 0; }
.cloth-slot { flex: 1 1 auto; min-height: 0; }
.trace-slot { flex: 0 0 auto; max-height: 40%; overflow: auto; border-top: 1px solid var(--md-outline-variant); }
.seg { display: inline-flex; border: 1px solid var(--md-outline-variant); border-radius: var(--radius-full); overflow: hidden; }
.seg button { white-space: nowrap; border: 0; background: transparent; padding: 4px 12px; font-size: 12px; font-weight: 560; color: var(--md-on-surface-variant); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.seg button + button { border-left: 1px solid var(--md-outline-variant); }
/* the ring inside the button: the group's rounded clip would cut it off outside */
.seg button:focus-visible { outline-offset: -3px; }

/* ---- the stage: one, two or four panes, each one view ------------------------------------------- */
.stage { position: relative; display: grid; gap: 1px; min-width: 0; min-height: 0; background: var(--md-outline-variant); }
.stage[data-n="1"] { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.stage[data-n="2"] { grid-template: minmax(0, 1fr) / repeat(2, minmax(0, 1fr)); }
.stage[data-n="4"] { grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); }
.pane { position: relative; display: flex; min-width: 0; min-height: 0; background: var(--stage-bg); }
.pane-host { flex: 1; min-width: 0; min-height: 0; display: flex; }
/* a 2D drawing keeps clear of the tools floating over its top edge (the 3D view goes under them) */
.pane-host.view:has(> svg) { padding-top: 52px; }
.app:not(.desktop) .pane-host.view:has(> svg) { padding-top: 46px; }
.pane-host.view { border-radius: 0; }
.pane-tools, .stage-tools, .stage-foot { position: absolute; display: flex; align-items: center; gap: 6px; pointer-events: none; z-index: 3; }
.pane-tools > *, .stage-tools > *, .stage-foot > * { pointer-events: auto; }
.pane-tools { top: 10px; left: 10px; right: 10px; flex-wrap: wrap; }
.stage-tools { top: 10px; right: 10px; }
.stage-foot { left: 10px; bottom: 10px; }
.chip.view-chip { padding-right: 6px; color: var(--md-on-surface); font-weight: 600; }
.chip .chev { width: 18px; height: 18px; }
.chip-row { display: inline-flex; }
.chip-row .chip { border-radius: 0; padding: 0 8px; }
.chip-row .chip:first-child { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.chip-row .chip:last-child { border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.chip-row .chip + .chip { margin-left: -1px; }
.chip select { border: 0; background: transparent; padding: 0; color: inherit; }
.follow-chip { border-color: transparent; background: var(--md-primary-container); color: var(--md-on-primary-container); }

/* ---- time: the caption under the stage; the player along the window's bottom, centred on it ------ */
.centre { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.caption { padding: 8px 18px; border-top: 1px solid var(--md-outline-variant); background: var(--md-surface-low); }
.caption .status-line { padding: 0; font-size: 14px; height: calc(2 * 1.45em); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.player { border-top: 1px solid var(--md-outline-variant); background: var(--md-surface-mid); }
.player .transport { padding: 10px 20px 8px; gap: 8px; }
.player .moments { width: 100%; max-width: 760px; margin: 0 auto; }
@media (max-width: 1279px) {
  .work { --left: 280px; --right: 300px; }
}

/* ---- phones and small tablets: the same components, other slots --------------------------------- */
.appbar { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 8px; height: 52px; background: var(--md-surface-low); border-bottom: 1px solid var(--md-outline-variant); }
.appbar .brand { margin-right: 4px; }
.appbar .spacer { flex: 1; }
.appbar .brand span { display: none; }
.appbar select.ws { font-weight: 620; padding: 6px 8px; }
.app.phone { grid-template-rows: 52px minmax(0, 54fr) auto minmax(0, 46fr); }
.app.phone .stage { grid-template: auto minmax(0, 1fr) / minmax(0, 1fr); gap: 0; background: var(--stage-bg); }
.view-chips { display: flex; gap: 6px; padding: 8px 10px 0; overflow-x: auto; scrollbar-width: none; }
.view-chips .chip { flex: none; }
.app:not(.desktop) .pane-tools { top: 6px; left: 8px; right: 8px; flex-wrap: nowrap; }
.app:not(.desktop) .pane-tools .chip { height: 30px; font-size: 12px; }
.app:not(.desktop) .pane-tools label.chip { min-width: 0; flex: 0 1 auto; overflow: hidden; }
.under-stage { display: flex; flex-direction: column; border-bottom: 1px solid var(--md-outline-variant); }
.under-stage .caption { padding: 6px 12px; }
.under-stage .caption .status-line { font-size: 12.5px; }
.under-stage .player .transport { padding: 8px 12px 6px; gap: 6px; }
/* a phone's stepper is dots only: the caption above it names the moment reached */
.under-stage .moments .name { display: none; }
.under-stage .transport-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
.under-stage .transport .speed { display: none; }
.under-stage .transport .after { width: auto; }
.under-stage .controls { order: -1; gap: 8px; }
.under-stage .controls .btn.icon-only { width: 42px; height: 42px; }
.under-stage .controls .btn.play { width: 50px; height: 50px; }
.under-stage .where { text-align: right; font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* on the narrowest phones there is no room beside the controls for the pick in words: it was cut to "Pick 1 (car…"; the caption above says the moment */
@media (max-width: 359px) { .app.phone .under-stage .where { display: none; } }
.sheet { display: flex; flex-direction: column; min-height: 0; background: var(--md-surface-low); }
.sheet .grab { align-self: center; display: flex; align-items: center; justify-content: center; width: 64px; height: 22px; padding: 0; border: 0; background: transparent; cursor: grab; touch-action: none; }
.sheet .grab span { width: 36px; height: 4px; border-radius: 2px; background: var(--md-outline); }
.app.landscape .sheet .grab { display: none; }
/* the sheet's sizes: a peek shows its tabs; full hides the stage, keeping the controls */
.app.phone[data-sheet="peek"] { grid-template-rows: 52px minmax(0, 1fr) auto 120px; }
.app.phone[data-sheet="full"] { grid-template-rows: 52px auto minmax(0, 1fr); }
.app.phone[data-sheet="full"] > .stage { display: none; }
.app.phone[data-sheet="full"] .under-stage .caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; border: 0; /* out of sight, still heard: its status line is a live region */ }
.sheet .tabs { background: transparent; }
.sheet-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app.landscape { grid-template-rows: 44px minmax(0, 1fr); }
.app.landscape .appbar { height: 44px; }
.app.landscape .land { display: grid; grid-template-columns: minmax(0, 60fr) minmax(0, 40fr); min-height: 0; }
.app.landscape .land-stage { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.app.landscape .land-stage .stage { grid-template: auto minmax(0, 1fr) / minmax(0, 1fr); gap: 0; background: var(--stage-bg); }
.app.landscape .sheet { border-left: 1px solid var(--md-outline-variant); }
.app.landscape .under-stage .caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; border: 0; /* out of sight, still heard: its status line is a live region */ }

/* ---- the setup popover and the about dialog ---------------------------------------------------- */
.popover { position: fixed; z-index: 25; max-height: calc(100dvh - 16px); overflow-y: auto; display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius-m); background: var(--md-surface-highest); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5); }
.popover label { font-size: 12px; color: var(--md-on-surface-variant); }
.popover .btn { justify-self: start; height: 32px; padding: 0 12px; }
/* the two things to choose before punching, alike and side by side: the ready-made decks and the head (on two lines where they do not fit one) */
.setup-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px 0; }
.chip.setup-chip, .chip.decks-chip { max-width: 100%; gap: 6px; padding: 0 8px; color: var(--md-on-surface); }
.chip.setup-chip span, .chip.decks-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.setup-chip .icon, .chip.decks-chip .icon { width: 18px; height: 18px; color: var(--md-on-surface-variant); }
.popover input[type="color"] { width: 44px; height: 28px; padding: 0; border: 1px solid var(--md-outline-variant); border-radius: 6px; background: none; }

/* ---- the guide (Learn): the tutorial's step card above the panel it needs ---------------------- */
/* Learn is a mode: its tab is selected and the stage framed in blue; the step's card says where */
.app[data-ws="learn"] .stage::after { content: ""; position: absolute; inset: 0; z-index: 4; border: 2px solid var(--md-primary); pointer-events: none; }
/* The step stacks from the top: the card, Back and Next right under it, then the cards with all
   the height left. A step longer than its room scrolls, and Back and Next stay at its foot. */
.guide { flex: 0 1 auto; display: flex; min-height: min(220px, 100%); border-bottom: 1px solid var(--md-outline-variant); background: var(--md-surface-mid); }
.panel.left > .guide ~ .bench-slot { height: clamp(110px, 20%, 170px); }
.panel.left > .guide ~ .chain-slot { flex: 1 1 0; min-height: 110px; }
/* where the step does not use the cards (the story), the guide has the panel */
.panel.left.guide-only > :not(.guide):not(.rail) { display: none; }
.panel.left.guide-only > .guide { border-bottom: 0; }
.sheet-body > .guide { border-bottom: 0; }
.guide-box { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.step-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 8px 4px 16px; }
.step-kicker { flex: 1; margin: 0; font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--md-primary); }
.step-head .btn.icon-only { width: 34px; height: 34px; }
.step-head .icon { width: 20px; height: 20px; }
.step-scroll { flex: 0 1 auto; min-height: 0; overflow-y: auto; padding: 0 12px 4px; scrollbar-gutter: stable; }
.step-card { padding: 14px 16px; border: 1px solid var(--card-edge); border-radius: var(--radius-l); background: var(--md-surface-high); }
.step-card h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.3; outline: none; }
.step-card p { margin: 0 0 10px; max-width: 68ch; user-select: text; -webkit-user-select: text; }
.step-lead { padding-bottom: 10px; border-bottom: 1px solid var(--md-outline-variant); color: var(--md-on-surface-variant); font-size: 13px; }
.step-picture { margin: 2px 0 12px; }
.step-picture img { display: block; width: 100%; height: auto; max-height: 300px; object-fit: contain; border-radius: var(--radius-m); background: var(--md-surface-low); }
.step-picture figcaption { margin-top: 6px; font-size: 11.5px; line-height: 1.4; color: var(--md-on-surface-variant); user-select: text; -webkit-user-select: text; }
/* predict, then weave: the question and its choices, then what it says to the answer */
.predict { margin: 4px 0 8px; padding: 0; border: 0; min-width: 0; }
.predict legend { padding: 0; margin-bottom: 8px; font-weight: 600; }
.choice { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; padding: 8px 10px; border: 1px solid var(--md-outline-variant); border-radius: var(--radius-s); cursor: pointer; }
.choice:hover { background: var(--md-surface-highest); }
.choice:has(input:checked) { border-color: var(--md-primary); background: color-mix(in srgb, var(--md-primary) 12%, transparent); }
.choice input { margin: 0; accent-color: var(--md-primary); }
.feedback { font-size: 13px; }
.feedback.right { color: var(--lift); }
.feedback.wrong { color: var(--attention); }
.taskline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 4px 0 10px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--attention-container); color: var(--on-attention-container); font-size: 13px; }
.taskline > .icon { flex: none; width: 20px; height: 20px; }
.taskline .task-text { flex: 1 1 160px; }
.taskline .btn.ask { height: 32px; padding: 0 12px 0 8px; gap: 4px; }
.taskline .btn.ask .icon { width: 18px; height: 18px; }
.taskline.done { background: color-mix(in srgb, var(--lift) 18%, transparent); color: var(--md-on-surface); }
.taskline.done > .icon { color: var(--lift); }
.step-done { padding-left: 12px; border-left: 3px solid var(--lift); }
.step-recap { padding: 10px 12px; border-radius: var(--radius-s); background: var(--md-primary-container); color: var(--md-on-primary-container); font-size: 13px; }
.step-actions { margin-top: 6px; }
.step-nav { flex: none; display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px 12px; }
.step-nav .btn { gap: 2px; }
/* what a step locks is greyed (P6); pressed, it says why in the status line */
.btn.locked, .chip.locked, .chain-end.locked { opacity: 0.38; cursor: not-allowed; }
.locked[data-control="punch"], .locked[data-control="punch"] * { cursor: not-allowed; }
.chip.wanted { box-shadow: 0 0 0 2px var(--attention), 0 0 14px color-mix(in srgb, var(--attention) 45%, transparent); }

/* ---- the About dialog: a title band with its close button, then the body, which scrolls -------- */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-l);
  overflow: hidden;
  background: var(--md-surface-mid);
  color: var(--md-on-surface);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: var(--md-scrim); }
.dialog-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 20px; background: var(--md-surface-high); border-bottom: 1px solid var(--md-outline-variant); }
.dialog-title { margin: 0; font-size: 16px; font-weight: 600; }
.dialog-close { color: var(--md-on-surface-variant); }
.dialog-body { min-height: 0; padding: 20px 24px 22px; overflow-y: auto; user-select: text; -webkit-user-select: text; }
.dialog-body p { color: var(--md-on-surface-variant); margin: 0 0 10px; }
.dialog-body .dialog-name { margin: 0 0 4px; font-size: 22px; font-weight: 600; color: var(--md-on-surface); }
.dialog-body h3 { margin: 18px 0 6px; font-size: 13px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--md-on-surface-variant); }
.dialog-body ul { margin: 0; padding-left: 18px; color: var(--md-on-surface-variant); }
.dialog-body a { color: var(--md-primary); }
.dialog-logo { width: 80px; height: auto; display: block; margin: 0 0 12px; }
.dialog-source { display: flex; align-items: center; gap: 10px; margin-top: 14px !important; }

/* ---- a 3D view's note: which unit it shows, and the idea it teaches -------------------------- */
.unit-note { position: static; }
.unit-note > summary { list-style: none; padding: 0 7px; color: var(--md-on-surface); }
.unit-note > summary::-webkit-details-marker { display: none; }
.unit-note > summary .icon { width: 18px; height: 18px; color: var(--md-primary); }
.unit-note[open] > summary { border-color: transparent; background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.unit-card { position: absolute; top: calc(100% + 6px); left: 0; z-index: 5; width: min(380px, 100%); padding: 12px 14px; border-radius: var(--radius-m); background: var(--md-surface-highest); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5); }
.unit-card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 620; color: var(--md-on-surface); }
.unit-card p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--md-on-surface-variant); user-select: text; -webkit-user-select: text; }

/* the section's zoom: a plain magnifier, no control of its own, marks the chips beside it as a
   zoom (on a phone, where room is short, the chips alone) */
.zoom-tool { display: inline-flex; align-items: center; gap: 4px; }
.zoom-mark { display: inline-flex; color: var(--md-on-surface-variant); pointer-events: none; }
.zoom-mark .icon { width: 18px; height: 18px; }
.app:not(.desktop) .zoom-mark { display: none; }

/* ---- the cloth's colours: the button shows the pair, the panel sets each and offers pairs -------- */
.pair-swatch rect { stroke: color-mix(in srgb, currentColor 55%, transparent); stroke-width: 1; }
.colours-btn .pair-swatch { width: 22px; height: 22px; }
.popover.colours-pop { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: min(320px, calc(100vw - 16px)); padding: 14px 14px 12px; }
.popover-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.colour-sample { display: block; width: 72px; height: 30px; border-radius: 6px; overflow: hidden; border: 1px solid var(--md-outline-variant); }
.colour-sample svg { display: block; width: 100%; height: 100%; shape-rendering: crispEdges; }
.popover-title { margin: 0 2px; font-size: 14px; font-weight: 620; color: var(--md-on-surface); }
.popover-sub { margin: 4px 2px 0; font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--md-on-surface-variant); }
.colour-threads { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 4px; }
.colour-threads .swap { grid-column: 2; grid-row: 1 / 3; width: 36px; height: 36px; }
/* each thread is a button that gives it to the picker below; the one being set is marked */
.colour-row { grid-column: 1; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--radius-s); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.colour-row:hover { background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); }
.colour-row[aria-pressed="true"] { border-color: var(--md-primary); background: color-mix(in srgb, var(--md-primary) 10%, transparent); }
.colour-row:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 1px; }
.swatch { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--md-outline); }
.colour-text { display: flex; flex-direction: column; min-width: 0; }
.colour-name { font-size: 13.5px; font-weight: 600; color: var(--md-on-surface); }
.colour-hint { font-size: 11.5px; line-height: 1.35; color: var(--md-on-surface-variant); }
.colour-row .hex { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--md-on-surface-variant); }
.colour-pairs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px; }
.pair { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--md-outline-variant); border-radius: 10px; background: var(--md-surface-high); color: var(--md-on-surface); cursor: pointer; }
.pair:hover { border-color: var(--md-outline); }
.pair[aria-pressed="true"] { border-color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-primary); }
.pair .pair-swatch { width: 28px; height: 28px; }
.popover-foot { display: flex; justify-content: flex-end; margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--md-outline-variant); }

/* the page's colour picker (js/ui/colourPicker.js): saturation across and brightness up a square
   of the hue, the hue below it, the hex value */
.cp { display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 0; }
.cp-area { position: relative; height: 140px; border-radius: var(--radius-s); cursor: crosshair; touch-action: none; outline: none; background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(calc(var(--hue, 0) * 1deg) 100% 50%)); }
.cp-area:focus-visible { box-shadow: 0 0 0 2px var(--md-primary); }
.cp-thumb { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.5); pointer-events: none; }
.cp-row { display: flex; align-items: center; gap: 10px; }
.cp-swatch { flex: none; width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--md-outline); }
.cp-hue { flex: 1; height: 14px; margin: 0; border-radius: 7px; -webkit-appearance: none; appearance: none; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); cursor: pointer; }
.cp-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border: 2px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.cp-hue::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.cp-hue:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }
.cp-hex-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--md-on-surface-variant); }
.cp-hex { width: 96px; padding: 5px 8px; border: 1px solid var(--md-outline-variant); border-radius: var(--radius-s); background: var(--md-surface-high); color: var(--md-on-surface); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; text-transform: uppercase; }
.cp-hex:focus { outline: 2px solid var(--md-primary); outline-offset: -1px; }

/* ---- Create: the picture on point paper, and how it is read (js/app/components/picture.js) ---- */
.picture-slot { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* Design: the picture at its own height (scrolling if the panel is short), the cards under it with the room left */
.panel.left.on-design > .picture-slot { flex: 0 1 auto; }
.panel.left.on-design > .chain-slot { flex: 1 1 0; min-height: 120px; }
.panel.left.on-design > .panel-head ~ .panel-head { border-top: 1px solid var(--md-outline-variant); }
.panel-head .weave-it { height: 32px; padding: 0 14px; gap: 6px; font-size: 13px; }
.panel.left.on-picture > .guide { flex: 0 1 auto; max-height: 55%; }
.pic-box { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 14px; }
.pic-tools { display: flex; align-items: center; gap: 4px; }
.pic-tools .spacer { flex: 1; }
.pic-tools .btn.icon-only { width: 34px; height: 34px; }
.pic-tools .icon { width: 20px; height: 20px; }
.pic-grid { display: block; width: 100%; aspect-ratio: 1; border-radius: var(--radius-s); cursor: crosshair; touch-action: none; box-shadow: 0 0 0 1px var(--md-outline-variant); }
.pic-field { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--md-on-surface-variant); }
.pic-threshold { display: flex; flex-direction: column; gap: 4px; }
.pic-threshold .pic-field { display: flex; }
.pic-threshold input { flex: 1; accent-color: var(--md-primary); }
.pic-hint { margin: 0; font-size: 12px; line-height: 1.4; color: var(--md-on-surface-variant); }
/* what an image becomes, before the file dialog */
.popover.image-pop { display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: min(340px, calc(100vw - 16px)); }
.image-pop p { margin: 0 2px; font-size: 13px; line-height: 1.45; color: var(--md-on-surface); }
.image-pop p.muted { font-size: 12px; color: var(--md-on-surface-variant); }
.image-pop .popover-foot .btn { gap: 6px; }
.pic-note { margin: 0; font-size: 12px; color: var(--md-on-surface-variant); }
.pic-note:empty { display: none; }
.pic-reading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.pic-label { font-size: 12px; color: var(--md-on-surface-variant); }
.pic-options { display: flex; flex-wrap: wrap; gap: 10px; }
.weave-it-row { flex: none; padding: 10px 12px; border-bottom: 1px solid var(--md-outline-variant); }
.weave-it-row .btn { width: 100%; justify-content: center; gap: 6px; }
/* the cloth as a view on the stage: centred, as large as the pane holds it */
/* centred by its margins, not by flex alignment, so a cloth taller than its pane scrolls to its top (its newest rows) */
.cloth-box.large { width: 100%; height: 100%; display: flex; padding: 56px 12px 12px; overflow: auto; }
.cloth-box.large > canvas { margin: auto; flex: none; }

/* ---- Play: the games (js/app/components/games.js) ------------------------------------------- */
.games-slot { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.games-box { display: flex; flex-direction: column; min-height: 100%; }
.game-choose { flex: none; padding: 12px 14px 0; }
/* the game on show, by its title, as a heading would be; the list of games under it */
.game-chooser { width: 100%; font-size: 16px; font-weight: 600; padding: 8px 10px; }
.game-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 16px; }
.game-title { margin: 0; font-size: 16px; }
.game-text { margin: 0; font-size: 13px; color: var(--md-on-surface-variant); user-select: text; -webkit-user-select: text; }
.game-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.game-label { font-size: 12px; color: var(--md-on-surface-variant); }
.game-input { width: 100%; padding: 8px 10px; border: 1px solid var(--md-outline-variant); border-radius: var(--radius-s); background: var(--md-surface-high); color: var(--md-on-surface); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; resize: vertical; }
.game-input:focus { outline: 2px solid var(--md-primary); outline-offset: -1px; }
.game-row .game-input { flex: 1; width: auto; }
.game-result { margin: 0; font-size: 13.5px; font-weight: 600; }
.game-result.right { color: var(--lift); }
.game-result.wrong { color: var(--attention); }
.game-result:empty { display: none; }
.game-score { margin: 0; font-size: 12px; color: var(--md-on-surface-variant); }
.byte-rows { border-collapse: collapse; font-size: 12.5px; }
.byte-rows th { font-weight: 600; color: var(--md-on-surface-variant); text-align: left; padding: 2px 10px 4px 0; }
.byte-rows td { padding: 1px 10px 1px 0; font-variant-numeric: tabular-nums; }
.byte-rows td.bits { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.08em; }
.guess-cards { display: flex; flex-direction: column; gap: 3px; }
.guess-card { display: flex; align-items: center; gap: 8px; padding: 2px 8px; border-radius: 4px; background: var(--paste-dim); color: var(--paste-ink); font-size: 14px; }
.guess-card .num { width: 14px; font-size: 11px; font-weight: 650; }
.guess-card .holes { letter-spacing: 0.15em; }
.guess-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.guess-choice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 2px solid var(--md-outline-variant); border-radius: var(--radius-s); background: var(--md-surface-high); color: var(--md-on-surface); font-size: 12px; cursor: pointer; }
.guess-choice:hover { border-color: var(--md-outline); }
.guess-choice.right { border-color: var(--lift); }
.guess-choice.wrong { border-color: var(--attention); }
.guess-choice[aria-disabled="true"] { cursor: default; }
.drawboy-figure { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--md-on-surface-variant); }
/* the cords between the words that ask for them and the shuttle, spaced as the panel's own rows; a pulled cord rises 6 px into the room above */
.drawboy-hand { display: flex; flex-direction: column; gap: 10px; }
.drawboy-hand > p { margin: 0; }
.cords { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: 6px 0 2px; }
.cord { height: 52px; border: 1px solid var(--md-outline-variant); border-radius: 6px; background: var(--md-surface-high); color: var(--md-on-surface); font-weight: 650; cursor: pointer; }
.cord[aria-pressed="true"] { background: var(--lift); color: var(--md-surface); border-color: transparent; transform: translateY(-6px); }
.machine-slot { flex: 1 1 auto; min-height: 0; display: flex; }
