/* Modern Automotive Dark-Mode Stylesheet */
:root {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-surface: #334155;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --accent-emerald: #10B981;
  --accent-blue: #3B82F6;
  --accent-orange: #F97316;
  --accent-red: #EF4444;
  --border-color: rgba(255, 255, 255, 0.1);
  --font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Top Navigation Bar */
header {
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-badge {
  background: linear-gradient(135deg, #10B981, #3B82F6);
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg-surface);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748B;
}

.dot.online {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.dot.streaming {
  background: var(--accent-blue);
  box-shadow: 0 0 8px var(--accent-blue);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
}

/* Layout Workspace */
.app-container {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Sidebar Drawer */
aside.sidebar {
  width: 420px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 500;
  padding-bottom: 0;
}

.sidebar-scroll-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 12px;
}

.panel-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Form Controls */
.form-group {
  margin-bottom: 12px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

select, input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Profile Pills */
.profile-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-btn {
  background: var(--bg-primary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn:hover {
  border-color: var(--accent-blue);
  color: #fff;
}

.pill-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
  font-weight: 600;
}

/* Provider Toggles (Activation & Filtering) */
.provider-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.provider-toggle-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  min-height: 36px;
  box-sizing: border-box;
  touch-action: manipulation;
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.provider-toggle-card:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.provider-toggle-card input[type="checkbox"] {
  accent-color: var(--accent-emerald);
  cursor: pointer;
  width: 14px;
  height: 14px;
}

.provider-toggle-card.active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.5);
  color: var(--text-main);
}

.provider-toggle-card:not(.active) {
  opacity: 0.55;
  border-color: rgba(255, 255, 255, 0.08);
}

/* Primary Action Buttons */
.btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
}

.btn-emerald {
  background: #10B981;
  color: #fff;
}

.btn-emerald:hover {
  background: #059669;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  margin-top: 8px;
}

.btn-outline:hover {
  background: var(--bg-surface);
}

/* Simulation Action Bar */
.sim-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-sm {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: #fff;
  cursor: pointer;
}

.btn-sm:hover {
  background: var(--bg-surface);
}

.btn-danger {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.btn-warning {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.btn-warning:hover {
  background: rgba(249, 115, 22, 0.15);
}

/* Route Cards */
.route-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
  transition: all 0.2s;
}

.route-card.active-route {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.route-card.disabled-provider {
  display: none !important;
}

.disabled-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.disabled-notice {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  line-height: 1.4;
}

.route-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.provider-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.provider-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

.provider-tag.tmap { background: #E11D48; color: #fff; }
.provider-tag.naver { background: #059669; color: #fff; }
.provider-tag.kakao { background: #FACC15; color: #000; }
.provider-tag.google { background: #2563EB; color: #fff; }
.provider-tag.apple { background: #64748B; color: #fff; }

.rank-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-surface);
}

.rank-badge.top {
  background: var(--accent-emerald);
  color: #fff;
}

.route-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
  background: var(--bg-secondary);
  padding: 8px;
  border-radius: 6px;
  text-align: center;
}

.metric-item .val {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.metric-item .lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin: 8px 0;
  color: var(--text-muted);
}

.score-val {
  font-weight: 700;
  color: #38BDF8;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.card-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: #fff;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease-in-out;
}

.card-btn:hover {
  background: #475569;
}

.card-btn.start-guidance-btn {
  background: #10B981;
  border-color: #059669;
  color: #052E16;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.card-btn.start-guidance-btn:hover {
  background: #059669;
  color: #ffffff;
}

.card-btn.stop-guidance-btn {
  background: #EF4444;
  border-color: #DC2626;
  color: #ffffff;
  font-weight: 800;
}

.card-btn.stop-guidance-btn:hover {
  background: #DC2626;
}

.card-btn.select-route-btn {
  background: #1E293B;
  border-color: #334155;
  color: #CBD5E1;
}

.card-btn.select-route-btn:hover {
  background: #334155;
  color: #ffffff;
}

.card-btn.swap-btn {
  background: #2563EB;
  border-color: #1D4ED8;
  color: #ffffff;
}

.card-btn.swap-btn:hover {
  background: #1D4ED8;
}

.card-btn.handover-btn {
  flex: 0 0 auto;
  min-width: 82px;
  background: #0F172A;
  border-color: #334155;
  color: #94A3B8;
}

.card-btn.handover-btn:hover {
  background: #1E293B;
  color: #F8FAFC;
}

/* Guidance Mode Selector */
.guidance-mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.guidance-mode-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.guidance-mode-label input[type="radio"] {
  display: none;
}

.guidance-mode-label.active {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.15);
  color: #F8FAFC;
}

/* Map Canvas */
#map {
  flex: 1;
  height: 100%;
  background: #020617;
}

/* Turn-by-Turn HUD Overlay */
.hud-overlay {
  position: absolute;
  top: 16px;
  left: 440px;
  right: 20px;
  max-width: 500px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 1000;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.turn-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.hud-info {
  flex: 1;
  min-width: 0;
}

.hud-top-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 16px;
}

.hud-dist {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
}

.hud-instruction {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.hud-speed {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--accent-blue);
  white-space: nowrap;
}

.hud-speed-unit {
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 3px;
  color: var(--text-muted);
}

.hud-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: center;
  flex-shrink: 0;
}

.hud-side .hud-bearing,
.hud-side .hud-stop-btn {
  width: 100%;
  min-height: 34px;
  padding: 4px 10px;
  justify-content: center;
  box-sizing: border-box;
}

/* 1-Tap Hysteresis Split Card (NHTSA 2-Sec Rule) */
.switch-toast {
  position: absolute;
  bottom: 30px;
  left: 440px;
  right: 20px;
  max-width: 580px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
  backdrop-filter: blur(12px);
  border: 2px solid var(--accent-orange);
  border-radius: 14px;
  padding: 16px 20px;
  display: none;
  align-items: center;
  justify-content: space-between;
  z-index: 1100;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.switch-toast.show {
  display: flex;
}

.switch-text {
  flex: 1;
}

.switch-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-orange);
  margin-bottom: 4px;
}

.switch-desc {
  font-size: 0.85rem;
  color: var(--text-main);
}

.switch-actions {
  display: flex;
  gap: 10px;
  margin-left: 16px;
}

.switch-btn-confirm {
  background: var(--accent-orange);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.switch-btn-confirm:hover {
  background: #EA580C;
}

.switch-btn-dismiss {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

/* Handover Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-backdrop.show {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 480px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.code-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #38BDF8;
  word-break: break-all;
  margin: 10px 0;
}

.modal-close-btn {
  width: 100%;
  padding: 10px;
  background: var(--bg-surface);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* --- Naver Map Style Directions Input UI --- */
.naver-directions-box {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  gap: 10px;
  margin-top: 8px;
}

.dir-inputs-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dir-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dir-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.origin-badge {
  background: #10B981;
  color: #fff;
}

.dest-badge {
  background: #EF4444;
  color: #fff;
}

.input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.dir-input {
  width: 100%;
  padding: 8px 38px 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
}

.dir-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: #1E293B;
}

.btn-clear {
  position: absolute;
  right: 2px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  min-width: 36px;
  min-height: 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  line-height: 1;
}

.btn-clear:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.dir-connector-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: 14px;
  height: 12px;
}

.connector-stem {
  width: 2px;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
}

.btn-swap-od {
  min-width: 36px;
  min-height: 36px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-swap-od:hover {
  background: var(--bg-surface);
  color: #fff;
  border-color: var(--accent-blue);
}

.btn-swap-od:active {
  transform: scale(0.95);
}

/* --- Collapsible MCDM Profile Details/Summary Styling --- */
details.collapsible-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
}

details.collapsible-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  font-size: 0.82rem;
  color: var(--text-muted);
  user-select: none;
}

details.collapsible-section summary::-webkit-details-marker {
  display: none;
}

details.collapsible-section summary .chevron-icon {
  font-size: 0.7rem;
  transition: transform 0.2s;
}

details.collapsible-section[open] summary .chevron-icon {
  transform: rotate(180deg);
}

/* --- Bottom Collapsible Provider Drawer --- */
.bottom-provider-drawer {
  position: relative;
  margin: 12px 20px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.provider-drawer-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--bg-secondary);
}

.provider-drawer-summary::-webkit-details-marker {
  display: none;
}

.drawer-summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.drawer-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.bottom-provider-drawer[open] .drawer-chevron {
  transform: rotate(180deg);
}

.provider-drawer-content {
  padding: 8px 16px 14px 16px;
  background: var(--bg-primary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Mobile Responsive Optimization */
@media (max-width: 768px) {
  body {
    position: relative;
    height: 100vh;
    overflow: hidden;
  }

  .app-container {
    flex-direction: column;
    position: relative;
    height: 100vh;
  }

  #map {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
  }

  aside.sidebar {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 48vh;
    background: rgba(30, 41, 59, 0.94);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 500;
    overflow: hidden;
  }

  .hud-overlay {
    left: 12px !important;
    right: 12px !important;
    top: 12px !important;
    max-width: none !important;
  }

  .switch-toast {
    left: 12px !important;
    right: 12px !important;
    bottom: 60px !important;
    max-width: none !important;
  }

  .modal-content {
    width: calc(100vw - 32px) !important;
    max-width: 480px;
    padding: 16px;
  }
}

@media (max-width: 640px) {
  header {
    height: auto;
    min-height: 50px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .brand {
    font-size: 0.95rem;
    gap: 8px;
  }
  .system-status {
    gap: 8px;
    font-size: 0.75rem;
  }
}

@media (max-width: 400px) {
  .naver-directions-box {
    padding: 8px 10px;
    gap: 6px;
  }

  .dir-input {
    font-size: 0.82rem;
    padding: 6px 38px 6px 8px;
  }
  .origin-row .dir-input { padding-right: 106px; }

  .btn-swap-od {
    min-width: 36px;
    min-height: 36px;
    width: 38px;
    height: 38px;
  }

  .provider-drawer-summary {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}

/* --- M2: Unified POI Autocomplete --- */
.poi-autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1200;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
}
.poi-item {
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.poi-item:last-child { border-bottom: none; }
.poi-item:hover, .poi-item:active { background: var(--bg-surface); }
.poi-item-title { font-size: 0.88rem; font-weight: 600; color: var(--text-main); }
.poi-item-addr { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }
.poi-item-badges { display: flex; gap: 4px; margin-top: 4px; }
.poi-item-empty { padding: 12px; font-size: 0.8rem; color: var(--text-muted); text-align: center; }

/* --- M3: Driving mode (full-screen map, Heading-Up) --- */
.app-container.driving-mode #map {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}
.app-container.driving-mode .hud-overlay {
  left: 16px;
  right: 16px;
  margin: 0 auto;
}
.app-container.driving-mode .leaflet-map-pane { transition: transform 0.35s ease-out; }
.hud-bearing {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: rgba(30, 41, 59, 0.85);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.hud-bearing:hover, .hud-bearing:active {
  background: var(--bg-surface);
  border-color: var(--accent-blue);
}
.hud-bearing-mode {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}
.hud-bearing.north-up .hud-bearing-mode {
  background: rgba(59, 130, 246, 0.22);
  color: #60A5FA;
}
.vehicle-arrow {
  display: inline-block;
  transition: transform 0.3s ease-out;
  line-height: 1;
}
.drawer-reroute-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}
.drawer-reroute-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.drawer-reroute-select {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 36px;
  cursor: pointer;
}
.hud-stop-btn {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent-red);
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.switch-toast { z-index: 1500; }
.switch-btn-confirm, .switch-btn-dismiss { min-height: 44px; touch-action: manipulation; }

/* --- Current Location Buttons (Origin Row & Map Floating Button) --- */
.btn-locate-origin {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  height: 28px;
  background: rgba(16, 185, 129, 0.16);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  margin: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}
.origin-row .dir-input { padding-right: 112px; }
.btn-locate-origin:hover {
  background: rgba(16, 185, 129, 0.28);
  border-color: #10B981;
}

/* --- Leaflet "My Location" control (bottom-right, layout independent) --- */
:root { --dock-h: 52px; }
.locate-control.leaflet-bar { border: none; margin: 0 12px 16px 0; }
.locate-control a.locate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #10B981;
  border: 1px solid rgba(15, 23, 42, 0.18);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  opacity: 0.92;
}
.locate-control a.locate-btn:hover { background: #fff; border-color: #10B981; opacity: 1; }
.locate-control a.locate-btn.busy { opacity: 0.6; pointer-events: none; }

/* --- Collapsible destination card (sidebar handle) --- */
.sidebar-handle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  color: var(--text-main);
  border: none;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  flex-shrink: 0;
}
.sidebar-handle .handle-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1rem;
  flex-shrink: 0;
}
.sidebar-handle .handle-title-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-width: 0;
}
.sidebar-handle .handle-brand {
  font-size: 0.88rem;
  font-weight: 800;
  color: #F8FAFC;
  line-height: 1.2;
  white-space: nowrap;
}
.sidebar-handle .handle-summary {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-handle .handle-summary:empty {
  display: none;
}
aside.sidebar.sidebar-collapsed > *:not(.sidebar-handle) { display: none !important; }
aside.sidebar.sidebar-collapsed { overflow: hidden; }
aside.sidebar.sidebar-collapsed .sidebar-handle { border-bottom: none; }

/* Driving mode (desktop): card becomes a collapsible overlay panel over the full-screen map */
.app-container.driving-mode { position: relative; }
.app-container.driving-mode aside.sidebar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 380px;
  max-height: 70vh;
  overflow: hidden;
  z-index: 600;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.app-container.driving-mode aside.sidebar.sidebar-collapsed { width: 360px; }

@media (max-width: 768px) {
  /* Bottom docked sheet (collapsed = handle bar only) */
  aside.sidebar,
  .app-container.driving-mode aside.sidebar {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 60vh;
    border-radius: 14px 14px 0 0;
    border-bottom: none;
  }
  .app-container.driving-mode aside.sidebar.sidebar-collapsed { width: auto; }
  .locate-control.leaflet-bar { margin-bottom: calc(var(--locate-offset, 0px) + 16px); }
  .switch-toast { bottom: calc(var(--dock-h) + 16px) !important; }
}

/* --- Compact status badges inside the card handle --- */
.sidebar-handle .handle-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}
.sidebar-handle .handle-status .status-badge {
  padding: 2px 8px;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
/* Desktop (non-driving): card is a fixed sidebar, so the chevron is only shown when collapsible */
@media (min-width: 769px) {
  .app-container:not(.driving-mode) .sidebar-handle { cursor: default; }
  .app-container:not(.driving-mode) .sidebar-handle .handle-chevron { display: none; }
}
