/* Captain Code TUI walkthrough - standalone /demo page */

.demo-page main {
  padding: 0;
}

.demo-stage {
  --tui-bg: #0a0d12;
  --tui-panel: #0f141c;
  --tui-line: rgba(232, 238, 248, 0.1);
  --tui-ink: #e8eef8;
  --tui-muted: #8b96a8;
  --tui-faint: #5a6578;
  --tui-accent: #5c9cf5;
  --tui-ok: #7dcea0;
  --tui-warn: #e6b35c;
  --tui-busy: #5c9cf5;
  --tui-cool: #c9896b;
  position: relative;
  min-height: calc(100vh - 4.5rem);
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem) 2.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(92, 156, 245, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(125, 206, 160, 0.06), transparent 50%),
    #07090d;
  overflow: hidden;
}

.demo-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(232, 238, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 238, 248, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
  pointer-events: none;
}

.demo-intro {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto 1.5rem;
  text-align: center;
}

.demo-intro .section-kicker {
  color: var(--tui-accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.75rem;
  margin: 0 0 0.65rem;
}

.demo-intro h1 {
  font-family: var(--display, "Space Grotesk", sans-serif);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.7rem;
  color: var(--tui-ink);
}

.demo-intro .lede {
  margin: 0 auto;
  max-width: 52ch;
  color: var(--tui-muted);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  line-height: 1.55;
}

.demo-frame {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  margin: 0 auto;
  height: clamp(340px, 62vh, 720px);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  border-radius: 12px;
  overflow: hidden;
  background: var(--tui-bg);
  border: 1px solid rgba(92, 156, 245, 0.28);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 40px 100px -40px rgba(92, 156, 245, 0.45),
    0 24px 60px -24px rgba(0, 0, 0, 0.85);
}

.demo-tui-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.demo-tui-shell[hidden] {
  display: none !important;
}

.demo-titlebar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.9rem;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid var(--tui-line);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  color: var(--tui-faint);
  flex: none;
}

.demo-titlebar .traffic,
.demo-browser-bar .traffic {
  display: flex;
  gap: 6px;
}

.demo-titlebar .traffic i,
.demo-browser-bar .traffic i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(232, 238, 248, 0.16);
}

.demo-titlebar .traffic i:nth-child(1),
.demo-browser-bar .traffic i:nth-child(1) { background: #ff5f57; }
.demo-titlebar .traffic i:nth-child(2),
.demo-browser-bar .traffic i:nth-child(2) { background: #febc2e; }
.demo-titlebar .traffic i:nth-child(3),
.demo-browser-bar .traffic i:nth-child(3) { background: #28c840; }

.demo-titlebar .path {
  color: var(--tui-muted);
}

.demo-titlebar .path b {
  color: var(--tui-ink);
  font-weight: 500;
}

.demo-titlebar .live {
  margin-left: auto;
  color: var(--tui-ok);
}

.demo-tui {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.85fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.demo-session {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
  border-right: 1px solid var(--tui-line);
}

.demo-session[hidden],
.demo-browser[hidden],
.demo-cinema[hidden] {
  display: none !important;
}

/* Browser window that replaces the TUI - same open path as the live product */
.demo-browser {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #0c0f14;
  color: var(--tui-ink);
}

/* Title card + credits reel - full-bleed inside the demo frame */
.demo-cinema {
  display: block;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(92, 156, 245, 0.45) #05070a;
  background:
    radial-gradient(ellipse 70% 55% at 50% 35%, rgba(92, 156, 245, 0.12), transparent 60%),
    #05070a;
  color: var(--tui-ink);
}

.demo-cinema-inner {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  box-sizing: border-box;
}

.demo-cinema-inner:has(.demo-cinema-credits) {
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(1.75rem, 7vh, 3.25rem);
}

.demo-cinema-titlecard {
  text-align: center;
  max-width: 34rem;
  position: relative;
}

.demo-cinema-titlecard[data-phase="black"] .demo-cinema-kicker,
.demo-cinema-titlecard[data-phase="black"] .demo-cinema-title,
.demo-cinema-titlecard[data-phase="black"] .demo-cinema-tag,
.demo-cinema-titlecard[data-phase="black"] .demo-cinema-sub {
  opacity: 0;
}

.demo-cinema-studio {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  animation: demo-studio-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.demo-cinema-studio[data-phase="black"] {
  opacity: 0;
  animation: none;
}

.demo-cinema-studio-mark {
  display: flex;
  width: clamp(5.4rem, 14vw, 7.2rem);
  height: auto;
  aspect-ratio: 466.23 / 216;
  align-items: center;
  justify-content: center;
  color: #cf9e13;
}

.demo-cinema-studio-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.demo-cinema-studio-name {
  margin: 0;
  font-family: var(--display, "Space Grotesk", sans-serif);
  font-size: clamp(1.35rem, 3.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--tui-ink);
}

.demo-cinema-studio-presents {
  margin: 0.15rem 0 0;
  animation: demo-studio-presents-in 0.7s ease 0.35s both;
}

@keyframes demo-studio-in {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(1.5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes demo-studio-presents-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.demo-cinema-kicker {
  margin: 0 0 1rem;
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--tui-faint);
  min-height: 1.1em;
}

.demo-cinema-title {
  margin: 0;
  font-family: var(--display, "Space Grotesk", sans-serif);
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.05;
  color: var(--tui-ink);
  text-transform: uppercase;
  min-height: 1.1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42em;
  flex-wrap: wrap;
}

.demo-cinema-titlecard[data-phase="hero"] .demo-cinema-title {
  min-height: clamp(7rem, 26vw, 12rem);
}

.demo-cinema-title-mark {
  flex: none;
  display: inline-flex;
  width: 0.78em;
  height: 0.78em;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 50%;
  color: #5c9cf5;
}

.demo-cinema-title-mark.is-hero {
  width: clamp(7rem, 26vw, 12rem);
  height: clamp(7rem, 26vw, 12rem);
}

.demo-cinema-title-mark.is-shrinking {
  transition:
    width 0.86s cubic-bezier(0.22, 0.08, 0.18, 1),
    height 0.86s cubic-bezier(0.22, 0.08, 0.18, 1);
  width: 0.78em;
  height: 0.78em;
}

.demo-cinema-title-mark[hidden] {
  display: none !important;
}

.demo-cinema-title-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.demo-cinema-title-mark.is-rest {
  transform: rotate(45deg);
}

.demo-cinema-title-mark.is-settled {
  transform: rotate(0deg);
}

.demo-cinema-title-mark.is-steering {
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .demo-cinema-studio {
    animation: none;
  }
  .demo-cinema-studio-presents {
    animation: none;
  }
  .demo-cinema-title-mark.is-steering {
    transform: rotate(0deg);
  }
  .demo-cinema-title-mark.is-shrinking {
    transition: none;
  }
}

.demo-cinema-caret {
  display: inline-block;
  margin-left: 0.08em;
  color: var(--tui-accent);
  font-weight: 400;
  animation: demo-cinema-blink 0.9s steps(1) infinite;
  vertical-align: baseline;
}

.demo-cinema-title .demo-cinema-caret {
  font-size: 0.55em;
  vertical-align: 0.18em;
}

.demo-cinema-kicker .demo-cinema-caret {
  letter-spacing: 0;
  font-size: 1em;
}

@keyframes demo-cinema-blink {
  50% { opacity: 0; }
}

.demo-cinema-tag {
  margin: 1.15rem 0 0;
  font-family: var(--display, "Space Grotesk", sans-serif);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--tui-accent);
  min-height: 1.25em;
}

.demo-cinema-sub {
  margin: 0.7rem auto 0;
  max-width: 36ch;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--tui-muted);
  min-height: 1.5em;
}

.demo-cinema-credits {
  width: min(720px, 100%);
  text-align: center;
  padding-bottom: 3.5rem;
}

.demo-cinema-credits .demo-cinema-tag {
  margin-bottom: 1.5rem;
  color: var(--tui-muted);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 400;
}

.demo-credit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-align: left;
}

.demo-credit-line {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.75rem;
  will-change: opacity, transform;
}

.demo-credit-line.is-pending,
.demo-cinema-endcard.is-pending {
  display: none;
}

.demo-credit-line.is-on {
  display: flex;
  animation: demo-credit-rise 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.demo-cinema-endcard.is-on {
  display: block;
  animation: demo-credit-rise 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes demo-credit-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(1.5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.demo-credit-logo {
  flex: none;
  width: 1.35rem;
  height: 1.35rem;
  color: var(--tui-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-credit-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.demo-credit-name {
  flex: none;
  font-family: var(--display, "Space Grotesk", sans-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--tui-ink);
  line-height: 1.2;
  min-width: 7.5rem;
}

.demo-credit-blurb {
  flex: 1;
  min-width: 0;
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  color: var(--tui-muted);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-credit-line-caret {
  flex: none;
  color: var(--tui-accent);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.85rem;
  animation: demo-cinema-blink 0.9s steps(1) infinite;
}

.demo-cinema-endcard {
  margin: 1.75rem 0 0;
  font-family: var(--display, "Space Grotesk", sans-serif);
  font-size: 1.05rem;
  color: var(--tui-accent);
}

.demo-dash-section {
  margin: 0 0 1.35rem;
}

.demo-dash-section:last-child {
  margin-bottom: 0.5rem;
}

.demo-cinema-titlecard[data-phase="fin"] .demo-cinema-kicker {
  color: var(--tui-ok);
}

.demo-browser-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  background: #161b24;
  border-bottom: 1px solid rgba(232, 238, 248, 0.08);
  flex: none;
}

.demo-browser-url {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: #0a0d12;
  border: 1px solid rgba(232, 238, 248, 0.1);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.68rem;
  color: var(--tui-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-browser-url .scheme {
  color: var(--tui-faint);
}

.demo-browser-tab {
  flex: none;
  max-width: 11rem;
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.65rem;
  color: var(--tui-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-dash-scroll {
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--tui-accent) #12171f;
  touch-action: pan-y;
  background: var(--tui-bg);
}

.demo-dash-scroll::-webkit-scrollbar {
  width: 10px;
}

.demo-dash-scroll::-webkit-scrollbar-track {
  background: #12171f;
}

.demo-dash-scroll::-webkit-scrollbar-thumb {
  background: var(--tui-accent);
  border-radius: 6px;
  border: 2px solid #12171f;
}

.demo-dash-page {
  padding: 0.95rem 1.15rem 2rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  line-height: 1.4;
  min-height: min-content;
}

.demo-dash-card {
  background: var(--tui-panel);
  border: 1px solid var(--tui-line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.35rem;
}

.demo-dash-scrollx {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.demo-dash-note,
.demo-dash-foot {
  margin: 0.45rem 0 0;
  color: var(--tui-faint);
  font-size: 0.62rem;
  line-height: 1.35;
}

.demo-dash-foot {
  margin: 0.85rem 0 0.25rem;
}

.demo-dash-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--tui-ink);
}

.demo-dash-head p {
  margin: 0.15rem 0 0.75rem;
  color: var(--tui-muted);
  font-size: 0.7rem;
}

.demo-dash-head .ok { color: var(--tui-ok); }

.demo-dash-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.demo-browser .demo-dash-tiles {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .demo-browser .demo-dash-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.demo-dash-tiles .tile {
  background: var(--tui-panel);
  border: 1px solid var(--tui-line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}

.demo-dash-tiles .v {
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--tui-ink);
}

.demo-dash-tiles .k {
  color: var(--tui-muted);
  font-size: 0.65rem;
}

.demo-dash-tiles .d {
  color: var(--tui-faint);
  font-size: 0.6rem;
}

.demo-dash-page h3 {
  margin: 0.55rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tui-ink);
}

.demo-dash-bars {
  display: grid;
  gap: 0.28rem;
  margin-bottom: 0.55rem;
}

.demo-dash-bars .bar-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) 2.4rem;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.65rem;
  color: var(--tui-muted);
}

.demo-dash-bars .bar-row i {
  display: block;
  height: 8px;
  width: var(--w);
  border-radius: 3px;
  background: var(--tui-accent);
}

.demo-dash-bars .bar-row b {
  text-align: right;
  font-weight: 600;
  color: var(--tui-ink);
}

.demo-dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.demo-dash-table th {
  text-align: left;
  color: var(--tui-muted);
  font-weight: 600;
  padding: 0.25rem 0.35rem;
  border-bottom: 1px solid var(--tui-line);
}

.demo-dash-table td {
  padding: 0.28rem 0.35rem;
  border-bottom: 1px solid var(--tui-line);
  color: var(--tui-ink);
}

.demo-dash-table td.ok { color: var(--tui-ok); font-weight: 600; }

.demo-session-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--tui-line);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.78rem;
}

.demo-session-head .thread {
  color: var(--tui-ink);
  font-weight: 500;
}

.demo-session-head .thread::before {
  content: "◈ ";
  color: var(--tui-accent);
}

.demo-session-head .meta {
  color: var(--tui-faint);
  font-size: 0.7rem;
}

.demo-feed {
  overflow: auto;
  padding: 0.9rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: clamp(0.72rem, 1.1vw, 0.82rem);
  line-height: 1.55;
  scroll-behavior: smooth;
}

.demo-msg {
  display: grid;
  gap: 0.25rem;
  animation: demo-rise 0.35s ease both;
}

.demo-msg[data-role="user"] .who { color: var(--tui-accent); }
.demo-msg[data-role="system"] .who { color: var(--tui-warn); }
.demo-msg[data-role="assistant"] .who { color: var(--tui-ok); }
.demo-msg[data-role="route"] .who { color: var(--tui-muted); }

.demo-msg .who {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.demo-msg .body {
  color: var(--tui-ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.demo-msg[data-role="route"] .body,
.demo-msg[data-role="system"] .body {
  color: var(--tui-muted);
}

.demo-msg[data-handoff="true"] {
  padding: 0.45rem 0.65rem;
  border-left: 2px solid var(--tui-ok);
  background: rgba(110, 198, 140, 0.08);
}

.demo-msg[data-handoff="true"] .who {
  color: var(--tui-ok);
}

.demo-msg .body .kw { color: var(--tui-accent); }
.demo-msg .body .ok { color: var(--tui-ok); }
.demo-msg .body .warn { color: var(--tui-warn); }
.demo-msg .body .dim { color: var(--tui-faint); }

.demo-route-card {
  margin-top: 0.15rem;
  padding: 0.55rem 0.7rem;
  border-left: 2px solid var(--tui-accent);
  background: rgba(92, 156, 245, 0.07);
  display: grid;
  gap: 0.2rem;
}

.demo-route-card strong {
  color: var(--tui-ink);
  font-weight: 500;
}

.demo-composer {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--tui-line);
  background: rgba(0, 0, 0, 0.25);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: clamp(0.74rem, 1.1vw, 0.84rem);
  color: var(--tui-ink);
  min-height: 3rem;
}

.demo-composer .prompt {
  color: var(--tui-accent);
  flex: none;
  margin-top: 0.05rem;
}

.demo-composer .typed {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.2em;
}

.demo-composer .typed[data-empty="true"]::after {
  content: attr(data-placeholder);
  color: var(--tui-faint);
}

.demo-composer .caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  margin-left: 1px;
  background: var(--tui-accent);
  vertical-align: text-bottom;
  animation: demo-blink 1s steps(1) infinite;
}

.demo-composer .caret[hidden] { display: none; }

.demo-models {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  min-height: 0;
  background: var(--tui-panel);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  color: var(--tui-muted);
}

.demo-dash-links {
  padding: 0.55rem 0.85rem 0.15rem;
  border-bottom: 1px solid transparent;
}

.demo-dash-link {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--tui-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  opacity: 0.7;
}

.demo-dash-link.is-hot,
.demo-dash-link[data-active="true"] {
  opacity: 1;
  color: var(--tui-ok);
  font-weight: 500;
}

.demo-models-head,
.demo-models-sub {
  padding: 0.5rem 0.85rem 0;
}

.demo-models-head {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  color: var(--tui-ink);
  font-size: 0.78rem;
  font-weight: 500;
}

.demo-models-head .dim {
  color: var(--tui-faint);
  font-weight: 400;
  font-size: 0.68rem;
}

.demo-models-sub {
  padding-top: 0.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--tui-line);
  color: var(--tui-faint);
  font-size: 0.68rem;
}

.demo-models-sub .helm {
  color: var(--tui-accent);
}

.demo-leg-list {
  overflow: auto;
  padding: 0.4rem 0.45rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  min-height: 0;
}

.demo-leg {
  display: grid;
  grid-template-columns: 1.1ch minmax(0, 1fr) 2.2ch auto;
  gap: 0.3rem;
  align-items: baseline;
  padding: 0.18rem 0.3rem;
  border-radius: 4px;
}

.demo-leg[data-status="busy"] {
  background: rgba(92, 156, 245, 0.1);
}

.demo-leg[data-status="cooling"] {
  background: rgba(201, 137, 107, 0.1);
}

.demo-leg .glyph { color: var(--tui-faint); }
.demo-leg[data-status="busy"] .glyph { color: var(--tui-busy); }
.demo-leg[data-status="cooling"] .glyph { color: var(--tui-cool); }
.demo-leg[data-status="idle"] .glyph { color: var(--tui-faint); }

.demo-leg .name {
  color: var(--tui-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-leg[data-director="true"] .name {
  color: var(--tui-accent);
}

.demo-leg .perf {
  color: var(--tui-faint);
  font-size: 0.62rem;
  text-align: right;
}

.demo-leg .perf.open { color: var(--tui-ok); }

.demo-leg .detail {
  color: var(--tui-faint);
  font-size: 0.62rem;
  text-align: right;
  white-space: nowrap;
}

.demo-leg[data-status="busy"] .detail { color: var(--tui-busy); }
.demo-leg[data-status="cooling"] .detail { color: var(--tui-cool); }

.demo-shield {
  padding: 0.45rem 0.85rem;
  border-top: 1px solid var(--tui-line);
  font-size: 0.62rem;
  color: var(--tui-faint);
  line-height: 1.35;
}

.demo-shield .dot {
  color: var(--tui-ok);
  margin-right: 0.3rem;
}

.demo-runs {
  border-top: 1px solid var(--tui-line);
  padding: 0.4rem 0.7rem 0.55rem;
  min-height: 0;
  overflow: auto;
  max-height: 38%;
}

.demo-runs-head {
  color: var(--tui-ink);
  font-weight: 500;
  font-size: 0.72rem;
  margin-bottom: 0.3rem;
}

.demo-runs-empty {
  color: var(--tui-faint);
  font-size: 0.62rem;
  font-style: italic;
}

.demo-run {
  display: grid;
  gap: 0.05rem;
  margin-bottom: 0.35rem;
  font-size: 0.62rem;
  line-height: 1.3;
}

.demo-run .at {
  color: var(--tui-faint);
}

.demo-run .mark {
  color: var(--tui-ink);
}

.demo-run[data-kind="route"] .mark { color: var(--tui-accent); }
.demo-run[data-kind="done"] .mark { color: var(--tui-ok); }
.demo-run[data-kind="run"] .mark { color: var(--tui-busy); }

.demo-run .ms {
  color: var(--tui-faint);
  margin-left: 0.25rem;
}

.demo-run .txt {
  color: var(--tui-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-player {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  margin: 1rem auto 0;
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(92, 156, 245, 0.18);
  background: rgba(8, 11, 16, 0.72);
  backdrop-filter: blur(8px);
  border-radius: 10px;
}

.demo-narration {
  display: grid;
  gap: 0.2rem;
}

.demo-narration .act {
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tui-accent);
}

.demo-narration .title {
  font-family: var(--display, "Space Grotesk", sans-serif);
  font-size: 1.05rem;
  color: var(--tui-ink);
  letter-spacing: -0.015em;
}

.demo-narration .note {
  color: var(--tui-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 70ch;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.demo-controls .ctrl {
  appearance: none;
  border: 1px solid rgba(92, 156, 245, 0.28);
  background: rgba(92, 156, 245, 0.08);
  color: var(--tui-ink);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.78rem;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  min-width: 2.5rem;
}

.demo-controls .ctrl:hover {
  border-color: var(--tui-accent);
  background: rgba(92, 156, 245, 0.16);
}

.demo-controls .ctrl:focus-visible {
  outline: 2px solid var(--tui-accent);
  outline-offset: 2px;
}

.demo-controls .ctrl[data-variant="play"] {
  background: var(--tui-accent);
  border-color: var(--tui-accent);
  color: #061018;
  font-weight: 600;
}

.demo-controls .ctrl[data-variant="play"]:hover {
  filter: brightness(1.08);
}

.demo-controls .step-count {
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.75rem;
  color: var(--tui-faint);
  min-width: 5.5ch;
  text-align: center;
}

.demo-scrub {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.demo-scrub button {
  appearance: none;
  border: 0;
  height: 6px;
  flex: 1 1 18px;
  min-width: 14px;
  border-radius: 999px;
  background: rgba(232, 238, 248, 0.12);
  padding: 0;
  cursor: pointer;
}

.demo-scrub button[data-done="true"] {
  background: rgba(92, 156, 245, 0.55);
}

.demo-scrub button[data-current="true"] {
  background: var(--tui-accent);
}

.demo-scrub button:focus-visible {
  outline: 2px solid var(--tui-accent);
  outline-offset: 2px;
}

.demo-trail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.demo-trail-chip {
  appearance: none;
  border: 1px solid rgba(232, 238, 248, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--tui-faint);
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: default;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.demo-trail-chip[data-unlocked="true"] {
  color: var(--tui-ink);
  border-color: rgba(92, 156, 245, 0.35);
  background: rgba(92, 156, 245, 0.1);
  cursor: pointer;
}

.demo-trail-chip[data-current="true"] {
  color: #061018;
  border-color: var(--tui-accent);
  background: var(--tui-accent);
  font-weight: 600;
}

.demo-trail-chip[data-unlocked="true"]:hover {
  border-color: var(--tui-accent);
}

.demo-trail-chip[data-unlocked="false"] {
  opacity: 0.55;
}

.demo-hint {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  margin: 0.85rem auto 0;
  text-align: center;
  font-family: var(--mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  color: var(--tui-faint);
}

@keyframes demo-blink {
  50% { opacity: 0; }
}

@keyframes demo-rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 820px) {
  .demo-stage {
    padding: 1rem 0.75rem 1.75rem;
  }

  .demo-frame {
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .demo-frame:has(.demo-browser:not([hidden])),
  .demo-frame:has(.demo-cinema:not([hidden])) {
    height: clamp(420px, 70svh, 720px);
  }

  .demo-tui {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 48vh) auto;
  }

  .demo-session {
    border-right: 0;
    border-bottom: 1px solid var(--tui-line);
    min-height: 280px;
    height: 100%;
    max-height: 100%;
  }

  .demo-browser-tab {
    display: none;
  }

  .demo-models {
    grid-template-rows: auto auto auto;
    max-height: 220px;
  }

  .demo-leg-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.15rem 0.35rem;
  }

  .demo-leg {
    grid-template-columns: 1.1ch minmax(0, 1fr);
  }

  .demo-leg .detail {
    grid-column: 2;
    text-align: left;
  }

  .demo-player {
    margin-top: 0.85rem;
  }

  .demo-controls {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .demo-leg-list {
    grid-template-columns: 1fr;
  }

  .demo-session {
    min-height: 260px;
  }

  .demo-tui {
    grid-template-rows: minmax(240px, 42vh) auto;
  }

  .demo-intro h1 {
    font-size: 1.55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo-msg,
  .demo-composer .caret,
  .demo-cinema-caret {
    animation: none;
  }
}

/* Homepage: title, then the TUI. First picture under the nav. */
.hero.hero-with-tui {
  padding: clamp(1.1rem, 2.2vw, 1.6rem) 0 clamp(1.4rem, 3vw, 2rem);
}

.hero-with-tui .wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  width: min(100% - 32px, 1180px);
}

.hero-with-tui .hero-brand {
  margin-bottom: 0.4rem;
}

.hero-with-tui h1,
html[data-theme="captain"] .hero-with-tui h1 {
  max-width: 18ch;
  margin-bottom: 0;
  font-size: clamp(2rem, 4.2vw, 3.2rem);
}

.demo-stage-embed {
  min-height: 0;
  padding: 0;
  background: transparent;
  overflow: visible;
}

.demo-stage-embed::before {
  display: none;
}

.demo-stage-embed .demo-frame {
  width: 100%;
  height: clamp(340px, calc(100vh - 13.5rem), 620px);
  height: clamp(340px, calc(100svh - 13.5rem), 620px);
}

.demo-stage-embed .demo-player {
  width: 100%;
  margin: 0.65rem auto 0;
  padding: 0.7rem 0.85rem 0.75rem;
}

.demo-stage-embed .demo-controls {
  margin: 0;
}

.hero-follow {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.75rem;
}

.hero-follow .lede {
  margin: 0;
  max-width: 62ch;
  font-size: 1.02rem;
  line-height: 1.5;
}

.hero-follow .hero-actions {
  margin: 0;
  flex: none;
}

.demo-stage-embed:focus-visible {
  outline: 2px solid var(--tui-accent);
  outline-offset: 4px;
}

@media (max-width: 820px) {
  .hero-with-tui h1,
  html[data-theme="captain"] .hero-with-tui h1 {
    max-width: none;
  }

  .demo-stage-embed .demo-frame {
    height: clamp(420px, 70svh, 720px);
  }

  .hero-follow {
    align-items: flex-start;
  }
}

.demo-story {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  margin: 0 auto 0.65rem;
  color: var(--tui-ink);
  font-size: 0.9rem;
  line-height: 1.5;
}

.demo-story span {
  display: block;
  color: var(--tui-muted);
  font-size: 0.72rem;
}

.demo-trail-chip {
  cursor: pointer;
}

.demo-trail-chip[data-unlocked="false"] {
  opacity: 1;
  color: var(--tui-muted);
}

.demo-trail-chip:focus-visible {
  outline: 2px solid var(--tui-accent);
  outline-offset: 3px;
}

.demo-feed {
  scroll-behavior: auto;
}

.demo-msg {
  flex-shrink: 0;
}

@media (max-width: 820px) {
  .demo-leg[data-status="busy"] {
    order: -1;
  }

  .demo-models {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    max-height: 180px;
  }

  .demo-titlebar .live,
  .demo-session-head .meta {
    display: none;
  }

  .demo-tui {
    grid-template-rows: minmax(420px, 56svh) auto;
  }

  .demo-feed {
    font-size: 0.75rem;
    line-height: 1.45;
    gap: 0.65rem;
    padding: 0.7rem;
  }
}
