/* ==============================================================================
   BimmerVision Design System (Unified Mac & Windows Avalonia/Swift Theme)
   ============================================================================== */

:root {
  /* Exact Colors from TeslaTheme.swift and Tesla.axaml */
  --tesla-canvas: #0B0B0C;
  --tesla-panel: #131416;
  --tesla-hud: #171719;
  --tesla-elevated: #1C1D20;
  --tesla-ink: rgba(255, 255, 255, 0.96);
  --tesla-muted: rgba(255, 255, 255, 0.62);
  --tesla-faint: rgba(255, 255, 255, 0.44);
  --tesla-line: rgba(255, 255, 255, 0.08);

  /* BMW M Colors */
  --m-blue: #3DA8F2;
  --m-indigo: #3043A6;
  --m-red: #EE2440;
  --signal-green: #38D47A;

  /* Safe Area Insets for iOS */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--tesla-canvas);
  color: var(--tesla-ink);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
  line-height: 1.4;
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==============================================================================
   Top Navigation Bar (Wordmark, Nav Tabs, Status)
   ============================================================================== */

.app-header {
  height: 56px;
  padding: 0 20px;
  background: rgba(19, 20, 22, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--tesla-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
}

.brand-wordmark {
  height: 18px;
  width: auto;
  object-fit: contain;
  opacity: 0.95;
}

/* Nav Tabs: Recordings / Playback */
.nav-tabs {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--tesla-line);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--tesla-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--tesla-ink);
}

.nav-tab.disabled,
.nav-tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-tab.active {
  background: var(--tesla-panel);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit-toggle-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tesla-line);
  color: var(--tesla-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.unit-toggle-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--tesla-ink);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--tesla-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--tesla-line);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--signal-green);
  box-shadow: 0 0 8px var(--signal-green);
}

/* ==============================================================================
   Tab Views Switcher
   ============================================================================== */

.tab-view {
  display: none;
  flex: 1;
}

.tab-view.active {
  display: block;
}

/* ==============================================================================
   TAB 1: RECORDINGS & DRIVE OVERVIEW VIEW
   ============================================================================== */

.recordings-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px 20px;
  max-width: 1440px;
  margin: 0 auto;
}

.drives-sidebar {
  background: var(--tesla-panel);
  border: 1px solid var(--tesla-line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 90px);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px 10px 14px;
  border-bottom: 1px solid var(--tesla-line);
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--tesla-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.section-count {
  font-size: 11px;
  color: var(--tesla-faint);
  font-variant-numeric: tabular-nums;
}

.drive-cards-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

/* Date Groups */
.date-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.date-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 4px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.date-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--tesla-ink);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-group-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--tesla-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: 10px;
}

/* Rich Drive Card */
.drive-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--tesla-line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}

.drive-card:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.12);
}

.drive-card.active {
  background: rgba(48, 67, 166, 0.18);
  border-color: var(--m-blue);
  box-shadow: 0 0 12px rgba(0, 102, 177, 0.25);
}

.drive-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.drive-card-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.drive-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tesla-ink);
}

.drive-card-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--m-blue);
}

.drive-card-dur-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--tesla-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Locations block inside Drive Card */
.drive-card-locations {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.drive-loc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.drive-loc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.drive-loc-dot.start {
  background: var(--m-blue);
  box-shadow: 0 0 6px rgba(0, 102, 177, 0.6);
}

.drive-loc-dot.end {
  background: var(--m-red);
  box-shadow: 0 0 6px rgba(224, 0, 0, 0.6);
}

.drive-loc-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--tesla-faint);
  width: 38px;
  flex-shrink: 0;
  letter-spacing: 0.4px;
}

.drive-loc-text {
  color: var(--tesla-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Action Buttons inside Drive Card */
.drive-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-view-entire-drive {
  flex: 1;
  background: rgba(48, 67, 166, 0.2);
  border: 1px solid var(--m-blue);
  color: #ffffff;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-view-entire-drive:hover {
  background: var(--m-blue);
  box-shadow: 0 2px 8px rgba(0, 102, 177, 0.4);
}

.btn-toggle-recordings {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tesla-line);
  color: var(--tesla-ink);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-toggle-recordings:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-toggle-recordings .chevron {
  transition: transform 0.2s ease;
  display: inline-block;
}

.btn-toggle-recordings.expanded .chevron {
  transform: rotate(180deg);
}

.btn-lock-drive.is-locked,
.btn-lock-clip.is-locked {
  color: #f59e0b !important;
  border-color: rgba(245, 158, 11, 0.5) !important;
  background: rgba(245, 158, 11, 0.12) !important;
}

.btn-lock-drive:hover,
.btn-lock-clip:hover {
  background: rgba(255, 255, 255, 0.12) !important;
}

.btn-delete-drive:hover,
.btn-delete-clip:hover {
  background: rgba(238, 36, 64, 0.25) !important;
}
  transform: rotate(180deg);
}

/* Expandable Drawer for Specific Recordings */
.drive-recordings-drawer {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.drive-recordings-drawer.open {
  display: flex;
}

.recording-clip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  gap: 8px;
}

.recording-clip-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.recording-clip-name {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recording-clip-meta {
  font-size: 10px;
  color: var(--tesla-muted);
  display: flex;
  gap: 6px;
}

.btn-play-clip {
  background: var(--m-blue);
  border: none;
  color: white;
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-play-clip:hover {
  background: #0077d4;
  transform: scale(1.02);
}

/* Selected Drive Overview Stage */
.drive-overview-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.overview-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
}

.overview-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--tesla-ink);
}

.overview-subtitle {
  font-size: 12px;
  color: var(--tesla-muted);
  margin-top: 2px;
}

.overview-play-btn {
  background: var(--m-indigo);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(48, 67, 166, 0.4);
  transition: all 0.2s ease;
}

.overview-play-btn:hover {
  background: #3952cf;
  box-shadow: 0 6px 16px rgba(48, 67, 166, 0.6);
}

/* Start / End Endpoints Row */
.endpoints-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.endpoint-card {
  background: var(--tesla-panel);
  border: 1px solid var(--tesla-line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.endpoint-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-start { background-color: var(--m-blue); }
.dot-end { background-color: var(--m-red); }

.endpoint-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--tesla-muted);
  letter-spacing: 0.5px;
}

.endpoint-address {
  font-size: 13px;
  font-weight: 500;
  color: var(--tesla-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.endpoint-time {
  font-size: 11px;
  color: var(--tesla-faint);
  font-variant-numeric: tabular-nums;
}

/* Map Card */
.overview-map-card {
  background: #000000;
  border: 1px solid var(--tesla-line);
  border-radius: 12px;
  overflow: hidden;
  height: 260px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#overviewMapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Metrics Grid (3 Columns x 2 Rows) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric-card {
  background: var(--tesla-panel);
  border: 1px solid var(--tesla-line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.metric-label {
  font-size: 11px;
  color: var(--tesla-muted);
}

.metric-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--tesla-ink);
  font-variant-numeric: tabular-nums;
}

/* Segments in Drive */
.drive-segments-box {
  background: var(--tesla-panel);
  border: 1px solid var(--tesla-line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.segments-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--tesla-muted);
  letter-spacing: 0.15em;
}

.segments-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.segment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--tesla-line);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.segment-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ==============================================================================
   TAB 2: PLAYBACK VIEW (Player, Cockpit HUD, Sedan Camera Selector, Live Map)
   ============================================================================== */

.playback-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px 20px;
  max-width: 1440px;
  margin: 0 auto;
}

.playback-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card {
  background: var(--tesla-panel);
  border: 1px solid var(--tesla-line);
  border-radius: 12px;
  overflow: hidden;
}

/* ==============================================================================
   Corrected Top-Down Sedan Camera Selector
   ============================================================================== */

.sedan-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tesla-line);
}

.sedan-header-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sedan-panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--tesla-ink);
  letter-spacing: 0.12em;
}

.sedan-hint-text {
  font-size: 9px;
  font-weight: 600;
  color: var(--m-blue);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.sedan-view-switchers {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sedan-view-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #1C1C1F;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--tesla-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sedan-view-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--tesla-ink);
}

.sedan-view-pill.active {
  background: var(--m-indigo);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(48, 67, 166, 0.4);
}

.sedan-stage-wrapper {
  background: radial-gradient(circle at center, rgba(30, 32, 40, 0.4) 0%, rgba(10, 11, 14, 0.9) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
}

/* Fixed 200x240 Aspect Ratio Container */
.sedan-stage-box {
  position: relative;
  width: 200px;
  height: 240px;
}

.sedan-beams {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.clickable-cone {
  cursor: pointer;
  pointer-events: auto;
}

.clickable-cone:hover {
  filter: brightness(1.25);
}

.beam-cone {
  transition: opacity 0.25s ease, filter 0.25s ease, transform 0.25s ease;
  transform-origin: 100px 120px;
}

.beam-cone.anim-pulse {
  animation: coneSelectFlash 0.4s ease-out;
}

@keyframes coneSelectFlash {
  0% { filter: brightness(2.2) drop-shadow(0 0 16px rgba(61, 168, 242, 0.9)); transform: scale(1.05); }
  50% { filter: brightness(1.6) drop-shadow(0 0 8px rgba(61, 168, 242, 0.5)); }
  100% { filter: none; transform: scale(1); }
}

/* Centered BMW Sedan */
.sedan-img {
  position: absolute;
  width: 80px;
  height: 154px;
  left: 60px;
  top: 43px;
  object-fit: contain;
  z-index: 3;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.85));
  pointer-events: none;
}

/* Invisible Generous Touch & Click Hit Zones */
.cam-hit-zone {
  position: absolute;
  z-index: 5;
  cursor: pointer;
}
.hit-front {
  top: 0;
  left: 35px;
  width: 130px;
  height: 70px;
}
.hit-rear {
  bottom: 0;
  left: 35px;
  width: 130px;
  height: 70px;
}
.hit-left {
  top: 50px;
  left: 0;
  width: 68px;
  height: 140px;
}
.hit-right {
  top: 50px;
  right: 0;
  width: 68px;
  height: 140px;
}

/* Camera Target Badges Geometrically Locked to Body */
.camera-target {
  position: absolute;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.camera-target:active {
  transform: scale(0.92);
}

.target-front.anim-pop {
  animation: targetFrontPopAnim 0.35s ease-out;
}
@keyframes targetFrontPopAnim {
  0% { transform: translateX(-50%) scale(0.85); }
  50% { transform: translateX(-50%) scale(1.22); }
  100% { transform: translateX(-50%) scale(1); }
}

.target-rear.anim-pop {
  animation: targetRearPopAnim 0.35s ease-out;
}
@keyframes targetRearPopAnim {
  0% { transform: translateX(-50%) scale(0.85); }
  50% { transform: translateX(-50%) scale(1.22); }
  100% { transform: translateX(-50%) scale(1); }
}

.target-left.anim-pop {
  animation: targetLeftPopAnim 0.35s ease-out;
}
@keyframes targetLeftPopAnim {
  0% { transform: translateY(-50%) scale(0.85); }
  50% { transform: translateY(-50%) scale(1.22); }
  100% { transform: translateY(-50%) scale(1); }
}

.target-right.anim-pop {
  animation: targetRightPopAnim 0.35s ease-out;
}
@keyframes targetRightPopAnim {
  0% { transform: translateY(-50%) scale(0.85); }
  50% { transform: translateY(-50%) scale(1.22); }
  100% { transform: translateY(-50%) scale(1); }
}

.cam-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  margin-bottom: 2px;
  transition: all 0.2s ease;
}

.cam-badge {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(15, 17, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--tesla-muted);
  transition: all 0.2s ease;
}

/* Front Target */
.target-front {
  top: 8px;
  left: 100px;
  transform: translateX(-50%);
}
.target-front .cam-dot { background-color: var(--m-red); }
.target-front.active .cam-dot { box-shadow: 0 0 10px var(--m-red); }
.target-front.active .cam-badge { color: #fff; background: var(--m-red); border-color: var(--m-red); }

/* Rear Target */
.target-rear {
  bottom: 8px;
  left: 100px;
  transform: translateX(-50%);
}
.target-rear .cam-dot { background-color: var(--m-blue); }
.target-rear.active .cam-dot { box-shadow: 0 0 10px var(--m-blue); }
.target-rear.active .cam-badge { color: #fff; background: var(--m-indigo); border-color: var(--m-blue); }

/* Left Target (Tucked snug against driver door) */
.target-left {
  top: 97px;
  left: 14px;
  transform: translateY(-50%);
}
.target-left .cam-dot { background-color: var(--m-blue); }
.target-left.active .cam-dot { box-shadow: 0 0 10px var(--m-blue); }
.target-left.active .cam-badge { color: #fff; background: var(--m-indigo); border-color: var(--m-blue); }

/* Right Target (Tucked snug against passenger door) */
.target-right {
  top: 97px;
  right: 14px;
  transform: translateY(-50%);
}
.target-right .cam-dot { background-color: var(--m-blue); }
.target-right.active .cam-dot { box-shadow: 0 0 10px var(--m-blue); }
.target-right.active .cam-badge { color: #fff; background: var(--m-indigo); border-color: var(--m-blue); }

/* Center Car Body Hit Area */
.target-center-car {
  position: absolute;
  width: 60px;
  height: 100px;
  top: 70px;
  left: 70px;
  z-index: 5;
  cursor: pointer;
}

/* Live Map Box in Playback */
.live-map-box {
  width: 100%;
  height: 175px;
  background: #121214;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 10px 10px;
}

#playbackMapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==============================================================================
   Main Stage: Video Viewport & Cockpit HUD
   ============================================================================== */

.playback-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Video Player Stage */
.player-stage {
  background: #000;
  border-radius: 12px;
  border: 1px solid var(--tesla-line);
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
}

.canvas-viewport {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #040507;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#videoCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Cockpit Instrument Bar (Speed & Limit Left | Blinkers & Steering Center | Pedals Right) */
.cockpit-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--tesla-hud);
  border-top: 1px solid var(--tesla-line);
  border-bottom: 1px solid var(--tesla-line);
}

.hud-cluster {
  display: flex;
  align-items: center;
}

.hud-left {
  gap: 16px;
  flex: 1;
  justify-content: flex-start;
}

.hud-center {
  gap: 24px;
  flex: 1;
  justify-content: center;
}

.hud-right {
  gap: 16px;
  flex: 1;
  justify-content: flex-end;
}

.blinker-icon {
  width: 38px;
  height: 38px;
  fill: rgba(255, 255, 255, 0.16);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  transition: all 0.15s ease;
}

@keyframes blinkerFlash {
  0%, 49.9% {
    fill: var(--signal-green);
    filter: drop-shadow(0 0 14px var(--signal-green));
    opacity: 1;
  }
  50%, 100% {
    fill: rgba(255, 255, 255, 0.16);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
    opacity: 0.35;
  }
}

.blinker-active {
  fill: var(--signal-green);
  filter: drop-shadow(0 0 14px var(--signal-green));
  animation: blinkerFlash 0.667s infinite step-end;
}

.hud-speed-group {
  display: flex;
  align-items: baseline;
  gap: 4px;
  cursor: pointer;
}

.hud-speed-val {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud-speed-unit {
  font-size: 13px;
  font-weight: 700;
  color: var(--tesla-muted);
}

.hud-limit-sign {
  width: 36px;
  height: 42px;
  background: #fff;
  border: 3px solid #c01025;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hud-limit-text {
  color: #111;
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud-limit-label {
  color: #444;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

/* Option 3 Pedals */
.pedals-group {
  display: flex;
  gap: 16px;
  align-items: center;
}

.pedal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.pedal-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--tesla-muted);
  transition: color 0.15s ease;
}

.pedal-brake svg, .pedal-gas svg {
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Brake Active */
.pedal-active-brake .pedal-brake svg {
  transform: translateY(2px) scale(0.93);
  filter: drop-shadow(0 0 10px rgba(238, 36, 64, 0.9));
}
.pedal-active-brake .brake-pad { fill: rgba(238, 36, 64, 0.35) !important; stroke: var(--m-red) !important; }
.pedal-active-brake .brake-arm { fill: var(--m-red) !important; }
.pedal-active-brake .brake-rib { stroke: #ffffff !important; }
.pedal-active-brake .pedal-label { color: var(--m-red); }

/* Gas Active */
.pedal-active-gas .pedal-gas svg {
  transform: translateY(2px) scaleY(0.88);
  filter: drop-shadow(0 0 10px rgba(56, 212, 122, 0.9));
}
.pedal-active-gas .gas-pad { fill: rgba(56, 212, 122, 0.35) !important; stroke: var(--signal-green) !important; }
.pedal-active-gas .gas-hinge { fill: var(--signal-green) !important; }
.pedal-active-gas .gas-rib { stroke: #ffffff !important; }
.pedal-active-gas .pedal-label { color: var(--signal-green); }

/* Steering Wheel */
.wheel-group {
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-wrapper {
  position: relative;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.7));
}

.wheel-horn {
  position: absolute;
  visibility: hidden;
}

.wheel-angle-label {
  display: none !important;
}

/* Transport Scrubber */
.transport-panel {
  padding: 14px 18px;
  background: var(--tesla-panel);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scrubber-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scrub-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.scrub-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--m-blue);
  cursor: pointer;
  box-shadow: 0 0 8px var(--m-blue);
}

.timecode-display {
  font-size: 12px;
  font-family: monospace;
  color: var(--tesla-muted);
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
}

.transport-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tesla-line);
  color: var(--tesla-ink);
  width: 36px;
  height: 36px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.control-btn:active {
  transform: scale(0.93);
}

.play-btn {
  background: var(--m-indigo);
  border-color: rgba(255, 255, 255, 0.15);
  width: 44px;
  height: 44px;
  border-radius: 22px;
  color: white;
}

.play-btn:hover {
  background: #3952cf;
}

.export-btn {
  background: linear-gradient(135deg, #005a9e, #3da8f2);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(61, 168, 242, 0.35);
  transition: all 0.2s ease;
}

.export-btn:hover {
  filter: brightness(1.1);
}

/* ==============================================================================
   Export Modal Sheet
   ============================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: var(--tesla-elevated);
  width: 90%;
  max-width: 460px;
  border-radius: 14px;
  border: 1px solid var(--tesla-line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  transform: scale(0.94);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-backdrop.open .modal-sheet {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--tesla-line);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--tesla-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-label {
  font-size: 14px;
  font-weight: 600;
}

.modal-sublabel {
  font-size: 11px;
  color: var(--tesla-muted);
}

.modal-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--tesla-line);
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.modal-toggle {
  position: relative;
  width: 46px;
  height: 26px;
}

.modal-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.25s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--m-blue);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.progress-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3da8f2, #38d47a);
  transition: width 0.15s linear;
}

.progress-text {
  font-size: 12px;
  color: var(--tesla-muted);
  text-align: center;
}

.modal-primary-btn {
  background: linear-gradient(135deg, #005a9e, #3da8f2);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  transition: all 0.2s ease;
}

.modal-primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==============================================================================
   Mobile Reflow (Screens < 960px)
   ============================================================================== */

@media (max-width: 959px) {
  body, html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  .app-shell {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  .app-header {
    height: 48px;
    padding: 0 10px;
    gap: 6px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
  }

  .header-left {
    min-width: 0;
    flex-shrink: 1;
  }

  .brand-wordmark {
    height: 15px;
    max-width: 85px;
    object-fit: contain;
  }

  .nav-tabs {
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
  }

  .nav-tab {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
  }

  .nav-tab svg {
    width: 13px;
    height: 13px;
  }

  .header-right {
    gap: 6px;
    flex-shrink: 0;
  }

  .unit-toggle-pill {
    padding: 3px 6px;
    font-size: 10px;
  }

  .status-pill {
    padding: 5px 8px;
    font-size: 11px;
    gap: 5px;
  }

  .status-pill #connStatus {
    display: none;
  }

  .recordings-grid {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .endpoints-row {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .playback-grid {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .playback-stage {
    order: 1;
  }

  .playback-sidebar {
    order: 2;
  }

  .hud-speed-val {
    font-size: 32px;
  }

  .cockpit-hud {
    padding: 8px 10px;
  }

  .hud-left {
    gap: 10px;
  }

  .hud-center {
    gap: 14px;
  }

  .hud-right {
    gap: 10px;
  }

  .wheel-wrapper {
    width: 38px;
    height: 38px;
  }

  .wheel-img {
    width: 36px;
    height: 36px;
  }

  .blinker-icon {
    width: 28px;
    height: 28px;
  }

  .pedals-group {
    gap: 8px;
  }

  .modal-sheet {
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    padding-bottom: var(--safe-bottom);
  }
}

/* ==============================================================================
   Mobile Responsive Navigation & Header (Prevents cutoff on 375px-430px screens)
   ============================================================================== */

@media (max-width: 600px) {
  .app-header {
    height: 48px;
    padding: 0 8px;
    gap: 6px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
  }

  .header-left {
    min-width: 0;
    flex-shrink: 1;
  }

  .brand-wordmark {
    height: 14px;
    max-width: 80px;
    object-fit: contain;
  }

  .nav-tabs {
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
  }

  .nav-tab {
    padding: 4px 7px;
    font-size: 11px;
    gap: 3px;
  }

  .nav-tab svg {
    width: 13px;
    height: 13px;
  }

  .header-right {
    gap: 5px;
    flex-shrink: 0;
  }

  .unit-toggle-pill {
    padding: 3px 6px;
    font-size: 10px;
  }

  .status-pill {
    padding: 4px 8px;
    font-size: 11px;
    gap: 5px;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 0 8px;
    gap: 4px;
  }

  .status-pill {
    padding: 6px;
    border-radius: 50%;
    gap: 0;
  }

  .status-pill #connStatus {
    display: none;
  }

  .brand-wordmark {
    max-width: 68px;
    height: 13px;
  }

  .nav-tabs {
    padding: 2px;
    gap: 2px;
  }

  .nav-tab {
    padding: 3px 6px;
    font-size: 10.5px;
    gap: 2px;
  }

  .nav-tab svg {
    display: none;
  }
}

/* ==============================================================================
   Camera Identity & Calibration Modal (Matches Mac/Windows SedanCameraPanel)
   ============================================================================== */

.identify-canvas-box {
  width: 100%;
  position: relative;
  background: #000;
  border-radius: 10px;
  border: 1px solid var(--tesla-line);
  overflow: hidden;
  margin-bottom: 12px;
}

#identifyCanvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1280 / 480;
  display: block;
}

.identify-canvas-labels {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  pointer-events: none;
}

.identify-label-badge {
  background: rgba(14, 17, 24, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
}

.identify-info-pill {
  font-family: Consolas, Menlo, Monaco, monospace;
  font-size: 11px;
  color: var(--tesla-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--tesla-line);
  margin-bottom: 14px;
  word-break: break-all;
}

.identify-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.identify-action-btn {
  background: #1C1C1F;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.identify-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.identify-action-btn.active-mapping {
  background: rgba(61, 168, 242, 0.2);
  border-color: var(--m-blue);
  color: var(--m-blue);
}

/* ==============================================================================
   Fluid cockpit — Tesla screen, one M stripe
   Layout only. Wheel, blinkers, pedals, sedan art, and camera cones are unchanged.
   ============================================================================== */

:root {
  --deck: #07080a;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

body {
  background:
    radial-gradient(900px 420px at 80% -8%, rgba(48, 67, 166, 0.18), transparent 60%),
    var(--tesla-canvas);
}

.app-shell {
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  height: 60px;
  padding: 0 22px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: rgba(11, 11, 12, 0.72);
  border-bottom: none;
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--m-blue) 0 33.34%,
    var(--m-indigo) 33.34% 66.67%,
    var(--m-red) 66.67% 100%
  );
  opacity: 0.92;
}

.header-left { justify-self: start; }
.header-right { justify-self: end; }

.brand-wordmark {
  height: 16px;
  opacity: 0.92;
}

.nav-tabs {
  border-radius: 999px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.nav-tab {
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 6px 16px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.nav-tab.active {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.unit-toggle-pill,
.status-pill {
  border-radius: 999px;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.08);
}

.tab-view.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  animation: viewIn 0.38s var(--ease);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.recordings-grid,
.playback-grid {
  flex: 1;
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 14px 16px 16px;
  gap: 12px;
  align-items: stretch;
}

.recordings-grid {
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

.playback-grid {
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
}

.drives-sidebar,
.panel-card,
.endpoint-card,
.drive-segments-box,
.overview-map-card {
  background: rgba(22, 23, 26, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  box-shadow: none;
}

.drives-sidebar {
  max-height: none;
  min-height: 0;
  height: 100%;
}

.drive-cards-list,
.drive-overview-stage {
  min-height: 0;
}

.drive-cards-list {
  flex: 1;
  overflow: auto;
  padding: 10px;
  gap: 8px;
}

.drive-overview-stage {
  height: 100%;
  overflow: hidden;
  gap: 12px;
  padding: 2px 2px 4px 0;
  min-height: 0;
}

.section-header {
  padding: 14px 16px 12px;
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.section-title,
.segments-header,
.sedan-panel-title {
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--tesla-faint);
}

.overview-title {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.03em;
}

.overview-subtitle {
  font-size: 13px;
  font-weight: 400;
}

.overview-play-btn,
.play-btn {
  border: none;
  border-radius: 999px;
  background: #f4f4f5;
  color: #0b0b0c;
  box-shadow: none;
  font-weight: 600;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}

.overview-play-btn:hover,
.play-btn:hover {
  background: #ffffff;
  filter: none;
  box-shadow: none;
}

.overview-play-btn:active,
.play-btn:active,
.control-btn:active,
.export-btn:active {
  transform: scale(0.96);
}

.endpoints-row {
  gap: 10px;
}

.endpoint-card {
  padding: 14px 16px;
}

.overview-map-card {
  flex: 1 1 0;
  height: auto;
  min-height: 160px;
  overflow: hidden;
  background: #050506;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  overflow: hidden;
}

.metric-card {
  background: transparent;
  border: none;
  border-radius: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px 16px 16px;
}

.metric-card:last-child {
  border-right: none;
}

.metric-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tesla-faint);
}

.metric-val {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: -0.03em;
  margin-top: 4px;
}

.drive-card {
  border-radius: 14px;
  background: transparent;
  border-color: transparent;
  padding: 12px 12px 12px 14px;
}

.drive-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.drive-card.active {
  background: rgba(61, 168, 242, 0.08);
  border-color: transparent;
  box-shadow: inset 2px 0 0 var(--m-blue);
}

.drive-card-locations {
  background: transparent;
  border: none;
  padding: 0;
}

.btn-view-entire-drive {
  background: rgba(255, 255, 255, 0.06);
  border-color: transparent;
  border-radius: 999px;
  font-weight: 500;
}

.btn-view-entire-drive:hover {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.btn-play-clip {
  background: #f4f4f5;
  color: #0b0b0c;
  border-radius: 999px;
}

.btn-play-clip:hover {
  background: #ffffff;
}

.date-group-header {
  border-bottom: none;
  padding-top: 10px;
}

.playback-sidebar,
.playback-stage {
  min-height: 0;
  height: 100%;
}

.playback-sidebar {
  display: flex;
}

.sedan-panel-card {
  flex: 0 0 auto;
}

.live-map-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sedan-panel-header {
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.sedan-view-switchers {
  width: 100%;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.sedan-view-pill {
  flex: 1;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  padding: 6px 8px;
}

.sedan-view-pill.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: transparent;
  box-shadow: none;
}

.sedan-stage-wrapper {
  background: transparent;
  padding: 6px 0 12px;
}

.live-map-box {
  flex: 1;
  height: auto;
  min-height: 140px;
  border-radius: 0 0 18px 18px;
  background: #050506;
}

.player-stage {
  flex: 1;
  min-height: 0;
  height: 100%;
  border-radius: 20px;
  border-color: rgba(255, 255, 255, 0.06);
  background: var(--deck);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.canvas-viewport {
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: auto;
  background:
    radial-gradient(80% 70% at 50% 40%, #12141a 0%, #040507 72%);
}

.canvas-viewport::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background: linear-gradient(to bottom, transparent, var(--deck));
  pointer-events: none;
}

.cockpit-hud {
  background: transparent;
  border: none;
  padding: 2px 28px 0;
}

.hud-speed-val {
  font-size: 58px;
  font-weight: 300;
  letter-spacing: -0.045em;
}

.hud-speed-unit {
  font-weight: 500;
  letter-spacing: 0.12em;
  font-size: 11px;
}

.transport-panel {
  background: transparent;
  padding: 4px 22px 16px;
  gap: 10px;
}

.scrub-slider {
  height: 3px;
  background: rgba(255, 255, 255, 0.16);
}

.scrub-slider::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  background: #fff;
  box-shadow: none;
}

.timecode-display {
  font-family: "Segoe UI", ui-monospace, monospace;
  letter-spacing: 0.04em;
}

.control-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

.control-btn.play-btn {
  width: 52px;
  height: 52px;
  background: #f4f4f5;
  color: #0b0b0c;
  border: none;
}

.control-btn.play-btn:hover {
  background: #ffffff;
}

.export-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--tesla-ink);
  border-radius: 999px;
  box-shadow: none;
  font-weight: 500;
  padding: 8px 14px;
}

.export-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  filter: none;
}

.modal-sheet {
  border-radius: 20px;
  background: rgba(22, 23, 26, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.modal-title {
  font-weight: 400;
  letter-spacing: -0.02em;
}

.modal-primary-btn {
  background: #f4f4f5;
  color: #0b0b0c;
  border-radius: 999px;
  font-weight: 600;
}

.modal-primary-btn:hover {
  filter: none;
  background: #fff;
}

.drive-cards-list::-webkit-scrollbar,
.drive-overview-stage::-webkit-scrollbar {
  width: 8px;
}

.drive-cards-list::-webkit-scrollbar-thumb,
.drive-overview-stage::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-card:nth-child(3) {
    border-right: none;
  }

  .metric-card:nth-child(4),
  .metric-card:nth-child(5) {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .metric-card:nth-child(4) {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }
}

@media (max-width: 959px) {
  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .app-header {
    display: flex;
    height: 52px;
    padding: 0 12px;
  }

  .tab-view.active {
    display: block;
    overflow: visible;
    animation: none;
  }

  .recordings-grid,
  .playback-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    padding: 12px;
  }

  .drives-sidebar {
    max-height: 460px;
    height: auto;
  }

  .drive-overview-stage,
  .playback-stage,
  .playback-sidebar {
    height: auto;
    overflow: visible;
  }

  .overview-map-card {
    flex: none;
    height: 220px;
    min-height: 220px;
  }

  .canvas-viewport {
    aspect-ratio: 4 / 3;
    flex: none;
    min-height: 200px;
  }

  .canvas-viewport::after {
    height: 36px;
  }

  .player-stage {
    height: auto;
  }

  .live-map-box {
    height: 180px;
    flex: none;
  }

  .hud-speed-val {
    font-size: 40px;
  }

  .cockpit-hud {
    padding: 0 12px;
  }

  .playback-stage { order: 1; }
  .playback-sidebar { order: 2; }
}

@media (max-width: 640px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card,
  .metric-card:nth-child(3),
  .metric-card:nth-child(4),
  .metric-card:nth-child(5) {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .metric-card:nth-child(1),
  .metric-card:nth-child(2) {
    border-top: none;
  }

  .metric-card:nth-child(odd) {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }

  .metric-card:nth-child(even) {
    border-right: none;
  }

  .overview-title {
    font-size: 24px;
  }

  .endpoints-row {
    grid-template-columns: 1fr;
  }

  .hud-center {
    gap: 10px;
  }
}

/* ==============================================================================
   Brand Cluster & Eye Logo
   ============================================================================== */
.brand-cluster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  user-select: none;
}

.app-logo {
  width: 24px;
  height: 24px;
  max-height: 24px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

/* ==============================================================================
   Advanced Details Toggle & Debug Banner
   ============================================================================== */
.advanced-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--tesla-muted);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.advanced-toggle-label:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--tesla-ink);
}

.advanced-toggle-label input[type="checkbox"] {
  accent-color: #3da8f2;
  cursor: pointer;
  width: 13px;
  height: 13px;
  margin: 0;
}

.debug-banner {
  display: none;
  background: rgba(14, 16, 22, 0.96);
  border-bottom: 1px solid rgba(61, 168, 242, 0.35);
  color: #3da8f2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  padding: 8px 18px;
  line-height: 1.4;
  white-space: nowrap;
  overflow-x: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.debug-banner.visible {
  display: block !important;
}

/* ==============================================================================
   Blocking Video Loading & Decoding Modal
   ============================================================================== */
.loading-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  user-select: none;
}

.loading-modal-card {
  background: #12141a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 24px rgba(61, 168, 242, 0.25);
  animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.loading-spinner-ring {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #3da8f2;
  border-radius: 50%;
  animation: spinnerSpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spinnerSpin {
  to { transform: rotate(360deg); }
}

.loading-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}

.loading-modal-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

@media (max-width: 640px) {
  .advanced-toggle-text {
    display: none;
  }
  .loading-modal-card {
    margin: 0 16px;
    padding: 20px 24px;
  }
}


.hud-car-limit { display:flex; flex-direction:column; align-items:center; gap:3px; flex-shrink:0; }
.hud-limit-source { font-size:9px; line-height:1.1; text-align:center; color:var(--tesla-muted); }

.clip-row-raw { display:flex;align-items:center;justify-content:center;min-height:28px;padding:4px 7px;border:1px solid rgba(255,255,255,.16);border-radius:6px;color:var(--tesla-muted);font-size:10px;text-decoration:none;white-space:nowrap; }
.raw-recording-download { margin-top:16px;padding-top:14px;border-top:1px solid var(--tesla-line);text-align:center; }
.raw-recording-download a { color:var(--m-blue);font-size:13px; }
.raw-recording-download p { color:var(--tesla-muted);font-size:11px;line-height:1.5;margin:8px 0 0; }
