:root {
  --bg: #f6f1e8;
  --ink: #17151c;
  --muted: #706c79;
  --panel: #fffaf0;
  --panel-cool: #eef7f6;
  --line: #ded4c3;
  --black: #121018;
  --lime: #9cff6e;
  --coral: #ff8a5b;
  --sky: #63b8ff;
  --violet: #7d68d4;
  --red: #cf5959;
  --green: #4d9d67;
  --amber: #c78131;
  --shadow: 0 24px 60px rgba(23, 21, 28, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(18, 16, 24, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(18, 16, 24, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 52px 52px;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button {
  cursor: pointer;
  font: inherit;
}

code {
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

.demo-shell {
  min-height: 100vh;
}

.command-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255, 250, 240, 0.16);
  background: rgba(18, 16, 24, 0.94);
  color: #fffaf0;
  backdrop-filter: blur(14px);
}

.brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-signal {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 250, 240, 0.2);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 72% 26%, var(--coral) 0 5px, transparent 6px),
    linear-gradient(135deg, transparent 0 38%, var(--lime) 39% 44%, transparent 45%),
    #211d2a;
}

.brand p,
.brand h1,
.panel p,
.panel h3,
.headline-panel p,
.headline-panel h2,
.live-panel p,
.live-panel h3 {
  margin: 0;
}

.brand p {
  color: var(--lime);
  font-size: 12px;
  font-weight: 840;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand h1 {
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.15;
}

.story-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.story-step {
  display: grid;
  min-height: 48px;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(255, 250, 240, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.05);
  color: #ded8cc;
  text-align: left;
}

.story-step span {
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
}

.story-step:hover,
.story-step.active {
  border-color: rgba(156, 255, 110, 0.55);
  background: rgba(156, 255, 110, 0.12);
  color: #ffffff;
}

.command-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.primary-button {
  min-height: 40px;
  border-radius: var(--radius);
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 20px;
}

.primary-button {
  padding: 0 16px;
  border: 1px solid var(--lime);
  background: var(--lime);
  color: var(--black);
  font-weight: 900;
}

.stage {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.opening-grid,
.two-column,
.comparison-grid,
.safety-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
}

.headline-panel,
.live-panel,
.panel,
.narrative-band,
.pipeline-panel,
.patient-picker,
.patient-board,
.evidence-board,
.safety-hero,
.manifest-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
}

.headline-panel {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  padding: 34px;
  background:
    linear-gradient(120deg, rgba(255, 138, 91, 0.12), transparent 38%),
    linear-gradient(310deg, rgba(99, 184, 255, 0.16), transparent 42%),
    #fffaf0;
}

.headline-panel::after {
  position: absolute;
  right: -60px;
  bottom: -80px;
  width: 360px;
  height: 220px;
  border: 1px solid rgba(18, 16, 24, 0.11);
  border-radius: 50%;
  content: "";
  transform: rotate(-14deg);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.headline-panel h2,
.engine-core h2,
.safety-hero h2 {
  max-width: 760px;
  margin: 10px 0 16px;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 0.98;
}

.lead,
.safety-hero p {
  max-width: 760px;
  color: #4d4856;
  font-size: 18px;
  line-height: 1.72;
}

.talk-points {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}

.talk-points div,
.metric-tile,
.route-item,
.signal-card,
.pipeline-step,
.method-row,
.plain-item,
.patient-button,
.evidence-item,
.manifest-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.talk-points div {
  padding: 14px;
}

.talk-points strong,
.talk-points span {
  display: block;
}

.talk-points strong {
  margin-bottom: 6px;
  font-size: 16px;
}

.talk-points span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.live-panel,
.panel,
.narrative-band,
.pipeline-panel,
.patient-picker,
.patient-board,
.evidence-board,
.safety-hero,
.manifest-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-heading h3,
.narrative-band h3,
.evidence-board h3 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.15;
}

.soft-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid #f2c0a6;
  border-radius: 999px;
  padding: 0 10px;
  background: #fff2ea;
  color: #974b2f;
  font-size: 12px;
  font-weight: 860;
  white-space: nowrap;
}

.hero-trace {
  display: block;
  width: 100%;
  height: 344px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-tile {
  min-height: 118px;
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.metric-value {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 940;
  line-height: 1;
}

.metric-note {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.narrative-band {
  background: #16131d;
  color: #fffaf0;
}

.narrative-band .eyebrow {
  color: var(--lime);
}

.route-map {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.route-item {
  min-height: 118px;
  padding: 12px;
  background: rgba(255, 250, 240, 0.08);
  border-color: rgba(255, 250, 240, 0.16);
  color: #fffaf0;
}

.route-item b {
  display: block;
  color: var(--coral);
  font-size: 12px;
}

.route-item strong {
  display: block;
  margin: 8px 0 6px;
}

.route-item p {
  margin: 0;
  color: #d8d0c6;
  font-size: 12px;
  line-height: 1.45;
}

.device-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.device-row strong {
  display: block;
  margin-bottom: 7px;
  font-size: 20px;
}

.device-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
}

.sensor-device {
  position: relative;
  display: grid;
  width: 128px;
  height: 128px;
  place-items: center;
  border: 2px solid #201c27;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 48%, rgba(18, 16, 24, 0.15) 49% 51%, transparent 52%),
    #f4eadb;
}

.sensor-device span {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--black);
  box-shadow: inset 0 0 0 9px var(--lime);
  transform: rotate(12deg);
}

.sensor-device i {
  position: absolute;
  right: 16px;
  top: 22px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--coral);
}

.raw-stream,
.method-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 13px;
}

th,
td {
  padding: 11px;
  border-bottom: 1px solid #ece2d2;
  text-align: left;
}

th {
  background: #fcf2e4;
  color: #3b3542;
  font-weight: 900;
  white-space: nowrap;
}

td {
  color: #403b49;
}

.gate-meter {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.gate-dial {
  display: grid;
  width: 130px;
  height: 130px;
  place-items: center;
  border-radius: 18px;
  background:
    conic-gradient(var(--lime) 0 96%, #ded4c3 96% 100%);
}

.gate-dial strong {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border-radius: 50%;
  background: var(--black);
  color: var(--lime);
  font-size: 25px;
}

.gate-copy strong {
  display: block;
  margin-bottom: 7px;
  font-size: 18px;
}

.gate-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.gate-list,
.plain-list,
.evidence-list,
.manifest-panel {
  display: grid;
  gap: 10px;
}

.gate-item,
.plain-item,
.evidence-item,
.manifest-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.gate-item span,
.plain-item span,
.evidence-item span,
.manifest-item span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--black);
  color: var(--lime);
  font-size: 12px;
  font-weight: 900;
}

.gate-item p,
.plain-item p,
.evidence-item p,
.manifest-item p {
  margin: 0;
  color: #4b4652;
  line-height: 1.5;
}

.engine-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.engine-core {
  min-height: 510px;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--black);
  color: #fffaf0;
  box-shadow: var(--shadow);
}

.engine-core .eyebrow {
  color: var(--lime);
}

.engine-radar {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 1;
  margin: 24px auto 0;
  border: 1px solid rgba(255, 250, 240, 0.15);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49%, rgba(156, 255, 110, 0.25) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(156, 255, 110, 0.25) 50%, transparent 51%);
}

.engine-radar span {
  position: absolute;
  border: 1px solid rgba(156, 255, 110, 0.28);
  border-radius: 50%;
  inset: calc(var(--i, 0) * 12%);
}

.engine-radar span:nth-child(1) { --i: 1; }
.engine-radar span:nth-child(2) { --i: 2; }
.engine-radar span:nth-child(3) { --i: 3; }
.engine-radar span:nth-child(4) { --i: 4; }

.engine-radar b {
  position: absolute;
  inset: 42%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--lime);
  color: var(--black);
}

.signal-wall {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.signal-card {
  padding: 18px;
}

.signal-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.signal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.pipeline-panel {
  margin-top: 0;
}

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

.pipeline-step {
  min-height: 154px;
  padding: 14px;
}

.pipeline-step b {
  display: block;
  color: var(--coral);
  font-size: 12px;
}

.pipeline-step strong {
  display: block;
  margin: 9px 0 8px;
  font-size: 16px;
}

.pipeline-step p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.comparison-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
}

.comparison-main {
  background: #fffaf0;
}

.method-bars {
  display: grid;
  gap: 13px;
}

.method-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 70px;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.method-name {
  font-weight: 900;
}

.method-name span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.method-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece2d2;
}

.method-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sky), var(--lime));
}

.method-score {
  color: #302a38;
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.patient-workbench {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 310px;
  gap: 18px;
}

.patient-picker,
.evidence-board {
  align-self: start;
}

.patient-picker {
  display: grid;
  gap: 10px;
}

.patient-button {
  display: grid;
  width: 100%;
  gap: 7px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
}

.patient-button.active {
  border-color: var(--black);
  background: #fff2ea;
}

.patient-button strong {
  font-size: 16px;
}

.patient-button span {
  color: var(--muted);
  font-size: 12px;
}

.patient-board {
  display: grid;
  gap: 16px;
}

.patient-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 154px;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.patient-summary h3 {
  margin: 4px 0 8px;
  font-size: 26px;
}

.patient-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.probability-dial {
  display: grid;
  width: 140px;
  height: 140px;
  place-items: center;
  border-radius: 20px;
  justify-self: end;
}

.probability-dial strong {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  font-size: 24px;
}

.trace-board {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.cgm-svg {
  display: block;
  width: 100%;
  height: 330px;
  overflow: visible;
}

.evidence-board h3 {
  margin-bottom: 14px;
}

.evidence-item strong {
  display: block;
  margin-bottom: 5px;
}

.evidence-item small {
  color: var(--muted);
  line-height: 1.45;
}

.safety-hero {
  display: grid;
  align-content: center;
  min-height: 420px;
  background: var(--black);
  color: #fffaf0;
}

.safety-hero .eyebrow {
  color: var(--lime);
}

.safety-hero p {
  color: #ddd3c8;
}

.manifest-panel {
  background: var(--panel-cool);
}

.manifest-item {
  grid-template-columns: 92px minmax(0, 1fr);
}

.manifest-item span {
  width: 82px;
  background: #ffffff;
  color: var(--black);
}

@media (max-width: 1180px) {
  .command-bar {
    grid-template-columns: 1fr;
  }

  .story-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .opening-grid,
  .two-column,
  .comparison-grid,
  .engine-layout,
  .safety-layout {
    grid-template-columns: 1fr;
  }

  .pipeline,
  .route-map,
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .patient-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .stage,
  .command-bar {
    padding: 14px;
  }

  .story-nav,
  .talk-points,
  .pipeline,
  .route-map,
  .metric-strip,
  .signal-wall {
    grid-template-columns: 1fr;
  }

  .story-step {
    min-height: 42px;
  }

  .headline-panel {
    min-height: auto;
    padding: 22px;
  }

  .headline-panel h2,
  .engine-core h2,
  .safety-hero h2 {
    font-size: 36px;
  }

  .device-row,
  .gate-meter,
  .patient-summary {
    grid-template-columns: 1fr;
  }

  .probability-dial {
    justify-self: start;
  }

  .method-row {
    grid-template-columns: 1fr;
  }

  .method-score {
    text-align: left;
  }
}
