/* ============================================================
   Product previews. A light HTML recreation of the prototype
   (prototype/src/client), built on the design system's tokens and
   the app's own sizes, so it looks like the product and stays crisp.
   Everything is scoped under .app; a page can hold several.

   Each .app is drawn at a desktop size. Where the column is narrower,
   demo.js scales the whole app down as one picture inside a .stage
   (no mobile re-layout), and offers "Expand" to see it larger.
   ============================================================ */

/* --- stage: the scaled box around an .app (added by demo.js) --- */
.stage { position: relative; }
.stage > .app { transform-origin: 0 0; }
.stage.is-scaled .app, .stage.is-scaled .app * { touch-action: pan-y !important; }
/* small previews get an Expand button under them, so it never covers the picture */
.stage__open {
  position: absolute; right: 0; bottom: 0; z-index: 6;
  display: none; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 10px;
  border: 0; border-radius: var(--radius-full); background: var(--surface-raised); box-shadow: 0 0 0 1px var(--border-default);
  font: var(--text-ui); color: var(--text-hi); cursor: pointer;
}
.stage__open svg { width: 14px; height: 14px; }
.stage.is-small .stage__open { display: inline-flex; }
.stage.is-small { cursor: zoom-in; }

/* --- viewer: the enlarged preview (full screen, pans) --- */
.viewer { position: fixed; inset: 0; z-index: 1000; background: var(--surface-panel); display: flex; flex-direction: column; animation: studio-pop-in var(--dur-base) var(--ease-out); }
.viewer__bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 52px; padding: 0 12px 0 16px; font: var(--text-ui); color: var(--text-lo); }
.viewer__close { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-full); background: var(--accent); color: var(--text-on-accent); cursor: pointer; }
.viewer__close svg { width: 16px; height: 16px; }
.viewer__scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 16px 24px; display: grid; -webkit-overflow-scrolling: touch; }
.viewer__sizer { position: relative; margin: auto; }
.viewer__sizer > .app { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.viewer .app__canvas { touch-action: pan-x pan-y; }
.viewer .el[data-drag], .viewer [data-src] { touch-action: none; }
html.is-viewing, html.is-viewing body { overflow: hidden; }

/* ============================================================
   App shell. Panels and bars as in the prototype: top bar 52px,
   files 248px, agent / properties 340px.
   ============================================================ */
.app {
  --app-h: 660px;
  position: relative;
  display: grid;
  grid-template: "top top top" auto "side canvas agent" minmax(0, 1fr) / 248px minmax(0, 1fr) 340px;
  height: var(--app-h);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-chrome);
  box-shadow: 0 0 0 1px var(--border-strong), 0 30px 80px -24px rgba(24,24,27,0.22), 0 8px 24px -12px rgba(24,24,27,0.12);
  color: var(--text-hi);
  font: var(--text-body);
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
  isolation: isolate;
}
.app svg.i { width: 16px; height: 16px; flex: none; }
:where(.app) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: default; }
.app--canvas { --app-h: 500px; grid-template: "top" auto "canvas" minmax(0, 1fr) / minmax(0, 1fr); }
.app--agent  { --app-h: 560px; grid-template: "top top" auto "canvas agent" minmax(0, 1fr) / minmax(0, 1fr) 340px; }
.app--side   { --app-h: 540px; grid-template: "top top" auto "side canvas" minmax(0, 1fr) / 248px minmax(0, 1fr); }
.app--design { grid-template: "top top top" auto "side canvas agent" minmax(0, 1fr) / 248px minmax(0, 1fr) 300px; }
.app--doc    { --app-h: 640px; grid-template: "top top top top top" auto "side doc split canvas agent" minmax(0, 1fr) / 248px minmax(0, 46fr) 9px minmax(0, 54fr) 340px; }
.app--full[data-right="off"] { grid-template: "top top" auto "side canvas" minmax(0, 1fr) / 248px minmax(0, 1fr); }
.app--doc[data-side="off"] { grid-template: "top top top top" auto "doc split canvas agent" minmax(0, 1fr) / minmax(0, 50fr) 9px minmax(0, 50fr) 340px; }
.app--tall   { --app-h: 600px; }
.app--short  { --app-h: 440px; }

/* --- top bar --- */
.app__top {
  grid-area: top;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 14px;
  border-bottom: 1px solid var(--chrome-border);
  font: var(--text-ui); color: var(--text-mid);
  white-space: nowrap;
}
.app__brand { position: relative; flex: none; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--accent); }
.app__brand::before, .app__brand::after { content: ""; position: absolute; width: 10px; height: 10px; }
.app__brand::before { left: 7px; top: 7px; border: 1.6px solid rgba(255,255,255,.55); }
.app__brand::after { left: 11px; top: 11px; background: #fff; }
.app__crumbs { display: flex; gap: 7px; align-items: center; min-width: 0; overflow: hidden; color: var(--text-lo); font-weight: var(--fw-regular); font-size: var(--fs-body); }
.app__crumbs .sep { color: var(--text-faint); }
.app__crumbs .cur { color: var(--text-hi); font-weight: var(--fw-semibold); }
.app__saved { display: inline-flex; align-items: center; gap: 6px; font: var(--text-caption); color: var(--text-lo); }
.app__saved::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.app__top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.app__tbtn { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; border-radius: var(--radius-md); color: var(--text-mid); }
.app__tbtn.ico { width: 32px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }
.app__tbtn.on { background: var(--chrome-hover); color: var(--text-hi); }
.app__tbtn .ast { font: var(--fw-medium) 15px/1 var(--font-mono); padding-top: 3px; }
.app__divider { width: 1px; height: 20px; background: var(--chrome-border); margin: 0 6px; }
.app__editing { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; font: var(--text-caption); color: var(--text-mid); }
.app__editing .ast { font: var(--fw-medium) 15px/1 var(--font-mono); color: var(--selection); padding-top: 3px; animation: studio-pulse 1.2s var(--ease-inout) infinite; }

/* --- panel tabs (Files | Layers, Agent | Properties) --- */
.ptabs { flex: none; display: flex; align-items: center; gap: 2px; padding: 8px 8px 8px; margin: 0 0 0; border-bottom: 1px solid var(--chrome-border); }
.ptab { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: var(--radius-sm); font: var(--text-ui); color: var(--text-lo); }
.ptab svg.i { width: 14px; height: 14px; }
.ptab.on { background: var(--surface-panel); box-shadow: var(--shadow-xs); color: var(--text-hi); }
.ptab.on svg.i { color: var(--accent); }
.ptab .dotm { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: -2px; }
.ptabs__end { margin-left: auto; display: flex; align-items: center; gap: 2px; color: var(--text-mid); }
.ptabs__end > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); }

/* a panel's content that a played scene swaps (Files → Layers, Agent → Properties) */
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* --- left sidebar: files tree, or layers --- */
.app__side { grid-area: side; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--chrome-border); font: var(--text-ui); }
.side__search { display: flex; align-items: center; gap: 6px; padding: 10px 8px 6px; }
.side__field { flex: 1; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 9px; border-radius: var(--radius-sm); background: var(--surface-card); border: 1px solid var(--border-default); color: var(--text-faint); font: var(--text-body); }
.side__field svg.i { width: 14px; height: 14px; }
.side__plus { display: grid; place-items: center; width: 30px; height: 30px; color: var(--text-mid); }
.tree { list-style: none; margin: 0; padding: 2px 6px; color: var(--text-mid); flex: 1; min-height: 0; overflow: hidden; }
.tree li {
  --d: 0;
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 6px 0 calc(28px + var(--d) * 16px);
  border-radius: var(--radius-sm);
  font: var(--fw-regular) var(--fs-body)/1 var(--font-sans);
  white-space: nowrap; overflow: hidden;
}
.tree li.d1 { --d: 1; } .tree li.d2 { --d: 2; } .tree li.d3 { --d: 3; } .tree li.d4 { --d: 4; }
.tree li svg.i { width: 15px; height: 15px; color: var(--text-faint); }
.tree li.dir { gap: 6px; padding-left: calc(8px + var(--d) * 16px); font: var(--fw-semibold) var(--fs-sm)/1 var(--font-sans); color: var(--text-mid); }
.tree li.dir .chev { width: 14px; height: 14px; }
.tree li.on { background: var(--accent-soft); color: var(--accent-active); }
.tree li.on svg.i { color: var(--accent); }
.tree li.sel { background: var(--chrome-hover); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tree .thumb { width: 18px; height: 13px; border-radius: 2px; flex: none; object-fit: cover; box-shadow: 0 0 0 1px var(--border-strong); }
.tree .n { margin-left: auto; font: var(--fw-medium) 10px/1 var(--font-mono); color: var(--text-faint); }
.tree [data-src] { cursor: grab; }
.tree li.is-new { animation: studio-pop-in var(--dur-base) var(--ease-spring); }
.side__trash { flex: none; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-top: 1px solid var(--chrome-border); font: var(--fw-semibold) var(--fs-sm)/1 var(--font-sans); color: var(--text-mid); }
.side__trash svg.i { width: 15px; height: 15px; color: var(--text-faint); }
.side__trash .chev { width: 14px; height: 14px; }
.side__trash .n { margin-left: auto; font: var(--fw-medium) 10px/1 var(--font-mono); color: var(--text-faint); }
/* layers tab: the layouts on the board, the active one open */
.layers li { font-size: var(--fs-sm); }
.layers li .eye { margin-left: auto; opacity: 0; }
.layers li.on .eye { opacity: 1; }
.layers li.sel { background: var(--selection-fill); box-shadow: none; color: var(--text-hi); }
.layers li.sel svg.i { color: var(--selection); }

/* ============================================================
   Canvas: the board, with the scene in board coordinates.
   ============================================================ */
.app__canvas {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
  background-color: var(--surface-canvas);
  background-image: radial-gradient(var(--canvas-dot) 0.9px, transparent 1.1px);
  background-size: calc(24px * var(--zoom, 1)) calc(24px * var(--zoom, 1));
  background-position: var(--pan-x, 0) var(--pan-y, 0);
  touch-action: pan-y;
}
.scene {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  transform: translate(var(--pan-x, 40px), var(--pan-y, 40px)) scale(var(--zoom, 1));
}
.app__canvas.is-refitting, .app__canvas.is-refitting .scene { transition: transform 700ms var(--ease-out), background-size 700ms var(--ease-out), background-position 700ms var(--ease-out); }
.scene__links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.scene__links path, .scene__links line { fill: none; stroke: var(--warm-800); stroke-width: 1.5; }
.scene__links .lineage { stroke: var(--warm-500); stroke-width: 1; }
.scene__links .wire.is-live { stroke: var(--info); stroke-dasharray: 5 4; animation: studio-flow 0.6s linear infinite; }

/* board elements: positioned in scene coordinates */
.el { position: absolute; }
.el[data-drag] { cursor: grab; touch-action: none; }
.el.is-dragging { cursor: grabbing; z-index: 50 !important; }
.app[data-play] .el[data-drag] { cursor: default; }
.spot { position: absolute; width: 1px; height: 1px; pointer-events: none; }
.el.is-dragging > .el__body { box-shadow: var(--shadow-lg); }
.el.is-snapping { transition: left var(--dur-slow) var(--ease-out), top var(--dur-slow) var(--ease-out); }
.el__body { position: relative; width: 100%; height: 100%; }
/* name labels: images, videos and frames (as in the app), at a constant screen size */
.el__name {
  position: absolute; left: 0; bottom: 100%; margin-bottom: calc(5px / var(--zoom, 1));
  display: inline-flex; align-items: center; gap: 4px;
  font: var(--fw-regular) calc(11px / var(--zoom, 1))/1 var(--font-sans); color: var(--text-lo);
  white-space: nowrap; pointer-events: none;
}

/* selection: slate border and round handles; constant on screen */
.el.is-selected { outline: calc(1.5px / var(--zoom, 1)) solid var(--selection); outline-offset: calc(2px / var(--zoom, 1)); }
.el.is-selected::before, .el.is-selected::after {
  content: ""; position: absolute; z-index: 2; width: calc(9px / var(--zoom, 1)); height: calc(9px / var(--zoom, 1)); border-radius: 50%;
  background: #fff; border: calc(1.5px / var(--zoom, 1)) solid var(--selection); box-sizing: border-box;
}
.el.is-selected::before { left: calc(-6.5px / var(--zoom, 1)); top: calc(-6.5px / var(--zoom, 1)); }
.el.is-selected::after { right: calc(-6.5px / var(--zoom, 1)); bottom: calc(-6.5px / var(--zoom, 1)); }
/* drop onto: counting (slate), then armed (ink outline + halo) */
.el.is-holding { outline: calc(1.5px / var(--zoom, 1)) solid var(--selection); outline-offset: calc(3px / var(--zoom, 1)); border-radius: 4px; }
.el.is-armed { outline: calc(2px / var(--zoom, 1)) solid var(--accent); outline-offset: calc(5px / var(--zoom, 1)); border-radius: 8px; box-shadow: 0 0 0 calc(11px / var(--zoom, 1)) color-mix(in srgb, var(--accent) 18%, transparent); }
/* the agent's change: a dashed slate outline for a moment */
.el.is-flash::after {
  content: ""; position: absolute; z-index: 3; pointer-events: none;
  inset: calc(-6px / var(--zoom, 1)); border-radius: 8px;
  border: calc(2px / var(--zoom, 1)) dashed var(--selection);
  animation: demo-flash 1.6s var(--ease-out) forwards;
}
@keyframes demo-flash { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* image: radius 4, no border */
.img > .el__body { border-radius: 4px; overflow: hidden; background: var(--surface-card); }
.img > .el__body > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; transition: opacity var(--dur-slower) var(--ease-out); }
.img > .el__body > img.mix { mix-blend-mode: soft-light; }
.img.is-gen > .el__body > img, .img.is-gen > .el__body > .sheet { opacity: 0 !important; }
.img.is-new, .el.is-new { animation: studio-pop-in var(--dur-base) var(--ease-spring); }
/* generating placeholder: faint stripes, label, model, a sweeping bar */
.is-gen > .el__body { box-shadow: inset 0 0 0 1px var(--border-default); background: repeating-linear-gradient(135deg, rgba(28,28,26,.05) 0 9px, transparent 9px 18px), var(--surface-card); }
.gen { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 3px; padding: 9px 10px 10px; }
.gen__label { font: var(--fw-semibold) 11px/1.2 var(--font-sans); color: var(--text-hi); }
.gen__model { font: var(--fw-regular) 10px/1.2 var(--font-sans); color: var(--text-lo); }
.gen__bar { margin-top: 4px; height: 4px; border-radius: 99px; background: var(--border-default); overflow: hidden; }
.gen__bar::after { content: ""; display: block; height: 100%; width: 32%; border-radius: inherit; background: var(--accent); animation: studio-indeterminate 1.4s var(--ease-inout) infinite; }
/* a contact sheet: a grid of images in one result */
.sheet { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 4%; padding: 6%; background: #fff; }
.sheet img { width: 100%; height: 100%; object-fit: cover; min-height: 0; }

/* video: a poster, the clip loads and plays on click; round play button bottom-left */
.video > .el__body { background: var(--accent); }
.video > .el__body > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.video.is-playing > .el__body > video { opacity: 1; }
.vid { position: absolute; left: 8px; bottom: 8px; z-index: 1; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(28,28,26,.72); color: #fff; cursor: pointer !important; }
.vid .i { width: 10px !important; height: 10px !important; fill: currentColor; margin-left: 1px; }
.video.is-playing .vid, .is-gen .vid { opacity: 0; }
.video.is-gen > .el__body { background: repeating-linear-gradient(135deg, rgba(28,28,26,.05) 0 9px, transparent 9px 18px), var(--surface-card); }

/* sticky: radius 6, text centred, the note's own ink */
.note > .el__body {
  display: grid; place-items: center; text-align: center;
  padding: 12px;
  border-radius: 6px;
  background: var(--note-bg, var(--note-yellow));
  color: var(--note-ink, var(--note-yellow-ink));
  box-shadow: 0 3px 10px rgba(24,24,27,.14);
  font: var(--fw-regular) 14px/1.3 var(--font-sans);
  text-wrap: balance;
}
.note.c-violet { --note-bg: var(--note-violet); --note-ink: var(--note-violet-ink); }
.note.c-green  { --note-bg: var(--note-green);  --note-ink: var(--note-green-ink); }
.note.c-pink   { --note-bg: var(--note-pink);   --note-ink: var(--note-pink-ink); }
.note.c-blue   { --note-bg: var(--note-blue);   --note-ink: var(--note-blue-ink); }
.note.c-gray   { --note-bg: var(--note-gray);   --note-ink: var(--note-gray-ink); }
.note.c-slate  { --note-bg: var(--note-slate);  --note-ink: var(--note-slate-ink); }
.note.sm > .el__body { padding: 9px 10px; font-size: 12px; line-height: 1.3; }

/* text on the board */
.txt { font: var(--fw-regular) 16px/1.3 var(--font-sans); color: var(--text-hi); }
.txt.sm { font-size: 13px; color: var(--text-mid); }
.txt.h { font: var(--fw-semibold) 22px/1.15 var(--font-sans); letter-spacing: -0.01em; white-space: nowrap; }
/* a snippet: text from a document, with a red label back to it */
.snip > .el__body { font: var(--fw-regular) 15px/1.35 var(--font-sans); color: var(--text-hi); }
.snip > .el__body b { font-weight: var(--fw-semibold); }
.snip > .el__name { color: var(--danger); font-weight: var(--fw-medium); }

/* shapes */
.shp > .el__body { display: grid; place-items: center; text-align: center; padding: 8px 10px; background: var(--fill, #fff); border: 1.5px solid var(--stroke, var(--accent)); border-radius: 8px; font: var(--fw-regular) 14px/1.25 var(--font-sans); color: var(--text-hi); }
.shp.swatch > .el__body { border: 0; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(28,28,26,.12); }
.shp small { display: block; font: var(--fw-regular) 10.5px/1.3 var(--font-sans); color: var(--text-lo); }
.shp.pill > .el__body { border-radius: var(--radius-full); }
.shp.soft > .el__body { background: var(--surface-sunken); border-style: dashed; color: var(--text-mid); }
.shp.hl > .el__body { border-color: var(--success); background: var(--success-soft); }
/* a step in a framework (story beats): bold title, then a line or two, left-aligned */
.shp.beat > .el__body { place-items: start; align-content: start; text-align: left; padding: 10px 12px; border-width: 1px; border-color: var(--border-strong); font-size: 12.5px; line-height: 1.32; color: var(--text-mid); }
.shp.beat b { display: block; margin-bottom: 3px; font: var(--fw-semibold) 14px/1.2 var(--font-sans); color: var(--text-hi); }

/* frame: white, radius 4, title above */
.frame > .el__body { background: #fff; border: 1px solid var(--border-default); border-radius: 4px; box-shadow: 0 1px 6px rgba(24,24,27,.06); }
.frame > .el__name { font: var(--fw-medium) calc(13px / var(--zoom, 1))/1 var(--font-sans); color: var(--text-lo); margin-bottom: calc(6px / var(--zoom, 1)); }

/* link card: a board, folder or document on the board */
.link > .el__body { display: flex; align-items: center; gap: 12px; padding: 0 14px 0 15px; background: #fff; border: 1px solid var(--border-default); border-radius: 10px; box-shadow: 0 2px 6px rgba(24,24,27,.08); }
.link__tile { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 6px; flex: none; background: color-mix(in srgb, var(--tone, var(--danger)) 15%, transparent); color: var(--tone, var(--danger)); }
.link__tile .i { width: 18px !important; height: 18px !important; }
.link.board { --tone: var(--success); } .link.folder { --tone: var(--warning); } .link.doc { --tone: var(--danger); }
.link b { display: block; font: var(--fw-semibold) 14px/1.2 var(--font-sans); color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link small { display: block; margin-top: 3px; font: var(--fw-medium) 11px/1.2 var(--font-sans); color: var(--text-lo); white-space: nowrap; }

/* layout (design artboard): a header tab above, the artboard, its layers */
.lay > .el__body { overflow: hidden; background: var(--bg, #fff); color: var(--fg, #fff); box-shadow: var(--shadow-sm), 0 0 0 1px rgba(28,28,26,.14); }
.lay > .el__name {
  margin: 0; height: 20px; padding: 0 7px; gap: 5px;
  transform: scale(calc(1 / var(--zoom, 1))); transform-origin: 0 100%;
  font: var(--fw-semibold) 11px/1 var(--font-sans); color: var(--text-mid);
  background: #fff; border: 1px solid var(--border-default); border-bottom: 0; border-radius: 5px 5px 0 0;
}
.lay > .el__name .i { width: 12px !important; height: 12px !important; }
.lay > .el__name small { font: var(--fw-regular) 9px/1 var(--font-mono); color: var(--text-faint); }
.lay.on > .el__name { background: var(--selection); border-color: var(--selection); color: #fff; }
.lay.on > .el__name small { color: rgba(255,255,255,.75); }
.lay img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lay .shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(10,10,9,.78), rgba(10,10,9,0) 62%); }
.lay .n { position: absolute; }
.lay .serif { font-family: ui-serif, Georgia, "Times New Roman", serif; }
/* layer content: sizes in artboard px (the artboard scales with the board) */
.lay .ly-h { font: 400 var(--s, 30px)/1.05 ui-serif, Georgia, serif; letter-spacing: -0.01em; }
.lay .ly-p { font: 400 var(--s, 11px)/1.4 var(--font-sans); }
.lay .ly-k { font: 500 var(--s, 8px)/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.lay .ly-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--g, 12px); counter-reset: ly; }
.lay .ly-list li { display: grid; grid-template-columns: 22px 1fr; font: 400 var(--s, 11px)/1.35 var(--font-sans); }
.lay .ly-list li::before { counter-increment: ly; content: "0" counter(ly); font: 500 8px/1.7 var(--font-mono); opacity: .6; }
.lay .ly-list b { display: block; font: 400 calc(var(--s, 11px) * 1.35)/1.15 ui-serif, Georgia, serif; margin-bottom: 3px; }
.lay img.n { object-fit: cover; }
.lay .n.is-sel, .lay .n[data-on].on { outline: calc(1.5px / var(--zoom, 1)) solid var(--selection); outline-offset: 1px; }
.lay .n.is-sel::before, .lay .n[data-on].on::before { content: attr(data-dims); position: absolute; left: -1px; bottom: calc(100% + 4px); padding: 2px 5px; border-radius: 3px; background: var(--selection); color: #fff; font: var(--fw-semibold) 8.5px/1.2 var(--font-sans); letter-spacing: 0; white-space: pre; text-transform: none; }

/* ============================================================
   Action card (prototype ActionNode): 280 wide, radius 12.
   data-state: ready | needs | queued | run | done
   ============================================================ */
.act > .el__body { background: #fff; border: 1px solid var(--border-default); border-radius: 12px; box-shadow: 0 3px 10px rgba(24,24,27,.1); font: var(--fw-medium) 12px/1.2 var(--font-sans); color: var(--text-mid); }
.act.is-armed > .el__body, .act.is-holding > .el__body { border-color: var(--selection); }
.act__head { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--border-default); }
.act__head .cat { width: 7px; height: 7px; border-radius: 50%; background: var(--tone, var(--accent)); flex: none; }
.act__head b { font: var(--fw-semibold) 14px/1 var(--font-sans); color: var(--text-hi); white-space: nowrap; }
.act__st { margin-left: auto; font: var(--fw-semibold) 11px/1 var(--font-sans); color: var(--text-lo); white-space: nowrap; }
.act__head .i { width: 14px !important; height: 14px !important; color: var(--text-lo); margin: 0 4px; }
.act.t-video { --tone: var(--info); } .act.t-meaning { --tone: var(--warning); }
.act__body { display: flex; flex-direction: column; gap: 4px; padding: 12px 12px 0; }
.act__cap { display: flex; justify-content: space-between; height: 14px; margin-top: 2px; font: var(--fw-semibold) 10px/1 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--text-lo); }
.act__cap .meta { font-weight: var(--fw-medium); letter-spacing: 0; text-transform: none; color: var(--text-faint); }
.act__cap ~ .act__cap { margin-top: 8px; }
.act__row { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 4px; border-radius: 7px; background: var(--surface-canvas); white-space: nowrap; overflow: hidden; }
.act__row > img, .act__row > .th { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; flex: none; background: var(--surface-card); }
.act__row > .th.t { display: grid; place-items: center; background: var(--note-yellow); color: var(--note-yellow-ink); font: var(--fw-semibold) 11px/1 var(--font-sans); }
.act__row > .th.t.snip { background: color-mix(in srgb, var(--danger) 14%, #fff); color: var(--danger); }
.act__row .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.act__row .x { width: 12px !important; height: 12px !important; color: var(--text-lo); margin-right: 5px; }
.act__row .role { flex: none; display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; border: 1px dashed var(--text-faint); font: var(--fw-medium) 10.5px/1 var(--font-sans); color: var(--text-lo); }
.act__row .role.set { border-style: solid; border-color: var(--border-default); background: #fff; color: var(--text-hi); font-weight: var(--fw-semibold); }
.act__row .note { flex: none; font: var(--fw-medium) 11px/1 var(--font-sans); color: var(--text-faint); margin-right: 6px; }
.act__row.set { padding-left: 8px; }
.act__row.set > .i, .act__row.up > .i { width: 14px !important; height: 14px !important; color: var(--text-lo); }
.act__row.up { padding-left: 8px; }
.act__row.is-new { animation: studio-pop-in var(--dur-base) var(--ease-spring); }
.act__drop { display: flex; align-items: center; height: 30px; padding: 0 10px; border-radius: 7px; border: 1px dashed var(--text-faint); font: var(--fw-medium) 11.5px/1 var(--font-sans); color: var(--text-lo); }
.act.is-armed .act__drop, .act.is-holding .act__drop { border-color: var(--selection); color: var(--selection); background: rgba(90,118,176,.06); }
.act__sum { margin-top: 4px; font: var(--fw-medium) 12px/1.3 var(--font-sans); color: var(--text-lo); }
.act__bar { display: none; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--info-soft); overflow: hidden; }
.act__bar::after { content: ""; display: block; width: 34%; height: 100%; border-radius: inherit; background: var(--info); animation: studio-indeterminate 1.4s var(--ease-inout) infinite; }
.act[data-state="run"] .act__bar { display: block; }
.act__foot { display: flex; gap: 8px; padding: 10px 12px 12px; }
.act__run { flex: 1; display: grid; place-items: center; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; font: var(--fw-semibold) 13px/1 var(--font-sans); white-space: nowrap; }
.act__run[data-run-btn] { cursor: pointer !important; }
.act__res { display: none; place-items: center; width: 104px; height: 32px; border-radius: 8px; background: var(--surface-card); color: var(--text-hi); font: var(--fw-semibold) 13px/1 var(--font-sans); }
.act[data-state="done"] .act__res { display: grid; }
.act .port { position: absolute; top: 50%; width: 11px; height: 11px; margin-top: -5.5px; border-radius: 50%; background: #fff; border: 1.5px solid var(--accent); box-sizing: border-box; }
.act .port.l { left: -5.5px; } .act .port.r { right: -5.5px; border-color: var(--success); }
/* status and button text follow the state */
.act .act__st::after { content: "Ready"; }
.act[data-state="needs"] .act__st::after { content: "Needs inputs"; }
.act[data-state="queued"] .act__st::after { content: "Queued"; color: var(--text-faint); }
.act[data-state="run"] .act__st { color: var(--info); }
.act[data-state="run"] .act__st::after { content: "Running"; }
.act[data-state="done"] .act__st { color: var(--success); }
.act[data-state="done"] .act__st::after { content: "Done"; }
.act .act__run::after { content: "Run"; }
.act[data-state="done"] .act__run::after { content: "Run again"; }
.act[data-chain="head"] .act__run::after { content: "Run chain"; }
.act[data-chain="head"][data-state="done"] .act__run::after { content: "Run chain again"; }
.act[data-chain="next"] .act__run::after { content: "Run from here"; }
.act[data-state="run"] .act__run::after, .act[data-state="queued"] .act__run::after { content: "Stop"; }
.act[data-state="run"] .act__run, .act[data-state="queued"] .act__run { background: var(--surface-card); color: var(--text-hi); }
.act[data-state="needs"] .act__run { background: var(--warm-300); color: #fff; }

/* ============================================================
   Canvas overlays (screen space, not scaled with the board)
   ============================================================ */
.app__tools {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; gap: 1px; padding: 4px;
  background: var(--surface-panel); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  color: var(--text-mid);
}
.app__tools span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); }
.app__tools span.on { background: var(--accent); color: var(--text-on-accent); }
.app__tools span.off { opacity: .4; }
.app__tools hr { border: 0; height: 1px; background: var(--border-default); margin: 3px 4px; }
.app__zoom {
  position: absolute; right: 16px; bottom: 16px; z-index: 5;
  display: flex; align-items: center; gap: 0; padding: 3px;
  background: var(--surface-panel); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  color: var(--text-mid);
}
.app__zoom span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); }
.app__zoom output { width: 50px; text-align: center; font: var(--fw-semibold) 12px/1 var(--font-mono); color: var(--text-hi); }
.app__zoom i { width: 1px; height: 18px; margin: 0 3px; background: var(--border-default); }
.app__hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 5;
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 13px;
  background: var(--surface-raised); border-radius: var(--radius-full); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-default);
  font: var(--text-ui); font-weight: var(--fw-regular); color: var(--text-mid); white-space: nowrap;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.app__hint.is-hidden { opacity: 0; pointer-events: none; }
.app__hint .i { width: 14px; height: 14px; }

/* hold to combine: a pill at the cursor; armed, it turns ink */
.hold[hidden] { display: none; }
.hold {
  position: absolute; z-index: 20; pointer-events: none;
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px 0 5px;
  border-radius: var(--radius-full); background: #fff; color: var(--text-hi);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border-default);
  font: var(--fw-medium) 12px/1 var(--font-sans); white-space: nowrap;
  transform: translate(14px, 14px);
}
.hold.flip { transform: translate(calc(-100% - 14px), 14px); }
.hold svg { width: 18px; height: 18px; flex: none; }
.hold .ring-bg { fill: none; stroke: var(--border-default); stroke-width: 2.5; }
.hold .ring { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 44; stroke-dashoffset: 44; transform: rotate(-90deg); transform-origin: 50% 50%; }
.hold.is-counting .ring { animation: demo-ring var(--hold, 700ms) linear forwards; }
@keyframes demo-ring { to { stroke-dashoffset: 0; } }
.hold .plus { display: none; }
.hold.is-armed { background: var(--accent); color: #fff; box-shadow: var(--shadow-md); padding-left: 9px; }
.hold.is-armed .ringw { display: none; }
.hold.is-armed .plus { display: block; width: 14px; height: 14px; }

/* drop popover (prototype DropPopover) */
.pop {
  position: absolute; z-index: 30; width: 288px;
  background: var(--surface-overlay); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); overflow: hidden;
  animation: studio-pop-in var(--dur-fast) var(--ease-spring);
  transform-origin: top left;
}
.pop__head { display: flex; align-items: center; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--border-default); }
.pp { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font: var(--fw-semibold) 12px/1 var(--font-sans); color: var(--text-hi); }
.pp > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .sw { width: 20px; height: 20px; border-radius: 4px; flex: none; object-fit: cover; display: grid; place-items: center; font: var(--fw-semibold) 10px/1 var(--font-mono); }
.pop__head .arr { color: var(--text-faint); flex: none; }
.pop__list { padding: 6px; }
.pop__label { padding: 6px 8px 6px; font: var(--fw-medium) 10px/1 var(--font-mono); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-faint); }
.pop__opt { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: 8px 9px; border-radius: var(--radius-sm); cursor: pointer !important; }
.pop__opt:hover, .pop__opt:focus-visible, .pop__opt.is-hl { background: var(--accent-soft); outline: none; }
.pop__opt b { display: block; font: var(--text-body-strong); color: var(--text-hi); }
.pop__opt small { display: block; margin-top: 2px; font: var(--text-caption); color: var(--text-lo); }
.pop__opt .agent__mark { margin-top: 1px; }

/* ghost cursor for scenes that act a drag out */
.ghost { position: absolute; z-index: 40; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity 160ms var(--ease-out); }
.ghost.is-on { opacity: 1; }
.ghost__ptr { width: 18px; height: 18px; display: block; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.3)); }
.ghost__carry { position: absolute; left: 10px; top: 14px; opacity: .92; box-shadow: var(--shadow-lg); border-radius: 6px; overflow: hidden; background: #fff; transform: rotate(-2deg); }
.ghost__carry img { display: block; width: 84px; height: 56px; object-fit: cover; }
.ghost__carry.txt { width: 200px; padding: 8px 10px; font: var(--fw-regular) 11px/1.35 var(--font-sans); color: var(--text-hi); }
.ghost__carry.chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px 0 8px; font: var(--fw-semibold) 12px/1 var(--font-sans); white-space: nowrap; }
.ghost .hold { left: 0; top: 0; }
.ghost.is-dropped .ghost__carry { display: none; }
.ghost:has(.hold:not([hidden])) .ghost__carry { top: 44px; }
.ghost__carry.note { width: 150px; padding: 12px; background: var(--note-yellow); color: var(--note-yellow-ink); text-align: center; font: var(--fw-regular) 11px/1.35 var(--font-sans); }

.app__replay { position: absolute; left: 16px; bottom: 16px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--radius-full); background: var(--surface-raised); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-default); font: var(--text-ui); color: var(--text-mid); cursor: pointer !important; }
.app__replay .i { width: 13px !important; height: 13px !important; }
.app__replay:hover { color: var(--text-hi); }
.app__replay[hidden] { display: none; }
.app__ghost { position: fixed; z-index: 1100; width: 96px; height: 64px; border-radius: var(--radius-sm); object-fit: cover; pointer-events: none; box-shadow: var(--shadow-lg); opacity: 0.92; transform: translate(-50%, -50%) rotate(-2deg); }
.app__ghost.row { width: auto; height: 28px; padding: 0 10px; display: inline-flex; align-items: center; gap: 8px; background: var(--surface-raised); font: var(--text-ui); color: var(--text-hi); }
.app__canvas.is-drop-target { box-shadow: inset 0 0 0 2px var(--accent); }

/* ============================================================
   Actions library: drops down over the top of the canvas
   ============================================================ */
.alib { position: absolute; left: 0; right: 0; top: 0; z-index: 8; padding: 16px 20px 18px 62px; background: var(--surface-panel); box-shadow: var(--shadow-md); }
.alib__head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.alib__head h3 { font: var(--text-h3); margin: 0 6px 0 0; }
.alib__chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: var(--radius-full); background: var(--chrome-2); font: var(--text-ui); color: var(--text-mid); }
.alib__chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--tone, var(--accent)); }
.alib__chip.on { background: var(--accent); color: #fff; }
.alib__hint { margin-left: auto; font: var(--text-caption); color: var(--text-faint); }
.alib__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.alib__card { border: 1px solid var(--border-default); border-radius: var(--radius-md); background: #fff; overflow: hidden; }
.alib__card.on { box-shadow: 0 0 0 2px var(--accent); }
.alib__cover { position: relative; height: 64px; margin: 6px 6px 0; border-radius: var(--radius-sm); display: grid; place-items: center; background: color-mix(in srgb, var(--tone, var(--accent)) 9%, var(--surface-card)); color: var(--tone, var(--accent)); }
.alib__cover .i { width: 24px !important; height: 24px !important; }
.alib__badge { position: absolute; left: 5px; bottom: 5px; padding: 2px 5px; border-radius: 3px; background: rgba(28,28,26,.62); color: #fff; font: var(--fw-medium) 9px/1.1 var(--font-sans); }
.alib__name { display: flex; align-items: center; gap: 6px; padding: 8px 9px 3px; font: var(--fw-semibold) 12.5px/1.2 var(--font-sans); color: var(--text-hi); }
.alib__name i { width: 6px; height: 6px; border-radius: 50%; background: var(--tone, var(--accent)); flex: none; }
.alib__desc { padding: 0 9px 10px; font: var(--fw-regular) 11px/1.35 var(--font-sans); color: var(--text-lo); }
.t-video { --tone: var(--info); } .t-meaning { --tone: var(--warning); }

/* ============================================================
   Right panel: the agent conversation, or properties
   ============================================================ */
.app__agent { grid-area: agent; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--chrome-border); font: var(--text-body); }
.agent__mark { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font: var(--fw-medium) 12px/1 var(--font-mono); padding-top: 3px; box-sizing: border-box; }
.agent__log { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; padding: 14px; }
.agent__log > * { flex: none; }
.msg-user { align-self: flex-end; max-width: 86%; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-user > p, .msg-user.plain { margin: 0; padding: 8px 12px; border-radius: var(--radius-md); background: var(--surface-raised); box-shadow: var(--shadow-xs); color: var(--text-hi); }
.msg-meta, .msg-think { display: flex; align-items: center; gap: 6px; font: var(--text-caption); color: var(--text-lo); }
.msg-think .i { width: 14px !important; height: 14px !important; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: var(--radius-full); background: var(--surface-raised); box-shadow: var(--shadow-xs), 0 0 0 1px var(--border-default); font: var(--fw-medium) var(--fs-caption)/1 var(--font-sans); color: var(--text-mid); }
.chip .ok { position: relative; width: 12px; height: 12px; flex: none; }
.chip .ok::before { content: ""; position: absolute; left: 3px; top: 1px; width: 4px; height: 7px; border: solid var(--success); border-width: 0 1.75px 1.75px 0; transform: rotate(40deg); }
.chip.is-busy .ok::before { left: 0; top: 0; width: 8px; height: 8px; border: 1.75px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; transform: none; animation: studio-spin .8s linear infinite; }
.msg-text { color: var(--text-mid); }
.msg-text b { font-weight: var(--fw-semibold); color: var(--text-hi); }
.msg-foot { font: var(--fw-regular) 10.5px/1 var(--font-mono); color: var(--text-faint); }
.changed { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-full); background: var(--accent-soft-2); font: var(--fw-medium) var(--fs-caption)/1 var(--font-sans); color: var(--text-hi); }
.changed .i { width: 13px !important; height: 13px !important; }
.cchip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 4px; border-radius: var(--radius-full); background: var(--surface-raised); box-shadow: 0 0 0 1px var(--border-default); font: var(--fw-medium) var(--fs-caption)/1 var(--font-sans); color: var(--text-hi); animation: studio-pop-in var(--dur-fast) var(--ease-spring); }
.cchip > .sw, .cchip > .tile { width: 18px; height: 18px; border-radius: 4px; object-fit: cover; flex: none; display: grid; place-items: center; background: var(--accent-soft); }
.cchip .tile .i { width: 11px !important; height: 11px !important; }
.cchip .tile.doc { color: var(--danger); }
.composer { flex: none; padding: 12px; border-top: 1px solid var(--chrome-border); }
.composer__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.composer__chips:empty { display: none; }
.composer__box { padding: 8px; border-radius: var(--radius-md); background: var(--surface-raised); border: 1px solid var(--border-default); }
.composer__ph { min-height: 44px; padding: 2px 2px 0; color: var(--text-faint); font: var(--text-body); }
.composer__bar { display: flex; align-items: center; gap: 12px; color: var(--text-lo); font: var(--text-caption); padding: 0 2px; }
.composer__bar .model { display: inline-flex; align-items: center; gap: 3px; color: var(--text-mid); }
.composer__bar .model .i { width: 12px !important; height: 12px !important; }
.composer__send { margin-left: auto; display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--warm-300); color: #fff; }
.composer__send .i { width: 15px !important; height: 15px !important; }

/* properties (a selected layer) */
.props { flex: 1; min-height: 0; overflow: hidden; padding: 4px 0; font: var(--text-caption); color: var(--text-mid); }
.props__sec { padding: 12px 14px; border-bottom: 1px solid var(--chrome-border); }
.props__title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font: var(--fw-semibold) var(--fs-sm)/1 var(--font-sans); color: var(--text-hi); }
.props__title small { font: var(--fw-regular) 11px/1 var(--font-sans); color: var(--text-lo); }
.props__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.props__f { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--surface-card); border: 1px solid var(--border-default); font: var(--fw-medium) 12px/1 var(--font-sans); color: var(--text-hi); white-space: nowrap; overflow: hidden; }
.props__f > i { font: var(--fw-medium) 10.5px/1 var(--font-mono); font-style: normal; color: var(--text-faint); }
.props__f.full { grid-column: 1 / -1; }
.props__f .sw { width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(28,28,26,.2); }
.props__seg { display: flex; grid-column: 1 / -1; padding: 2px; border-radius: var(--radius-sm); background: var(--chrome-2); }
.props__seg span { flex: 1; display: grid; place-items: center; height: 24px; border-radius: 4px; font: var(--fw-medium) 11.5px/1 var(--font-sans); color: var(--text-lo); }
.props__seg span.on { background: #fff; color: var(--text-hi); box-shadow: var(--shadow-xs); }

/* ============================================================
   Document pane (split view): the doc left of the board
   ============================================================ */
.docpane { grid-area: doc; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface-panel); }
.docpane__head { flex: none; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 10px 0 18px; border-bottom: 1px solid var(--border-default); }
.docpane__head > .i { color: var(--red-500); width: 17px !important; height: 17px !important; }
.docpane__head b { font: var(--text-body-strong); color: var(--text-hi); white-space: nowrap; }
.docpane__head .wc { margin-left: auto; font: var(--fw-regular) 11px/1 var(--font-mono); color: var(--text-faint); white-space: nowrap; }
.docpane__head .ib { display: grid; place-items: center; width: 30px; height: 30px; color: var(--text-mid); }
.docpane__body { position: relative; flex: 1; min-height: 0; overflow: hidden; padding: 30px 40px 64px; }
.prose em.cue { display: block; margin: -4px 0 12px; padding-left: 10px; border-left: 2px solid var(--border-strong); font-size: 13px; color: var(--text-lo); }
.prose { max-width: 720px; font: var(--fw-regular) 15px/1.72 var(--font-sans); color: var(--text-mid); }
.prose h1 { margin: 0 0 14px; font: var(--fw-bold) 26px/1.2 var(--font-sans); color: var(--text-hi); letter-spacing: -0.01em; }
.prose h2 { margin: 20px 0 6px; font: var(--fw-semibold) 18px/1.3 var(--font-sans); color: var(--text-hi); }
.prose p { margin: 0 0 12px; }
.prose .ph { color: var(--text-faint); }
.prose .sub { margin-top: -8px; font-size: 13px; color: var(--text-lo); }
.prose .on, .prose .is-picked { background: color-mix(in srgb, var(--selection) 16%, transparent); border-radius: 3px; }
.split { grid-area: split; position: relative; background: var(--surface-canvas); border-left: 1px solid var(--border-default); border-right: 1px solid var(--border-default); }
.split::after { content: ""; position: absolute; left: 2px; top: 50%; width: 3px; height: 34px; margin-top: -17px; border-radius: 2px; background: var(--warm-400); }

/* ============================================================
   Play: boards that act something out when scrolled into view
   [data-step="n"]  hidden until step n (steps are data-gap apart, 500ms by default)
   [data-show="a b"] visible from step a (until step b);  [data-hide-at=n] gone from step n
   [data-on="a b"]   has class .on from step a (until step b)
   [data-gen]       appears generating, then resolves
   [data-at="1:run 6:done"]  a card's state at steps
   [data-move=n]    starts at data-from="x y" and glides to its place at step n
   [data-flash]     flashes (the agent's change) when it appears
   .ghost[data-ghost=n]  a cursor drags from data-from to data-to (selectors)
   ============================================================ */
.js .app[data-play] [data-step]:not(.is-on) { opacity: 0; transform: translateY(6px) scale(0.97); pointer-events: none; }
.js .app[data-play] [data-step] { transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-spring); }
.js .app[data-play] .scene__links [data-step]:not(.is-on) { transform: none; }
.js .app[data-play] [data-show]:not(.is-on) { display: none; }
.js .app[data-play] [data-show].is-on { animation: studio-pop-in var(--dur-slow) var(--ease-out); }
.js .app[data-play] .is-off { display: none !important; }
.el.is-moving { transition: left 900ms var(--ease-out), top 900ms var(--ease-out), rotate 900ms var(--ease-out); }

/* ============================================================
   Legacy pieces, used by the audience pages until they're rebuilt
   ============================================================ */
.app__mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--accent); color: var(--text-on-accent); font: var(--fw-medium) 15px/1 var(--font-mono); padding-top: 4px; }
.app__tabs { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 0; margin-bottom: 8px; }
.app__tab { display: inline-flex; gap: 6px; align-items: center; height: 30px; padding: 0 11px; border-radius: var(--radius-sm); background: var(--surface-panel); box-shadow: var(--shadow-xs); color: var(--text-hi); }
.app__search { display: flex; align-items: center; gap: 6px; height: 30px; margin: 0 8px 8px; padding: 0 9px; border-radius: var(--radius-sm); background: var(--surface-card); border: 1px solid var(--border-default); color: var(--text-faint); font-weight: var(--fw-regular); }
.app__search .grow { flex: 1; }
.app__trash { margin-top: auto; display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border-top: 1px solid var(--chrome-border); color: var(--text-mid); font-weight: var(--fw-semibold); }
.app__trash .n { margin-left: auto; font: var(--text-mono-label); color: var(--text-faint); }
.agent__head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 14px; font: var(--fw-semibold) 15px/1 var(--font-sans); border-bottom: 1px solid var(--chrome-border); }
.agent__head .icons { margin-left: auto; display: flex; gap: 12px; color: var(--text-lo); }
.agent__head .sub { font: var(--text-caption); color: var(--text-lo); font-weight: var(--fw-regular); }
.composer__chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border-radius: var(--radius-xs); background: var(--accent-soft); font: var(--fw-medium) var(--fs-caption)/1 var(--font-sans); color: var(--text-hi); }
.composer__chip .sw { width: 14px; height: 14px; border-radius: 2px; object-fit: cover; }
.composer__text { color: var(--text-hi); min-height: 40px; font-size: var(--fs-sm); }
.composer__send.is-ready { background: var(--accent); }
.composer:not(:has(.composer__box)) { margin: 0 12px 12px; padding: 8px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-raised); }
.msg-user:not(:has(> p)) { padding: 8px 12px; border-radius: var(--radius-md); background: var(--surface-raised); box-shadow: var(--shadow-xs); color: var(--text-hi); display: block; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex: none; }
.card > .el__body { background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: 12px; box-shadow: var(--shadow-sm); font: var(--text-caption); color: var(--text-mid); }
.card__head { display: flex; align-items: center; gap: 7px; padding: 10px 11px; border-bottom: 1px solid var(--border-default); font: var(--fw-semibold) var(--fs-sm)/1 var(--font-sans); color: var(--text-hi); }
.card__head .status { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font: var(--text-caption); color: var(--text-lo); }
.card__head .tag { margin-left: 2px; padding: 2px 5px; border-radius: var(--radius-xs); background: var(--chrome-2); font: var(--fw-medium) 9.5px/1 var(--font-mono); color: var(--text-lo); }
.card__sec { padding: 9px 11px; border-bottom: 1px solid var(--border-default); }
.card__label { font: var(--text-mono-label); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-faint); margin-bottom: 7px; font-size: 10px; }
.card__inputs { display: flex; gap: 5px; }
.card__inputs > * { width: 34px; height: 34px; border-radius: var(--radius-xs); object-fit: cover; }
.card__inputs .add, .card__inputs .slot { border: 1px dashed var(--border-strong); display: grid; place-items: center; color: var(--text-faint); background: var(--surface-sunken); }
.card__inputs .slot.is-filled { border: 0; }
.card__prompt { padding: 9px 11px; border-bottom: 1px solid var(--border-default); font: var(--fw-regular) 11.5px/1.4 var(--font-sans); color: var(--text-hi); }
.card__foot { padding: 9px 11px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__meta { font: var(--fw-regular) 11px/1.3 var(--font-mono); color: var(--text-lo); }
.card__run { height: 28px; padding: 0 14px; white-space: nowrap; flex: none; border-radius: 8px; background: var(--accent); color: var(--text-on-accent); font: var(--text-ui); display: inline-flex; align-items: center; }
.card__run[data-run-btn] { cursor: pointer !important; }
.card__out { display: flex; gap: 5px; padding: 9px 11px; border-top: 1px solid var(--border-default); }
.card__out > * { width: 34px; height: 34px; border-radius: var(--radius-xs); object-fit: cover; }
.card__bar { height: 3px; background: var(--border-subtle); overflow: hidden; }
.card__bar::after { content: ""; display: block; height: 100%; width: 0; background: var(--info); }
.card[data-state="run"] .card__bar::after { width: 100%; transition: width var(--run, 1600ms) linear; }
.card[data-state="done"] .card__bar::after { width: 100%; background: var(--success); }
.card[data-state] .status .dot { background: var(--text-faint); }
.card[data-state="ready"] .status .dot, .card[data-state="done"] .status .dot { background: var(--success); }
.card[data-state="run"] .status .dot { background: var(--info); animation: studio-pulse 1.4s var(--ease-inout) infinite; }
.card[data-state] .st::after { content: "Waiting"; }
.card[data-state="ready"] .st::after { content: "Ready"; }
.card[data-state="run"] .st::after { content: "Running"; }
.card[data-state="done"] .st::after { content: "Done"; }
.card[data-state] .card__run::after { content: "Run"; }
.card[data-state="run"] .card__run::after { content: "Stop"; }
.card[data-state="done"] .card__run::after { content: "Run again"; }
.card[data-state="wait"] .card__run { background: var(--warm-300); }
.card[data-state="run"] .card__run { background: var(--surface-sunken); color: var(--text-hi); box-shadow: inset 0 0 0 1px var(--border-strong); }
.card .port { position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: #fff; border: 1.5px solid var(--accent); }
.card .port.l { left: -5px; } .card .port.r { right: -5px; border-color: var(--success); }
.scene__links .wire { stroke: var(--warm-800); stroke-width: 1.5; }
.doc > .el__body { background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: 10px; box-shadow: var(--shadow-sm); overflow: hidden; }
.doc__head { display: flex; align-items: center; gap: 8px; padding: 9px 10px; font: var(--fw-semibold) var(--fs-sm)/1.2 var(--font-sans); color: var(--text-hi); }
.doc__icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius-xs); background: var(--danger-soft); color: var(--danger); flex: none; }
.doc__icon .i { width: 13px !important; height: 13px !important; }
.doc__tag { margin-left: auto; font: var(--text-mono-label); font-size: 10px; color: var(--text-faint); white-space: nowrap; }
.doc__tag.is-new { color: var(--success); }
.doc__text { padding: 0 11px 11px; font: var(--fw-regular) 11px/1.5 var(--font-sans); color: var(--text-mid); }
.doc__text p + p { margin-top: 6px; }
.doc__text h4 { margin: 8px 0 3px; font: var(--fw-semibold) 11px/1.3 var(--font-sans); color: var(--text-hi); }
.doc__text ins { text-decoration: none; background: var(--success-soft); color: var(--text-hi); border-radius: 2px; padding: 0 2px; }
.doc__text .cap { font: var(--text-mono-label); font-size: 9.5px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-faint); }
.doc__text .tags { color: var(--info); }
.cc { position: absolute; left: 8%; right: 8%; bottom: 14%; z-index: 1; text-align: center; font: 800 11px/1.15 var(--font-sans); color: #fff; text-transform: uppercase; text-shadow: 0 1px 0 #000, 0 0 6px rgba(0,0,0,.6); }
.cc mark { background: #ffd84a; color: #111; padding: 0 2px; text-shadow: none; }
.img.is-gen .cc { opacity: 0; }
.tbl > .el__body { background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: 10px; box-shadow: var(--shadow-sm); overflow: hidden; font: var(--fw-regular) 11px/1.3 var(--font-sans); color: var(--text-mid); }
.tbl__row { display: grid; grid-template-columns: var(--cols, 24px 1fr 80px); align-items: center; gap: 10px; min-height: 30px; padding: 4px 10px; border-top: 1px solid var(--border-subtle); }
.tbl__row:first-child { border-top: 0; }
.tbl__head { min-height: 26px; background: var(--surface-sunken); font: var(--text-mono-label); font-size: 9.5px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-faint); }
.tbl__row > b { font-weight: var(--fw-medium); color: var(--text-hi); }
.tbl__row img { width: 40px; height: 24px; border-radius: 3px; object-fit: cover; }
.tbl .tag { justify-self: start; display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--radius-xs); background: var(--chrome-2); font-size: 10px; color: var(--text-mid); white-space: nowrap; }
.tbl .tag.ok { background: var(--success-soft); color: var(--success); }
.tbl .tag.wip { background: var(--warning-soft); color: var(--text-hi); }
.pal > .el__body { display: flex; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px var(--border-default); }
.pal i { flex: 1; background: var(--c); }
.post > .el__body { background: #fff; border-radius: 10px; box-shadow: var(--shadow-md), 0 0 0 1px var(--border-default); overflow: hidden; display: flex; flex-direction: column; font: var(--fw-regular) 10.5px/1.35 var(--font-sans); color: var(--text-hi); }
.post__head { display: flex; align-items: center; gap: 6px; padding: 7px 8px; font-weight: var(--fw-semibold); }
.post__head .av { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; background: var(--warm-300); }
.post__head .pf { margin-left: auto; font: var(--fw-regular) 9.5px/1 var(--font-mono); color: var(--text-faint); }
.post__media { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.post__media > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.post__cap { padding: 7px 8px 9px; color: var(--text-mid); }
.post__cap b { color: var(--text-hi); }
.post__cap .tags { color: var(--info); }
.seq > .el__body { background: var(--warm-900); border-radius: 10px; padding: 8px; box-shadow: var(--shadow-md); }
.seq__clips { display: flex; gap: 3px; height: calc(100% - 22px); }
.seq__clips > * { flex: var(--len, 1); min-width: 0; height: 100%; object-fit: cover; border-radius: 3px; }
.seq__ruler { display: flex; justify-content: space-between; margin-top: 6px; font: var(--fw-regular) 9.5px/1 var(--font-mono); color: var(--warm-400); }
.seq__head { position: absolute; top: 4px; bottom: 18px; left: 34%; width: 2px; background: #ff5a36; border-radius: 1px; }
.frame__run { position: absolute; right: 0; bottom: calc(100% + 4px); display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--radius-sm); background: var(--accent); color: var(--text-on-accent); font: var(--fw-medium) 11px/1 var(--font-sans); cursor: pointer !important; }
.frame__run .i { width: 9px !important; height: 9px !important; fill: currentColor; }
.lay.is-gen > .el__body > :not(.gen) { opacity: 0; }
.lib__group { margin: 10px 16px 4px; font: var(--text-mono-label); font-size: 10px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-faint); }
.lib { list-style: none; margin: 0; padding: 0 8px; }
.lib li { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--text-mid); font-weight: var(--fw-regular); }
.lib li .i { width: 15px; height: 15px; color: var(--text-lo); }
.lib li.is-active { background: var(--accent-soft); color: var(--text-hi); }
.lib li.is-new { color: var(--text-hi); font-weight: var(--fw-medium); }
.ftree, .ftree ul { list-style: none; margin: 0; padding: 0; }
.ftree { padding: 0 8px; }
.ftree ul { padding-left: 16px; }
.ftree summary, .ftree .f { display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--text-mid); font-weight: var(--fw-regular); cursor: pointer; list-style: none; }
.ftree summary { font-weight: var(--fw-semibold); }
.ftree summary::-webkit-details-marker { display: none; }
.ftree summary .chev { width: 12px; height: 12px; color: var(--text-faint); margin-right: -3px; transition: transform var(--dur-fast) var(--ease-out); }
.ftree details:not([open]) > summary .chev { transform: rotate(-90deg); }
.ftree .i { color: var(--text-faint); width: 15px; height: 15px; }
.ftree .thumb { width: 18px; height: 13px; border-radius: 2px; flex: none; object-fit: cover; }
.ftree .f[data-src] { cursor: grab; }
.ftree .f.is-active { background: var(--accent-soft); color: var(--text-hi); }
.ftree .n { margin-left: auto; font: var(--text-mono-label); color: var(--text-faint); }
