/* ============================================================================
   Tesla Browser Emulator — Zero-Scroll Cockpit Stylesheet
   Hard Constraint (Law 17 & PRD Sec 04): 100vw x 100dvh, overflow: hidden.
   Only .inspector-body scrolls in place.
   ============================================================================ */

:root {
  --bg: #070a0f;
  --bg-elev: #0d121c;
  --bg-card: #111826;
  --bg-code: #090e16;
  --border: #1e2a3d;
  --border-bright: #2f4361;
  --text: #e6edf7;
  --text-muted: #93a4bd;
  --text-dim: #657690;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.14);
  --red: #e31937;
  --red-soft: rgba(227, 25, 55, 0.18);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.14);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.cockpit-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------- TOP COMMAND STRIP ---------------- */
.topbar {
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid rgba(227, 25, 55, 0.42);
  background: rgba(227, 25, 55, 0.12);
  color: #ff6b81;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
}
.brand-btn:hover {
  border-color: var(--red);
  background: rgba(227, 25, 55, 0.22);
}
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px rgba(227, 25, 55, 0.9);
}

.ctrl-select {
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  background: var(--bg-card);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  max-width: 225px;
}
.ctrl-select.compact {
  height: 24px;
  font-size: 11px;
  max-width: 190px;
}

.seg-group {
  display: inline-flex;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--bg-code);
  overflow: hidden;
  height: 30px;
}
.seg-group.compact {
  height: 24px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 0 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, color 120ms;
}
.seg-btn + .seg-btn {
  border-left: 1px solid var(--border);
}
.seg-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.seg-btn.active {
  background: var(--cyan-soft);
  color: var(--cyan);
}
.seg-btn[data-transport="proxy"].active {
  background: var(--green-soft);
  color: var(--green);
}
.seg-btn[data-transport="direct"].active {
  background: var(--amber-soft);
  color: var(--amber);
}

.act-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.act-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}
.act-btn.active {
  border-color: var(--cyan);
  background: var(--cyan-soft);
  color: var(--cyan);
}
.act-btn.accent-purple {
  border-color: rgba(167, 139, 250, 0.45);
  color: var(--purple);
}
.act-btn.accent-purple:hover {
  background: var(--purple-soft);
}
.act-btn.detect-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: rgba(34, 211, 238, 0.42);
  color: var(--cyan);
}
.act-btn.detect-btn.is-tesla {
  border-color: rgba(52, 211, 153, 0.65);
  background: var(--green-soft);
  color: var(--green);
}
.detect-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}
.act-btn.detect-btn.is-tesla .detect-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.grade-pill {
  height: 30px;
  min-width: 66px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--bg-code);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}
.grade-pill.grade-a { border-color: rgba(52, 211, 153, 0.65); color: var(--green); background: var(--green-soft); }
.grade-pill.grade-b { border-color: rgba(34, 211, 238, 0.65); color: var(--cyan); background: var(--cyan-soft); }
.grade-pill.grade-c { border-color: rgba(251, 191, 36, 0.65); color: var(--amber); background: var(--amber-soft); }
.grade-pill.grade-f { border-color: rgba(227, 25, 55, 0.65); color: #ff6b81; background: var(--red-soft); }

/* Popovers */
.popover-anchor {
  position: relative;
}
.mini-popover {
  position: absolute;
  top: 36px;
  right: 0;
  width: 224px;
  background: var(--bg-elev);
  border: 1px solid var(--border-bright);
  border-radius: 9px;
  padding: 10px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 80;
}
.pop-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cyan);
}
.pop-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.pop-primary, .pop-secondary {
  height: 29px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.pop-primary {
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: var(--cyan-soft);
  color: var(--cyan);
}
.pop-primary:hover { background: rgba(34, 211, 238, 0.25); }
.pop-secondary {
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
  color: var(--text);
}
.pop-secondary:hover { border-color: var(--purple); color: var(--purple); }

/* ---------------- MAIN WORKSPACE ---------------- */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 338px;
  overflow: hidden;
}

.stage-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, rgba(34, 211, 238, 0.05), transparent 65%), var(--bg);
}

.compare-bar {
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: rgba(13, 18, 28, 0.9);
  border-bottom: 1px solid var(--border);
}
.cmp-label {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.09em;
}
.cmp-p2-wrap {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.stage-canvas {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 14px;
  overflow: hidden;
  position: relative;
}

.stage-footer {
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}
.footer-telemetry {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}
.footer-brand a {
  color: var(--cyan);
  text-decoration: none;
}
.footer-brand a:hover { text-decoration: underline; }

/* ---------------- TESLA OS v12/v13 STUDIO HARDWARE BEZEL & CHROME ---------------- */
.tesla-slot {
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

.tesla-unit {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  border-radius: 26px;
  padding: 14px;
  background: linear-gradient(155deg, #22262e, #0a0b0e 42%, #171a20);
  box-shadow:
    0 30px 72px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 0 1.5px #050608;
  border: 1.5px solid #2b303a;
}

.tesla-unit.no-bezel {
  padding: 0;
  border-radius: 12px;
  background: transparent;
  border: 1.5px solid var(--border-bright);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
}

.tesla-unit.style-cybertruck {
  border-radius: 8px;
  background: linear-gradient(145deg, #2b2f35, #0a0b0d 50%, #20242a);
  border: 2px solid #525b68;
}
.tesla-unit.style-cybertruck .tesla-screen {
  border-radius: 3px;
}

.tesla-screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  /* Authentic Tesla OS v12/v13 Night palette: true OLED black */
  --ts-bg: #000000;
  --ts-strip: #000000;
  --ts-card: #15171c;
  --ts-card-border: rgba(255, 255, 255, 0.08);
  --ts-chrome: #0f1116;
  --ts-input: #1a1d24;
  --ts-dock: #000000;
  --ts-border: rgba(255, 255, 255, 0.09);
  --ts-text: #f4f6fa;
  --ts-muted: #98a0ad;
  --ts-dim: #555c68;
  --ts-accent: #3b82f6;
  --ts-hairline: rgba(255, 255, 255, 0.34);
  background: var(--ts-bg);
  color: var(--ts-text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tesla-screen[data-theme="light"] {
  --ts-bg: #eceef1;
  --ts-strip: #111317;
  --ts-card: #ffffff;
  --ts-card-border: rgba(15, 23, 42, 0.1);
  --ts-chrome: #f4f6f9;
  --ts-input: #ffffff;
  --ts-dock: #f2f4f7;
  --ts-border: rgba(15, 23, 42, 0.12);
  --ts-text: #11151d;
  --ts-muted: #556070;
  --ts-dim: #8a94a4;
  --ts-accent: #2563eb;
  --ts-hairline: rgba(255, 255, 255, 0.38);
}

.tesla-unit.style-cybertruck .tesla-screen {
  --ts-accent: #e31937;
}

/* Main Content Area above Dock */
.ts-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  background: var(--ts-bg);
}
.ts-body.layout-vertical {
  flex-direction: column;
}

/* ============================================================================
   LEFT VEHICLE STUDIO CARD (Matches authentic Tesla OS v12/v13 reference)
   ============================================================================ */
.ts-drive-strip {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: radial-gradient(ellipse at 50% 58%, #101318 0%, #000000 68%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px 18px;
  position: relative;
  overflow: hidden;
  color: #f4f6fa;
}
.ts-body.layout-vertical .ts-drive-strip {
  border-right: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-direction: row;
  align-items: stretch;
  gap: 24px;
  padding: 18px 26px;
}

/* Top Gear + Battery Header inside Vehicle Card */
.ts-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 6;
  height: 36px;
  flex-shrink: 0;
}
.ts-gears {
  display: flex;
  gap: 11px;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #515660;
}
.ts-gears button {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 2px 3px;
  cursor: pointer;
}
.ts-gears .gear-active {
  color: #ffffff;
  font-weight: 700;
}

.ts-batt {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e4e7ee;
  font-size: 21px;
  font-weight: 600;
}
.ts-batt-icon {
  width: 44px;
  height: 20px;
  border: 2px solid #7d838f;
  border-radius: 4px;
  padding: 2px;
  position: relative;
  background: #0b0d11;
}
.ts-batt-icon::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 4px;
  width: 3px;
  height: 8px;
  background: #7d838f;
  border-radius: 0 2px 2px 0;
}
.ts-batt-fill {
  width: 68%;
  height: 100%;
  background: #e4e7ee;
  border-radius: 1px;
}
.ts-batt-fill.charging {
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.7);
}

/* Speed Overlay (visible when in Driving mode) */
.ts-drive-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  z-index: 6;
}
.ts-speed-inline {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.ts-speed-num {
  font-size: 74px;
  font-weight: 300;
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: #ffffff;
}
.ts-speed-unit {
  font-size: 16px;
  font-weight: 600;
  color: #7d8594;
  letter-spacing: 0.08em;
}
.ts-ap-wheel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #3b82f6;
  font-size: 15px;
  font-weight: 600;
}
.ts-ap-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2.5px solid #3b82f6;
  background: rgba(59, 130, 246, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 3D Photorealistic Studio Vehicle Stage + Authentic Tesla Callout Leader Lines */
.ts-car-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 4px -24px;
}
.ts-body.layout-vertical .ts-car-stage {
  margin: 0;
  flex: 1.15;
}

.ts-car-photo {
  width: 106%;
  max-width: 780px;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 84% 78% at 50% 50%, #000 56%, transparent 98%);
  mask-image: radial-gradient(ellipse 84% 78% at 50% 50%, #000 56%, transparent 98%);
  filter: contrast(1.06) saturate(1.06);
  transition: transform 240ms ease;
}
.ts-body.layout-vertical .ts-car-photo {
  width: 100%;
  max-width: 580px;
}

/* Minimalist Floating Callouts (Lock, Open Frunk, Open Trunk, Charge Bolt) */
.ts-callout {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: none;
  background: transparent;
  color: #e6ebf2;
  cursor: pointer;
  padding: 4px 8px;
  text-align: left;
  transition: color 140ms, transform 140ms;
}
.ts-callout:hover {
  color: #ffffff;
  transform: translateY(-2px);
}
.ts-callout.active {
  color: #38bdf8;
}
.ts-callout.active-warn {
  color: #fbbf24;
}
.ts-callout-sm {
  font-size: 16px;
  font-weight: 400;
  color: #8c939f;
  line-height: 1.15;
}
.ts-callout-lg {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.2;
}
.ts-callout-line {
  width: 1.5px;
  background: linear-gradient(to bottom, var(--ts-hairline), rgba(255, 255, 255, 0.05));
  margin-top: 8px;
}

.ts-co-lock {
  top: 12%;
  left: 48%;
  transform: translateX(-50%);
}
.ts-co-lock:hover {
  transform: translateX(-50%) translateY(-2px);
}
.ts-co-lock .ts-callout-line { height: 108px; }

.ts-co-frunk {
  top: 30%;
  left: 9%;
  align-items: flex-start;
}
.ts-co-frunk .ts-callout-line { height: 56px; margin-left: 16px; }

.ts-co-trunk {
  top: 22%;
  right: 9%;
  align-items: flex-start;
}
.ts-co-trunk .ts-callout-line { height: 90px; margin-left: 14px; }

.ts-co-charge {
  top: 46%;
  right: 4%;
  padding: 6px;
  color: #b7becb;
}
.ts-co-charge.active {
  color: #22c55e;
  filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.8));
}

.ts-car-model-chip {
  position: absolute;
  bottom: 10px;
  left: 24px;
  z-index: 4;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.42);
  pointer-events: none;
}

/* ============================================================================
   FLOATING TESLA OS v12/v13 GLASS MINI MEDIA PLAYER (Matches reference!)
   ============================================================================ */
.ts-mini-player {
  background: rgba(24, 26, 31, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 6;
  min-width: 0;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
}
.ts-body.layout-vertical .ts-mini-player {
  width: 440px;
  flex-shrink: 0;
  align-self: center;
}
.ts-mp-top {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.ts-mp-art {
  width: 72px;
  height: 72px;
  border-radius: 9px;
  background: linear-gradient(135deg, #272c36, #14171d);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  color: #e6edf7;
  overflow: hidden;
}
.ts-mp-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ts-mp-meta {
  min-width: 0;
  flex: 1;
}
.ts-mp-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-mp-artist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.ts-mp-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
  flex-shrink: 0;
}
.ts-mp-eq span {
  width: 2.5px;
  background: #8e95a3;
  border-radius: 1px;
}
.ts-mp-eq.playing span {
  background: #22d3ee;
}
.ts-mp-artist {
  font-size: 16.5px;
  color: #8e95a3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-mp-aux {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #8e95a3;
  flex-shrink: 0;
}

.ts-mp-controls {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.ts-mp-icon-btn {
  height: 44px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #d7dce6;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, color 120ms;
}
.ts-mp-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
.ts-mp-icon-btn.liked {
  color: #e31937;
}
.ts-mp-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: -6px;
}
.ts-mp-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}
.ts-mp-dots span:first-child {
  background: #ffffff;
}

/* ============================================================================
   RIGHT BROWSER PANE + SLEEK TESLA OS TOP STATUS & BROWSER BAR
   ============================================================================ */
.ts-browser-pane {
  display: flex;
  flex-direction: column;
  background: var(--ts-bg);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.ts-right-top {
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--ts-bg);
  color: var(--ts-muted);
  font-size: 16.5px;
  font-weight: 500;
}
.ts-rt-left, .ts-rt-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ts-airbag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  padding: 3px 8px;
  border-radius: 5px;
}
.ts-sb-pill {
  font-size: 13.5px;
  font-weight: 700;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 3px 11px;
  border-radius: 999px;
}

.ts-browser-bar {
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--ts-chrome);
  border-top: 1px solid var(--ts-border);
  border-bottom: 1px solid var(--ts-border);
}

.ts-nav-btn {
  width: 42px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--ts-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ts-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ts-nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.ts-nav-btn:disabled {
  opacity: 0.34;
  cursor: default;
}

.ts-addr-form {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--ts-border);
  background: var(--ts-input);
}
.ts-addr-form:focus-within {
  border-color: rgba(255, 255, 255, 0.38);
}
.ts-lock {
  color: #34d399;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.ts-addr-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--ts-text);
  font-family: var(--mono);
  font-size: 18px;
  outline: none;
}
.ts-go-btn {
  height: 30px;
  padding: 0 14px;
  border-radius: 7px;
  border: none;
  background: #e31937;
  color: #fff;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.ts-vp-badge {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ts-muted);
  border: 1px solid var(--ts-border);
  white-space: nowrap;
  flex-shrink: 0;
}

.ts-viewport-wrap {
  position: relative;
  overflow: hidden;
  background: #080b10;
  flex-shrink: 0;
}

.tesla-iframe {
  display: block;
  border: none;
  background: #0a0f18;
}

/* Daytime Glare Wash Overlay */
.ts-glare-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 180ms ease;
  background:
    linear-gradient(
      128deg,
      rgba(255, 255, 255, 0.44) 0%,
      rgba(255, 250, 235, 0.22) 22%,
      rgba(255, 255, 255, 0.05) 42%,
      rgba(255, 255, 255, 0.28) 54%,
      rgba(255, 248, 220, 0.08) 68%,
      rgba(255, 255, 255, 0.16) 100%
    );
  mix-blend-mode: screen;
}
.ts-glare-overlay.active {
  opacity: 1;
}

/* ============================================================================
   AUTHENTIC TESLA OS v12/v13 BOTTOM DOCK (Matches reference screenshot!)
   ============================================================================ */
.ts-dock {
  height: 76px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 42px;
  background: var(--ts-dock);
  border-top: 1px solid var(--ts-border);
  color: var(--ts-text);
}
.ts-dock-car-btn {
  border: none;
  background: transparent;
  color: var(--ts-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
}
.ts-dock-car-btn:hover { color: var(--ts-text); background: rgba(255,255,255,0.06); }

.ts-dock-stepper {
  display: flex;
  align-items: center;
  gap: 18px;
}
.ts-step-arrow {
  border: none;
  background: transparent;
  color: var(--ts-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
}
.ts-step-arrow:hover { color: var(--ts-text); background: rgba(255,255,255,0.06); }
.ts-temp-num {
  font-size: 34px;
  font-weight: 300;
  letter-spacing: -0.03em;
  min-width: 44px;
  text-align: center;
}

.ts-dock-apps {
  display: flex;
  align-items: center;
  gap: 30px;
}
.ts-app-icon {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 130ms ease;
}
.ts-app-icon:hover {
  transform: scale(1.08);
}
.ts-app-icon.active::after {
  content: "";
  position: absolute;
  bottom: -9px;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: #ffffff;
}
.tesla-screen[data-theme="light"] .ts-app-icon.active::after {
  background: #11151d;
}

.ts-dock-vol {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ts-vol-icon-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ts-text);
  font-family: var(--mono);
  font-size: 14px;
}

/* ---------------- RIGHT DARK-CYBER CONTROL RAIL ---------------- */
.control-rail {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
}

.rail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  flex-shrink: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}
.card-title {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--cyan);
}
.card-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}
.status-chip {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-bright);
  background: var(--bg-code);
  color: var(--text-dim);
}
.status-chip.live {
  border-color: rgba(52, 211, 153, 0.55);
  background: var(--green-soft);
  color: var(--green);
}

/* Steering Wheel Card */
.wheel-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}
.wheel-btn {
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--bg-code);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.wheel-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.wheel-btn.primary {
  border-color: rgba(34, 211, 238, 0.48);
  background: var(--cyan-soft);
  color: var(--cyan);
}
.wheel-subrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.vol-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.vol-btn {
  height: 24px;
  padding: 0 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-code);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
}
.vol-btn:hover { border-color: var(--cyan); color: var(--text); }
.vol-val {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--cyan);
  min-width: 30px;
  text-align: center;
}
.key-hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* Audit Toggles Card */
.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.tog-btn {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-code);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.tog-btn .led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #334155;
  flex-shrink: 0;
}
.tog-btn.on {
  border-color: rgba(34, 211, 238, 0.5);
  color: var(--text);
  background: rgba(34, 211, 238, 0.08);
}
.tog-btn.on .led {
  background: var(--cyan);
  box-shadow: 0 0 7px var(--cyan);
}
.tog-btn.warn.on {
  border-color: rgba(251, 191, 36, 0.55);
  color: var(--amber);
  background: var(--amber-soft);
}
.tog-btn.warn.on .led {
  background: var(--amber);
  box-shadow: 0 0 7px var(--amber);
}

/* Tabbed Inspector Card (ONLY scrollable region on page) */
.inspector-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
.tab-bar.tab-bar-5 {
  grid-template-columns: repeat(5, 1fr);
}
.tab-btn {
  height: 32px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  background: rgba(34, 211, 238, 0.06);
}
.tab-count {
  font-size: 9.5px;
  padding: 1px 4px;
  border-radius: 999px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.inspector-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inspector-body::-webkit-scrollbar { width: 6px; }
.inspector-body::-webkit-scrollbar-track { background: transparent; }
.inspector-body::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }

/* Inspector Interior Styles */
.score-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--bg-code);
  border: 1px solid var(--border);
}
.score-badge-lg {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 800;
  flex-shrink: 0;
  border: 1px solid var(--border-bright);
}
.score-badge-lg.grade-a { color: var(--green); border-color: rgba(52,211,153,0.55); background: var(--green-soft); }
.score-badge-lg.grade-b { color: var(--cyan); border-color: rgba(34,211,238,0.55); background: var(--cyan-soft); }
.score-badge-lg.grade-c { color: var(--amber); border-color: rgba(251,191,36,0.55); background: var(--amber-soft); }
.score-badge-lg.grade-f { color: #ff6b81; border-color: rgba(227,25,55,0.55); background: var(--red-soft); }
.score-badge-lg .lg-g { font-size: 16px; line-height: 1; }
.score-badge-lg .lg-n { font-size: 10px; opacity: 0.9; }

.score-bar-track {
  height: 6px;
  border-radius: 999px;
  background: #172030;
  overflow: hidden;
  margin-top: 4px;
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.cat-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(9, 14, 22, 0.72);
  border: 1px solid var(--border);
}
.cat-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10.5px;
}
.cat-name { color: var(--text); font-weight: 700; }
.cat-pts { color: var(--cyan); }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--text-muted);
}
.chk-pill {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 1px;
}
.chk-pill.pass { background: var(--green-soft); color: var(--green); }
.chk-pill.warn { background: var(--amber-soft); color: var(--amber); }
.chk-pill.fail { background: var(--red-soft); color: #ff6b81; }

.ins-actions {
  display: flex;
  gap: 6px;
}
.ins-btn {
  flex: 1;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--bg-code);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
}
.ins-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.ins-btn.primary {
  border-color: rgba(34, 211, 238, 0.5);
  background: var(--cyan-soft);
  color: var(--cyan);
}

.kv-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 8px;
}
.kv-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  color: var(--cyan);
  margin-bottom: 5px;
  letter-spacing: 0.06em;
}
.kv-line {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.4;
  word-break: break-all;
  margin-bottom: 3px;
  color: var(--text-muted);
}
.kv-k { color: var(--text); font-weight: 600; }

.field-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 3px;
  display: block;
}
.ins-input, .ins-textarea, .ins-select {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--bg-code);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 8px;
  outline: none;
}
.ins-textarea { resize: vertical; min-height: 60px; }
.ins-input:focus, .ins-textarea:focus, .ins-select:focus { border-color: var(--cyan); }

.hdr-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr 24px;
  gap: 4px;
  margin-bottom: 4px;
}
.hdr-del-btn {
  border-radius: 5px;
  border: 1px solid rgba(227, 25, 55, 0.4);
  background: var(--red-soft);
  color: #ff6b81;
  font-weight: 700;
  cursor: pointer;
}

.vp-override-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 5px;
  align-items: center;
}

.console-item {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 5px 7px;
  border-radius: 5px;
  background: var(--bg-code);
  border-left: 3px solid var(--border-bright);
  word-break: break-word;
  color: var(--text-muted);
}
.console-item.warn { border-left-color: var(--amber); color: #fde68a; }
.console-item.error { border-left-color: var(--red); color: #fca5a5; }
.console-item.info { border-left-color: var(--cyan); color: #bae6fd; }
.console-ts { color: var(--text-dim); margin-right: 6px; font-size: 9.5px; }

.empty-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 12px 6px;
  text-align: center;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
}
.modal-box {
  width: 440px;
  max-width: 92vw;
  background: var(--bg-elev);
  border: 1px solid var(--border-bright);
  border-top: 3px solid var(--red);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  color: var(--cyan);
  margin-bottom: 10px;
}
.icon-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}
.modal-box p { margin: 0 0 10px; color: var(--text-muted); line-height: 1.5; }
.modal-box a { color: var(--cyan); }
.modal-disclaimer {
  font-family: var(--mono);
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--amber-soft);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fde68a;
}

.toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  z-index: 150;
}
