:root {
  color-scheme: dark;
  --bg: #071116;
  --panel: #0c1a21;
  --panel-2: #10212a;
  --panel-3: #132832;
  --line: rgba(164, 202, 211, .13);
  --line-strong: rgba(164, 202, 211, .23);
  --text: #e7f1f2;
  --muted: #8ba3aa;
  --quiet: #5d737b;
  --accent: #63e0cb;
  --accent-dim: rgba(99, 224, 203, .14);
  --good: #8ee4bf;
  --warn: #efc37d;
  --bad: #e39a8f;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(ellipse at 18% 0%, rgba(25, 71, 78, .20), transparent 42%), var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { width: min(100%, 1800px); margin: 0 auto; padding: 0 28px 18px; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 16px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; border: 1px solid rgba(99,224,203,.26); border-radius: 11px; background: linear-gradient(145deg, rgba(99,224,203,.15), rgba(99,224,203,.035)); color: var(--accent); display: grid; place-items: center; flex: 0 0 auto; }
.brand-mark svg { width: 25px; height: 25px; }
.eyebrow, .panel-kicker { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .15em; line-height: 1.5; }
h1 { font-size: 17px; line-height: 1.2; letter-spacing: -.035em; font-weight: 650; margin: 2px 0 0; }
.topbar-meta { display: flex; align-items: center; gap: 9px; color: #9db4ba; font-size: 9px; letter-spacing: .12em; font-weight: 750; white-space: nowrap; }
.live-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 4px rgba(99,224,203,.09), 0 0 12px rgba(99,224,203,.5); }
.meta-divider { width: 1px; height: 13px; background: var(--line-strong); margin: 0 4px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 396px); gap: 20px; align-items: start; padding: 20px 0 14px; }
.stage-column { min-width: 0; }
.stage-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 0 2px 12px; }
.eyebrow-sep { color: var(--accent); margin: 0 5px; }
.stage-title { margin-top: 4px; color: #dce8e9; font-size: 15px; letter-spacing: -.025em; font-weight: 550; }
.field-key { display: flex; gap: 12px; align-items: center; padding-bottom: 2px; white-space: nowrap; }
.key-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; }
.key-chip i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.key-negative { background: #6374bb; }
.key-neutral { background: #274b5b; }
.key-positive { background: #62d9bd; }
.canvas-wrap { position: relative; overflow: hidden; border: 1px solid rgba(116, 176, 185, .19); border-radius: 14px; height: clamp(340px, calc(100vh - 360px), 510px); min-height: 340px; background: #091a24; box-shadow: 0 16px 48px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.025); }
#fieldCanvas { display: block; width: 100%; height: 100%; outline: none; }
#fieldCanvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.canvas-topline, .canvas-bottomline { position: absolute; left: 15px; right: 15px; pointer-events: none; display: flex; justify-content: space-between; align-items: center; }
.canvas-topline { top: 13px; }
.canvas-bottomline { bottom: 12px; }
.canvas-label, .field-mode { font-family: var(--mono); font-size: 8px; letter-spacing: .13em; color: rgba(206,230,233,.7); text-shadow: 0 1px 5px #071116; }
.canvas-label-right { color: rgba(166,194,200,.56); }
.scale-mark { color: rgba(213,233,234,.8); font-family: var(--mono); font-size: 9px; display: flex; align-items: center; gap: 7px; text-shadow: 0 1px 5px #071116; }
.scale-mark i { display: inline-block; width: 42px; height: 5px; border-left: 1px solid rgba(225,245,245,.75); border-right: 1px solid rgba(225,245,245,.75); border-bottom: 1px solid rgba(225,245,245,.75); }
.scale-mark small { color: rgba(166,194,200,.6); font-size: 8px; }
.canvas-corner { position: absolute; right: 16px; bottom: 39px; color: rgba(119,176,183,.28); font: 800 8px/1.25 var(--mono); letter-spacing: .12em; text-align: right; pointer-events: none; }
.caption-row { display: flex; align-items: center; gap: 12px; padding: 13px 3px 1px; min-height: 65px; }
.caption-icon { width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; border: 1px solid rgba(99,224,203,.22); background: var(--accent-dim); }
.caption-icon span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(99,224,203,.55); }
.caption-copy { min-width: 0; flex: 1; }
.caption-label { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .14em; margin-bottom: 3px; }
.caption-copy p { margin: 0; color: #bacdd0; font-size: 11px; line-height: 1.5; }
.caption-state { color: var(--accent); font: 700 8px var(--mono); letter-spacing: .12em; white-space: nowrap; padding: 6px 8px; border-radius: 5px; background: rgba(99,224,203,.07); }
.control-column { min-width: 0; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 110px); overflow-y: auto; overflow-x: hidden; padding: 0 3px 4px 0; scrollbar-width: thin; scrollbar-color: #27424b transparent; }
.control-column::-webkit-scrollbar { width: 5px; }
.control-column::-webkit-scrollbar-thumb { background: #27424b; border-radius: 5px; }
.panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(16,34,43,.96), rgba(10,24,31,.96)); border-radius: var(--radius); padding: 13px 14px; box-shadow: 0 7px 24px rgba(0,0,0,.12); }
.detection-panel { padding: 13px 15px 11px; }
.detection-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0 9px; }
.detection-title { font-size: 17px; font-weight: 650; letter-spacing: -.04em; }
.detection-subtitle { margin-top: 3px; font-size: 10px; color: var(--muted); }
.signal-ring { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; border: 1px solid rgba(99,224,203,.42); display: grid; place-items: center; background: rgba(99,224,203,.08); box-shadow: 0 0 0 5px rgba(99,224,203,.035); }
.signal-ring span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px rgba(99,224,203,.7); }
.detection-panel.undetected .signal-ring { border-color: rgba(239,195,125,.35); background: rgba(239,195,125,.06); }
.detection-panel.undetected .signal-ring span { background: var(--warn); box-shadow: 0 0 12px rgba(239,195,125,.35); }
.detection-panel.undetected .detection-title { color: #e8c995; }
.threshold-track { position: relative; height: 4px; border-radius: 4px; background: #1b343d; overflow: visible; }
.threshold-fill { width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #507b89, var(--accent)); transition: width .25s ease; }
.threshold-tick { position: absolute; left: 33.333%; top: -3px; width: 1px; height: 10px; background: #e4f1ee; opacity: .65; }
.threshold-labels { display: flex; justify-content: space-between; color: var(--quiet); font: 700 7px var(--mono); letter-spacing: .09em; margin-top: 7px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.model-tag { color: #6f8990; font: 700 7px var(--mono); letter-spacing: .12em; border: 1px solid var(--line); padding: 4px 6px; border-radius: 4px; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readout-card { min-width: 0; padding: 9px 10px 8px; background: rgba(4,16,21,.35); border: 1px solid rgba(155,190,197,.08); border-radius: 8px; }
.primary-readout { grid-column: 1 / -1; background: linear-gradient(110deg, rgba(99,224,203,.085), rgba(99,224,203,.018)); border-color: rgba(99,224,203,.15); }
.readout-name { color: #9fb4b9; font-size: 9px; font-weight: 600; }
.info-dot { display: inline-grid; place-items: center; margin-left: 3px; width: 12px; height: 12px; border-radius: 50%; border: 1px solid #527078; color: #8ba7ae; font: 700 8px Georgia, serif; cursor: help; }
.readout-value { display: flex; align-items: baseline; gap: 5px; margin-top: 4px; font: 600 20px/1 var(--mono); letter-spacing: -.07em; color: #e8f5f2; font-variant-numeric: tabular-nums; }
.primary-readout .readout-value { font-size: 26px; color: var(--accent); }
.readout-value small { color: #88a2a8; font: 500 9px var(--sans); letter-spacing: 0; }
.readout-foot { margin-top: 5px; color: #627b82; font-size: 8px; }
.readout-note { margin-top: 9px; color: #6d858c; font-size: 8px; line-height: 1.45; }
.controls-panel { padding-bottom: 12px; }
.control-group { margin: 0 0 12px; }
.control-group:last-of-type { margin-bottom: 9px; }
.control-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.control-label-row label { color: #c6d6d8; font-size: 10px; font-weight: 600; }
.control-label-row output { color: var(--accent); font: 600 9px var(--mono); white-space: nowrap; }
input[type="range"] { appearance: none; display: block; width: 100%; height: 15px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(90deg, rgba(99,224,203,.58), #29434c); border-radius: 4px; }
input[type="range"]::-moz-range-track { height: 3px; background: linear-gradient(90deg, rgba(99,224,203,.58), #29434c); border-radius: 4px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #071116; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(99,224,203,.65), 0 0 9px rgba(99,224,203,.25); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #071116; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(99,224,203,.65); }
input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.range-ends { display: flex; justify-content: space-between; color: #617a81; font: 8px var(--mono); margin-top: 2px; }
.compact-control { margin-bottom: 9px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
.preset-button { border: 1px solid var(--line-strong); background: rgba(255,255,255,.018); color: #a7bdc1; border-radius: 6px; min-height: 30px; font-size: 9px; font-weight: 650; cursor: pointer; transition: border-color .18s ease, background .18s ease, color .18s ease; }
.preset-button:hover { border-color: rgba(99,224,203,.45); color: #e2f3ef; }
.preset-button.active { border-color: rgba(99,224,203,.35); background: rgba(99,224,203,.09); color: var(--accent); }
.transport-panel { padding: 11px 12px 9px; }
.transport-main { display: flex; gap: 7px; }
.transport-button { height: 34px; padding: 0 11px; border-radius: 6px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.025); color: #b7c9cc; font-size: 9px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.transport-button:hover, .screenshot-button:hover { border-color: rgba(99,224,203,.42); background: rgba(99,224,203,.07); }
.primary-transport { min-width: 96px; border-color: rgba(99,224,203,.28); background: rgba(99,224,203,.1); color: var(--accent); }
.icon-transport { width: 36px; padding: 0; font-size: 17px; }
.pause-icon { width: 9px; height: 11px; display: inline-block; border-left: 2px solid currentColor; border-right: 2px solid currentColor; }
.play-icon { width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid currentColor; }
.transport-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.quality-control { display: flex; align-items: center; gap: 4px; color: #6f8990; font: 700 7px var(--mono); letter-spacing: .09em; }
.quality-control span { margin-right: 3px; }
.quality-control button { border: 1px solid transparent; background: transparent; color: #6f8990; padding: 4px 5px; border-radius: 4px; font: 700 7px var(--mono); cursor: pointer; }
.quality-control button[aria-pressed="true"] { border-color: rgba(99,224,203,.25); background: rgba(99,224,203,.08); color: var(--accent); }
.screenshot-button { height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: 5px; border: 1px solid var(--line); background: transparent; color: #a9bec2; font-size: 8px; cursor: pointer; }
.screenshot-button svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.solver-status { display: flex; align-items: center; gap: 6px; color: #668087; font: 7px var(--mono); letter-spacing: .08em; margin-top: 10px; }
.solver-pulse { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px rgba(99,224,203,.45); }
.science-wrap { padding: 1px 0 8px; }
.science-panel { border: 1px solid var(--line); border-radius: 10px; background: rgba(11,26,33,.72); overflow: hidden; }
.science-panel summary { min-height: 43px; display: flex; align-items: center; gap: 10px; padding: 0 14px; cursor: pointer; list-style: none; color: #c7d8da; font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: var(--accent); background: rgba(99,224,203,.08); font: 13px Georgia, serif; }
.science-summary { color: #718a91; font-size: 9px; font-weight: 450; letter-spacing: 0; margin-left: 3px; }
.chevron { margin-left: auto; color: #789198; font-size: 15px; transition: transform .2s ease; }
.science-panel[open] .chevron { transform: rotate(180deg); }
.science-content { border-top: 1px solid var(--line); padding: 15px; }
.science-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.science-block { min-width: 0; }
.science-block-title { color: var(--accent); font: 750 8px var(--mono); letter-spacing: .1em; margin-bottom: 10px; }
.equation { color: #e1eeee; font: 14px/1.45 Georgia, serif; letter-spacing: .01em; padding: 7px 8px; margin: 6px 0; background: rgba(255,255,255,.025); border-left: 2px solid rgba(99,224,203,.45); border-radius: 0 4px 4px 0; overflow-wrap: anywhere; }
.equation sub { font-size: 9px; }
.science-block p, .science-block li { color: #91a9ae; font-size: 9px; line-height: 1.55; margin: 7px 0 0; }
.science-block ul { padding-left: 14px; margin: 4px 0 0; }
.science-block li { margin: 0 0 4px; }
.audit-values { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.audit-values div { background: rgba(255,255,255,.025); border-radius: 5px; padding: 7px; }
.audit-values span { display: block; color: #70878d; font: 7px var(--mono); letter-spacing: .06em; }
.audit-values strong { display: block; margin-top: 5px; color: #d9e9e8; font: 600 12px var(--mono); }
.audit-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; color: #71888e; font-size: 8px; }
.audit-foot strong { color: var(--accent); font: 600 11px var(--mono); }
.disclaimer { color: #c0d0d2 !important; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px !important; }
.number-key { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; color: #71888e; font-size: 8px; line-height: 1.5; }
.number-key b { color: #a8c0c3; font-weight: 650; }
.footer-line { display: flex; justify-content: space-between; gap: 12px; color: #4e666d; font: 7px var(--mono); letter-spacing: .1em; padding: 4px 2px 0; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 1080px) {
  .app-shell { padding-left: 20px; padding-right: 20px; }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(320px, 360px); gap: 14px; }
  .field-key { gap: 7px; }
  .science-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { min-height: 100vh; }
  .app-shell { padding: 0 13px 12px; }
  .topbar { height: 62px; }
  .brand-mark { width: 33px; height: 33px; border-radius: 9px; }
  h1 { font-size: 15px; }
  .topbar-meta { font-size: 7px; gap: 6px; }
  .meta-divider { margin: 0 1px; }
  .workspace { display: flex; flex-direction: column; gap: 10px; padding: 13px 0 10px; }
  .stage-column { width: 100%; flex: 0 0 auto; }
  .stage-head { align-items: start; flex-direction: column; gap: 7px; padding-bottom: 9px; }
  .stage-title { font-size: 13px; }
  .field-key { align-self: flex-start; }
  .canvas-wrap { height: clamp(275px, 42vh, 360px); min-height: 275px; border-radius: 10px; }
  .canvas-topline { left: 10px; right: 10px; top: 10px; }
  .canvas-label { font-size: 7px; }
  .caption-row { padding-top: 10px; min-height: 58px; gap: 9px; }
  .caption-copy p { font-size: 10px; }
  .caption-state { font-size: 7px; padding: 5px 6px; }
  .control-column { width: 100%; max-height: none; overflow: visible; padding: 0; display: grid; grid-template-columns: 1fr; gap: 9px; }
  .panel { padding: 12px; }
  .detection-panel { padding: 12px 13px 10px; }
  .science-wrap { padding-top: 0; }
  .science-panel summary { min-height: 42px; padding: 0 11px; gap: 8px; font-size: 8px; }
  .science-summary { display: none; }
  .science-content { padding: 12px; }
  .science-grid { grid-template-columns: 1fr 1fr; gap: 15px 12px; }
  .footer-line { display: none; }
}
@media (max-width: 420px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .topbar-meta { letter-spacing: .07em; }
  .topbar-meta span:last-child { display: none; }
  .topbar-meta .meta-divider { display: none; }
  .canvas-wrap { height: 290px; min-height: 270px; }
  .canvas-label-right { max-width: 118px; text-align: right; }
  .caption-state { display: none; }
  .science-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
/* Embed layout: the stage remains visible while the controls own their own scroll area. */
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app-shell { height: 100%; display: flex; flex-direction: column; }
body.embed-mode .topbar { flex: 0 0 72px; }
body.embed-mode .workspace { flex: 1 1 auto; min-height: 0; overflow: hidden; grid-template-rows: minmax(0, 1fr); }
body.embed-mode .stage-column { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
body.embed-mode .stage-head, body.embed-mode .caption-row { flex: 0 0 auto; }
body.embed-mode .canvas-wrap { flex: 1 1 auto; height: auto; min-height: 190px; }
body.embed-mode .control-column { height: 100%; max-height: none; min-height: 0; }
body.embed-mode .science-wrap { flex: 0 0 auto; }
body.embed-mode .footer-line { flex: 0 0 auto; }
body.embed-mode .science-content { max-height: 180px; overflow: auto; }
@media (max-width: 760px) {
  body.embed-mode .topbar { flex: 0 0 62px; }
  body.embed-mode .workspace { overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; }
  body.embed-mode .stage-column { height: auto; overflow: visible; display: block; flex: 0 0 auto; }
  body.embed-mode .canvas-wrap { flex: 0 0 auto; height: 290px; min-height: 270px; }
  body.embed-mode .control-column { height: auto; flex: 0 0 auto; }
  body.embed-mode .science-wrap { flex: 0 0 auto; }
  body.embed-mode .science-content { max-height: 260px; }
  body.embed-mode .footer-line { display: none; }
}
