:root {
  color-scheme: dark;
  --bg: #070809;
  --panel: rgba(12, 14, 15, 0.88);
  --panel-strong: rgba(8, 10, 11, 0.96);
  --line: rgba(210, 229, 225, 0.17);
  --text: #f4fbf8;
  --muted: #aebbb8;
  --ink: #d8fff3;
  --cyan: #80dcff;
  --gold: #f2cf83;
  --ghost: #8f9c9a;
  --erase: #ff8d7a;
}

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

body {
  background:
    linear-gradient(rgba(216, 255, 243, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(128, 220, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 16% 12%, rgba(216, 255, 243, 0.10), transparent 30%),
    radial-gradient(circle at 84% 16%, rgba(242, 207, 131, 0.08), transparent 28%),
    radial-gradient(circle at 58% 88%, rgba(128, 220, 255, 0.08), transparent 34%),
    var(--bg);
  background-size: 42px 42px, 42px 42px, 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; }
.signal { text-align: right; }

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(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 1080px;
  font-size: clamp(42px, 6.5vw, 88px);
  line-height: 0.94;
  letter-spacing: 0;
}

.lead {
  max-width: 920px;
  margin: 24px 0 0;
  color: #d0ddda;
  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(216, 255, 243, 0.42);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

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

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

.hud, .first-hint {
  position: absolute;
  border: 1px solid rgba(244, 251, 248, 0.16);
  background: rgba(0, 0, 0, 0.48);
  color: rgba(244, 251, 248, 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(455px, calc(100% - 28px));
  border-color: rgba(216, 255, 243, 0.24);
  border-radius: 7px;
  padding: 12px 40px 12px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
}

.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%;
  pointer-events: auto;
}

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

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

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

button {
  min-height: 38px;
  border: 1px solid rgba(244, 251, 248, 0.16);
  border-radius: 6px;
  background: rgba(244, 251, 248, 0.055);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
}

button span,
button small {
  display: block;
  line-height: 1.15;
}

button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

button:hover, button.is-active {
  border-color: rgba(216, 255, 243, 0.58);
  background: rgba(216, 255, 243, 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(--ink); }

.inline-ja {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.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(244, 251, 248, 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 {
  margin-left: 4px;
  color: rgba(244, 251, 248, 0.64);
  font-size: 10px;
  font-weight: 700;
  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(244, 251, 248, 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(244, 251, 248, 0.1);
}

.legend div:last-child { border-right: 0; }

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

.road { background: var(--ink); }
.ghost { background: var(--ghost); }
.crossing { background: var(--cyan); }
.erasure { background: var(--erase); }

.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(244, 251, 248, 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(128, 220, 255, 0.28);
  background: rgba(128, 220, 255, 0.045);
}

.lab-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.lab-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.lab-footer a {
  color: var(--ink);
  text-decoration: none;
}

.lab-footer a:hover {
  color: var(--text);
}

@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; }
  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; }
  .lab-footer {
    align-items: flex-start;
    flex-direction: column;
    width: min(100% - 22px, 1240px);
  }
  .lab-footer nav { justify-content: flex-start; }
}
