/* DREAMT.LIFE — oil explainer
   Industrial drawing-office palette: warm paper, ink, hazard yellow. */

:root {
  --bg: #12100e;
  --panel: #191714;
  --panel-2: #211e1a;
  --line: #35302a;
  --ink: #e8e2d6;
  --ink-dim: #a29a8c;
  --ink-faint: #6d675d;
  --accent: #d8a12a;
  --accent-2: #c9662a;
  --sea: #3a6a91;

  --g-subsurface: #8a6a3d;
  --g-gathering: #b4823c;
  --g-separation: #c8632f;
  --g-oil: #b6503a;
  --g-gas: #4f95b5;
  --g-water: #3d918a;
  --g-drilling: #8b7cb0;
  --g-utilities: #9a9a83;
  --g-safety: #cf5340;
  --g-marine: #6a7f9e;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
}

/* ------------------------------------------------------------ topbar -- */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  height: 34px;
}
.topbar .brand {
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.14em;
  font-weight: 700;
}
.nav { color: var(--ink-faint); display: flex; gap: 8px; flex-wrap: wrap; }
.nav a { color: var(--ink-dim); text-decoration: none; }
.nav a:hover { color: var(--ink); }
.nav a.current { color: var(--accent); }
.nav small { color: var(--ink-faint); }

/* --------------------------------------------------------- workspace -- */
.workspace {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr) 330px;
  height: calc(100% - 34px);
}

.panel {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); }
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); }

.panel-head { padding: 14px 14px 4px; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--ink-faint);
  letter-spacing: 0.18em;
  font-size: 9px;
}
h1 {
  margin: 0 0 8px;
  font-size: 19px;
  letter-spacing: 0.02em;
  color: var(--accent);
  font-weight: 600;
}
.lede { margin: 0; color: var(--ink-dim); line-height: 1.5; font-size: 11px; }

.panel-section { padding: 12px 14px; border-top: 1px solid var(--line); }
.panel-section.first { border-top: none; }
.panel-section h2 {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
  font-weight: 600;
  display: flex;
  gap: 6px;
  align-items: center;
}
.panel-section h2 span { color: var(--line); }
.panel-section h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.note { margin: 0 0 10px; color: var(--ink-faint); line-height: 1.45; font-size: 10px; }
.muted { color: var(--ink-faint); }

/* --------------------------------------------------------- controls -- */
.control { margin-bottom: 11px; }
.control-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.control-head label { color: var(--ink-dim); font-size: 10.5px; }
.control-head output { color: var(--accent); font-size: 10.5px; }
.control-help {
  margin: 4px 0 0;
  color: var(--ink-faint);
  font-size: 9.5px;
  line-height: 1.4;
  display: none;
}
.control:hover .control-help, .control:focus-within .control-help { display: block; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; background: var(--accent); border: none; cursor: pointer;
}

select, input[type="number"] {
  width: 100%;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 5px 6px;
  font-family: var(--mono);
  font-size: 11px;
}
select:focus, input:focus { outline: 1px solid var(--accent); }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--ink-dim);
  font-size: 10.5px;
}
.toggle-row input { accent-color: var(--accent); cursor: pointer; }
.toggle-row:hover { color: var(--ink); }

button {
  background: var(--panel-2);
  color: var(--ink-dim);
  border: 1px solid var(--line);
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
button:hover { color: var(--ink); border-color: var(--ink-faint); }
button.primary { color: var(--accent); border-color: #5a4520; }
button.primary:hover { background: #2a2113; }
button.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }

.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.button-row.tight { grid-template-columns: auto 1fr auto; margin-bottom: 10px; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
button.wide { width: 100%; }

.seed-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
.seed-row label { color: var(--ink-dim); font-size: 10.5px; }

/* ------------------------------------------------------------ stage -- */
.stage-wrap { position: relative; background: #9db4c4; overflow: hidden; }
#stage { display: block; width: 100%; height: 100%; }

.label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.scene-label {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  white-space: nowrap;
  font-size: 9px;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  background: rgba(18, 16, 14, 0.82);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left-width: 3px;
  cursor: pointer;
  font-family: var(--mono);
}
.scene-label:hover { background: rgba(18, 16, 14, 0.96); color: #fff; }
.scene-label.group-subsurface { border-left-color: var(--g-subsurface); }
.scene-label.group-gathering { border-left-color: var(--g-gathering); }
.scene-label.group-separation { border-left-color: var(--g-separation); }
.scene-label.group-oil { border-left-color: var(--g-oil); }
.scene-label.group-gas { border-left-color: var(--g-gas); }
.scene-label.group-water { border-left-color: var(--g-water); }
.scene-label.group-drilling { border-left-color: var(--g-drilling); }
.scene-label.group-utilities { border-left-color: var(--g-utilities); }
.scene-label.group-safety { border-left-color: var(--g-safety); }
.scene-label.group-marine { border-left-color: var(--g-marine); }

.viewpoints {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: calc(100% - 20px);
}
.viewpoints button {
  background: rgba(18, 16, 14, 0.78);
  font-size: 9.5px;
  padding: 4px 7px;
}

.hud {
  position: absolute;
  background: rgba(18, 16, 14, 0.8);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 4px 9px;
  font-size: 10px;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.hud .sep { color: var(--line); margin: 0 2px; }
.hud-bottom { left: 10px; bottom: 10px; }
.hud-hint { right: 10px; bottom: 10px; color: var(--ink-faint); }

.trip-banner {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(140, 44, 28, 0.92);
  border: 1px solid #e0704f;
  color: #ffe6dc;
  padding: 5px 10px;
  font-size: 10px;
  letter-spacing: 0.06em;
}
.build-status[hidden] { display: none; }
.build-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(18, 16, 14, 0.55);
  color: var(--accent);
  letter-spacing: 0.2em;
  font-size: 11px;
}

/* -------------------------------------------------------- explainer -- */
.stats { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
.stats dt { color: var(--ink-faint); font-size: 10px; }
.stats dd { margin: 0; color: var(--ink); font-size: 10px; text-align: right; }

.stage-list { display: flex; flex-direction: column; gap: 1px; }
.stage-group-head {
  margin: 9px 0 3px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stage-group-head::before {
  content: "";
  width: 7px; height: 7px;
  background: currentColor;
}
.stage-group-head:first-child { margin-top: 0; }

.stage-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-left: 3px solid var(--line);
  padding: 4px 6px;
  color: var(--ink-dim);
  font-size: 10.5px;
  line-height: 1.35;
}
.stage-item:hover { background: var(--panel-2); color: var(--ink); }
.stage-item.active { background: var(--panel-2); color: var(--accent); border-left-color: var(--accent); }
.stage-item .idx { color: var(--ink-faint); font-size: 9px; min-width: 16px; }
.stage-item .count { color: var(--ink-faint); font-size: 9px; margin-left: auto; }

.stage-detail h3 {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.stage-detail .tagline {
  margin: 0 0 8px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}
.stage-detail p { margin: 0 0 8px; line-height: 1.5; color: var(--ink-dim); font-size: 10.5px; }
.stage-detail p.why {
  border-left: 2px solid var(--line);
  padding-left: 8px;
  color: var(--ink-faint);
}
.stage-detail .spec-table {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.stage-detail .spec-table dt { color: var(--ink-faint); font-size: 9.5px; }
.stage-detail .spec-table dd { margin: 0; color: var(--ink); font-size: 9.5px; text-align: right; }
.stage-detail .flowline {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 9.5px;
  line-height: 1.5;
}
.stage-detail .flowline b { color: var(--ink-dim); font-weight: 500; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr) 270px; }
}

/* ------------------------------------------------------- module map -- */
.process-map {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 9, 8, 0.86);
  display: none;
  padding: 22px;
}
.process-map.open { display: block; }

.map-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
}
.map-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.map-head h2 { margin: 2px 0 4px; font-size: 17px; color: var(--accent); font-weight: 600; }
.map-sub-title { margin: 0; color: var(--ink-dim); font-size: 10.5px; }
.map-actions { display: flex; gap: 6px; }

.map-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 9.5px;
}
.map-legend i { display: inline-block; width: 18px; height: 0; vertical-align: middle; margin-right: 5px; }
.map-legend .k-flow { border-top: 1px solid var(--ink-dim); }
.map-legend .k-pair { border-top: 1px dashed var(--accent-2); }
.map-legend .k-absent { border-top: 1px dotted var(--ink-faint); }
.map-legend .map-hint { margin-left: auto; color: var(--ink-faint); }

.map-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; }
.map-scroll { overflow: auto; padding: 10px; }
.map-detail {
  overflow-y: auto;
  border-left: 1px solid var(--line);
  padding: 14px 16px;
  background: var(--panel-2);
}

.map-svg { display: block; }
.map-lane { fill: rgba(255, 255, 255, 0.014); }
.map-lane.alt { fill: rgba(255, 255, 255, 0.032); }
.map-lane-label {
  fill: var(--ink-faint);
  font: 8.5px var(--mono);
  letter-spacing: 0.16em;
}
.map-link { fill: none; stroke: #6d675d; stroke-width: 1.1; color: #6d675d; }
.map-pair { fill: none; stroke: var(--accent-2); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.5; }

.map-node { cursor: pointer; outline: none; }
.map-box { fill: var(--panel-2); stroke: var(--line); stroke-width: 1; }
.map-node:hover .map-box { fill: #2b2721; stroke: var(--ink-faint); }
.map-node.selected .map-box { fill: #33291a; stroke: var(--accent); }
.map-node:focus-visible .map-box { stroke: var(--accent); }
.map-node.absent { opacity: 0.34; }
.map-node.absent .map-box { stroke-dasharray: 3 3; }
.map-step { fill: var(--ink-faint); font: 8px var(--mono); letter-spacing: 0.12em; }
.map-title { fill: var(--ink); font: 11px var(--mono); }
.map-node.selected .map-title { fill: var(--accent); }
.map-sub { fill: var(--ink-faint); font: 8.5px var(--mono); }

.map-detail h3 { margin: 0 0 4px; font-size: 13px; color: var(--accent); font-weight: 600; }
.map-detail h4 {
  margin: 14px 0 6px;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  font-weight: 600;
}
.map-detail p { margin: 0 0 8px; font-size: 10.5px; line-height: 1.5; color: var(--ink-dim); }
.map-detail .tagline { font-size: 8.5px; letter-spacing: 0.14em; color: var(--ink-faint); }
.map-detail .io { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.map-detail .io-k {
  display: block;
  font-size: 8.5px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 3px;
}
.map-detail .io ul { margin: 0; padding-left: 14px; }
.map-detail .io li { font-size: 9.5px; line-height: 1.45; color: var(--ink-dim); }
.map-detail .contract {
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  margin-top: 10px;
  font-size: 10px;
}
.map-detail .options { margin: 0; padding: 0; list-style: none; }
.map-detail .options li {
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  font-size: 10px;
  line-height: 1.45;
  color: var(--ink-faint);
}
.map-detail .options li.current { border-left-color: var(--accent); background: var(--panel); }
.map-detail .options li b { color: var(--ink); font-weight: 500; }
.map-detail .options li em { color: var(--accent); font-style: normal; font-size: 9px; }
.map-detail .options li span { display: block; margin-top: 3px; }
.map-detail .swap { border-left: 2px solid var(--accent-2); padding-left: 8px; }
.map-detail .pairs { color: var(--ink-faint); font-size: 9.5px; }
.map-detail .units { color: var(--ink); font-size: 10px; }
.map-detail .code { color: var(--ink-faint); font-size: 9px; line-height: 1.6; }
.map-detail code { color: var(--ink-dim); }

@media (max-width: 1100px) {
  .map-body { grid-template-columns: minmax(0, 1fr) 300px; }
}

.map-zoom { display: inline-flex; gap: 0; margin-right: 8px; }
.map-zoom button { border-right-width: 0; }
.map-zoom button:last-child { border-right-width: 1px; }
.map-zoom button.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.map-scroll { overflow: auto; padding: 10px; }
