.run-demo {
  position: relative;
  grid-template-rows: auto auto minmax(370px, 1fr) auto auto;
  overflow: hidden;
}

.code-file { min-width: 0; border-bottom: 1px solid var(--ink); background: var(--soft); }
.code-filebar { min-height: 36px; display: flex; align-items: center; gap: 9px; padding: 8px 18px; border-bottom: 1px solid var(--line); font: 11px/1.3 var(--mono); }
.code-filebar b { font-weight: 600; }
.code-filebar em { margin-left: auto; color: var(--muted); font-style: normal; }
.ts-badge { display: inline-grid; place-items: center; width: 23px; height: 19px; background: var(--blue); color: var(--paper); font: 700 9px/1 var(--sans); }
.run-code { border-bottom: 0; counter-reset: code-line; }
.run-code code { display: block; font-size: 0; line-height: 0; }
.run-code span {
  position: relative;
  display: block;
  margin-inline: -18px;
  padding-inline: 56px 18px;
  border-left: 2px solid transparent;
  counter-increment: code-line;
  font-size: clamp(11px, .92vw, 13px);
  line-height: 1.48;
  transition: color 500ms cubic-bezier(.16, 1, .3, 1), background-color 500ms cubic-bezier(.16, 1, .3, 1), border-color 500ms cubic-bezier(.16, 1, .3, 1), opacity 500ms cubic-bezier(.16, 1, .3, 1);
}
.run-code span::before { content: counter(code-line); position: absolute; left: 20px; width: 20px; color: var(--muted); text-align: right; opacity: .62; }
.run-code span > i { color: var(--blue); font-style: normal; }

.run-code span.is-active { color: var(--ink); background: var(--selected); border-color: var(--blue); }
.run-code span.is-done { color: var(--muted); opacity: .72; }

.run-stage {
  position: relative;
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  height: 430px;
  min-height: 430px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 96%, var(--blue));
}

.run-rail {
  list-style: none;
  margin: 0;
  padding: 0;
  border-right: 1px solid var(--line);
}

.run-rail li {
  position: relative;
  min-height: 72px;
  padding: 12px 11px 11px 42px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  transition: color 500ms cubic-bezier(.16, 1, .3, 1), background-color 500ms cubic-bezier(.16, 1, .3, 1), transform 500ms cubic-bezier(.16, 1, .3, 1);
}

.run-rail li > span { position: absolute; top: 14px; left: 11px; font: 11px/1 var(--mono); }
.run-rail b { display: block; color: inherit; font-size: 13px; }
.run-rail small { display: block; margin-top: 3px; font: 10px/1.35 var(--mono); }
.run-rail li.is-active { color: var(--blue); background: var(--selected); transform: translateX(3px); }
.run-rail li.is-done { color: var(--ink); }
.run-rail li.is-done::after { content: ""; position: absolute; left: 14px; bottom: 13px; width: 7px; height: 4px; border: solid var(--blue); border-width: 0 0 1px 1px; transform: rotate(-45deg); }

.agent-surface {
  --cc-bg: #f7f5ef;
  --cc-panel: #f0ede5;
  --cc-border: #d4cfc5;
  --cc-text: #292724;
  --cc-muted: #77716a;
  --cc-faint: #969089;
  --cc-orange: #bd5b3c;
  --cc-green: #418f4c;
  --cc-purple: #5753bc;
  position: relative;
  height: 430px;
  min-width: 0;
  overflow: hidden;
  background: var(--cc-bg);
  color: var(--cc-text);
}
:root[data-theme="dark"] .agent-surface {
  --cc-bg: #141414;
  --cc-panel: #1b1715;
  --cc-border: #2d2d2d;
  --cc-text: #dedede;
  --cc-muted: #8d8d8d;
  --cc-faint: #777;
  --cc-orange: #df7956;
  --cc-green: #69c277;
  --cc-purple: #b8b6ff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .agent-surface {
    --cc-bg: #141414;
    --cc-panel: #1b1715;
    --cc-border: #2d2d2d;
    --cc-text: #dedede;
    --cc-muted: #8d8d8d;
    --cc-faint: #777;
    --cc-orange: #df7956;
    --cc-green: #69c277;
    --cc-purple: #b8b6ff;
  }
}
.agent-topline { min-height: 42px; display: flex; border-bottom: 1px solid var(--cc-border); font: 12px/1.4 var(--sans); }
.claude-tab { display: inline-flex; align-items: center; gap: 9px; min-width: 184px; padding: 9px 14px; border-right: 1px solid #2d2d2d; }
.claude-tab { border-right-color: var(--cc-border); }
.claude-tab b { color: var(--cc-text); font-weight: 600; }
.claude-mark { color: var(--cc-orange); font-size: 20px; line-height: 1; }
.claude-close { margin-left: auto; color: var(--cc-text); font-size: 20px; line-height: 1; }
.agent-prompt { min-height: 54px; display: flex; align-items: center; gap: 10px; padding: 14px 22px 8px; color: var(--cc-muted); background: var(--cc-panel); font: 13px/1.4 var(--mono); }
.prompt-mark { color: var(--cc-muted); font-weight: 700; }
.agent-prompt i { width: 1px; height: 17px; background: var(--cc-text); animation: yield-caret 900ms steps(1) infinite; }

.agent-scenes { position: relative; height: 334px; min-height: 0; padding-bottom: 22px; overflow-y: auto; scrollbar-width: none; background: var(--cc-bg); }
.agent-scenes::-webkit-scrollbar { display: none; }
.agent-scene {
  position: relative;
  max-height: 0;
  padding: 0 clamp(22px, 3vw, 36px);
  overflow: hidden;
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  filter: blur(2px);
  pointer-events: none;
  transition: max-height 800ms cubic-bezier(.16, 1, .3, 1), padding 800ms cubic-bezier(.16, 1, .3, 1), opacity 650ms cubic-bezier(.16, 1, .3, 1), transform 650ms cubic-bezier(.16, 1, .3, 1), filter 650ms cubic-bezier(.16, 1, .3, 1);
  will-change: max-height, transform, opacity, filter;
}

.agent-scene.is-active, .agent-scene.is-past { max-height: 250px; padding-top: 18px; opacity: 1; transform: translate3d(0, 0, 0); filter: blur(0); pointer-events: auto; }
.agent-scene.is-active { padding-bottom: 4px; }
.agent-scene.is-past { padding-bottom: 0; }
.transcript-item { opacity: 0; transform: translateY(9px); transition: opacity 600ms cubic-bezier(.16, 1, .3, 1), transform 600ms cubic-bezier(.16, 1, .3, 1); }
.agent-scene.is-active .transcript-item, .agent-scene.is-past .transcript-item { opacity: 1; transform: translateY(0); }
.agent-scene.is-active .transcript-item:nth-child(2), .agent-scene.is-past .transcript-item:nth-child(2) { transition-delay: 150ms; }
.agent-scene.is-active .transcript-item:nth-child(3), .agent-scene.is-past .transcript-item:nth-child(3) { transition-delay: 300ms; }
.claude-response { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 12px; max-width: 680px; }
.claude-response p { margin: 0; color: var(--cc-text); font: 13px/1.46 var(--mono); }
.claude-response code { color: var(--cc-text); font-size: inherit; }
.response-dot { width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--cc-text); }
.todo-update { max-width: 680px; margin: 20px 0 0; font: 12px/1.45 var(--mono); }
.todo-title { display: flex; align-items: center; gap: 11px; color: var(--cc-text); }
.todo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cc-green); }
.todo-tree { position: relative; display: grid; gap: 1px; margin: 5px 0 0 20px; padding-left: 22px; color: var(--cc-text); }
.todo-tree::before { content: ""; position: absolute; left: 4px; top: 0; width: 12px; height: 14px; border-left: 1px solid var(--cc-muted); border-bottom: 1px solid var(--cc-muted); }
.todo-tree > span { display: flex; align-items: center; gap: 9px; }
.todo-tree i { width: 7px; height: 7px; border: 1px solid var(--cc-muted); }
.todo-tree .todo-active { color: var(--cc-purple); font-weight: 700; }
.todo-tree .todo-active i { border-color: var(--cc-purple); }
.todo-tree .todo-done { color: var(--cc-muted); }
.todo-tree .todo-done i { border-color: var(--cc-green); background: var(--cc-green); }
.claude-status { display: flex; align-items: center; gap: 9px; margin-top: 22px; color: var(--cc-faint); font: 12px/1.4 var(--mono); }
.agent-scene.is-past .claude-status { max-height: 0; margin-top: 0; overflow: hidden; opacity: 0; }
.claude-status b { color: var(--cc-orange); }
.status-spark { color: var(--cc-orange); font-size: 16px; animation: yield-spin 1.8s linear infinite; }
.gate-status b { color: var(--cc-green); }
.gate-status .status-spark { color: var(--cc-green); animation: none; }

.evidence-token { position: absolute; right: 22px; bottom: 20px; display: flex; gap: 10px; padding: 8px 10px; border: 1px solid var(--blue); background: var(--paper); color: var(--blue); font: 10px/1.2 var(--mono); opacity: 0; transform: translate3d(70px, 20px, 0) scale(.88); transition: opacity 500ms cubic-bezier(.16, 1, .3, 1), transform 800ms cubic-bezier(.16, 1, .3, 1); }
.run-demo[data-step="3"] .evidence-token { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
.run-demo[data-step="4"] .evidence-token { opacity: 0; transform: translate3d(-80px, -120px, 0) scale(.72); }

.run-description { margin: 0; padding: 9px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font: 10px/1.45 var(--mono); }
.run-controls { min-height: 68px; }

@keyframes yield-caret { 50% { opacity: 0; } }
@keyframes yield-pulse { 50% { transform: scale(1.55); background: var(--blue); } }
@keyframes yield-spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .run-demo { grid-template-rows: auto auto auto auto auto; }
  .run-stage { display: block; height: auto; min-height: 0; }
  .run-rail { border-right: 0; }
  .run-rail li { min-height: 64px; }
  .agent-surface { display: none; }
  .run-description { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-prompt i, .status-spark { animation: none; }
  .evidence-token { display: none; }
}
