/* ==================================================================
   BMW GARAGE — 视觉系统
   ================================================================== */
:root {
  --bg:        #07080a;
  --bg-2:      #0b0d10;
  --panel:     #0d0f13;
  --panel-2:   #111419;
  --line:      rgba(255, 255, 255, 0.075);
  --line-2:    rgba(255, 255, 255, 0.14);
  --text:      #e9ecef;
  --text-2:    #9aa3ad;
  --text-3:    #5f6873;
  --accent:    #1c69d4;
  --m-blue:    #0066b1;
  --m-navy:    #003070;   /* M 三色中间那条：深海军蓝，取自官方 M 涂装贴图 */
  --m-red:     #e22718;
  --radius:    10px;
  --font: "Inter", "Helvetica Neue", -apple-system, BlinkMacSystemFont,
          "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; }

/* ================= 加载层 ================= */
#loader {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 45%, #12161c 0%, #07080a 62%);
  transition: opacity .7s ease, visibility .7s;
}
#loader.is-done { opacity: 0; visibility: hidden; }
.loader-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.loader-logo { width: 62px; height: 62px; opacity: .95; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-bar { width: 190px; height: 2px; background: rgba(255,255,255,.1); overflow: hidden; border-radius: 2px; }
.loader-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--m-blue), var(--m-navy), var(--m-red)); animation: slide 1.15s ease-in-out infinite; transition: width .35s ease; }
.loader-text { min-width: 190px; text-align: center; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }
.loader-text { font-size: 11px; letter-spacing: .22em; color: var(--text-3); text-transform: uppercase; }

/* ================= 布局 ================= */
#app {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 330px;
  grid-template-rows: 66px minmax(0, 1fr);
  grid-template-areas:
    "top   top   top"
    "side  stage panel";
  height: 100vh;
  height: 100dvh;
}

/* ================= 顶栏 ================= */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 22px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0c0e12, #08090b);
  position: relative; z-index: 20;
}
/* 移动端菜单按钮（桌面隐藏） */
.menu-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-right: 4px;
  border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.menu-toggle svg { width: 18px; height: 18px; fill: var(--text-2); }
.menu-toggle:active { background: rgba(255,255,255,.09); }

.sidebar-close {
  display: none;
  width: 28px; height: 28px; margin-left: 6px;
  align-items: center; justify-content: center;
  border-radius: 6px;
}
.sidebar-close svg { width: 14px; height: 14px; fill: var(--text-3); }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  opacity: 0; pointer-events: none;
  transition: opacity .28s ease;
  z-index: 35;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-logo { width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-size: 13px; font-weight: 700; letter-spacing: .26em; }
.brand-sub { font-size: 10px; letter-spacing: .18em; color: var(--text-3); margin-top: 3px; }

.m-stripe {
  display: flex; gap: 2px; height: 18px; align-items: stretch;
  transform: skewX(-20deg);
  margin-left: 4px;
}
.m-stripe i { width: 5px; display: block; }
.m-stripe .m1 { background: var(--m-blue); }
.m-stripe .m2 { background: var(--m-navy); }
.m-stripe .m3 { background: var(--m-red); }

.topnav { margin-left: auto; display: flex; gap: 4px; }
.topnav-item {
  padding: 8px 15px; font-size: 12px; letter-spacing: .12em;
  color: var(--text-3); border-radius: 6px; transition: .2s;
}
.topnav-item:hover { color: var(--text-2); background: rgba(255,255,255,.04); }
.topnav-item.is-active { color: var(--text); background: rgba(255,255,255,.07); }

/* ================= 左侧车系 ================= */
.sidebar {
  grid-area: side;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px;
}
.sidebar-title { font-size: 11px; letter-spacing: .24em; color: var(--text-3); text-transform: uppercase; }
.sidebar-count {
  font-size: 10px; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 20px; padding: 2px 8px;
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 10px 16px; min-height: 0; }
.sidebar-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--line);
  font-size: 10.5px; color: var(--text-3); letter-spacing: .04em;
}
.sidebar-foot b { color: var(--text-2); font-weight: 600; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 8px #2ecc71; }

/* 分组 */
.group { margin-top: 6px; }
.group-head {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 10px; border-radius: 7px;
  transition: background .18s;
}
.group-head:hover { background: rgba(255,255,255,.035); }
.group-bar { width: 2px; height: 13px; border-radius: 2px; background: var(--line-2); }
.group.is-open .group-bar { background: linear-gradient(180deg, var(--m-blue), var(--m-navy), var(--m-red)); }
.group-name { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--text-2); }
.group.is-open .group-name { color: var(--text); }
.group-en { font-size: 9.5px; letter-spacing: .14em; color: var(--text-3); text-transform: uppercase; margin-left: auto; }
.group-chev { width: 12px; height: 12px; fill: var(--text-3); transition: transform .22s; }
.group.is-open .group-chev { transform: rotate(90deg); }

.group-body { overflow: hidden; max-height: 0; transition: max-height .32s cubic-bezier(.4,0,.2,1); }
.group.is-open .group-body { max-height: 900px; }

/* 车型条目 */
.series {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px 8px 21px; border-radius: 7px;
  text-align: left; transition: background .16s, color .16s;
  position: relative;
}
.series:hover { background: rgba(255,255,255,.045); }
.series-name { font-size: 12.5px; color: var(--text-2); letter-spacing: .02em; }
.series-code {
  font-size: 9.5px; color: var(--text-3); letter-spacing: .1em;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}
.series.is-soon { opacity: .42; cursor: not-allowed; }
.series.is-soon:hover { background: none; }
.series.is-live .series-name { color: var(--text); font-weight: 600; }
.series.is-live::before {
  content: ""; position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 9px var(--accent);
}
.series.is-live { background: rgba(28,105,212,.10); }
.series.is-selected { background: rgba(28,105,212,.20); box-shadow: inset 2px 0 0 var(--accent); }
.series.is-live:hover { background: rgba(28,105,212,.16); }
.series-badge {
  margin-left: auto; font-size: 8.5px; letter-spacing: .1em;
  color: var(--text-3); text-transform: uppercase;
}

/* 多底盘代号车系：名称行 + 缩进的变体行 */
.series-label {
  padding: 10px 10px 4px 21px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
  color: var(--text-2);
}
.series.is-variant { padding-left: 30px; }
.series.is-variant .series-name {
  font-size: 11.5px; letter-spacing: .08em; color: var(--text-2);
}
.series.is-variant.is-live .series-name { color: var(--text); }
.series-years {
  margin-left: auto; font-size: 9.5px; color: var(--text-3); letter-spacing: .04em;
}
.series.is-variant .series-badge { margin-left: auto; }

/* 舞台加载遮罩 */
#stageLoading {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(8px);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: rgba(13,15,19,.88);
  backdrop-filter: blur(14px);
  font-size: 11px; letter-spacing: .1em; color: var(--text-2);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  z-index: 8;
}
#stageLoading.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
#stageLoading .spin {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.18); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

/* ================= 3D 舞台 ================= */
.stage {
  grid-area: stage;
  position: relative;
  min-width: 0; min-height: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, #1a2029 0%, #0d1015 45%, #07080a 78%);
  overflow: hidden;
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 78% 70% at 50% 46%, transparent 40%, rgba(0,0,0,.55) 100%),
    linear-gradient(180deg, rgba(0,0,0,.35) 0%, transparent 18%, transparent 82%, rgba(0,0,0,.45) 100%);
}

.stage-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 26px 30px; pointer-events: none; z-index: 5;
}
.model-head { pointer-events: auto; }
.model-eyebrow { display: flex; gap: 7px; margin-bottom: 11px; }
.tag {
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px;
  background: rgba(28,105,212,.16); color: #7fb0f0; border: 1px solid rgba(28,105,212,.3);
}
.tag-ghost { background: rgba(255,255,255,.05); color: var(--text-3); border-color: var(--line); }
.model-name {
  font-size: 40px; font-weight: 300; letter-spacing: .04em; line-height: 1;
  background: linear-gradient(180deg, #ffffff 20%, #9aa3ad 130%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.model-sub { margin-top: 9px; font-size: 11.5px; letter-spacing: .1em; color: var(--text-3); }

.stage-tools { display: flex; gap: 8px; pointer-events: auto; }
.tool {
  display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(13,15,19,.72);
  backdrop-filter: blur(12px);
  font-size: 10.5px; letter-spacing: .12em; color: var(--text-2);
  transition: .18s;
}
.tool svg { width: 14px; height: 14px; fill: currentColor; }
.tool:hover { border-color: var(--line-2); color: var(--text); background: rgba(20,24,30,.9); }
.tool.is-on { border-color: rgba(28,105,212,.55); color: #8fbcf5; background: rgba(28,105,212,.14); }

.stage-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 30px; z-index: 5;
}
.view-tabs {
  display: flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 9px;
  background: rgba(13,15,19,.72); backdrop-filter: blur(12px);
}
.view-tabs button {
  padding: 6px 14px; font-size: 10.5px; letter-spacing: .1em;
  color: var(--text-3); border-radius: 6px; transition: .16s;
}
.view-tabs button:hover { color: var(--text-2); }
.view-tabs button.is-active { background: rgba(255,255,255,.09); color: var(--text); }
.hint { font-size: 10px; letter-spacing: .14em; color: var(--text-3); }

/* ================= 场景 / 车辆控制坞 ================= */
.dock {
  position: absolute;
  left: 50%; bottom: 66px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(11,13,16,.80);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 14px 44px rgba(0,0,0,.55);
  max-width: calc(100% - 28px);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.dock::-webkit-scrollbar { display: none; }
.dock-group { display: flex; align-items: center; gap: 2px; flex: none; }
.dock-group button {
  padding: 6px 11px; font-size: 10.5px; letter-spacing: .1em;
  color: var(--text-3); border-radius: 7px; transition: .16s;
  white-space: nowrap;
}
.dock-group button:hover:not(:disabled) { color: var(--text-2); background: rgba(255,255,255,.05); }
.dock-group button.is-active { background: rgba(255,255,255,.10); color: var(--text); }
.dock-sep { width: 1px; height: 18px; background: var(--line); flex: none; }
.dock-icons button { display: flex; align-items: center; gap: 5px; }
.dock-icons svg { width: 15px; height: 15px; fill: currentColor; flex: none; }
.dock-icons button.is-on { color: #ffd27a; background: rgba(255,190,80,.13); }
.dock-icons button.is-on svg { filter: drop-shadow(0 0 6px rgba(255,200,100,.75)); }
.dock-icons button:disabled { opacity: .26; cursor: not-allowed; }
.dock-steer { gap: 8px; padding: 0 4px; }
.dock-label { font-size: 10px; letter-spacing: .14em; color: var(--text-3); }
.dock-val { font-size: 10px; color: var(--text-2); min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
#steer {
  -webkit-appearance: none; appearance: none;
  width: 96px; height: 3px; border-radius: 2px;
  background: rgba(255,255,255,.14); outline: none; cursor: pointer;
}
#steer::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--bg-2); cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,255,255,.3);
}
#steer::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: var(--text);
  border: 2px solid var(--bg-2); cursor: pointer;
}
#steer:disabled { opacity: .3; cursor: not-allowed; }

/* ================= 右侧面板 ================= */
.panel {
  grid-area: panel;
  border-left: 1px solid var(--line);
  background: var(--bg-2);
  min-height: 0; display: flex; flex-direction: column;
}
.panel-scroll { flex: 1; overflow-y: auto; padding: 22px 22px 40px; min-height: 0; }

.block { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 15px; }
.block-head h2 { font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--text-2); }
.block-meta { font-size: 10.5px; color: var(--text-3); letter-spacing: .04em; }

/* 色板 */
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 11px; }
.swatch {
  position: relative; aspect-ratio: 1; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.16);
  transition: transform .18s, box-shadow .18s;
  box-shadow: inset 0 -6px 12px rgba(0,0,0,.45), inset 0 4px 8px rgba(255,255,255,.16);
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3.5px var(--accent), inset 0 -6px 12px rgba(0,0,0,.45); }
.swatch::after {
  content: attr(data-cn);
  position: absolute; left: 50%; bottom: -19px; transform: translateX(-50%);
  font-size: 8.5px; color: var(--text-3); white-space: nowrap;
  opacity: 0; transition: opacity .18s; pointer-events: none;
}
.swatch:hover::after { opacity: 1; }

/* 轮毂 */
.wheel-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.wheel-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(255,255,255,.02);
  font-size: 11px; color: var(--text-2); transition: .18s;
}
.wheel-opt:hover:not(:disabled) { border-color: var(--line-2); }
.wheel-opt.is-active { border-color: rgba(28,105,212,.5); background: rgba(28,105,212,.1); color: var(--text); }
.wheel-opt:disabled { opacity: .35; cursor: not-allowed; }
.wheel-dot {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--text-3); position: relative; flex: none;
}
.wheel-dot::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%;
  border: 1px solid var(--text-3);
}

/* 参数 */
.specs { display: flex; flex-direction: column; }
.specs > div {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px dashed rgba(255,255,255,.055);
}
.specs > div:last-child { border-bottom: 0; }
.specs dt { font-size: 11px; color: var(--text-3); letter-spacing: .04em; }
.specs dd { font-size: 12px; color: var(--text); font-weight: 500; letter-spacing: .02em; }
.specs dd em { font-style: normal; font-size: 9.5px; color: var(--text-3); margin-left: 2px; }

.block-note p { font-size: 10.5px; line-height: 1.85; color: var(--text-3); letter-spacing: .03em; }
.block-note p + p { margin-top: 10px; }
.block-note b { color: var(--text-2); font-weight: 600; }
.credit-line { font-size: 9.5px; color: #4b535c; letter-spacing: .04em; }

/* 滚动条 */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }

/* ================= 响应式 ================= */
@media (max-width: 1280px) {
  #app { grid-template-columns: 240px minmax(0,1fr) 300px; }
  .model-name { font-size: 34px; }
}
@media (max-width: 1024px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px minmax(0,1fr) auto;
    grid-template-areas: "top" "stage" "panel";
  }

  /* 侧边栏改为抽屉 */
  .sidebar {
    position: fixed;
    top: 56px; left: 0; bottom: 0;
    width: 288px; max-width: 84vw;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 0 48px rgba(0,0,0,.7);
    border-right: 1px solid var(--line-2);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { display: block; }
  .sidebar-backdrop.is-on { opacity: 1; pointer-events: auto; }
  .sidebar-close { display: flex; }
  .menu-toggle { display: flex; }

  .topbar { padding: 0 14px; gap: 10px; }
  .m-stripe { display: none; }
  .brand-logo { width: 28px; height: 28px; }
  .brand-title { font-size: 11px; letter-spacing: .2em; }
  .brand-sub { font-size: 9px; }
  .topnav-item { padding: 7px 10px; font-size: 11px; }

  .panel {
    border-left: 0; border-top: 1px solid var(--line);
    max-height: 36vh;
  }
  .panel-scroll { padding: 14px 16px 24px; }
  .block { padding-bottom: 16px; margin-bottom: 16px; }
  .block-head { margin-bottom: 11px; }

  /* 色板：手机上收紧成小圆点 */
  .swatches {
    grid-template-columns: repeat(8, 1fr);
    gap: 7px;
  }
  .swatch {
    width: 100%;
    max-width: 30px;
    justify-self: center;
    border-width: 1px;
  }
  .swatch.is-active {
    box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3px var(--accent), inset 0 -4px 8px rgba(0,0,0,.45);
  }
  .swatch::after { display: none; }

  .model-name { font-size: 28px; }
  .model-sub { font-size: 10.5px; }
  .stage-top { padding: 16px 16px; }
  .stage-bottom { padding: 14px 16px; }
  .view-tabs button { padding: 6px 10px; font-size: 10px; }
  .hint { display: none; }
  #stageLoading { bottom: 70px; }

  /* 控制坞：手机上贴底、自动换行 */
  .dock {
    bottom: 56px;
    left: 10px; right: 10px;
    transform: none;
    max-width: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 6px;
    padding: 5px 7px;
    overflow: visible;
  }
  .dock-sep { display: none; }
  .dock-group button { padding: 6px 9px; font-size: 10px; }
  .dock-icons button span { display: none; }
  .dock-icons svg { width: 16px; height: 16px; }
  .dock-steer { flex: 1 1 100%; justify-content: center; }
  .dock-label { display: none; }
  #steer { width: 120px; }
  .dock-val { min-width: 26px; }
}

@media (max-width: 480px) {
  .brand-text { display: none; }
  .topnav-item { padding: 6px 8px; font-size: 10.5px; }
  .model-name { font-size: 24px; }
  .stage-tools .tool span { display: none; }
  .stage-tools .tool { padding: 0 10px; }
  .panel { max-height: 40vh; }
  .swatches { grid-template-columns: repeat(8, 1fr); gap: 6px; }
  .swatch { max-width: 26px; }
  .specs > div { padding: 7px 0; }
  .specs dt { font-size: 10.5px; }
  .specs dd { font-size: 11.5px; }
}
