/* Public interface only. ID scope isolates it from the shared administration styles. */
body.is-public-map-open {
  --ui-surface: #1c2420;
  --ui-raised: #29332d;
  --ui-line: rgba(255, 255, 255, 0.12);
  --ui-text: #f1f5f2;
  --ui-muted: #b5c2b9;
  font-family: "Segoe UI", system-ui, sans-serif;
}

#mapView {
  font-size: 15px;
  line-height: 1.5;
}

#mapView .ui-icon {
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#mapView :is(button, a, input, [role="button"]):focus-visible {
  outline: 2px solid #b8efc2 !important;
  outline-offset: 3px !important;
}

#mapView button { touch-action: manipulation; }
#mapView button:disabled { opacity: .45; cursor: default; }

#mapView .map-edge-controls {
  top: max(16px, env(safe-area-inset-top)) !important;
  left: max(16px, env(safe-area-inset-left)) !important;
}

body.is-public-map-panel-fullscreen #mapView .map-edge-controls { z-index: 75; }

#mapView .map-round-button {
  display: grid;
  place-content: center;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  border-radius: 13px !important;
  color: #f1f8f2 !important;
  box-shadow: 0 4px 14px #10261930 !important;
}

#mapView .map-schedules-control {
  position: fixed;
  z-index: 70;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
}

#mapView .map-favorites-control {
  top: calc(max(16px, env(safe-area-inset-top)) + 54px) !important;
  right: max(16px, env(safe-area-inset-right)) !important;
}

body.is-public-map-panel-open #mapView .map-schedules-control,
body.is-map-drawer-open #mapView .map-schedules-control { display: none; }

#mapView .map-side-drawer {
  width: min(280px, calc(100dvw - 48px));
  padding: max(18px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  gap: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 0 20px 20px 0;
  box-shadow: 12px 0 36px #0003;
}

#mapView .map-drawer-brand { gap: 10px; padding: 0 4px; }
#mapView .map-drawer-brand strong { font-size: 17px; font-weight: 700; }
#mapView .map-drawer-brand span { font-size: 12px; font-weight: 400; }
#mapView .map-drawer-logo { flex: 0 0 42px; }
#mapView .map-drawer-brand .ui-icon-button { margin-left: auto; }

#mapView .ui-icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #ffffff12;
  color: inherit;
  font: 28px/1 "Segoe UI", sans-serif;
  cursor: pointer;
}

#mapView .map-drawer-nav { gap: 6px; }
#mapView .map-drawer-nav button,
#mapView .map-drawer-footer a {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  gap: 12px;
  font-size: 15px;
  font-weight: 500;
}

#mapView .map-drawer-nav button.is-active { font-weight: 650; }
#mapView .map-drawer-footer a { font-size: 12px; overflow-wrap: anywhere; }
#mapView .map-drawer-footer .ui-icon { width: 18px; height: 18px; flex-basis: 18px; }

#mapView .public-map-panel {
  color: var(--ui-text) !important;
  font-size: 15px !important;
  border: 1px solid var(--ui-line) !important;
}

/* Keep headers fixed while their content scrolls, including short landscape screens. */
#mapView .public-map-panel .map-panel-body {
  min-width: 0;
  min-height: 0 !important;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #7f9184 transparent;
}

#mapView .map-panel-head h2 {
  font-weight: 650 !important;
  line-height: 1.35 !important;
  letter-spacing: -.015em;
}

#mapView .map-panel-head .eyebrow:empty { display: none; }
#mapView :is(h1, h2)[tabindex="-1"]:focus { outline: none; }

#mapView #mapPanelCloseButton {
  display: grid !important;
  place-items: center !important;
  flex: 0 0 44px;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: #ffffff10 !important;
  color: var(--ui-text) !important;
  font: 28px/1 "Segoe UI", sans-serif !important;
}

#mapView #mapPanelCloseButton::before,
#mapView #mapPanelCloseButton::after { content: none !important; }

#mapView .public-map-panel.is-fullscreen:not(.is-blog-panel) {
  padding: max(18px, env(safe-area-inset-top)) 24px 0 !important;
  background: var(--ui-surface) !important;
}

#mapView .public-map-panel.is-fullscreen:not(.is-blog-panel) .map-panel-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between;
  min-height: 52px !important;
  width: min(960px, 100%);
  margin: 0 auto 20px !important;
  padding: 0 0 12px 54px !important;
  border-bottom: 1px solid var(--ui-line) !important;
}

#mapView .public-map-panel.is-fullscreen .map-panel-head h2 { font-size: 22px !important; }
#mapView .public-map-panel.is-fullscreen:not(.is-blog-panel) .map-panel-body {
  width: min(960px, 100%);
  margin: 0 auto !important;
  padding: 0 2px max(24px, env(safe-area-inset-bottom)) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  gap: 20px !important;
}

/* The line chooser fills the screen; route details keep the glass bottom panel. */
#mapView .public-map-panel.is-fullscreen.is-schedules-panel {
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)) !important;
  border: 0 !important;
  background: #211c1d !important;
  color: #dedadb !important;
  font-family: Arial, sans-serif;
}

#mapView .public-map-panel.is-fullscreen.is-schedules-panel .map-panel-head {
  width: 100%;
  min-height: 60px !important;
  margin: 0 !important;
  padding: 0 0 0 44px !important;
  border: 0 !important;
}

#mapView .public-map-panel.is-fullscreen.is-schedules-panel .map-panel-head::after { content: none !important; }
#mapView .public-map-panel.is-fullscreen.is-schedules-panel .map-panel-head h2 {
  margin: 0 !important;
  color: inherit !important;
  font-size: 20px !important;
  font-weight: 700 !important;
  letter-spacing: 0;
}

#mapView .public-map-panel.is-fullscreen.is-schedules-panel #mapPanelCloseButton { display: none !important; }
#mapView:has(.public-map-panel.is-fullscreen.is-schedules-panel:not([hidden])) .map-edge-controls {
  top: calc(env(safe-area-inset-top) + 8px) !important;
  left: calc(max(16px, env(safe-area-inset-left)) - 6px) !important;
}

#mapView:has(.public-map-panel.is-fullscreen.is-schedules-panel:not([hidden])) #mapMenuButton .menu-line {
  width: 18px !important;
  height: 2px !important;
  background: #dedadb !important;
}

#mapView .public-map-panel.is-fullscreen.is-schedules-panel .map-panel-body {
  width: 100%;
  margin: 0 !important;
  padding: 2px 0 max(24px, env(safe-area-inset-bottom)) !important;
  gap: 8px !important;
}

#mapView .is-schedules-panel .public-line-search { position: relative; width: 100%; margin: 0 !important; }
#mapView .is-schedules-panel .public-line-search input {
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 16px 0 46px;
  border: 0 !important;
  border-radius: 999px !important;
  color: #dedadb !important;
  background: #352f31 !important;
  font-family: inherit;
  font-size: 16px !important;
  font-weight: 400 !important;
}

#mapView .is-schedules-panel .public-line-search input::placeholder { color: #a29b9d; opacity: 1; }
#mapView .is-schedules-panel .public-line-search span { width: 13px; height: 13px; border-color: #dedadb; }
#mapView .is-schedules-panel .public-line-search span::after { width: 7px; right: -5px; bottom: -3px; background: #dedadb; }
#mapView .is-schedules-panel .public-line-grid {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px !important;
  width: 100% !important;
  margin: 0 !important;
}

#mapView .is-schedules-panel .public-line-button {
  flex: 0 0 auto;
  width: 80px;
  min-width: 80px !important;
  min-height: 30px !important;
  gap: 6px;
  border: 0 !important;
  border-radius: 14px !important;
  padding: 4px 8px !important;
  background: var(--line-color) !important;
  color: #e5e2e3;
  font: 700 18px/22px Arial, sans-serif;
}

#mapView .is-schedules-panel .public-line-button span { font: inherit; }
#mapView .is-schedules-panel .public-line-button .line-badge-icon { width: 14px; height: 16px; flex: 0 0 14px; background: currentColor; }

@media (pointer: coarse) {
  #mapView .is-schedules-panel .public-line-button { min-height: 40px !important; }
}

#mapView .map-settings-stack { width: min(640px, 100%); margin-inline: auto; gap: 16px !important; }
#mapView .map-settings-section {
  padding: 20px !important;
  border: 1px solid var(--ui-line) !important;
  border-radius: 16px !important;
  background: var(--ui-raised) !important;
}

#mapView .map-settings-section h3 { font-size: 16px; font-weight: 650; margin-bottom: 12px; }
#mapView .map-settings-options { gap: 4px; }
#mapView .map-settings-section .check-row { min-height: 44px; gap: 12px; font-size: 15px; font-weight: 400; color: var(--ui-text); }
#mapView .map-settings-section .check-row input { width: 20px; height: 20px; min-height: 20px; flex: 0 0 20px; }
#mapView .map-settings-actions button { font-weight: 600; border-radius: 12px; }

#mapView .public-map-panel.is-bottom {
  --bottom-panel-edge: 16px;
  --bottom-panel-icon-size: 36px;
  --bottom-panel-icon-gap: 8px;
  width: min(600px, calc(100dvw - 32px)) !important;
  max-width: calc(100dvw - 32px) !important;
  height: var(--panel-height, min(46dvh, 440px)) !important;
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top))) !important;
  padding-inline: var(--bottom-panel-edge) !important;
  /* One translucent surface shared by stops, courses and favorites. */
  background: rgba(29, 29, 27, .64) !important;
  -webkit-backdrop-filter: blur(24px) saturate(120%) !important;
  backdrop-filter: blur(24px) saturate(120%) !important;
  border: 0 !important;
  border-radius: 16px 16px 0 0 !important;
  box-shadow: 0 12px 40px #0003, inset 0 1px 0 #ffffff0d !important;
}

#mapView .public-map-panel.is-bottom > .map-panel-grip { height: 12px !important; }
#mapView .public-map-panel.is-bottom > .map-panel-grip::before { width: 36px !important; height: 4px !important; box-shadow: none !important; }
#mapView .public-map-panel.is-bottom .map-panel-head {
  min-height: 44px !important;
  margin-bottom: 0 !important;
  padding-bottom: 8px !important;
}
#mapView .public-map-panel.is-bottom .map-panel-head::after {
  content: "" !important;
  display: block !important;
  bottom: 0 !important;
  height: 1px !important;
  background: #0000001f !important;
  box-shadow: 0 2px 5px #00000014;
}
#mapView .public-map-panel.is-bottom .map-panel-head h2 { min-height: 36px !important; font-size: 16px !important; line-height: 1.25 !important; font-weight: 700 !important; }
#mapView .public-map-panel.is-bottom #mapPanelCloseButton,
#mapView .public-map-panel.is-bottom :is(.favorite-stop-button, .vehicle-icon-button, .line-direction-button, .line-loop-indicator) {
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  border-radius: 50% !important;
  background: rgba(44, 41, 46, .56) !important;
}
#mapView .public-map-panel.is-bottom #mapPanelCloseButton { font-size: 25px !important; }
#mapView .public-map-panel.is-bottom .favorite-stop-button img { width: 21px !important; height: 21px !important; }
#mapView .public-map-panel.is-bottom :is(.vehicle-panel-actions, .line-panel-actions) { top: 12px !important; }
#mapView .public-map-panel.is-bottom :is(.stop-type-icon, .favorite-title-icon) { width: 28px; height: 28px; border-radius: 7px; flex: 0 0 28px; }
#mapView .public-map-panel.is-bottom .stop-panel-title-main { gap: 8px !important; }
#mapView .public-map-panel.is-bottom .map-panel-body {
  background: transparent !important;
  padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  scrollbar-color: rgba(255, 255, 255, .5) transparent;
}

#mapView .public-map-panel.is-bottom .map-panel-body::-webkit-scrollbar-track { background: transparent !important; }
#mapView .departure-info > strong,
#mapView .favorite-stop-heading strong,
#mapView .favorite-departure-direction,
#mapView .route-stop-name strong { font-weight: 600 !important; }
#mapView .departure-status, #mapView .favorite-departure-time { font-size: 13px; font-weight: 500; }
#mapView .route-stop-name strong { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
#mapView .line-route-actions .map-action-button { background: #ffffff0d !important; font-weight: 600; }
#mapView .departure-list { gap: 0 !important; }
#mapView .departure-card {
  min-height: 70px !important;
  gap: 2px !important;
  padding: 12px var(--bottom-panel-edge) !important;
  margin-inline: calc(0px - var(--bottom-panel-edge));
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
}
#mapView .departure-card:hover,
#mapView .departure-card:focus-within { background: #ffffff08 !important; }
#mapView .departure-card.is-expanded { background: #ffffff10 !important; }
#mapView .departure-card .line-badge { min-width: 38px; min-height: 22px; padding: 0 6px; border-radius: 6px !important; font-size: 13px; }
#mapView .departure-card .line-badge-icon { width: 13px; height: 13px; }
#mapView .departure-main {
  width: 100%;
  min-height: 22px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
#mapView .departure-info { gap: 7px; }
#mapView .departure-info > strong { white-space: normal; line-height: 1.3; font-size: 14px !important; }
#mapView .departure-status { flex-wrap: wrap; row-gap: 3px; margin-top: 2px; padding-right: 40px; font-size: 13px; line-height: 1.3; }
#mapView .departure-status strong { font-weight: 600; }
#mapView .departure-minutes { position: relative; align-self: start; min-width: 32px; line-height: 22px; }
#mapView .departure-minutes strong { font-size: 14px !important; font-weight: 600; }
#mapView .departure-minutes span { position: absolute; right: 0; top: 22px; font-size: 12px; line-height: 16px; font-weight: 500; }
#mapView .favorite-stop-open {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: 600 15px/1.4 "Segoe UI", system-ui, sans-serif;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
#mapView .favorite-stop-remove { width: 36px; min-width: 36px; height: 36px; border-radius: 50%; background: rgba(44, 41, 46, .56); }
#mapView .favorite-stop-card { background: transparent !important; }
#mapView .favorite-departure-direction { white-space: normal; line-height: 1.4; }
#mapView .public-route-stop[role="button"]:focus-visible { outline-offset: -3px !important; }
#mapView .vehicle-mini-menu { width: min(260px, calc(100dvw - 40px)); max-height: 55dvh; overflow-y: auto; border: 1px solid var(--ui-line); background: var(--ui-surface); }
#mapView .vehicle-mini-menu button { min-height: 44px; font-weight: 500; }
#mapView .departure-actions .show-course-button { min-height: 48px; font-weight: 600 !important; }
#mapView .map-empty-copy { color: var(--ui-muted) !important; padding: 28px 16px; font-size: 15px; font-weight: 400; line-height: 1.6; text-align: center; }
#mapView .favorites-empty { padding: 28px 16px; gap: 12px; }
#mapView .favorites-empty strong { font-size: 18px; font-weight: 600; }

#mapView .public-brigade-modal { background: var(--ui-surface); border: 1px solid var(--ui-line); }
#mapView .public-brigade-modal-head h2 { font-size: 20px; font-weight: 650; line-height: 1.4; }
#mapView .public-brigade-modal-body { overflow-y: auto; overscroll-behavior: contain; }
#mapView .public-date-strip { grid-template-columns: minmax(0, 1fr) !important; }
#mapView .public-date-scroll {
  display: flex !important;
  gap: 8px !important;
  overflow-x: auto !important;
  padding: 4px 4px 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #7f9184 transparent;
}
#mapView .public-date-button {
  flex: 0 0 108px;
  min-height: 60px !important;
  padding: 10px !important;
  border: 1px solid var(--ui-line) !important;
  border-radius: 12px !important;
  scroll-snap-align: start;
}
#mapView .public-date-button strong { font-size: 13px !important; font-weight: 600 !important; line-height: 1.4 !important; }
#mapView .public-date-button span { font-size: 12px !important; font-weight: 400 !important; line-height: 1.4 !important; }
#mapView .public-date-button.is-active { background: var(--map-accent-soft) !important; border-color: #83c78f !important; color: #c3edcb !important; }
#mapView .brigade-schedule-empty { font-size: 15px !important; font-weight: 400 !important; }
#mapView .brigade-modal-icon { width: 44px !important; height: 44px !important; }
#mapView .map-theme-popover { max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--ui-surface); }
#mapView .map-theme-grid { gap: 20px; padding: 24px 8px 8px; }
#mapView .map-theme-choice, #mapView .map-theme-close { width: 44px; height: 44px; min-width: 44px; }
#mapView .public-blog-screen h1 { font-weight: 650; }
#mapView .public-blog-card-copy strong { font-weight: 600; line-height: 1.4; }
#mapView .public-blog-content { line-height: 1.75; overflow-wrap: anywhere; }
#mapView .public-map-panel.is-blog-panel .map-panel-body,
#mapView .public-blog-screen { background: var(--ui-surface) !important; }
#mapView .public-blog-screen {
  max-width: 1120px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
#mapView .public-blog-topbar { min-height: 52px; padding-bottom: 12px; border-bottom: 1px solid var(--ui-line); }
#mapView .public-blog-icon-button { width: 44px; height: 44px; border-radius: 12px; background: #ffffff0d; }
#mapView .public-blog-screen h1 { margin-left: 0; line-height: 1.35; overflow-wrap: anywhere; }
#mapView .public-blog-grid { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 20px; }
#mapView .public-blog-card { min-height: 0; grid-template-rows: auto 1fr; border: 1px solid var(--ui-line); border-radius: 16px; background: var(--ui-raised); }
#mapView .public-blog-card-copy small, #mapView .public-blog-date { font-weight: 400; color: var(--ui-muted); }
#mapView .public-blog-empty { margin: 24px 0; padding: 32px 20px; border: 1px solid var(--ui-line); border-radius: 16px; background: var(--ui-raised); color: var(--ui-muted); font-weight: 400; text-align: center; }
#mapView .public-blog-retry { min-height: 44px; padding: 10px 18px; border: 1px solid var(--ui-line); border-radius: 12px; background: var(--map-accent-deep); color: var(--ui-text); font: inherit; cursor: pointer; }

body.is-public-map-open .cookie-notice {
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border-radius: 16px;
}
body.is-public-map-open .cookie-actions { flex-wrap: wrap; }
body.is-public-map-open .cookie-actions button { min-height: 44px; font-weight: 600; }

@media (max-width: 600px) {
  #mapView .public-map-panel.is-bottom { width: calc(100dvw - 16px) !important; max-width: calc(100dvw - 16px) !important; }
  #mapView .public-map-panel.is-fullscreen:not(.is-blog-panel):not(.is-schedules-panel) { padding-inline: 16px !important; }
  #mapView .public-map-panel.is-fullscreen:not(.is-blog-panel):not(.is-schedules-panel) .map-panel-head { padding-left: 56px !important; margin-bottom: 16px !important; }
  #mapView .public-map-panel.is-fullscreen .map-panel-head h2 { font-size: 20px !important; }
  #mapView .map-settings-section { padding: 16px !important; }
  #mapView .favorite-departure-list { padding-left: 0; }
  #mapView .public-brigade-modal { max-height: calc(100dvh - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  #mapView *, #mapView *::before, #mapView *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media (max-height: 500px) {
  #mapView .public-map-panel.is-bottom { height: var(--panel-height, 76dvh) !important; }
  #mapView .favorites-empty { min-height: 150px; padding-block: 16px; }
}

@media (max-width: 420px) {
  #mapView .public-map-panel.is-bottom .stop-panel-title-main > span:last-child { white-space: normal !important; overflow-wrap: anywhere; }
}
