/* ==========================================================================
   demo.css — the showcase (tab strip + mock app window + scripted scenes)
   Owner: Agent B. Every selector here begins `.demo-` (plus @keyframes
   prefixed `demo-`). Consumes tokens.css only — never redefines a token,
   never styles a bare element, never assumes site.css is present.
   ========================================================================== */

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

/* ---------------------------------------------------------------------------
   1. Tab strip
   ------------------------------------------------------------------------- */

.demo-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  /* The strip's top edge is the section's own dashed seam (site.css `.demo::before`); its bottom
     edge is a full-bleed dashed line (`.demo-tabs::after`, site.css) drawn in this transparent row. */
  border-bottom: 1px solid transparent;
}

.demo-tab {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 20px 16px;
  column-gap: 10px;
  row-gap: 3px;
  align-content: center;
  justify-content: start;
  height: 76px;
  min-width: 0;
  padding-inline: 16px;
  margin: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.demo-tab:last-child { border-right: 0; }

.demo-tab:hover { background: var(--surface-hover); }

.demo-tab.is-active { background: var(--surface-active); }

.demo-tab:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: -2px;
  z-index: 1;
}

.demo-tab__num {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-subtle);
}

.demo-tab.is-active .demo-tab__num { color: var(--accent-ink); }

.demo-tab__title {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 20px;
  font-size: 15px;
  font-weight: var(--fw-regular);
  color: var(--ink-soft);
}

.demo-tab.is-active .demo-tab__title { color: var(--ink-strong); }

.demo-tab__sub {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 16px;
  font-size: 12.5px;
  font-weight: var(--fw-body);
  color: var(--ink-subtle);
}

.demo-tab__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;   /* above the dashed line under the strip */
}

.demo-tab__bar b {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

@media (max-width: 999px) {
  .demo-tab {
    grid-template-columns: auto auto;
    grid-template-rows: 20px;
    justify-content: center;
  }
  .demo-tab__sub { display: none; }
  .demo-tab__num { grid-row: 1; }
  .demo-tab__title { grid-row: 1; }
}

@media (max-width: 759px) {
  .demo-tab {
    grid-template-columns: 1fr;
    height: 52px;
    padding-inline: 16px;
    justify-content: stretch;
  }
  .demo-tab__num { display: none; }
  .demo-tab__title {
    grid-column: 1;
    text-align: center;
    font-size: 14px;
  }
}

/* ---------------------------------------------------------------------------
   2. Panel chrome — stage, caption, pause
   ------------------------------------------------------------------------- */

.demo-panel {
  position: relative;
  padding: clamp(24px, 5vw, 56px);
  background: var(--surface);
}

.demo-stage {
  display: flex;
  justify-content: center;
}

.demo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
  max-width: 1000px;
  margin: 20px auto 0;
}

.demo-caption {
  flex: 1 1 320px;
  max-width: 60ch;
  margin: 0;
  font-size: 15px;
  line-height: var(--lh-body);
  color: var(--ink-2);
  transition: opacity var(--dur) var(--ease-out);
}

.demo-caption.is-swapping { opacity: 0; }

.demo-pause {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 4px 2px;
  border: 0;
  background: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ink-soft);
  cursor: pointer;
}

.demo-pause__label { border-bottom: 1px solid transparent; }
.demo-pause:hover .demo-pause__label { border-bottom-color: currentColor; }

.demo-pause:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

.demo-pause__icon svg { display: block; }

.demo-noscript {
  max-width: 60ch;
  margin: 24px auto 0;
  text-align: center;
  font-size: 14px;
  line-height: var(--lh-body);
  color: var(--ink-2);
}

@media (max-width: 759px) {
  .demo-meta { flex-direction: column; gap: 10px; }
  .demo-pause { margin-left: 0; }
}

/* ---------------------------------------------------------------------------
   3. The window
   ------------------------------------------------------------------------- */

.demo-window {
  position: relative;
  width: min(1000px, 100%);
  height: clamp(480px, 46vw, 580px);
  margin-inline: auto;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--rule-warm);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-window);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

@media (min-width: 760px) and (max-width: 999px) {
  .demo-window { height: clamp(520px, 62vw, 580px); }
}

/* -- Top bar --------------------------------------------------------------- */

.demo-titlebar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding-inline: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule-warm);
}

.demo-titlebar__mark { display: block; flex: 0 0 auto; color: var(--ink); }
.demo-titlebar__mark .demo-mark__dot { fill: var(--accent); }
.demo-titlebar__mark .demo-mark__frame { fill: none; stroke: currentColor; }

.demo-titlebar__sep { color: var(--ink-faint); font-size: 13px; }

.demo-titlebar__workspace {
  min-width: 0;
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--ink-strong);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.demo-titlebar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex: 0 0 auto;
}

.demo-avatars { display: flex; }
.demo-avatars .demo-avatar:not(:first-child) { margin-left: -6px; }

.demo-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid var(--surface);
  background: var(--accent-ink);
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--fw-regular);
}

.demo-avatar--b { background: var(--ink-2); }

.demo-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--ink-faint);
}

.demo-icon-btn--share.is-hot { color: var(--ink-soft); }

@media (max-width: 759px) {
  .demo-icon-btn:not(.demo-icon-btn--share) { display: none; }
}

/* -- Thread bar -------------------------------------------------------------- */

.demo-threadbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding-inline: 16px;
  border-bottom: 1px solid var(--rule-warm);
  color: var(--ink-soft);
}

.demo-threadbar__back { flex: 0 0 auto; color: var(--ink-soft); }

.demo-threadbar__title {
  min-width: 0;
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* -- Body / split ------------------------------------------------------------ */

.demo-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
}

.demo-chat {
  grid-column: 1;
  grid-row: 1;
  width: min(540px, 100%);
  min-width: 0;
  height: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
}

.demo-body.has-result {
  grid-template-columns: minmax(250px, 34%) 1fr;
}

.demo-body.has-result .demo-chat {
  width: auto;
  margin-inline: 0;
}

.demo-art {
  display: none;
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--rule-warm);
  opacity: 0;
  flex-direction: column;
}

.demo-body.has-result .demo-art {
  display: flex;
  opacity: 1;
}

.demo-sheet__grabber,
.demo-sheet__docked { display: none; }

/* ---------------------------------------------------------------------------
   4. Chat
   ------------------------------------------------------------------------- */

.demo-chat__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  mask-image: linear-gradient(to bottom, transparent 0, black 16px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 16px);
}

.demo-msg { max-width: 96%; }

.demo-msg--user {
  align-self: flex-end;
  max-width: 84%;
  padding: 9px 13px;
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 12px 12px 4px 12px;
  font-size: 13px;
}

.demo-msg--assistant {
  align-self: stretch;
  max-width: 96%;
  color: var(--ink);
  font-size: 13px;
}

.demo-tool {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: stretch;
}

.demo-tool__line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.demo-tool__line svg { flex: 0 0 auto; color: var(--ink-faint); }
.demo-tool__chevron { margin-left: auto; color: var(--ink-faint); }

.demo-tool__mono {
  margin-left: 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-subtle);
}

/* -- generic card ------------------------------------------------------------ */

.demo-card {
  align-self: stretch;
  background: var(--surface);
  border: 1px solid var(--rule-warm);
  border-radius: var(--radius-card);
  padding: 12px;
}

.demo-card__row { display: flex; align-items: center; gap: 10px; }

.demo-card__icon {
  flex: 0 0 auto;
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-chip);
  background: var(--paper-2);
  color: var(--ink-soft);
}

.demo-card__title {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ink-strong);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.demo-card__sub {
  font-size: 12px;
  color: var(--ink-soft);
}

.demo-card__open {
  flex: 0 0 auto;
  color: var(--ink-faint);
  margin-left: auto;
}

.demo-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.demo-card__btn {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  transition: transform var(--dur-fast) var(--ease-out);
}

.demo-card__btn--ghost {
  background: var(--surface);
  border: 1px solid var(--line-pill);
  color: var(--ink);
}

.demo-card__btn--accent {
  background: none;
  border: 1px solid transparent;
  padding-inline: 8px;
  color: var(--accent-ink);
}

.demo-card__btn--solid {
  background: var(--accent-ink);
  border: 1px solid transparent;
  color: var(--surface);
}

.demo-card[data-pressable].is-pressed,
.demo-card__btn.is-pressed {
  transform: scale(0.96);
}

.demo-card__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--ls-kicker);
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin-bottom: 6px;
  display: block;
}

.demo-card__collapsed {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink);
}

/* -- table card --------------------------------------------------------------- */

.demo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.demo-table th {
  text-align: left;
  font-weight: var(--fw-medium);
  color: var(--ink-soft);
  font-size: 11.5px;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--rule-warm);
}

.demo-table td {
  padding: 8px;
  border-bottom: 1px solid var(--rule-warm);
  color: var(--ink);
}

.demo-table tr:last-child td { border-bottom: 0; }

.demo-table th:not(:first-child),
.demo-table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.demo-table tr.is-featured td { background: var(--accent-wash); }
.demo-table tr.is-featured td:first-child { border-radius: var(--radius-chip) 0 0 var(--radius-chip); }
.demo-table tr.is-featured td:last-child { border-radius: 0 var(--radius-chip) var(--radius-chip) 0; }

/* -- approval card ------------------------------------------------------------- */

.demo-approval__text { font-size: 12.5px; color: var(--ink); margin: 0 0 10px; }

/* -- composer ------------------------------------------------------------------ */

.demo-composer {
  flex: 0 0 auto;
  margin: 8px 20px 20px;
  padding: 10px 12px 8px;
  background: var(--surface);
  border: 1px solid var(--rule-warm);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
}

.demo-composer__field {
  min-height: 18px;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 8px;
}

.demo-composer__placeholder { color: var(--ink-subtle); }

.demo-composer__caret {
  display: inline-block;
  width: 1.5px;
  height: 13px;
  margin-bottom: -2px;
  background: var(--ink);
  opacity: 0;
}

.demo-composer__field.is-typing .demo-composer__caret {
  opacity: 1;
  animation: demo-caret-blink 1s steps(1) infinite;
}

.demo-composer__row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.demo-composer__add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-soft);
}

.demo-composer__add svg { color: var(--ink-faint); }

.demo-composer__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--surface);
  transition: background var(--dur-fast) var(--ease-out);
}

.demo-composer__send.is-active { background: var(--accent-ink); }

@media (max-width: 759px) {
  .demo-composer { margin: 8px 16px 16px; }
}

/* ---------------------------------------------------------------------------
   5. Pointer + click affordance
   ------------------------------------------------------------------------- */

.demo-pointer {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  z-index: 40;
  color: var(--ink-strong);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px var(--ink-strong));
}

.demo-pointer svg { display: block; }

.demo-pointer__fill {
  fill: currentColor;
  stroke: var(--surface);
  stroke-width: 1.2px;
  stroke-linejoin: round;
}

.demo-click-ring {
  position: absolute;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  opacity: 0.7;
  transform: scale(0.4);
  pointer-events: none;
  z-index: 39;
}

/* ---------------------------------------------------------------------------
   6. Result pane — shared bits
   ------------------------------------------------------------------------- */

.demo-art__inner {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(16px, 3vw, 28px);
}

.demo-art__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 16px;
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--ink-strong);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.demo-chip svg { flex: 0 0 auto; color: var(--ink-soft); }

.demo-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

.demo-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ink-faint);
  flex: 0 0 auto;
}

.demo-dot--ok { background: var(--ok); }

.demo-dot--pulse { animation: demo-dot-pulse 1.8s var(--ease-in-out) infinite; }

.demo-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: var(--fw-medium);
  flex: 0 0 auto;
}

.demo-pill--ok { background: var(--ok-wash); color: var(--ok-ink); }

/* ---------------------------------------------------------------------------
   7. Document result
   ------------------------------------------------------------------------- */

.demo-doc__toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 4px;
  margin-bottom: 16px;
  border: 1px solid var(--rule-warm);
  border-radius: var(--radius-chip);
  color: var(--ink-faint);
  font-size: 12px;
}

.demo-doc__tool { display: inline-flex; align-items: center; gap: 4px; }
.demo-doc__tool--b { font-weight: 700; }
.demo-doc__tool--i { font-style: italic; }
.demo-doc__tool--u { text-decoration: underline; }
.demo-doc__divider { width: 1px; height: 14px; background: var(--rule-warm); }

.demo-doc__page {
  background: var(--surface);
  border: 1px solid var(--rule-warm);
  border-radius: var(--radius-card);
  padding: clamp(20px, 4vw, 36px);
}

.demo-doc__title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: var(--fw-regular);
  color: var(--ink-strong);
}

.demo-doc__meta {
  margin: 0 0 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-subtle);
}

.demo-doc__totals {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule-warm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.demo-doc__totals-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  max-width: 260px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.demo-doc__totals-row span:last-child {
  font-variant-numeric: tabular-nums;
}

.demo-doc__totals-row--total {
  font-weight: var(--fw-medium);
  color: var(--ink-strong);
  font-size: 13.5px;
  padding-top: 6px;
  border-top: 1px solid var(--rule-warm);
}

.demo-doc__terms {
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--ink-2);
}

@media (max-width: 999px) {
  .demo-doc__toolbar { display: none; }
  .demo-doc__page { padding: 16px; }
  .demo-doc__title { font-size: 17px; }
  .demo-doc__meta { margin-bottom: 14px; }
  .demo-doc__terms { margin-top: 14px; }
}

/* ---------------------------------------------------------------------------
   8. Dashboard result
   ------------------------------------------------------------------------- */

.demo-dash__titlerow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}

.demo-dash__titlerow h3 {
  margin: 0;
  font-size: 16px;
  font-weight: var(--fw-regular);
  color: var(--ink-strong);
}

.demo-dash__sub { font-size: 13px; color: var(--ink-subtle); }

.demo-dash__tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule-warm);
  border: 1px solid var(--rule-warm);
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: 16px;
}

.demo-tile {
  background: var(--surface);
  padding: 14px 16px;
  min-width: 0;
}

.demo-tile__label {
  margin: 0 0 6px;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.demo-tile__value {
  margin: 0;
  font-size: 18px;
  font-weight: var(--fw-regular);
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: opacity var(--dur) var(--ease-out);
}

.demo-tile__value--accent { color: var(--accent-ink); }
.demo-tile__value.is-swapping { opacity: 0; }

.demo-dash__chart {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.demo-dash__chart .demo-card__title {
  margin: 0 0 16px;
  font-weight: var(--fw-medium);
  flex: 0 0 auto;
}

.demo-bars {
  display: flex;
  align-items: flex-end;
  gap: clamp(10px, 3vw, 28px);
  flex: 1 1 auto;
  min-height: 70px;
}

.demo-bar {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.demo-bar__track {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  min-height: 0;
}

.demo-bar__fill {
  width: 100%;
  height: 0%;
  border-radius: 4px 4px 0 0;
  background: var(--accent-soft);
}

.demo-bar__fill--solid { background: var(--accent); }

.demo-bar--dim .demo-bar__fill { background: var(--line); }

.demo-bar__label {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color var(--dur) var(--ease-out);
}

.demo-bar--dim .demo-bar__label { color: var(--ink-subtle); }

.demo-chip--viewing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  margin-bottom: 12px;
  border-radius: var(--radius-pill);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 12px;
  width: fit-content;       /* a compact pill, even inside the pane's stretching flex column */
  align-self: flex-start;
}

.demo-chip--viewing svg { color: var(--ink-soft); }

@media (max-width: 999px) {
  .demo-dash__tiles { grid-template-columns: repeat(3, 1fr); }
  .demo-tile { padding: 10px 12px; }
  .demo-tile__value { font-size: 15px; }
}

@media (max-width: 759px) {
  .demo-dash__tiles { grid-template-columns: repeat(3, 1fr); }
  .demo-tile { padding: 8px 8px; }
  .demo-tile__label { font-size: 10.5px; }
  .demo-tile__value { font-size: 13.5px; }
  .demo-bars { gap: 8px; }
  .demo-bar__label { font-size: 10px; }
}

/* ---------------------------------------------------------------------------
   9. Workflow result
   ------------------------------------------------------------------------- */

.demo-flow__hint { font-size: 12px; color: var(--ink-soft); flex: 0 0 auto; }

.demo-flow__nodes {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-bottom: 20px;
}

.demo-node {
  flex: 0 0 auto;
  min-width: 128px;
  padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--rule-warm);
  border-radius: var(--radius-card);
  text-align: center;
}

.demo-node--accent { background: var(--accent-wash); border-color: transparent; }

.demo-node__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  color: var(--ink-soft);
}

.demo-node--accent .demo-node__icon { color: var(--accent-ink); }

.demo-node__title {
  margin: 0;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ink-strong);
}

.demo-node__sub {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.demo-connector {
  position: relative;
  flex: 0 0 auto;
  width: 2px;
  height: 28px;
  margin: 0 auto;
}

.demo-connector__base,
.demo-connector__draw {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  margin-left: -1px;
  transform-origin: top center;
}

.demo-connector__base { background: var(--rule-warm); }
.demo-connector__draw { background: var(--accent); transform: scaleY(0); }

.demo-connector__dot {
  position: absolute;
  left: 50%;
  top: 0;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0;
}

.demo-flow__log {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-warm);
}

.demo-flow__log-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

@media (max-width: 999px) {
  .demo-flow__nodes {
    flex: 0 0 auto;
    gap: 0;
    margin-bottom: 14px;
  }
  .demo-node {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    text-align: left;
  }
  .demo-node__icon { margin: 0; width: 20px; height: 20px; flex: 0 0 auto; }
  .demo-node__title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .demo-node__sub {
    margin: 0 0 0 auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .demo-connector { width: 2px; height: 12px; margin: 0 auto; }
}

@media (min-width: 1000px) {
  .demo-flow__nodes {
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
  }
  .demo-node { flex: 1 1 0; }
  .demo-connector { width: auto; height: 2px; flex: 1 1 44px; margin: 0 8px; }
  .demo-connector__base,
  .demo-connector__draw {
    left: 0;
    top: 50%;
    width: 100%;
    height: 2px;
    margin-left: 0;
    margin-top: -1px;
    transform-origin: left center;
  }
  .demo-connector__draw { transform: scaleX(0); }
  .demo-connector__dot { left: 0; top: 50%; margin: -3px 0 0 -3px; }
}

/* ---------------------------------------------------------------------------
   10. Share popover
   ------------------------------------------------------------------------- */

.demo-popover {
  position: absolute;
  top: 44px;
  right: 16px;
  width: min(300px, calc(100% - 32px));
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--rule-warm);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px;
  opacity: 0;
  transform: translateY(-8px);
}

.demo-popover__title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ink-strong);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.demo-popover__list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.demo-popover__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-popover__name {
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
}

.demo-popover__branch {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-popover__perm {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.demo-popover__footer {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--rule-warm);
  font-size: 11.5px;
  color: var(--ink-soft);
}

.demo-popover__footer svg { flex: 0 0 auto; margin-top: 1px; color: var(--ink-faint); }

@media (max-width: 759px) {
  .demo-popover {
    position: absolute;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, calc(-50% + 8px));
    width: min(280px, calc(100% - 40px));
  }
  .demo-body.has-result .demo-popover.is-open {
    transform: translate(-50%, -50%);
  }
}

/* ---------------------------------------------------------------------------
   11. Phone — result pane becomes a bottom sheet
   ------------------------------------------------------------------------- */

@media (max-width: 759px) {
  .demo-panel { padding: 16px; }
  .demo-window { width: 100%; height: 540px; font-size: 13.5px; }

  .demo-body { display: block; position: relative; height: 100%; }

  .demo-chat {
    width: 100%;
    height: 100%;
    margin: 0;
  }

  .demo-body.has-result .demo-chat { width: 100%; }

  .demo-art {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    top: 56px;
    bottom: 0;
    height: auto;
    grid-column: auto;
    grid-row: auto;
    border-left: 0;
    border-top: 1px solid var(--rule-warm);
    border-radius: 14px 14px 0 0;
    box-shadow: var(--shadow-card);
    background: var(--paper);
    opacity: 1;
    transform: translateY(100%);
    pointer-events: none;
  }

  .demo-body.has-result .demo-art {
    transform: translateY(0);
    pointer-events: auto;
  }

  .demo-sheet__grabber {
    display: block;
    width: 36px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 2px;
    background: var(--line);
  }

  .demo-body.has-result .demo-composer { display: none; }

  .demo-sheet__docked {
    display: block;
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 5;
  }

  .demo-sheet__docked:empty { display: none; }

  .demo-sheet__docked .demo-card,
  .demo-sheet__docked .demo-msg--assistant {
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }

  .demo-sheet__docked .demo-msg--assistant {
    padding: 10px 12px;
    border: 1px solid var(--rule-warm);
    border-radius: var(--radius-card);
  }
}

/* ---------------------------------------------------------------------------
   12. Entrance animation helper class (used for instant/no-op too)
   ------------------------------------------------------------------------- */

.demo-enter {
  opacity: 0;
  transform: translateY(6px);
}

/* ---------------------------------------------------------------------------
   13. Reduced motion — belt and braces alongside the JS instant path
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .demo-tab__bar b { transition: none; }
  .demo-dot--pulse { animation: none; }
  .demo-composer__caret { animation: none; opacity: 0; }
}

/* ---------------------------------------------------------------------------
   14. Keyframes
   ------------------------------------------------------------------------- */

@keyframes demo-caret-blink {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes demo-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.2); }
}
