/* ============================================================
   Hanse 510 Configurator — UI
   ============================================================ */
:root {
  --bg: #0d1216;
  --bg-2: #131b21;
  --panel: rgba(16, 23, 28, .82);
  --line: rgba(255, 255, 255, .10);
  --line-2: rgba(255, 255, 255, .16);
  --fg: #eef3f6;
  --fg-dim: #93a3ad;
  --fg-mute: #67757e;
  --accent: #3fa9c9;
  --accent-2: #7fd4ea;
  --warn: #e0a33f;
  --r: 10px;
  --panel-w: 340px;
  --rail-w: 76px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.light {
  --bg: #eef2f4;
  --bg-2: #e3e9ec;
  --panel: rgba(252, 253, 254, .88);
  --line: rgba(10, 25, 35, .10);
  --line-2: rgba(10, 25, 35, .18);
  --fg: #10202a;
  --fg-dim: #52656f;
  --fg-mute: #7b8c95;
  --accent: #177e9c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 100%; height: 100%; display: block; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ------------------------------------------------------------- loader */
#loader {
  position: fixed; inset: 0; z-index: 90; display: grid; place-content: center;
  gap: 22px; justify-items: center; background: var(--bg);
  transition: opacity .7s var(--ease), visibility .7s;
}
#loader.gone { opacity: 0; visibility: hidden; }
#loader .mark { font-size: 40px; font-weight: 300; letter-spacing: .18em; }
#loader .mark span { color: var(--accent); font-weight: 600; }
#loader .bar { width: 210px; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
#loader .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#loader .pct { font-size: 11px; letter-spacing: .22em; color: var(--fg-mute); }

/* --------------------------------------------------------------- rail */
#rail {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail-w); z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 0; background: var(--panel); backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
}
.rail-btn {
  width: 58px; padding: 12px 4px; border-radius: var(--r); color: var(--fg-dim);
  display: grid; gap: 6px; justify-items: center;
  transition: background .28s var(--ease), color .28s var(--ease), transform .28s var(--ease);
}
.rail-btn:hover { color: var(--fg); background: rgba(255, 255, 255, .06); }
.rail-btn.on { color: var(--accent-2); background: rgba(63, 169, 201, .14); }
.rail-btn.on::before {
  content: ''; position: absolute; left: 0; width: 3px; height: 30px;
  background: var(--accent); border-radius: 0 3px 3px 0; transform: translateX(0);
}
.rail-btn { position: relative; }
.rail-ico { width: 24px; height: 24px; }
.rail-lbl { font-size: 10.5px; letter-spacing: .04em; }

/* -------------------------------------------------------------- panel */
#panel {
  position: fixed; left: var(--rail-w); top: 0; bottom: 0; width: var(--panel-w); z-index: 39;
  display: flex; flex-direction: column; background: var(--panel);
  backdrop-filter: blur(22px); border-right: 1px solid var(--line);
}
.panel-top {
  padding: 20px 20px 14px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.brand-mark { font-size: 10px; letter-spacing: .34em; color: var(--accent); font-weight: 600; }
.brand h1 { margin: 4px 0 0; font-size: 21px; font-weight: 300; letter-spacing: .01em; }
.build-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--fg-mute); letter-spacing: .1em; }
.dot-live { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

#panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 14px 20px; }
#panel-body::-webkit-scrollbar { width: 7px; }
#panel-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.grp-head { padding: 12px 6px 6px; }
.grp-title { margin: 0; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--fg-mute); font-weight: 500; }

/* option card */
.opt-card { border-bottom: 1px solid var(--line); }
.opt-row {
  display: flex; align-items: center; gap: 8px; padding: 13px 6px; cursor: pointer;
  transition: color .2s;
}
.opt-row:hover { color: var(--accent-2); }
.opt-name { flex: 1; font-size: 13.5px; font-weight: 450; }
.opt-val { font-size: 11px; color: var(--fg-mute); max-width: 120px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-tog { width: 15px; height: 15px; color: var(--fg-mute); transition: transform .3s var(--ease); }
.opt-card.open .opt-tog { transform: rotate(180deg); }
.opt-body { max-height: 0; overflow: hidden; transition: max-height .38s var(--ease); }

/* variant tabs */
.vtabs { display: flex; gap: 6px; padding: 2px 6px 12px; flex-wrap: wrap; }
.vtab {
  padding: 6px 13px; border-radius: 20px; font-size: 11.5px; color: var(--fg-dim);
  border: 1px solid var(--line); transition: all .25s var(--ease);
}
.vtab:hover { border-color: var(--line-2); color: var(--fg); }
.vtab.on { background: var(--accent); border-color: var(--accent); color: #04141a; font-weight: 500; }

/* swatch grid */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 7px; padding: 2px 6px 16px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 7px; padding: 2px 6px 16px; }

.chip {
  position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: rgba(255, 255, 255, .03); text-align: left; padding: 7px;
  transition: border-color .22s var(--ease), transform .22s var(--ease), background .22s;
  display: flex; flex-direction: column; gap: 6px;
}
.chip:hover { border-color: var(--line-2); transform: translateY(-1px); }
.chip.on { border-color: var(--accent); background: rgba(63, 169, 201, .13); }
.chip.warn { border-style: dashed; border-color: var(--warn); }
.dot { width: 100%; height: 30px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, .28); }
.chip-lbl { font-size: 10.5px; line-height: 1.25; color: var(--fg-dim); }
.chip.on .chip-lbl { color: var(--fg); }
.chip-note { font-size: 10px; color: var(--fg-mute); }
.chip-img { width: 100%; height: 54px; object-fit: cover; border-radius: 5px; background: var(--bg-2); }
.chip-text { padding: 10px; }
.chip-badge {
  position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--warn); color: #1a1204; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

/* panel footer */
.panel-foot { display: flex; gap: 8px; padding: 13px 16px; border-top: 1px solid var(--line); }
.btn { flex: 1; padding: 11px; border-radius: 8px; font-size: 12.5px; font-weight: 500; transition: all .25s var(--ease); }
.btn.ghost { border: 1px solid var(--line-2); color: var(--fg); }
.btn.ghost:hover { background: rgba(255, 255, 255, .07); }
.btn.solid { background: var(--accent); color: #04141a; }
.btn.solid:hover { background: var(--accent-2); }

/* ------------------------------------------------------------ toolbar */
#toolbar {
  position: fixed; right: 20px; top: 20px; z-index: 45; display: flex; flex-direction: column; gap: 7px;
}
#toolbar button {
  width: 40px; height: 40px; padding: 9px; border-radius: 9px; color: var(--fg-dim);
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(16px);
  transition: all .25s var(--ease);
}
#toolbar button:hover { color: var(--fg); border-color: var(--line-2); transform: translateY(-1px); }

.hint {
  position: fixed; left: calc(var(--rail-w) + var(--panel-w) + 20px); bottom: 18px; z-index: 30;
  font-size: 11px; color: var(--fg-mute); letter-spacing: .05em;
  transition: opacity .5s; opacity: 0;
}
body.loaded .hint { opacity: 1; }

/* ------------------------------------------------------------ summary */
#summary {
  position: fixed; right: 0; top: 0; bottom: 0; width: 330px; z-index: 60;
  background: var(--panel); backdrop-filter: blur(24px); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .42s var(--ease);
  display: flex; flex-direction: column;
}
body.show-summary #summary { transform: none; }
#summary header { display: flex; justify-content: space-between; align-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
#summary h3 { margin: 0; font-size: 15px; font-weight: 400; }
#summary header button { font-size: 15px; color: var(--fg-mute); }
#summary-body { overflow-y: auto; padding: 14px 18px 30px; }
.sum-sec { margin-bottom: 18px; }
.sum-sec h4 { margin: 0 0 8px; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.sum-k { color: var(--fg-mute); }
.sum-v { text-align: right; }

/* -------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 14px); z-index: 80;
  padding: 10px 20px; border-radius: 24px; background: var(--accent); color: #04141a;
  font-size: 12.5px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: all .34s var(--ease);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  #panel { width: 300px; }
  .hint { display: none; }
}
@media (max-width: 770px) {
  :root { --rail-w: 0px; }
  #rail {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 62px;
    flex-direction: row; justify-content: center; gap: 2px; border-right: 0; border-top: 1px solid var(--line);
  }
  .rail-btn { width: 74px; padding: 7px 4px; }
  .rail-btn.on::before { left: 50%; top: 0; width: 26px; height: 3px; transform: translateX(-50%); border-radius: 0 0 3px 3px; }
  #panel {
    left: 0; right: 0; width: auto; top: auto; bottom: 62px; height: 46vh;
    border-right: 0; border-top: 1px solid var(--line);
  }
  #summary { width: 100%; }
  #toolbar { top: 14px; right: 12px; flex-direction: row; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
