/* Dashboard prototype. g-design tokens only; the scene geometry lives in panels.js. */
html, body { height: 100%; }
body.dash { overflow: hidden; background: var(--surface-2); --font-brand: "Young Serif", "Young Serif Fallback", Georgia, serif; }

.hud { position: fixed; inset: 0 0 auto 0; z-index: 60; padding: var(--sp-4) var(--sp-5); pointer-events: none; }
.hud-in { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.hud-in > * { pointer-events: auto; }
.hud-title { display: flex; flex-direction: column; }
.hud-title strong { font-family: var(--font-brand); font-weight: 400; font-size: 20px; line-height: var(--lh-4); }
/* The readout and the log float over the scene, so they are frosted (fasra.css, Frost). The panels in the scene are not. */
.readout, .logbox { background: color-mix(in oklab, var(--surface-1) var(--glass-keep), transparent); -webkit-backdrop-filter: var(--glass-fx); backdrop-filter: var(--glass-fx); }
.readout { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-card); border: 1px solid var(--border); }

.logbox { position: fixed; left: var(--sp-5); bottom: var(--sp-4); z-index: 60; width: 460px; max-width: calc(100vw - 2 * var(--sp-5)); padding: var(--sp-2) var(--sp-3); box-sizing: border-box;
  border-radius: var(--radius-card); border: 1px solid var(--border); }
.logv { display: flex; flex-direction: column; justify-content: flex-end; list-style: none; margin: var(--sp-1) 0 0; padding: 0; font-family: var(--font-mono); font-size: 12px; line-height: var(--lh-1); height: calc(7 * 20px); overflow: hidden; }
.logv li { display: grid; grid-template-columns: 64px 84px minmax(0, 1fr) auto; gap: var(--sp-2); flex: none; height: 20px; align-items: center; white-space: nowrap; animation: dash-wipe-x 360ms var(--ease-out) both; }
.logv li > span { overflow: hidden; text-overflow: ellipsis; }
.lv-t { color: var(--text-primary); }
.lv-a, .lv-by, .logv .num { color: var(--text-secondary); }

/* Scene */
.scene { position: fixed; inset: 0; overflow: hidden; perspective-origin: 50% 50%; cursor: grab; touch-action: none; }
.scene.is-dragging { cursor: grabbing; }
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage-css3d .slot, .stage-canvas .slot { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage-css3d .slot { backface-visibility: hidden; }
/* Panels that settle back are veiled, not made see-through, so nothing behind shows through them. */
.panel { position: relative; }
.panel::before { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none; background: var(--surface-2); opacity: 0; transition: opacity 700ms var(--ease-ios); }
.scene.has-front .slot:not(.is-front) .panel::before { opacity: .5; }
.slot-graph { pointer-events: none; }
.graph-ph { position: relative; overflow: hidden; }
.graph-ph.is-live { font-family: var(--font-ui); overflow: visible; background: none; border-color: transparent; pointer-events: auto; }
.graph-ph.is-live > span { display: none; }
.graph-ph canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.graph-ph { width: 360px; height: 230px; }

/* Panels */
.panel { box-sizing: border-box; margin: 0; padding: var(--sp-3) var(--sp-4); cursor: default; background: var(--surface-1);
  animation: dash-wipe-y 560ms var(--ease-out) both; }
.slot-task .panel { width: 300px; }
.slot-stat .panel { width: 180px; }
.slot-list .panel { width: 260px; }
.slot-chart .panel { width: 280px; }
.p-head { display: flex; align-items: center; gap: var(--sp-2); min-height: 32px; }
.p-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.p-title strong { font-weight: 600; }
.p-sub { color: var(--text-secondary); font-size: 12px; line-height: var(--lh-1); }
.p-orb { width: 24px; height: 24px; }
.p-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-2); color: var(--text-secondary); font-size: 12px; }

.steps { list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
.step { display: grid; grid-template-columns: 12px 1fr auto; gap: var(--sp-2); align-items: center; height: 24px; font-size: 13px; }
.step-label { transition: color 300ms var(--ease-out); }
.step-mark { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--text-secondary); box-sizing: border-box; transition: background-color 300ms var(--ease-out), border-color 300ms var(--ease-out); }
.step.is-done .step-mark { background: var(--accent-fill); border-color: var(--accent-fill); }
.step.is-failed .step-mark { border-color: var(--danger-text, var(--text-primary)); }
.step-state { font-size: 12px; color: var(--text-secondary); }
.step.is-pending .step-label, .step.is-pending .step-state { color: var(--text-placeholder); }
.step.is-pending .step-mark { border-style: dashed; border-color: var(--text-placeholder); }
.step.is-running .step-state { color: var(--text-primary); }

.stat { display: flex; flex-direction: column; gap: var(--sp-1); }
.stat-num { font-size: 32px; line-height: var(--lh-5); font-weight: 500; }

.plist { list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
/* A new row first opens its own height, pushing the others down, then wipes in from the left */
.plist li { display: grid; grid-template-columns: 64px 1fr auto; gap: var(--sp-2); align-items: center; height: 24px; font-size: 13px; overflow: hidden; animation: dash-row-in 560ms var(--ease-ios) both; }
@keyframes dash-row-in { 0% { height: 0; clip-path: inset(0 100% 0 0); } 45% { height: 24px; clip-path: inset(0 100% 0 0); } 100% { height: 24px; clip-path: inset(0 0 0 0); } }
.plist li > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-line { margin: var(--sp-2) 0 0; }

.chart-now { display: flex; flex-direction: column; align-items: flex-end; }
.chart-now .num { font-size: 20px; line-height: var(--lh-3); }
.spark { display: block; margin-top: var(--sp-2); overflow: visible; }
.spark .line { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .grid { stroke: var(--border); stroke-dasharray: 2 4; }
.spark .axis { stroke: var(--border); }
.spark .cross { stroke: var(--text-secondary); stroke-width: 1; }
.spark .dot { fill: var(--chart-1); stroke: var(--surface-1); stroke-width: 2; }
.chart-foot { display: flex; justify-content: space-between; margin-top: var(--sp-1); }

/* Masked reveals, never fades */
@keyframes dash-wipe-y { from { clip-path: inset(0 0 100% 0 round var(--radius-card)); } to { clip-path: inset(0 0 0 0 round var(--radius-card)); } }
@keyframes dash-wipe-x { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Flat list under 700px: no scene, same panels and commands */
.stage-flat { position: static; overflow: auto; height: 100%; cursor: auto; padding: calc(var(--hud-h, 160px) + var(--sp-3)) var(--sp-4) var(--sp-5); box-sizing: border-box; display: flex; flex-direction: column; gap: var(--sp-3); }
body.dash:has(.stage-flat) { overflow: auto; }
.stage-flat .slot { scroll-margin: calc(var(--hud-h, 160px) + var(--sp-3)) 0 24px; }
.stage-flat .logbox { position: static; width: auto; max-width: none; }
.stage-flat .slot .panel { width: 100%; }
.stage-flat .slot.is-front .panel { border-color: var(--accent-edge); }
.stage-flat.has-front .slot:not(.is-front) .panel::before { opacity: 0; }
@media (max-width: 699px) {
  .hud { padding: var(--sp-3) var(--sp-4); background: var(--surface-2); }
  .readout { flex-wrap: wrap; }
  .logv { height: calc(4 * 20px); }
  .logv li { grid-template-columns: 64px 76px minmax(0, 1fr); }
  .lv-by { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, .step, .logv li, .plist li { animation: none; }
}

/* The chat dock. At 700px and wider it is a column on the right and the scene re-flows in the space left of it
   (dockedPose in dash.js). Under 700px it is the first thing in the flat list, panels below it. */
:root { --dock-w: 400px; }
.dock { display: flex; flex-direction: column; box-sizing: border-box; background: var(--surface-2); }
.dock-h { display: flex; align-items: center; gap: var(--sp-2); min-height: 56px; padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--border-subtle); box-sizing: border-box; }
.dock-h .btn { min-height: 40px; }
.dock-acts { display: flex; gap: var(--sp-1); margin-left: auto; flex: none; }
.dock-chat { flex: 1; min-height: 0; }
.dock .logbox { position: static; width: auto; max-width: none; margin: var(--sp-3) var(--sp-4) 0; }
.dock .logv { height: calc(5 * 20px); }
.dock .logv li { grid-template-columns: 56px 80px minmax(0, 1fr); }
.dock .lv-by { display: none; }
body.docked .dock { position: fixed; top: 0; right: 0; bottom: 0; width: var(--dock-w); z-index: 70; border-left: 1px solid var(--border-subtle); }
body.docked .scene { right: var(--dock-w); }
body.docked .hud { right: var(--dock-w); }
.stage-flat .dock { height: calc(100svh - var(--hud-h, 160px) - var(--sp-3) - var(--sp-4)); flex: none; transition: height 420ms var(--ease-ios); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); overflow: hidden; scroll-margin: calc(var(--hud-h, 160px) + var(--sp-3)) 0 24px; }

/* Docked: every panel rests at 1.25 so its smallest text (12px) lands at 11.5px or more after the scene's 0.77 scale.
   Agent panels rest compact (TaskPanel) and the graph gets the room the step lists gave up. */
body.docked .slot .panel { zoom: 1.25; width: var(--pw, 240px); }
body.docked .spark { width: 100%; height: auto; }
/* The graph: a flat layer under every panel, sized by fit() in dash.js, clipped so its labels stay inside,
   and wiped shut (labels with the orbs) while a panel is brought forward. */
.graph-layer { position: absolute; z-index: 1; overflow: hidden; }
.graph-layer .graph-ph { width: 100%; height: 100%; }
/* lines and labels run out over the last 32px instead of being cut on a straight line */
.graph-layer { --edge: 32px;
  mask-image: linear-gradient(to right, transparent, #000 var(--edge), #000 calc(100% - var(--edge)), transparent),
    linear-gradient(to bottom, transparent, #000 var(--edge), #000 calc(100% - var(--edge)), transparent);
  mask-composite: intersect; }
.graph-layer .graph-ph.is-live { overflow: hidden; }
.scene.has-front .graph-layer { pointer-events: none; }
.panel.is-compact .p-sub { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* Phone: the frame-time readout folded behind a small control at the foot of the list */
.readout-fold { align-self: flex-start; }
.readout-btn { font: inherit; background: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--sp-3); border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle); font-size: 13px; color: var(--text-secondary); cursor: pointer; list-style: none; }
.readout-btn[aria-expanded="true"] { color: var(--text-primary); }
.readout-fold .readout { margin-top: var(--sp-2); }
body.docked .slot.is-front .panel { width: 300px; }

/* Folds: a row that eases between 0 and its content's height, clipped as it goes, so what sits below slides
   instead of jumping and the content is revealed by its edge, never faded. Interruptible: it is a transition. */
.fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 420ms var(--ease-ios); }
.fold.is-open { grid-template-rows: 1fr; }
.fold > div { min-height: 0; overflow: hidden; }
.steps-fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 520ms var(--ease-ios); }
.steps-fold > div { min-height: 0; overflow: hidden; }
.panel:not(.is-compact) .steps-fold { grid-template-rows: 1fr; }
body.docked .slot .panel { transition: width 520ms var(--ease-ios); }
/* Theme: colours ease over 320ms instead of flipping in one frame */
body.dash, .panel, .dock, .dock-h, .hud, .logbox, .readout, .ch-q span, .ch-suggest button {
  transition-property: background-color, color, border-color, width, grid-template-rows; transition-duration: 320ms; transition-timing-function: var(--ease-ios); }
body.docked .slot .panel { transition-duration: 320ms, 320ms, 320ms, 520ms; }

/* The way back to the site: wordmark and three quiet links, above the page title */
.hud-nav { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-1); pointer-events: auto; width: max-content; max-width: 100%; }
.hud-nav .mark { display: flex; align-items: center; height: 40px; width: 104px; flex: none; color: var(--text-primary); }
.hud-nav .mark svg { height: 22px; width: auto; display: block; }
.hud-nav nav { display: flex; flex-wrap: wrap; gap: 0 var(--sp-3); font-size: 13px; }
.hud-nav nav a { display: inline-flex; align-items: center; min-height: 40px; color: var(--text-secondary); text-decoration: none; }
.hud-nav nav a:hover { color: var(--text-primary); }

/* Touch: every control at least 40px tall */
@media (max-width: 699px), (pointer: coarse) {
  .p-foot .btn { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .fold, .steps-fold, body.docked .slot .panel { transition-duration: 1ms; }
}
/* A compact panel's line under the name always holds two lines, so a step that wraps or unwraps it never jumps the panel */
.panel.is-compact .p-title .p-sub { min-height: 2lh; }

/* At rest the chat reads from the top: intro, then suggestions, the bar held at the foot (chat.css packs the thread;
   here the foot takes the rest of the docked column). */
body.docked .ch:has(.ch-empty) .ch-foot { flex: 1; display: flex; flex-direction: column; }
body.docked .ch:has(.ch-empty) .ch-foot > .ask { margin-top: auto; }
/* Phone: the chat's height is set to its content (dash.js), eased only once the first size is in */
.stage-flat .dock:not(.is-sized) { transition: none; }

/* Map labels a panel covers wipe shut under a soft edge (dash.js hideUnder). The renderer sets its own clip-path
   transition inline, so this keeps it and adds the mask's. */
.graph-layer .gl-label { -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%); mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
  -webkit-mask-size: 250% 100%; mask-size: 250% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: 0 0; mask-position: 0 0;
  transition: clip-path 480ms var(--ease-out), -webkit-mask-position 360ms var(--ease-ios), mask-position 360ms var(--ease-ios) !important; }
.graph-layer .gl-label.is-under { -webkit-mask-position: 100% 0; mask-position: 100% 0; pointer-events: none; }

/* Status badges hold the width of their widest word, so Working, Finished and Waiting swap without a jump */
.p-head .badge { min-width: 78px; justify-content: center; box-sizing: border-box; }

/* Tablet widths, 700 to 1099: the flat list in two columns under the chat */
@media (min-width: 700px) {
  .stage-flat { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; align-items: start; }
  .stage-flat > .dock, .stage-flat > .logbox, .stage-flat > .readout-fold { grid-column: 1 / -1; }
}
/* Tablet rows: the chat, then the two short stat tiles side by side, then agents, so no column holds a gap */
@media (min-width: 700px) {
  .stage-flat > .dock { order: -2; }
  .stage-flat > .slot { order: 1; }
  .stage-flat > .slot:has(.stat) { order: -1; }
  .stage-flat > .slot:has(.chart), .stage-flat > .slot:has(.plist) { order: 2; }
  .stage-flat > .logbox { order: 3; }
}
/* Phone: the links sit in one row of their own under the wordmark, whole, never wrapped or cut */
@media (max-width: 699px) {
  .hud-nav { width: 100%; flex-wrap: wrap; row-gap: 0; }
  .hud-nav nav { flex: 1 0 100%; flex-wrap: nowrap; white-space: nowrap; gap: 0 14px; margin-top: -4px; }
}
@media (max-width: 359px) { .hud-nav nav { gap: 0 10px; font-size: 12.5px; } }
@media (min-width: 700px) { .stage-flat { align-items: stretch; } .stage-flat > .slot > .panel { height: 100%; box-sizing: border-box; } }
/* Flat list at every width: the header is opaque, so the list never prints under the title; slots stop just below it */
@media (max-width: 1099px) { .hud { background: var(--surface-2); } .stage-flat > .slot { scroll-margin-top: 8px; } }
.panel.answer { padding: 0; border: 0; background: none; box-shadow: none; }
.panel.answer::before { display: none; }
.ease { overflow: hidden; transition: height 420ms var(--ease-ios); }
@media (prefers-reduced-motion: reduce) { .ease { transition: none; } }
.ease > div { display: flow-root; }
/* the panel copy of an answer is the big one, so its names wrap whole and are never the cut copy */
.panel.answer .kit-nm { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; }
.panel.answer .kit-list li { height: auto; min-height: var(--h-2); padding-block: 4px; }
body.docked .slot.is-front .panel.answer { width: 380px; }
