/* The transcript: row frame, carets, lazy rows (content-visibility), row
   entrances, fold rhythm, the running arc, the select-turn cursor and the
   markdown prose (`.zg-md`). */

/* A small inline running indicator (a fold step, the host transcript's
   load button) for places with no timeline Dot: a thin arc sweeping round a
   faint ring, the same drawing as the Dot's running orbit. Reduced / off
   motion: a still arc. */
.zg-arc {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 9999px;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--zg-text-muted) 28%, transparent);
}

.zg-arc::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(from 0deg, var(--zg-accent) 0 28%, transparent 28% 100%);
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px));
  animation: zg-orbit 0.9s linear infinite;
}

html[data-motion='off'] .zg-arc::after,
html[data-motion='reduced'] .zg-arc::after {
  animation: none;
  transform: rotate(-30deg);
}

/* A sent prompt (`UserPromptRow`, chat/transcript/prompt.tsx) reads as it
   was typed: the composer's face, size and rhythm. Each typed line is a block
   (`PromptLines`) trimmed to its text, 0.15em apart, 1.5rem between wrapped
   lines: the composer's paragraphs (`.ProseMirror p`), so a blank line is one
   short step, not a full empty line. The bubble is the accent's soft tint
   with a hairline of the accent, on the kit's largest radius (`--zg-accent-wash`:
   half the tint in light, where an alpha wash over white reads far stronger). */
.zg-prompt-bubble {
  padding: 10px 14px;
  border-radius: var(--zg-radius-xl);
  background: var(--zg-accent-wash);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--zg-accent) 12%, transparent);
  font-family: var(--zg-font-prompt);
  font-size: var(--zg-font-size-prompt);
  line-height: var(--zg-leading-chat);
}
.zg-prompt-line {
  margin: 0;
  text-box: trim-both;
}
.zg-prompt-line + .zg-prompt-line {
  margin-top: 0.15em;
}
/* A blank line keeps its line box: trimmed to nothing it would be 0px. */
.zg-prompt-line:empty::after {
  content: '\200b';
}

/* The column a transcript and its composer share: the same side padding on
   both, always, so their edges line up and the prompt rail appearing or
   leaving moves nothing. */
.zg-transcript-column {
  padding-inline: var(--zg-transcript-gutter);
}

/* Select-turn highlight (Timeline SelectCursor): one tint behind the
   transcript that fades in, then slides and resizes between selections.
   The timeline isolates so it can sit behind the rows (z-index -1) and
   above nothing else. */
.zg-timeline {
  isolation: isolate;
}

.zg-select-cursor {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  z-index: -1;
  border-radius: var(--zg-radius-lg);
  background: var(--zg-accent-soft-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--zg-motion-fade-out);
}

.zg-select-cursor[data-on='true'] {
  opacity: 1;
  transition: opacity var(--zg-motion-fade);
}

.zg-select-cursor[data-on='true'][data-slide='true'] {
  transition:
    opacity var(--zg-motion-fade),
    transform var(--zg-motion-snap),
    height var(--zg-motion-snap);
}

/* The prompt rail's hovered exchange (`RailTint`): the select cursor's
   element in the row hover's tone, so it never reads as a selection. */
.zg-select-cursor.zg-rail-tint {
  background: var(--zg-hover-wash);
}

/* The prompt rail (`TranscriptRail`): ticks left of the transcript's text,
   centred in that space (near the pane's edge once it is wide) and on the
   view's height, over the layout (never in it). A tick is a
   short line; the one in view and the one under the pointer stretch to full
   length and take the text's tone. Touch screens get no rail. */
.zg-prompt-rail {
  position: absolute;
  z-index: 2;
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--zg-motion-fade-out),
    visibility 0s linear var(--zg-motion-fade-out-duration, 0s);
}

.zg-prompt-rail[data-on='true'] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--zg-motion-fade);
}

/* Past its most ticks (TranscriptRail sets the height) it scrolls; an end with more ticks fades. */
.zg-prompt-rail-ticks {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.zg-prompt-rail-ticks[data-fade-top] {
  mask-image: linear-gradient(to bottom, transparent, #000 24px);
}

.zg-prompt-rail-ticks[data-fade-bottom] {
  mask-image: linear-gradient(to top, transparent, #000 24px);
}

.zg-prompt-rail-ticks[data-fade-top][data-fade-bottom] {
  mask-image: linear-gradient(to bottom, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.zg-prompt-rail-ticks::-webkit-scrollbar {
  display: none;
}

.zg-prompt-rail-tick {
  position: relative;
  flex: none;
  height: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.zg-prompt-rail-tick::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 0;
  width: 14px;
  height: 2px;
  border-radius: 9999px;
  background: var(--zg-text-subtle);
  transform: scaleX(0.55);
  transform-origin: left center;
  transition:
    transform var(--zg-motion-snap),
    background-color var(--zg-motion-hover);
}

.zg-prompt-rail-tick[aria-current='location']::before {
  background: var(--zg-text);
  transform: scaleX(1);
}

.zg-prompt-rail-tick[data-hover]::before {
  background: var(--zg-text-muted);
  transform: scaleX(1);
}

.zg-prompt-rail-tick[aria-current='location'][data-hover]::before {
  background: var(--zg-text);
}

/* A prompt whose history is loading for a jump to it. */
.zg-prompt-rail-tick[data-pending]::before {
  background: var(--zg-text-muted);
  transform: scaleX(1);
  animation: zg-prompt-rail-pending 0.9s ease-in-out infinite alternate;
}

@keyframes zg-prompt-rail-pending {
  to {
    opacity: 0.35;
  }
}

html[data-motion='off'] .zg-prompt-rail-tick[data-pending]::before,
html[data-motion='reduced'] .zg-prompt-rail-tick[data-pending]::before {
  animation: none;
}

.zg-prompt-rail-tick:focus-visible {
  outline: 2px solid var(--zg-ring);
  outline-offset: 1px;
  border-radius: var(--zg-radius-xs);
}

/* A preview, not a menu: the pointer goes through it to the rail. */
.zg-prompt-rail-card {
  pointer-events: none;
}

@media (hover: none) {
  .zg-prompt-rail {
    display: none;
  }
}

/* In select mode (the only time rows carry `data-stop`) a row is clickable. */
[data-stop] {
  cursor: pointer;
}

/* A collapsible header's caret (`Caret` in chat/transcript/frame.tsx,
   trailing every disclosure label and the session list's group headers): it
   turns on `snap` (an indicator); its hover / focus reveal is colour
   feedback (`hover`). */
.zg-caret {
  transition:
    transform var(--zg-motion-snap),
    opacity var(--zg-motion-hover);
}
.zg-caret[data-open] {
  transform: rotate(90deg);
}

/* The attachments strip (`fold-attachments.tsx`): a containment boundary of
   a fixed height (one row of 64px tiles), so a tile sliding in or out lays
   out and paints the strip alone, never the transcript around it. */
.zg-fold-attachments {
  contain: strict;
  box-sizing: content-box;
  height: 64px;
}

/* The attachments strip's count tile (`fold-attachments.tsx`): each image
   pushed in becomes its cover, fading in over the tray on `fade`. */
.zg-fold-attachments-cover {
  animation: zg-fade-in var(--zg-motion-fade) both;
}

/* A settled fold's call counts (`FoldOutcomes`): a 16px hairline chip that
   sits inside the header's hover wash, its glyphs soft-tinted (below). */
.zg-fold-outcomes {
  display: inline-flex;
  align-items: center;
  height: 16px;
  border-radius: 9999px;
  box-shadow: inset 0 0 0 1px var(--zg-hairline);
  white-space: nowrap;
  line-height: 1;
}
/* A meaning tint (`--zg-tint`) blended halfway into the muted text, so
   transcript detail (fold outcomes, the run receipt) reads as detail, not
   as an alert. Recolors with the theme like the tint it starts from. */
/* Doubled class: it tints icons too (`i-ph-check-bold zg-soft-tint`), and an icon class carries
   `color: inherit`. A page that loads the kit's stylesheet before its utilities (the website) let
   that tie win, and the check of a fold's outcomes went grey. */
.zg-soft-tint.zg-soft-tint {
  color: color-mix(in oklab, var(--zg-tint) 55%, var(--zg-text-muted));
}
.zg-tint-success {
  --zg-tint: var(--zg-success);
}
.zg-tint-danger {
  --zg-tint: var(--zg-danger);
}
.zg-tint-model {
  --zg-tint: var(--zg-model);
}
.zg-tint-accent {
  --zg-tint: var(--zg-accent);
}
.zg-tint-accent-alt {
  --zg-tint: var(--zg-accent-alt);
}
.zg-tint-money {
  --zg-tint: var(--zg-money);
}
.zg-tint-warn {
  --zg-tint: var(--zg-warn);
}

/* A fact chip (run receipt cells, a tool row's model, a worker report's
   directory): a hairline pill on the row's own background, so each value
   reads as its own unit. 20px tall so 11px `.zg-meta` text has room. Colour
   comes from the markup (a meaning tint, or the inherited `.zg-meta` tone). */
.zg-meta-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding-inline: 8px;
  border-radius: 9999px;
  box-shadow: inset 0 0 0 1px var(--zg-hairline);
  white-space: nowrap;
  line-height: 1;
}

/* Transcript rows (Timeline). Offscreen rows skip layout and paint
   (content-visibility); each row's contain-intrinsic-size rides its inline
   style (a content-aware estimate, `rowCvStyle`), keeping the scrollbar
   honest without measuring. Text selection and find-in-page still work. */
.zg-cv-row {
  content-visibility: auto;
  /* content-visibility clips paint to the row's box, which cut the left
     rounded corner off hover washes that bleed 6px past the text column
     (`.zg-disclosure`, `-mx-1.5 px-1.5`). Widen the clip box by the bleed
     and pull it back, as `.zg-collapsible-inner` does. */
  padding-inline: 6px;
  margin-inline: -6px;
}
/* A row inside a row (an open fold's, a message group's, a worker's) renders
   with its parent. Skipped on its own, it lagged a frame behind the parent
   coming into view: still at its estimate as it scrolled in, then snapping
   to its real height in view, shifting every row below it. */
.zg-cv-row .zg-cv-row {
  content-visibility: visible;
  contain-intrinsic-size: none !important;
}

/*
 * Inside a fold (the exchange's steps, an exchange's earlier messages) every
 * item sits this far below the one above it, the header included, so both
 * folds keep one rhythm. Each item carries the gap on its top; a timeline
 * row inside a fold drops its own 12px row gap (`--zg-row-gap`), and the
 * fold as a whole ends on that row gap before the next row.
 */
:root {
  --zg-fold-gap: 8px;
}
.zg-fold-messages {
  --zg-row-gap: 0px;
}
.zg-fold-messages .zg-fold-body > .zg-cv-row {
  padding-top: var(--zg-fold-gap);
}

/* A new row rises on `settle` and fades in on `fade` (never the spring). */
.zg-row-enter {
  animation:
    zg-row-rise var(--zg-motion-settle) both,
    zg-fade-in var(--zg-motion-fade) both;
}

/* History mounting as it scrolls in (`LazyRow`) is not a new row: it must
   read as already there, never fade in under the user's eye. */
.zg-cv-row[data-quiet] .zg-row-enter {
  animation: none;
}

/* Inside an exchange fold (compact transcript) the first rows stagger and
   sharpen out of a blur, so a burst of tool calls reads as a sequence,
   not a slab. The blur is capped to the rows the eye lands on (the top of
   an opening fold, the row a live fold just appended) and kept small:
   blurring sixty wide rows at once is a frame budget, not a flourish. */
.zg-fold-body > .zg-cv-row:nth-child(-n + 4) .zg-row-enter,
.zg-fold-body > .zg-cv-row:last-child .zg-row-enter {
  /* The blur is fade-side: it sharpens on `fade`, never the spring. */
  --zg-blur-from: 2px;
  animation:
    zg-row-rise var(--zg-motion-settle) both,
    zg-fade-in var(--zg-motion-fade) both,
    zg-unblur var(--zg-motion-fade) both;
}

.zg-fold-body > .zg-cv-row:nth-child(2) .zg-row-enter {
  animation-delay: 30ms;
}
.zg-fold-body > .zg-cv-row:nth-child(3) .zg-row-enter {
  animation-delay: 60ms;
}
.zg-fold-body > .zg-cv-row:nth-child(4) .zg-row-enter {
  animation-delay: 90ms;
}
.zg-fold-body > .zg-cv-row:nth-child(n + 5) .zg-row-enter {
  animation-delay: 120ms;
}

/* Transform only; the opacity is the shared `zg-fade-in`. Reduced motion
   zeroes the rise and keeps the brief fade; off is instant (the vars). */
@keyframes zg-row-rise {
  from {
    transform: translateY(4px);
  }
  to {
    transform: translateY(0);
  }
}

/* Transcript prose. Family + size come from the Appearance tokens so the
   user's chat font applies to every rendered message. */
.zg-md {
  font-family: var(--zg-font-chat);
  font-size: var(--zg-font-size-chat);
  line-height: var(--zg-leading-chat);
  color: var(--zg-text);
}

/* Mermaid diagrams (MermaidDiagram, drawn by Pele). Pele's SVG reads these
   variables, so a theme switch repaints it with no redraw. The depth grammar
   holds: the diagram sits on the code panel's tone, its nodes are raised
   chips, its subgraphs trays; lines and borders are the text's quieter tones;
   charts and categories take the status colors. */
.zg-diagram {
  --pele-bg: var(--zg-code-bg);
  --pele-fg: var(--zg-text);
  --pele-muted: var(--zg-text-muted);
  --pele-line: var(--zg-text-muted);
  --pele-surface: var(--zg-raised);
  --pele-surface-alt: var(--zg-tray);
  --pele-border: var(--zg-border);
  --pele-accent: var(--zg-accent);
  --pele-critical: var(--zg-danger);
  --pele-error: var(--zg-danger);
  --pele-font: var(--zg-font-chat);
  --pele-font-mono: var(--zg-font-mono);
  --pele-radius: var(--zg-radius-sm);
  /* Pele's own hue order (blue, orange, green, red, …): neighbors stay apart in every theme. */
  --pele-series-1: var(--zg-accent);
  --pele-series-2: var(--zg-warn);
  --pele-series-3: var(--zg-success);
  --pele-series-4: var(--zg-danger);
  --pele-series-5: var(--zg-model);
  --pele-series-6: var(--zg-info);
  --pele-series-7: var(--zg-accent-alt);
  --pele-series-8: var(--zg-money);
}
/* The measured text: Pele sizes labels from the canvas's font. */
.zg-diagram-canvas {
  font-family: var(--zg-font-chat);
  font-size: var(--zg-font-size-chat);
  line-height: var(--zg-leading-body);
  color: var(--zg-text);
}
.zg-diagram-canvas > svg {
  display: block;
  margin-inline: auto;
}
/* A view's diagram (MermaidDiagram `view`, docs/VIEWS-STYLE.md, Diagrams). The drawing is drawn at
   the width its scale gives (`--zg-diagram-width`, DG1); lines keep their width when it scales. Nodes
   are raised chips, their text 13 px at 500; a kind shows by its shape or outline, never a fill
   (DG4). Edges 1 px muted; a path the source styles (`linkStyle`, `==>`) 2 px in the accent; async
   dashed 4 3; an edge label's name muted, its value (after the middle dot) at 500 (DG5). */
.zg-diagram-view .zg-diagram-canvas {
  font-size: var(--zg-font-size-ui);
}
.zg-diagram-view .zg-diagram-canvas[data-zg-diagram-fit] > svg {
  width: min(100%, var(--zg-diagram-width));
}
/* Too wide to shrink and stay readable (text at least 11 px, TY14): drawn at its width, the frame scrolls. */
.zg-diagram-view .zg-diagram-canvas[data-zg-diagram-scroll] > svg {
  width: var(--zg-diagram-width);
  /* Over Pele's inline max-width: 100%. */
  max-width: none !important;
  margin-inline: 0;
}
.zg-diagram-view .pele-edge > path,
.zg-diagram-view .pele-node > :not(text) {
  vector-effect: non-scaling-stroke;
}
.zg-diagram-view .pele-label {
  font-weight: 500;
  fill: var(--pele-fg) !important;
}
/* A styled node: the chip's fill, an accent outline; its label keeps the text color (DG4). */
.zg-diagram-view .pele-node > :not(text)[style*='fill:'],
.zg-diagram-view .pele-node > :not(text)[style*='stroke:'] {
  fill: var(--pele-surface) !important;
  stroke: var(--pele-accent) !important;
}
.zg-diagram-view .pele-edge > path[stroke-dasharray] {
  stroke-dasharray: 4 3;
}
.zg-diagram-view .pele-edge > path[stroke-width]:not(.pele-marker),
.zg-diagram-view .pele-edge[style*='stroke:'] > path:not(.pele-marker) {
  stroke: var(--pele-accent);
  stroke-width: 2px;
}
.zg-diagram-view .pele-edge:has(> path[stroke-width]:not(.pele-marker)) > .pele-marker,
.zg-diagram-view .pele-edge[style*='stroke:'] > .pele-marker {
  fill: var(--pele-accent);
}
.zg-diagram-view .pele-edge-label text {
  fill: var(--zg-text-muted);
}
/* The highlighted path (`highlight`, DG5): its edges 2 px in the accent, its nodes outlined in it. */
.zg-diagram-view .pele-edge[data-zg-path] > path:not(.pele-marker) {
  stroke: var(--pele-accent) !important;
  stroke-width: 2px;
}
.zg-diagram-view .pele-edge[data-zg-path] > .pele-marker {
  fill: var(--pele-accent) !important;
}
.zg-diagram-view .pele-node[data-zg-path] > :not(text) {
  stroke: var(--pele-accent) !important;
  stroke-width: 1.5px;
}
/* The key line's swatch: a short stroke of the path's accent. */
.zg-diagram-key-line {
  flex: none;
  width: 1rem;
  height: 2px;
  border-radius: 9999px;
  background: var(--zg-accent);
}
.zg-diagram-view .zg-diagram-value {
  fill: var(--zg-text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
/* Views (zidane-ui/views, docs/VIEWS.md). A view draws in its frame and never
   outside it: the frame clips and contains its layout and paint, so nothing a
   view holds can sit over the transcript or the app. */
.zg-view {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  contain: layout paint;
  max-width: 100%;
  font-family: var(--zg-font-chat);
  font-size: var(--zg-font-size-chat);
  line-height: var(--zg-leading-body);
}
/* The frame while the views chunk loads. */
.zg-view[data-zg-view='pending'] {
  min-height: 4rem;
}
/* A view being copied as an image: its controls stay out of the image. */
.zg-view[data-zg-view-capturing] [data-zg-view-controls],
.zg-view[data-zg-view-capturing] [data-zg-view-capture-skip] {
  visibility: hidden;
}
.zg-view-body {
  overflow: hidden;
  /* A view whose next state loads keeps its old tree; it dims only past this wait (docs/VIEWS.md, State). */
  --zg-view-wait: 150ms;
  transition: opacity var(--zg-motion-fade-out);
}
.zg-view-body[data-zg-view-waiting] {
  opacity: 0.7;
  transition: opacity var(--zg-motion-fade) var(--zg-view-wait);
}
/* The controls of a view's state: one row each, the label before the control. */
.zg-view-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  min-width: 0;
}
/* A part waiting for its code to run, or its chunk to load. */
.zg-view-skeleton {
  background: var(--zg-track);
  animation: zg-view-pulse 1.2s ease-in-out infinite alternate;
}
@keyframes zg-view-pulse {
  from {
    opacity: 0.5;
  }
  to {
    opacity: 1;
  }
}
html[data-motion='off'] .zg-view-skeleton,
html[data-motion='reduced'] .zg-view-skeleton {
  animation: none;
}
/* An element no component draws: a plain box, its words kept. */
.zg-view-unknown {
  box-shadow: inset 0 0 0 1px var(--zg-hairline);
}

/* Zoomed in: the drawing pans under the pointer. */
.zg-diagram-canvas[data-zoomed] {
  cursor: grab;
}
.zg-diagram-canvas[data-zoomed]:active {
  cursor: grabbing;
}

.zg-md > *:first-child {
  margin-top: 0;
}

.zg-md > *:last-child {
  margin-bottom: 0;
}

/* The prose rules below stay out of the views a reply draws. Only a box with views on
   (`.zg-md-views`, set by `Markdown` under `MarkdownViews`) pays for the check: without
   views the first selector is a plain descendant one. */
.zg-md:where(:not(.zg-md-views)) p,
.zg-md-views p:where(:not(.zg-view *)) {
  margin: 0 0 0.75em;
}

/*
 * The Markdown component strips headings, bold, italic and strike from a
 * chat reply (heading tags become <p>, the mark tags fragments) so the
 * chat surface matches the editor's structural-only construct set. A
 * document keeps bold and italic and draws headings as `.zg-md-heading`
 * paragraphs (below). No `.zg-md h*`, `.zg-md strong` or `.zg-md em`
 * rules exist.
 */
.zg-md:where(:not(.zg-md-views)) ul,
.zg-md-views ul:where(:not(.zg-view *)),
.zg-md:where(:not(.zg-md-views)) ol,
.zg-md-views ol:where(:not(.zg-view *)) {
  margin: 0 0 0.75em;
  padding-left: 1.5em;
}

.zg-md:where(:not(.zg-md-views)) ul,
.zg-md-views ul:where(:not(.zg-view *)) {
  list-style: disc;
}
/* One more digit width per digit past the first (`--zg-ol-digits`, set by the Markdown
   component), so "10." stays inside the gutter like "9." does. */
.zg-md:where(:not(.zg-md-views)) ol,
.zg-md-views ol:where(:not(.zg-view *)) {
  list-style: decimal;
  padding-left: calc(1.5em + (var(--zg-ol-digits, 1) - 1) * 1ch);
}
.zg-md:where(:not(.zg-md-views)) ol > li::marker,
.zg-md-views ol > li:where(:not(.zg-view *))::marker {
  font-variant-numeric: tabular-nums;
}

.zg-md:where(:not(.zg-md-views)) li,
.zg-md-views li:where(:not(.zg-view *)) {
  margin: 0.2em 0;
}

.zg-md:where(:not(.zg-md-views)) li > p,
.zg-md-views li > p:where(:not(.zg-view *)) {
  margin: 0;
}

.zg-md:where(:not(.zg-md-views)) blockquote,
.zg-md-views blockquote:where(:not(.zg-view *)) {
  margin: 0 0 0.75em;
  padding: 0.25em 0 0.25em 0.9em;
  border-left: 2px solid var(--zg-hairline);
  color: var(--zg-text-muted);
}

.zg-md .zg-md-heading {
  font-weight: var(--zg-weight-strong);
  color: var(--zg-text);
  margin-top: 1em;
}
.zg-md > .zg-md-heading:first-child {
  margin-top: 0;
}

.zg-md:where(:not(.zg-md-views)) hr,
.zg-md-views hr:where(:not(.zg-view *)) {
  border: none;
  border-top: 1px solid var(--zg-hairline);
  margin: 1em 0;
}

/* Tables sit in a tray: tone for the frame, hairlines between rows only. */
.zg-md:where(:not(.zg-md-views)) table,
.zg-md-views table:where(:not(.zg-view *)) {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 0 0.75em;
  font-size: 0.9em;
  background: var(--zg-tray);
  border-radius: var(--zg-radius-md);
  box-shadow: inset 0 0 0 1px var(--zg-hairline);
  overflow: hidden;
}

.zg-md:where(:not(.zg-md-views)) th,
.zg-md-views th:where(:not(.zg-view *)),
.zg-md:where(:not(.zg-md-views)) td,
.zg-md-views td:where(:not(.zg-view *)) {
  padding: 0.4em 0.75em;
  text-align: left;
}

.zg-md:where(:not(.zg-md-views)) tr + tr > td,
.zg-md-views tr + tr > td:where(:not(.zg-view *)),
.zg-md:where(:not(.zg-md-views)) thead + tbody > tr:first-child > td,
.zg-md-views thead + tbody > tr:first-child > td:where(:not(.zg-view *)) {
  border-top: 1px solid var(--zg-hairline);
}

.zg-md:where(:not(.zg-md-views)) th,
.zg-md-views th:where(:not(.zg-view *)) {
  font-weight: var(--zg-weight-strong);
  font-size: 0.92em;
  color: var(--zg-text-muted);
}

/* Inline code in a cell: the code tone matches the tray, which left the chip
   invisible and its padding reading as a stray indent against the header. The
   track tone sets it into the tray like every other chip, and a cell that is
   only code bleeds the chip padding into the cell's so its text lines up. */
.zg-md:where(:not(.zg-md-views)) table code,
.zg-md-views table code:where(:not(.zg-view *)) {
  background: var(--zg-track);
}
.zg-md:where(:not(.zg-md-views)) td > code:only-child,
.zg-md-views td > code:only-child:where(:not(.zg-view *)) {
  margin-inline-start: -0.25rem;
}

/* Image generation (`ImageGenerationBlock`). The frame takes the requested
   aspect ratio before the image exists, so the swap from loader to image never
   changes the row's height. While the call runs, a soft band sweeps across the
   tray (a loop: stilled under reduced / off motion). The image decodes off
   screen, then fades in and unblurs on `fade`. */
.zg-image-frame {
  position: relative;
  overflow: hidden;
  width: min(100%, 22rem);
  max-height: 20rem;
  border-radius: var(--zg-radius-md);
  background: var(--zg-tray);
}

/* The edge paints over the absolutely placed image (an inset shadow on the
   frame itself would sit under it). The pending sweep shares this layer. */
.zg-image-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--zg-hairline);
  pointer-events: none;
}

.zg-image-frame[data-pending]::after {
  background: linear-gradient(
      100deg,
      transparent 30%,
      color-mix(in srgb, var(--zg-text) 7%, transparent) 50%,
      transparent 70%
    )
    0 0 / 250% 100%;
  animation: zg-shimmer 1.8s linear infinite;
}

html[data-motion='off'] .zg-image-frame[data-pending]::after,
html[data-motion='reduced'] .zg-image-frame[data-pending]::after {
  animation: none;
}

.zg-image-frame > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
}

.zg-image-frame > img[data-ready] {
  --zg-blur-from: 8px;
  opacity: 1;
  animation:
    zg-fade-in var(--zg-motion-fade) both,
    zg-unblur var(--zg-motion-fade) both;
}

/*
 * Inline badges (chat/transcript/badges.tsx): files, skills, commands, links and
 * references, in the composer, sent prompts and replies alike. Every badge is
 * the same box: a plain inline box (text that does not wrap) in the
 * surrounding text's own face and size. Its 1px vertical padding only paints:
 * an inline box's padding never changes the line, so a line is the same height
 * with badges as without, and a descender (the g of `origin/main`) keeps a
 * pixel of background under it instead of touching the edge. In the composer
 * the caret beside or inside a badge is the caret anywhere else: Chrome draws
 * a misplaced, line-tall caret next to a non-editable inline-block, never
 * next to an inline box. A file name's code face is an inner
 * `.zg-badge-code`, so it never changes the box.
 */
.zg-badge {
  margin: 0 0.05em;
  padding: 1px 0.4em;
  border-radius: 0.35em;
  background: color-mix(in srgb, var(--zg-text) 8%, transparent);
  color: var(--zg-text);
  font: inherit;
  white-space: nowrap;
  text-decoration: none;
}
/*
 * A badge's toned-down second part (a ticket's title): its own clipped box
 * so a long one ends in an ellipsis. `overflow: hidden` moves an
 * inline-block's baseline to its bottom edge; top-aligned, it sits on the
 * label's line.
 */
.zg-badge-detail {
  display: inline-block;
  max-width: var(--zg-badge-detail-max, 24ch);
  margin-left: 0.35em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
  color: var(--zg-text-subtle);
}
.zg-badge-code {
  font-family: var(--zg-font-mono);
  font-size: 0.9em;
  /* Inside the box's own line: the code face's taller metrics never stretch it. */
  line-height: 1;
}
/*
 * Typed text (a link, a command's `/name`, decorated in the composer) keeps
 * the editor's whitespace handling: under `nowrap` the browser types a space
 * at its edge as a non-breaking one, which would reach the prompt. A link may
 * break where text can, so a long one never runs out of the box.
 */
.zg-badge[data-typed] {
  white-space: pre;
}
.zg-badge[data-typed][data-kind='link'] {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-decoration-break: clone;
}
a.zg-badge,
.zg-badge[role='button'] {
  cursor: pointer;
  transition:
    background-color var(--zg-motion-hover),
    box-shadow var(--zg-motion-hover);
}
@media (hover: hover) and (pointer: fine) {
  a.zg-badge:hover,
  .zg-badge[role='button']:hover {
    background: var(--zg-raised);
    box-shadow: var(--zg-shadow-raised);
  }
}
.zg-badge-icon,
.zg-badge-glyph::before {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-inline-end: 0.35em;
  vertical-align: -0.1em;
}
/*
 * The default icon color, at zero specificity: a tone class on the icon (a
 * reference's state, `text-zg-warn`) wins over it. As a plain class rule it
 * outranked them, and chip icons read gray whatever their state.
 */
:where(.zg-badge-icon) {
  color: var(--zg-text-muted);
}
.zg-badge-glyph::before {
  color: var(--zg-text-muted);
}
.zg-badge-glyph::before {
  content: '';
}
/* A language's two letters (`TS`, `PY`) in place of a type icon: drawn by CSS,
   so the badge's text is the name alone (what a copy or a screen reader gets). */
.zg-badge-letters::before {
  content: attr(data-letters);
}
/*
 * In its own smaller face, sized back to the icon box: as tall, the same gap,
 * the same bottom edge. `overflow: hidden` makes its bottom edge, not its
 * letters' baseline, what `vertical-align` places, as for the empty icon box;
 * the offset is the icon's -0.1em in this face.
 */
.zg-badge-letters {
  overflow: hidden;
  width: auto;
  min-width: calc(1.45em / 0.56);
  height: calc(0.9em / 0.56);
  margin-inline-end: calc(0.35em / 0.56);
  padding: 0 0.2em;
  border-radius: 0.25em;
  background: color-mix(in srgb, currentColor 14%, transparent);
  font-family: var(--zg-font-ui);
  font-size: 0.56em;
  font-weight: var(--zg-weight-strong);
  line-height: calc(0.9em / 0.56);
  letter-spacing: 0.02em;
  text-align: center;
  vertical-align: calc(-0.1em / 0.56);
}
.zg-badge-site::before {
  background: var(--zg-site-icon) center / contain no-repeat;
  border-radius: 2px;
}
/* The kinds' hues, on the glyph only: the badges stay one family. */
.zg-badge[data-kind='skill']::before {
  color: color-mix(in oklab, var(--zg-chip-skills-bg) 70%, var(--zg-text));
}
.zg-badge[data-kind='command']::before {
  color: color-mix(in oklab, var(--zg-chip-default-bg) 70%, var(--zg-text));
}
/* A link in prose (a reply) keeps its link styling, led by the site's icon. */
.zg-link-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-inline-end: 0.3em;
  vertical-align: -0.14em;
  border-radius: 2px;
  background: var(--zg-site-icon) center / contain no-repeat;
}

/* A wheel scroll in flight: the rows take no pointer events, so nothing
   restyles under a still pointer while they slide (useWheelHoverPause). The
   scrollbar belongs to the scroller and keeps working. */
[data-wheeling] > * {
  pointer-events: none;
}

/* A codemode script line by line (`CodemodeScript`): a sticky gutter (the
   state of the line's latest call, then its number) beside the code. Lines the
   script has not reached are dim; the running one carries the accent and the
   running sweep; a call that ends washes its line once; a failed line is red,
   the script's own error under it. A running script past 15 lines scrolls to
   follow its running line, and keeps that window once it ends. Motion stops
   under reduced / off. */
/* The frame's hairline, drawn again over the lines: the sticky gutter and the
   tinted lines are opaque, and covered it where they meet the frame's edge. */
.zg-script-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--zg-hairline);
  pointer-events: none;
}
.zg-script-lines {
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: 100%;
  padding-block: 0.5rem;
  font-family: var(--zg-font-mono);
  font-size: var(--zg-font-size-code);
  line-height: var(--zg-leading-ui);
  color: var(--zg-code-fg);
}
.zg-code-scroll[data-wrap] .zg-script-lines {
  width: auto;
}
/* A long script's window: the frame's own scroller takes it, so one element
   scrolls both ways and the sticky gutter stays put sideways too. */
.zg-code-scroll:has(> .zg-script-lines[data-window]) {
  max-height: calc(15 * 1.5 * var(--zg-font-size-code) + 1rem);
  overflow-y: auto;
  scroll-behavior: smooth;
}
html[data-motion='off'] .zg-code-scroll,
html[data-motion='reduced'] .zg-code-scroll {
  scroll-behavior: auto;
}
.zg-script-line {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  background: var(--zg-script-tint, transparent);
  transition: background-color var(--zg-motion-fade);
}
.zg-script-gutter {
  position: sticky;
  left: 0;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.375rem;
  padding-inline: var(--zg-code-pad-x) 0.75rem;
  background: var(--zg-code-bg);
  color: var(--zg-text-subtle);
  font-variant-numeric: tabular-nums;
  user-select: none;
  transition:
    background-color var(--zg-motion-fade),
    color var(--zg-motion-fade);
}
.zg-script-number {
  min-width: var(--zg-script-digits, 1ch);
  text-align: end;
}
.zg-script-mark {
  display: inline-block;
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  font-size: 0.75rem;
}
.zg-script-code {
  white-space: pre;
  padding-inline-end: var(--zg-code-pad-x);
  transition: opacity var(--zg-motion-fade);
}
.zg-code-scroll[data-wrap] .zg-script-code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.zg-script-line[data-state='idle'] .zg-script-code,
.zg-script-line[data-state='idle'] .zg-script-number {
  opacity: 0.4;
}
/* In a loop that went round again: ran in the round before, not yet in this one. */
.zg-script-line[data-state='previous'] .zg-script-code {
  opacity: 0.6;
}
.zg-script-line[data-state='previous'] .zg-script-mark {
  opacity: 0.35;
}
/* A `sleep`: the running tint, softer, and its mark breathing. */
.zg-script-line[data-state='waiting'] {
  --zg-script-tint: color-mix(in srgb, var(--zg-accent-wash) 40%, transparent);
  --zg-script-bar: color-mix(in srgb, var(--zg-accent) 60%, transparent);
}
.zg-script-line[data-state='waiting'] .zg-script-gutter {
  color: var(--zg-accent);
}
.zg-script-line[data-state='waiting'] .zg-script-mark {
  animation: zg-script-breathe 2s ease-in-out infinite;
}
html[data-motion='off'] .zg-script-line .zg-script-mark,
html[data-motion='reduced'] .zg-script-line .zg-script-mark {
  animation: none;
}

/* Loops: the first line's mark, and while the script is in a loop, its line
   numbers in the running color. */
.zg-script-loop {
  color: var(--zg-text-subtle);
  transition: color var(--zg-motion-fade);
}
.zg-script-loop[data-active] {
  color: var(--zg-accent);
}
.zg-script-line[data-in-loop] .zg-script-number {
  color: color-mix(in srgb, var(--zg-accent) 75%, var(--zg-text-subtle));
}

/* After a line's code: a loop's round, a line's call count, a wait's time left. */
.zg-script-note {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-inline-start: 0.625ch;
  border-radius: var(--zg-radius-xs);
  font-family: var(--zg-font-ui);
  font-size: 0.85em;
  color: var(--zg-text-subtle);
  font-variant-numeric: tabular-nums;
  vertical-align: 0.05em;
  transition: color var(--zg-motion-fade);
}
.zg-script-note[data-active] {
  padding-inline: 0.375rem;
  color: var(--zg-accent);
  background: color-mix(in srgb, var(--zg-accent-wash) 60%, transparent);
}
/* A line's tint and bar come from its state. The gutter stays opaque (code
   scrolled sideways passes under it): the tint goes on a layer over its own
   background, and the bar sits on it, so both stay in place while scrolling. */
.zg-script-line[data-state='running'] {
  --zg-script-tint: color-mix(in srgb, var(--zg-accent-wash) 70%, transparent);
  --zg-script-bar: var(--zg-accent);
}
.zg-script-line[data-state='failed'],
.zg-script-error {
  --zg-script-tint: color-mix(in srgb, var(--zg-danger-soft) 70%, transparent);
  --zg-script-bar: var(--zg-danger);
}
.zg-script-gutter::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--zg-script-tint, transparent);
  box-shadow: inset 2px 0 0 var(--zg-script-bar, transparent);
}
.zg-script-line[data-state='running'] .zg-script-gutter {
  color: var(--zg-accent);
}
.zg-script-line[data-state='running']::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
      100deg,
      transparent 30%,
      color-mix(in srgb, var(--zg-text) 6%, transparent) 50%,
      transparent 70%
    )
    0 0 / 250% 100%;
  animation: zg-shimmer 1.8s linear infinite;
}
.zg-script-line[data-state='done'] .zg-script-mark {
  color: var(--zg-success);
  animation: zg-fade-in var(--zg-motion-fade) both;
}
.zg-script-line[data-settling],
.zg-script-line[data-settling] .zg-script-gutter::before {
  animation: zg-script-settle calc(var(--zg-motion-fade-duration, 200ms) * 4) var(--zg-motion-fade-ease, ease-out) both;
}
.zg-script-error .zg-script-code,
.zg-script-error .zg-script-gutter {
  color: var(--zg-danger);
}
html[data-motion='off'] .zg-script-line::after,
html[data-motion='reduced'] .zg-script-line::after {
  animation: none;
}

@keyframes zg-script-breathe {
  50% {
    opacity: 0.4;
  }
}

@keyframes zg-script-settle {
  from {
    background-color: color-mix(in srgb, var(--zg-success-soft) 80%, transparent);
  }
}

/* What a command or a tool wrote, in every row: a tool's output, a `!` run, a script's
   live lines, a block's run. One tone and one metric, so live lines and the saved
   output that replaces them read the same (no swap from bright to muted). */
.zg-output {
  padding: 0.5rem var(--zg-code-pad-x, 12px);
  font-family: var(--zg-font-mono);
  font-size: var(--zg-font-size-code);
  line-height: var(--zg-leading-ui);
  color: var(--zg-text-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The last lines a running thing wrote (`LiveOutput`): a script's prints and shell calls, a Run here. */
.zg-live-output {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-top: 0.375rem;
  /* Each streamed line grows in (`Grow`, a grid-row tween): keep that layout
     inside the box, not spreading to the scroller and every visible row. */
  contain: layout;
}
.zg-live-output[data-full] {
  min-height: calc(var(--zg-live-tail) * 1.5em + 1rem);
}
/* A full window: the new line grows in as the oldest shrinks out, on one curve, so the
   box keeps its height and the lines slide up instead of the box breathing. */
.zg-live-output > .zg-grow,
.zg-live-output > .zg-grow[data-shown] {
  transition:
    grid-template-rows var(--zg-motion-settle),
    opacity var(--zg-motion-fade);
}
.zg-live-output [data-stream='console'],
.zg-live-output [data-stream='stderr'] {
  color: var(--zg-text-subtle);
}

/* A reply's shell block and its run under it (`RunnableCodeBlock`). */
.zg-run-block > .zg-code-frame {
  margin-block: 0;
}
.zg-run-panel {
  margin-top: 0.25rem;
}
.zg-run-panel > .zg-live-output {
  margin-top: 0.125rem;
}
.zg-run-output {
  margin-top: 0.125rem;
  max-height: calc(20 * 1.5em + 1rem);
  overflow: auto;
}
.zg-run-note {
  color: var(--zg-text-subtle);
  font-style: italic;
}
.zg-run-terminal {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--zg-text-muted);
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .zg-run-terminal:hover {
    color: var(--zg-text);
  }
}

/* Terminal colors (`AnsiText`): the 16 base colors on the theme's tokens, the bright
   ones lifted toward the text color. A span reads them by number; 256-palette and
   24-bit colors are its own. */
.zg-ansi {
  --zg-ansi-0: var(--zg-text-subtle);
  --zg-ansi-1: var(--zg-danger);
  --zg-ansi-2: var(--zg-success);
  --zg-ansi-3: var(--zg-warn);
  --zg-ansi-4: var(--zg-info);
  --zg-ansi-5: var(--zg-accent-alt);
  --zg-ansi-6: color-mix(in srgb, var(--zg-info) 50%, var(--zg-success));
  --zg-ansi-7: var(--zg-text-muted);
  --zg-ansi-8: var(--zg-text-subtle);
  --zg-ansi-9: color-mix(in srgb, var(--zg-ansi-1) 70%, var(--zg-text));
  --zg-ansi-10: color-mix(in srgb, var(--zg-ansi-2) 70%, var(--zg-text));
  --zg-ansi-11: color-mix(in srgb, var(--zg-ansi-3) 70%, var(--zg-text));
  --zg-ansi-12: color-mix(in srgb, var(--zg-ansi-4) 70%, var(--zg-text));
  --zg-ansi-13: color-mix(in srgb, var(--zg-ansi-5) 70%, var(--zg-text));
  --zg-ansi-14: color-mix(in srgb, var(--zg-ansi-6) 70%, var(--zg-text));
  --zg-ansi-15: var(--zg-text);
}

/* A running script's progress under its row's header: filled to its percent when
   that is exact, else a band that moves (still under reduced / off motion). */
.zg-script-bar {
  position: relative;
  display: block;
  height: 2px;
  margin-top: 0.25rem;
  overflow: hidden;
  border-radius: 9999px;
  background: var(--zg-track);
}
/* The fill scales from the left (composited), never animates its width; the
   track's clip rounds its end. */
.zg-script-bar::after {
  content: '';
  position: absolute;
  inset-block: 0;
  left: 0;
  width: 100%;
  transform: scaleX(var(--zg-script-scale, 0));
  transform-origin: left;
  background: var(--zg-accent);
  transition: transform var(--zg-motion-settle);
}
.zg-script-bar[data-indeterminate]::after {
  width: 30%;
  transform: none;
  animation: zg-script-band 1.4s ease-in-out infinite;
}
html[data-motion='off'] .zg-script-bar[data-indeterminate]::after,
html[data-motion='reduced'] .zg-script-bar[data-indeterminate]::after {
  width: 100%;
  opacity: 0.35;
  animation: none;
}

@keyframes zg-script-band {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

/* An environment setup step (`EnvironmentSetupRow`): no enter of its own (the
   fold's collapse opens it, and a remount must not replay one); a step's words
   brighten as it starts and dim as it finishes, on the fade clock (motion off:
   at once). */
.zg-environment-setup-step {
  transition:
    color var(--zg-motion-fade),
    opacity var(--zg-motion-fade);
}
/* A setup step's whole output: about twelve lines tall, scrolled inside so
   the transcript keeps its place, a wheel at its end staying in the log. */
.zg-environment-setup-log {
  max-height: 15rem;
  overflow: auto;
  overscroll-behavior: contain;
}
