:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: rgba(13, 13, 15, 0.88);
  --panel-strong: rgba(9, 9, 11, 0.96);
  --line: rgba(241, 220, 176, 0.18);
  --text: #fbf7ee;
  --muted: #bdb4a7;
  --gold: #f2cd7b;
  --flame: #ff9d4f;
  --ember: #ff5b4a;
  --ash: #bbb7ad;
  --wind: #8bd9ff;
  --green: #9be0b2;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  background:
    linear-gradient(rgba(242, 205, 123, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 217, 255, 0.02) 1px, transparent 1px),
    radial-gradient(circle at 16% 14%, rgba(255, 157, 79, 0.12), transparent 30%),
    radial-gradient(circle at 84% 18%, rgba(139, 217, 255, 0.08), transparent 28%),
    radial-gradient(circle at 58% 86%, rgba(255, 91, 74, 0.09), transparent 34%),
    var(--bg);
  background-size: 44px 44px, 44px 44px, auto, auto, auto, auto;
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 34px 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.18em;
}

.brand { color: var(--text); font-weight: 900; text-decoration: none; }
.signal { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; text-align: right; }
.signal a { color: var(--muted); text-decoration: none; }
.signal a:hover { color: var(--gold); }

main {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding-bottom: 44px;
}

.hero { padding: 42px 0 32px; }

.eyebrow, .kicker {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 1040px;
  font-size: clamp(44px, 7.2vw, 96px);
  line-height: 0.92;
  letter-spacing: 0;
}

.lead {
  max-width: 920px;
  margin: 24px 0 0;
  color: #dfd6c8;
  font-size: 18px;
  line-height: 1.8;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.stage-panel, .control-panel, .legend, .doc-shell {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

.stage-panel, .control-panel, .doc-shell { border-radius: 8px; }

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.stage-note { margin: 0; color: var(--muted); line-height: 1.7; }

.status-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(242, 205, 123, 0.42);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.canvas-wrap {
  position: relative;
  margin: 0 18px 18px;
  overflow: hidden;
  border: 1px solid rgba(241, 220, 176, 0.16);
  border-radius: 6px;
  background: #020202;
  aspect-ratio: 1120 / 720;
}

canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

.hud, .first-hint {
  position: absolute;
  border: 1px solid rgba(251, 247, 238, 0.16);
  background: rgba(0, 0, 0, 0.48);
  color: rgba(251, 247, 238, 0.78);
  pointer-events: none;
}

.hud {
  top: 14px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.hud-left { left: 14px; }
.hud-right { right: 14px; }
.hud-bottom { right: 14px; bottom: 14px; top: auto; }

.first-hint {
  left: 14px;
  bottom: 14px;
  z-index: 2;
  width: min(440px, calc(100% - 28px));
  border-color: rgba(242, 205, 123, 0.25);
  border-radius: 7px;
  padding: 12px 40px 12px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: auto;
}

.first-hint strong { display: block; margin-bottom: 4px; color: var(--text); }

.first-hint button {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 26px;
  min-height: 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
}

.first-hint.is-hidden { display: none; }
.control-panel { padding: 14px; background: var(--panel-strong); }

.panel-block {
  padding: 16px 0;
  border-bottom: 1px solid rgba(251, 247, 238, 0.12);
}

.panel-block:first-child { padding-top: 4px; }
.panel-block:last-child { border-bottom: 0; }

button {
  min-height: 38px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid rgba(251, 247, 238, 0.16);
  border-radius: 6px;
  background: rgba(251, 247, 238, 0.055);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
}

button small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
}

button span {
  line-height: 1.1;
}

button:hover, button.is-active {
  border-color: rgba(242, 205, 123, 0.58);
  background: rgba(242, 205, 123, 0.14);
}

.button-grid, .segmented { display: grid; gap: 8px; }
.action-grid { grid-template-columns: repeat(3, 1fr); }
.lens-grid { grid-template-columns: repeat(4, 1fr); }

.ranges label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.ranges label:last-child { margin-bottom: 0; }
.ranges strong { color: var(--text); }
.ranges input { grid-column: 1 / -1; width: 100%; accent-color: var(--flame); }

.status-list dl { display: grid; gap: 8px; margin: 0; }

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(251, 247, 238, 0.08);
  padding-bottom: 7px;
}

.status-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.status-list dt small {
  color: rgba(251, 247, 238, 0.62);
  font-size: 10px;
  letter-spacing: 0;
}

.status-list dd {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.narrative-text, .report-text { margin: 0; color: var(--muted); line-height: 1.65; }

.report-text {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(251, 247, 238, 0.14);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 18px 0;
  border-radius: 8px;
  overflow: hidden;
}

.legend div {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px;
  color: var(--muted);
  line-height: 1.55;
  border-right: 1px solid rgba(251, 247, 238, 0.1);
}

.legend div:last-child { border-right: 0; }
.legend b { color: var(--text); }

.dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 50%;
}

.flame { background: var(--flame); }
.ember { background: var(--ember); }
.ash { background: var(--ash); }
.wind { background: var(--wind); }

.doc-shell { margin-top: 18px; padding: 24px; }
.doc-head p:last-child { max-width: 880px; color: var(--muted); line-height: 1.75; }
.doc-shell h2, .doc-card h3 { margin: 0; letter-spacing: 0; }
.doc-shell h2 { font-size: 28px; }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.doc-card {
  border: 1px solid rgba(251, 247, 238, 0.12);
  border-radius: 8px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.16);
}

.doc-card dl { display: grid; gap: 12px; margin: 16px 0 0; }
.doc-card dt { color: var(--text); font-weight: 900; margin-bottom: 4px; }
.doc-card dd { margin: 0; color: var(--muted); line-height: 1.65; }

.formula-card {
  border-color: rgba(255, 157, 79, 0.28);
  background: rgba(255, 157, 79, 0.055);
}

@media (max-width: 1080px) {
  .workbench { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: repeat(2, 1fr); }
  .control-panel { order: 2; }
}

@media (max-width: 720px) {
  .site-header { align-items: flex-start; flex-direction: column; padding-inline: 18px; }
  .signal { justify-content: flex-start; text-align: left; }
  main { width: min(100% - 22px, 1240px); }
  .hero { padding-top: 28px; }
  .lead { font-size: 16px; }
  .stage-head { align-items: flex-start; flex-direction: column; }
  .status-badge { display: inline-flex; margin-top: 4px; }
  .action-grid, .lens-grid, .legend, .doc-grid { grid-template-columns: 1fr; }
  .hud-left { max-width: calc(100% - 28px); }
  .hud-right { display: none; }
}
