:root {
  --bg: #0a0b10; --surface: rgb(20 23 33 / 0.78); --surface-solid: #141721; --surface-2: #1b1f2c;
  --border: rgb(255 255 255 / 0.1); --border-strong: rgb(255 255 255 / 0.2);
  --text: #eef0f6; --muted: #a0a7ba; --faint: #6f7689;
  --red: #ff3b3b; --orange: #ff8a1f; --yellow: #ffcc1a;
  --grad: linear-gradient(110deg, var(--red), var(--orange) 55%, var(--yellow));
  --display: "Space Grotesk", system-ui, sans-serif; --body: "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.glass { background: var(--surface); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); border: 1px solid var(--border); }

/* loader */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 16px; background: radial-gradient(60% 60% at 50% 40%, #1a1420, var(--bg)); transition: opacity 0.6s var(--ease), visibility 0.6s; }
.loader.is-done { opacity: 0; visibility: hidden; }
.loader img { height: 48px; width: auto; }
.loader__title { font-family: var(--display); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.85rem; color: var(--muted); }
.loader__bar { width: min(320px, 70vw); height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.loader__bar span { display: block; height: 100%; width: 0; background: var(--grad); transition: width 0.2s; }
.loader__pct { font-size: 0.85rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* top bar */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 14px 18px 26px; pointer-events: none; background: linear-gradient(rgb(10 11 16 / 0.6), rgb(10 11 16 / 0)); }
.title h1, .title p { text-shadow: 0 1px 8px rgb(0 0 0 / 0.6); }
.lbl-short { display: none; }
.topbar > * { pointer-events: auto; }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--muted); padding: 6px 10px 6px 4px; border-radius: 12px; }
.back:hover { color: var(--text); background: rgb(255 255 255 / 0.06); }
.back img { height: 34px; width: auto; }
.title h1 { font-family: var(--display); font-size: 1.15rem; line-height: 1.1; }
.title p { font-size: 0.8rem; color: var(--muted); }
.tools { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background 0.2s, border-color 0.2s; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
#btnSound .on { display: none; } #btnSound[aria-pressed="true"] .on { display: inline; } #btnSound[aria-pressed="true"] .off { display: none; }

/* camera presets */
.cams { position: fixed; top: 76px; left: 50%; translate: -50% 0; z-index: 9; display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cams button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-size: 0.85rem; color: var(--muted); }
.cams button:hover { color: var(--text); }
.cams button.is-active { background: var(--text); color: var(--bg); }

/* panel */
.panel { position: fixed; z-index: 10; right: 18px; top: 76px; bottom: 92px; width: 340px; display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3); transition: transform 0.4s var(--ease), opacity 0.3s; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; padding: 14px 6px; font-size: 0.88rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--orange); }
.tabpanels { flex: 1; overflow-y: auto; padding: 18px; }
.tabpanels h2 { font-family: var(--display); font-size: 0.95rem; font-weight: 600; margin: 4px 0 12px; display: flex; justify-content: space-between; gap: 8px; }
.tabpanels h2:not(:first-child) { margin-top: 20px; }
.sel { color: var(--muted); font-family: var(--body); font-weight: 500; font-size: 0.85rem; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; padding: 3px; background: transparent; transition: transform 0.2s var(--ease), border-color 0.2s; }
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: inset 0 -6px 12px rgb(0 0 0 / 0.35), inset 0 4px 8px rgb(255 255 255 / 0.25); }
.swatch:hover { transform: scale(1.06); }
.swatch[aria-pressed="true"] { border-color: var(--orange); }
.toggle { display: flex; gap: 10px; align-items: center; margin-top: 16px; font-size: 0.88rem; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--orange); width: 18px; height: 18px; }
.cards { display: grid; gap: 10px; }
.card { text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); display: grid; gap: 4px; }
.card strong { font-family: var(--display); }
.card small { color: var(--muted); }
.card[aria-pressed="true"] { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange) inset; }
.seg { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 9px; font-size: 0.86rem; color: var(--muted); }
.seg button.is-active, .seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.seg--wrap { flex-wrap: wrap; } .seg--wrap button { flex: 1 1 45%; }

.summary { border-top: 1px solid var(--border); padding: 16px 18px 18px; background: rgb(10 11 16 / 0.4); }
.summary__row { display: flex; justify-content: space-between; align-items: baseline; }
.summary__row strong { font-family: var(--display); font-size: 1.3rem; }
.summary__list { list-style: none; padding: 0; margin: 8px 0 4px; font-size: 0.82rem; color: var(--muted); display: grid; gap: 2px; }
.summary__list li { display: flex; justify-content: space-between; gap: 8px; }
.summary__note { font-size: 0.72rem; color: var(--faint); margin-bottom: 12px; }
.summary__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 0.92rem; border: 1px solid var(--border-strong); background: var(--surface); text-decoration: none; white-space: nowrap; transition: transform 0.2s var(--ease), background 0.2s; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--grad); color: #140600; border: 0; box-shadow: 0 10px 30px -10px rgb(255 80 40 / 0.6); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--link { border: 0; background: none; color: var(--muted); backdrop-filter: none; }

/* dock */
.dock { position: fixed; z-index: 10; left: 18px; bottom: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.btn--panel { display: none; }

/* hotspots */
#hotspots { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
.hs { position: absolute; left: 0; top: 0; pointer-events: auto; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 0; background: rgb(255 255 255 / 0.18); display: grid; place-items: center; transition: opacity 0.3s, transform 0.2s var(--ease); will-change: transform; }
.hs::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 12px var(--orange); }
.hs::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgb(255 204 26 / 0.7); animation: ping 2s infinite; }
@keyframes ping { 0% { transform: scale(0.6); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.hs span { position: absolute; left: 36px; white-space: nowrap; padding: 6px 10px; border-radius: 8px; background: var(--surface-solid); border: 1px solid var(--border); font-size: 0.8rem; font-weight: 600; opacity: 0; translate: -6px 0; transition: opacity 0.2s, translate 0.2s; pointer-events: none; }
.hs:hover span, .hs:focus-visible span { opacity: 1; translate: 0 0; }
.hs.is-hidden { opacity: 0; pointer-events: none; }
body[data-mode="drive"] #hotspots, body[data-mode="drive"] .panel, body[data-mode="drive"] .cams, body[data-mode="drive"] .dock { opacity: 0; pointer-events: none; }

/* HUD */
.hud { position: fixed; inset: 0; z-index: 11; pointer-events: none; }
.hud > * { pointer-events: auto; }
.speedo { position: absolute; left: 50%; bottom: 28px; translate: -50% 0; display: flex; align-items: baseline; gap: 6px; padding: 10px 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(10px); }
.speedo strong { font-family: var(--display); font-size: 2.6rem; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.speedo span { color: var(--muted); }
.speedo__gear { margin-left: 10px; padding-left: 12px; border-left: 1px solid var(--border-strong); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.speedo__gear b { color: var(--orange); font-family: var(--display); }
.hud__hint { position: absolute; left: 50%; top: 82px; translate: -50% 0; font-size: 0.82rem; color: var(--muted); padding: 6px 12px; border-radius: 999px; background: var(--surface); white-space: nowrap; }
.hud__exit { position: absolute; right: 18px; bottom: 28px; }
.touchpad { display: none; }

/* toast */
.toast { position: fixed; z-index: 30; left: 50%; bottom: 96px; translate: -50% 20px; opacity: 0; padding: 10px 18px; border-radius: 999px; background: var(--surface-solid); border: 1px solid var(--border-strong); font-size: 0.9rem; transition: opacity 0.3s, translate 0.3s var(--ease); pointer-events: none; }
.toast.is-on { opacity: 1; translate: -50% 0; }

/* dialogs */
.dialog { margin: auto; width: min(440px, calc(100vw - 32px)); border-radius: 18px; padding: 24px; background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong); box-shadow: 0 30px 80px rgb(0 0 0 / 0.6); }
.dialog::backdrop { background: rgb(5 6 10 / 0.6); backdrop-filter: blur(4px); }
.dialog h2 { font-family: var(--display); margin-bottom: 8px; }
.dialog p { color: var(--muted); margin-bottom: 16px; font-size: 0.95rem; }
.dialog label { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
.dialog input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; }
.dialog__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.keys { padding-left: 1.1em; display: grid; gap: 8px; color: var(--muted); margin-bottom: 18px; font-size: 0.92rem; }
kbd { font: 600 0.78rem var(--body); padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); }
.qr { display: grid; place-items: center; margin-bottom: 16px; }
.qr img, .qr svg { width: 180px; height: 180px; background: #fff; padding: 10px; border-radius: 12px; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; }

/* mobile */
@media (max-width: 900px) {
  .panel { left: 10px; right: 10px; top: auto; bottom: 76px; width: auto; max-height: 62vh; transform: translateY(calc(100% + 90px)); opacity: 0; }
  body.panel-open .panel { transform: none; opacity: 1; }
  .btn--panel { display: inline-flex; }
  .dock { left: 10px; right: 10px; bottom: 12px; justify-content: space-between; }
  .dock .btn { flex: 1; padding: 10px; font-size: 0.85rem; }
  .cams { top: 68px; max-width: calc(100vw - 20px); overflow-x: auto; }
  .title p, .back img { display: none; }
  .topbar { padding: 10px; gap: 8px; }
  .icon-btn { width: 38px; height: 38px; }
  .hud__hint { display: none; }
  .touchpad { display: grid; grid-template-columns: 68px 68px 1fr 68px 68px; gap: 10px; position: absolute; bottom: 100px; left: 12px; right: 12px; }
  .touchpad [data-k="brake"] { grid-column: 4; } .touchpad [data-k="gas"] { grid-column: 5; }
  .lbl-long { display: none; } .lbl-short { display: inline; }
  .dock { flex-wrap: nowrap; }
  .touchpad button { width: 68px; height: 68px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); font-size: 1.4rem; touch-action: none; user-select: none; -webkit-user-select: none; }
  .touchpad button:active, .touchpad button.is-down { background: var(--text); color: var(--bg); }
  .speedo { bottom: 190px; }
  .hud__exit { top: 64px; bottom: auto; right: 10px; }
}
@media (prefers-reduced-motion: reduce) { .hs::after { animation: none; } }
