/* 空间助手。z-index 40–48：高于图例(~9)、低于导出遮罩(~60) 和加载层(50)。 */
.gm-chat-fab {
  position: fixed;
  z-index: 45;
  right: 68px;
  bottom: calc(150px + env(safe-area-inset-bottom));
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 22px;
  background: #16181d;
  color: #fff;
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: .5px;
  box-shadow: 0 2px 12px rgba(22, 28, 38, .22);
  cursor: pointer;
}
.gm-chat-fab:active { background: #2a2e35; }
.gm-chat-fab[hidden] { display: none !important; }

.gm-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(12, 16, 24, .18);
  pointer-events: none;
}
.gm-chat-backdrop[hidden] { display: none !important; }

.gm-chat-panel {
  position: fixed;
  z-index: 45;
  right: 68px;
  bottom: calc(150px + env(safe-area-inset-bottom));
  width: 380px;
  max-height: min(620px, calc(100dvh - 210px));
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #1d232b;
  border-radius: 16px;
  box-shadow: 0 10px 36px rgba(22, 28, 38, .22);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
.gm-chat-panel[hidden] { display: none !important; }

.gm-chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 8px 14px;
  border-bottom: 1px solid #eceef1;
}
.gm-chat-head b { flex: 1; font-size: 15px; }
.gm-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #414b57;
  font-size: 16px;
  cursor: pointer;
}
.gm-icon:hover { background: #f3f5f7; }

.gm-chat-settings {
  flex: none;
  padding: 10px 12px 12px;
  background: #f7f8fa;
  border-bottom: 1px solid #eceef1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gm-chat-settings[hidden] { display: none !important; }
.gm-chat-settings label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 700; color: #66707c; }
.gm-chat-settings input {
  height: 34px;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 13px;
  color: #1d232b;
  background: #fff;
}
.gm-chat-settings .gm-note { margin: 0; font-size: 11px; line-height: 1.55; color: #66707c; font-weight: 400; }
.gm-chat-settings .gm-row { display: flex; gap: 8px; }
.gm-chat-settings button, .gm-send, .gm-confirm button, .gm-presets button {
  font-family: inherit;
  cursor: pointer;
}
.gm-chat-settings .gm-row button, .gm-send {
  height: 34px;
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  background: #16181d;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.gm-chat-settings .gm-row button.gm-ghost {
  background: #fff;
  color: #16181d;
  border: 1px solid #d0d7de;
}

.gm-chat-log {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 12px;
  min-height: 120px;
  min-width: 0;
}
.gm-msg { margin: 0 0 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 100%; min-width: 0; }
.gm-msg-user { align-items: flex-end; }
.gm-bubble {
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.gm-msg-user .gm-bubble { background: #16181d; color: #fff; border-bottom-right-radius: 4px; }
.gm-msg-bot .gm-bubble {
  background: #f3f5f7;
  color: #1d232b;
  border-bottom-left-radius: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
}
.gm-msg-bot .gm-bubble:empty { display: none; }
.gm-msg-bot .gm-bubble > :first-child { margin-top: 0; }
.gm-msg-bot .gm-bubble > :last-child { margin-bottom: 0; }
.gm-msg-bot .gm-bubble p { margin: 0 0 8px; }
.gm-msg-bot .gm-bubble h1,
.gm-msg-bot .gm-bubble h2,
.gm-msg-bot .gm-bubble h3,
.gm-msg-bot .gm-bubble h4,
.gm-msg-bot .gm-bubble h5,
.gm-msg-bot .gm-bubble h6 {
  margin: 8px 0 4px;
  line-height: 1.35;
  font-weight: 700;
}
.gm-msg-bot .gm-bubble h1 { font-size: 16px; }
.gm-msg-bot .gm-bubble h2 { font-size: 15px; }
.gm-msg-bot .gm-bubble h3 { font-size: 14px; }
.gm-msg-bot .gm-bubble h4,
.gm-msg-bot .gm-bubble h5,
.gm-msg-bot .gm-bubble h6 { font-size: 13px; }
.gm-msg-bot .gm-bubble ul,
.gm-msg-bot .gm-bubble ol { margin: 4px 0 8px; padding-left: 1.25em; }
.gm-msg-bot .gm-bubble li { margin: 2px 0; }
.gm-msg-bot .gm-bubble strong { font-weight: 700; }
.gm-msg-bot .gm-bubble em { font-style: italic; }
.gm-msg-bot .gm-bubble a { color: #1f5fa8; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.gm-msg-bot .gm-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: rgba(22, 28, 38, .06);
  padding: 0 4px;
  border-radius: 4px;
}
.gm-msg-bot .gm-bubble pre {
  margin: 6px 0;
  padding: 8px;
  overflow-x: auto;
  max-width: 100%;
  background: #16181d;
  color: #f3f5f7;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
.gm-msg-bot .gm-bubble pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  white-space: pre;
  word-break: normal;
}
.gm-msg-bot .gm-bubble .gm-md-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 6px 0;
}
.gm-msg-bot .gm-bubble table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 12px;
  line-height: 1.45;
}
.gm-msg-bot .gm-bubble th,
.gm-msg-bot .gm-bubble td {
  border: 1px solid #d0d7de;
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.gm-msg-bot .gm-bubble th { background: #e6eaee; font-weight: 700; }
.gm-msg-bot .gm-bubble tbody tr:nth-child(even) td { background: rgba(22, 28, 38, .045); }
.gm-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.gm-tool {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 8px;
  background: #eaf1fb;
  color: #1f5fa8;
  font-size: 11px;
  font-weight: 700;
}
.gm-tool.bad { background: #fde8e8; color: #b42318; }

.gm-confirm {
  flex: none;
  margin: 0 12px 8px;
  padding: 8px;
  border-radius: 12px;
  background: #fdf2e3;
  color: #7a4b00;
}
.gm-confirm[hidden] { display: none !important; }
.gm-confirm p { margin: 0 0 8px; font-size: 12px; line-height: 1.5; }
.gm-confirm .gm-row { display: flex; gap: 8px; }
.gm-confirm button {
  height: 32px;
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  background: #16181d;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.gm-confirm button.gm-ghost { background: #fff; color: #16181d; }

.gm-presets {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 8px;
}
.gm-presets[hidden] { display: none !important; }
.gm-presets button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(22, 28, 38, .14);
  border-radius: 999px;
  background: #fff;
  color: #16181d;
  font-size: 12px;
  font-weight: 650;
}
.gm-presets button:disabled { opacity: .45; }

.gm-compose {
  flex: none;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #eceef1;
}
.gm-compose textarea {
  flex: 1;
  resize: none;
  height: 38px;
  max-height: 96px;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: #1d232b;
}
.gm-send { flex: none; height: 38px; }
.gm-send:disabled, .gm-compose textarea:disabled { opacity: .5; }

/* 步骤条（P2-8）、小票（P0-2）、追问（P2-10） */
.gm-steps, .gm-receipts {
  max-width: 100%;
  width: 100%;
  font-size: 11px;
  line-height: 1.5;
  color: #4a5562;
}
.gm-steps[hidden], .gm-receipts[hidden], .gm-follow[hidden], .gm-verify-note[hidden] { display: none !important; }
.gm-steps summary, .gm-receipts summary {
  cursor: pointer;
  font-weight: 700;
  color: #66707c;
  padding: 2px 0;
  list-style-position: inside;
}
.gm-steps ol { margin: 2px 0 0; padding-left: 1.4em; }
.gm-steps li { margin: 1px 0; }
.gm-steps li.bad { color: #b42318; }
.gm-receipts summary { color: #1f5fa8; }
.gm-rc-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.gm-rc {
  border: 1px solid #dfe5ec;
  border-radius: 10px;
  padding: 6px 8px;
  background: #fbfcfd;
}
.gm-rc-title { font-weight: 700; color: #1d232b; font-size: 12px; margin-bottom: 4px; }
.gm-rc-kv { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; margin: 0; }
.gm-rc-kv dt { color: #8a919c; white-space: nowrap; }
.gm-rc-kv dd { margin: 0; overflow-wrap: anywhere; color: #2b333d; }
.gm-rc-btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.gm-rc-btns button, .gm-follow button {
  height: 26px;
  padding: 0 9px;
  border: none;
  border-radius: 8px;
  background: #16181d;
  color: #fff;
  font: 700 11px/1 inherit;
  font-family: inherit;
  cursor: pointer;
}
.gm-rc-btns button.gm-ghost { background: #fff; color: #16181d; border: 1px solid #d0d7de; }
.gm-rc-note { color: #1a7f37; font-weight: 700; }
.gm-sub-badge {
  display: inline-block; margin: 0; padding: 1px 8px; border-radius: 999px;
  background: #f6efe2; color: #8a5a00; font-size: 11px; font-weight: 700; line-height: 1.7; white-space: nowrap;
}
.gm-rc-btns button:disabled, .gm-follow button:disabled { opacity: .55; cursor: not-allowed; }
.gm-rc-rows { margin: 6px 0 0; padding-left: 1.6em; max-height: 180px; overflow-y: auto; }
.gm-rc-rows li { padding: 2px 4px; border-radius: 6px; cursor: pointer; }
.gm-rc-rows li:hover { background: #eef3f8; }
.gm-rc-rows li.sel { background: #fff1c2; }
.gm-rc-rows li.gm-more { cursor: default; color: #8a919c; }
.gm-unverified { color: #9aa1aa; text-decoration: underline dotted; text-underline-offset: 2px; cursor: help; }
.gm-verify-note { font-size: 11px; color: #8a919c; }
.gm-follow { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-follow button { background: #fff; color: #1f5fa8; border: 1px solid #c7d7ea; border-radius: 999px; height: 28px; font-weight: 650; }
.gm-follow button:hover { background: #eef3f8; }
.gm-mode { display: flex; flex-direction: column; gap: 4px; }
.gm-chat-settings label.gm-radio { flex-direction: row; align-items: center; gap: 6px; font-size: 12px; color: #2b333d; font-weight: 650; }
.gm-chat-settings label.gm-radio input { height: auto; }
.gm-adv { display: flex; flex-direction: column; gap: 6px; }
.gm-adv[hidden] { display: none !important; }

/* 地图上的小票图例 */
.gm-agent-legend {
  position: fixed;
  z-index: 44;
  left: 12px;
  top: calc(136px + env(safe-area-inset-top));
  max-width: 240px;
  max-height: 40vh;
  overflow-y: auto;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .96);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(22, 28, 38, .18);
  font: 12px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: #1d232b;
}
.gm-al-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.gm-al-head b { min-width: 0; flex: 1; white-space: normal; overflow-wrap: anywhere; }
.gm-al-head button { flex: none; }
.gm-al-head button { border: none; background: transparent; font-size: 16px; line-height: 1; cursor: pointer; color: #66707c; }
.gm-al-row { display: flex; align-items: center; gap: 6px; }
.gm-al-row b { min-width: 0; overflow-wrap: anywhere; }
.gm-al-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 1px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.gm-al-ring { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px dashed #1f5fa8; }
.gm-al-note { color: #8a919c; font-size: 11px; margin-top: 2px; }

/* 打开时把缩放/导出/影像按钮和哨兵弹窗抬到面板之上，仍低于导出遮罩和 50。 */
body.gm-chat-open #zoomCtrl { z-index: 48; }
body.gm-chat-open .maplibregl-popup.s2-pop { z-index: 48; }

/* 地标故事抽屉/小卡打开时：移动助手按钮，不改 z-index（按钮仍可点，也不再盖住正文）。 */
@media (min-width: 641px) {
  body.lm-drawer-open .gm-chat-fab,
  body.lm-drawer-open .gm-chat-panel {
    right: calc(24px + min(380px, 100vw - 24px));
  }
  body.lm-mini-open .gm-chat-fab,
  body.lm-mini-open .gm-chat-panel {
    right: calc(24px + min(300px, 100vw - 24px));
  }
}
@media (max-width: 640px) {
  body.lm-drawer-open:not(.gm-mobile-ui) .gm-chat-fab,
  body.lm-mini-open:not(.gm-mobile-ui) .gm-chat-fab {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    right: 12px;
  }
  body.gm-mobile-ui.gm-sheet-peek .gm-chat-fab,
  body.gm-mobile-ui.gm-sheet-peek.lm-drawer-open .gm-chat-fab,
  body.gm-mobile-ui.gm-sheet-peek.lm-mini-open .gm-chat-fab {
    left: 12px;
    right: auto;
    top: auto;
    bottom: calc(var(--gm-sheet-offset, 60px) + 10px);
  }
  body.gm-mobile-ui.gm-sheet-raised .gm-chat-fab,
  body.gm-mobile-ui.gm-sheet-raised.lm-drawer-open .gm-chat-fab,
  body.gm-mobile-ui.gm-sheet-raised.lm-mini-open .gm-chat-fab {
    bottom: auto;
    top: calc(var(--gm-topbar-bottom-px, 57px) + 4px);
    left: 12px;
    right: auto;
    z-index: 34;
  }
}

@media (max-width: 720px) {
  .gm-chat-panel {
    left: 0;
    right: 64px;
    width: auto;
    bottom: 0;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
  }
  .gm-msg-bot .gm-bubble th,
  .gm-msg-bot .gm-bubble td { padding: 3px 5px; }
}
