/* Loopsuit Brain — case study demo base (1280×720 capture viewport) */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500&family=Outfit:wght@600;700&display=swap");

:root {
  /* Cortex LIGHT theme (matches cortex/src/app/globals.css .light) — default for all demos */
  --cx-bg: #fafbfd;
  --cx-bg-raised: #ffffff;
  --cx-bg-overlay: #f5f6f9;
  --cx-bg-input: #f0f1f5;
  --cx-surface: #edeef3;
  --cx-surface-hover: #e4e6ed;
  --cx-surface-active: #d8dae4;
  --cx-border: rgba(15, 17, 25, 0.08);
  --cx-border-subtle: rgba(15, 17, 25, 0.05);
  --cx-fg: #0f1119;
  --cx-fg-muted: rgba(15, 17, 25, 0.62);
  --cx-fg-subtle: rgba(15, 17, 25, 0.4);
  --cx-accent: #3b7bef;
  --cx-accent-hover: #2b6bdf;
  --cx-accent-muted: rgba(59, 123, 239, 0.1);
  --cx-accent-fg: #ffffff;
  --cx-success: #16a34a;
  --cx-warning: #d97706;
  --cx-voice: #ef4444;
  --cx-voice-glow: rgba(239, 68, 68, 0.2);
  --cx-graph-node: #3b7bef;
  --cx-graph-edge: rgba(59, 123, 239, 0.25);
  --cx-graph-highlight: #8b5cf6;
  --lt-bg: #fafbfd;
  --lt-raised: #ffffff;
  --lt-border: rgba(15, 17, 25, 0.08);
  --lt-fg: #0f1119;
  --lt-fg-muted: rgba(15, 17, 25, 0.6);
  --lt-fg-subtle: rgba(15, 17, 25, 0.35);
  --lt-accent: #3b7bef;
  --lt-accent-soft: rgba(59, 123, 239, 0.1);
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-display: "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --demo-w: 1280px;
  --demo-h: 720px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: var(--demo-w);
  height: var(--demo-h);
  overflow: hidden;
  background: #e8eaef;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* Case-study frame — matches loopsuitai.com placeholder container */
.demo-frame {
  position: relative;
  width: var(--demo-w);
  height: var(--demo-h);
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, #f4f5f8 0%, #ebeef3 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 24px 60px rgba(15, 17, 25, 0.12);
}

.demo-stage {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  will-change: transform;
}

/* Animated product cursor */
.demo-cursor {
  position: absolute;
  z-index: 1000;
  width: 22px;
  height: 22px;
  pointer-events: none;
  transform: translate(-2px, -2px);
  transition: opacity 0.25s ease;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.demo-cursor svg {
  display: block;
}

.demo-cursor.is-clicking {
  transform: translate(-2px, -2px) scale(0.88);
}

.demo-cursor-you {
  position: absolute;
  left: 16px;
  top: 18px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #0f1119;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(15, 17, 25, 0.28);
}

.demo-cursor-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 2px solid rgba(79, 140, 255, 0.7);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
}

/* Grainy atmospheric wash (FranchiseShift / Cortex polish) */
.cx-grain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.cx-grain__wash {
  position: absolute;
  inset: 0;
}

.cx-grain[data-palette="ember"] .cx-grain__wash {
  background:
    radial-gradient(ellipse 90% 70% at 12% 18%, #1e1b4b 0%, transparent 55%),
    radial-gradient(ellipse 80% 75% at 88% 28%, #b91c1c 0%, transparent 52%),
    radial-gradient(ellipse 95% 80% at 28% 92%, #ea580c 0%, #c2410c 35%, transparent 60%),
    linear-gradient(155deg, #0f0a1a 0%, #1a0f24 40%, #2a1218 100%);
}

.cx-grain[data-palette="dusk"] .cx-grain__wash {
  background:
    radial-gradient(ellipse 85% 70% at 18% 22%, #0c4a6e 0%, transparent 55%),
    radial-gradient(ellipse 75% 70% at 92% 32%, #9f1239 0%, transparent 50%),
    radial-gradient(ellipse 95% 80% at 22% 88%, #c2410c 0%, #9a3412 40%, transparent 62%),
    linear-gradient(155deg, #0a1628 0%, #1a1028 45%, #1c0f18 100%);
}

.cx-grain[data-palette="midnight"] .cx-grain__wash {
  background:
    radial-gradient(ellipse 85% 70% at 14% 20%, #312e81 0%, transparent 55%),
    radial-gradient(ellipse 80% 75% at 90% 26%, #831843 0%, transparent 52%),
    radial-gradient(ellipse 90% 75% at 30% 90%, #b45309 0%, #92400e 38%, transparent 60%),
    linear-gradient(155deg, #0b0a14 0%, #16102a 42%, #1a1018 100%);
}

.cx-grain[data-palette="seas"] .cx-grain__wash {
  background:
    radial-gradient(ellipse 85% 70% at 10% 20%, #0e7490 0%, transparent 55%),
    radial-gradient(ellipse 75% 70% at 88% 24%, #1d4ed8 0%, transparent 50%),
    radial-gradient(ellipse 90% 75% at 30% 90%, #0f766e 0%, #115e59 40%, transparent 62%),
    linear-gradient(155deg, #061018 0%, #0c1a28 45%, #0a1218 100%);
}

.cx-grain[data-palette="orchard"] .cx-grain__wash {
  background:
    radial-gradient(ellipse 85% 70% at 14% 18%, #3f6212 0%, transparent 55%),
    radial-gradient(ellipse 75% 70% at 90% 30%, #b45309 0%, transparent 50%),
    radial-gradient(ellipse 90% 75% at 24% 88%, #65a30d 0%, #4d7c0f 40%, transparent 62%),
    linear-gradient(155deg, #0c1208 0%, #1a180c 45%, #141008 100%);
}

.cx-grain__noise {
  position: absolute;
  inset: -20%;
  width: 140%;
  height: 140%;
  mix-blend-mode: overlay;
  opacity: 0.62;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.35' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 110px 110px;
  animation: cx-grain-shift 8s steps(10) infinite;
}

.cx-grain__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, transparent 30%),
    linear-gradient(0deg, rgba(10, 10, 10, 0.35) 0%, transparent 45%);
}

@keyframes cx-grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1.5%, 1%); }
  50% { transform: translate(1%, -1.2%); }
  75% { transform: translate(-0.8%, -0.6%); }
  100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .cx-grain__noise { animation: none; }
}

html.compact .demo-cursor-you {
  font-size: 8px;
  padding: 2px 5px;
}

.demo-cursor-ring.pulse {
  animation: cursor-ring 0.45s ease-out forwards;
}

@keyframes cursor-ring {
  0% {
    opacity: 0.9;
    transform: scale(0.5);
  }
  100% {
    opacity: 0;
    transform: scale(1.4);
  }
}

/* Cortex app chrome */
.cortex-app {
  display: flex;
  width: 100%;
  height: 100%;
  background: var(--cx-bg);
  color: var(--cx-fg);
}

/* Light theme — matches cortex/src/app/globals.css .light */
.cortex-app.light {
  --cx-bg: #fafbfd;
  --cx-bg-raised: #ffffff;
  --cx-bg-input: #f0f1f5;
  --cx-surface: #edeef3;
  --cx-surface-hover: #e4e6ed;
  --cx-border: rgba(0, 0, 0, 0.08);
  --cx-border-subtle: rgba(0, 0, 0, 0.04);
  --cx-fg: #0f1119;
  --cx-fg-muted: rgba(15, 17, 25, 0.6);
  --cx-fg-subtle: rgba(15, 17, 25, 0.35);
  --cx-accent: #3b7bef;
  --cx-accent-hover: #2b6bdf;
  --cx-accent-muted: rgba(59, 123, 239, 0.1);
  --cx-voice: #ef4444;
}

.cortex-sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--cx-border);
  background: var(--cx-bg-raised);
  display: flex;
  flex-direction: column;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.cortex-sidebar.is-dimmed {
  opacity: 0.55;
  filter: blur(1.5px);
}

.cortex-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--cx-border-subtle);
  flex-shrink: 0;
}

.cortex-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(59, 123, 239, 0.1);
  color: var(--cx-accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.cortex-logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

.cortex-search-wrap {
  padding: 12px;
  flex-shrink: 0;
}

.cortex-search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--cx-bg-input);
  border: 1px solid var(--cx-border-subtle);
  font-size: 13px;
  color: var(--cx-fg-subtle);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.cortex-search-trigger.is-highlight {
  border-color: rgba(59, 123, 239, 0.45);
  box-shadow: 0 0 0 3px var(--cx-accent-muted);
  background: var(--cx-bg-raised);
  color: var(--cx-fg-muted);
}

.cortex-search-trigger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.cortex-search-trigger kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--cx-fg-subtle);
  background: var(--cx-surface);
  padding: 2px 6px;
  border-radius: 4px;
}

.cortex-search-trigger kbd.is-pulse {
  animation: kbd-pulse 0.9s ease-in-out infinite;
}

@keyframes kbd-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(59, 123, 239, 0.35);
  }
  50% {
    box-shadow: 0 0 0 6px transparent;
  }
}

.cortex-nav {
  padding: 0 8px;
  flex: 1;
}

.cortex-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--cx-fg-muted);
  margin-bottom: 4px;
}

.cortex-nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--cx-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.cortex-sidebar-foot {
  padding: 12px 8px;
  border-top: 1px solid var(--cx-border-subtle);
  flex-shrink: 0;
}

.cortex-sidebar-foot .cortex-nav-item {
  color: var(--cx-fg-subtle);
}

.cortex-nav-item.is-voice {
  color: var(--cx-voice);
}

.cortex-nav-item.is-voice .cortex-nav-icon-wrap {
  position: relative;
}

.cortex-voice-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cx-voice);
  animation: voice-dot 2s ease-in-out infinite;
}

@keyframes voice-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35);
  }
  50% {
    box-shadow: 0 0 0 6px transparent;
  }
}

.cortex-sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 0;
}

.cortex-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b7bef, #8b5cf6);
  border: 2px solid var(--cx-bg-raised);
  box-shadow: 0 0 0 1px var(--cx-border);
}

.cortex-nav-item.is-active {
  background: var(--cx-accent-muted);
  color: var(--cx-accent);
}

.cortex-nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

.cortex-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.cortex-main.is-dimmed {
  opacity: 0.5;
  filter: blur(2px);
}

.cortex-main.is-dimmed .note-card.is-focus {
  opacity: 1;
  filter: none;
}

.cortex-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--cx-border-subtle);
}

.cortex-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
}

.cortex-subtitle {
  font-size: 13px;
  color: var(--cx-fg-muted);
  margin-top: 2px;
}

.cortex-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Demo narration caption */
.demo-caption {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 900;
  max-width: 520px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--cx-bg-raised);
  border: 1px solid var(--cx-border);
  box-shadow: 0 16px 40px rgba(15, 17, 25, 0.12);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cx-fg);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.demo-caption.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.demo-caption em {
  font-style: normal;
  color: var(--cx-accent);
  font-weight: 600;
}

.demo-caption kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--cx-surface);
  border: 1px solid var(--cx-border);
  border-radius: 5px;
  padding: 2px 7px;
  margin: 0 2px;
}

/* Skeleton placeholders */
.sk-line {
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--cx-surface) 0%,
    var(--cx-surface-hover) 50%,
    var(--cx-surface) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-line.w40 { width: 40%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.note-card.is-skeleton {
  pointer-events: none;
}

.note-card.is-ghost {
  opacity: 0.35;
  filter: blur(1px);
  transition: opacity 0.35s ease, filter 0.35s ease;
}

.cmd-item.is-ghost {
  opacity: 0.3;
  filter: blur(0.5px);
}

.cmd-item.is-hidden {
  display: none;
}

/* Command palette overlay */
.cmd-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 25, 0.35);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 72px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.cmd-overlay.is-visible {
  opacity: 1;
}

.cmd-palette {
  width: min(560px, 92%);
  border-radius: 16px;
  background: var(--lt-raised);
  color: var(--lt-fg);
  box-shadow:
    0 32px 80px rgba(15, 17, 25, 0.22),
    0 0 0 1px var(--cx-border);
  overflow: hidden;
  transform: translateY(-12px) scale(0.98);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.cmd-overlay.is-visible .cmd-palette {
  transform: translateY(0) scale(1);
}

.cmd-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--lt-border);
  color: var(--lt-fg-subtle);
}

.cmd-typed {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--lt-fg);
}

.cmd-caret {
  width: 2px;
  height: 16px;
  background: var(--lt-accent);
  animation: blink 1s steps(2) infinite;
}

.cmd-results {
  padding: 8px;
}

.cmd-group {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--lt-fg-subtle);
  padding: 10px 12px 6px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--lt-fg-muted);
}

.cmd-item.is-active {
  background: var(--lt-accent-soft);
  color: var(--lt-fg);
}

.cmd-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  border: 1px solid var(--lt-border);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--lt-fg-subtle);
}

/* Answer panel */
.answer-panel {
  position: absolute;
  right: 32px;
  bottom: 72px;
  width: 400px;
  border-radius: 14px;
  background: var(--cx-bg-raised);
  border: 1px solid var(--cx-border);
  box-shadow: 0 24px 60px rgba(15, 17, 25, 0.14);
  padding: 16px 18px;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 50;
}

.answer-panel.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.answer-panel.is-loading .answer-text {
  color: var(--cx-fg-subtle);
}

.answer-panel.is-loading .answer-stream-cursor {
  display: none;
}

.answer-panel.is-loading .answer-text::before {
  content: "";
  display: block;
  height: 10px;
  width: 92%;
  border-radius: 6px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--cx-surface) 0%, var(--cx-surface-hover) 50%, var(--cx-surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.answer-panel.is-loading .answer-text::after {
  content: "";
  display: block;
  height: 10px;
  width: 70%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--cx-surface) 0%, var(--cx-surface-hover) 50%, var(--cx-surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.answer-stream-cursor {
  display: inline-block;
  width: 2px;
  height: 13px;
  background: var(--cx-accent);
  animation: blink 1s steps(2) infinite;
  vertical-align: -2px;
  margin-left: 1px;
}

.answer-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--cx-accent);
  margin-bottom: 8px;
}

.answer-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--cx-fg-muted);
}

.answer-sources {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.answer-source {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--cx-accent);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--cx-accent-muted);
}

/* Graph canvas area */
.graph-wrap {
  position: absolute;
  inset: 0;
}

.graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.graph-hud {
  position: absolute;
  left: 20px;
  bottom: 20px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--cx-border);
  backdrop-filter: blur(8px);
  font-size: 11px;
  color: var(--cx-fg-muted);
}

.graph-node-card {
  position: absolute;
  width: 280px;
  border-radius: 14px;
  background: var(--lt-raised);
  color: var(--lt-fg);
  border: 1px solid var(--lt-border);
  box-shadow: 0 20px 50px rgba(15, 17, 25, 0.14);
  padding: 16px 18px;
  opacity: 0;
  transform: scale(0.92);
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.graph-node-card.is-visible {
  opacity: 1;
  transform: scale(1);
}

.graph-node-card h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.graph-node-card p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--lt-fg-muted);
}

/* Agent library stack */
.agent-stack {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 70% at 50% 40%, rgba(59, 123, 239, 0.06), transparent);
}

.stack-panel {
  position: absolute;
  border: 1px solid var(--cx-border);
  border-radius: 16px;
  background: var(--cx-bg-raised);
  box-shadow: 0 24px 60px rgba(15, 17, 25, 0.14);
  padding: 18px 20px;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s ease;
}

.stack-panel.p1 {
  width: 320px;
  transform: rotate(-4deg) translate(-40px, 30px);
  opacity: 0.45;
}

.stack-panel.p2 {
  width: 300px;
  transform: rotate(3deg) translate(20px, 50px);
  opacity: 0.65;
}

.stack-panel.p3 {
  width: 290px;
  transform: rotate(-1deg);
  opacity: 1;
  z-index: 3;
  box-shadow: 0 32px 70px rgba(15, 17, 25, 0.16), 0 0 0 1px rgba(59, 123, 239, 0.15);
}

.stack-panel.is-front {
  transform: rotate(0deg) scale(1.02);
}

.sp-head {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--cx-fg-subtle);
  margin-bottom: 12px;
}

.sp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--cx-fg-muted);
}

.sp-row.is-hi {
  background: var(--cx-accent-muted);
  color: var(--cx-fg);
}

.sp-dot {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

/* Kernel router flow */
.router-flow {
  display: grid;
  grid-template-columns: 1fr 80px 1fr 80px 1fr;
  align-items: center;
  gap: 0;
  height: 100%;
  padding: 48px 40px;
  background: var(--cx-bg);
}

.router-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.router-card {
  border-radius: 14px;
  border: 1px solid var(--cx-border);
  background: var(--cx-bg-raised);
  padding: 16px;
  opacity: 0.4;
  transform: translateY(8px);
  transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.router-card.is-lit {
  opacity: 1;
  transform: translateY(0);
  border-color: rgba(79, 140, 255, 0.4);
  box-shadow: 0 0 30px rgba(79, 140, 255, 0.12);
}

.router-card h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.router-card p {
  font-size: 11px;
  line-height: 1.45;
  color: var(--cx-fg-muted);
}

.router-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cx-fg-subtle);
  opacity: 0.3;
  transition: opacity 0.4s ease, color 0.4s ease;
}

.router-arrow.is-lit {
  opacity: 1;
  color: var(--cx-accent);
}

.router-arrow svg {
  width: 32px;
  height: 32px;
}

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

@media (prefers-reduced-motion: reduce) {
  .demo-cursor,
  .cmd-caret {
    animation: none !important;
  }
}

/* ───────────────────────────────────────────────
   Compact / mobile portrait mode
   Activated by demo-engine.js (html.compact) when the demo renders in a
   narrow viewport. Reflows the landscape 1280×720 layouts into a legible
   portrait layout, hides the cursor, and lets the stage sit untransformed.
─────────────────────────────────────────────── */
html.compact,
html.compact body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

html.compact .demo-frame {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

html.compact .demo-stage {
  position: absolute;
  inset: 0;
  transform: none !important;
}

html.compact .demo-cursor {
  display: none !important;
}

/* App shell (command center §07 uses .cortex-sidebar) */
html.compact .cortex-app {
  flex-direction: column;
}

html.compact .cortex-sidebar {
  display: none;
}

html.compact .cortex-main {
  width: 100%;
  flex: 1;
}

/* Command palette overlay */
html.compact .cmd-overlay {
  padding-top: 40px;
}

html.compact .cmd-palette {
  width: 92%;
}

html.compact .cmd-input-row {
  padding: 14px 16px;
}

html.compact .cmd-item {
  font-size: 14px;
  padding: 11px 12px;
}

/* Sourced answer → full-width bottom sheet */
html.compact .answer-panel {
  left: 12px;
  right: 12px;
  bottom: 12px;
  width: auto;
}

html.compact .answer-text {
  font-size: 14px;
}

/* Caption sits closer to the bottom edge */
html.compact .demo-caption {
  bottom: 14px;
  max-width: calc(100% - 24px);
  font-size: 12.5px;
  padding: 10px 16px;
}

/* Kernel router flow → single vertical column */
html.compact .router-flow {
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 56px 16px 20px;
  height: 100%;
  align-content: start;
  overflow-y: auto;
}

html.compact .router-arrow {
  transform: rotate(90deg);
  height: 22px;
}

html.compact .router-arrow svg {
  width: 22px;
  height: 22px;
}

html.compact .router-question {
  white-space: normal;
  max-width: calc(100% - 32px);
  text-align: center;
  font-size: 12px;
  top: 12px;
  line-height: 1.4;
}

html.compact .router-card {
  padding: 12px 14px;
}

html.compact .router-card h3 {
  font-size: 14.5px;
}

html.compact .router-card p {
  font-size: 12.5px;
}

/* Agent library stack → stacked, unrotated, full width */
html.compact .agent-stack {
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

html.compact .stack-panel {
  position: static !important;
  width: 100% !important;
  transform: none !important;
  opacity: 1 !important;
}
