:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #5a6560;
  --line: #d8ded7;
  --accent: #0b6b75;
  --accent-strong: #064d55;
  --gold: #b98225;
  --shadow: 0 18px 50px rgba(22, 32, 29, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(11, 107, 117, 0.08), transparent 300px),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: var(--accent-strong);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

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

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.index-header {
  max-width: 860px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.lede {
  margin: 22px 0 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.6;
}

.status-panel {
  margin-top: 44px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.jump-panel {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.jump-panel h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.jump-list a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 760;
  text-decoration: none;
}

.jump-list a:hover {
  border-color: var(--accent);
}

.demo-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  margin-bottom: 26px;
}

.demo-header h1 {
  font-size: clamp(2rem, 5vw, 4.1rem);
}

.back-link {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.demo-meta {
  margin-top: 14px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.demo-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.output {
  min-height: 520px;
  overflow: hidden;
}

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

.metric {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.insight {
  padding: 16px;
  border-left: 4px solid var(--gold);
  background: #fff8ec;
  color: #4b371d;
  line-height: 1.5;
}

.viz {
  width: 100%;
  min-height: 520px;
  display: block;
}

.debugger-demo {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(300px, 1.05fr);
  gap: 14px;
  padding: 14px;
  min-height: 520px;
  background: #eef4f1;
}

.debugger-demo section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pane-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.code-pane {
  overflow: hidden;
}

.code-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 12px;
  list-style: none;
  background: #17201d;
}

.code-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 36px;
  padding: 0 10px 0 0;
  border-radius: 6px;
  color: #dfe8e4;
}

.code-list li.active {
  background: #f1b84b;
  color: #17201d;
  box-shadow: inset 4px 0 0 #e6695b;
}

.line-no {
  color: rgba(255, 255, 255, 0.55);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  text-align: right;
}

.code-list li.active .line-no {
  color: rgba(23, 32, 29, 0.65);
}

.code-list code {
  min-width: 0;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-pane,
.explain-pane {
  display: grid;
  align-content: start;
}

.call-stack,
.heap-board,
.debugger-actions,
.explain-pane p,
.branch-card,
.output-card,
.trace-dots {
  margin: 12px;
}

.stack-frame {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #edf7f4;
  color: var(--accent-strong);
}

.stack-frame span,
.locals-grid span,
.heap-label,
.branch-card span,
.output-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.locals-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.locals-grid div,
.branch-card,
.output-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.locals-grid strong,
.branch-card strong,
.output-card strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.heap-board {
  display: grid;
  gap: 12px;
}

.heap-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.heap-cell,
.empty-cell {
  display: grid;
  place-items: center;
  min-width: 54px;
  min-height: 54px;
  padding: 7px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.heap-cell span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.heap-cell strong {
  font-size: 1.06rem;
}

.heap-cell.active {
  border-color: #e6695b;
  box-shadow: 0 0 0 4px rgba(230, 105, 91, 0.18);
}

.heap-cell.pass {
  background: #eaf7ef;
}

.heap-cell.fail {
  background: #fff0ee;
}

.empty-cell {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.explain-pane {
  grid-column: 1 / -1;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  align-items: stretch;
}

.explain-pane .pane-title,
.explain-pane .debugger-actions,
.explain-pane .trace-dots {
  grid-column: 1 / -1;
}

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

.debugger-actions button {
  min-height: 36px;
}

.explain-pane p {
  align-self: stretch;
  line-height: 1.5;
}

.branch-card {
  background: #eaf7ef;
}

.branch-card.miss {
  background: #fff0ee;
}

.output-card {
  background: #fff8ec;
}

.trace-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.trace-dots span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #cad5d0;
}

.trace-dots span.done {
  background: #5db7a8;
}

.trace-dots span.now {
  background: #e6695b;
  transform: scale(1.35);
}

.fsm-demo {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(270px, 0.65fr);
  gap: 14px;
  padding: 14px;
  min-height: 520px;
  background: #f1f4f7;
}

.fsm-demo section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.fsm-graph svg {
  display: block;
  width: 100%;
  min-height: 430px;
}

.fsm-edge {
  fill: none;
  stroke: #6f7d8c;
  stroke-width: 4;
  marker-end: url("#arrowhead");
}

.fsm-edge.active {
  stroke: #e6695b;
  stroke-width: 8;
}

.fsm-graph text {
  fill: #17201d;
  font-weight: 900;
}

.fsm-node circle {
  fill: #fff;
  stroke: #0b6b75;
  stroke-width: 5;
}

.fsm-node.active circle {
  fill: #fff8ec;
  stroke: #e6695b;
  stroke-width: 8;
}

.fsm-node.accepting circle {
  stroke: #43a487;
}

.fsm-side {
  display: grid;
  align-content: start;
}

.tape-row,
.path-row,
.verdict,
.transition-table {
  margin: 12px;
}

.tape-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tape-cell {
  display: grid;
  place-items: center;
  width: 48px;
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tape-cell span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.tape-cell strong {
  font-size: 1.3rem;
}

.tape-cell.done {
  background: #eaf7ef;
  border-color: #43a487;
}

.tape-cell.active {
  background: #fff8ec;
  border-color: #e6695b;
  box-shadow: 0 0 0 4px rgba(230, 105, 91, 0.16);
}

.verdict {
  padding: 12px;
  border-radius: 8px;
  background: #edf7f4;
}

.verdict.accepted {
  background: #eaf7ef;
}

.verdict.rejected {
  background: #fff0ee;
}

.verdict span,
.path-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.verdict strong {
  display: block;
  margin-top: 6px;
}

.path-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.path-row span:not(.path-label) {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf7f4;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 900;
}

.path-row span.active {
  background: #e6695b;
  color: #fff;
}

.transition-table {
  width: calc(100% - 24px);
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
  font-size: 0.9rem;
}

.transition-table th,
.transition-table td {
  padding: 9px;
  border: 1px solid var(--line);
  text-align: center;
}

.transition-table th {
  background: #f6faf8;
}

.transition-table tr.active th,
.transition-table tr.active td {
  background: #fff8ec;
  color: #7f2d55;
  font-weight: 900;
}

.lab-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  min-height: 520px;
  background: #f3f6f4;
}

.lab-board section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.mini-code {
  margin: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #17201d;
  color: #eaf1ee;
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}

.mutant-grid,
.check-list,
.risk-bars,
.trigger-map {
  display: grid;
  gap: 10px;
  margin: 12px;
}

.mutant,
.check-list div,
.stage-pill {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mutant span,
.mutant em,
.stage-pill em {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.mutant strong {
  display: block;
  margin: 6px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.mutant.killed {
  border-color: #43a487;
  background: #eaf7ef;
}

.mutant.survived {
  border-color: #e6695b;
  background: #fff0ee;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  margin: 22px auto 12px;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, #fff 0 56%, transparent 57%),
    conic-gradient(#0b6b75 calc(var(--score) * 1%), #d8ded7 0);
  text-align: center;
}

.score-ring strong {
  display: block;
  font-size: 1.55rem;
}

.score-ring span {
  display: block;
  max-width: 90px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lab-note {
  margin: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.phone-mock {
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #edf7f4);
}

.phone-top {
  margin-bottom: 18px;
  font-weight: 900;
}

.progress {
  height: 12px;
  border-radius: 999px;
  background: #d8ded7;
  overflow: hidden;
}

.progress span,
.risk-bars i,
.trigger-map span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #0b6b75;
}

.phone-mock button {
  width: 100%;
  margin: 22px 0 12px;
}

.toast {
  padding: 12px;
  border-radius: 8px;
  background: #fff8ec;
  color: #4b371d;
  font-weight: 800;
}

.friction-stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.friction-stack span,
.check-list span {
  display: block;
  color: var(--muted);
}

.check-list .good {
  border-color: #43a487;
  background: #eaf7ef;
}

.check-list .warn {
  border-color: #e6695b;
  background: #fff0ee;
}

.lifecycle-flow {
  display: grid;
  align-content: start;
  gap: 10px;
  padding-bottom: 12px;
}

.stage-pill {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  margin: 0 12px;
}

.stage-pill span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #edf7f4;
  color: var(--accent-strong);
  font-weight: 900;
}

.stage-pill.risk {
  border-color: #e6695b;
  background: #fff0ee;
}

.stage-pill.ok {
  border-color: #43a487;
  background: #eaf7ef;
}

.risk-bars label,
.trigger-map div {
  display: grid;
  gap: 7px;
}

.risk-bars span,
.trigger-map div span {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: #d8ded7;
  overflow: hidden;
}

.utterance {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px;
  font-size: 1.15rem;
  line-height: 1.5;
}

.utterance span {
  position: relative;
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf7f4;
  font-weight: 850;
}

.utterance span.switch {
  background: #fff8ec;
  box-shadow: inset 0 -4px 0 #f1b84b;
}

.utterance em {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.econ-board,
.sensor-board {
  min-height: 520px;
  background: #f6faf8;
}

.econ-board svg,
.sensor-board svg {
  display: block;
  width: 100%;
  min-height: 520px;
}

.taxonomy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px;
  align-items: end;
}

.taxonomy-grid div {
  display: grid;
  gap: 6px;
  min-height: 155px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.taxonomy-grid span {
  align-self: end;
  border-radius: 8px 8px 0 0;
  background: #5db7a8;
}

.taxonomy-grid em {
  color: var(--muted);
  font-style: normal;
  font-weight: 900;
}

.axis-map,
.scenario-grid {
  position: relative;
  min-height: 260px;
  margin: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 49%, var(--line) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, var(--line) 50%, transparent 51%),
    #fff;
}

.axis-map i,
.scenario-grid i {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 4px solid #fff;
  border-radius: 999px;
  background: #e6695b;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 14px rgba(23, 32, 29, 0.25);
}

.axis-map span,
.axis-map b {
  position: absolute;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.axis-map span {
  right: 10px;
  bottom: 8px;
}

.axis-map b {
  left: 10px;
  top: 8px;
}

.ability-card {
  display: grid;
  gap: 10px;
  margin: 12px;
  padding: 18px;
  border-radius: 8px;
  background: #17201d;
  color: #fff;
}

.ability-card strong {
  font-size: 1.35rem;
}

.ability-card span {
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.counterplay {
  display: grid;
  place-items: center;
  min-height: 170px;
  margin: 12px;
  border-radius: 8px;
  background: #fff0ee;
}

.counterplay span {
  display: block;
  height: 18px;
  min-width: 24px;
  border-radius: 999px;
  background: #43a487;
}

.counterplay strong {
  margin-top: 8px;
  font-size: 1.4rem;
}

.matrix3 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px;
}

.matrix3 span {
  padding: 12px;
  border-radius: 8px;
  background: #edf7f4;
  font-weight: 900;
}

.matrix3 .hot {
  background: #fff0ee;
  color: #7f2d55;
}

.chain {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px;
  align-items: center;
}

.chain span {
  display: grid;
  place-items: center;
  min-width: 74px;
  height: calc(var(--h) * 1px);
  padding: 8px;
  border-radius: 8px;
  background: #edf7f4;
  color: var(--accent-strong);
  font-weight: 900;
}

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

.scenario-grid span {
  padding: 12px;
  color: var(--muted);
  font-weight: 900;
}

.face-meter {
  display: grid;
  place-items: center;
  min-height: 240px;
  margin: 12px;
  border-radius: 8px;
  background: #fff8ec;
}

.face-meter span {
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 38% 40%, #17201d 0 6px, transparent 7px),
    radial-gradient(circle at 62% 40%, #17201d 0 6px, transparent 7px),
    radial-gradient(ellipse at 50% calc(58% + var(--m) * 0.12px), transparent 0 22px, #17201d 23px 27px, transparent 28px),
    #f1b84b;
}

.rep-ledger {
  display: grid;
  gap: 12px;
  margin: 12px;
}

.rep-ledger div {
  display: grid;
  gap: 7px;
}

.rep-ledger span {
  display: block;
  height: 14px;
  border-radius: 999px;
  background: #0b6b75;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 30px;
}

.unit-section {
  margin-top: 46px;
}

.unit-title {
  margin: 0 0 16px;
  font-size: 1.45rem;
}

.demo-card {
  display: grid;
  min-height: 330px;
  color: inherit;
  text-decoration: none;
  overflow: hidden;
}

.thumb {
  min-height: 170px;
  background: linear-gradient(135deg, rgba(11, 107, 117, 0.15), rgba(185, 130, 37, 0.2));
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  font-size: 3rem;
  font-weight: 900;
}

.card-body {
  padding: 18px;
}

.card-body h2 {
  margin: 0;
  font-size: 1.18rem;
}

.card-body p {
  color: var(--muted);
  line-height: 1.45;
}

.status-panel h2 {
  margin: 0 0 18px;
  font-size: 1.25rem;
}

dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

dl div {
  min-width: 0;
  padding: 16px;
  border-left: 4px solid var(--accent);
  background: var(--surface);
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

dd {
  margin: 8px 0 0;
  font-size: 1rem;
  line-height: 1.4;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 24px, 1120px);
    padding: 32px 0;
  }

  h1 {
    font-size: 2.35rem;
    line-height: 1.04;
  }

  .lede {
    font-size: 1rem;
  }

  .status-panel {
    padding: 18px;
  }

  .jump-panel {
    padding: 16px;
  }

  .jump-list {
    gap: 8px;
  }

  .jump-list a {
    min-height: 36px;
    font-size: 0.86rem;
  }

  dl {
    grid-template-columns: 1fr;
  }

  .demo-header,
  .demo-grid {
    grid-template-columns: 1fr;
  }

  .demo-header h1 {
    font-size: 2.15rem;
  }

  .output,
  .viz {
    min-height: 430px;
  }

  .output {
    order: -1;
  }

  .debugger-demo {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 10px;
  }

  .fsm-demo {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 10px;
  }

  .lab-board {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 10px;
  }

  .fsm-graph svg {
    min-height: 320px;
  }

  .code-list {
    padding: 10px;
  }

  .code-list code {
    font-size: 0.78rem;
  }

  .locals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .explain-pane {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}
