:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #0d1a17;
  --panel-2: #101f1b;
  --line: rgba(176, 207, 190, .12);
  --line-strong: rgba(176, 207, 190, .22);
  --text: #edf5ee;
  --muted: #91a69a;
  --muted-2: #60756a;
  --accent: #b9f36a;
  --accent-soft: rgba(185, 243, 106, .13);
  --accent-line: rgba(185, 243, 106, .35);
  --radius: 18px;
  --grid: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; overflow-x: hidden; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; background: radial-gradient(ellipse at 35% 15%, rgba(28, 67, 50, .18), transparent 42%), var(--bg); }
body.embed-mode .app-shell { height: 100%; min-height: 0; padding: 14px 16px 16px; }
.topbar { min-height: 56px; display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.brand-mark { width: 34px; height: 34px; border: 1px solid var(--accent-line); border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: 3px; background: var(--accent-soft); transform: rotate(-5deg); }
.brand-mark span { width: 4px; border-radius: 5px; background: var(--accent); display: block; }
.brand-mark span:nth-child(1) { height: 10px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; opacity: .72; }
.brand-copy { display: flex; flex-direction: column; gap: 2px; }
.eyebrow, .panel-kicker, .stage-kicker, .status-label, .topbar-seed, .time-label, .control-count, .number-tag, .metric-origin, .panel-footer, .audit-heading, .canvas-corner { font-size: 9px; font-weight: 750; letter-spacing: .14em; color: var(--muted-2); }
.eyebrow { display: flex; align-items: center; gap: 8px; }
.eyebrow-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
h1 { font-size: 19px; line-height: 1.1; letter-spacing: -.035em; font-weight: 650; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 20px; }
.live-indicator { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .12em; }
.live-dot, .live-mini span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(185,243,106,.7); }
.live-dot.paused { background: #718278; box-shadow: none; }
.topbar-seed { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; }
.topbar-seed span { color: var(--muted); margin-left: 5px; letter-spacing: .08em; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 366px; gap: 14px; flex: 1 1 auto; min-height: 0; }
.stage-card, .control-panel { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(18, 34, 28, .96), rgba(10, 22, 18, .98)); box-shadow: 0 18px 55px rgba(0,0,0,.16); }
.stage-card { display: flex; flex-direction: column; overflow: hidden; }
.stage-head { padding: 17px 20px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.stage-kicker { color: var(--accent); }
.stage-subtitle { margin-top: 5px; font-size: 12px; color: var(--muted); }
.stage-actions { display: flex; align-items: center; gap: 9px; }
.time-chip { padding: 7px 10px; min-width: 88px; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 2px; background: rgba(255,255,255,.018); }
.time-label { font-size: 8px; }
.time-chip strong { font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 650; }
.icon-button { height: 36px; width: 38px; border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(255,255,255,.025); display: grid; place-items: center; cursor: pointer; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.icon-button:hover { border-color: var(--accent-line); background: var(--accent-soft); transform: translateY(-1px); }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.canvas-wrap { flex: 1 1 auto; min-height: 180px; position: relative; overflow: hidden; margin: 0 12px; border: 1px solid rgba(185,243,106,.08); border-radius: 14px; background: radial-gradient(ellipse at center, rgba(17, 43, 33, .56), rgba(5, 15, 13, .94) 72%); }
#simulationCanvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.canvas-corner { position: absolute; top: 13px; display: flex; align-items: center; gap: 7px; font-size: 8px; color: rgba(185, 207, 190, .54); pointer-events: none; }
.canvas-corner-left { left: 14px; }
.canvas-corner-right { right: 14px; }
.corner-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(185,243,106,.6); }
.canvas-bottom-note { position: absolute; bottom: 12px; left: 15px; display: flex; align-items: center; gap: 8px; color: rgba(195, 216, 199, .6); font-size: 9px; pointer-events: none; }
.canvas-bottom-note em { color: rgba(145,166,154,.5); font-style: normal; margin-left: 3px; }
.scale-line { display: inline-block; width: 32px; height: 4px; border: 1px solid rgba(185,243,106,.7); border-top: 0; }
.stage-foot { padding: 13px 20px 16px; display: grid; grid-template-columns: 124px minmax(0,1fr); gap: 18px; align-items: center; flex: 0 0 auto; }
.pattern-status { display: flex; flex-direction: column; gap: 4px; }
.status-label { font-size: 8px; }
.pattern-status strong { font-size: 11px; color: var(--accent); letter-spacing: .08em; }
#stateCaption { margin: 0; color: #a7b9ad; font-size: 11px; line-height: 1.5; max-width: 620px; }
.control-panel { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(185,243,106,.18) transparent; display: flex; flex-direction: column; }
.panel-section { padding: 17px 17px 15px; border-bottom: 1px solid var(--line); }
.panel-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.panel-kicker { font-size: 8px; color: var(--muted-2); }
h2 { margin: 5px 0 0; font-size: 16px; line-height: 1.15; letter-spacing: -.025em; font-weight: 620; }
.control-count { padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; font-size: 8px; white-space: nowrap; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 15px; }
.preset-button { min-width: 0; display: flex; align-items: center; gap: 9px; text-align: left; padding: 9px 9px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); cursor: pointer; transition: border-color .18s ease, background .18s ease; }
.preset-button:hover { border-color: var(--accent-line); }
.preset-button.active { border-color: var(--accent-line); background: var(--accent-soft); }
.preset-button strong { display: block; font-size: 10px; font-weight: 650; }
.preset-button small { display: block; margin-top: 3px; font-size: 8px; color: var(--muted); }
.preset-glyph { flex: 0 0 27px; height: 27px; border-radius: 8px; border: 1px solid rgba(185,243,106,.18); position: relative; background: rgba(185,243,106,.07); }
.branch-glyph::before, .branch-glyph::after { content: ""; position: absolute; left: 12px; top: 5px; width: 1px; height: 17px; background: var(--accent); transform: rotate(24deg); opacity: .8; }
.branch-glyph::after { top: 9px; left: 8px; width: 9px; height: 8px; border-top: 1px solid var(--accent); border-left: 1px solid var(--accent); background: none; transform: rotate(8deg); }
.compact-glyph::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(185,243,106,.45); }
.slider-block { margin: 0 0 13px; }
.slider-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slider-heading label { font-size: 10px; color: #c8d7cd; font-weight: 560; }
.symbol { color: var(--accent); font-style: italic; margin-left: 3px; }
.slider-heading output { font-size: 11px; color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.slider-heading output small { color: var(--muted); font-size: 9px; font-weight: 500; }
input[type="range"] { appearance: none; width: 100%; height: 16px; margin: 6px 0 0; background: transparent; cursor: pointer; display: block; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 999px; background: linear-gradient(90deg, var(--accent) 0%, rgba(185,243,106,.24) 100%); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 999px; background: linear-gradient(90deg, var(--accent) 0%, rgba(185,243,106,.24) 100%); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; margin-top: -4.5px; border: 2px solid #0c1712; background: var(--accent); box-shadow: 0 0 0 2px rgba(185,243,106,.28); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; border: 2px solid #0c1712; background: var(--accent); box-shadow: 0 0 0 2px rgba(185,243,106,.28); }
.slider-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted-2); font-size: 8px; margin-top: 1px; }
.number-tag { color: #687b6f; font-size: 7px; letter-spacing: .1em; }
.transport-row { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 7px; margin-top: 5px; }
.transport-button { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 9px; background: rgba(255,255,255,.025); color: #b7c6bb; display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 10px; font-weight: 600; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.transport-button:hover { border-color: var(--accent-line); background: rgba(185,243,106,.06); }
.transport-button.primary { background: var(--accent); color: #172014; border-color: var(--accent); }
.transport-button.primary:hover { background: #cafb83; }
.pause-icon { width: 8px; height: 10px; 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; margin-left: 2px; }
.step-icon { font-size: 19px; line-height: 10px; font-weight: 400; }
.reset-icon { font-size: 15px; line-height: 1; }
.quality-row { margin-top: 11px; display: flex; justify-content: space-between; align-items: center; color: var(--muted-2); font-size: 8px; letter-spacing: .12em; font-weight: 750; }
.quality-switch { display: flex; gap: 3px; padding: 3px; border-radius: 8px; background: rgba(0,0,0,.2); border: 1px solid var(--line); }
.quality-switch button { padding: 4px 9px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 8px; cursor: pointer; }
.quality-switch button.selected { color: var(--accent); background: var(--accent-soft); }
.readout-section { padding-top: 15px; padding-bottom: 13px; }
.readout-title { align-items: center; }
.live-mini { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 8px; font-weight: 750; letter-spacing: .1em; }
.live-mini span { width: 5px; height: 5px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
.metric-card { min-height: 64px; padding: 9px 10px 7px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.018); display: flex; flex-direction: column; gap: 4px; }
.metric-name { font-size: 9px; color: var(--muted); }
.metric-card strong { font-size: 17px; line-height: 1; font-weight: 640; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.metric-card strong small { font-size: 9px; color: var(--muted); font-weight: 500; }
.metric-origin { font-size: 7px; color: #64786c; letter-spacing: .12em; }
.threshold-note { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 8px; }
.threshold-note b { color: #c6d7ca; font-weight: 650; }
.threshold-note em { color: var(--muted-2); font-style: normal; }
.threshold-mark { width: 12px; height: 2px; background: var(--accent); opacity: .8; }
.science-panel { margin: 0 17px; border-bottom: 1px solid var(--line); }
.science-panel summary { list-style: none; cursor: pointer; padding: 14px 0; display: flex; justify-content: space-between; align-items: center; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary > span:first-child { display: flex; flex-direction: column; gap: 4px; }
.science-panel summary strong { font-size: 12px; font-weight: 620; }
.chevron { color: var(--accent); font-size: 18px; transition: transform .18s ease; }
.science-panel[open] .chevron { transform: rotate(180deg); }
.science-content { padding: 0 0 14px; }
.equation { display: grid; grid-template-columns: 1fr auto 60px; gap: 8px; align-items: center; padding: 7px 8px; margin-bottom: 5px; border-radius: 7px; background: rgba(255,255,255,.025); }
.equation span { color: var(--muted); font-size: 9px; }
.equation code { color: #d6e5d9; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; white-space: nowrap; }
.equation small { color: var(--muted-2); font-size: 7px; text-align: right; text-transform: uppercase; letter-spacing: .1em; }
.science-content p { color: #9eb0a3; font-size: 9px; line-height: 1.55; margin: 9px 0; }
.science-content p b { color: #c9d8cd; }
.science-content p em { color: #b9c9bc; }
.audit-box { margin-top: 10px; padding: 10px; border: 1px solid rgba(185,243,106,.17); border-radius: 9px; background: rgba(185,243,106,.045); }
.audit-heading { display: flex; justify-content: space-between; color: var(--accent); font-size: 7px; }
.audit-heading small { color: var(--muted-2); font-size: 7px; }
.audit-values { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 9px; }
.audit-values span { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 8px; }
.audit-values strong { color: #dce9de; font-size: 11px; font-variant-numeric: tabular-nums; }
.audit-difference { display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 7px; color: var(--muted); font-size: 8px; }
.audit-difference strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.disclaimer { color: #74877b !important; font-size: 8px !important; }
.panel-footer { margin-top: auto; padding: 11px 17px 13px; display: flex; justify-content: space-between; gap: 8px; font-size: 7px; color: #53675c; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 1000px) and (min-width: 761px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; }
  .panel-section { padding-left: 14px; padding-right: 14px; }
  .science-panel { margin-left: 14px; margin-right: 14px; }
}
@media (max-width: 760px) {
  .app-shell { padding: 10px; gap: 9px; min-height: 100vh; }
  body.embed-mode .app-shell { padding: 8px; gap: 8px; }
  .topbar { min-height: 43px; gap: 9px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  h1 { font-size: 16px; }
  .eyebrow { font-size: 7px; }
  .topbar-right { gap: 9px; }
  .topbar-seed { display: none; }
  .live-indicator { font-size: 8px; }
  .workspace { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(230px, 37dvh) minmax(0,1fr); gap: 8px; height: calc(100vh - 62px); height: calc(100dvh - 62px); flex: 1 1 auto; }
  body.embed-mode .workspace { height: calc(100% - 51px); grid-template-rows: minmax(230px, 37dvh) minmax(0,1fr); }
  .stage-card { border-radius: 14px; }
  .stage-head { padding: 10px 12px 8px; }
  .stage-kicker { font-size: 8px; }
  .stage-subtitle { font-size: 9px; margin-top: 3px; }
  .time-chip { padding: 5px 7px; min-width: 69px; }
  .time-label { font-size: 7px; }
  .time-chip strong { font-size: 11px; }
  .icon-button { height: 30px; width: 32px; }
  .canvas-wrap { margin: 0 7px; min-height: 130px; border-radius: 10px; }
  .canvas-corner { top: 8px; font-size: 7px; }
  .canvas-corner-left { left: 9px; }
  .canvas-corner-right { right: 9px; }
  .canvas-bottom-note { bottom: 7px; left: 9px; font-size: 7px; }
  .stage-foot { padding: 8px 12px 9px; grid-template-columns: 92px minmax(0,1fr); gap: 8px; }
  .status-label { font-size: 7px; }
  .pattern-status strong { font-size: 9px; }
  #stateCaption { font-size: 9px; line-height: 1.35; }
  .control-panel { border-radius: 14px; }
  .panel-section { padding: 12px 13px 11px; }
  .panel-kicker { font-size: 7px; }
  h2 { font-size: 14px; margin-top: 3px; }
  .control-count { font-size: 7px; }
  .preset-row { margin: 9px 0 10px; gap: 7px; }
  .preset-button { padding: 6px 7px; gap: 7px; border-radius: 9px; }
  .preset-glyph { flex-basis: 23px; height: 23px; }
  .branch-glyph::before { left: 10px; top: 4px; height: 14px; }
  .branch-glyph::after { left: 7px; top: 7px; }
  .compact-glyph::before { inset: 5px; }
  .preset-button strong { font-size: 9px; }
  .preset-button small { font-size: 7px; margin-top: 2px; }
  .slider-block { margin-bottom: 8px; }
  .slider-heading label { font-size: 9px; }
  .slider-heading output { font-size: 10px; }
  input[type="range"] { height: 14px; margin-top: 3px; }
  .slider-foot { font-size: 7px; }
  .number-tag { font-size: 6px; }
  .transport-row { margin-top: 3px; gap: 6px; }
  .transport-button { min-height: 30px; font-size: 9px; }
  .quality-row { margin-top: 7px; font-size: 7px; }
  .quality-switch button { padding: 3px 8px; }
  .readout-section { padding-top: 10px; padding-bottom: 9px; }
  .metric-grid { margin-top: 8px; gap: 6px; }
  .metric-card { min-height: 52px; padding: 6px 8px 5px; gap: 3px; }
  .metric-name { font-size: 8px; }
  .metric-card strong { font-size: 14px; }
  .metric-card strong small { font-size: 8px; }
  .metric-origin { font-size: 6px; }
  .threshold-note { margin-top: 7px; font-size: 7px; }
  .science-panel { margin: 0 13px; }
  .science-panel summary { padding: 10px 0; }
  .science-panel summary strong { font-size: 11px; }
  .science-content p { font-size: 8px; }
  .equation { padding: 6px; grid-template-columns: 1fr auto 48px; }
  .equation span, .equation code { font-size: 8px; }
  .panel-footer { padding: 8px 13px 9px; font-size: 6px; }
}
@media (max-width: 390px) {
  .workspace { grid-template-rows: minmax(220px, 35dvh) minmax(0,1fr); }
  body.embed-mode .workspace { grid-template-rows: minmax(220px, 35dvh) minmax(0,1fr); }
  .stage-subtitle { max-width: 180px; }
  .stage-foot { grid-template-columns: 84px minmax(0,1fr); }
  #stateCaption { font-size: 8px; }
  .slider-foot { letter-spacing: -.01em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
