:root {
  color-scheme: dark;
  --bg: #05090d;
  --bg-soft: #081019;
  --surface: rgba(12, 21, 30, 0.94);
  --surface-2: rgba(18, 30, 41, 0.92);
  --line: rgba(255, 255, 255, 0.11);
  --text: #f4f7fa;
  --muted: #9eabb7;
  --primary: #ff6a1a;
  --primary-ink: #190700;
  --accent: #59b8ff;
  --glow: rgba(89, 184, 255, 0.24);
  --danger: #ff6f77;
  --success: #4bd99a;
  --radius: 0px;
  --font-display: Inter, ui-sans-serif, system-ui, sans-serif;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-skin="performance_red"] {
  --bg: #080708; --bg-soft: #10090a; --surface: rgba(25, 12, 14, 0.95);
  --surface-2: rgba(38, 17, 20, 0.92); --primary: #ff353d; --accent: #ff8f5c;
  --glow: rgba(255, 53, 61, 0.27); --radius: 4px;
}
html[data-skin="modern_oem"] {
  --bg: #090d10; --bg-soft: #10161a; --surface: rgba(20, 27, 32, 0.96);
  --surface-2: rgba(29, 39, 46, 0.94); --primary: #67b7d4; --accent: #d8e3e9;
  --glow: rgba(103, 183, 212, 0.18); --radius: 8px;
}
html[data-skin="cyberpunk"] {
  --bg: #080611; --bg-soft: #100a1c; --surface: rgba(20, 11, 35, 0.94);
  --surface-2: rgba(31, 15, 51, 0.92); --primary: #00f0ff; --primary-ink: #001114;
  --accent: #ff2bd6; --glow: rgba(0, 240, 255, 0.28); --radius: 0px;
}
html[data-skin="mini_hud"] {
  --bg: #020805; --bg-soft: #04110a; --surface: rgba(3, 19, 10, 0.96);
  --surface-2: rgba(5, 30, 16, 0.94); --primary: #46ff82; --primary-ink: #001507;
  --accent: #b6ffcb; --glow: rgba(70, 255, 130, 0.22); --radius: 2px;
}
html[data-skin="retro_analog"] {
  --bg: #100b07; --bg-soft: #19110a; --surface: rgba(38, 26, 17, 0.96);
  --surface-2: rgba(56, 38, 24, 0.94); --primary: #e5a85d; --primary-ink: #1d1004;
  --accent: #f3d2a2; --glow: rgba(229, 168, 93, 0.2); --radius: 6px;
  --font-display: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh; margin: 0; color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, var(--glow), transparent 34rem),
    linear-gradient(145deg, var(--bg-soft), var(--bg));
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.noscript { padding: 1rem; background: var(--danger); color: #210306; font-weight: 800; text-align: center; }

.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--muted); }
.spinner { width: 42px; height: 42px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.small { width: 24px; height: 24px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand { display: inline-flex; align-items: center; gap: .8rem; text-decoration: none; font-weight: 800; letter-spacing: .09em; }
.brand strong { color: var(--primary); }
.brand.compact { font-size: .95rem; }
.brand-mark { width: 38px; height: 38px; display: grid; align-content: center; gap: 4px; padding: 8px 6px; border: 1px solid var(--line); }
.brand-mark span { height: 3px; background: var(--primary); display: block; }
.brand-mark span:nth-child(1) { width: 70%; }
.brand-mark span:nth-child(2) { width: 100%; }
.brand-mark span:nth-child(3) { width: 52%; }

.eyebrow { margin: 0 0 .55rem; color: var(--primary); font-size: .72rem; font-weight: 900; letter-spacing: .18em; }
.muted { color: var(--muted); line-height: 1.6; }
.shadow-badge { padding: .35rem .6rem; border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); color: var(--primary); font-size: .7rem; font-weight: 900; letter-spacing: .1em; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1.1fr) minmax(360px, .9fr); }
.auth-brand { padding: clamp(2rem, 6vw, 6rem); display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); }
.auth-brand h1 { max-width: 9ch; margin: 0; font: 700 clamp(3rem, 7vw, 7rem)/.93 var(--font-display); letter-spacing: -.055em; }
.auth-brand p:last-child { max-width: 38rem; color: var(--muted); font-size: 1.1rem; line-height: 1.7; }
.auth-card { width: min(100% - 2rem, 520px); margin: auto; padding: clamp(1.5rem, 5vw, 3rem); border: 1px solid var(--line); background: var(--surface); box-shadow: 0 30px 80px rgba(0,0,0,.42); }
.auth-card h2 { margin: 0; font: 700 clamp(2rem, 4vw, 3.2rem)/1 var(--font-display); letter-spacing: -.04em; }
.auth-links { margin-top: 1.25rem; display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .88rem; }
.auth-links a:hover { color: var(--text); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: 72px minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(18px); }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.sidebar { position: sticky; top: 72px; height: calc(100vh - 72px); display: flex; flex-direction: column; justify-content: space-between; padding: 1.25rem .9rem; border-right: 1px solid var(--line); }
.side-nav { display: grid; gap: .35rem; }
.side-nav button, .mobile-nav button { border: 0; background: transparent; color: var(--muted); }
.side-nav button { display: flex; align-items: center; gap: .8rem; padding: .8rem .9rem; text-align: left; font-weight: 750; border-left: 2px solid transparent; }
.side-nav button.active { color: var(--text); background: color-mix(in srgb, var(--primary) 9%, transparent); border-left-color: var(--primary); }
.side-nav button span { width: 1.3rem; color: var(--primary); text-align: center; }
.account-link { padding: .8rem .9rem; color: var(--muted); text-decoration: none; font-size: .85rem; }
.account-link:hover { color: var(--text); }

.content { min-width: 0; padding: clamp(1.25rem, 3vw, 3rem); }
.route-page { display: none; max-width: 1180px; margin: 0 auto; }
.route-page.active { display: block; }
.page-heading { margin-bottom: 1.5rem; }
.page-heading h1 { margin: 0; font: 700 clamp(2.2rem, 5vw, 4.8rem)/.95 var(--font-display); letter-spacing: -.05em; }
.page-heading p { max-width: 52rem; color: var(--muted); line-height: 1.65; }
.page-heading.with-action { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }

.surface { border: 1px solid var(--line); background: var(--surface); padding: clamp(1rem, 2vw, 1.5rem); border-radius: var(--radius); }
.profile-hero { position: relative; overflow: hidden; min-height: 260px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.5rem; padding: clamp(1.5rem, 4vw, 3rem); border: 1px solid var(--line); background: linear-gradient(135deg, var(--surface-2), var(--surface)); box-shadow: inset 0 0 60px var(--glow); }
.hero-glow { position: absolute; inset: auto -10% -75% auto; width: 36rem; height: 36rem; border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent); border-radius: 50%; box-shadow: 0 0 0 6rem color-mix(in srgb, var(--primary) 5%, transparent), 0 0 0 12rem color-mix(in srgb, var(--accent) 3%, transparent); }
.avatar-frame { position: relative; z-index: 1; width: 76px; height: 76px; display: grid; place-items: center; border: 2px solid var(--primary); background: var(--bg); box-shadow: 0 0 24px var(--glow); font: 800 1.7rem/1 var(--font-display); }
.avatar-frame.large { width: 110px; height: 110px; margin: 1rem auto; font-size: 2.3rem; }
.hero-copy { position: relative; z-index: 1; min-width: 0; }
.hero-copy h1 { margin: 0; font: 700 clamp(2rem, 5vw, 4.5rem)/.95 var(--font-display); letter-spacing: -.045em; }
.hero-copy p { margin: .5rem 0 0; color: var(--muted); line-height: 1.5; }
.hero-copy #heroHandle { color: var(--primary); font-weight: 800; }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.metric-card { min-height: 145px; display: grid; align-content: center; gap: .3rem; padding: 1.2rem; border: 1px solid var(--line); background: var(--surface); }
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong { font: 700 clamp(1.35rem, 3vw, 2.3rem)/1 var(--font-display); color: var(--primary); overflow-wrap: anywhere; }

.section-title { display: flex; align-items: center; justify-content: space-between; }
.section-title h2 { margin: 0; }
.empty-state { min-height: 250px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-state h3 { margin: .6rem 0 .25rem; color: var(--text); font-size: 1.35rem; }
.empty-state p { max-width: 42rem; line-height: 1.65; }
.empty-icon { font-size: 2.2rem; color: var(--primary); }

.future-grid, .safety-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.future-card { min-height: 180px; display: grid; align-content: center; gap: .5rem; padding: 1.4rem; border: 1px solid var(--line); background: var(--surface); }
.future-card strong { font-size: 1.25rem; }
.future-card span { color: var(--muted); line-height: 1.5; }
.notice { margin-top: 1rem; padding: 1rem; border-left: 3px solid var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--muted); line-height: 1.55; }

.two-column { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 1rem; align-items: start; }
.profile-preview-card { position: sticky; top: 96px; text-align: center; box-shadow: inset 0 0 44px var(--glow); }
.profile-preview-card h2 { margin: .4rem 0; font: 700 2rem/1 var(--font-display); }
.profile-preview-card #previewHandle { color: var(--primary); font-weight: 800; }
.profile-preview-card #previewBio { color: var(--muted); line-height: 1.55; }
.profile-preview-card dl { margin: 1.2rem 0; display: grid; border-top: 1px solid var(--line); }
.profile-preview-card dl div { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.profile-preview-card dt { color: var(--muted); }

.form-stack { display: grid; gap: 1rem; }
.form-stack label { display: grid; gap: .5rem; }
.form-stack label > span { font-size: .88rem; font-weight: 800; }
.form-stack small { color: var(--muted); line-height: 1.45; }
input, textarea, select {
  width: 100%; min-height: 48px; padding: .8rem .9rem; border: 1px solid var(--line);
  border-radius: var(--radius); outline: none; background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  color: var(--text);
}
textarea { resize: vertical; line-height: 1.5; }
select { appearance: auto; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--glow); }
.check-row { grid-template-columns: auto 1fr; align-items: start; gap: .7rem !important; color: var(--muted); line-height: 1.5; }
.check-row input { width: 18px; min-height: 18px; margin-top: .15rem; accent-color: var(--primary); }

.primary-button, .secondary-button, .ghost-button, .danger-text-button {
  min-height: 44px; padding: .72rem 1rem; border-radius: var(--radius); font-weight: 850; text-decoration: none;
}
.primary-button { border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); }
.secondary-button { border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--line)); background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--text); }
.secondary-button.inline { display: inline-flex; align-items: center; margin-top: .7rem; }
.ghost-button { border: 1px solid var(--line); background: transparent; color: var(--text); }
.text-button, .danger-text-button { border: 0; background: transparent; }
.text-button { color: var(--primary); font-weight: 800; }
.danger-text-button { color: var(--danger); }
button:disabled { opacity: .55; cursor: wait; }

.message { margin: 0 0 1rem; padding: .9rem 1rem; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); line-height: 1.5; }
.message.error { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.message.success { border-left-color: var(--success); background: color-mix(in srgb, var(--success) 8%, transparent); }

.inline-loading { display: flex; align-items: center; gap: .8rem; color: var(--muted); padding: 1rem; }
.garage-list { display: grid; gap: 1rem; }
.garage-card { overflow: hidden; }
.garage-card-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.garage-card-header h2 { margin: .25rem 0; font: 700 1.6rem/1 var(--font-display); }
.garage-private-summary { margin: 0; color: var(--muted); }
.garage-state { color: var(--primary); font-size: .72rem; font-weight: 900; letter-spacing: .12em; }
.public-preview { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); background: var(--surface-2); box-shadow: inset 0 0 35px var(--glow); }
.public-preview h3 { margin: 0; font: 700 1.5rem/1 var(--font-display); }
.public-preview p { margin: .45rem 0 0; color: var(--muted); line-height: 1.5; }
.garage-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .7rem; }

.safety-grid article h3 { margin-top: 0; }
.safety-grid article p { color: var(--muted); line-height: 1.6; }

.mobile-nav { display: none; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 48vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 64px minmax(0, 1fr); padding-bottom: 74px; }
  .sidebar { display: none; }
  .topbar { height: 64px; }
  .content { padding: 1rem; }
  .mobile-nav {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; height: 68px;
    display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(18px);
  }
  .mobile-nav button { display: grid; place-content: center; justify-items: center; gap: .15rem; font-size: .67rem; }
  .mobile-nav button span { color: var(--primary); font-size: 1rem; }
  .mobile-nav button.active { color: var(--text); background: color-mix(in srgb, var(--primary) 9%, transparent); }
  .two-column { grid-template-columns: 1fr; }
  .profile-preview-card { position: static; }
}

@media (max-width: 640px) {
  .topbar .shadow-badge { display: none; }
  .profile-hero { grid-template-columns: auto 1fr; min-height: 230px; }
  .profile-hero > .secondary-button { grid-column: 1 / -1; width: 100%; }
  .dashboard-grid, .future-grid, .safety-grid, .field-grid { grid-template-columns: 1fr; }
  .page-heading.with-action, .garage-card-header { align-items: stretch; flex-direction: column; }
  .auth-links { flex-direction: column; }
}
