:root {
  color-scheme: dark;
  --bg: #0b111a;
  --panel: #111c29;
  --panel-2: #162434;
  --panel-3: #1b2b3d;
  --line: #26394d;
  --text: #e9f0f7;
  --muted: #91a4b8;
  --teal: #52d6c5;
  --blue: #69a9ff;
  --orange: #ffad66;
  --pink: #f27da8;
  --green: #83d69a;
  --red: #ff7e7e;
  --radius: 15px;
  font-family: 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; color: var(--text); background: radial-gradient(ellipse at 15% -10%, #1b3447 0, transparent 42%), var(--bg); min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px clamp(16px, 3vw, 42px); border-bottom: 1px solid rgba(145,164,184,.16); background: rgba(8,14,22,.84); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(140deg, #1d8f91, #244e75); box-shadow: 0 8px 24px rgba(43,180,171,.16); color: white; font-weight: 800; letter-spacing: -.08em; }
.brand-copy { min-width: 0; }
.brand-copy strong { display: block; font-size: 13px; letter-spacing: .13em; text-transform: uppercase; }
.brand-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.top-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.version-pill, .status-pill { padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; background: #101c29; white-space: nowrap; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 10px rgba(131,214,154,.6); }
.module-nav { display: flex; gap: 6px; padding: 11px clamp(16px, 3vw, 42px); overflow-x: auto; border-bottom: 1px solid rgba(145,164,184,.12); scrollbar-width: thin; background: rgba(12,20,30,.78); }
.module-nav a { white-space: nowrap; font-size: 11px; color: var(--muted); padding: 8px 11px; border: 1px solid transparent; border-radius: 9px; transition: .15s ease; }
.module-nav a:hover { color: var(--text); background: var(--panel); }
.module-nav a.active { color: var(--teal); background: rgba(82,214,197,.09); border-color: rgba(82,214,197,.24); }
.page-wrap { max-width: 1600px; margin: 0 auto; padding: 26px clamp(14px, 3vw, 42px) 46px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 4px 0 20px; }
.eyebrow { color: var(--teal); font-size: 10px; letter-spacing: .18em; font-weight: 800; text-transform: uppercase; margin-bottom: 8px; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 36px); letter-spacing: -.045em; line-height: 1.1; }
.page-heading p { max-width: 720px; margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.heading-code { color: #6f879d; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; white-space: nowrap; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px; background: rgba(17,28,41,.82); border: 1px solid var(--line); border-radius: 13px; margin-bottom: 16px; }
.toolbar-spacer { flex: 1; }
.btn { border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: #172637; padding: 8px 12px; font-size: 11px; font-weight: 700; transition: .15s ease; }
.btn:hover { border-color: #4e748f; background: #20364a; }
.btn.primary { color: #061b1c; background: var(--teal); border-color: var(--teal); }
.btn.primary:hover { background: #7de8da; }
.btn.soft { color: var(--muted); background: transparent; }
.btn.warn { color: #ffd1a8; border-color: rgba(255,173,102,.28); background: rgba(255,173,102,.07); }
.btn.small { padding: 6px 9px; font-size: 10px; }
.toolbar .tiny-status { color: var(--muted); font-size: 11px; margin: 0 5px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 16px; align-items: start; }
.main-stack { min-width: 0; display: grid; gap: 16px; }
.panel { min-width: 0; background: linear-gradient(180deg, rgba(20,33,48,.96), rgba(15,25,37,.96)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 38px rgba(0,0,0,.13); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-bottom: 1px solid rgba(145,164,184,.13); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 13px; letter-spacing: -.01em; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.panel-body { padding: 14px 16px 16px; }
.panel-kicker { color: var(--muted); text-transform: uppercase; letter-spacing: .13em; font-size: 9px; font-weight: 800; }
.canvas-wrap { position: relative; background: #07101a; border: 1px solid rgba(145,164,184,.12); border-radius: 11px; overflow: hidden; }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; }
.field-canvas { aspect-ratio: 1 / 1; max-height: 590px; image-rendering: pixelated; cursor: crosshair; }
.chart-canvas { width: 100%; height: 220px; }
.chart-canvas canvas { width: 100%; height: 100%; }
.canvas-caption { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; margin-top: 9px; }
.legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 9px; }
.metric { padding: 11px 12px; background: rgba(7,16,26,.52); border: 1px solid rgba(145,164,184,.13); border-radius: 11px; min-width: 0; }
.metric .label { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.metric strong { display: block; font-size: 20px; letter-spacing: -.04em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.metric small { display: block; margin-top: 2px; color: #6f879d; font-size: 9px; }
.controls-panel { position: sticky; top: 148px; }
.controls-panel .panel-body { padding: 14px; }
.control-row { margin-bottom: 17px; }
.control-row:last-child { margin-bottom: 0; }
.control-label { display: flex; justify-content: space-between; gap: 10px; color: #d8e3ed; font-size: 11px; margin-bottom: 7px; }
.control-label output { color: var(--teal); font: 11px ui-monospace, monospace; }
input[type="range"] { width: 100%; accent-color: var(--teal); cursor: pointer; }
select, input[type="number"], input[type="text"] { width: 100%; padding: 9px 10px; color: var(--text); background: #0b1724; border: 1px solid var(--line); border-radius: 8px; outline: none; font-size: 11px; }
select:focus, input:focus { border-color: var(--teal); }
.control-hint { color: #6f879d; font-size: 9px; line-height: 1.5; margin-top: 6px; }
.control-divider { height: 1px; background: rgba(145,164,184,.14); margin: 14px 0; }
.inline-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-controls label { color: var(--muted); font-size: 10px; }
.inline-controls select { width: auto; min-width: 110px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.field-and-profile { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(250px,.8fr); gap: 14px; }
.note { color: var(--muted); font-size: 10px; line-height: 1.6; }
.callout { padding: 11px 12px; border-left: 2px solid var(--teal); background: rgba(82,214,197,.06); border-radius: 0 9px 9px 0; color: #b9cbd8; font-size: 10px; line-height: 1.6; }
.code-equation { padding: 13px 14px; border: 1px solid rgba(82,214,197,.2); background: rgba(6,17,26,.75); border-radius: 10px; color: #c4f1e9; font: 12px/1.9 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; }
.term-list { display: grid; gap: 9px; }
.term-row { display: grid; grid-template-columns: 104px minmax(0,1fr) 72px; align-items: center; gap: 9px; font-size: 10px; }
.term-row .term-name { color: var(--muted); }
.term-bar { height: 8px; background: #0a1520; border-radius: 99px; overflow: hidden; }
.term-bar span { display: block; height: 100%; border-radius: inherit; }
.term-row strong { text-align: right; font: 10px ui-monospace, monospace; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th, td { padding: 9px 10px; border-bottom: 1px solid rgba(145,164,184,.12); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
td { color: #d5e0e9; font-variant-numeric: tabular-nums; }
.preset-card { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(7,16,26,.5); }
.preset-card h3 { margin: 0 0 5px; font-size: 12px; }
.preset-card p { margin: 0 0 10px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.scenario-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.scenario-card { border: 1px solid var(--line); background: rgba(7,16,26,.45); border-radius: 12px; overflow: hidden; }
.scenario-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 11px; border-bottom: 1px solid rgba(145,164,184,.12); }
.scenario-card header strong { font-size: 11px; }
.scenario-card canvas { display: block; width: 100%; aspect-ratio: 1.55 / 1; background: #07101a; }
.scenario-card footer { padding: 9px 11px; color: var(--muted); font-size: 9px; display: flex; justify-content: space-between; gap: 8px; }
.progress-track { height: 8px; border-radius: 99px; background: #07111b; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--teal)); border-radius: inherit; width: 0; transition: width .2s ease; }
.objective { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(145,164,184,.1); font-size: 10px; }
.objective:last-child { border-bottom: 0; }
.objective .state { color: var(--muted); }
.objective.done .state { color: var(--green); }
.badge { display: inline-block; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 9px; }
.badge.good { color: var(--green); border-color: rgba(131,214,154,.25); background: rgba(131,214,154,.07); }
.badge.warn { color: var(--orange); border-color: rgba(255,173,102,.25); background: rgba(255,173,102,.07); }
.footer { display: flex; justify-content: space-between; gap: 12px; padding: 20px 0 0; color: #647b91; font-size: 9px; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.center { text-align: center; }
.small-muted { color: var(--muted); font-size: 10px; }
.file-input { display: none; }
@media (max-width: 1060px) {
  .layout { grid-template-columns: minmax(0,1fr) 260px; }
  .field-and-profile { grid-template-columns: minmax(0,1fr); }
  .field-canvas { max-height: 520px; }
}
@media (max-width: 780px) {
  .topbar { position: static; }
  .layout { grid-template-columns: minmax(0,1fr); }
  .controls-panel { position: static; order: -1; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-code { text-align: left; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .two-col, .three-col { grid-template-columns: minmax(0,1fr); }
  .field-and-profile { grid-template-columns: minmax(0,1fr); }
  .toolbar-spacer { display: none; }
  .toolbar { gap: 6px; }
  .toolbar .tiny-status { margin-left: auto; }
}
@media (max-width: 480px) {
  .brand-copy span { display: none; }
  .top-meta .version-pill { display: none; }
  .scenario-grid { grid-template-columns: minmax(0,1fr); }
  .metric strong { font-size: 18px; }
  .panel-head { align-items: flex-start; }
  .btn { padding: 8px 9px; }
}
