:root {
  color-scheme: dark;
  --paper: #efe8d4;
  --paper-strong: #fff7de;
  --muted: #a9ac9f;
  --dim: #737a72;
  --panel: rgba(6, 10, 9, 0.76);
  --line: rgba(239, 232, 212, 0.18);
  --amber: #e2b656;
  --cyan: #69d5c7;
  --rust: #df795f;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background:
    linear-gradient(180deg, rgba(105, 213, 199, 0.06), transparent 34%),
    radial-gradient(circle at 52% 48%, rgba(239, 232, 212, 0.06), transparent 38%),
    #020303;
  color: var(--paper);
  font-family: Arial, "Segoe UI", sans-serif;
}
canvas { display: block; }
#field-canvas, #particle-canvas {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
}
#particle-canvas { pointer-events: none; }

.hud {
  position: fixed;
  z-index: 2;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(14px) saturate(1.1);
}
.hud-status { left: 18px; top: 18px; width: min(380px, calc(100vw - 36px)); padding: 16px; }
.hud-menu { right: 18px; top: 18px; width: min(280px, calc(100vw - 36px)); padding: 16px; }
.hud-legend { left: 18px; bottom: 168px; width: min(280px, calc(100vw - 36px)); padding: 12px 16px; }
.hud-timeline { left: 18px; right: 18px; bottom: 18px; padding: 12px 16px; }
.hud-enso {
  right: 18px;
  top: 250px;
  width: min(520px, calc(100vw - 36px));
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding: 14px 16px;
}

.brand-row, .timeline-top, .panel-title, .section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { color: var(--paper-strong); font-family: Georgia, serif; font-size: 22px; }
.strap, .dataset, .panel-title span, label span, #legend-name, .status-grid span, .label, .eyebrow {
  color: var(--muted); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
}
.strap { margin-top: 5px; color: var(--amber); }
.week-pill {
  min-width: 58px; border: 1px solid rgba(226, 182, 86, 0.5); padding: 7px 9px;
  color: var(--amber); text-align: center; font-family: Consolas, monospace;
}
.dataset { margin-top: 12px; color: #c1bea9; text-transform: none; }
.status-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 14px;
  border: 1px solid rgba(239, 232, 212, 0.14); background: rgba(239, 232, 212, 0.11);
}
.status-grid div { padding: 10px; background: rgba(4, 7, 6, 0.72); }
.status-grid strong, .summary-grid strong { display: block; margin-top: 4px; color: var(--paper-strong); font-size: 14px; }
.readout { margin-top: 12px; white-space: pre-wrap; font-family: Consolas, monospace; font-size: 12px; color: #d7d3c0; }
.mode-row { display: flex; gap: 8px; margin: 12px 0; }
button {
  background: rgba(239, 232, 212, 0.08); color: var(--paper); border: 1px solid var(--line);
  padding: 7px 10px; cursor: pointer; font: inherit;
}
button:hover { border-color: var(--amber); }
label { display: block; margin-top: 10px; }
input[type="range"] { width: 100%; }
.panel-note { margin-top: 12px; color: var(--dim); font-size: 11px; line-height: 1.4; }
.panel-note code { color: var(--cyan); }
.legend-values { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
#legend-canvas { width: 100%; height: 18px; margin-top: 8px; }
.timeline-rail { display: grid; gap: 6px; margin-top: 8px; }
.timeline-mark {
  min-width: 0; padding: 6px 4px; text-align: left;
}
.timeline-mark strong { display: block; font-size: 11px; }
.timeline-mark span { display: block; font-size: 10px; color: var(--muted); }
.timeline-mark.active { border-color: var(--amber); color: var(--amber); }
#time-label { font-family: Consolas, monospace; font-size: 12px; }
.chart-wrap { height: 220px; margin-top: 10px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
h2 { margin: 4px 0 0; font-size: 16px; font-weight: 600; }
.eyebrow { margin: 0; }
.loading {
  position: fixed; inset: 0; z-index: 3; display: grid; place-items: center;
  background: rgba(2, 3, 3, 0.55); letter-spacing: 0.12em; text-transform: uppercase;
}
.loading.hidden { display: none; }

@media (max-width: 980px) {
  .hud-enso { left: 18px; right: 18px; top: auto; bottom: 150px; max-height: 36vh; width: auto; }
  .hud-menu { top: auto; bottom: auto; display: none; }
  .hud-legend { bottom: auto; top: auto; display: none; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
