/* =========================================================================
   NEW MOBILE REDESIGN 
   ========================================================================= */

.mobile-only { display: none !important; }
.mobile-map-load-indicator { display: none; }

@media (max-width: 768px), (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  .mobile-only { display: flex !important; }
  
  /* Topbar redesign */
  #topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    background: linear-gradient(180deg, rgba(13,17,23,0.9) 0%, rgba(13,17,23,0.4) 60%, transparent 100%);
    border: none;
    flex-direction: column;
    padding: 10px 12px 34px;
    gap: 8px;
    height: auto;
    pointer-events: none; /* let clicks pass through the gradient */
  }
  .topbar-brand { margin-bottom: 0; pointer-events: auto; display: flex; align-items: center; justify-content: flex-start; width: 100%; }
  .publisher-logo-full { height: 24px; }
  .publisher-logo-compact { height: 30px; }
  .topbar-sub { display: block !important; font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .7px; }
  
  .topbar-center { width: 100%; display: flex; gap: 8px; flex-direction: row; pointer-events: auto; justify-content: flex-start; }
  
  .topbar-btn {
    /* Hide probe btn from topbar, move to pill */
    display: none !important;
  }
  
  .map-search-wrap { flex: 1; position: relative; width: 100%; }
  #map-search-input {
    background: #161b22 !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 19px !important;
    padding: 8px 42px 8px 14px !important;
    width: 100% !important;
    height: 38px !important;
    color: #fff !important;
    font-size: 12px !important;
  }

  .map-search-submit {
    top: 3px;
    right: 3px;
    width: 32px;
    height: 32px;
  }
  
  /* Mobile Top Cards (now inside topbar) */
  #mobile-top-cards {
    display: flex !important;
    gap: 6px;
    width: 100%;
    pointer-events: auto;
  }
  
  .m-card {
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.05);
    min-height: 54px;
    border-radius: 9px;
    padding: 7px 8px;
    flex: 1;
    min-width: 0;
    box-shadow: 0 5px 16px rgba(0,0,0,0.42);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .m-card.mobile-card-hidden { display: none !important; }
  .m-card.mobile-map-active-hidden { display: none !important; }
  .m-card-title { overflow: hidden; font-size: 7.5px; color: var(--text-muted); font-weight: 650; margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.45px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
  .m-card-val { font-size: 14px; font-weight: 750; color: #fff; display: flex; align-items: baseline; gap: 3px; line-height: 1.15; }
  .m-card-val span { font-size: 14px; }
  .m-card-sub { display: none; }
  .m-card-meta { display: flex; align-items: center; gap: 4px; min-width: 0; margin-top: 3px; }
  .m-card-badge { display: inline-block; flex: 0 0 auto; background: rgba(227, 179, 65, 0.2); color: #e3b341; padding: 2px 6px; border-radius: 12px; font-size: 8px; font-weight: 700; line-height: 1.35; text-align: center; white-space: nowrap; }
  .m-card-time { min-width: 0; overflow: hidden; color: var(--text-muted); font-size: 8px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
  .m-card-badge.map-state-current { background: rgba(46, 160, 67, 0.18); color: #3fb950; }
  .m-card-badge.map-state-historical { background: rgba(137, 87, 229, 0.2); color: #bc8cff; }
  .m-card-badge.map-state-simulation { background: rgba(88, 166, 255, 0.18); color: #58a6ff; }
  .m-card-badge.map-state-loading { box-shadow: 0 0 0 1px currentColor inset; }
  
  /* Trend specific */
  .trend-down { color: #2ea043; font-size: 11px; align-items: center; }
  
  /* Bottom Nav */
  #mobile-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #0d1117;
    border-top: 1px solid rgba(255,255,255,0.05);
    z-index: 1050;
    display: flex !important;
    justify-content: space-around;
    padding: 7px 0 calc(7px + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
  }
  .nav-btn {
    background: none; border: none;
    color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 9px; padding: 3px 5px;
    flex: 1; cursor: pointer;
  }
  .nav-btn.active { color: var(--accent); }
  .nav-icon { font-size: 18px; line-height: 1; }
  
  /* New Probe Pill Button */
  .probe-pill-btn {
    position: absolute; bottom: 66px; left: 12px; transform: none;
    background: rgba(22,27,34,0.95);
    border: 1px solid rgba(255,255,255,0.1);
    width: 42px; height: 42px;
    border-radius: 50%;
    padding: 0;
    overflow: hidden;
    color: #fff; font-size: 0; font-weight: 500;
    display: flex !important; align-items: center; justify-content: center; gap: 0;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    white-space: nowrap;
    cursor: pointer;
    transition: bottom 160ms ease;
  }

  .location-pill-btn {
    position: absolute;
    bottom: 66px;
    left: 62px;
    z-index: 1000;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    color: #79c0ff;
    background: rgba(22,27,34,.95);
    border: 1px solid rgba(88,166,255,.34);
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
    cursor: pointer;
    transition: bottom 160ms ease, background 160ms ease, color 160ms ease;
  }
  .location-pill-btn:hover,
  .location-pill-btn:focus-visible { color: #fff; background: rgba(47,129,247,.28); }
  .location-pill-btn:disabled { cursor: progress; opacity: .72; }

  .mobile-map-load-indicator:not(.hidden) {
    position: absolute;
    top: 52%;
    left: 50%;
    z-index: 1020;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: rgba(13, 17, 23, 0.82);
    color: #58a6ff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.38);
    pointer-events: none;
    backdrop-filter: blur(5px);
  }
  .mobile-map-load-indicator .sim-load-spinner {
    width: 12px;
    height: 12px;
    flex-basis: 12px;
    border-width: 2px;
  }

  /* Compact map-level control. It stays reachable while the bottom sheet is
     closed, so a historical/manual level can be adjusted or reset without
     reopening the simulator panel. */
  #mobile-map-simulator {
    position: absolute;
    right: 12px;
    bottom: 62px;
    left: 12px;
    z-index: 1025;
    display: flex !important;
    max-width: 440px;
    margin: 0 auto;
    overflow: hidden;
    flex-direction: column;
    color: #e6edf3;
    background: rgba(13, 17, 23, 0.96);
    border: 1px solid rgba(88, 166, 255, 0.34);
    border-radius: 11px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
  }
  #mobile-map-simulator.mobile-sim-hidden { display: none !important; }
  .mobile-map-sim-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
  .mobile-map-sim-toggle {
    width: 100%;
    min-height: 42px;
    padding: 6px 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
  }
  .mobile-map-sim-toggle > span:first-child {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .mobile-map-sim-kicker {
    color: #8b949e;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.8px;
  }
  #mobile-map-sim-label {
    overflow: hidden;
    font-size: 11px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-map-sim-value {
    color: #58a6ff;
    font-size: 15px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .mobile-map-sim-chevron {
    color: #8b949e;
    font-size: 10px;
    transition: transform 160ms ease;
  }
  #mobile-map-simulator.is-expanded .mobile-map-sim-chevron { transform: rotate(180deg); }
  .mobile-map-sim-controls {
    padding: 0 10px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
  .mobile-map-sim-controls[hidden] { display: none !important; }
  .mobile-map-sim-range-row {
    min-height: 46px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 9px;
  }
  #mobile-map-sim-slider {
    width: 100%;
    min-width: 0;
    accent-color: #2f81f7;
  }
  .mobile-map-sim-step,
  .mobile-map-sim-current {
    color: #e6edf3;
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
  }
  .mobile-map-sim-step {
    width: 34px;
    height: 34px;
    font-size: 18px;
    line-height: 1;
  }
  .mobile-map-sim-current {
    min-width: 64px;
    min-height: 34px;
    margin-right: 8px;
    padding: 0 9px;
    color: #79c0ff;
    border-color: rgba(88, 166, 255, 0.32);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
  }
  .mobile-map-sim-current[hidden] { display: none !important; }
  .mobile-sim-load-status {
    /* The visible progress affordance is the spinner beside the level value.
       Keep this live region available to assistive technology without adding
       a large status box over the map. */
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
  #mobile-map-simulator[aria-busy="true"] .mobile-map-sim-value::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border: 2px solid rgba(88, 166, 255, .3);
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: flood-load-spin .8s linear infinite;
    vertical-align: -1px;
  }
  #mobile-map-simulator[data-loading-phase="focus"] #mobile-map-sim-slider,
  #mobile-map-simulator[data-loading-phase="focus"] .mobile-map-sim-step {
    opacity: 0.55;
  }
  #map-container.mobile-simulator-visible .probe-pill-btn,
  #map-container.mobile-simulator-visible .location-pill-btn { bottom: 116px; }
  #map-container.mobile-simulator-open .probe-pill-btn,
  #map-container.mobile-simulator-open .location-pill-btn { bottom: 182px; }
  
  /* Overrides for existing components */
  #map-container { flex: 1; height: 100dvh; min-height: 0; }
  #main-layout { flex: 1; position: relative; }
  
  /* Sidebar becomes Bottom Sheet */
  #sidebar {
    height: auto; max-height: 80vh;
    padding-bottom: 80px; /* space for bottom nav */
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    transform: translateY(100%);
    z-index: 1040;
    background: #0d1117;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .sidebar-inner { padding: 16px 20px; }
  .sidebar-drag-handle {
    position: relative;
    width: 100%;
    height: 24px;
    margin: -6px 0 6px;
    padding: 0;
    flex: 0 0 24px;
    align-items: center;
    justify-content: center;
    color: transparent;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: grab;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }
  .sidebar-drag-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.24);
    border-radius: 2px;
    transition: width 140ms ease, background-color 140ms ease;
  }
  .sidebar-drag-handle:active { cursor: grabbing; }
  .sidebar-drag-handle:active::before,
  #sidebar.is-dragging .sidebar-drag-handle::before {
    width: 50px;
    background: rgba(121,192,255,.72);
  }
  .sidebar-drag-handle:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 1px;
  }
  #sidebar.is-dragging {
    transition: none !important;
    user-select: none;
    will-change: transform;
  }
  
  /* Hide elements from desktop sidebar on mobile */
  #panel-level { display: none !important; }
  #sidebar-toggle { display: none !important; }
  
  /* Map controls floating */
  .mobile-layer-toggle {
    position: absolute;
    top: 152px;
    right: 12px;
    z-index: 1022;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 50%;
    background: rgba(13,17,23,.9);
    color: #e6edf3;
    box-shadow: 0 5px 16px rgba(0,0,0,.45);
    backdrop-filter: blur(10px);
  }
  .mobile-layer-toggle[aria-expanded="true"] {
    color: #79c0ff;
    border-color: rgba(88,166,255,.45);
    background: rgba(22,27,34,.97);
  }
  .map-layer-pills {
    display: none !important;
    bottom: auto !important; top: 198px !important; left: auto !important; right: 12px !important;
    flex-direction: column !important;
    background: rgba(13,17,23,0.85) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
    border-radius: 14px !important;
    padding: 4px !important;
    transform: none !important;
    gap: 4px;
  }
  .map-layer-pills.mobile-layers-open { display: flex !important; }
  .layer-pill { 
    width: auto; height: 32px; border-radius: 16px; 
    background: transparent; color: var(--text-muted) !important; 
    border: none;
    box-shadow: none;
    margin-bottom: 0;
    padding: 0 12px;
    font-size: 11px;
    display: flex; align-items: center; justify-content: center;
  }
  .layer-pill.active {
    background: rgba(255,255,255,0.1) !important;
    color: #fff !important;
  }
  .layer-pill::after { display: none !important; }

  .low-level-warning {
    top: 152px;
    right: 60px;
    left: 12px;
    width: auto;
    max-width: 270px;
    padding: 6px 9px;
    transform: none;
    border-left-width: 3px;
    border-radius: 7px;
    background: rgba(13,17,23,.9);
    font-size: 10px;
    line-height: 1.25;
    text-align: left;
    backdrop-filter: blur(8px);
  }
  .low-level-warning-desktop { display: none; }
  .low-level-warning-mobile { display: inline; }
  
  .leaflet-control-zoom { margin-top: 260px !important; margin-bottom: 0 !important; }
}

/* Startup Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(4px);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: #161b22; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 24px; max-width: 400px;
  color: #fff; box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  position: relative;
}

/* Portrait phones use one compact header row and explicit, non-overlapping
   control zones. Landscape has its own composition further below. */
@media (max-width: 768px) and (orientation: portrait) {
  #topbar {
    display: grid;
    grid-template-columns: minmax(118px, .44fr) minmax(0, 1fr);
    grid-template-areas:
      "brand search"
      "cards cards";
    align-content: start;
    padding: 8px 12px 24px;
    gap: 6px 8px;
    background: linear-gradient(180deg, rgba(13,17,23,.92) 0%, rgba(13,17,23,.62) 76%, transparent 100%);
  }

  .topbar-brand {
    grid-area: brand;
    width: auto;
    min-width: 0;
    height: 34px;
  }
  .publisher-logo-full { height: 22px; }

  .topbar-center {
    grid-area: search;
    width: 100%;
    min-width: 0;
    height: 34px;
    justify-self: stretch;
  }
  .map-search-wrap { min-width: 0; }
  #map-search-input {
    height: 34px !important;
    padding: 6px 34px 6px 11px !important;
    border-radius: 17px !important;
    font-size: 10.5px !important;
  }
  .map-search-submit {
    top: 2px;
    right: 2px;
    width: 30px;
    height: 30px;
  }

  #mobile-top-cards {
    grid-area: cards;
    height: 50px;
    gap: 5px;
  }
  .m-card {
    min-height: 50px;
    height: 50px;
    padding: 5px 7px;
    border-radius: 8px;
  }
  .m-card-title { margin-bottom: 0; font-size: 7px; }
  .m-card-val,
  .m-card-val span { font-size: 13px; }
  .m-card-meta { margin-top: 1px; }
  .m-card-badge { padding: 1px 5px; font-size: 7px; }
  .m-card-time { font-size: 7px; }
  .trend-down { font-size: 10px; }

  .mobile-layer-toggle {
    top: 110px;
    right: 10px;
  }
  .map-layer-pills {
    top: 154px !important;
    right: 10px !important;
  }

  /* Leaflet places its zoom control in the lower-right corner by default,
     where it collided with the app navigation. On phones it gets a stable
     map-only lane beneath the layer menu. */
  .leaflet-control-zoom {
    position: fixed !important;
    top: clamp(318px, 42vh, 370px) !important;
    right: 10px !important;
    margin: 0 !important;
    transform: none !important;
  }

  .probe-pill-btn {
    bottom: 70px;
    left: 10px;
  }
  .location-pill-btn {
    bottom: 70px;
    left: 60px;
  }
}
.startup-modal-content { width: min(100%, 400px); }
.startup-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 42px 14px 0;
  color: #e3b341;
  font-size: 18px;
  line-height: 1.2;
}
.startup-modal-title svg { flex: 0 0 auto; }
.startup-modal-copy { display: grid; gap: 8px; }
.startup-modal-copy p {
  margin: 0;
  color: #e6edf3;
  font-size: 13px;
  line-height: 1.5;
}
.startup-modal-copy .startup-modal-emphasis {
  color: #fff;
  font-weight: 700;
}
.defesa-civil-info {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(227, 179, 65, 0.24);
}
.defesa-civil-title {
  margin: 0 0 10px;
  color: #e3b341;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .45px;
  text-transform: uppercase;
}
.emergency-contact-list { display: grid; gap: 9px; }
.emergency-contact {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
}
.emergency-city {
  color: #c9d1d9;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}
.emergency-numbers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}
.emergency-hotline,
.emergency-phone {
  text-decoration: none;
  white-space: nowrap;
}
.emergency-hotline {
  min-width: 38px;
  padding: 3px 7px;
  border: 1px solid rgba(227, 179, 65, .36);
  border-radius: 6px;
  background: rgba(227, 179, 65, .12);
  color: #f2cc60;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.1;
  text-align: center;
}
.emergency-hotline.secondary {
  border-color: rgba(255, 123, 114, .34);
  background: rgba(248, 81, 73, .10);
  color: #ff9b94;
}
.emergency-or { color: #7d8590; font-size: 10px; }
.emergency-phone { color: #fff; font-size: 13px; font-weight: 750; }
.emergency-hotline:hover,
.emergency-phone:hover { text-decoration: underline; }
.modal-close-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 9px;
  background: rgba(255,255,255,0.04);
  color: #c9d1d9;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.modal-close-x:hover,
.modal-close-x:focus-visible {
  background: rgba(255,255,255,0.10);
  color: #fff;
  outline: 2px solid #58a6ff;
  outline-offset: 1px;
}
.modal-methodology-link {
  margin: 15px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 11px;
  line-height: 1.35;
}
.modal-methodology-link a { color: #58a6ff; }

@media (max-width: 480px) {
  .modal-overlay { padding: 14px; }
  .modal-content { padding: 20px 17px 17px; max-height: calc(100vh - 28px); overflow: auto; }
  .modal-content h3 { padding-right: 32px; font-size: 17px; }
  .startup-modal-copy p { font-size: 12px; }
  .defesa-civil-info { margin-top: 14px; padding-top: 12px; }
  .emergency-contact { padding: 8px 9px; }
}

/* Toast */
.probe-toast {
  position: fixed; top: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(13,17,23,0.9); color: white; padding: 12px 24px;
  border-radius: 20px; font-weight: 600; font-size: 13px;
  z-index: 10000; border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: fadeInOut 3s forwards;
  pointer-events: none;
}
@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  90% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}


/* Dailies List */
.dailies-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.daily-item {
  display: flex;
  justify-content: space-between;
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.05);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}
.daily-date {
  color: var(--text-muted);
  font-weight: 500;
}
.daily-avg {
  color: #fff;
  font-weight: bold;
}

.probe-intro {
  --probe-intro-bottom: 122px;
  position: fixed;
  bottom: var(--probe-intro-bottom);
  left: 12px;
  z-index: 10000;
  width: min(310px, calc(100vw - 24px));
  padding: 12px 36px 12px 13px;
  color: #e6edf3;
  background: rgba(13,17,23,.97);
  border: 1px solid rgba(88,166,255,.38);
  border-radius: 11px;
  box-shadow: 0 10px 28px rgba(0,0,0,.55);
  font-size: 11px;
  line-height: 1.42;
  animation: probeIntroIn 180ms ease-out both;
}
.probe-intro strong {
  display: block;
  margin-bottom: 4px;
  color: #79c0ff;
  font-size: 12px;
}
.probe-intro p { margin: 0; }
.probe-intro-hint {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-weight: 700;
}
.probe-intro-close {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 26px;
  height: 26px;
  padding: 0;
  color: #8b949e;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.probe-intro-close:hover,
.probe-intro-close:focus-visible { color: #fff; background: rgba(255,255,255,.08); }
@keyframes probeIntroIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px), (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  #low-level-warning {
    top: auto !important;
    right: 16px !important;
    bottom: 170px !important;
    left: 16px !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
    padding: 8px 12px !important;
    font-size: 0.72rem !important;
    line-height: 1.35 !important;
  }
}

/* Phones used sideways need a different composition, not merely a shorter
   version of the portrait stack. Keep the map as the main surface: brand and
   search share the first row, the status cards use one compact row, and the
   primary navigation moves to a narrow right rail. */
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  #topbar {
    right: 54px;
    display: grid;
    grid-template-columns: minmax(150px, 0.6fr) minmax(250px, 1.4fr);
    grid-template-areas:
      "brand search"
      "cards cards";
    align-content: start;
    padding: 6px 10px 14px;
    gap: 4px 8px;
    background: linear-gradient(180deg, rgba(13,17,23,.92) 0%, rgba(13,17,23,.58) 78%, transparent 100%);
  }

  .topbar-brand {
    grid-area: brand;
    width: auto;
    height: 34px;
  }
  .publisher-logo-full { height: 23px; }

  .topbar-center {
    grid-area: search;
    width: auto;
    height: 34px;
  }
  #map-search-input {
    height: 34px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }
  .map-search-submit {
    top: 1px;
    width: 32px;
    height: 32px;
  }

  #mobile-top-cards {
    grid-area: cards;
    width: min(100%, 520px);
    height: 42px;
    gap: 4px;
    justify-self: start;
  }
  .m-card {
    min-height: 42px;
    height: 42px;
    padding: 4px 7px;
    border-radius: 7px;
  }
  .m-card-title {
    margin-bottom: 0;
    font-size: 7px;
    line-height: 1;
  }
  .m-card-val,
  .m-card-val span { font-size: 12px; line-height: 1.05; }
  .m-card-meta { margin-top: 1px; }
  .m-card-time { display: none; }
  .m-card-badge { padding: 1px 5px; font-size: 7px; }
  .trend-down { font-size: 10px; }

  #mobile-bottom-nav {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: 54px;
    height: 100dvh;
    padding: 4px 0;
    flex-direction: column;
    justify-content: space-evenly;
    border-top: 0;
    border-left: 1px solid rgba(255,255,255,.07);
  }
  #mobile-bottom-nav .nav-btn {
    flex: 0 1 64px;
    width: 100%;
    min-height: 48px;
    padding: 3px 2px;
    gap: 0;
    justify-content: center;
  }
  #mobile-bottom-nav .nav-icon {
    width: 21px;
    height: 21px;
    font-size: 17px;
  }
  #mobile-bottom-nav .nav-label { display: none; }

  .probe-pill-btn {
    bottom: 10px;
    left: 10px;
    width: 38px;
    height: 38px;
  }
  .location-pill-btn {
    bottom: 10px;
    left: 56px;
    width: 38px;
    height: 38px;
  }
  #map-container.mobile-simulator-visible .probe-pill-btn,
  #map-container.mobile-simulator-visible .location-pill-btn { bottom: 58px; }
  #map-container.mobile-simulator-open .probe-pill-btn,
  #map-container.mobile-simulator-open .location-pill-btn { bottom: 112px; }

  #mobile-map-simulator {
    right: 64px;
    bottom: 8px;
    left: 64px;
    max-width: 440px;
  }
  .mobile-map-sim-toggle { min-height: 40px; padding: 5px 9px; }
  .mobile-map-sim-controls { padding: 0 9px 7px; }
  .mobile-map-sim-range-row { min-height: 42px; }

  .mobile-layer-toggle {
    top: 104px;
    right: 64px;
    width: 36px;
    height: 36px;
  }
  .map-layer-pills {
    top: 144px !important;
    right: 64px !important;
  }
  .leaflet-right { right: 54px; }
  .leaflet-control-zoom {
    margin-top: 104px !important;
    margin-bottom: 0 !important;
  }

  #low-level-warning {
    right: 64px !important;
    bottom: 8px !important;
    left: 58px !important;
    max-width: 360px !important;
    margin: 0 auto;
    padding: 6px 9px !important;
    font-size: 10px !important;
  }
  #map-container.mobile-simulator-visible #low-level-warning { bottom: 58px !important; }

  #sidebar {
    top: 0;
    right: 54px;
    bottom: 0;
    left: auto;
    width: min(440px, calc(100vw - 74px));
    height: 100dvh;
    max-height: 100dvh;
    padding-bottom: 0;
    border-radius: 14px 0 0 14px;
    border-top: 0;
    border-left: 1px solid rgba(255,255,255,.1);
    transform: translateX(110%);
  }
  #sidebar.open { transform: translateX(0) !important; }
  .sidebar-inner { padding: 10px 14px 14px; }
  .sidebar-drag-handle { margin-bottom: 8px; }
  .sidebar-drag-handle { display: none !important; }

  .modal-overlay { padding: 8px; }
  .modal-content {
    width: min(680px, calc(100vw - 70px));
    max-width: 680px;
    max-height: calc(100dvh - 16px);
    overflow: auto;
    padding: 14px 16px;
  }
  .startup-modal-title { margin-bottom: 8px; font-size: 15px; }
  .startup-modal-copy { gap: 4px; }
  .startup-modal-copy p { font-size: 11px; line-height: 1.35; }
  .defesa-civil-info { margin-top: 9px; padding-top: 8px; }
  .defesa-civil-title { margin-bottom: 6px; }
  .emergency-contact-list { grid-template-columns: 1fr 1fr; gap: 6px; }
  .emergency-contact { padding: 6px 8px; }
  .modal-methodology-link { margin-top: 8px; padding-top: 7px; }
  .probe-toast { top: 8px; }
}

@media (max-width: 430px) and (orientation: portrait) {
  .publisher-logo-full { display: none; }
  .publisher-logo-compact { display: block; }
}

