:root {
  --bg: #0f1115;
  --bg2: #161a21;
  --card: #1b2029;
  --line: #2a313d;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #f08a24;
  --accent2: #ffb35c;
  --good: #4ade80;
  --warn: #facc15;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
}
a { color: var(--accent2); }
code { font-family: var(--mono); background: #232a35; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.5rem;
  background: rgba(15, 17, 21, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: .55rem; white-space: nowrap; }
.brand-badge {
  background: var(--accent); color: #111; font-weight: 800; font-size: .8rem;
  padding: 3px 7px; border-radius: 6px; letter-spacing: .05em;
}
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a {
  color: var(--muted); text-decoration: none; font-size: .9rem;
  padding: .35rem .65rem; border-radius: 8px;
}
.topbar nav a:hover { color: var(--text); background: var(--card); }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(320px, 1fr) 1.5fr; gap: 2rem; align-items: center;
  padding: 3rem 1.5rem 2rem; max-width: 1400px; margin: 0 auto;
}
.eyebrow { color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; margin: 0 0 .75rem; }
.hero h1 { font-size: clamp(2.2rem, 4.5vw, 3.6rem); letter-spacing: -.02em; }
.lede { color: var(--muted); font-size: 1.08rem; max-width: 52ch; }
.hero-actions { display: flex; gap: .75rem; margin: 1.5rem 0; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .7rem 1.2rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem;
  cursor: pointer; font-family: inherit; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #141414; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent2); }
.btn.small { padding: .45rem .8rem; font-size: .85rem; }
.btn.active { border-color: var(--accent); color: var(--accent2); }

.viewer-controls { display: flex; gap: 1.2rem; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.viewer-controls label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.viewer-controls select, .bolt-tools select, .bolt-tools input {
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem .6rem; font-family: inherit; font-size: .9rem;
}
input[type="checkbox"] { accent-color: var(--accent); }

.viewer {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #262d39 0%, #12151b 75%);
  border: 1px solid var(--line);
}
.viewer canvas { display: block; width: 100% !important; height: 100% !important; }
.car-viewer { height: min(62vh, 560px); min-height: 360px; }
.viewer-hint {
  position: absolute; left: 12px; bottom: 10px; z-index: 2; pointer-events: none;
  font-size: .78rem; color: var(--muted); background: rgba(0, 0, 0, .45); padding: 3px 9px; border-radius: 20px;
}
.viewer-label {
  position: absolute; z-index: 3; pointer-events: none; transform: translate(-50%, -130%);
  background: rgba(240, 138, 36, .95); color: #111; font-weight: 700; font-size: .78rem;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap; display: none;
}
.viewer-loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem;
}

.disclaimer {
  max-width: 1400px; margin: 0 auto 1rem; padding: .9rem 1.2rem; border-radius: var(--radius);
  background: rgba(250, 204, 21, .07); border: 1px solid rgba(250, 204, 21, .3); color: #e9dba0; font-size: .92rem;
  width: calc(100% - 3rem);
}

/* ---------- sections ---------- */
.section { max-width: 1400px; margin: 0 auto; padding: 3.5rem 1.5rem 1rem; }
.section-head { margin-bottom: 1.5rem; max-width: 80ch; }
.section-head h2 { font-size: 2rem; position: relative; padding-left: 14px; }
.section-head h2::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 5px; border-radius: 3px; background: var(--accent);
}
.section-head p { color: var(--muted); margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card h3 { font-size: 1.1rem; color: var(--accent2); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: .4rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-size: .88rem; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: linear-gradient(160deg, #222834, #1a1f27); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .v { font-size: 1.7rem; font-weight: 800; color: var(--text); }
.stat .v small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.stat .l { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; }

/* ---------- engine explorer ---------- */
.engine-layout { display: grid; grid-template-columns: 1fr 360px; gap: 1rem; }
.engine-viewer { height: 620px; }
.engine-panel { display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.control-block label { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); margin-bottom: .3rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.control-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.part-list { display: flex; flex-wrap: wrap; gap: .35rem; max-height: 170px; overflow: auto; padding-right: 4px; }
.part-chip {
  font-size: .78rem; padding: .3rem .6rem; border-radius: 20px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--muted); cursor: pointer; font-family: inherit;
}
.part-chip:hover, .part-chip.active { color: #111; background: var(--accent); border-color: var(--accent); }
.part-info { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; flex: 1; overflow: auto; max-height: 360px; }
.part-info h3 { color: var(--accent2); font-size: 1.15rem; }
.part-info p { font-size: .92rem; color: #c9ced8; }
.part-info ul { padding-left: 1.1rem; margin: .4rem 0; font-size: .88rem; color: #c9ced8; }
.part-info .tag { display: inline-block; font-size: .72rem; padding: 2px 7px; border-radius: 5px; background: #2b3340; color: var(--muted); margin: 0 .3rem .3rem 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--card); }
table.data th, table.data td { padding: .6rem .85rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #202632; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #212734; }
table.data td.num { font-family: var(--mono); white-space: nowrap; }
table.data td.torque { font-family: var(--mono); color: var(--accent2); font-weight: 700; white-space: nowrap; }
table.data td .note { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
table.data .group-row td { background: #252c38; color: var(--accent); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
table.compact th, table.compact td { padding: .4rem .7rem; }
.sock { display: inline-block; font-family: var(--mono); font-size: .82rem; background: #2d3542; padding: 1px 7px; border-radius: 5px; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab {
  padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); cursor: pointer; font-family: inherit; font-size: .9rem; font-weight: 600;
}
.tab.active { background: var(--accent); color: #111; border-color: var(--accent); }
.unit-toggle { margin-top: .6rem; color: var(--muted); font-size: .88rem; }

.bolt-tools { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.bolt-tools input { flex: 1; min-width: 220px; padding: .6rem .8rem; }
.sub-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; margin-top: 1.25rem; }
#head-seq svg { width: 100%; height: auto; }

/* ---------- wiring ---------- */
.wiring-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; }
.wiring-canvas { background: #f4f1e8; border-radius: var(--radius); border: 1px solid var(--line); overflow: auto; padding: .5rem; }
.wiring-canvas svg { width: 100%; height: auto; min-width: 700px; display: block; }
.wiring-canvas .wire { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; transition: stroke-width .1s, opacity .1s; }
.wiring-canvas .wire-outline { fill: none; stroke: #222; stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; }
.wiring-canvas svg.hovering .wgroup { opacity: .18; }
.wiring-canvas svg.hovering .wgroup.hot { opacity: 1; }
.wiring-canvas .wgroup { cursor: pointer; transition: opacity .12s; }
.wiring-canvas .wgroup.hot .wire { stroke-width: 6; }
.wiring-canvas .comp rect, .wiring-canvas .comp circle { fill: #fff; stroke: #222; stroke-width: 2; }
.wiring-canvas .comp text, .wiring-canvas text { font-family: var(--font); fill: #1d1d1d; }
.wiring-canvas .wlabel { font-family: var(--mono); font-size: 12px; font-weight: 700; paint-order: stroke; stroke: #f4f1e8; stroke-width: 4px; }
.wiring-side { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.wiring-side h3 { color: var(--accent2); }
.wiring-side h4 { margin-top: 1rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.wiring-side ul { padding-left: 1.1rem; font-size: .88rem; color: #c9ced8; }
.wiring-side li { margin-bottom: .35rem; }
.color-legend { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .6rem; font-size: .82rem; }
.color-legend span { display: flex; align-items: center; gap: .4rem; }
.color-legend i { width: 22px; height: 10px; border-radius: 3px; border: 1px solid #000; display: inline-block; }

/* ---------- teardown ---------- */
.progress { position: relative; height: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; margin-bottom: 1.2rem; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0; transition: width .3s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .82rem; font-weight: 700; }
.guide-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li {
  counter-increment: s; position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: .8rem 1rem .8rem 3.3rem; margin-bottom: .55rem; cursor: pointer; transition: border-color .15s, opacity .15s;
}
.steps li::before {
  content: counter(s); position: absolute; left: .8rem; top: .75rem; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: grid; place-items: center; background: #2b3340; font-weight: 800; font-size: .85rem;
}
.steps li:hover { border-color: var(--accent); }
.steps li.done { opacity: .55; }
.steps li.done::before { content: "✓"; background: var(--good); color: #0b2a14; }
.steps li strong { display: block; }
.steps li span { color: var(--muted); font-size: .88rem; }
.steps li .spec { color: var(--accent2); font-family: var(--mono); font-size: .82rem; }

.footer { border-top: 1px solid var(--line); margin-top: 4rem; padding: 2rem 1.5rem; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- responsive ---------- */
@media (max-width: 1050px) {
  .hero { grid-template-columns: 1fr; }
  .engine-layout, .wiring-layout, .sub-grid, .guide-cols { grid-template-columns: 1fr; }
  .engine-viewer { height: 480px; }
}
@media (max-width: 700px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar nav { justify-content: flex-start; }
}
