@layer reset, base, layout, components, responsive;
@layer reset {
  * { box-sizing:border-box; }
  body,h1,h2,h3,p,figure { margin:0; }
  button,input,select { font:inherit; }
  button { cursor:pointer; }
  button:disabled { cursor:not-allowed; }
  a { color:inherit; }
}
@layer base {
  :root { color-scheme:dark; --bg:#181818; --surface:#202020; --surface2:#292929; --line:#414141; --text:#e2e2e2; --muted:#a7a7a7; --mint:#bdd6c6; --gold:#e2cd92; --red:#e6a5a5; font:13px/1.45 ui-monospace,"SFMono-Regular",Consolas,monospace; }
  body { background:var(--bg); color:var(--text); min-width:280px; }
  ::selection { background:#646464; color:white; }
  :focus-visible { outline:2px solid var(--gold); outline-offset:3px; }
  button,input,select { -webkit-tap-highlight-color:transparent; }
  h1 { font-size:24px; line-height:1.3; font-weight:600; }
  h2 { font-size:17px; line-height:1.4; font-weight:600; }
  h3 { font-size:13px; line-height:1.4; font-weight:700; }
  button { background:none; color:inherit; border:0; }
  input,select { color:inherit; }
  .mono,.number { font-variant-numeric:tabular-nums; }
  .muted { color:var(--muted); }
  .positive { color:var(--mint); }
  .negative { color:var(--red); }
  .small { font-size:12px; }
  .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
  .skip-link { position:fixed; top:-100px; left:16px; z-index:100; background:var(--text); color:var(--bg); padding:10px; }
  .skip-link:focus { top:8px; }
}
@layer layout {
  .site-header { max-width:1240px; padding:6px 18px; margin:auto; display:flex; align-items:center; justify-content:space-between; gap:12px; border-bottom:1px solid var(--line); }
  .brand { display:inline-flex; align-items:center; gap:7px; text-decoration:none; font-weight:700; white-space:nowrap; }
  .brand::before { content:''; width:24px; height:24px; flex:none; background:url('./logo.svg?v=89b6e4b8da88') center / contain no-repeat; }
  .header-actions { display:flex; align-items:center; gap:6px; }
  .shell { max-width:1240px; margin:auto; padding:14px 18px 78px; }
  .welcome { max-width:940px; margin:auto; padding:30px 18px; }
  .welcome-copy .lede { max-width:78ch; margin:12px 0 8px; }
  .eyebrow { color:var(--muted); font-size:11px; margin-bottom:6px; }
  .setup { border-top:1px solid var(--line); padding-top:16px; margin-top:24px; }
  .section-top,.section-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:8px; }
  .lab-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  .setup-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-top:16px; }
  .setup-controls { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
  .campaign-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:10px; }
  .campaign-heading > div { display:flex; align-items:baseline; flex-wrap:wrap; gap:14px; }
  .campaign-heading h1 { font-size:20px; }
  .campaign-heading .context { color:var(--muted); }
  .metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); border-block:1px solid var(--line); margin-bottom:10px; }
  .metric { padding:8px 12px; border-left:1px solid var(--line); }
  .metric:first-child { border-left:0; padding-left:0; }
  .metric-label { display:block; color:var(--muted); font-size:11px; }
  .metric-value { font-size:20px; font-variant-numeric:tabular-nums; }
  .risk-values { display:block; font-size:13px; line-height:1.35; white-space:nowrap; }
  .metric-detail { display:block; font-size:11px; color:var(--muted); }
  .tab-bar { display:flex; gap:20px; margin-bottom:12px; border-bottom:1px solid var(--line); }
  .tab-bar button { padding:5px 2px; color:var(--muted); border-bottom:2px solid transparent; }
  .tab-bar button[aria-selected=true] { border-color:var(--text); color:var(--text); }
  .dashboard { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(300px,1fr); gap:22px; align-items:start; }
  .primary-column,.section { min-width:0; }
  .sidebar { display:grid; gap:16px; min-width:0; }
  .secondary-indicators { display:grid; grid-template-columns:1fr 1fr; gap:18px; }
  .footer-bar { position:fixed; bottom:0; inset-inline:0; border-top:1px solid var(--line); background:var(--bg); z-index:10; }
  .footer-inner { max-width:1240px; padding:8px 18px; margin:auto; display:flex; align-items:center; justify-content:space-between; gap:14px; }
  .footer-summary { display:flex; flex-wrap:wrap; gap:4px 18px; font-size:12px; color:var(--muted); }
  .footer-summary strong { color:var(--text); font-weight:400; }
  .decision { border:1px solid #666; padding:12px; margin-bottom:8px; }
  .decision h2 { margin-bottom:8px; }
  .decision-body { color:var(--text); }
  .choice-grid { display:grid; grid-template-columns:1fr; gap:6px; margin-top:12px; }
  .text-block p + p { margin-top:12px; }
  .loading-screen { padding:24px; }
}
@layer components {
  .button { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:32px; padding:5px 10px; border-radius:2px; background:var(--text); color:var(--bg); font-weight:600; font-size:12px; text-decoration:none; border:1px solid var(--text); }
  .button:hover { background:white; }
  .button.secondary { background:var(--surface); color:var(--text); border-color:var(--line); }
  .button.secondary:hover { background:var(--surface2); border-color:#888; }
  .button.ghost { min-height:28px; color:var(--muted); background:transparent; font-weight:400; border-color:transparent; padding:3px 6px; }
  .button.ghost:hover { color:var(--text); background:var(--surface2); }
  .button:disabled { opacity:.45; }
  .button[aria-pressed=true] { border-color:var(--text); color:var(--text); background:var(--surface2); }
  .lab-option { display:block; position:relative; }
  .lab-option input { position:absolute; inset:0; opacity:0; cursor:pointer; }
  .lab-card { display:block; min-height:80px; border:1px solid var(--line); border-radius:2px; padding:10px; }
  .lab-card strong { display:flex; justify-content:space-between; font-weight:600; }
  .lab-card small { display:block; color:var(--muted); font-size:11px; margin-top:5px; }
  .lab-option input:checked + .lab-card { border-color:var(--text); background:var(--surface2); }
  .lab-option input:focus-visible + .lab-card { outline:2px solid var(--gold); outline-offset:3px; }
  .lab-option input:checked + .lab-card strong::after { content:'✓'; }
  .seed-label { color:var(--muted); display:flex; align-items:center; gap:8px; font-size:12px; }
  .text-input { width:170px; border:1px solid var(--line); border-radius:2px; background:var(--surface); padding:5px 8px; min-height:32px; }
  .notice { border-left:2px solid var(--gold); padding:7px 10px; color:var(--text); background:var(--surface2); margin-bottom:10px; font-size:12px; }
  .notice.error { border-color:var(--red); color:var(--red); }
  .notice .button { margin-left:8px; }
  .save-indicator { color:var(--muted); font-size:11px; }
  .save-dot { display:inline-block; width:4px; height:4px; margin-right:5px; border-radius:50%; background:var(--mint); }
  .plan-presets { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:6px; }
  .plan-presets .button { min-height:28px; padding:3px 8px; font-size:11px; font-weight:400; }
  .allocation-row { display:grid; grid-template-columns:116px minmax(50px,1fr) 36px 27px; align-items:center; gap:8px; padding:4px 0; border-bottom:1px solid #303030; min-height:35px; }
  .allocation-row label { font-size:12px; }
  .allocation-value { text-align:right; font-size:12px; }
  .lock-button { border:1px solid var(--line); color:var(--muted); border-radius:2px; width:27px; height:27px; line-height:1; }
  .lock-button[aria-pressed=true] { color:var(--gold); border-color:var(--gold); }
  .allocation-row input { width:100%; height:24px; margin:0; cursor:pointer; accent-color:#ccc; -webkit-appearance:none; appearance:none; background:transparent; }
  .allocation-row input:disabled { opacity:.45; cursor:not-allowed; }
  .allocation-row input::-webkit-slider-runnable-track { height:4px; background:linear-gradient(to right,#bbb var(--fill),#444 var(--fill)); }
  .allocation-row input::-webkit-slider-thumb { -webkit-appearance:none; appearance:none; width:12px; height:16px; margin-top:-6px; background:var(--text); border:1px solid var(--bg); border-radius:2px; }
  .allocation-row input::-moz-range-track { height:4px; background:#444; }
  .allocation-row input::-moz-range-progress { height:4px; background:#bbb; }
  .allocation-row input::-moz-range-thumb { width:12px; height:16px; border:1px solid var(--bg); border-radius:2px; background:var(--text); }
  .plan-note { color:var(--muted); font-size:11px; margin-top:8px; }
  .allocation-help { border:0; padding-block:8px; }
  .allocation-help summary,.standing-plan summary { font-size:11px; color:var(--muted); }
  .allocation-help dl { margin:8px 0; font-size:12px; }
  .allocation-help dl > div { display:grid; grid-template-columns:116px 1fr; gap:8px; margin-top:6px; }
  .allocation-help dt { font-weight:600; }
  .allocation-help dd { margin:0; color:var(--muted); }
  .standing-plan { padding:6px 0; border:0; }
  .race-chart { --race-label-width:145px; --race-gap:10px; position:relative; margin-bottom:8px; }
  .race-row { display:grid; grid-template-columns:var(--race-label-width) minmax(20px,1fr); align-items:center; gap:var(--race-gap); margin:5px 0; }
  .race-label { display:flex; justify-content:space-between; align-items:center; gap:5px; font-size:11px; }
  .race-label strong { font-weight:400; }
  .race-label .mono { white-space:nowrap; }
  .race-track { height:5px; background:#333; }
  .race-fill { height:100%; background:#888; min-width:2px; }
  .race-row.player .race-fill { background:var(--text); }
  .race-row.player .race-label strong { font-weight:700; }
  .race-axis { position:relative; height:48px; margin-left:calc(var(--race-label-width) + var(--race-gap)); }
  .race-guides { position:absolute; z-index:1; top:12px; bottom:0; left:calc(var(--race-label-width) + var(--race-gap)); right:0; pointer-events:none; }
  .race-guide { position:absolute; top:0; bottom:0; border-left:1px dotted #aaa; transform:translateX(-1px); }
  .race-milestone { position:absolute; z-index:2; top:0; transform:translateX(-50%); min-width:28px; min-height:24px; padding:3px 2px; background:var(--bg); color:var(--muted); font-size:10px; line-height:18px; text-decoration:underline dotted; text-underline-offset:3px; }
  .race-milestone:hover,.race-milestone:focus-visible { color:var(--text); }
  .race-milestone-agi { top:24px; }
  .race-milestone-sar,.race-milestone-asi { transform:translateX(-100%); }
  .race-tooltip { position:fixed; z-index:1000; width:max-content; max-width:min(24rem,calc(100vw - 16px)); max-height:calc(100dvh - 16px); overflow:auto; padding:9px 11px; border:1px solid #777; background:var(--surface2); color:var(--text); font-size:12px; line-height:1.5; box-shadow:0 3px 12px #0005; }
  .race-tooltip[hidden] { display:none; }
  .research-list { display:grid; gap:6px; }
  .research-row { display:grid; grid-template-columns:1fr 50px 25px; align-items:center; gap:5px; font-size:11px; }
  progress { width:100%; height:4px; border:0; background:#333; }
  progress::-webkit-progress-bar { background:#333; }
  progress::-webkit-progress-value { background:#bbb; }
  progress::-moz-progress-bar { background:#bbb; }
  .status-pill { font-size:10px; color:var(--muted); text-align:right; }
  .treaty-status .section-heading { align-items:start; }
  .treaty-status h3 { font-size:12px; }
  .choice { display:flex; flex-direction:column; text-align:left; padding:8px 10px; border:1px solid var(--line); border-radius:2px; background:var(--surface); }
  .choice:hover:not(:disabled) { background:var(--surface2); border-color:#bbb; }
  .choice strong { font-size:12px; font-weight:600; margin-bottom:3px; }
  .choice-description { font-size:12px; color:var(--muted); }
  .choice-cost { font-size:11px; color:var(--gold); margin-top:3px; }
  .choice:disabled { opacity:.5; }
  .choice-unavailable { margin-top:3px; color:var(--red); font-size:11px; }
  .report { padding-top:10px; border-top:1px solid var(--line); margin-top:10px; }
  .report ul { padding-left:17px; margin:5px 0 0; color:var(--muted); font-size:12px; }
  .report li + li { margin-top:3px; }
  .research-cards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .research-card { padding:10px; border:1px solid var(--line); }
  .research-card p { color:var(--muted); margin-top:6px; font-size:12px; }
  .research-card progress { margin-top:8px; }
  .research-card .number { font-size:18px; float:right; margin-left:10px; }
  .history-list { list-style:none; padding:0; margin:0; }
  .history-list li { display:grid; grid-template-columns:75px 1fr; gap:14px; border-top:1px solid var(--line); padding:10px 0; }
  .history-list time { font-size:11px; color:var(--muted); }
  .history-list p { color:var(--muted); margin-top:4px; font-size:12px; }
  .empty-state { color:var(--muted); padding:15px 0; }
  details { border-top:1px solid var(--line); padding:10px 0; }
  summary { cursor:pointer; font-size:12px; }
  details p { color:var(--muted); font-size:12px; margin-top:8px; }
  .help-list { margin:12px 0; padding-left:22px; }
  .help-list li + li { margin-top:10px; }
  .ending-shell { max-width:1240px; padding:18px 18px 40px; margin:auto; }
  .ending-details.early { grid-template-columns:1fr; }
  .ending-heading { margin-bottom:16px; }
  .ending-heading h1 { font-size:26px; margin-bottom:8px; }
  .ending-heading p { max-width:95ch; color:var(--muted); }
  .cosmos-stage { position:relative; height:clamp(300px,45vw,540px); border:1px solid var(--line); overflow:hidden; background:#020807; }
  #cosmos-canvas { width:100%; height:100%; display:block; }
  .cosmos-caption { display:flex; flex-wrap:wrap; align-items:baseline; gap:3px 14px; margin-top:7px; }
  .cosmos-caption .number { font-size:13px; color:var(--text); }
  .cosmos-caption p { font-size:11px; color:var(--muted); }
  .cosmos-control-bar { display:flex; align-items:center; flex-wrap:wrap; gap:10px; padding:8px 0; }
  .cosmos-control-bar input { flex:1; min-width:60px; accent-color:#ccc; }
  .cosmos-control-bar .button { padding:4px 8px; }
  .ending-metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); margin:16px 0; border-block:1px solid var(--line); }
  .ending-metric { padding:12px; border-left:1px solid var(--line); }
  .ending-metric:first-child { padding-left:0; border-left:0; }
  .ending-metric .number { font-size:26px; display:block; }
  .ending-metric span:last-child { color:var(--muted); font-size:11px; }
  .ending-details { display:grid; grid-template-columns:1.2fr 1fr; gap:24px; }
  .cause-list { color:var(--muted); margin:8px 0 0; padding-left:18px; font-size:12px; }
  .cause-list li + li { margin-top:6px; }
  .milestones { margin-top:8px; }
  .milestone { display:flex; justify-content:space-between; gap:14px; border-top:1px solid var(--line); padding:6px 0; font-size:12px; }
  .milestone span:first-child { color:var(--muted); }
  .ending-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:20px; }
  .modal-backdrop { position:fixed; inset:0; z-index:30; background:#000a; display:flex; justify-content:center; align-items:center; padding:16px; }
  .modal { max-width:680px; width:100%; max-height:92vh; overflow:auto; background:var(--bg); border:1px solid #777; padding:16px; }
  .modal h2 { margin-bottom:10px; }
  .modal .close-row { display:flex; justify-content:end; margin-top:12px; }
  .footer-links { display:flex; flex-wrap:wrap; gap:16px; color:var(--muted); font-size:11px; margin-top:24px; }
  .footer-links a { text-underline-offset:3px; }
}
@layer responsive {
  @media (max-width:1000px) { .secondary-indicators { grid-template-columns:1fr; gap:12px; } }
  @media (max-width:720px) {
    .site-header { padding:6px 12px; gap:8px; } .header-actions { gap:0; } .header-actions .button { font-size:11px; padding-inline:5px; }
    .welcome { padding:20px 12px; } .lab-options { grid-template-columns:repeat(2,minmax(0,1fr)); } .lab-card { min-height:92px; }
    .shell { padding:12px 12px 100px; } .save-indicator { max-width:100px; text-align:right; font-size:10px; }
    .metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } .metric { padding:6px 10px; } .metric:nth-child(3) { border-left:0; padding-left:0; border-top:1px solid var(--line); } .metric:nth-child(4) { border-top:1px solid var(--line); }
    .dashboard { grid-template-columns:1fr; gap:16px; } .secondary-indicators { grid-template-columns:1fr 1fr; gap:14px; }
    .footer-inner { padding:8px 12px; gap:10px; } .footer-summary { font-size:11px; } .footer-inner > .button { flex-shrink:0; }
    .ending-shell { padding:12px; } .ending-details { grid-template-columns:1fr; gap:18px; }
    .ending-metric { padding:10px 7px; } .ending-metric .number { font-size:22px; }
  }
  @media (max-width:440px) {
    .risk-values { font-size:12px; }
    .race-chart { --race-label-width:110px; --race-gap:8px; }
    .race-label { font-size:10px; }
    .site-header { align-items:start; flex-direction:column; gap:2px; } .header-actions { width:100%; justify-content:space-between; }
    .allocation-row { grid-template-columns:102px minmax(45px,1fr) 31px 27px; gap:5px; } .allocation-row label { font-size:11px; }
    .secondary-indicators,.research-cards { grid-template-columns:1fr; }
    .footer-inner { align-items:stretch; flex-direction:column; gap:6px; } .footer-summary { justify-content:space-between; }
    .cosmos-control-bar > .small { display:none; } .ending-metric .number { font-size:20px; }
    .modal-backdrop { padding:8px; } .modal { padding:12px; }
  }
  @media (max-width:319px) { .ending-metric .number { font-size:17px; } }
  @media (pointer:coarse) { .button,.tab-bar button { min-height:40px; } .allocation-row { min-height:44px; } .lock-button { height:40px; } }
  @media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; } }
}
@layer components {
  .coordination-metric .metric-value { display:block; font-size:13px; margin-block:5px; }
  .cashflow-row { display:flex; justify-content:space-between; padding:4px 0; border-bottom:1px solid #303030; }
  .product-forecast > p { margin-top:6px; }
  .research-trials { margin-bottom:18px; }
  .trial-row { display:grid; grid-template-columns:1fr 130px 110px; align-items:center; gap:12px; border-top:1px solid var(--line); padding:6px 0; }
  .research-modal { max-width:810px; padding:8px; }
}
@layer responsive {
  @media (max-width:440px) { .trial-row { grid-template-columns:1fr 100px; gap:4px 10px; } .trial-row > .small { grid-row:2; } .trial-row .button { grid-row:1 / 3; grid-column:2; } }
}
