:root {
  --panel: rgba(13, 19, 30, 0.9);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9edf3;
  --muted: #9aa5b5;
  --orange: #f08a24;
  --orange-2: #ffb35c;
  --ok: #3fb950;
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05070d; color: var(--text); font: 14px/1.5 var(--font); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; }
.labels { position: absolute; inset: 0; }
.tag {
  padding: 2px 7px; border-radius: 4px; background: rgba(10, 14, 22, 0.78); border: 1px solid var(--line);
  font-size: 11px; color: var(--text); white-space: nowrap; pointer-events: none;
}
.tag-catcher { border-color: var(--orange); color: var(--orange-2); }

/* top bar */
#top {
  position: fixed; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px); z-index: 5;
}
.brand { font-weight: 800; letter-spacing: 0.04em; color: var(--text); text-decoration: none; font-size: 16px; }
.brand span { color: var(--orange); font-weight: 600; margin-left: 2px; }
.pages a { color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.pages a.on { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 5px 10px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--orange); color: #1a1006; font-weight: 700; }
.kpi { margin-left: auto; display: flex; gap: 14px; align-items: baseline; font-variant-numeric: tabular-nums; }
.kpi b { font-size: 18px; color: var(--orange-2); }
.kpi span { color: var(--muted); }

/* side panel */
#side {
  position: fixed; top: 70px; left: 10px; bottom: 46px; width: 340px; overflow-y: auto; z-index: 4;
  padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
#side h2 { margin: 2px 0 10px; font-size: 18px; }
body[data-mode="run"] .build-only, body[data-mode="build"] .run-only { display: none; }
.cta { width: 100%; padding: 9px; border: 0; border-radius: 8px; background: var(--orange); color: #1a1006; font-weight: 800; margin-bottom: 12px; }
.cta.ghost, button.ghost { background: none; border: 1px solid var(--orange); color: var(--orange-2); font-weight: 700; }
.row { display: flex; gap: 6px; }
.row button, .pairs button { flex: 1; padding: 6px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 7px; }
.row button:disabled { opacity: 0.35; cursor: default; }
.catch-head { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
#catchers { display: flex; gap: 4px; height: 46px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; }
.bar { width: 16px; height: 46px; background: rgba(255, 255, 255, 0.06); border-radius: 3px; position: relative; overflow: hidden; }
.bar i { position: absolute; left: 0; right: 0; bottom: 0; }
.kv { display: grid; gap: 3px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.kv div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 2px; }
.kv span { color: var(--muted); }
#controls label, .pairs { display: block; margin-bottom: 10px; }
#controls label b { float: right; color: var(--orange-2); }
#controls input[type=range] { width: 100%; accent-color: var(--orange); }
.pairs .row { margin-top: 6px; flex-wrap: wrap; }
.toggles { display: flex; gap: 14px; margin: 6px 0 10px; color: var(--muted); }
.toggles input { accent-color: var(--orange); }
.cams { margin-bottom: 12px; }

/* build guide */
.step-head { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.track { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; }
.track i { display: block; height: 100%; background: var(--orange); border-radius: 2px; transition: width 0.3s; }
.cost { color: var(--orange-2); font-weight: 700; font-size: 13px; margin: -4px 0 8px; }
#step-body p, #info-body p { margin: 0 0 8px; color: #cdd5df; }
.nav { margin: 12px 0; }
#step-list { margin: 14px 0 12px; padding-left: 20px; color: var(--muted); font-size: 12.5px; }
#step-list li { cursor: pointer; padding: 2px 0; }
#step-list li.done { color: #7f8b9b; }
#step-list li.on { color: var(--orange-2); font-weight: 700; }

/* info */
#info {
  position: fixed; top: 70px; right: 10px; width: 330px; max-height: calc(100% - 120px); overflow-y: auto; z-index: 4;
  padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
#info[hidden] { display: none; }
#info-close { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 22px; color: var(--muted); }
#info-kind { color: var(--orange-2); font-size: 12px; padding-right: 20px; }
#info h3 { margin: 2px 0 10px; font-size: 18px; }
.role { color: var(--orange-2) !important; }
#info-focus { width: 100%; padding: 7px; border-radius: 8px; margin-top: 4px; }

/* bill of materials */
.bom { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.bom summary { cursor: pointer; font-weight: 800; margin-bottom: 8px; }
.bom table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bom th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 3px 2px; }
.bom td { padding: 3px 2px; border-bottom: 1px dashed var(--line); }
.bom td:nth-child(n+2), .bom th:nth-child(n+2) { text-align: right; }
.bom tfoot td { color: var(--muted); }
.bom tr.grand td { color: var(--orange-2); font-weight: 800; font-size: 14px; border-bottom: 0; }
.note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* legend */
#legend {
  position: fixed; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; z-index: 4;
}
#legend i { display: inline-block; width: 18px; height: 6px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
#legend .hint { margin-left: auto; color: var(--muted); }

@media (max-width: 900px) {
  #side { width: auto; right: 10px; top: auto; bottom: 46px; max-height: 45%; }
  #info { left: 10px; right: 10px; width: auto; top: 110px; max-height: 40%; }
  .kpi { margin-left: 0; }
  #legend .hint { display: none; }
}
