:root {
  color-scheme: dark;
  --bg: #06111a;
  --panel: #0b1b27;
  --panel-2: #0e2230;
  --panel-3: #102b38;
  --line: rgba(158, 204, 220, .12);
  --line-strong: rgba(158, 204, 220, .22);
  --text: #e8f4f5;
  --muted: #91aab3;
  --dim: #617984;
  --accent: #56e4d1;
  --accent-2: #26bfae;
  --accent-soft: rgba(86, 228, 209, .12);
  --radius: 16px;
  --space: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-width: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { width: 100%; height: 100vh; height: 100dvh; display: grid; grid-template-rows: 68px minmax(0, 1fr); overflow: hidden; background: radial-gradient(ellipse at 28% 4%, rgba(22, 80, 86, .16), transparent 44%), #06111a; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(7, 19, 29, .92); min-width: 0; }
.brand-mark { width: 30px; height: 30px; border: 1px solid rgba(86, 228, 209, .35); border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-8deg); background: rgba(86, 228, 209, .07); flex: 0 0 auto; }
.brand-mark span { width: 2px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 8px rgba(86, 228, 209, .4); }
.brand-mark span:nth-child(1) { height: 9px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; opacity: .72; }
.brand-copy { min-width: 0; }
.eyebrow, .stage-kicker { font-size: 9px; letter-spacing: .19em; font-weight: 750; color: #78a3aa; }
h1 { margin: 3px 0 0; font-size: 16px; letter-spacing: .13em; font-weight: 760; line-height: 1.1; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 9px; color: #8ba5ae; font-size: 9px; letter-spacing: .13em; font-weight: 700; white-space: nowrap; }
.live-dot, .state-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(86, 228, 209, .65); }
.version-chip { padding: 6px 9px; border: 1px solid var(--line-strong); border-radius: 6px; color: #a7c0c6; letter-spacing: .11em; }
.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; padding: 12px; }
.stage-card, .control-card { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(13, 34, 47, .98), rgba(7, 22, 33, .98)); box-shadow: 0 18px 50px rgba(0, 0, 0, .16); }
.stage-card { position: relative; overflow: hidden; display: flex; flex-direction: column; isolation: isolate; }
.stage-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1; background: radial-gradient(ellipse at 50% 34%, rgba(27, 102, 105, .13), transparent 50%), linear-gradient(180deg, rgba(14, 40, 51, .18), transparent 50%); }
.stage-topline { position: absolute; z-index: 2; top: 18px; left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.stage-subtitle { margin-top: 5px; color: #78929c; font-size: 11px; letter-spacing: .015em; }
.stage-state { display: flex; align-items: center; gap: 8px; border: 1px solid rgba(86, 228, 209, .2); background: rgba(6, 20, 29, .7); padding: 7px 10px; border-radius: 20px; font-size: 8px; letter-spacing: .15em; font-weight: 800; color: #a4c7c8; }
.stage-state.is-clear { border-color: rgba(86, 228, 209, .25); color: #9be9dc; }
.stage-state.is-clear .state-indicator { background: var(--accent); box-shadow: 0 0 10px rgba(86, 228, 209, .5); }
#fieldCanvas { display: block; width: 100%; height: 100%; min-height: 0; flex: 1 1 auto; }
.stage-legend { position: absolute; left: 20px; bottom: 18px; display: flex; align-items: center; gap: 18px; color: #75919b; font-size: 8px; font-weight: 750; letter-spacing: .12em; pointer-events: none; }
.stage-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.legend-dot.focal { background: var(--accent); box-shadow: 0 0 8px rgba(86, 228, 209, .6); }
.legend-dot.neighbour { background: #9cb9d4; }
.legend-line { display: inline-block; width: 15px; border-top: 1px dashed #4eaaa6; }
.stage-footnote { position: absolute; right: 20px; bottom: 18px; color: #536d78; font-size: 8px; letter-spacing: .11em; font-weight: 700; pointer-events: none; }
.control-card { overflow: hidden; display: flex; flex-direction: column; }
.control-scroll { min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 18px 18px 16px; scrollbar-width: thin; scrollbar-color: #294651 transparent; }
.control-scroll::-webkit-scrollbar { width: 5px; }
.control-scroll::-webkit-scrollbar-thumb { background: #294651; border-radius: 5px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 17px; font-weight: 680; letter-spacing: -.025em; }
.control-index { color: #617b85; font-size: 9px; letter-spacing: .12em; font-weight: 700; padding-bottom: 3px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.preset-button { min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left; border: 1px solid var(--line); background: rgba(9, 27, 39, .7); border-radius: 10px; padding: 9px 8px; cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.preset-button:hover { border-color: rgba(86, 228, 209, .35); transform: translateY(-1px); }
.preset-button.active { border-color: rgba(86, 228, 209, .5); background: rgba(45, 137, 129, .12); }
.preset-icon { flex: 0 0 25px; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; color: var(--accent); background: rgba(86, 228, 209, .1); font-size: 16px; }
.preset-button b { display: block; font-size: 10px; line-height: 1.25; font-weight: 700; color: #d9e9e9; }
.preset-button small { display: block; margin-top: 3px; font-size: 8px; color: #77929b; }
.control-list { display: grid; gap: 14px; }
.control-item { min-width: 0; }
.control-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.control-label-row label { color: #bfd0d4; font-size: 10px; font-weight: 650; letter-spacing: .015em; }
.control-label-row output { color: var(--accent); font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.symbol { color: #83a6ab; font-family: Georgia, serif; font-style: italic; }
input[type="range"] { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 15px; margin: 7px 0 1px; padding: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, #278f87, #56e4d1); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, #278f87, #56e4d1); }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; margin-top: -5px; background: #d9fffa; border: 3px solid #2db9aa; box-shadow: 0 0 0 3px rgba(86, 228, 209, .12), 0 0 10px rgba(86, 228, 209, .32); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: #d9fffa; border: 3px solid #2db9aa; box-shadow: 0 0 0 3px rgba(86, 228, 209, .12); }
input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.range-meta { display: flex; align-items: center; justify-content: space-between; color: #5f7983; font-size: 8px; font-variant-numeric: tabular-nums; }
.provenance { color: #67848d; font-size: 7px; font-weight: 800; letter-spacing: .12em; white-space: nowrap; }
.readout-block { margin-top: 18px; padding: 13px 12px 12px; border: 1px solid rgba(86, 228, 209, .14); border-radius: 11px; background: linear-gradient(135deg, rgba(20, 58, 63, .23), rgba(9, 25, 36, .5)); }
.readout-heading { display: flex; justify-content: space-between; align-items: center; color: #8eb0b5; font-size: 8px; font-weight: 800; letter-spacing: .16em; margin-bottom: 10px; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.readout-cell { min-width: 0; padding: 8px 8px 7px; border-radius: 7px; background: rgba(4, 17, 26, .42); border: 1px solid rgba(150, 198, 204, .07); }
.readout-label { display: block; color: #78949d; font-size: 8px; letter-spacing: .04em; }
.readout-cell strong { display: block; margin-top: 5px; color: #e7f5f3; font-size: 20px; line-height: 1; font-weight: 720; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.readout-cell strong small { color: #83a4aa; font-size: 10px; font-weight: 650; letter-spacing: 0; }
.readout-note { display: block; margin-top: 5px; color: #6e8b93; font-size: 8px; }
.threshold-track { margin-top: 12px; }
.threshold-copy { display: flex; justify-content: space-between; gap: 8px; color: #829da5; font-size: 8px; }
.threshold-copy b { color: var(--accent); font-size: 8px; letter-spacing: .08em; }
.threshold-copy b.is-triggered { color: var(--accent); }
.threshold-meter { position: relative; height: 5px; margin-top: 7px; border-radius: 8px; background: rgba(130, 165, 172, .12); overflow: hidden; }
.threshold-meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #2c9b91, #64edcf); transition: width .16s linear; }
.threshold-meter i { position: absolute; top: -2px; bottom: -2px; left: 15.6%; border-left: 1px dashed rgba(232, 244, 245, .65); }
.threshold-caption { margin-top: 6px; color: #607c86; font-size: 8px; line-height: 1.35; }
.transport-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 7px; margin-top: 14px; }
.transport-primary, .transport-secondary, .utility-button { min-width: 0; border-radius: 8px; cursor: pointer; font-size: 9px; font-weight: 800; letter-spacing: .1em; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.transport-primary:hover, .transport-secondary:hover, .utility-button:hover { transform: translateY(-1px); }
.transport-primary { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid rgba(86, 228, 209, .42); background: linear-gradient(135deg, #1b827d, #17655f); color: #f0fffc; padding: 10px 8px; box-shadow: 0 5px 16px rgba(19, 128, 119, .16); }
.transport-primary span:first-child { font-size: 12px; }
.transport-secondary { border: 1px solid var(--line-strong); background: rgba(11, 30, 42, .7); color: #a8c0c5; padding: 10px 6px; }
.transport-secondary span { color: var(--accent); font-size: 13px; }
.utility-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.utility-button { padding: 8px 7px; border: 1px solid var(--line); background: transparent; color: #77939b; font-size: 8px; }
.utility-button[aria-pressed="true"] { color: var(--accent); border-color: rgba(86, 228, 209, .28); background: rgba(86, 228, 209, .05); }
.restart-note { margin: 9px 0 13px; color: #617c85; font-size: 8px; line-height: 1.5; }
kbd { font: inherit; color: #a4bdc0; border: 1px solid rgba(153, 194, 198, .18); border-radius: 3px; padding: 1px 4px; }
.science-panel { border-top: 1px solid var(--line); padding-top: 11px; }
.science-panel summary { display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none; outline-offset: 4px; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: rgba(86, 228, 209, .09); color: var(--accent); font-size: 15px; }
.science-panel summary b { display: block; color: #cbdcdd; font-size: 10px; }
.science-panel summary small { display: block; margin-top: 2px; color: #718b94; font-size: 8px; }
.chevron { margin-left: auto; color: #78949c; font-size: 15px; transition: transform .2s ease; }
.science-panel[open] .chevron { transform: rotate(180deg); }
.science-content { padding: 13px 2px 2px; color: #91aab0; font-size: 9px; line-height: 1.55; }
.science-content h3 { margin: 12px 0 5px; color: #c7d9db; font-size: 10px; font-weight: 700; }
.science-content p { margin: 5px 0 8px; }
.science-content .equation { padding: 7px 9px; border-left: 2px solid rgba(86, 228, 209, .55); background: rgba(4, 18, 26, .45); color: #c7e7e3; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; letter-spacing: .015em; }
.science-content ul { margin: 5px 0 9px; padding-left: 16px; }
.science-content li { margin: 4px 0; }
.audit-box { display: flex; gap: 8px; margin: 10px 0; padding: 9px; border: 1px solid rgba(86, 228, 209, .18); border-radius: 8px; background: rgba(86, 228, 209, .045); }
.audit-icon { color: var(--accent); font-size: 14px; }
.audit-box b { color: #b9d7d7; font-size: 9px; }
.audit-box p { margin: 3px 0 0; color: #7f9da3; font-size: 8px; }
.evidence-note { padding: 9px; border-radius: 8px; background: rgba(14, 36, 48, .7); }
.evidence-note p { margin: 5px 0; }
.evidence-note small { color: #68838d; font-size: 8px; }
.disclaimer { padding-top: 8px; border-top: 1px solid var(--line); color: #738b92; font-size: 8px; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 900px) and (min-width: 701px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 326px; gap: 9px; padding: 9px; }
  .control-scroll { padding: 14px 13px; }
  .stage-topline { left: 15px; right: 15px; }
  .stage-legend { left: 15px; gap: 12px; }
  .stage-footnote { right: 15px; }
}
@media (max-width: 700px) {
  .app-shell { grid-template-rows: 56px minmax(0, 1fr); }
  .topbar { padding: 0 13px; gap: 10px; }
  .brand-mark { width: 27px; height: 27px; }
  h1 { font-size: 13px; }
  .eyebrow { font-size: 8px; }
  .topbar-right { gap: 6px; font-size: 7px; letter-spacing: .08em; }
  .topbar-status { display: none; }
  .version-chip { padding: 5px 7px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(235px, 39vh) minmax(0, 1fr); gap: 8px; padding: 8px; }
  .stage-card { min-height: 0; }
  .stage-topline { top: 12px; left: 13px; right: 13px; }
  .stage-kicker { font-size: 8px; }
  .stage-subtitle { font-size: 9px; }
  .stage-state { padding: 6px 8px; font-size: 7px; }
  .stage-legend { left: 13px; bottom: 11px; gap: 10px; font-size: 7px; }
  .stage-footnote { right: 13px; bottom: 11px; font-size: 6px; }
  .control-scroll { padding: 13px 13px 18px; }
  .panel-heading { margin-bottom: 11px; }
  .panel-heading h2 { font-size: 15px; }
  .control-index { font-size: 8px; }
  .preset-row { margin-bottom: 14px; }
  .control-list { gap: 12px; }
  .readout-block { margin-top: 15px; }
}
@media (max-width: 380px) {
  .stage-subtitle { max-width: 190px; }
  .stage-footnote { display: none; }
  .preset-button { padding: 8px 6px; gap: 6px; }
  .preset-icon { flex-basis: 22px; width: 22px; height: 22px; }
  .preset-button b { font-size: 9px; }
  .preset-button small { font-size: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
