:root {
  --bg: #070b12;
  --bg2: #0d1522;
  --panel: rgba(13, 20, 32, 0.78);
  --panel-solid: #0e1624;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #e6edf6;
  --muted: #8b9bb0;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --radius: 14px;
  --top: 64px;
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(1200px 700px at 50% 55%, #102038 0%, var(--bg) 70%) fixed, var(--bg);
  font-size: 14px;
  line-height: 1.5;
}
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ── top bar ───────────────────────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 20;
  display: flex; align-items: center; gap: 20px; padding: 0 18px;
  background: linear-gradient(to bottom, rgba(7, 11, 18, 0.95), rgba(7, 11, 18, 0.6));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.car-tabs {
  display: flex; gap: 4px; margin: 0 auto; padding: 4px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 999px;
}
.car-tab {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px;
  color: var(--muted); font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 8px;
  transition: background 0.2s, color 0.2s;
}
.car-tab:hover { color: var(--text); }
.car-tab.active { background: var(--text); color: #0b1220; }
.flag {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; padding: 1px 5px; border-radius: 4px;
  border: 1px solid currentColor; opacity: 0.7;
}
.btn-compare {
  border: 1px solid var(--line-strong); background: transparent; padding: 7px 14px; border-radius: 999px; font-weight: 600;
}
.btn-compare:hover { border-color: var(--accent); color: var(--accent); }

/* ── stage ─────────────────────────────── */
.stage { position: fixed; inset: var(--top) 0 0 0; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; outline: none; touch-action: none; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }
.dim-label {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #bae6fd; white-space: nowrap;
  background: rgba(8, 47, 73, 0.75); border: 1px solid rgba(125, 211, 252, 0.4); padding: 2px 7px; border-radius: 6px;
}
body:not(.dims-on) .dim-label { display: none !important; }

/* ── panels ────────────────────────────── */
.panel {
  position: absolute; top: 14px; bottom: 86px; z-index: 10;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); overflow: auto; scrollbar-width: thin; scrollbar-color: #26344a transparent;
}
.panel.left { left: 14px; width: 248px; padding: 14px 10px; display: flex; flex-direction: column; gap: 14px; }
.panel.right { right: 14px; width: 360px; padding: 22px 22px 16px; }
.panel h4 {
  margin: 0 6px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 600;
}
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; display: inline-block; box-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent); }
.layer-row {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; cursor: pointer; user-select: none;
}
.layer-row:hover { background: rgba(255, 255, 255, 0.04); }
.layer-row input { accent-color: var(--accent); margin: 0; }
.layer-name { flex: 1; }
.count { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.parts-section { min-height: 0; }
.part-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 7px 8px; border-radius: 8px; color: #c8d3e1; font-size: 13px;
}
.part-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.part-item.active { background: rgba(56, 189, 248, 0.14); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }

/* info */
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); font-weight: 600; }
#info h2 { margin: 4px 0 2px; font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; }
#info h3 { margin: 22px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
#info p { margin: 0 0 8px; color: #c8d3e1; }
.variant { color: var(--muted); font-size: 13px; }
.badge {
  display: inline-block; margin: 12px 0 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: #bbf7d0; background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.3);
}
.lede { font-size: 14.5px; color: #d5deea !important; margin-top: 10px !important; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .v span { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.stat .s { font-size: 11px; color: var(--muted); }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
dt { color: var(--muted); font-size: 12.5px; }
dd { margin: 0; font-size: 13px; color: #dbe4ef; }
.makers dt { grid-column: 1 / -1; margin-top: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.makers dd { grid-column: 1 / -1; }
.specs { padding: 12px 14px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); margin-top: 14px; }
.specs dd { font-family: 'JetBrains Mono', monospace; font-size: 12px; text-align: right; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  margin: 12px 0 4px;
}
.back { border: 0; background: transparent; color: var(--muted); padding: 0; font-size: 13px; }
.back:hover { color: var(--text); }
.insight {
  margin-top: 18px; padding: 12px 14px; border-radius: 10px; color: #dbeafe; font-size: 13.5px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(34, 197, 94, 0.08)); border: 1px solid rgba(56, 189, 248, 0.25);
}
.insight-k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.pager { display: flex; gap: 8px; margin-top: 18px; }
.pager button {
  flex: 1; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); padding: 8px 10px; border-radius: 8px; font-size: 12px;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pager button:hover { color: var(--text); border-color: var(--line-strong); }
.tip { font-size: 12.5px; color: var(--muted) !important; margin-top: 16px !important; }
.disclaimer { font-size: 11px; color: #64748b !important; margin-top: 22px !important; line-height: 1.45; }
.info-handle { display: none; }

/* ── toolbar ───────────────────────────── */
.toolbar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 12;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 28px);
}
.toolbar .group {
  display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px);
}
.toolbar button {
  border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.toolbar button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.toolbar button.active { color: #0b1220; background: var(--accent); }
.explode { align-items: center; gap: 10px !important; padding: 4px 12px !important; color: var(--muted); font-size: 13px; }
.explode input { width: 130px; accent-color: var(--accent); }
.explode .mono { font-size: 11px; width: 34px; text-align: right; }

.hint {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 5; pointer-events: none;
  font-size: 12px; color: var(--muted); padding: 5px 12px; border-radius: 999px; background: rgba(7, 11, 18, 0.5); border: 1px solid var(--line);
}
#tooltip {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; opacity: 0; transition: opacity 0.12s;
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
  background: rgba(7, 11, 18, 0.92); border: 1px solid var(--line-strong);
}
#tooltip.show { opacity: 1; }

#loader {
  position: absolute; inset: 0; z-index: 40; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: rgba(7, 11, 18, 0.55); opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#loader.show { opacity: 1; }
.loader-ring { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(56, 189, 248, 0.2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.loader-text { color: var(--muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

.fab-left { display: none; }

/* ── compare dialog ────────────────────── */
dialog#compare {
  width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border-radius: 18px;
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog#compare::backdrop { background: rgba(2, 6, 12, 0.7); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.dialog-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.dialog-head button { border: 0; background: rgba(255, 255, 255, 0.06); width: 32px; height: 32px; border-radius: 8px; }
.table-wrap { overflow: auto; padding: 0 22px; max-height: calc(100vh - 200px); }
#compare-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#compare-table th, #compare-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
#compare-table thead th { position: sticky; top: 0; background: var(--panel-solid); font-size: 15px; font-weight: 700; z-index: 1; }
#compare-table tbody th { color: var(--muted); font-weight: 500; width: 26%; }
#compare-table td { font-variant-numeric: tabular-nums; }
#compare-table td.best { color: #86efac; font-weight: 600; }
#compare-table .unit { color: var(--muted); font-size: 11px; }
#compare-table .note { font-size: 11px; color: #64748b; margin-top: 2px; font-weight: 400; }
dialog#compare .disclaimer { padding: 0 22px 18px; margin-top: 12px !important; }

/* ── responsive ────────────────────────── */
@media (max-width: 1180px) {
  .brand-sub { display: none; }
  .panel.right { width: 320px; }
  .panel.left { width: 220px; }
}
@media (max-width: 900px) {
  :root { --top: 104px; }
  .topbar { flex-wrap: wrap; height: var(--top); padding: 10px 16px; gap: 8px 12px; align-content: center; }
  .car-tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .car-tab { flex: 1; justify-content: center; padding: 7px 8px; font-size: 13px; }
  .btn-compare { margin-left: auto; }
  .hint { display: none; }
  .panel.left {
    left: 16px; right: 16px; width: auto; top: 12px; bottom: auto; max-height: 55%;
    transform: translateY(-120%); transition: transform 0.25s; z-index: 15;
  }
  body.left-open .panel.left { transform: none; }
  .fab-left {
    display: block; position: absolute; top: 12px; left: 16px; z-index: 14; border: 1px solid var(--line-strong);
    background: var(--panel); padding: 6px 12px; border-radius: 999px; font-size: 12.5px; backdrop-filter: blur(10px);
  }
  body.left-open .fab-left { display: none; }
  .panel.right {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 46%; border-radius: 18px 18px 0 0; padding: 26px 16px 16px;
    transition: max-height 0.25s;
  }
  body.info-collapsed .panel.right { max-height: 64px; overflow: hidden; }
  .info-handle {
    display: block; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 80px; height: 22px; border: 0; background: transparent;
  }
  .info-handle::after { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 9px auto 0; }
  .toolbar { bottom: calc(46% + 10px); gap: 6px; }
  body.info-collapsed .toolbar { bottom: 74px; }
  .toolbar .group { padding: 3px; }
  .toolbar button { padding: 5px 8px; font-size: 12px; }
  .explode input { width: 90px; }
  #info h2 { font-size: 22px; }
}
@media (max-width: 420px) {
  .brand-name { font-size: 15px; }
  .car-tab .flag { display: none; }
}

.top-actions { display: flex; gap: 8px; align-items: center; }
.site-link { text-decoration: none; display: inline-flex; align-items: center; }
@media (max-width: 760px) { .site-link { display: none; } }
