:root {
  color-scheme: dark;
  --bg: #080c13;
  --panel: rgba(13, 19, 29, 0.91);
  --panel-2: rgba(23, 31, 44, 0.72);
  --line: rgba(170, 191, 217, 0.13);
  --text: #edf2f7;
  --muted: #8d99aa;
  --faint: #5e6b7e;
  --accent: #ffd200;
  --cyan: #65d7ff;
  --danger: #ff776d;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.hidden { display: none !important; }

.app { height: 100%; display: grid; grid-template-rows: 76px minmax(0, 1fr) 78px; }
.topbar {
  display: flex; align-items: center; gap: 22px; padding: 0 22px;
  background: rgba(7, 11, 18, 0.96); border-bottom: 1px solid var(--line); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 13px; flex: 0 0 auto; }
.brand-mark {
  font-size: 23px; line-height: 1; font-weight: 950; font-style: italic; letter-spacing: -1.5px;
  color: #0b0e13; background: var(--accent); padding: 8px 10px 8px 12px; transform: skewX(-7deg);
}
.brand-copy { display: flex; flex-direction: column; gap: 3px; }
.brand-copy strong { font-size: 15px; letter-spacing: 2px; }
.brand-copy span { font-size: 8px; color: var(--muted); letter-spacing: 1.55px; }
.brand-select {
  flex: 0 0 auto; max-width: 190px; appearance: none; cursor: pointer;
  background: #101722 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%238d99aa'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--line); border-radius: 7px; color: var(--text);
  font-size: 12px; font-weight: 600; padding: 9px 26px 9px 12px;
}
.brand-select:hover { border-color: #54657b; }
.brand-select option { background: #101722; color: var(--text); }
.top-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.series-tabs { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.series-tabs::-webkit-scrollbar { display: none; }
.series-tab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 9px 11px;
  border-radius: 7px; transition: .2s ease; position: relative;
}
.series-tab strong { display: block; font-size: 14px; letter-spacing: .4px; }
.series-tab span { display: block; font-size: 9px; margin-top: 3px; color: var(--faint); white-space: nowrap; }
.series-tab:hover { color: var(--text); background: rgba(255,255,255,.045); }
.series-tab.active { color: var(--accent); background: rgba(255,210,0,.08); }
.series-tab.active::after { content: ""; position: absolute; height: 2px; left: 12px; right: 12px; bottom: -17px; background: var(--accent); }
.segmented { display: flex; padding: 3px; background: #101722; border: 1px solid var(--line); border-radius: 8px; }
.segmented button { border: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 7px 10px; cursor: pointer; border-radius: 5px; white-space: nowrap; }
.segmented button.active { color: #12171f; background: #dce6f2; font-weight: 650; }

.workspace { min-height: 0; display: grid; grid-template-columns: 278px minmax(0, 1fr) 302px; }
.panel { background: var(--panel); min-height: 0; z-index: 3; display: flex; flex-direction: column; }
.parts-panel { border-right: 1px solid var(--line); padding: 20px 14px 12px; }
.inspector-panel { border-left: 1px solid var(--line); overflow-y: auto; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 5px 15px; }
.eyebrow { display: block; font-size: 8px; letter-spacing: 2px; color: var(--cyan); margin-bottom: 4px; }
h2 { font-size: 17px; margin: 0; letter-spacing: 1px; }
.count-badge { min-width: 29px; text-align: center; padding: 4px 6px; border-radius: 5px; background: #1d2634; color: var(--muted); font-size: 11px; }
.search-box { display: flex; align-items: center; gap: 7px; padding: 0 10px; background: #0a1019; border: 1px solid var(--line); border-radius: 7px; color: var(--faint); }
.search-box input { width: 100%; border: 0; background: transparent; color: var(--text); padding: 9px 0; font-size: 12px; outline: none; }
.tree-actions { display: flex; justify-content: space-between; padding: 8px 4px 5px; }
.text-button { border: 0; background: none; color: var(--muted); padding: 3px; font-size: 10px; cursor: pointer; }
.text-button:hover { color: var(--cyan); }
.parts-tree { overflow-y: auto; min-height: 0; flex: 1; padding-right: 2px; }
.parts-tree::-webkit-scrollbar, .inspector-panel::-webkit-scrollbar { width: 5px; }
.parts-tree::-webkit-scrollbar-thumb, .inspector-panel::-webkit-scrollbar-thumb { background: #2a3648; border-radius: 8px; }
.tree-system { border-bottom: 1px solid rgba(170,191,217,.07); }
.tree-system summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 11px 5px; color: #c7d0dc; font-size: 12px; user-select: none; }
.tree-system summary::-webkit-details-marker { display: none; }
.tree-system summary::before { content: "+"; color: var(--faint); font-size: 14px; width: 10px; }
.tree-system[open] summary::before { content: "−"; }
.system-icon { color: var(--cyan); font-size: 15px; }
.system-name { flex: 1; }
.system-count { font-size: 9px; color: var(--faint); }
.tree-part { display: flex; align-items: center; margin: 1px 0 1px 15px; border-radius: 5px; }
.tree-part.selected { background: rgba(101,215,255,.1); }
.tree-part.is-hidden .part-name { opacity: .38; }
.part-name { flex: 1; text-align: left; border: 0; background: none; color: #98a5b6; font-size: 11px; padding: 7px 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-name:hover { color: var(--text); }
.tree-part.selected .part-name { color: var(--cyan); }
.part-eye { width: 27px; height: 27px; padding: 0; border: 0; background: none; color: #718096; cursor: pointer; font-size: 13px; }
.part-eye:hover { color: var(--accent); }
.part-eye.off { color: #3b4656; }
.panel-footnote { padding: 10px 4px 0; font-size: 9px; color: var(--faint); text-align: center; }
.empty-tree { text-align: center; color: var(--faint); padding: 28px 0; font-size: 12px; }

.viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #15202e; }
.webgl, .webgl canvas { width: 100%; height: 100%; display: block; }
.webgl canvas { cursor: grab; }
.webgl canvas:active { cursor: grabbing; }
.viewport-topline { position: absolute; left: 18px; right: 18px; top: 16px; display: flex; justify-content: space-between; pointer-events: none; }
.live-badge { font-size: 8px; letter-spacing: 1.4px; color: rgba(255,255,255,.74); background: rgba(7,12,20,.38); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; padding: 6px 10px; backdrop-filter: blur(8px); }
.live-badge i { display: inline-block; width: 5px; height: 5px; background: #78e5ad; border-radius: 50%; margin-right: 5px; box-shadow: 0 0 7px #78e5ad; }
.visible-count { color: rgba(255,255,255,.66); font-size: 9px; padding: 6px 0; text-shadow: 0 1px 4px #000; }
.model-caption { position: absolute; left: 23px; bottom: 51px; display: flex; flex-direction: column; pointer-events: none; text-shadow: 0 2px 16px rgba(0,0,0,.45); }
.model-caption > span:first-child { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 4px; }
.model-caption strong { font-size: clamp(42px, 5vw, 72px); line-height: .98; letter-spacing: -3px; font-style: italic; font-weight: 900; }
.model-caption > span:last-child { font-size: 11px; color: rgba(255,255,255,.72); letter-spacing: 2px; margin-top: 8px; }
.viewport-hint { position: absolute; bottom: 17px; left: 23px; display: flex; gap: 15px; color: rgba(255,255,255,.47); font-size: 9px; pointer-events: none; }
.viewport-hint span + span::before { content: "·"; margin-right: 15px; }
.selection-chip { position: absolute; right: 18px; bottom: 18px; max-width: 45%; padding: 8px 12px; border-radius: 7px; background: rgba(7,13,22,.7); border: 1px solid rgba(101,215,255,.32); backdrop-filter: blur(10px); color: var(--cyan); font-size: 11px; pointer-events: none; }
.webgl-error { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: #111a26; padding: 30px; }
.webgl-error p { color: var(--muted); font-size: 12px; }

.inspector { padding: 23px 20px 30px; }
.inspector-kicker { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.series-tag, .part-system-tag { color: var(--accent); background: rgba(255,210,0,.08); border: 1px solid rgba(255,210,0,.17); font-size: 9px; padding: 4px 7px; border-radius: 4px; letter-spacing: .5px; }
.part-system-tag { color: var(--cyan); background: rgba(101,215,255,.07); border-color: rgba(101,215,255,.18); }
.inspector-index { color: var(--faint); font-size: 9px; letter-spacing: 1px; }
.inspector h1 { margin: 0; font-size: 40px; font-style: italic; letter-spacing: -1.5px; line-height: 1; }
.inspector h1.part-title { font-size: 25px; font-style: normal; letter-spacing: 0; }
.inspector-subtitle { color: var(--muted); font-size: 11px; letter-spacing: 1px; margin-top: 8px; }
.inspector-desc { color: #9ca9b9; font-size: 11px; line-height: 1.85; margin: 18px 0; }
.spec-table { border-top: 1px solid var(--line); margin-top: 13px; }
.spec-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(170,191,217,.08); font-size: 10px; }
.spec-row span { color: var(--faint); flex: 0 0 auto; }
.spec-row strong { color: #c8d1dc; text-align: right; font-weight: 500; }
.section-title { display: flex; align-items: center; gap: 8px; color: #b7c1ce; font-size: 11px; letter-spacing: 1px; margin: 24px 0 12px; }
.section-title::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.color-swatch { border: 1px solid var(--line); background: #111925; border-radius: 7px; padding: 7px; cursor: pointer; text-align: left; transition: .18s; }
.color-swatch:hover { border-color: #54657b; }
.color-swatch.active { border-color: var(--accent); background: rgba(255,210,0,.06); }
.swatch-color { display: block; height: 25px; border-radius: 4px; margin-bottom: 6px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.swatch-name { display: block; font-size: 8px; color: #a6b1bf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paint-grid { display: flex; flex-direction: column; gap: 6px; }
.paint-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 9px;
  background: #111925; border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
}
.paint-row span { flex: 1; font-size: 10px; color: #a6b1bf; }
.paint-row input[type="color"] {
  width: 26px; height: 20px; padding: 0; border: 0; background: none; cursor: pointer;
}
.paint-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.paint-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; opacity: 0; }
.paint-row i { width: 26px; height: 20px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); pointer-events: none; margin-left: -36px; }
.paint-row:hover { border-color: #54657b; }
.wheel-grid { display: flex; flex-direction: column; gap: 6px; }
.wheel-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 9px;
  background: #111925; border: 1px solid var(--line); border-radius: 7px;
}
.wheel-row span { flex: 1; font-size: 10px; color: #a6b1bf; }
.wheel-row select {
  appearance: none; border: 1px solid #2a3648; border-radius: 5px;
  color: var(--text); font-size: 10px; padding: 5px 8px; cursor: pointer;
  background: #0d1420 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%238d99aa'/%3E%3C/svg%3E") no-repeat right 8px center;
  padding-right: 20px;
}
.wheel-row:hover { border-color: #54657b; }
.part-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 18px; }
.part-actions .button { font-size: 10px; padding: 9px 5px; }
.part-actions .wide { grid-column: 1 / -1; }
.back-link { border: 0; padding: 0; background: none; color: var(--muted); font-size: 10px; cursor: pointer; margin-bottom: 16px; }
.back-link:hover { color: var(--cyan); }

.controlbar { display: flex; align-items: center; gap: 28px; padding: 0 22px; background: #090e16; border-top: 1px solid var(--line); z-index: 5; }
.control-group { display: flex; align-items: center; gap: 7px; }
.control-label { color: var(--faint); font-size: 9px; letter-spacing: 1px; margin-right: 5px; }
.button { border: 1px solid #283446; border-radius: 6px; background: #131c28; color: #b8c3d1; font-size: 11px; padding: 8px 13px; cursor: pointer; transition: .18s; white-space: nowrap; }
.button:hover { border-color: #5a6d85; color: #fff; }
.button.primary { color: #161a1f; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.button.primary:hover { background: #ffe056; }
.explode-control { flex: 1; max-width: 470px; margin: 0 auto; }
.explode-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; margin-bottom: 8px; }
.explode-label output { color: var(--cyan); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 3px; display: block; appearance: none; background: linear-gradient(90deg, var(--cyan) var(--range, 0%), #263243 var(--range, 0%)); border-radius: 4px; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #e9f7ff; border: 3px solid var(--cyan); box-shadow: 0 0 0 3px rgba(101,215,255,.12); }
.toggle { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; cursor: pointer; white-space: nowrap; }
.toggle input { display: none; }
.toggle span { width: 27px; height: 15px; border-radius: 20px; background: #253142; position: relative; transition: .2s; }
.toggle span::after { content: ""; position: absolute; width: 9px; height: 9px; left: 3px; top: 3px; border-radius: 50%; background: #8996a7; transition: .2s; }
.toggle input:checked + span { background: #376c80; }
.toggle input:checked + span::after { transform: translateX(12px); background: var(--cyan); }

.loader { position: fixed; inset: 0; z-index: 100; background: radial-gradient(circle at 50% 42%, #152235 0, #080c13 55%); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity .6s, visibility .6s; }
.loader.done { opacity: 0; visibility: hidden; }
.loader-mark { color: var(--accent); font-size: 52px; font-weight: 950; font-style: italic; letter-spacing: -4px; }
.loader-title { margin: 16px 0 25px; font-size: 14px; letter-spacing: 5px; color: #d9e2ee; }
.loader-track { width: 260px; height: 2px; background: #263243; overflow: hidden; }
#loader-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--cyan)); transition: width .25s; }
#loader-text { margin-top: 13px; color: var(--muted); font-size: 10px; letter-spacing: 1px; }
.loader-note { position: absolute; bottom: 35px; color: #465366; font-size: 9px; letter-spacing: 1px; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 238px minmax(0, 1fr) 260px; }
  .brand-copy { display: none; }
  .series-tab { padding: 8px; }
  .series-tab span { display: none; }
  .series-tab.active::after { bottom: -23px; }
  .controlbar { gap: 15px; }
  .control-label { display: none; }
}
@media (max-width: 850px) {
  .app { grid-template-rows: 64px minmax(0, 1fr) 70px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand-mark { font-size: 18px; }
  .top-actions { display: none; }
  .workspace { grid-template-columns: 190px minmax(0, 1fr); }
  .inspector-panel { display: none; }
  .series-tabs { justify-content: flex-start; overflow-x: auto; }
  .series-tab strong { font-size: 12px; }
  .controlbar { padding: 0 12px; }
  .assembly-controls .button:not(.primary), .view-controls .toggle { display: none; }
  .button { padding: 7px 9px; }
  .model-caption strong { font-size: 42px; }
}

/* ---- 传动套件选择 ---- */
.gs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 8px; }
.gs-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 7px; border: 1px solid #2a3444; border-radius: 6px; background: #101724; color: var(--text); cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.gs-chip:hover { border-color: #54657b; }
.gs-chip.active { border-color: var(--accent); background: #16202f; }
.gs-chip strong { font-size: 9.5px; letter-spacing: .3px; }
.gs-chip span { font-size: 8px; color: #a6b1bf; }
.gs-info { font-size: 9.5px; line-height: 1.5; color: #c3cdda; padding: 8px 9px; border: 1px dashed #2c3848; border-radius: 6px; }
.gs-info strong { color: #fff; }
.gs-info span { color: #8d99a9; }

/* ---------- 车型入口（品牌 → 车型） ---------- */
.button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.button.ghost:hover { border-color: #54657b; background: rgba(255,255,255,.04); }

.entry {
  position: fixed; inset: 0; z-index: 40; display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: radial-gradient(1200px 620px at 78% -8%, rgba(101,215,255,.10), transparent 60%),
              radial-gradient(900px 520px at 10% 108%, rgba(255,210,0,.08), transparent 62%),
              rgba(6, 9, 14, 0.965);
  backdrop-filter: blur(10px);
  animation: entryIn .28s ease both;
}
@keyframes entryIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.entry-head {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px 30px 16px; border-bottom: 1px solid var(--line);
}
.entry-title { display: flex; align-items: center; gap: 16px; }
.entry-title h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
.entry-title p { margin: 5px 0 0; font-size: 11px; color: var(--muted); letter-spacing: .3px; }
.entry-tools { display: flex; align-items: center; gap: 10px; }
.entry-search { width: 250px; }
.entry-body { min-height: 0; display: grid; grid-template-columns: 208px minmax(0, 1fr); }

.entry-brands { border-right: 1px solid var(--line); padding: 16px 10px 24px; overflow: auto; }
.entry-brand-item {
  width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 10px 12px; border-radius: 9px; display: flex; flex-direction: column; gap: 3px;
  color: var(--muted); transition: .18s ease; position: relative;
}
.entry-brand-item strong { font-size: 13px; color: var(--text); letter-spacing: .3px; }
.entry-brand-item span { font-size: 10px; color: var(--faint); }
.entry-brand-item:hover { background: rgba(255,255,255,.045); }
.entry-brand-item.active { background: rgba(255,210,0,.10); }
.entry-brand-item.active strong { color: var(--accent); }
.entry-brand-item.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; background: var(--accent);
}
.entry-brand-count { position: absolute; right: 12px; top: 12px; font-size: 10px; color: var(--faint); }

.entry-models {
  overflow: auto; padding: 18px 24px 40px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; align-content: start;
}
.model-card {
  text-align: left; cursor: pointer; border: 1px solid var(--line); border-radius: 13px;
  background: linear-gradient(180deg, rgba(23,31,44,.72), rgba(13,19,29,.86));
  padding: 15px 16px 13px; display: flex; flex-direction: column; gap: 10px;
  transition: .18s ease; position: relative; overflow: hidden;
}
.model-card:hover { border-color: rgba(255,210,0,.55); transform: translateY(-2px); }
.model-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(255,210,0,.32) inset; }
.model-card .mc-tag {
  font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: #0d1117;
  background: var(--accent); padding: 3px 7px; border-radius: 4px; align-self: flex-start; font-weight: 700;
}
.model-card h3 { margin: 0; font-size: 17px; letter-spacing: .3px; }
.model-card .mc-sub { font-size: 10.5px; color: var(--muted); }
.model-card .mc-desc { font-size: 10.5px; color: var(--faint); line-height: 1.55; min-height: 32px; }
.mc-geo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; border-top: 1px solid var(--line); padding-top: 9px; }
.mc-geo div { display: flex; flex-direction: column; gap: 2px; }
.mc-geo b { font-size: 12.5px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.mc-geo span { font-size: 8.5px; color: var(--faint); letter-spacing: .4px; }
.mc-spec { display: flex; flex-wrap: wrap; gap: 5px; }
.mc-spec i { font-style: normal; font-size: 9.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
