/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  /* Neutrals (Apple-style cool greys) */
  --slate-950: #0B0B0F;
  --slate-900: #1C1C1E;
  --slate-800: #2C2C2E;
  --slate-700: #3A3A3C;
  --slate-600: #48484A;
  --slate-500: #8E8E93;
  --slate-400: #AEAEB2;
  --slate-300: #C7C7CC;
  --slate-200: #E5E5EA;
  --slate-100: #F2F2F7;
  --slate-50:  #FBFBFD;

  /* Accent: iOS system blue */
  --blue-700: #0040DD;
  --blue-600: #0A84FF;
  --blue-500: #0A84FF;
  --blue-400: #409CFF;
  --blue-200: #B6DCFF;
  --blue-100: #E1F0FF;
  --blue-50:  #F0F7FF;

  --green-700: #248A3D;
  --green-600: #30D158;
  --green-100: #DCFCE7;
  --green-50:  #F0FDF4;

  --amber-600: #FF9F0A;
  --amber-100: #FEF3C7;

  --red-700: #D70015;
  --red-600: #FF3B30;
  --red-100: #FFE5E3;
  --red-50:  #FFF1F0;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Softer, deeper shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10);
  --shadow-float: 0 8px 30px rgba(0,0,0,0.12);

  /* Larger radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* Frosted glass surface */
  --glass-bg: rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.5);

  --transition: 200ms cubic-bezier(0.32, 0.72, 0, 1);
  --spring: 380ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* ===== RESET ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

/* ===== BASE ===== */
body {
  font-family: var(--font-sans);
  font-size: clamp(0.84rem, 0.78rem + 0.25vw, 0.95rem);
  line-height: 1.5;
  background: var(--slate-50);
  color: var(--slate-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===== HEADER ===== */
.header {
  background: var(--glass-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  padding: 0 20px;
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--slate-200);
  gap: 16px;
}

.header h1 {
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.2rem);
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.header h1::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--blue-500);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  margin-bottom: 1px;
}

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

.search-box {
  display: flex;
  gap: 6px;
}

.search-box input {
  width: 200px;
  padding: 9px 14px;
  background: var(--slate-100);
  color: var(--slate-900);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  transition: all var(--transition);
}

.search-box input::placeholder {
  color: var(--slate-500);
}

.search-box input:focus {
  outline: none;
  background: #fff;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 4px var(--blue-50);
}

.search-box button {
  padding: 9px 18px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.search-box button:hover {
  background: var(--blue-700);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== MAP PANEL ===== */
.map-panel {
  width: clamp(320px, 38%, 560px);
  position: relative;
  border-right: 1px solid var(--slate-200);
  flex-shrink: 0;
}

#map {
  width: 100%;
  height: 100%;
}

/* Map zoom controls */
.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1000;
}

.map-controls button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: var(--slate-800);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 1.25rem;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}

.map-controls button:hover {
  background: rgba(255,255,255,0.9);
  border-color: var(--slate-300);
  color: var(--slate-900);
}

.map-controls button svg {
  width: 16px;
  height: 16px;
}

/* ===== ROUTE CONTROLS OVERLAY ===== */
.route-controls-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-toolbar {
  display: flex;
  gap: 4px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-md);
}

.route-select {
  padding: 7px 10px;
  background: transparent;
  color: var(--slate-600);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.6875rem;
  font-family: var(--font-sans);
  font-weight: 500;
  max-width: 120px;
  transition: all var(--transition);
}

.route-select:hover {
  background: var(--slate-50);
  border-color: var(--slate-200);
  color: var(--slate-900);
}

.route-select:focus {
  outline: none;
  border-color: var(--blue-400);
}

.route-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 10px;
  background: transparent;
  color: var(--slate-600);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.6875rem;
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1;
  min-width: 52px;
}

.route-btn .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-500);
  transition: color var(--transition);
}

.route-btn .icon svg {
  width: 16px;
  height: 16px;
}

.route-btn:hover:not(:disabled) {
  background: var(--slate-50);
  border-color: var(--slate-200);
  color: var(--slate-900);
}

.route-btn:hover:not(:disabled) .icon {
  color: var(--slate-700);
}

.route-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.route-btn.active {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
}

.route-btn.active .icon {
  color: var(--blue-600);
}

.route-btn.danger:hover:not(:disabled) {
  background: var(--red-50);
  border-color: var(--red-100);
  color: var(--red-600);
}

.route-btn.danger:hover:not(:disabled) .icon {
  color: var(--red-600);
}

/* Route hint bar */
.route-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--blue-200);
  border-left: 3px solid var(--blue-600);
  border-radius: var(--radius-md);
  color: var(--slate-700);
  font-size: 0.8125rem;
  box-shadow: var(--shadow-sm);
}


.cancel-btn {
  padding: 4px 10px;
  background: var(--red-50);
  color: var(--red-600);
  border: 1px solid var(--red-100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.cancel-btn:hover {
  background: var(--red-100);
  border-color: var(--red-600);
}

/* Route info overlay (bottom-left of map) */
.route-info-overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 1000;
  background: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-md);
}


.route-info-content {
  display: flex;
  gap: 18px;
}

.route-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.route-stat .label {
  font-size: 0.6875rem;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.route-stat span:not(.label) {
  font-size: 0.875rem;
  color: var(--slate-900);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ===== STREET VIEW PANEL ===== */
.street-view-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--slate-950);
  min-width: 0;
}

#mapillary-viewer {
  flex: 1;
  position: relative;
  background: var(--slate-950);
  min-height: 0;
}


.placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--slate-600);
  padding: 24px;
  max-width: 340px;
}

.placeholder p {
  margin-bottom: 8px;
  font-size: 0.9375rem;
  color: var(--slate-400);
  line-height: 1.6;
}

.placeholder .hint {
  font-size: 0.8125rem;
  color: var(--slate-600);
}

/* ===== USER PHOTO VIEWER ===== */
.user-photo-viewer {
  flex: 1;
  position: relative;
  background: var(--slate-950);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}


.user-photo-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.photo-info-overlay {
  display: none;
}

/* ===== NAVIGATION CONTROLS ===== */
.nav-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid var(--slate-200);
  flex-shrink: 0;
  gap: 12px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: #fff;
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  font-weight: 500;
  min-width: 90px;
  justify-content: center;
}

.nav-btn:hover:not(:disabled) {
  background: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--slate-900);
}

.nav-btn:active:not(:disabled) {
  background: var(--slate-100);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-btn .arrow {
  font-size: 0.875rem;
  color: var(--slate-400);
}

.nav-info {
  color: var(--slate-500);
  font-size: 0.8125rem;
  flex: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ===== ROUTE PROGRESS BAR ===== */
.route-progress-container {
  padding: 6px 16px;
  background: #fff;
  border-top: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}


.progress-bar-wrapper {
  flex: 1;
  height: 5px;
  background: var(--slate-100);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--blue-600);
  border-radius: var(--radius-pill);
  transition: width var(--transition);
}

.route-progress-info {
  color: var(--slate-400);
  font-size: 0.75rem;
  min-width: 70px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ===== PLAYBACK CONTROLS ===== */
.playback-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--slate-50);
  border-top: 1px solid var(--slate-200);
  flex-shrink: 0;
  gap: 16px;
}


.follow-route-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  background: var(--green-600);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition);
  font-weight: 500;
  font-size: 0.8125rem;
  font-family: var(--font-sans);
}

.follow-route-btn:hover:not(:disabled) {
  background: var(--green-700);
}

.follow-route-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.follow-route-btn.following {
  background: var(--amber-600);
}

.follow-route-btn.following:hover:not(:disabled) {
  background: #b45309;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--slate-500);
}

.speed-control label {
  font-size: 0.8125rem;
  white-space: nowrap;
}

#speed-slider {
  width: 90px;
  cursor: pointer;
  accent-color: var(--blue-600);
}

#speed-value {
  min-width: 34px;
  color: var(--slate-700);
  font-weight: 500;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* ===== INFO PANEL ===== */
.info-panel {
  position: fixed;
  right: 0;
  top: 56px;
  width: clamp(260px, 24vw, 360px);
  height: calc(100vh - 56px);
  background: #fff;
  border-left: 1px solid var(--slate-200);
  padding: 0;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--spring);
  z-index: 1001;
  box-shadow: var(--shadow-lg);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
}

.info-panel.visible {
  transform: translateX(0);
}

.info-panel h3 {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--slate-100);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.route-info-panel {
  padding: 12px 16px;
  border-bottom: 1px solid var(--slate-100);
}

.route-info-panel .no-route {
  color: var(--slate-400);
  font-size: 0.8125rem;
}

.route-info-panel .route-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.route-info-panel .route-detail {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8125rem;
}

.route-info-panel .route-detail .label {
  color: var(--slate-500);
}

.route-info-panel .route-detail .value {
  color: var(--slate-900);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Route images list */
.route-images-list {
  border-bottom: 1px solid var(--slate-100);
}


.route-images-list h4 {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 16px 6px;
}

#route-images-container {
  max-height: 180px;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.route-image-item {
  padding: 6px 8px;
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--slate-700);
}

.route-image-item:hover {
  background: var(--slate-50);
  color: var(--slate-900);
}

.route-image-item.active {
  background: var(--blue-50);
  color: var(--blue-700);
}

.route-image-item .index {
  color: var(--slate-400);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.route-image-item.active .index {
  color: var(--blue-400);
}

/* Sequence list */
.sequence-list {
  padding: 0 8px 12px;
  max-height: 280px;
  overflow-y: auto;
}

.sequence-list .no-sequence {
  color: var(--slate-400);
  font-size: 0.8125rem;
  padding: 8px;
}

.sequence-item {
  padding: 6px 8px;
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.8rem;
  color: var(--slate-600);
  font-family: var(--font-mono);
}

.sequence-item:hover {
  background: var(--slate-50);
  color: var(--slate-900);
}

.sequence-item.active {
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 500;
}

/* ===== TOGGLE INFO PANEL BUTTON ===== */
.toggle-info-btn {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 1200;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: var(--blue-600);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
  cursor: pointer;
  font-size: 1.1rem;
  font-family: var(--font-sans);
  transition: all var(--transition);
}

.toggle-info-btn:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--slate-700);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  gap: 14px;
}


.loading-overlay p {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  animation: slideUp 0.2s ease;
  box-shadow: var(--shadow-lg);
  border: 1px solid transparent;
  max-width: 360px;
  text-align: center;
}

.toast.success {
  background: var(--green-600);
}

.toast.error {
  background: var(--red-600);
}

.toast.info {
  background: var(--slate-800);
  border-color: var(--slate-700);
}

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

/* ===== MAP MARKERS ===== */
.current-location-marker {
  width: 14px;
  height: 14px;
  background: var(--blue-600);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.25);
}

.route-start-marker {
  width: 22px;
  height: 22px;
  background: var(--green-600);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-sans);
}

.route-end-marker {
  width: 22px;
  height: 22px;
  background: var(--red-600);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-sans);
}

/* ===== MAPILLARY VIEWER ===== */
.mapillary-js {
  width: 100% !important;
  height: 100% !important;
}

/* Drawing mode cursor */
.map-drawing-mode {
  cursor: crosshair !important;
}

/* ===== MOTION & MICRO-INTERACTIONS ===== */
@keyframes lt-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lt-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* Ensure transform participates in the easing for press feedback */
.route-btn, .follow-route-btn, .search-box button { transition: all var(--transition); }
.line-capsule { transition: transform var(--transition); }

/* Press feedback — gentle scale-down on tap/click */
.route-btn:active:not(:disabled),
.nav-btn:active:not(:disabled),
.follow-route-btn:active:not(:disabled),
.search-box button:active,
.map-controls button:active,
.toggle-info-btn:active {
  transform: scale(0.95);
}
.line-capsule:active { transform: translateX(-50%) scale(0.97); } /* preserve horizontal centering */

/* Hover lift — only on devices with a real pointer (desktop) */
@media (hover: hover) and (pointer: fine) {
  .follow-route-btn:hover:not(:disabled),
  .search-box button:hover,
  .map-controls button:hover {
    transform: translateY(-1px);
  }
}

/* Gentle entrance for the mobile chrome */
@media (max-width: 768px) {
  .line-capsule { animation: lt-fade var(--spring) both; }
  .sv-controls { animation: lt-rise var(--spring) both; }
}

/* ===== MOBILE NAVIGATOR ELEMENTS (hidden on desktop) ===== */
.line-capsule { display: none; }
.sheet-grabber { display: none; }
.map-sheet-backdrop { display: none; }
.sv-controls { display: contents; } /* transparent to layout on desktop */

/* Honor reduced-motion: drop sheet/spring animations + press/entrance motion */
@media (prefers-reduced-motion: reduce) {
  .map-panel, .info-panel, .map-sheet-backdrop, .progress-bar { transition: none !important; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .route-btn:active, .nav-btn:active, .follow-route-btn:active,
  .search-box button:active, .map-controls button:active, .toggle-info-btn:active { transform: none !important; }
  .line-capsule:active { transform: translateX(-50%) !important; } /* keep centering, drop scale */
}

/* ===== RESPONSIVE: TABLET (keep stacked, restyled) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
  .main-content { flex-direction: column; }
  .map-panel { width: 100%; height: 42%; border-right: none; border-bottom: 1px solid var(--slate-200); }
  .street-view-panel { width: 100%; height: 58%; }
  .info-panel { width: 100%; height: 50vh; top: auto; bottom: 0; transform: translateY(100%); }
  .info-panel.visible { transform: translateY(0); }
}

/* ===== RESPONSIVE: MOBILE NAVIGATOR (<=768px) ===== */
@media (max-width: 768px) {
  .container { height: 100dvh; }
  .header { display: none; } /* search moves into the map sheet */

  .main-content { position: relative; flex-direction: column; height: 100%; }

  /* Street-view is the fullscreen hero */
  .street-view-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
  }

  /* Top frosted capsule */
  .line-capsule {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1300;
    max-width: 80vw;
    padding: 10px 18px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-float);
    color: var(--slate-900);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 44px;
  }
  #line-capsule-text { overflow: hidden; text-overflow: ellipsis; }
  .line-capsule-chevron { color: var(--slate-400); font-size: 0.75rem; }

  /* Map panel becomes a corner PiP */
  .map-panel {
    position: fixed;
    right: 14px;
    bottom: 150px;
    width: 116px;
    height: 116px;
    border: 2px solid #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-float);
    z-index: 1200;
    transition: right var(--spring), bottom var(--spring), width var(--spring), height var(--spring), border-radius var(--spring);
  }
  #map { width: 100%; height: 100%; }

  /* In PiP state hide overlay tools & in-map controls */
  .map-panel:not(.expanded) .route-controls-overlay,
  .map-panel:not(.expanded) .map-controls,
  .map-panel:not(.expanded) .route-info-overlay { display: none; }

  /* Expanded = bottom sheet */
  .map-panel.expanded {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 78dvh;
    border: none;
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    z-index: 1400;
  }
  .map-panel.expanded #map { height: 56%; border-bottom: 1px solid var(--slate-200); }

  .map-panel.expanded .sheet-grabber {
    display: block;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 5px;
    border-radius: var(--radius-pill);
    background: var(--slate-300);
    z-index: 1500;
  }

  /* In expanded state, lay tools out as a readable stack at the bottom of the sheet */
  .map-panel.expanded .route-controls-overlay {
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 44%;
    overflow-y: auto;
    padding: 14px;
    background: #fff;
    z-index: 1450;
  }
  .map-panel.expanded .route-toolbar {
    flex-wrap: wrap;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    gap: 8px;
  }
  .map-panel.expanded .route-btn,
  .map-panel.expanded .route-select {
    flex: 1 1 28%;
    min-height: 64px;
    border: 1px solid var(--slate-200);
    background: var(--slate-50);
    border-radius: var(--radius-md);
  }
  .map-panel.expanded .map-controls { display: flex; }

  /* Search relocated into the sheet by JS (#search-input/#search-btn) */
  .map-panel.expanded .search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
  }
  .map-panel.expanded .search-box input { flex: 1; width: auto; }

  /* Dim backdrop behind the sheet */
  .map-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 1350;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }
  .map-sheet-backdrop.visible { opacity: 1; pointer-events: auto; }

  /* Bottom mini-player */
  .sv-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 1250;
    padding: 10px 12px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-float);
  }
  .sv-controls .nav-controls,
  .sv-controls .playback-controls {
    background: transparent;
    border: none;
    padding: 0;
  }
  .sv-controls .route-progress-container {
    background: transparent;
    border: none;
    padding: 0;
  }
  .nav-btn { min-width: 0; flex: 1; min-height: 44px; }
  .playback-controls { flex-direction: row; gap: 8px; align-items: center; }
  .follow-route-btn { flex: 1; min-height: 44px; }
  .speed-control { display: flex; align-items: center; gap: 8px; }
  .speed-control label { display: none; } /* compact: slider + value only */

  /* Info panel as bottom drawer */
  .info-panel {
    width: 100%; height: 60dvh;
    top: auto; bottom: 0;
    transform: translateY(100%);
    z-index: 1450;
  }
  .info-panel.visible { transform: translateY(0); }
  .toggle-info-btn { top: max(12px, env(safe-area-inset-top)); right: 14px; z-index: 1360; }
}
