/* ============================================================================
   Brandpatch AI — Studio
   The desk's room: a #E4E4E9 page, one white frame (28px radius, 16px inset),
   Plus Jakarta Sans at zero tracking, DM Mono only for file facts and the
   command that ran. The bench (what you can do, the file on the bench, the form
   that starts the job) sits on the white canvas; the library is the grey rail.
   Phone: one column, 44px targets, 16px inputs, safe-area at the bottom.
   No Playfair, no purple, nothing under 12px. Lime only while a job is live.
   Transitions 120–180ms; reduced motion kills them.
   ========================================================================== */

/* retired: the old display voice was `font-family: var(--display); font-style: italic; font-weight: 600;`
   (Playfair). Studio now speaks Plus Jakarta Sans only — see .display below. */

/* ── the studio palette (light, like the desk canvas — same on both themes) ── */
:root, .studio {
  --st-page: #E4E4E9;
  --st-frame: #FFFFFF;
  --st-frame-edge: rgba(20, 20, 30, .04);
  --st-side: #F5F5F7;
  --st-card: #FFFFFF;
  --st-card-edge: rgba(0, 0, 0, .06);
  --st-field: #F1F1F4;
  --st-search: #ECECF0;
  --st-field-edge: rgba(0, 0, 0, .08);
  --st-hair: rgba(0, 0, 0, .06);
  --st-thumb: #ECECF0;
  --st-ink: #1A1A1A;
  --st-ink-2: #5C5C66;
  --st-muted: #8A8A93;
  --st-on-ink: #FFFFFF;
  --st-ink-hi: #2B2B2B;
  --st-live: #DEEC71;
  --st-live-ink: #0D0D0D;
  --st-bad: #B4432E;
  --st-bad-soft: #FBE5DF;
  --st-bad-ink: #8F3322;
  --st-ghost: #E4E4E9;
  --st-sh-frame: 0 24px 60px rgba(20, 20, 30, .08);
  --st-sh-card: 0 10px 28px rgba(40, 24, 16, .06);
  --st-sh-menu: 0 1px 2px rgba(20, 20, 30, .05), 0 16px 40px rgba(20, 20, 30, .12);
  --st-r-frame: 28px;
  --st-inset: 16px;
  --st-rail-w: 384px;
  --st-fast: 120ms;
  --st-mid: 180ms;
}

/* the shell's legacy tokens resolve to the studio palette on this page, so the
   sheet reads var(--room)/var(--bone) like every other surface and still lands
   on the desk's greys whatever the theme cookie says */
body, html[data-theme="light"] body, html[data-theme="dark"] body, .studio {
  --room: var(--st-page); --ink: var(--st-side); --panel: var(--st-card); --panel-2: var(--st-field);
  --edge: var(--st-field-edge); --edge-soft: var(--st-hair); --edge-strong: rgba(0, 0, 0, .16);
  --bone: var(--st-ink); --bone-dim: var(--st-ink-2); --faint: var(--st-muted);
  --on-bone: var(--st-on-ink); --bone-hi: var(--st-ink-hi);
  --glacier: var(--st-ink); --glacier-dim: var(--st-ink-2);
  --ember: var(--st-bad); --ember-soft: var(--st-bad); --ember-sunk: var(--st-bad-soft);
  --code-fg: #2A2826; --strong-fg: var(--st-ink);
  --lane: var(--st-live); --lane-ink: var(--st-live-ink);
  --display: var(--sans);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--room); color: var(--bone); font-family: var(--sans); font-size: 14px; line-height: 1.5; letter-spacing: 0; -webkit-font-smoothing: antialiased; }
body::before { display: none; }
h1, h2, h3, p, ol, ul, figure { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: 0; }
a { color: var(--bone); text-decoration-color: var(--st-muted); text-underline-offset: 2px; }
.ic { width: 16px; height: 16px; flex: none; display: block; }
.studio-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 99; padding: 8px 16px; border-radius: 10px; background: var(--st-card); border: 1px solid var(--st-card-edge); color: var(--st-ink); text-decoration: none; box-shadow: var(--st-sh-menu); }
.skip-link:focus { top: 16px; }
:focus-visible { outline: 2px solid var(--st-ink); outline-offset: 2px; }
::selection { background: rgba(26, 26, 26, .14); color: inherit; }

/* two small voices: .meta is the desk's 12px sans caption; .tape is DM Mono
   for file facts, sizes and the command that ran */
.meta { font-family: var(--sans); font-size: 12px; line-height: 1.45; letter-spacing: 0; color: var(--st-muted); }
.tape { font-family: var(--mono); font-size: var(--t-micro); font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--st-muted); font-variant-numeric: tabular-nums; }

/* ── the frame: one white sheet on the grey page, the height of the room ── */
.studio {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--st-rail-w);
  grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - var(--bar-h) - 2 * var(--st-inset));
  min-height: 480px;
  margin: var(--st-inset);
  border-radius: var(--st-r-frame);
  overflow: hidden;
  background: var(--st-frame);
  color: var(--st-ink);
  box-shadow: var(--st-sh-frame), 0 0 0 1px var(--st-frame-edge);
}
/* the error strip and the gate span the whole frame */
.studio > .studio-error, .studio > .studio-gate { grid-column: 1 / -1; }
.studio > #studioBootstrap { align-self: start; align-content: start; }
.studio-shell { display: contents; }

.studio-error {
  align-self: start; margin: 20px 24px 0; padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--st-bad) 30%, transparent); border-radius: 12px;
  background: var(--st-bad-soft); color: var(--st-bad); font-size: 13px;
}
.studio:has(> .studio-error:not([hidden])) { grid-template-rows: auto minmax(0, 1fr); }
.studio:has(> .studio-error:not([hidden])) > .studio-error { grid-row: 1; }
.studio:has(> .studio-error:not([hidden])) .bench, .studio:has(> .studio-error:not([hidden])) .library, .studio:has(> .studio-error:not([hidden])) > .studio-gate { grid-row: 2; }

/* ── the gate: the desk's door, same two fields, "Open Studio" ────────── */
.studio-gate {
  align-self: stretch; justify-self: stretch;
  width: 100%; margin: 0; padding: clamp(32px, 5vw, 72px) clamp(24px, 5vw, 72px);
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(20rem, .85fr);
  gap: clamp(32px, 5vw, 80px); align-items: center; align-content: center;
  overflow-y: auto;
}
.display { font-family: var(--sans); font-style: normal; font-weight: 600; font-size: 32px; line-height: 1.2; letter-spacing: 0; color: var(--st-ink); text-wrap: balance; }
.gate-pitch { display: grid; gap: 22px; min-width: 0; }
.gate-display { font-size: clamp(2.5rem, 5.4vw, 4.5rem); font-weight: 800; line-height: 1.04; }
.gate-display span { display: block; color: var(--st-muted); }
.gate-lede { color: var(--st-ink-2); font-size: 16px; line-height: 1.55; max-width: 50ch; }
.gate-doors { list-style: none; padding: 0; display: grid; border-top: 1px solid var(--st-hair); }
.gate-door {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 16px; row-gap: 12px; align-items: start;
  padding: 18px 0; border-bottom: 1px solid var(--st-hair);
}
.gate-door-ic {
  display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 14px; background: var(--st-field); color: var(--st-ink);
}
.gate-door:first-child .gate-door-ic { background: var(--st-ink); color: var(--st-on-ink); }
.gate-door-copy { display: grid; gap: 2px; min-width: 0; }
.gate-door-copy strong { font-size: 16px; font-weight: 700; color: var(--st-ink); }
.gate-door-copy small { font-size: 14px; line-height: 1.5; color: var(--st-ink-2); }
.gate-verbs { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; }
.gate-verbs > span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px 0 10px;
  border-radius: 999px; background: var(--st-side); border: 1px solid var(--st-hair);
  font-size: 13px; font-weight: 600; color: var(--st-ink);
}
.gate-card {
  display: grid; gap: 16px; align-content: start;
  padding: 28px; border-radius: 24px; background: var(--st-side);
}
.gate-card-title { font-size: 20px; font-weight: 700; line-height: 1.25; color: var(--st-ink); }
.gate-form { display: grid; gap: 14px; }
.gate-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.gate-form .fld { display: grid; gap: 6px; }
.gate-form label { font-size: 12px; font-weight: 500; color: var(--st-ink-2); }
.gate-form input {
  min-height: 48px; padding: 0 14px; width: 100%; font-size: 16px;
  border: 1px solid var(--st-field-edge); border-radius: 12px; background: var(--st-card); color: var(--st-ink);
  transition: border-color var(--st-fast) var(--e-out), background-color var(--st-fast) var(--e-out);
}
.gate-form input::placeholder { color: var(--st-muted); }
.gate-form input:focus-visible { border-color: var(--st-ink); background: var(--st-card); outline-offset: 1px; }
.gate-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gate-row .btn-solid { flex: 1 1 100%; min-height: 48px; justify-content: space-between; padding: 0 20px 0 22px; }
.error-text { color: var(--st-bad); font-size: 13px; }
.gate-foot { color: var(--st-muted); font-size: 13px; }
.gate-foot a { color: var(--st-ink-2); }

/* ── buttons: the desk's family — black pill, hairline pill, quiet text ── */
.btn-solid, .btn-outline, .btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent;
  font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--st-fast) var(--e-out), border-color var(--st-fast) var(--e-out), color var(--st-fast) var(--e-out);
}
.btn-solid { background: var(--st-ink); color: var(--st-on-ink); border-color: var(--st-ink); }
.btn-solid:hover { background: var(--st-ink-hi); border-color: var(--st-ink-hi); }
.btn-outline { border-color: var(--st-field-edge); color: var(--st-ink); background: var(--st-card); }
.btn-outline:hover { background: var(--st-field); border-color: rgba(0, 0, 0, .16); }
.btn-quiet { color: var(--st-ink-2); background: transparent; padding: 0 12px; font-weight: 500; }
.btn-quiet:hover { background: var(--st-field); color: var(--st-ink); }
.btn-solid:disabled, .btn-outline:disabled, .btn-quiet:disabled { opacity: .45; cursor: not-allowed; }
.btn-solid:disabled:hover { background: var(--st-ink); }
.btn-outline .ic, .btn-quiet .ic { color: currentColor; }
.btn-solid .ic, .btn-outline .ic { transition: transform var(--st-mid) var(--e-out); }
@media (hover: hover) and (pointer: fine) {
  .btn-solid:not(:disabled):hover > .ic:last-child { transform: translateX(3px); }
  #sendPrompt:not(:disabled):hover .ic { transform: scale(1.12); }
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 999px; border: 1px solid var(--st-card-edge); background: var(--st-card); color: var(--st-ink-2); cursor: pointer;
  transition: background-color var(--st-fast) var(--e-out), color var(--st-fast) var(--e-out), border-color var(--st-fast) var(--e-out);
}
.icon-btn:hover { color: var(--st-ink); border-color: var(--st-field-edge); }
.upload { cursor: pointer; }

/* the workspace picker: a white pill like the desk's engine control */
.thread-pick { display: grid; gap: 6px; width: min(20rem, 100%); flex: none; }
.thread-pick > span:first-child { font-size: 12px; color: var(--st-muted); font-weight: 500; }
.select-wrap { position: relative; display: block; }
.select-wrap select {
  width: 100%; min-height: 40px; padding: 0 38px 0 14px; appearance: none; -webkit-appearance: none;
  border: 1px solid var(--st-card-edge); border-radius: 999px; background: var(--st-card); color: var(--st-ink);
  font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: 0 1px 2px rgba(20, 20, 30, .04);
  transition: border-color var(--st-fast) var(--e-out);
}
.select-wrap select:hover { border-color: var(--st-field-edge); }
.select-wrap .ic { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--st-muted); pointer-events: none; }

/* ── the bench: the white canvas, one 720px column, scrolls on its own ──── */
.bench {
  grid-column: 1; grid-row: 1;
  min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 28px 32px 40px;
  scrollbar-width: thin; scrollbar-color: var(--st-field-edge) transparent;
}
.bench > * { width: 100%; max-width: 720px; margin-left: auto; margin-right: auto; }
.bench > .sr-only { width: 1px; height: 1px; margin: -1px; }
.bench > * + * { margin-top: 16px; }
.bench > .studio-head + .modes { margin-top: 24px; }
.bench > .bench-row { margin-top: 20px; }
.bench > .bench-row + * { margin-top: 8px; }
.bench-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.bench-tape { min-width: 0; }
.to-library { display: none; }
.bench > .receipts { margin-top: 28px; }

.studio-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.studio-title { display: grid; gap: 6px; min-width: 0; }
.studio-title h1 { font-size: 36px; line-height: 1.1; font-weight: 800; letter-spacing: 0; color: var(--st-ink); }
.lede { max-width: 56ch; color: var(--st-ink-2); font-size: 14px; line-height: 1.55; }

/* what you can do: two doors, one open at a time — the desk's assist cards */
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode {
  position: relative;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 32px; column-gap: 14px; row-gap: 2px; align-items: center;
  min-height: 88px; padding: 18px 18px; text-align: left; min-width: 0;
  background: var(--st-card); border: 1px solid var(--st-card-edge); border-radius: 20px;
  box-shadow: var(--st-sh-card); color: var(--st-ink-2); cursor: pointer;
  transition: border-color var(--st-fast) var(--e-out), background-color var(--st-mid) var(--e-out), box-shadow var(--st-mid) var(--e-out), color var(--st-fast) var(--e-out), transform var(--st-fast) var(--e-out);
}
.mode[aria-selected="false"]:hover { border-color: var(--st-field-edge); transform: translateY(-1px); }
.mode:active { transform: translateY(1px); }
/* the open door points down at its panel: a notch in the door's own ink */
.mode::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 14px; height: 14px;
  background: var(--st-ink); border-radius: 0 0 3px 0; pointer-events: none;
  opacity: 0; transform: translate(-50%, -6px) rotate(45deg) scale(.6);
  transition: opacity var(--st-fast) var(--e-out), transform var(--st-mid) var(--e-out);
}
.mode[aria-selected="true"]::after { opacity: 1; transform: translate(-50%, 0) rotate(45deg); }
.mode[aria-selected="true"] .mode-ic { animation: st-land var(--st-mid) var(--e-out) both; }
@keyframes st-land {
  from { transform: scale(.82) rotate(-8deg); }
  to { transform: none; }
}
.mode[aria-selected="true"] { background: var(--st-ink); border-color: var(--st-ink); color: rgba(255, 255, 255, .72); box-shadow: 0 10px 28px rgba(20, 20, 30, .16); }
.mode-ic {
  grid-column: 1; grid-row: 1 / span 2; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--st-field); color: var(--st-ink);
  transition: background-color var(--st-fast) var(--e-out), color var(--st-fast) var(--e-out);
}
.mode[aria-selected="true"] .mode-ic { background: rgba(255, 255, 255, .14); color: var(--st-on-ink); }
.mode strong { grid-column: 2; grid-row: 1; font-size: 17px; font-weight: 700; color: var(--st-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the door's arrow: → "open this" in a hairline circle; ↓ "open below" on white once chosen */
.mode-go {
  grid-column: 3; grid-row: 1 / span 2; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 999px;
  border: 1px solid var(--st-field-edge); background: var(--st-card); color: var(--st-ink-2);
  transition: background-color var(--st-mid) var(--e-out), border-color var(--st-mid) var(--e-out), color var(--st-mid) var(--e-out);
}
.mode-go .ic { grid-area: 1 / 1; transition: opacity var(--st-fast) var(--e-out), transform var(--st-mid) var(--e-out); }
.mode-go .go-down { opacity: 0; transform: translateY(-5px); }
.mode[aria-selected="true"] .mode-go { background: var(--st-card); border-color: var(--st-card); color: var(--st-ink); }
.mode[aria-selected="true"] .go-right { opacity: 0; transform: translateX(5px); }
.mode[aria-selected="true"] .go-down { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .mode[aria-selected="false"]:hover .mode-go { background: var(--st-ink); border-color: var(--st-ink); color: var(--st-on-ink); }
  .mode[aria-selected="false"]:hover .go-right { transform: translateX(2px); }
  .mode[aria-selected="false"]:hover .mode-ic { background: var(--st-ink); color: var(--st-on-ink); }
}
.mode[aria-selected="true"] strong { color: var(--st-on-ink); }
.mode small { grid-column: 2; grid-row: 2; font-size: 13px; line-height: 1.4; color: inherit; }
.mode[aria-selected="false"] small { color: var(--st-muted); }

/* the file on the bench */
/* the file on the bench: thumbnail left, what it is and what you can do right —
   short enough that the form under it stays in view */
.stage-preview {
  display: grid; grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); gap: 16px; align-items: center;
  padding: 12px; border: 1px solid var(--st-card-edge); border-radius: 20px; background: var(--st-card); box-shadow: var(--st-sh-card);
  animation: st-rise var(--st-mid) var(--e-out) both;
}
.stage-figure { display: grid; place-items: center; min-height: 9rem; max-height: 13rem; overflow: hidden; border-radius: 14px; background: var(--st-thumb); box-shadow: inset 0 0 0 1px var(--st-hair); }
.stage-figure img, .stage-figure video { max-width: 100%; max-height: 13rem; display: block; object-fit: contain; }
.stage-meta { display: grid; gap: 4px; padding: 4px 4px 4px 0; min-width: 0; align-content: center; }
.stage-on { display: inline-flex; align-items: center; gap: 6px; width: max-content; min-height: 24px; padding: 0 10px 0 8px; margin-bottom: 4px; border-radius: 999px; background: var(--st-ink); color: var(--st-on-ink); font-size: 12px; font-weight: 600; }
.stage-on .ic { width: 14px; height: 14px; }
.stage-name { font-weight: 600; font-size: 15px; color: var(--st-ink); overflow-wrap: anywhere; }
.stage-meta .tape { overflow-wrap: anywhere; }
.stage-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* the form that starts the job: a white card, 20px radius */
.tool { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--st-card-edge); border-radius: 20px; background: var(--st-card); box-shadow: var(--st-sh-card); }
.tool-head { display: grid; gap: 2px; }
.tool-head h3 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--st-ink); }
.head-ic {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 9px; background: var(--st-field); color: var(--st-ink);
}
.tool-head .meta { padding-left: 38px; }
.tool textarea {
  width: 100%; min-height: 6rem; max-height: 16rem; resize: vertical; padding: 12px 14px;
  border: 1px solid var(--st-field-edge); border-radius: 14px; background: var(--st-field); color: var(--st-ink); font-size: 16px; line-height: 1.55;
  transition: border-color var(--st-fast) var(--e-out), background-color var(--st-fast) var(--e-out);
}
.tool textarea::placeholder { color: var(--st-muted); }
.tool textarea:focus-visible { border-color: var(--st-ink); background: var(--st-card); outline-offset: 1px; }
.tool-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tool.is-refine .tool-head h3::after { content: " · from the selected image"; color: var(--st-ink-2); font-weight: 400; }
.composer:focus-within { border-color: var(--st-field-edge); }

/* the video door with nothing on the bench: say what to do, offer the upload */
.pick-hint { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border: 1px dashed var(--st-field-edge); border-radius: 14px; background: var(--st-side); }
.pick-hint p { color: var(--st-ink-2); font-size: 13px; flex: 1; min-width: 12rem; }
.pick-mark {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 10px; background: var(--st-card); color: var(--st-ink-2); border: 1px solid var(--st-card-edge);
}

.verbs { display: grid; gap: 8px; }
.verb {
  display: grid; grid-template-columns: 7rem minmax(0, 1fr) auto; align-items: center; column-gap: 12px;
  padding: 10px 12px; border: 1px solid var(--st-hair); border-radius: 14px; background: var(--st-side);
  transition: border-color var(--st-fast) var(--e-out), background-color var(--st-fast) var(--e-out), box-shadow var(--st-fast) var(--e-out);
}
.verb:focus-within { border-color: var(--st-field-edge); background: var(--st-card); box-shadow: 0 1px 2px rgba(20, 20, 30, .04); }
.verb > b { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--st-ink); }
.verb-ic {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 8px; background: var(--st-card); border: 1px solid var(--st-card-edge); color: var(--st-ink-2);
}
.verb:focus-within .verb-ic { color: var(--st-on-ink); background: var(--st-ink); border-color: var(--st-ink); }
.verb-ic { transition: background-color var(--st-mid) var(--e-out), color var(--st-mid) var(--e-out), border-color var(--st-mid) var(--e-out), transform var(--st-mid) var(--e-out); }
@media (hover: hover) and (pointer: fine) {
  .verb:hover .verb-ic { color: var(--st-ink); border-color: var(--st-field-edge); transform: rotate(-6deg); }
  .verb:focus-within .verb-ic { transform: none; }
  .verb .btn-outline:not(:disabled):hover .ic { transform: translateX(2px); }
}
.verb-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.verb label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--st-ink-2); }
.verb input { width: 7.5rem; min-height: 40px; padding: 0 10px; border: 1px solid var(--st-field-edge); border-radius: 10px; background: var(--st-card); color: var(--st-ink); font-family: var(--mono); font-size: 14px; transition: border-color var(--st-fast) var(--e-out); }
.verb input:focus-visible { border-color: var(--st-ink); outline-offset: 1px; }
.verb .select-wrap { display: inline-block; }
.verb .select-wrap select { min-height: 40px; width: auto; padding-right: 34px; border-radius: 10px; font-size: 14px; box-shadow: none; }
.verb .btn-outline { min-height: 40px; }
.verb .btn-outline:not(:disabled):hover { background: var(--st-ink); color: var(--st-on-ink); border-color: var(--st-ink); }
.verb .meta { font-size: 13px; }
.verb:has(button:disabled) { opacity: .72; }
.verb-error { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--st-bad-ink); font-size: 13px; }
.verb-error .ic { color: var(--st-bad); }
.verb input[aria-invalid="true"] { border-color: var(--st-bad); }

/* door panels: brief enter on switch */
.door-panel.is-entering {
  animation: st-door var(--st-mid) var(--e-out) both;
}
@keyframes st-door {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* receipts: an icon for what ran, the verb and its state, then the command that
   ran or the host's error, word for word. Lime only while the job is live. */
.receipts { display: grid; gap: 12px; }
.receipt-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.receipt {
  position: relative;
  display: grid; gap: 8px; padding: 14px 16px 12px 62px; border: 1px solid var(--st-card-edge); border-radius: 16px;
  background: var(--st-card); font-size: 13px; color: var(--st-ink-2);
}
.receipt.is-new { animation: st-rise var(--st-mid) var(--e-out) both; }
.receipt-mark {
  position: absolute; left: 14px; top: 12px;
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 11px; background: var(--st-ink); color: var(--st-on-ink);
  transition: background-color var(--st-mid) var(--e-out), color var(--st-mid) var(--e-out);
}
.receipt.is-live .receipt-mark { background: var(--st-live); color: var(--st-live-ink); }
.receipt.is-failed .receipt-mark { background: var(--st-bad-soft); color: var(--st-bad); }
.receipt.is-landed .receipt-mark { animation: st-land var(--st-mid) var(--e-out) both; }
@keyframes st-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.receipt-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; margin-top: -2px; }
.receipt-title { min-width: 0; color: var(--st-ink); font-size: 15px; font-weight: 600; }
.receipt-state {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 26px; padding: 0 10px 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.receipt-state .ic { width: 14px; height: 14px; }
.receipt-state.is-ok { background: var(--st-side); color: var(--st-ink); border: 1px solid var(--st-hair); }
.receipt-state.is-bad { background: var(--st-bad-soft); color: var(--st-bad-ink); }
.receipt-state.is-live { padding: 0; }
.receipt-state.is-live .patch > * { font-size: 12px; font-weight: 600; padding: 3px 9px 4px; }
.receipt-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--st-muted); }
.receipt-ask { color: var(--st-ink-2); font-size: 14px; overflow-wrap: anywhere; }
.receipt-cmd-wrap { position: relative; }
.receipt-cmd { margin: 0; padding: 9px 48px 9px 12px; border-radius: 10px; background: var(--st-side); border: 1px solid var(--st-hair); color: var(--st-ink); font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.receipt-cmd::before { content: "$ "; color: var(--st-muted); }
.receipt-copy {
  position: absolute; right: 4px; top: 4px;
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--st-muted); cursor: pointer;
  transition: background-color var(--st-fast) var(--e-out), color var(--st-fast) var(--e-out);
}
.receipt-copy:hover { background: var(--st-card); color: var(--st-ink); }
.receipt-copy.is-done { color: var(--st-ink); }
.receipt-error {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 10px; row-gap: 2px; align-items: start;
  padding: 10px 12px; border-radius: 10px; background: var(--st-bad-soft);
  border: 1px solid color-mix(in srgb, var(--st-bad) 18%, transparent); color: var(--st-bad-ink);
}
.receipt-error > .ic { grid-row: 1 / span 2; margin-top: 2px; color: var(--st-bad); }
.receipt-error strong { font-size: 12px; font-weight: 600; }
.receipt-error p { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.receipt-error .receipt-retry { grid-column: 2; justify-self: start; margin-top: 6px; }
.receipt-retry {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px 0 10px;
  border: 1px solid color-mix(in srgb, var(--st-bad) 24%, transparent); border-radius: 999px;
  background: var(--st-card); color: var(--st-bad-ink); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background-color var(--st-fast) var(--e-out), border-color var(--st-fast) var(--e-out);
}
.receipt-retry:hover { border-color: var(--st-bad); }
.receipt-note { display: flex; align-items: flex-start; gap: 8px; color: var(--st-ink-2); font-size: 12px; }
.receipt-note .ic { width: 14px; height: 14px; margin-top: 1px; color: var(--st-muted); }
.receipt-more { display: grid; gap: 8px; }
.receipt-more > summary { cursor: pointer; font-size: 12px; color: var(--st-ink-2); list-style: none; }
.receipt-more > summary { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; }
.receipt-more > summary::before {
  content: ""; width: 6px; height: 6px; flex: none;
  border-right: 1.5px solid var(--st-muted); border-bottom: 1.5px solid var(--st-muted);
  transform: rotate(-45deg); transition: transform var(--st-fast) var(--e-out);
}
.receipt-more[open] > summary::before { transform: rotate(45deg); }
.receipt-more > summary::-webkit-details-marker { display: none; }
.receipt.is-failed { border-color: color-mix(in srgb, var(--st-bad) 35%, transparent); }
.receipt.is-live { border-color: color-mix(in srgb, var(--st-live) 70%, var(--st-card-edge)); }
.receipt-out { display: block; width: min(100%, 22rem); border-radius: 12px; border: 1px solid var(--st-card-edge); background: var(--st-thumb); }
.receipt .receipt-open, .receipt .receipt-dl {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px;
  border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--st-ink); text-decoration: none;
  border: 1px solid var(--st-card-edge); background: var(--st-card);
  transition: background-color var(--st-fast) var(--e-out), border-color var(--st-fast) var(--e-out);
}
.receipt .receipt-open:hover, .receipt .receipt-dl:hover { background: var(--st-field); border-color: var(--st-field-edge); }
.receipt-files { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.receipt-files .receipt-open { min-width: 0; max-width: 100%; }
.receipt-files .receipt-open span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* no receipts yet: the shape of one, drawn empty, and the two ways to start */
.receipts-empty {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center;
  margin-top: 4px; padding: 20px; border-radius: 20px; background: var(--st-side); border: 1px solid var(--st-hair);
}
.ghost-receipt {
  position: relative; display: grid; gap: 9px; padding: 14px 14px 14px 54px;
  border-radius: 14px; background: var(--st-card); border: 1px solid var(--st-card-edge); box-shadow: var(--st-sh-card);
  transform: rotate(-1.5deg);
}
.ghost-mark {
  position: absolute; left: 12px; top: 12px; display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 9px; background: var(--st-field); color: var(--st-ink-2);
}
.ghost-bar { display: block; height: 8px; border-radius: 4px; background: var(--st-field); }
.ghost-bar.is-title { width: 46%; height: 10px; background: var(--st-ghost); }
.ghost-bar.is-ask { width: 84%; }
.ghost-bar.is-tape { width: 58%; height: 6px; }
.ghost-cmd {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  background: var(--st-side); border: 1px solid var(--st-hair); font-family: var(--mono); font-size: 12px; line-height: 1; color: var(--st-muted);
}
.ghost-cmd b { font-weight: 400; }
.ghost-cmd .ghost-bar { flex: 1; height: 6px; background: var(--st-ghost); }
.receipts-empty-copy { display: grid; gap: 6px; min-width: 0; }
.receipts-empty-copy h3 { color: var(--st-ink); font-size: 15px; font-weight: 600; }
.receipts-empty-copy p { color: var(--st-ink-2); font-size: 13px; max-width: 42ch; }
.receipts-empty-go { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.library-loading { display: grid; gap: 10px; }
.lib-skel {
  display: block; height: 120px; border-radius: 14px;
  background: linear-gradient(90deg, #ececf0 0%, #f7f7f9 45%, #ececf0 90%);
  background-size: 200% 100%; animation: st-skel 1.2s ease-in-out infinite;
}
@keyframes st-skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* the patch: lime ground while a job is live, ink on it, a hair of tilt */
.patch { display: inline-block; transform: rotate(-1.5deg); transform-origin: 40% 60%; }
.patch > * { display: inline-block; background: var(--st-live); color: var(--st-live-ink); padding: 1px 7px 2px; border-radius: 4px; line-height: 1.2; font-size: 12px; font-weight: 500; font-style: normal; transform-origin: right center; }
.patch > .is-withdrawing { transform: scaleX(0); transition: transform var(--st-mid) var(--e-lane); }

/* ── the library: the grey rail, scrolls on its own ─────────────────────── */
.library {
  grid-column: 2; grid-row: 1;
  position: relative;
  display: grid; gap: 12px; align-content: start;
  min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--st-side); border-left: 1px solid var(--st-hair);
  scrollbar-width: thin; scrollbar-color: var(--st-field-edge) transparent;
}
.library.is-drag {
  outline: 2px dashed var(--st-ink); outline-offset: -10px;
}
.library-drop {
  position: absolute; inset: 12px; z-index: 4;
  display: grid; place-content: center; justify-items: center; gap: 8px;
  border-radius: 20px; border: 1.5px dashed var(--st-ink);
  background: color-mix(in srgb, var(--st-frame) 88%, transparent);
  color: var(--st-ink); font-size: 13px; font-weight: 500; pointer-events: none;
}
.library-drop .ic { width: 24px; height: 24px; }
.library-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.library-head h2 { font-size: 17px; font-weight: 600; color: var(--st-ink); }
.library-tools { display: flex; gap: 8px; align-items: center; }
.media-search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 12px; background: var(--st-search); color: var(--st-muted);
  transition: border-color var(--st-fast) var(--e-out), background-color var(--st-fast) var(--e-out);
}
.media-search:focus-within { border-color: var(--st-field-edge); background: var(--st-card); }
.media-search input { flex: 1; min-width: 0; min-height: 38px; border: 0; outline: 0; background: transparent; color: var(--st-ink); font-size: 14px; }
.media-search input::placeholder { color: var(--st-muted); }
.media-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.upload.is-busy { opacity: .7; pointer-events: none; }
.upload.is-busy .ic { animation: st-spin 700ms linear infinite; }
@keyframes st-spin { to { transform: rotate(360deg); } }
.library-filter { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--st-field); width: max-content; max-width: 100%; }
.library-filter button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--st-ink-2);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background-color var(--st-fast) var(--e-out), color var(--st-fast) var(--e-out), box-shadow var(--st-fast) var(--e-out);
}
.library-filter button .ic { width: 14px; height: 14px; }
.library-filter button:hover { color: var(--st-ink); }
.library-filter button[aria-checked="true"] { background: var(--st-card); color: var(--st-ink); box-shadow: 0 1px 2px rgba(20, 20, 30, .08); }

/* a card per file: thumbnail, name, kind · size, and its own actions (download, tick) */
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.asset {
  position: relative; display: grid; grid-template-rows: auto auto; min-width: 0;
  border: 1px solid var(--st-card-edge); border-radius: 16px; background: var(--st-card); color: var(--st-ink); overflow: hidden;
  box-shadow: 0 1px 2px rgba(20, 20, 30, .03);
  transition: border-color var(--st-fast) var(--e-out), box-shadow var(--st-mid) var(--e-out), transform var(--st-fast) var(--e-out);
}
.asset:hover { border-color: var(--st-field-edge); transform: translateY(-1px); box-shadow: var(--st-sh-card); }
/* the file on the bench: a 2px ink ring set off the card by a 3px gap of rail */
.asset.is-picked {
  border-color: var(--st-ink);
  box-shadow: 0 0 0 3px var(--st-side), 0 0 0 5px var(--st-ink), 0 10px 28px rgba(20, 20, 30, .12);
  transform: none;
}
.asset.is-picked:hover { transform: none; }
.asset-pick { display: grid; gap: 0; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; min-width: 0; }
.asset-pick:focus-visible { outline-offset: -2px; border-radius: 16px 16px 0 0; }
.asset-media { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; background: var(--st-thumb); }
.asset-media img, .asset-media video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--st-mid) var(--e-out); }
.asset:hover .asset-media img, .asset:hover .asset-media video { transform: scale(1.03); }
.asset.is-picked .asset-media img, .asset.is-picked .asset-media video { transform: none; }
.asset-media .asset-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(26, 26, 26, .82); color: #fff; pointer-events: none;
}
.asset-media .asset-play .ic { width: 14px; height: 14px; margin-left: 1px; }
.asset-meta { display: grid; gap: 2px; padding: 8px 10px 6px; min-width: 0; }
.asset-name { font-size: 13px; font-weight: 600; color: var(--st-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-kind { display: inline-flex; align-items: center; gap: 6px; font-family: var(--sans); font-size: 12px; color: var(--st-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-kind .ic { width: 14px; height: 14px; color: var(--st-muted); }
.asset-actions { display: flex; align-items: center; gap: 6px; padding: 0 6px 6px; }
.asset-dl {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border-radius: 999px;
  color: var(--st-ink-2); font-size: 12px; font-weight: 500; text-decoration: none;
  transition: background-color var(--st-fast) var(--e-out), color var(--st-fast) var(--e-out);
}
.asset-dl:hover { background: var(--st-field); color: var(--st-ink); }
/* the stitch tick: a white chip over the thumbnail's top-right corner */
.asset-tick {
  position: absolute; right: 8px; top: 8px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px 0 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--st-card-edge); color: var(--st-ink-2);
  font-size: 12px; font-weight: 500; cursor: pointer; box-shadow: 0 1px 2px rgba(20, 20, 30, .08);
  transition: background-color var(--st-fast) var(--e-out), color var(--st-fast) var(--e-out), border-color var(--st-fast) var(--e-out);
}
.asset-tick:hover { background: #fff; color: var(--st-ink); }
.asset-tick input { width: 16px; height: 16px; margin: 0; accent-color: var(--st-ink); cursor: pointer; }
.asset-tick.is-on { background: var(--st-ink); border-color: var(--st-ink); color: var(--st-on-ink); }
.asset-tick.is-on input { accent-color: #fff; }
.asset-tick:has(input:focus-visible) { outline: 2px solid var(--st-ink); outline-offset: 2px; }
.asset-picked {
  position: absolute; left: 8px; bottom: 8px; z-index: 1; display: none; align-items: center; gap: 4px;
  min-height: 24px; padding: 0 9px 0 6px; border-radius: 999px; background: var(--st-ink); color: var(--st-on-ink);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  pointer-events: none; box-shadow: 0 1px 3px rgba(20, 20, 30, .2);
}
.asset-picked .ic { width: 14px; height: 14px; }
.asset.is-picked .asset-picked { display: inline-flex; animation: st-pop var(--st-fast) var(--e-out) both; }
@keyframes st-pop {
  from { opacity: 0; transform: translateY(4px) scale(.94); }
  to { opacity: 1; transform: none; }
}

.studio-empty {
  display: grid; gap: 8px; justify-items: start; padding: 20px;
  border: 1px dashed var(--st-field-edge); border-radius: 16px; background: var(--st-card); color: var(--st-ink-2); font-size: 13px;
}
.studio-empty .empty-mark {
  display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 2px;
  border-radius: 12px; background: var(--st-side); border: 1px solid var(--st-hair); color: var(--st-ink-2);
}
.studio-empty .empty-mark .ic { width: 18px; height: 18px; }
.studio-empty h3 { color: var(--st-ink); font-size: 15px; font-weight: 600; }
.studio-empty .btn-outline { margin-top: 4px; }

/* an empty library: two empty frames in the gallery's own grid, the kinds it takes, one upload */
.library-empty {
  display: grid; gap: 6px; justify-items: center; text-align: center;
  padding: 16px 16px 20px; border: 1.5px dashed var(--st-field-edge); border-radius: 20px; background: var(--st-card);
  color: var(--st-ink-2); font-size: 13px;
  transition: border-color var(--st-fast) var(--e-out);
}
.library.is-drag .library-empty { border-color: var(--st-ink); }
.ghost-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; margin-bottom: 10px; }
.ghost-tile {
  display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 12px;
  background: var(--st-side); border: 1px solid var(--st-hair); color: var(--st-muted);
}
.ghost-tile .ic { width: 20px; height: 20px; }
.ghost-tile.is-video .ic { width: 32px; height: 32px; padding: 9px 8px 9px 10px; border-radius: 50%; background: var(--st-ghost); color: var(--st-ink-2); }
.library-empty h3 { color: var(--st-ink); font-size: 15px; font-weight: 600; }
.library-empty p { max-width: 30ch; }
.library-empty .library-empty-kinds { display: grid; gap: 2px; margin-top: 2px; color: var(--st-muted); }
.library-empty .btn-outline { margin-top: 10px; }
.library-empty.is-search { padding: 24px 16px; }
.library-empty.is-search .ghost-tiles, .library-empty.is-search .library-empty-kinds { display: none; }

/* ── laptop: a narrower rail ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  :root, .studio { --st-rail-w: 320px; }
  .bench { padding: 24px 24px 40px; }
  .gallery { grid-template-columns: 1fr; }
  .ghost-tiles { grid-template-columns: minmax(0, 1fr); }
  .ghost-tile.is-video { display: none; }
  .stage-preview { grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); }
  .receipts-empty { grid-template-columns: minmax(0, 1fr); }
  .ghost-receipt { max-width: 18rem; }
}

/* touch: every control is at least 44px, whatever the width */
@media (pointer: coarse) {
  .btn-solid, .btn-outline, .btn-quiet, .receipt-retry, .receipt .receipt-open, .receipt .receipt-dl, .asset-dl, .asset-tick, .library-filter button { min-height: 44px; }
  .icon-btn, .receipt-copy { width: 44px; height: 44px; }
  .select-wrap select, .verb input, .verb .select-wrap select { min-height: 44px; }
  .media-search input { min-height: 44px; }
  .receipt-cmd { padding-right: 56px; }
  .receipt-copy { right: 2px; top: 2px; }
}

/* ── phone: one column, no frame, the bench then the library ──────────── */
@media (max-width: 860px) {
  :root, .studio { --st-inset: 0px; }
  html, body { overflow-x: hidden; }
  .studio {
    display: block; height: auto; min-height: calc(100dvh - var(--bar-h));
    margin: 0; border-radius: 0; box-shadow: none; overflow-x: hidden; overflow-y: visible;
    background: var(--st-frame);
    max-width: 100vw;
  }
  body { background: var(--st-frame); }
  .studio-error { margin: 16px 16px 0; }
  .studio-gate { grid-template-columns: minmax(0, 1fr); gap: 28px; align-content: start; padding: 28px 16px calc(32px + env(safe-area-inset-bottom)); }
  .studio-gate .gate-display { font-size: 2.5rem; line-height: 1.06; }
  .gate-pitch { gap: 18px; }
  .gate-lede { font-size: 15px; }
  .gate-card { padding: 18px; border-radius: 20px; }
  .gate-verbs > span { min-height: 36px; }
  .receipt { padding-left: 58px; }
  .receipt-mark { left: 12px; }

  .bench, .library { overflow: visible; min-height: 0; }
  .bench { padding: 20px 16px 24px; }
  .bench > * { max-width: none; }
  .bench > .studio-head + .modes { margin-top: 20px; }
  .studio-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .studio-title h1 { font-size: 30px; }
  .thread-pick { width: 100%; }
  .select-wrap select { min-height: 44px; font-size: 16px; }

  .modes { gap: 10px; }
  .mode { grid-template-columns: 32px minmax(0, 1fr) 24px; column-gap: 8px; min-height: 64px; padding: 12px 10px 12px 12px; border-radius: 16px; }
  .mode-ic { grid-row: 1; width: 32px; height: 32px; border-radius: 10px; }
  .mode-go { grid-row: 1; width: 24px; height: 24px; }
  .mode-go .ic { width: 14px; height: 14px; }
  .mode strong { font-size: 14px; white-space: normal; line-height: 1.25; }
  .mode small { display: none; }

  .bench > .bench-row { margin-top: 18px; }
  .to-library { display: inline-flex; flex: none; min-height: 44px; padding: 0 10px 0 12px; gap: 6px; color: var(--st-ink); font-weight: 600; }

  .stage-preview { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .stage-meta { padding: 0 4px 4px; }
  .stage-figure { min-height: 10rem; max-height: 60vw; }
  .stage-figure img, .stage-figure video { max-height: 60vw; }
  .stage-actions .btn-outline, .stage-actions .btn-quiet { min-height: 44px; flex: 1 1 auto; }

  .tool { padding: 14px; border-radius: 18px; }
  .tool textarea { font-size: 16px; min-height: 7rem; }
  .tool-foot { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .tool-foot .btn-solid { min-height: 48px; width: 100%; }
  .tool-foot .meta { text-align: center; }
  .pick-hint { flex-direction: column; align-items: stretch; }
  .pick-hint .btn-outline { min-height: 44px; }
  .pick-mark { width: 36px; height: 36px; }

  .verb { grid-template-columns: minmax(0, 1fr); row-gap: 10px; padding: 12px; }
  .verb-fields { gap: 8px; }
  .verb label { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .verb input { flex: 1; width: auto; min-width: 0; min-height: 44px; font-size: 16px; }
  .verb .select-wrap { flex: 1; }
  .verb .select-wrap select { width: 100%; min-height: 44px; font-size: 16px; }
  .verb .btn-outline { width: 100%; min-height: 44px; }

  .receipt { padding: 12px 12px 12px 58px; }
  .receipt-title { font-size: 14px; }
  .receipt-cmd { padding-right: 56px; }
  .receipt-copy { width: 44px; height: 44px; right: 2px; top: 2px; }
  .receipt-retry { min-height: 44px; }
  .receipts-empty { padding: 16px; gap: 16px; border-radius: 18px; }
  .ghost-receipt { max-width: none; }
  .receipts-empty-go .btn-outline { flex: 1 1 10rem; min-height: 44px; }

  /* the library follows the bench; the safe-area sits under its last row */
  .library {
    border-left: 0; border-top: 1px solid var(--st-hair);
    padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  }
  .library.is-drag { outline-offset: -8px; }
  .library-tools { flex-wrap: wrap; }
  .media-search { flex: 1 1 100%; min-height: 48px; }
  .media-search input { font-size: 16px; min-height: 46px; }
  .library-tools .upload { flex: 1 1 auto; min-height: 44px; }
  .library-filter { width: 100%; }
  .library-filter button { flex: 1; min-height: 44px; padding: 0 10px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asset:hover { transform: none; }
  .asset:hover .asset-media img, .asset:hover .asset-media video { transform: none; }
  .asset-dl, .asset-tick { min-height: 44px; }
  .asset-media .asset-play { width: 40px; height: 40px; }
  .studio-empty .btn-outline, .library-empty .btn-outline { min-height: 44px; width: 100%; }
  .ghost-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ghost-tile.is-video { display: grid; }
  .library-empty p { max-width: 34ch; }
  .receipt .receipt-open, .receipt .receipt-dl { min-height: 44px; }
  .lib-skel { height: 96px; }
}
@media (max-width: 420px) {
  .gallery { gap: 8px; }
  .asset-dl { padding: 0 8px; }
  .library-filter button .ic { display: none; }
  /* Full timestamps must remain readable beside English or Spanish labels. */
  .verb[data-verb="cut"] .verb-fields, .verb[data-verb="gif"] .verb-fields {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px;
  }
}

/* ── motion: 120–180ms, and none of it under reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .studio *, .studio *::before, .studio *::after { transition: none !important; animation: none !important; }
  .patch > .is-withdrawing { transform: none; opacity: 0; }
  .lib-skel { animation: none !important; }
  .door-panel.is-entering, .receipt, .receipt-mark, .stage-preview, .mode-ic, .asset-picked { animation: none !important; }
  .upload.is-busy .ic { animation: none !important; }
  .mode:hover, .asset:hover { transform: none; }
}
@media (forced-colors: active) {
  .asset.is-picked { outline: 3px solid Highlight; outline-offset: 2px; }
  .mode[aria-selected="true"], .patch > *, .library.is-drag, .stage-on, .asset-picked, .receipt-state { border: 1px solid CanvasText; forced-color-adjust: none; }
  .mode::after { background: CanvasText; }
}

/* ══ One rhythm (studio7) ══════════════════════════════════════════════════
   The notice sits on the bench's own column, every control meets 44px at
   every width, and a door's name stays on one line on a phone. */
.studio { text-wrap: pretty; }
.btn-solid, .btn-outline, .btn-quiet, .receipt-retry, .receipt .receipt-open, .receipt .receipt-dl, .asset-dl, .asset-tick, .library-filter button { min-height: 44px; }
.studio .icon-btn, .receipt-copy { width: 44px; height: 44px; }
.receipt-more > summary { min-height: 44px; }
.receipt-cmd { padding-right: 56px; }
.media-search input { min-height: 44px; font-size: 16px; }
@media (min-width: 861px) {
  .studio > .studio-error { grid-column: 1; justify-self: center; width: min(720px, 100% - 64px); margin: 20px 0 0; }
  .studio:has(> .studio-error:not([hidden])) .library { grid-row: 1 / span 2; }
}
@media (max-width: 480px) {
  .modes { gap: 8px; }
  .mode { grid-template-columns: 32px minmax(0, 1fr); padding: 12px; }
  .mode-go { display: none; }
}

/* ══ One row, one left edge (studio8) ══════════════════════════════════════
   A control row is one group on the left with one 8px gap; nothing is pushed
   to the far side. Generate sits on the textarea's left edge with its note
   under it, the way Run sits in Apps. The bench line and its Library button
   share the left edge; the video hint's Upload follows its sentence. The
   full-width Open Studio centres word + arrow. */
.gate-row .btn-solid { justify-content: center; }
.tool-foot { display: grid; justify-items: start; gap: 8px; }
.tool-foot .btn-solid { order: -1; }
.bench-row { justify-content: flex-start; }
.pick-hint p { flex: 0 1 auto; }
.gate { text-wrap: pretty; }

/* Studio sections form a round trip on phones; scrolling keeps headings
   clear of the shared navigation and preserves a visible focus destination. */
.library-head-actions { display: flex; align-items: center; gap: 8px; }
.to-workbench { display: none; }
#libraryPane, #stagePreview, #imageForm, #videoTools { scroll-margin-top: calc(var(--bar-h) + 16px); }
@media (max-width: 860px) {
  .library-head { flex-wrap: wrap; }
  .library-head > div:first-child { flex: 1 1 120px; min-width: 0; }
  .library-head-actions { flex: 0 0 auto; }
  .studio .to-workbench { display: inline-flex; min-height: 44px; gap: 8px; padding-inline: 10px; }
}

/* Saved history shares the bench’s reading rhythm and explicit recovery. */
.history-status { margin: 0 0 12px; max-width: 65ch; color: var(--st-ink-2); font-size: 13px; line-height: 1.6; }
.history-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.history-controls button, .history-problem button { min-height: 44px; }
.history-problem { display: grid; justify-items: start; gap: 8px; margin-bottom: 16px; }
.history-problem p { margin: 0; color: var(--st-ink); font-size: 14px; overflow-wrap: anywhere; }
.receipt-title:focus-visible { outline: 2px solid var(--st-ink); outline-offset: 4px; border-radius: 4px; }
.receipt-ask { overflow-wrap: anywhere; }
.receipt-actions { flex-wrap: wrap; gap: 8px; }
.receipt { scroll-margin-top: calc(var(--bar-h) + 16px); }
