/* Mobile / responsive chrome: grouped tab nav, unified bottom sheet, map-first layout.
   Desktop (min-width 721px) keeps familiar top chips + floating legend + bottom drawer. */

:root {
  --gm-sheet-peek: 52px;
  --gm-sheet-mid: 42vh;
  --gm-sheet-full: min(88vh, calc(100dvh - 72px));
  --gm-sheet-offset: var(--gm-sheet-peek);
}

/* ---------- Group nav + chip row ---------- */
.chip-groups {
  pointer-events: auto;
  display: none;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: nowrap;
}
.chip-groups .grp-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 34px;
  padding: 0 6px;
  border: 1px solid rgba(22, 28, 38, .12);
  border-radius: 10px;
  background: rgba(255, 255, 255, .88);
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(22, 28, 38, .06);
}
.chip-groups .grp-btn.on {
  background: #16181d;
  border-color: #16181d;
  color: #fff;
}
.chips-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  min-width: 0;
}
.chips-wrap .chips {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 8px;
}
.chip-more {
  pointer-events: auto;
  flex: none;
  height: 36px;
  padding: 0 12px;
  margin-top: 8px;
  border: 1px dashed rgba(22, 28, 38, .22);
  border-radius: 12px;
  background: rgba(255, 255, 255, .95);
  font-size: 12px;
  font-weight: 700;
  color: #1f5fa8;
  cursor: pointer;
  white-space: nowrap;
}

.chip-overflow {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(12, 16, 24, .45);
}
.chip-overflow[hidden] { display: none; }
.chip-overflow-panel {
  width: min(420px, 100%);
  max-height: min(70vh, calc(100dvh - 80px));
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  padding: 12px 12px 16px;
  box-shadow: 0 8px 32px rgba(22, 28, 38, .2);
}
.chip-overflow-panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #6b7280;
}
.chip-overflow-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-overflow-grid .chip {
  height: 36px;
}

@media (min-width: 721px) {
  .chip-groups { display: none !important; }
  .chip-more { display: none !important; }
  .chips {
    flex-wrap: wrap;
    overflow-x: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .chips::after { display: none; }
}

@media (max-width: 720px) {
  body.gm-mobile-ui .chip-groups { display: flex; }
  body.gm-mobile-ui .chips {
    overflow-x: auto;
    -webkit-mask-image: none;
    mask-image: none;
  }
  body.gm-mobile-ui .chip-grp { display: none !important; }
  body.gm-mobile-ui .view-desc {
    pointer-events: none;
    margin: 6px auto 0;
    max-width: calc(100% - 20px);
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .93);
    box-shadow: 0 1px 6px rgba(22, 28, 38, .08);
    text-shadow: none;
    line-height: 1.45;
    font-size: 11px;
  }
  body.gm-mobile-ui.gm-map-focus .view-desc,
  body.gm-mobile-ui.gm-map-focus .region-bar,
  body.gm-mobile-ui.gm-map-focus .title-text p { display: none; }
  body.gm-mobile-ui.gm-map-focus .title-text h1 { font-size: 15px; }
  body.gm-mobile-ui.gm-map-focus .title-card { padding: 7px 12px; }
  /* Full sheet: collapse chip rows so sheet tabs sit below the title card, not under chips */
  body.gm-mobile-ui.gm-sheet-full .chip-groups,
  body.gm-mobile-ui.gm-sheet-full .chips-wrap,
  body.gm-mobile-ui.gm-sheet-full .view-desc,
  body.gm-mobile-ui.gm-sheet-full .region-bar,
  body.gm-mobile-ui.gm-sheet-full .title-text p {
    display: none !important;
  }
  body.gm-mobile-ui.gm-sheet-full .title-text h1 { font-size: 15px; }
  body.gm-mobile-ui.gm-sheet-full .title-card { padding: 8px 12px; }
}

/* ---------- Unified mobile bottom sheet ---------- */
.gm-m-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 22;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 28px rgba(22, 28, 38, .16);
  padding-bottom: env(safe-area-inset-bottom);
  pointer-events: auto;
  touch-action: manipulation;
  transition: height .28s ease, max-height .28s ease;
}
.gm-m-sheet[hidden] { display: none !important; }

.gm-m-sheet[data-detent="peek"] {
  height: var(--gm-sheet-peek);
  max-height: var(--gm-sheet-peek);
}
.gm-m-sheet[data-detent="mid"] {
  height: var(--gm-sheet-mid-px, var(--gm-sheet-mid));
  max-height: var(--gm-sheet-mid-px, var(--gm-sheet-mid));
}
.gm-m-sheet[data-detent="full"] {
  height: var(--gm-sheet-full-px, min(55vh, calc(100dvh - 200px)));
  max-height: var(--gm-sheet-full-px, min(55vh, calc(100dvh - 200px)));
}
.gm-m-sheet[data-drag="1"] {
  height: var(--gm-sheet-live-px, var(--gm-sheet-mid-px));
  max-height: var(--gm-sheet-live-px, var(--gm-sheet-mid-px));
}
body.gm-sheet-dragging .gm-m-sheet {
  transition: none;
}

.gm-m-sheet-grab {
  flex: none;
  padding: 10px 16px 6px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
body.gm-sheet-dragging .gm-m-sheet-grab { cursor: grabbing; }
.gm-m-sheet-grab .grab { margin-bottom: 0; }

.gm-m-sheet-tabs {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 0 12px 8px;
  border-bottom: 1px solid #f0f1f3;
  touch-action: pan-y;
}
body.gm-sheet-dragging .gm-m-sheet-tabs {
  touch-action: none;
}
.gm-m-sheet-tabs button {
  flex: 1 1 0;
  min-width: 0;
  height: 34px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  font-size: 12px;
  font-weight: 700;
  color: #4b5563;
  cursor: pointer;
}
.gm-m-sheet-tabs button.on {
  background: #16181d;
  border-color: #16181d;
  color: #fff;
}
.gm-m-sheet-tabs button:disabled {
  opacity: .45;
  cursor: default;
}

.gm-m-sheet-well {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gm-m-sheet-well[data-tab="panel"] .gm-slot-panel { display: flex; }
.gm-m-sheet-well[data-tab="panel"] .gm-slot-legend,
.gm-m-sheet-well[data-tab="panel"] .gm-slot-layers { display: none; }
.gm-m-sheet-well[data-tab="legend"] .gm-slot-legend { display: block; }
.gm-m-sheet-well[data-tab="legend"] .gm-slot-panel,
.gm-m-sheet-well[data-tab="legend"] .gm-slot-layers { display: none; }
.gm-m-sheet-well[data-tab="layers"] .gm-slot-layers { display: block; }
.gm-m-sheet-well[data-tab="layers"] .gm-slot-panel,
.gm-m-sheet-well[data-tab="layers"] .gm-slot-legend { display: none; }

.gm-slot {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  padding: 0 0 12px;
}
.gm-slot-legend { padding: 4px 12px 12px; }
.gm-slot-layers { padding: 0; }
.gm-slot-panel {
  flex-direction: column;
  padding: 8px 10px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.gm-panel-empty {
  padding: 24px 16px 32px;
  font-size: 13px;
  line-height: 1.65;
  color: #6b7280;
  text-align: center;
}
.gm-m-sheet-tabs button[aria-disabled="true"] {
  opacity: .55;
}

/* Legend in sheet: flat list, no floating card chrome */
body.gm-mobile-ui #legend {
  display: none !important;
}
body.gm-mobile-ui .gm-slot-legend .lg-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.gm-mobile-ui .gm-slot-legend .lg-scale svg { max-width: 100%; }

/* Desktop drawer hidden on mobile when sheet active */
body.gm-mobile-ui #drawer {
  visibility: hidden;
  pointer-events: none;
  max-height: 0;
  overflow: hidden;
}

/* Controls clear the sheet */
body.gm-mobile-ui #zoomCtrl {
  bottom: calc(var(--gm-sheet-offset, 60px) + env(safe-area-inset-bottom));
}
body.gm-mobile-ui .maplibregl-ctrl-bottom-right {
  bottom: calc(var(--gm-sheet-offset, 60px) + 8px + env(safe-area-inset-bottom)) !important;
  left: 92px !important;
  right: 12px !important;
  max-width: calc(100vw - 104px);
}
body.gm-mobile-ui .maplibregl-ctrl-attrib {
  max-width: 100%;
}
body.gm-mobile-ui .maplibregl-ctrl-attrib.maplibregl-compact-show {
  max-width: calc(100vw - 108px);
}

body.gm-mobile-ui.gm-sheet-peek .gm-chat-fab {
  left: 12px;
  right: auto;
  top: auto;
  bottom: calc(var(--gm-sheet-offset, 60px) + 10px);
}
/* Mid/full: park 空间助手 in the top control strip — no black pill over sheet taps */
body.gm-mobile-ui.gm-sheet-raised .gm-chat-fab {
  bottom: auto !important;
  top: calc(var(--gm-topbar-bottom-px, var(--gm-sheet-top-fallback, 57px)) + 4px);
  left: 12px;
  right: auto;
  z-index: 34;
}
/* Full detent: reserve a control strip between collapsed topbar and sheet (peek/mid rules above unchanged). */
body.gm-mobile-ui.gm-sheet-raised #zoomCtrl {
  bottom: auto !important;
  top: calc(var(--gm-topbar-bottom-px, 57px) + 4px);
  right: 12px;
  left: auto;
  z-index: 34;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
}
body.gm-mobile-ui.gm-sheet-raised #zoomCtrl .zoom-btn:not(#zoomIn):not(#zoomOut) {
  display: none;
}
body.gm-mobile-ui.gm-sheet-raised:not(.gm-sheet-full) .maplibregl-ctrl-bottom-right {
  bottom: auto !important;
  top: calc(var(--gm-topbar-bottom-px, var(--gm-sheet-top-fallback, 57px)) + 10px) !important;
  left: auto !important;
  right: 108px !important;
  max-width: none !important;
}
body.gm-mobile-ui.gm-sheet-full .maplibregl-ctrl-bottom-right {
  bottom: auto !important;
  top: calc(var(--gm-topbar-bottom-px, 57px) + 10px) !important;
  left: auto !important;
  right: 108px !important;
  max-width: none !important;
}
body.gm-mobile-ui.gm-sheet-raised .maplibregl-ctrl-top-right {
  display: none;
}
body.gm-mobile-ui.gm-sheet-raised .maplibregl-ctrl-attrib-inner {
  display: none !important;
}
body.gm-mobile-ui.gm-sheet-raised .maplibregl-ctrl-attrib-button {
  display: block !important;
}

/* Landmarks inside sheet */
body.gm-mobile-ui .gm-slot-panel .lm-root {
  position: static;
  inset: auto;
  height: auto;
  pointer-events: auto;
}
body.gm-mobile-ui .gm-slot-panel .lm-bar {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  margin: 0 0 8px;
  z-index: auto;
}
body.gm-mobile-ui .gm-slot-panel .lm-panel,
body.gm-mobile-ui .gm-slot-panel .lm-list,
body.gm-mobile-ui .gm-slot-panel .lm-route,
body.gm-mobile-ui .gm-slot-panel .lm-mini,
body.gm-mobile-ui .gm-slot-panel .lm-drawer {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  width: 100% !important;
  max-width: none !important;
  max-height: none;
  margin: 0 0 8px;
  box-shadow: 0 1px 8px rgba(22, 28, 38, .08);
}
body.gm-mobile-ui .gm-slot-panel .lm-list.lm-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  max-height: min(36vh, 280px);
}
body.gm-mobile-ui .gm-m-sheet[data-detent="mid"] .gm-slot-panel .lm-list.lm-panel {
  max-height: min(28vh, 200px);
}
body.gm-mobile-ui .gm-m-sheet[data-detent="mid"] .lm-axis-vals,
body.gm-mobile-ui .gm-m-sheet[data-detent="mid"] .lm-count {
  display: none;
}
body.gm-mobile-ui .gm-m-sheet[data-detent="mid"] .lm-axis-track-wrap {
  height: 32px;
}
body.gm-mobile-ui .gm-m-sheet[data-detent="mid"] .lm-axis-scale {
  font-size: 9px;
  line-height: 1.1;
}
body.gm-mobile-ui .gm-m-sheet[data-detent="mid"] .lm-bar {
  padding: 4px 8px;
  gap: 5px;
}
body.gm-mobile-ui .gm-m-sheet[data-detent="mid"] .lm-btn {
  padding: 4px 10px;
  font-size: 12px;
}
body.gm-mobile-ui.lm-mini-open .gm-slot-panel .lm-list,
body.gm-mobile-ui.lm-mini-open .gm-slot-panel .lm-route {
  display: none !important;
}
body.gm-mobile-ui.lm-mini-open .gm-slot-panel .lm-mini {
  margin-bottom: 0;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
}
body.gm-mobile-ui.lm-mini-open .gm-m-sheet[data-detent="mid"] .gm-slot-panel {
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}
body.gm-mobile-ui.lm-drawer-open .gm-slot-panel .lm-list,
body.gm-mobile-ui.lm-drawer-open .gm-slot-panel .lm-route {
  display: none !important;
}
body.gm-mobile-ui.lm-drawer-open .gm-slot-panel .lm-drawer {
  flex: 1 1 auto;
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.gm-mobile-ui .gm-slot-panel .lm-drawer-body {
  max-height: min(46vh, 360px);
}

body.gm-mobile-ui .gm-slot-layers .drawer-inner {
  padding: 2px 16px 22px;
}

/* Layer drawer source block in sheet */
body.gm-mobile-ui .gm-m-sheet[data-detent="peek"] .gm-m-sheet-tabs,
body.gm-mobile-ui .gm-m-sheet[data-detent="peek"] .gm-m-sheet-well {
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
  padding: 0;
  border: none;
}

@media (min-width: 721px) {
  .gm-m-sheet { display: none !important; }
  body.gm-mobile-ui #drawer { visibility: visible; pointer-events: auto; max-height: 72vh; overflow: visible; }
  body.gm-mobile-ui #legend { display: block !important; }
}