:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182019;
  background: #eef1eb;
  font-synthesis: none;
  --accent: #2f7d47;
  --accent-soft: #dcebdd;
  --line: #cfd6cc;
  --muted: #667166;
  --panel: rgba(249, 250, 247, 0.96);
  --leaf: #4d9a55;
  --stem: #b18b35;
  --root: #815c47;
  --reproductive: #c16d38;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input, select { font: inherit; }
button, select { color: inherit; }

body {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) 158px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.9), transparent 32%),
    #eef1eb;
}

.toolbar {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 250, 247, .94);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand > span:last-child { display: grid; gap: 3px; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

.brand-mark {
  display: flex;
  align-items: end;
  width: 28px;
  height: 36px;
  gap: 3px;
}
.brand-mark i { display: block; width: 7px; border-radius: 2px 2px 0 0; background: var(--accent); }
.brand-mark i:nth-child(1) { height: 16px; opacity: .55; }
.brand-mark i:nth-child(2) { height: 28px; opacity: .78; }
.brand-mark i:nth-child(3) { height: 36px; }

.toolbar-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.field { display: grid; align-items: center; gap: 6px; }
.field > span { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.compact-field { grid-template-columns: auto 132px; }
.compact-field > span { grid-row: 1; }
.compact-field select { grid-row: 1; }

select, .outline-button, .simulator-button, .step-buttons button {
  height: 36px;
  border: 1px solid #c7cec4;
  border-radius: 7px;
  background: #fff;
}
select { padding: 0 30px 0 10px; cursor: pointer; }
.outline-button { padding: 0 13px; cursor: pointer; font-size: 12px; font-weight: 650; }
.simulator-button { padding: 0 14px; border-color: var(--accent); color: #fff; background: var(--accent); cursor: pointer; font-size: 11px; font-weight: 750; }
.simulator-button:hover { filter: brightness(.94); }
.outline-button:hover, .step-buttons button:hover { border-color: #929d91; background: #f6f8f3; }

.gdd-field {
  grid-template-columns: auto minmax(180px, 250px) 66px;
  gap: 9px;
}
.gdd-field > span { grid-row: 1; }
#gdd-slider { grid-row: 1; width: 100%; accent-color: var(--accent); cursor: pointer; }
#gdd-value { grid-row: 1; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.step-buttons { display: flex; gap: 4px; }
.step-buttons button { width: 36px; padding: 0; cursor: pointer; font-size: 18px; }
.step-buttons button:disabled { opacity: .35; cursor: default; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
.viewport { position: relative; min-width: 0; overflow: hidden; border-right: 1px solid var(--line); }
#scene { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }

.loading-card, .error-card {
  position: absolute;
  z-index: 5;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 11px 14px;
  border: 1px solid rgba(112, 125, 109, .35);
  border-radius: 8px;
  color: #465246;
  background: rgba(255,255,255,.9);
  box-shadow: 0 10px 40px rgba(38, 52, 39, .08);
  font-size: 12px;
}
.error-card { max-width: 420px; color: #8c3a31; text-align: center; }

.scene-heading { position: absolute; top: 22px; left: 24px; pointer-events: none; }
.scene-heading > span { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.scene-heading h1 { margin: 5px 0 3px; font-size: clamp(22px, 2.2vw, 34px); line-height: 1; letter-spacing: -.035em; }
.scene-heading p { margin: 0; color: var(--muted); font-size: 11px; }

.view-switcher {
  position: absolute;
  top: 22px;
  right: 22px;
  display: flex;
  padding: 3px;
  border: 1px solid rgba(118, 130, 115, .32);
  border-radius: 8px;
  background: rgba(249,250,247,.88);
  backdrop-filter: blur(12px);
}
.view-button { height: 31px; padding: 0 12px; border: 0; border-radius: 5px; color: #596459; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.view-button.active { color: white; background: var(--accent); }

.compare-toggle {
  position: absolute;
  top: 72px;
  right: 22px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(118,130,115,.28);
  border-radius: 7px;
  color: #4d594e;
  background: rgba(249,250,247,.86);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.compare-toggle input { position: absolute; opacity: 0; }
.compare-toggle > span { position: relative; width: 25px; height: 14px; border-radius: 20px; background: #bdc6ba; transition: .2s; }
.compare-toggle > span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: white; transition: .2s; }
.compare-toggle input:checked + span { background: #6684aa; }
.compare-toggle input:checked + span::after { transform: translateX(11px); }

.apar-legend, .feedback-key {
  position: absolute;
  left: 24px;
  bottom: 20px;
  width: 250px;
  padding: 10px 11px;
  border: 1px solid rgba(118,130,115,.3);
  border-radius: 7px;
  background: rgba(249,250,247,.9);
  backdrop-filter: blur(10px);
}
.apar-legend header, .apar-legend footer { display: flex; align-items: center; justify-content: space-between; }
.apar-legend header { font-size: 10px; }
.apar-legend header span { font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.apar-legend header strong { font-size: 10px; }
.apar-legend footer { margin-top: 4px; color: var(--muted); font-size: 8px; }
.legend-gradient { height: 8px; margin-top: 8px; border-radius: 20px; background: linear-gradient(90deg, #440154, #21918c, #fde725); }
.feedback-key { display: flex; width: auto; gap: 14px; color: #465046; font-size: 10px; font-weight: 700; }
.feedback-key span { display: flex; align-items: center; gap: 6px; }
.feedback-key i { display: block; width: 18px; height: 3px; }
.actual-swatch { background: var(--accent); }
.potential-swatch { border-top: 2px dashed #6684aa; }

.simulator-panel {
  position: absolute;
  z-index: 8;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: min(410px, calc(100% - 28px));
  overflow: auto;
  border: 1px solid rgba(111, 124, 108, .35);
  border-radius: 10px;
  background: rgba(249, 250, 247, .98);
  box-shadow: 0 22px 70px rgba(35, 48, 36, .18);
  backdrop-filter: blur(15px);
}
.simulator-panel > header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 16px 17px 13px; border-bottom: 1px solid var(--line); background: rgba(249,250,247,.97); }
.simulator-panel > header span { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.simulator-panel > header h2 { margin: 3px 0 0; font-size: 19px; letter-spacing: -.025em; }
.simulator-panel > header button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-size: 18px; }
.simulator-panel > p { margin: 12px 17px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.simulator-panel details { border-top: 1px solid var(--line); }
.simulator-panel summary { padding: 11px 17px; color: #344035; cursor: pointer; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 0 17px 14px; }
.input-grid label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 8px; color: #5f6b60; font-size: 9px; }
.input-grid input { grid-column: 1 / -1; width: 100%; height: 32px; padding: 0 8px; border: 1px solid #cbd3c8; border-radius: 6px; color: #263027; background: #fff; font-variant-numeric: tabular-nums; }
.input-grid label > span { color: #8a9389; font-size: 8px; }
.simulator-panel form > footer { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 17px; border-top: 1px solid var(--line); background: rgba(249,250,247,.98); }
#simulator-status { color: var(--muted); font-size: 9px; }
#run-simulator { height: 36px; padding: 0 14px; border: 0; border-radius: 7px; color: #fff; background: var(--accent); cursor: pointer; font-weight: 750; }
#run-simulator:disabled { opacity: .55; cursor: progress; }

.inspector { min-width: 0; overflow: auto; background: var(--panel); }
.inspector-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 20px 16px; border-bottom: 1px solid var(--line); }
.inspector-header span:first-child, .metric-section > header span, .scenario-note > span, .timeline-copy > span { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.inspector-header h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.025em; }
.status-pill { padding: 5px 8px; border: 1px solid #a7c8aa; border-radius: 20px; color: #286c3a; background: #edf7ed; font-size: 9px; font-weight: 750; text-transform: uppercase; }

.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); margin: 0; padding: 13px 12px; border-bottom: 1px solid var(--line); list-style: none; }
.pipeline li { position: relative; display: grid; justify-items: center; gap: 2px; color: #556055; text-align: center; }
.pipeline li:not(:last-child)::after { content: ""; position: absolute; top: 9px; left: calc(50% + 11px); width: calc(100% - 22px); border-top: 1px solid #b7c1b5; }
.pipeline li > span { z-index: 1; display: grid; width: 19px; height: 19px; place-items: center; border: 1px solid #91aa91; border-radius: 50%; color: white; background: var(--accent); font-size: 7px; }
.pipeline strong { margin-top: 3px; font-size: 8px; }
.pipeline small { color: #7b857a; font-size: 7px; }

.metric-section { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.metric-section > header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 11px; }
.metric-section > header small { color: #7b857a; font-size: 8px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-grid article { display: grid; gap: 3px; padding: 10px; border: 1px solid #d8ded5; border-radius: 7px; background: #fff; }
.metric-grid article > span { color: #697469; font-size: 9px; }
.metric-grid strong { font-size: 17px; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.metric-grid small { color: #889187; font-size: 8px; }

.allocation-bar { display: flex; height: 11px; overflow: hidden; border-radius: 20px; background: #e1e6df; }
.allocation-bar i { display: block; min-width: 0; transition: width .25s ease; }
.allocation-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 10px; }
.allocation-legend span { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 6px; color: #5c675c; font-size: 9px; }
.allocation-legend i { width: 8px; height: 8px; border-radius: 2px; }
.allocation-legend strong { color: #263027; font-size: 9px; font-variant-numeric: tabular-nums; }

.comparison-row { display: grid; grid-template-columns: 84px 1fr 84px; align-items: center; gap: 8px; margin-top: 9px; }
.comparison-row > div:first-child, .comparison-row > div:last-child { display: grid; gap: 2px; }
.comparison-row > div:last-child { text-align: right; }
.comparison-row span { color: #727d72; font-size: 8px; }
.comparison-row strong { font-size: 11px; font-variant-numeric: tabular-nums; }
.comparison-track { height: 5px; overflow: hidden; border-radius: 20px; background: #dce2d9; }
.comparison-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.state-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; margin: 14px 0 0; }
.state-list div { display: flex; justify-content: space-between; gap: 8px; padding-top: 7px; border-top: 1px solid #dde2da; }
.state-list dt { color: #697469; font-size: 8px; }
.state-list dd { margin: 0; font-size: 9px; font-weight: 750; font-variant-numeric: tabular-nums; }

.total-output-section { background: #f3f7f0; }
.organ-select-label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; font-weight: 700; }
.organ-select-label select { width: 100%; min-width: 0; height: 32px; font-size: 9px; }
.organ-state-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.organ-state-grid article { display: grid; gap: 3px; padding: 8px; border: 1px solid #dae0d7; border-radius: 6px; background: #fff; }
.organ-state-grid article > span { color: #748075; font-size: 8px; }
.organ-state-grid article > strong { font-size: 11px; font-variant-numeric: tabular-nums; }
.organ-state-grid .wide { grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: center; }
.organ-state-grid .wide > i { grid-column: 1 / -1; display: block; height: 5px; overflow: hidden; border-radius: 10px; background: #dce3da; }
.organ-state-grid .wide > i b { display: block; width: 0; height: 100%; border-radius: inherit; background: #4c91a8; transition: width .25s; }

.scenario-note { margin: 14px 18px 20px; padding: 11px; border-left: 3px solid #b6c8ae; background: #eef3ea; }
.scenario-note p { margin: 5px 0 0; color: #596459; font-size: 9px; line-height: 1.45; }

.timeline-panel { display: grid; grid-template-columns: 190px minmax(0, 1fr) 270px; align-items: stretch; border-top: 1px solid var(--line); background: #f8faf6; }
.timeline-copy { padding: 17px 20px; border-right: 1px solid var(--line); }
.timeline-copy h2 { margin: 4px 0 12px; font-size: 17px; letter-spacing: -.02em; }
.timeline-copy label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.timeline-copy select { width: 100%; height: 30px; font-size: 10px; text-transform: none; }
.timeline-chart-wrap { min-width: 0; padding: 10px 12px 5px; }
.timeline-chart { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: #dbe1d8; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.chart-area { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.chart-point { fill: #fff; stroke: var(--accent); stroke-width: 2; cursor: pointer; vector-effect: non-scaling-stroke; }
.chart-point.active { fill: var(--accent); stroke-width: 3; }
.chart-label { fill: #6e796e; font-size: 8px; }
.footer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; border-left: 1px solid var(--line); }
.footer-stats div { display: grid; align-content: center; justify-items: center; gap: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.footer-stats dt { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.footer-stats dd { margin: 0; font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }

[hidden] { display: none !important; }

@media (max-width: 1050px) {
  body { grid-template-rows: auto minmax(0, 1fr) 140px; }
  .toolbar { min-height: 72px; padding: 10px 14px; }
  .brand small { display: none; }
  .gdd-field { grid-template-columns: minmax(130px, 1fr) 62px; }
  .gdd-field > span { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr) 310px; }
  .pipeline small { display: none; }
  .timeline-panel { grid-template-columns: 165px minmax(0, 1fr) 220px; }
}

@media (max-width: 760px) {
  html, body { overflow: auto; }
  body { display: block; }
  .toolbar { position: sticky; top: 0; flex-wrap: wrap; }
  .toolbar-controls { width: 100%; flex-wrap: wrap; }
  .compact-field { flex: 1 1 150px; }
  .gdd-field { flex: 2 1 230px; }
  .workspace { display: block; }
  .viewport { height: 62vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .inspector { overflow: visible; }
  .timeline-panel { display: block; }
  .timeline-chart-wrap { height: 150px; }
  .footer-stats { min-height: 120px; border-top: 1px solid var(--line); }
}
