/*
 * Drawn product graphics (src/graphics/library.js).
 *
 * The markup is the settled state. Everything below the "motion" line only
 * applies while the motion engine marks a graphic `data-live="true"`, i.e.
 * while it is on screen in a browser that has not asked for reduced motion.
 * Tokens only: no raw colour values outside design-tokens.css.
 */

.gfx {
  --gfx-loop: 14s;
  --gfx-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --gfx-surface: var(--color-surface-raised);
  --gfx-border: var(--color-border-subtle);
  --gfx-shadow:
    0 1px 2px var(--color-shadow-subtle),
    0 18px 40px -24px var(--color-shadow-medium);
  position: relative;
  width: 100%;
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  container-type: inline-size;
}

.gfx__inner {
  position: relative;
}

/* A graphic may sit inside a card link: it never inherits link styling. */
a .gfx,
a .gfx * {
  color: inherit;
  text-decoration: none;
}

.gfx *,
.gfx *::before,
.gfx *::after {
  box-sizing: border-box;
}

.gfx q::before,
.gfx q::after {
  content: "“";
}

.gfx q::after {
  content: "”";
}

.gfx img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- shared atoms ------------------------------------------------------- */

.gfx-thumb {
  display: block;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 3px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--color-surface-tinted);
}

.gfx-mark {
  display: inline-flex;
  flex: none;
  width: 22px;
  height: 22px;
  overflow: hidden;
  border-radius: 6px;
}

.gfx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gfx-list--panel {
  gap: 0;
  padding: 14px 16px 6px;
  border: 1px solid var(--gfx-border);
  border-radius: 12px;
  background: var(--gfx-surface);
}

.gfx-list__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
  color: var(--color-text-tertiary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gfx-list--panel .gfx-list__head {
  padding: 0 0 10px;
  color: var(--color-text-primary);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}

.gfx-list--panel .gfx-list__head > b {
  color: var(--color-text-tertiary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gfx-list__head > b:not(.gfx-list__live):not(.gfx-tag) {
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.gfx-list__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--gfx-border);
  border-radius: var(--radius-pill);
  background: var(--gfx-surface);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.gfx-list__live > i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-brand-signal);
}

.gfx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gfx-border);
  border-radius: 12px;
  background: var(--gfx-surface);
  box-shadow: var(--gfx-shadow);
}

.gfx-row--line {
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--gfx-border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.gfx-row__text {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.gfx-row__text > strong {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gfx-row__text > small {
  overflow: hidden;
  color: var(--color-text-tertiary);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gfx-bar {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--color-border-default);
}

.gfx-tag {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gfx-tag.is-signal {
  background: var(--color-brand-signal-soft);
  color: var(--color-text-primary);
}

.gfx-state {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.gfx-state svg {
  width: 12px;
  height: 12px;
}

.gfx-state.is-done {
  background: var(--color-status-success-soft);
  color: var(--color-status-success);
}

.gfx-state.is-review {
  background: var(--color-action-primary);
  color: var(--color-text-inverse);
}

.gfx-state.is-working {
  background: var(--color-surface-subtle);
  color: var(--color-text-tertiary);
}

.gfx-link-state {
  flex: none;
  color: var(--color-glacier-blue);
  font-size: 11.5px;
  font-weight: 500;
}

.gfx-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.gfx-check svg {
  width: 14px;
  height: 14px;
}

.gfx-check.is-missing {
  color: var(--color-text-tertiary);
}

.gfx-check.is-ok {
  color: var(--color-status-success);
  font-weight: 500;
}

.gfx-footnote {
  margin: 12px 0 0;
  color: var(--color-text-tertiary);
  font-size: 12px;
}

/* ---- chat --------------------------------------------------------------- */

.gfx--chat {
  /* One engine per 12s pass; six engines make a 72s round. */
  --gfx-loop: 12s;
  --gfx-round: calc(var(--gfx-loop) * 6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.gfx-chat__window {
  position: relative;
  width: 100%;
  max-width: 860px;
  overflow: visible;
  border: 1px solid var(--gfx-border);
  border-radius: 20px;
  background: var(--gfx-surface);
  box-shadow:
    0 1px 2px var(--color-shadow-subtle),
    0 30px 60px -30px var(--color-shadow-strong);
}

.gfx-chat__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gfx-border);
}

.gfx-engine-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--gfx-border);
  border-radius: 6px;
  background: var(--color-white);
}

.gfx-engine-mark img {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.gfx-chat__engines {
  position: relative;
  display: inline-grid;
}

.gfx-chat__engine {
  display: inline-flex;
  grid-area: 1 / 1;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  opacity: 0;
}

.gfx-chat__engine:first-child {
  opacity: 1;
}

.gfx-chat__engine .gfx-engine-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.gfx-chat__engine .gfx-engine-mark img {
  width: 16px;
  height: 16px;
}

.gfx-chat__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-tertiary);
  font-size: 12px;
}

.gfx-chat__live > i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-status-success);
}

.gfx-chat__body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.gfx-chat__question {
  display: flex;
  justify-content: flex-end;
}

.gfx-chat__typed {
  display: inline-block;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--color-surface-subtle);
  font-size: 15px;
  line-height: 1.4;
}

.gfx-chat__typed > span {
  display: inline;
}

.gfx-chat__caret {
  display: none;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--color-text-primary);
}

.gfx-chat__thinking {
  display: none;
  gap: 5px;
  align-items: center;
  height: 0;
  margin: -18px 0 0;
}

.gfx-chat__thinking > i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
}

.gfx-chat__answer {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 15px;
  line-height: 1.55;
}

.gfx-chat__cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.gfx-chat__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 14px;
  border: 1px solid var(--gfx-border);
  border-radius: 12px;
  background: var(--gfx-surface);
}

.gfx-chat__card.is-mine {
  border-color: var(--color-brand-signal);
  box-shadow: 0 0 0 1px var(--color-brand-signal);
}

.gfx-chat__mine {
  position: absolute;
  top: -10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-brand-signal);
  color: var(--color-text-primary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gfx-chat__image {
  display: block;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  padding: 6px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--color-surface-raised), var(--color-surface-tinted));
}

.gfx-chat__brand {
  color: var(--color-text-tertiary);
  font-size: 11px;
}

.gfx-chat__name {
  font-size: 14px;
  font-weight: 500;
}

.gfx-chat__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.gfx-chat__meta > b {
  font-size: 13px;
  font-weight: 600;
}

.gfx-chat__meta > span {
  color: var(--color-text-tertiary);
  font-size: 11px;
}

.gfx-chat__tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.gfx-chat__tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--color-surface-subtle);
  color: var(--color-text-tertiary);
  font-size: 13px;
  font-weight: 500;
}

.gfx-chat__tab .gfx-engine-mark {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.gfx-chat__tab .gfx-engine-mark img {
  width: 12px;
  height: 12px;
}

.gfx-chat__tab:first-child {
  border-color: var(--gfx-border);
  background: var(--gfx-surface);
  color: var(--color-text-primary);
}

@container (max-width: 640px) {
  .gfx-chat__cards {
    grid-template-columns: 1fr;
  }

  .gfx-chat__card:not(.is-mine) {
    display: none;
  }

  .gfx-chat__body {
    padding: 18px;
  }

  .gfx-chat__live {
    display: none;
  }

}

/* ---- connect ------------------------------------------------------------ */

.gfx-connect__stage {
  position: relative;
  aspect-ratio: 520 / 330;
  width: 100%;
  font-size: clamp(11px, calc(14cqw / 5.2), 14px);
}

.gfx-connect__links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gfx-connect__link {
  fill: none;
  stroke: var(--color-glacier-blue);
  stroke-opacity: 0.35;
  stroke-width: 1.5;
}

.gfx-connect__link[style*="--i:0"] {
  stroke: var(--color-brand-signal);
  stroke-opacity: 1;
  stroke-width: 2;
}

.gfx-connect__source {
  position: absolute;
  left: 0;
  display: flex;
  align-items: center;
  width: calc(170 / 520 * 100%);
  height: calc(44 / 330 * 100%);
  padding: 0 calc(12 / 520 * 100%);
  line-height: 1.1;
  border: 1px solid var(--gfx-border);
  border-radius: 12px;
  background: var(--gfx-surface);
  box-shadow: var(--gfx-shadow);
  font-weight: 500;
}

.gfx-connect__source.is-first {
  border-color: var(--color-brand-signal);
  box-shadow: 0 0 0 1px var(--color-brand-signal), var(--gfx-shadow);
}

.gfx-connect__node {
  position: absolute;
  top: calc(136 / 330 * 100%);
  left: calc(372 / 520 * 100%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: calc(46 / 330 * 100%);
  padding: 0 18px 0 12px;
  border-radius: 14px;
  background: var(--color-surface-inverse);
  box-shadow: 0 14px 30px -14px var(--color-shadow-elevated);
  color: var(--color-text-inverse);
  font-size: 1.07em;
  font-weight: 500;
}

.gfx-connect__thumbs {
  position: absolute;
  top: calc(276 / 330 * 100%);
  left: calc(200 / 520 * 100%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--gfx-border);
  border-radius: 10px;
  background: var(--gfx-surface);
}

.gfx-connect__thumbs .gfx-thumb {
  width: calc(40 / 520 * 100cqw);
  height: calc(40 / 520 * 100cqw);
  border-radius: 6px;
}

.gfx-connect__synced {
  position: absolute;
  top: calc(286 / 330 * 100%);
  left: calc(372 / 520 * 100%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-status-success-soft);
  color: var(--color-status-success);
  font-size: 0.86em;
  font-weight: 600;
  white-space: nowrap;
}

.gfx-connect__synced svg {
  width: 12px;
  height: 12px;
}

/* ---- questions ---------------------------------------------------------- */

.gfx-questions__row > q {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gfx-questions__row.is-first {
  border-color: var(--color-border-ocean);
  background: var(--color-surface-blue-soft, var(--color-surface-tinted));
}

.gfx-questions__volume {
  flex: none;
  color: var(--color-text-tertiary);
  font-size: 12px;
}

.gfx-rank {
  flex: none;
  min-width: 36px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.gfx-rank.is-up {
  background: var(--color-status-success-soft);
  color: var(--color-status-success);
}

.gfx-rank.is-down {
  background: var(--color-brand-signal-soft);
  color: var(--color-text-primary);
}

.gfx-rank.is-none {
  background: var(--color-surface-subtle);
  color: var(--color-text-tertiary);
}

/* ---- drafts ------------------------------------------------------------- */

.gfx-drafts__icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-surface-tinted);
}

.gfx-drafts__row.is-done .gfx-drafts__icon {
  background: var(--color-status-success-soft);
}

.gfx-drafts__row.is-review .gfx-drafts__icon {
  background: var(--color-brand-signal-soft);
}

/* ---- orders ------------------------------------------------------------- */

.gfx-orders__stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.gfx-orders__total {
  font-size: clamp(44px, 12cqw, 60px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.gfx-orders__share {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-status-success-soft);
  color: var(--color-status-success);
  font-size: 12px;
  font-weight: 600;
}

.gfx-orders__list {
  width: 100%;
  padding-top: 8px;
}

.gfx-orders__price {
  flex: none;
  color: var(--color-status-success);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- enrichment --------------------------------------------------------- */

.gfx-enrich {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.gfx-enrich__panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--gfx-border);
  border-radius: 12px;
  background: var(--gfx-surface);
}

.gfx-enrich__panel.is-before {
  background: var(--color-surface-muted);
}

.gfx-enrich__panel.is-after {
  border-color: var(--color-brand-signal);
  box-shadow: 0 0 0 1px var(--color-brand-signal);
}

.gfx-enrich__image {
  display: block;
  aspect-ratio: 306 / 110;
  overflow: hidden;
  padding: 6px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--color-surface-raised), var(--color-surface-tinted));
}

.gfx-enrich__panel.is-before .gfx-enrich__image {
  background: var(--gfx-surface);
  opacity: 0.55;
}

.gfx-enrich__attrs,
.gfx-enrich__docs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gfx-attr {
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-tinted);
  color: var(--color-deep-ocean);
  font-size: 11px;
  font-weight: 500;
}

.gfx-doc {
  padding: 5px 10px;
  border: 1px solid var(--gfx-border);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}

@container (max-width: 560px) {
  .gfx-enrich {
    grid-template-columns: 1fr;
  }
}

/* ---- reporting ---------------------------------------------------------- */

.gfx-report {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--gfx-border);
  border-radius: 12px;
  background: var(--gfx-surface);
}

.gfx-report__tabs {
  display: flex;
  gap: 4px;
}

.gfx-report__tab {
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  color: var(--color-text-tertiary);
  font-size: 11px;
  font-weight: 500;
}

.gfx-report__tab.is-active {
  background: var(--color-action-primary);
  color: var(--color-text-inverse);
}

.gfx-report__kpis {
  display: flex;
  gap: 28px;
}

.gfx-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gfx-kpi > small {
  color: var(--color-text-tertiary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gfx-kpi > b {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.gfx-kpi em {
  color: var(--color-status-success);
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}

.gfx-report__chart {
  width: 100%;
  height: auto;
  aspect-ratio: 276 / 90;
  overflow: visible;
}

.gfx-report__grid line {
  stroke: var(--color-border-subtle);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.gfx-report__area {
  fill: var(--color-brand-signal);
  fill-opacity: 0.18;
}

.gfx-report__line {
  fill: none;
  stroke: var(--color-brand-signal);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.gfx-report__dot {
  fill: var(--color-brand-signal);
  stroke: var(--color-white);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* ---- feeds -------------------------------------------------------------- */

.gfx-feeds__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 36px;
  border: 1px solid var(--gfx-border);
  border-radius: 5px;
  background: var(--color-surface-subtle);
  color: var(--color-text-tertiary);
}

.gfx-feeds__icon svg {
  width: 16px;
  height: 16px;
}

.gfx-feeds__ok {
  display: inline-flex;
  flex: none;
  color: var(--color-status-success);
}

.gfx-feeds__ok svg {
  width: 16px;
  height: 16px;
}

/* ---- activity ----------------------------------------------------------- */

.gfx-activity__row {
  gap: 14px;
}

.gfx-activity__time {
  flex: none;
  width: 64px;
  color: var(--color-text-tertiary);
  font-size: 11px;
}

.gfx-activity__event {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gfx-activity__who {
  flex: none;
  color: var(--color-text-tertiary);
  font-size: 11px;
}

.gfx-activity__state {
  flex: none;
  font-size: 11px;
  font-weight: 600;
}

.gfx-activity__state.is-done {
  color: var(--color-status-success);
}

.gfx-activity__state.is-review {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-brand-signal-soft);
  color: var(--color-text-primary);
}

.gfx-activity__state.is-muted {
  color: var(--color-text-tertiary);
}

@container (max-width: 520px) {
  .gfx-activity__who,
  .gfx-activity__time {
    display: none;
  }

  .gfx-activity__event {
    white-space: normal;
    font-size: 12.5px;
  }
}

@container (max-width: 480px) {
  .gfx-questions__row > q {
    white-space: normal;
    font-size: 13px;
    line-height: 1.3;
  }

  .gfx-questions__volume {
    display: none;
  }

  .gfx-list__head {
    font-size: 10px;
  }
}

/* ======================================================================== */
/* Motion. Only while on screen, never under reduced motion.                 */
/* ======================================================================== */

@media (prefers-reduced-motion: no-preference) {
  /* Shared row entrance: slide up and firm, staggered by --i, then hold. The
     loop restarts from the end so the graphic keeps breathing while in view.
     Opacity floors at 0.35, never 0: a row that is mid-entrance is still
     readable. */
  @keyframes gfx-row-in {
    0% {
      opacity: 0.35;
      transform: translateY(14px);
    }
    6% {
      opacity: 1;
      transform: translateY(0);
    }
    94% {
      opacity: 1;
      transform: translateY(0);
    }
    100% {
      opacity: 0.35;
      transform: translateY(14px);
    }
  }

  [data-live="true"] .gfx-row,
  [data-live="true"] .gfx-connect__source {
    animation: gfx-row-in var(--gfx-loop) var(--gfx-ease) calc(var(--i, 0) * 0.14s) infinite both;
  }

  /* --- chat timeline, one 12s pass per engine --------------------------
     0.0-1.6s   question types in, caret blinks
     1.8-2.8s   thinking dots
     2.8-4.2s   answer streams
     4.4-5.6s   three product cards slide in, one after the other
     6.0s       "your product" badge pops
     10.8-12s   the whole body fades and the next engine takes over
     Cards, badge and note are genuinely hidden before their moment: the
     scene is a sequence, not a reveal of something already there. The
     settled markup (no script, reduced motion) shows the full answer. */
  @keyframes gfx-chat-body {
    0% {
      opacity: 0;
    }
    3%,
    90% {
      opacity: 1;
    }
    100% {
      opacity: 0;
    }
  }

  @keyframes gfx-typed {
    0% {
      clip-path: inset(0 100% 0 0);
    }
    13% {
      clip-path: inset(0 -2px 0 0);
    }
    100% {
      clip-path: inset(0 -2px 0 0);
    }
  }

  @keyframes gfx-caret {
    0%,
    13% {
      opacity: 1;
    }
    16%,
    100% {
      opacity: 0;
    }
  }

  @keyframes gfx-caret-blink {
    50% {
      opacity: 0.1;
    }
  }

  @keyframes gfx-thinking {
    0%,
    14% {
      opacity: 0;
      height: 0;
      margin-top: -18px;
    }
    15%,
    22% {
      opacity: 1;
      height: 16px;
      margin-top: 0;
    }
    23%,
    100% {
      opacity: 0;
      height: 0;
      margin-top: -18px;
    }
  }

  @keyframes gfx-thinking-dot {
    0%,
    100% {
      transform: translateY(0);
      opacity: 0.4;
    }
    50% {
      transform: translateY(-3px);
      opacity: 1;
    }
  }

  @keyframes gfx-stream {
    0%,
    23% {
      clip-path: inset(0 0 100% 0);
      opacity: 0;
    }
    35% {
      clip-path: inset(0 0 -4px 0);
      opacity: 1;
    }
    100% {
      clip-path: inset(0 0 -4px 0);
      opacity: 1;
    }
  }

  @keyframes gfx-card-in {
    0%,
    36% {
      opacity: 0;
      transform: translateY(16px);
    }
    42%,
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes gfx-pop {
    0%,
    50% {
      opacity: 0;
      transform: scale(0.8);
    }
    53% {
      opacity: 1;
      transform: scale(1.08);
    }
    56%,
    100% {
      opacity: 1;
      transform: scale(1);
    }
  }

  /* Each engine owns one 12s window of the 72s round, in the header and in
     the tab strip. The windows are contiguous, so exactly one is visible. */
  @keyframes gfx-engine-turn {
    0% {
      opacity: 0;
      transform: translateY(6px);
    }
    1.5%,
    15.5% {
      opacity: 1;
      transform: translateY(0);
    }
    16.666%,
    100% {
      opacity: 0;
      transform: translateY(-6px);
    }
  }

  @keyframes gfx-tab-turn {
    0%,
    16.666% {
      border-color: var(--gfx-border);
      background: var(--gfx-surface);
      color: var(--color-text-primary);
    }
    16.667%,
    100% {
      border-color: transparent;
      background: var(--color-surface-subtle);
      color: var(--color-text-tertiary);
    }
  }

  /* Hero placement: the scene must never be empty, so only the typing,
     the engine rotation and the badge pop run; answer and cards stay. */
  [data-live="true"] .gfx--chat:not(.gfx--hero) .gfx-chat__body {
    animation: gfx-chat-body var(--gfx-loop) var(--gfx-ease) infinite both;
  }

  [data-live="true"] .gfx-chat__typed {
    animation: gfx-typed var(--gfx-loop) steps(30, end) infinite both;
  }

  [data-live="true"] .gfx-chat__caret {
    display: inline-block;
    animation:
      gfx-caret var(--gfx-loop) step-end infinite both,
      gfx-caret-blink 0.7s step-end infinite;
  }

  [data-live="true"] .gfx--chat:not(.gfx--hero) .gfx-chat__thinking {
    display: inline-flex;
    animation: gfx-thinking var(--gfx-loop) var(--gfx-ease) infinite both;
  }

  [data-live="true"] .gfx--chat:not(.gfx--hero) .gfx-chat__thinking > i {
    animation: gfx-thinking-dot 0.9s ease-in-out calc(var(--i, 0) * 0.15s) infinite;
  }

  [data-live="true"] .gfx-chat__thinking > i:nth-child(2) {
    --i: 1;
  }

  [data-live="true"] .gfx-chat__thinking > i:nth-child(3) {
    --i: 2;
  }

  [data-live="true"] .gfx--chat:not(.gfx--hero) .gfx-chat__answer {
    animation: gfx-stream var(--gfx-loop) var(--gfx-ease) infinite both;
  }

  [data-live="true"] .gfx--chat:not(.gfx--hero) .gfx-chat__card {
    animation: gfx-card-in var(--gfx-loop) var(--gfx-ease) calc(var(--i, 0) * 0.45s) infinite both;
  }

  [data-live="true"] .gfx-chat__mine {
    animation: gfx-pop var(--gfx-loop) var(--gfx-ease) infinite both;
  }

  [data-live="true"]   [data-live="true"] .gfx-chat__engine,
  [data-live="true"] .gfx-chat__engine:first-child {
    opacity: 0;
    animation: gfx-engine-turn var(--gfx-round) var(--gfx-ease) calc(var(--i, 0) * var(--gfx-loop)) infinite both;
  }

  [data-live="true"] .gfx-chat__tab,
  [data-live="true"] .gfx-chat__tab:first-child {
    animation: gfx-tab-turn var(--gfx-round) linear calc(var(--i, 0) * var(--gfx-loop)) infinite both;
  }

  /* --- connect: the links draw in, the node breathes once --------------- */
  @keyframes gfx-draw {
    0% {
      stroke-dashoffset: 1;
    }
    12% {
      stroke-dashoffset: 0;
    }
    94% {
      stroke-dashoffset: 0;
    }
    100% {
      stroke-dashoffset: 1;
    }
  }

  @keyframes gfx-pulse {
    0%,
    10% {
      transform: scale(1);
      box-shadow: 0 14px 30px -14px var(--color-shadow-elevated);
    }
    14% {
      transform: scale(1.04);
      box-shadow: 0 0 0 10px var(--color-signal-wash), 0 14px 30px -14px var(--color-shadow-elevated);
    }
    20%,
    100% {
      transform: scale(1);
      box-shadow: 0 14px 30px -14px var(--color-shadow-elevated);
    }
  }

  [data-live="true"] .gfx-connect__link {
    stroke-dasharray: 1;
    animation: gfx-draw var(--gfx-loop) var(--gfx-ease) calc(0.6s + var(--i, 0) * 0.12s) infinite both;
  }

  [data-live="true"] .gfx-connect__node {
    animation: gfx-pulse var(--gfx-loop) var(--gfx-ease) infinite both;
  }

  [data-live="true"] .gfx-connect__thumbs,
  [data-live="true"] .gfx-connect__synced {
    --i: 7;
    animation: gfx-row-in var(--gfx-loop) var(--gfx-ease) calc(var(--i) * 0.14s) infinite both;
  }

  /* --- drafts: working rows resolve into applied ------------------------ */
  @keyframes gfx-resolve {
    0%,
    40% {
      background: var(--color-surface-subtle);
      color: var(--color-text-tertiary);
    }
    46%,
    100% {
      background: var(--color-status-success-soft);
      color: var(--color-status-success);
    }
  }

  [data-live="true"] .gfx-drafts__row.is-working .gfx-state {
    animation: gfx-resolve var(--gfx-loop) var(--gfx-ease) calc(var(--i, 0) * 0.5s) infinite both;
  }

  @keyframes gfx-blink {
    0%,
    100% {
      opacity: 1;
    }
    50% {
      opacity: 0.3;
    }
  }

  [data-live="true"] .gfx-list__live > i {
    animation: gfx-blink 1.6s ease-in-out infinite;
  }

  /* --- enrichment: the after panel fills in ----------------------------- */
  @keyframes gfx-chip-in {
    0%,
    14% {
      opacity: 0.35;
      transform: translateY(6px) scale(0.96);
    }
    20% {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
    94% {
      opacity: 1;
    }
    100% {
      opacity: 0.35;
    }
  }

  [data-live="true"] .gfx-attr,
  [data-live="true"] .gfx-doc {
    animation: gfx-chip-in var(--gfx-loop) var(--gfx-ease) calc(var(--i, 0) * 0.12s) infinite both;
  }

  [data-live="true"] .gfx-doc {
    animation-delay: calc(0.7s + var(--i, 0) * 0.12s);
  }

  [data-live="true"] .gfx-enrich__panel.is-after .gfx-check {
    --i: 6;
    animation: gfx-chip-in var(--gfx-loop) var(--gfx-ease) calc(0.9s + var(--i) * 0.1s) infinite both;
  }

  /* --- reporting: the line draws, the dot lands ------------------------- */
  [data-live="true"] .gfx-report__line {
    stroke-dasharray: 1;
    animation: gfx-draw var(--gfx-loop) var(--gfx-ease) 0.3s infinite both;
  }

  @keyframes gfx-area-in {
    0% {
      opacity: 0;
    }
    14% {
      opacity: 1;
    }
    94% {
      opacity: 1;
    }
    100% {
      opacity: 0;
    }
  }

  [data-live="true"] .gfx-report__area {
    animation: gfx-area-in var(--gfx-loop) var(--gfx-ease) infinite both;
  }

  [data-live="true"] .gfx-report__dot {
    transform-box: fill-box;
    transform-origin: center;
    animation: gfx-pop var(--gfx-loop) var(--gfx-ease) -3.6s infinite both;
  }
}
