/* ───────────────────────────────────────────────────────────────
   地图浮层层级 / 定位 Token（P0-②: 统一散乱的 z-index 与魔法数字）
   层级顺序（低 → 高）: 底图 < 数据层 < 备案角标 < 控件/图例/统计 < 搜索框
   < 移动端FAB < 筛选面板 < 详情抽屉遮罩 < 详情抽屉 < 瞬时提示(toast)。
   #map-main 自带 base 堆叠上下文, 把 Leaflet 内部 z-index(最高 1000 的控件角)
   收纳在底图层内, 故上方 UI 用 600+ 即可稳定盖住地图控件。
   ─────────────────────────────────────────────────────────────── */
:root {
    /* z-index 标尺 */
    --z-map-base: 0;            /* #map-main 底图(含 Leaflet 内部 panes/controls) */
    --z-map-overlay-pane: 200;  /* 数据层语义档位(Leaflet pane 由 JS 管理, 此处仅作标尺锚点) */
    --z-map-legal: 400;         /* ICP / 营业执照角标(最低的 UI, 可被面板盖住) */
    --z-map-control: 600;       /* 缩放控件 / 图例 / Pro 角标 */
    --z-map-search: 640;        /* 河流搜索框 */
    --z-map-fab: 660;           /* 移动端"图层"FAB */
    --z-map-panel: 800;         /* 筛选 / 图层面板(桌面左卡 + 移动底抽屉) */
    --z-map-spotcard-overlay: 980; /* 详情抽屉的移动端背景遮罩 */
    --z-map-spotcard: 1000;     /* 河段详情抽屉 */
    --z-map-toast: 1100;        /* 欢迎引导 / 回退提示 / 加载中等瞬时浮层 */

    /* 关键定位 */
    --map-top-search-y: 14px;   /* 搜索框距地图顶部(原决策入口条位置; 入口条已删, 搜索框上移补位) */
    --map-control-y: 16px;      /* 缩放控件距地图顶部(移动端在媒体查询内下移避让搜索框) */
}

/* Full-screen Map Layout */
.map-page {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    overflow: hidden;
}

@media (max-width: 768px) {
    .map-page {
        top: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
    }
}

/* 隐藏footer和tab bar避免覆盖地图控件 */
.fb-footer,
.fb-tab-bar {
    display: none !important;
}

.map-fullscreen {
    flex: 1;
    position: relative;
}

#map-main {
    width: 100%;
    height: 100%;
    /* 自带堆叠上下文: 把 Leaflet 内部 z-index(panes 200-700、控件角 1000)
       全部收纳在底图层级内, 上方 UI 浮层用统一 token 即可稳定盖住地图。 */
    position: relative;
    z-index: var(--z-map-base);
}

/* 河流搜索框(原 map.html 内联定位/层级 → 这里用 token 表达) */
#reach-search-box {
    position: absolute;
    top: var(--map-top-search-y);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-map-search);
    width: min(440px, calc(100% - 24px));
}
#reach-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    background: #fff;
}
#reach-search-results {
    margin-top: 6px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: none; /* 初始隐藏; reach_search.js 用内联 style.display 控制显隐(内联优先) */
}
/* 搜索框下常驻一行价值提示: 半透明底保证压在地图瓦片上可读, 弱于输入框 */
.map-value-hint {
    width: max-content;
    max-width: 100%;
    margin: 6px auto 0;
    padding: 3px 12px;
    font-size: 12px;
    color: var(--fb-text-muted, #5b6b62);
    background: rgba(255, 255, 255, 0.82);
    border-radius: 999px;
    text-align: center;
    pointer-events: none;
}
/* 平板窄桌面(769-984px): 440px 居中搜索框会压住左栏(左栏止于 264px)。
   把搜索框中心移到左栏右侧剩余空间的中点并收窄, 两者互不重叠。 */
@media (min-width: 769px) and (max-width: 984px) {
    #reach-search-box {
        left: calc((100% + 264px) / 2);
        width: min(360px, calc(100% - 296px));
    }
}

/* 顶部决策入口条(3 pill)已删: 动作与现有控件重复, 搜索框上移补位(见 --map-top-search-y) */

/* 答案卡: "今天附近值得去 Top3" — 答案先行, 地图退为探索工具 */
.map-answer-card {
    position: absolute;
    top: 76px;
    /* 避让右侧控件列(40px 方形图标钮, right:16 → 左缘 right:56)+ 首访脉冲光环 10px。
       72px = 56 + 16px 余量。移动端(≤768px)有独立的底部布局覆盖此值。
       (定位钮 2026-07-15 由文字胶囊改回纯图标方钮, 故从 #520 的 140px 收回 72px) */
    right: 72px;
    width: 264px;
    background: var(--fb-surface, #fff);
    border-radius: var(--fb-radius-lg, 14px);
    box-shadow: 0 4px 20px rgba(31, 42, 36, 0.14);
    padding: 10px 12px;
    z-index: var(--z-map-control);
}
.answer-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 700;
    color: var(--fb-text, #1f2a24);
    margin-bottom: 6px;
}
.answer-card-close {
    border: none;
    background: transparent;
    color: var(--fb-text-muted, #5b6b62);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
}
.answer-card-actions { display: inline-flex; align-items: center; gap: 4px; }
.answer-card-share {
    border: 1px solid var(--fb-border, #e5e9e7);
    background: var(--fb-bg, #eef1ef);
    color: var(--fb-accent, #2b7c60);
    font-size: 11px;
    line-height: 1;
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
}
.answer-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    font: inherit;
    font-size: 13px;
    color: var(--fb-text, #1f2a24);
    padding: 7px 6px;
    border-radius: 8px;
    cursor: pointer;
}
.answer-item:hover { background: var(--fb-gray-100, #f1f4f3); }
.answer-item .ai-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.answer-item .ai-bite { flex: none; font-size: 12px; color: var(--fb-accent, #2b7c60); font-weight: 700; }
@media (max-width: 768px) {
    /* 移动端沉到底部(FAB 上方), 不挡搜索框与地图中心 */
    .map-answer-card {
        top: auto;
        right: 12px;
        left: 12px;
        bottom: 118px;
        width: auto;
    }

    /* 触控热区 ≥44px(WCAG 2.5.5): 关闭/分享按钮桌面态偏小, 仅移动端撑大, 不动桌面布局 */
    .answer-card-close {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px 10px;
    }
    .answer-card-share {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px 14px;
    }
}

/* 横屏矮视口(如 844×390): 桌面态答案卡 top:76 与顶部居中搜索框(y14, 高~44→底58)
   仅隔 ~18px 且二者水平重叠约 250px; 搜索框(z640)压答案卡(z600), 稍有内容/输入焦点
   /建议下拉即碰撞。横屏时: (1) 搜索框收窄, 不再伸进答案卡所在右列; (2) 答案卡明确下移
   带足够垂直余量; (3) 限高防止在矮视口里溢出屏底。 */
/* pointer:coarse 限定触屏设备: 桌面用户把窗口压矮到 500px 不该吃移动横屏布局(codex 评审) */
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
    #reach-search-box {
        left: 12px;
        transform: none;
        width: min(300px, calc(100% - 300px));
    }
    .map-answer-card {
        top: 96px;                 /* 明确让开搜索框(底 ~58)带足够垂直余量 */
        max-height: calc(100vh - 112px);
        overflow-y: auto;
    }
}

/* ICP备案号 + 营业执照公示角标(原 map.html 内联定位/层级 → token 化) */
.map-legal-badge {
    position: absolute;
    bottom: 4px;
    left: 10px;
    z-index: var(--z-map-legal);
    font-size: 11px;
    /* rgba(0,0,0,.4)≈#999 对白≈2.83:1 不达标 → 加深文字 + 半透明白底衬(压在瓦片上),
       #4d5a52 对白≈6.4:1, 最劣(白衬压深色瓦片)仍 ≥4.5:1 */
    color: #4d5a52;
    background: rgba(255, 255, 255, 0.82);
    padding: 2px 8px;
    border-radius: 8px;
    pointer-events: auto;
}
.map-legal-badge a {
    color: inherit;
}

/* Left Panel */
.map-panel {
    position: absolute;
    top: 16px;
    left: 16px;
    bottom: 16px;
    width: 248px;  /* 200→248: 原宽度下 19 个 chip 挤成一坨"调试面板"(codex 评审高优) */
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: var(--z-map-panel);
    pointer-events: none;
}

.map-panel > * {
    pointer-events: auto;
}

/* Map Layers Toggle */
.map-layers-card {
    background: var(--fb-surface);
    border-radius: var(--fb-radius-lg);
    box-shadow: 0 4px 20px rgba(31, 42, 36, 0.12);
    padding: 12px 16px;
    pointer-events: auto !important;
    position: relative;
    z-index: 1001;
}

/* 河段筛选面板(左上, 取代旧图层开关卡) */
.map-filter-card {
    background: var(--fb-surface, #fff);
    border-radius: var(--fb-radius-lg, 14px);
    box-shadow: 0 4px 20px rgba(31, 42, 36, 0.12);
    padding: 12px 14px;
    pointer-events: auto !important;
    position: relative;
    z-index: 1001;
    max-width: 280px;
}
.map-filter-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--fb-text, #1f2a24);
    margin-bottom: 8px;
}
/* 标题内嵌可见计数(反馈就近; 移动端抽屉盖住右下统计条时这是唯一反馈) */
.filter-title-count {
    font-size: 11px;
    font-weight: 400;
    color: var(--fb-text-muted, #5b6b62);
    margin-left: 6px;
}
/* 筛选后 0 结果的兜底提示(否则地图静默全空, 只剩角落一个不起眼的 0) */
.filter-empty-hint {
    font-size: 11px;
    line-height: 1.5;
    color: #92400e;
    background: #fef3c7;
    border-radius: 8px;
    padding: 6px 8px;
    margin: 2px 0 4px;
}
/* 空态提示内嵌的清除按钮: 动作贴着问题, 别让用户找底部链接 */
.filter-empty-clear {
    border: 1px solid #d97706;
    background: #fff;
    color: #92400e;
    font-size: 11px;
    border-radius: 999px;
    padding: 2px 10px;
    margin-left: 4px;
    cursor: pointer;
}
/* FAB 活跃筛选数角标 */
.fab-filter-count {
    background: var(--fb-accent, #2b7c60);
    color: #fff;
    font-size: 11px;
    line-height: 1;
    border-radius: 999px;
    padding: 3px 7px;
    margin-left: 2px;
}
.filter-group {
    /* 不给 fieldset 上 flex(Safari 对 fieldset 作 flex 容器兼容性差, codex 评审):
       block + chip 自身 inline-flex + margin 实现同样的换行流 */
    display: block;
    margin: 0 0 7px;
    /* fieldset 语义化后重置浏览器默认框线/内边距 */
    border: 0;
    padding: 0;
    min-width: 0;
}
.filter-group .filter-chip { margin: 0 4px 4px 0; }
/* 组间分隔线: 拉开四组的视觉层级(原先 19 个 chip 平铺一坨) */
.filter-group + .filter-group {
    border-top: 1px solid var(--fb-border, #e5e9e7);
    padding-top: 8px;
    margin-top: 2px;
}
.filter-group-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--fb-text-muted, #5b6b62);
    margin-bottom: 3px;
    padding: 0;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 999px;
    background: var(--fb-bg, #eef1ef);
    color: var(--fb-text-muted, #5b6b62);
    cursor: pointer;
    user-select: none;
}
.filter-chip input { margin: 0; width: 12px; height: 12px; cursor: pointer; }
.filter-chip:has(input:checked) {
    background: var(--fb-accent, #2b7c60);
    color: #fff;
    font-weight: 600;
}
.filter-clear {
    margin-top: 4px;
    border: none;
    background: transparent;
    color: var(--fb-text-muted, #5b6b62);
    font-size: 11px;
    text-decoration: underline;
    cursor: pointer;
    padding: 2px 0;
}
/* 跨页出口: 地图(这片视野) → 发现页(全站目录)。轻量文字链 */
.filter-discover-exits {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--fb-border, #e5e9e7);
}
.filter-discover-exits a {
    font-size: 12px;
    color: var(--fb-accent, #2b7c60);
    text-decoration: none;
}
.filter-discover-exits a:hover { text-decoration: underline; }
.filter-empty-hint a { color: #92400e; text-decoration: underline; }

.map-layers-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--fb-gray-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.map-layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    pointer-events: auto !important;
    position: relative;
}

.map-layer-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--fb-ink);
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-layer-label .layer-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 30px;
    display: inline-block;
    cursor: pointer;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
    margin: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--fb-gray-200);
    transition: 0.3s;
    border-radius: 999px;
    pointer-events: none;
    z-index: 1;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--fb-blue);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Spot Detail Card */
/* ── Spot Modal Overlay (mobile backdrop) ── */
.spot-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: var(--z-map-spotcard-overlay);
    animation: overlayIn 0.2s ease;
}
.spot-modal-overlay.visible { display: block; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Spot Card — desktop: right-side slide-in panel ── */
.map-spot-card {
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    right: -420px;                              /* starts off-screen */
    bottom: 12px;
    width: 400px;
    background: var(--fb-surface);
    border-radius: var(--fb-radius-lg);
    box-shadow: 0 8px 40px rgba(31, 42, 36, 0.18);
    overflow: hidden;  /* 外层不滚: 只让 .spot-card-body 滚, actions 常驻底栏(codex 评审) */
    z-index: var(--z-map-spotcard);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.map-spot-card[hidden] {
    display: none;
}

.map-spot-card.visible {
    right: 12px;
    pointer-events: auto;
}

.spot-card-drag-handle { display: none; }

.spot-card-header {
    padding: 20px 20px 16px;
    border-bottom: var(--fb-border);
    position: sticky;
    top: 0;
    background: var(--fb-surface);
    z-index: 1;
    flex-shrink: 0;
}

.spot-card-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--fb-ink-strong);
    margin-bottom: 4px;
}

.spot-card-subtitle {
    font-size: 13px;
    color: var(--fb-gray-text);
}

.spot-card-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--fb-gray-100);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.spot-card-close:hover {
    background: var(--fb-gray-200);
}

.spot-card-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;  /* flex 子项可收缩到内容以下才能真滚, 否则撑破外层把底栏顶走(codex 评审) */
}

.spot-badge-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.spot-index-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--fb-radius-pill);
    font-weight: 700;
    font-size: 14px;
    margin: 0;
    border: 1px solid transparent;
    appearance: none;
    cursor: pointer;
    line-height: 1.2;
    min-height: 36px;
    font-family: inherit;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.spot-index-badge:hover {
    transform: translateY(-1px);
}

.spot-index-badge:focus-visible {
    outline: 2px solid var(--fb-blue);
    outline-offset: 2px;
}

.spot-summary-badge.active {
    border-color: currentColor;
    box-shadow: 0 0 0 2px rgba(58, 111, 140, 0.12);
}

.spot-summary-badge[hidden] {
    display: none;
}

.spot-index-badge.high {
    background: rgba(43, 124, 96, 0.15);
    color: var(--map-marker-high);
}

.spot-index-badge.mid {
    background: rgba(58, 111, 140, 0.15);
    color: var(--map-marker-mid);
}

.spot-index-badge.low {
    background: rgba(214, 165, 76, 0.15);
    color: var(--map-marker-low);
}

.spot-index-badge.poor {
    background: rgba(227, 107, 107, 0.15);
    color: var(--map-marker-poor);
}

.spot-badge-info {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid #d8e2dc;
    border-radius: var(--fb-radius-md);
    background: #f8fbf9;
    color: var(--fb-ink);
    font-size: 12px;
    line-height: 1.5;
}

.spot-badge-info-title {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
    font-weight: 800;
    color: var(--fb-ink-strong);
}

.spot-badge-info-title span:last-child {
    flex: 0 0 auto;
}

.spot-badge-info-summary {
    font-weight: 700;
    margin-bottom: 4px;
}

.spot-badge-info-list {
    margin: 6px 0 0 16px;
    padding: 0;
    color: var(--fb-gray-text);
}

.spot-badge-info-list li {
    margin: 2px 0;
}

.spot-badge-info-note {
    margin-top: 6px;
    color: var(--fb-gray-text);
}

.spot-species-range {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.spot-species-cell {
    flex: 1;
    text-align: center;
    background: var(--fb-gray-100);
    border-radius: 8px;
    padding: 6px 4px;
}

.spot-species-cell strong {
    display: block;
    font-size: 16px;
    font-weight: 900;
    line-height: 1.1;
}

.spot-species-cell span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--fb-ink);
    margin-top: 1px;
}

.spot-species-cell em {
    display: block;
    font-size: 10px;
    font-style: normal;
    color: var(--fb-gray-text);
}

.spot-species-high strong { color: #16a34a; }
.spot-species-ok strong { color: #eab308; }
.spot-species-low strong { color: #dc2626; }

.spot-adv-controls {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.spot-adv-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spot-adv-label {
    flex: 0 0 28px;
    font-size: 11px;
    color: var(--fb-gray-text);
}

.spot-adv-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.spot-adv-chip {
    font-size: 12px;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--fb-gray-200);
    background: var(--fb-white);
    color: var(--fb-ink);
    cursor: pointer;
}

.spot-adv-chip.active {
    background: var(--fb-blue);
    border-color: var(--fb-blue);
    color: #fff;
    font-weight: 700;
}

.spot-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.spot-metric {
    background: var(--fb-white);
    border: var(--fb-border);
    border-radius: var(--fb-radius-md);
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s;
    /* div→button 语义化(键盘可达)后的外观重置 */
    appearance: none;
    font: inherit;
    text-align: left;
    color: inherit;
    display: block;
    width: 100%;
}
.spot-metric .spot-metric-label,
.spot-metric .spot-metric-value { display: block; }

.spot-metric:hover {
    border-color: var(--fb-blue);
    background: rgba(58, 111, 140, 0.05);
}

.spot-metric.active {
    border-color: var(--fb-blue);
    background: rgba(58, 111, 140, 0.1);
    box-shadow: 0 0 0 2px rgba(58, 111, 140, 0.2);
}

.spot-metric-label {
    font-size: 11px;
    color: var(--fb-gray-text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spot-metric-value {
    font-size: 16px;
    font-weight: 800;
    color: var(--fb-ink-strong);
}

.spot-metric-unit {
    font-size: 10px;
    font-weight: 400;
    color: var(--fb-gray-text);
}

@media (max-width: 480px) {
    .spot-index-badge {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        padding: 8px 10px;
    }

    .spot-index-badge span {
        font-size: 12px;
    }
}

/* 地图左下 Pro 升级徽章 */
.map-pro-badge-wrap {
    position: absolute;
    right: 16px;
    bottom: 84px;        /* 桌面:右下角、stats-bar 上方,避开左侧面板与屏幕中心 */
    z-index: var(--z-map-control);
}
.map-pro-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 99px;
    border: 2px solid #ffd700;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    transition: transform 0.15s ease;
}
.map-pro-badge:hover {
    transform: translateY(-2px);
}
.map-pro-badge-star {
    font-size: 18px;
}
.map-pro-badge-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.map-pro-badge-text strong {
    font-size: 13px;
    font-weight: 800;
    color: #ffd700;
}
.map-pro-badge-text em {
    font-size: 11px;
    font-style: normal;
    color: rgba(255,255,255,0.85);
    margin-top: 2px;
}
.map-pro-badge-close {
    position: absolute;
    top: -14px;
    right: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.map-pro-badge-close:hover { background: rgba(0,0,0,0.9); }
/* 触控目标:保持视觉 22px 圆点,用透明伪元素把可点区域扩到 ~44px */
.map-pro-badge-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
}
@media (max-width: 880px) {
    .map-pro-badge-wrap {
        right: 8px;
        bottom: calc(112px + env(safe-area-inset-bottom, 0px));  /* 移动:右下角、stats-bar 上方,离开地图中心 */
    }
}

/* Pro 门禁 —— 锁定参数卡片 */
.spot-metric.spot-metric-locked {
    background: repeating-linear-gradient(45deg, #f5f5f5, #f5f5f5 6px, #ebebeb 6px, #ebebeb 12px);
    opacity: 0.85;
    cursor: pointer;
}
.spot-metric.spot-metric-locked:hover {
    opacity: 1;
    border-color: #d97706;
}
.spot-metric.spot-metric-locked .spot-metric-label {
    color: var(--fb-ink-strong);
    font-weight: 600;
}

/* 升级横幅（出现在 .spot-metrics-grid 下方） */
.spot-pro-upgrade-banner {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fbbf24;
    border-radius: var(--fb-radius-md);
    padding: 10px 12px;
    font-size: 13px;
    color: #78350f;
    font-weight: 600;
    text-align: center;
    margin-top: 4px;
}
.spot-pro-upgrade-banner a {
    color: #b45309;
    text-decoration: underline;
    margin-left: 4px;
}

/* 数据源标签 */
.spot-data-source {
    font-size: 11px;
    color: var(--fb-gray-text);
    margin-top: 8px;
    padding: 4px 8px;
    background: var(--fb-gray-100);
    border-radius: var(--fb-radius-sm);
    display: inline-block;
}

.spot-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--fb-ink);
    margin: 16px 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.spot-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.spot-tag {
    padding: 4px 10px;
    border-radius: var(--fb-radius-pill);
    font-size: 12px;
    background: var(--fb-gray-100);
    color: var(--fb-ink);
}

.spot-tag.warning {
    background: rgba(244, 183, 64, 0.2);
    color: #b8860b;
}

.spot-tag.good {
    background: rgba(42, 124, 95, 0.15);
    color: var(--map-marker-high);
}

.spot-chart-container {
    margin-top: 8px;
    height: 120px;
    background: var(--fb-gray-100);
    border-radius: var(--fb-radius-md);
    padding: 8px;
}

/* CTA 常驻底栏: 卡片直接子级(非 .spot-card-body 内), flex-shrink:0 使其在
   短视口下不被内部滚动裁掉; 补回横向/底部 padding(原先由 body 的 20px 内边距提供),
   底部叠加安全区避让移动端 bottom-sheet 手势条/刘海。 */
.spot-card-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: var(--fb-border);
    background: var(--fb-surface);
    border-radius: 0 0 var(--fb-radius-lg) var(--fb-radius-lg);
}

.spot-action-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--fb-radius-pill);
    font-weight: 700;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.spot-action-btn.primary {
    background: var(--fb-ink-strong);
    color: var(--fb-white);
}

.spot-action-btn.primary:hover {
    background: var(--fb-navy);
}

.spot-action-btn.secondary {
    background: var(--fb-white);
    border: var(--fb-border);
    color: var(--fb-ink);
}

.spot-action-btn.secondary:hover {
    background: var(--fb-gray-100);
}

.spot-action-btn.secondary.active {
    background: var(--fb-blue);
    border-color: transparent;
    color: var(--fb-white);
}

/* Legend Card */
.map-legend-card {
    position: absolute;
    bottom: 28px;
    left: 16px;
    background: var(--fb-surface);
    border-radius: var(--fb-radius-lg);
    box-shadow: 0 4px 20px rgba(31, 42, 36, 0.12);
    padding: 12px 16px;
    z-index: var(--z-map-control);
}

/* 地图着色指标切换器(咬钩/水质指数/食用/类别) */
.map-metric-switch {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    background: var(--fb-bg, #eef1ef);
    border-radius: 999px;
    padding: 3px;
}
.metric-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--fb-text-muted, #5b6b62);
    font-size: 12px;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.metric-btn:hover { color: var(--fb-text, #1f2a24); }
.metric-btn.is-active {
    background: var(--fb-surface, #fff);
    color: var(--fb-text, #1f2a24);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(31, 42, 36, 0.12);
}

/* 触控热区 ≥44px(WCAG 2.5.5): 抽屉指标切换按钮桌面态仅 24px 高, 移动端增高并拉大间距 */
@media (max-width: 768px) {
    .map-metric-switch {
        gap: 6px;
    }
    .metric-btn {
        min-height: 44px;
        padding: 10px 8px;
    }
}

.map-legend-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--fb-ink);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.high { background: var(--map-marker-high); }
.legend-dot.mid { background: var(--map-marker-mid); }
.legend-dot.low { background: var(--map-marker-low); }
.legend-dot.poor { background: var(--map-marker-poor); }

.legend-line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
    display: inline-block;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: var(--map-control-y);
    right: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;   /* 控件列右对齐(所有钮同为 40px 方形, 贴右边一列) */
    gap: 8px;
    z-index: var(--z-map-control);
}

.map-control-btn {
    width: 40px;
    height: 40px;
    background: var(--fb-surface);
    border: none;
    border-radius: var(--fb-radius-md);
    box-shadow: 0 2px 8px rgba(31, 42, 36, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.map-control-btn:hover {
    background: var(--fb-gray-100);
}

.map-control-btn svg {
    width: 20px;
    height: 20px;
    color: var(--fb-ink);
}

/* 定位控件: 纯图标方钮(与缩放/全屏按钮同尺寸), 仅用蓝色描边点出"定位"入口。
   (#518 曾加"📍我的位置"文字胶囊, owner 2026-07-15 要求去掉文字只留图标) */
.map-control-locate {
    color: var(--fb-blue);
}
.map-control-locate svg { color: var(--fb-blue); }

/* 首访一次脉冲提示(JS 按 localStorage 只加一次, 点击/超时后移除) */
.map-control-btn.locate-hint {
    animation: znd-locate-pulse 1.6s ease-out 3;
}
@keyframes znd-locate-pulse {
    0%   { box-shadow: 0 2px 8px rgba(31,42,36,0.12), 0 0 0 0 rgba(58,111,140,0.45); }
    70%  { box-shadow: 0 2px 8px rgba(31,42,36,0.12), 0 0 0 10px rgba(58,111,140,0); }
    100% { box-shadow: 0 2px 8px rgba(31,42,36,0.12), 0 0 0 0 rgba(58,111,140,0); }
}
@media (prefers-reduced-motion: reduce) {
    .map-control-btn.locate-hint { animation: none; }
}

/* 右下"当前可见河段"统计条已删: 计数内嵌筛选面板标题 */

/* Drawer handle for mobile */
.map-panel-handle {
    display: none;
}

/* Responsive - Mobile bottom drawer */
@media (max-width: 768px) {
    .map-panel {
        position: fixed;
        top: auto;
        bottom: env(safe-area-inset-bottom, 0px);
        left: 0;
        right: 0;
        width: 100%;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: var(--z-map-panel);
        pointer-events: auto;
        background: var(--fb-surface);
        box-shadow: 0 -4px 20px rgba(31, 42, 36, 0.15);
        overflow-y: auto;
    }

    .map-panel.expanded {
        transform: translateY(0);
    }

    .map-panel-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 0 6px;
        cursor: pointer;
    }

    .map-panel-handle::before {
        content: "";
        width: 40px;
        height: 4px;
        background: var(--fb-gray-200);
        border-radius: 2px;
    }

    /* Hide the chevron arrow - FAB replaces it */
    .map-panel-handle::after {
        display: none;
    }

    .map-layers-card {
        border-radius: 0;
        box-shadow: none;
    }

    /* Mobile: spot card becomes a bottom sheet */
    .map-spot-card {
        top: auto;
        right: 0;
        left: 0;
        bottom: -100%;
        width: 100%;
        max-height: 75vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 30px rgba(31, 42, 36, 0.2);
        transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .map-spot-card.visible {
        right: 0;
        bottom: 0;
    }

    .spot-card-drag-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: var(--fb-gray-200);
        border-radius: 2px;
        margin: 10px auto 6px;
        flex-shrink: 0;
    }

    .spot-card-header {
        padding: 8px 20px 16px;
    }

    /* Show mobile overlay */
    .spot-modal-overlay { display: none; }
    .spot-modal-overlay.visible { display: block; }

    .map-legend-card {
        display: none;
    }
    /* JS 把图例卡重挂进筛选抽屉后(.in-drawer)恢复显示并去卡片化:
       手机此前完全没有图例/指标切换, 满屏彩色河线无从解读 */
    .map-legend-card.in-drawer {
        display: block;
        position: static;
        box-shadow: none;
        border-radius: 0;
        padding: 0 0 12px;
        margin-bottom: 12px;
        border-bottom: 1px solid var(--fb-border, #e5e9e7);
    }

    /* 抽屉内的筛选卡去掉嵌套卡片感(白卡套白抽屉+阴影很怪) */
    .map-filter-card {
        border-radius: 0;
        box-shadow: none;
        max-width: none;
    }

    /* 移动端把缩放控件下移, 避让顶部居中搜索框(搜索框 top 14px + 高约 46px → 约止于 60px) */
    :root {
        --map-control-y: 72px;
    }

    /* Larger touch targets for map controls on mobile */
    .map-control-btn {
        width: 48px;
        height: 48px;
    }

    .map-control-btn svg {
        width: 24px;
        height: 24px;
    }

    /* Mobile spot card metrics: 2 columns for longer labels */
    .spot-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .spot-metric-label {
        white-space: normal;
        font-size: 12px;
    }

    .spot-metric-value {
        font-size: 15px;
    }

    /* Larger close button for spot card */
    .spot-card-close {
        width: 40px;
        height: 40px;
    }

}

/* Mobile Filter FAB */
.map-filter-fab {
    display: none;
}

@media (max-width: 768px) {
    .map-filter-fab {
        display: flex;
        align-items: center;
        gap: 6px;
        position: absolute;
        /* 左下角: 原 top:12px/left:12px 与顶部决策入口条("查附近能不能钓")在窄屏直接重叠压字 */
        bottom: 64px;
        left: 12px;
        z-index: var(--z-map-fab);
        background: var(--fb-surface);
        border: none;
        border-radius: var(--fb-radius-pill);
        box-shadow: 0 2px 12px rgba(31, 42, 36, 0.15);
        padding: 10px 16px;
        font-size: 14px;
        font-weight: 600;
        color: var(--fb-ink);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .map-filter-fab svg {
        color: var(--fb-blue);
    }

    .map-filter-fab { animation: fabPulse 2s ease 2s 2; }
    @keyframes fabPulse { 0%,100% { box-shadow: 0 2px 12px rgba(31,42,36,0.15); } 50% { box-shadow: 0 2px 16px rgba(58,111,140,0.35); } }

    /* Hide FAB when panel is expanded */
    .map-panel.expanded ~ .map-controls ~ .map-filter-fab {
        display: none;
    }
}

/* P2 触控目标: 移动端把筛选 chip / 清除按钮放大到 ≥40px 热区。
   筛选面板是底抽屉(max-height 60vh + overflow-y auto), 放大后超高会滚动,
   不会盖住顶部搜索框或地图操作。 */
@media (max-width: 768px) {
    .filter-chip {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 13px;
        gap: 6px;
    }
    .filter-chip input {
        width: 16px;
        height: 16px;
    }
    .filter-clear {
        min-height: 40px;
        padding: 8px 4px;
        font-size: 13px;
    }
    .map-filter-title {
        font-size: 14px;
    }
    .filter-group-label {
        font-size: 12px;
    }
}

/* Welcome Guide - top toast style */
.map-welcome-guide {
    position: absolute;
    top: 72px;  /* 搜索框上移到顶部后, 引导 toast 下移避让(原 12px 会盖住搜索框) */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(47, 64, 56, 0.88);
    color: white;
    padding: 10px 20px;
    border-radius: var(--fb-radius-pill);
    font-size: 13px;
    z-index: var(--z-map-toast);
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    animation: toastAppear 0.4s ease 1s both, toastFade 0.6s ease 5.5s both;
    max-width: 420px;
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
.map-welcome-guide svg { flex-shrink: 0; opacity: 0.7; width: 16px; height: 16px; }
@keyframes toastAppear { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastFade { to { opacity: 0; visibility: hidden; } }
@media (max-width: 768px) {
    .map-welcome-guide { top: 72px; font-size: 12px; padding: 8px 16px; white-space: normal; max-width: calc(100% - 100px); text-align: center; }  /* 搜索框顶置后避让 */
}

/* 无障碍:首页河流搜索框可见焦点环(模板内联样式已移除 outline:none) */
#reach-search-input:focus,
#reach-search-input:focus-visible {
    outline: none;
    border-color: var(--fb-blue, #3a6f8c);
    box-shadow: 0 0 0 3px rgba(58, 111, 140, 0.35), 0 2px 12px rgba(0, 0, 0, 0.12);
}

/* 减少动态效果:欢迎提示是纯 CSS 动画驱动的瞬时 toast,关掉动画会让它永久停留,
   故在 reduce 模式下不展示(去除动态干扰,避免遗留常驻横幅)。 */
@media (prefers-reduced-motion: reduce) {
    .map-welcome-guide { animation: none; display: none; }
}

.map-fallback-notice {
    position: absolute;
    top: 58px;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    z-index: var(--z-map-toast);
    max-width: min(520px, calc(100% - 360px));
    background: rgba(255, 255, 255, 0.96);
    color: var(--fb-ink);
    border: 1px solid rgba(214, 165, 76, 0.55);
    border-left: 4px solid var(--fb-gold);
    border-radius: var(--fb-radius-md);
    box-shadow: 0 6px 18px rgba(31, 42, 36, 0.16);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.map-fallback-notice.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .map-fallback-notice {
        top: 104px;
        max-width: calc(100% - 32px);
        font-size: 12px;
        padding: 9px 12px;
    }
}

/* Loading State */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--fb-surface);
    padding: 16px 24px;
    border-radius: var(--fb-radius-lg);
    box-shadow: 0 4px 20px rgba(31, 42, 36, 0.12);
    font-size: 14px;
    color: var(--fb-ink);
    z-index: var(--z-map-toast);
}

/* 天地图标识样式 - 透明背景 */
.leaflet-control-attribution {
    font-size: 10px !important;
    /* 原 #666 透明底≈4.23:1(略低于4.5) → 半透明白底衬 + 加深文字。
       #454545 对白≈9.7:1, 最劣(白衬压深瓦片)≈5.8:1 ≥4.5:1 */
    background: rgba(255, 255, 255, 0.78) !important;
    color: #454545 !important;
    padding: 0 4px;
    border-radius: 4px;
    text-shadow: none;
}
.leaflet-control-attribution a {
    color: #333 !important;
}

#map-main .leaflet-interactive:focus,
#map-main .leaflet-interactive:focus-visible {
    outline: none;
}

/* 聚合点 DOM 样式 */
.leaflet-marker-icon.cluster-dot {
    background: none !important;
    border: none !important;
}

/* 站点圆点 DOM 样式 */
.leaflet-marker-icon.station-dot {
    background: none !important;
    border: none !important;
}

/* 站点名称标签 */
.station-label {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #d1d5db !important;
    border-radius: 4px !important;
    padding: 1px 5px !important;
    font-size: 12px !important;
    color: #374151 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    white-space: nowrap !important;
    pointer-events: none !important;
}

.river-tooltip {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #93c5fd !important;
    border-radius: 4px !important;
    padding: 2px 8px !important;
    font-size: 12px !important;
    color: #1e40af !important;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2) !important;
}

/* 首页 SEO 内链区样式已删(2026-07-03): 区块迁至 /discover/, 首页回归纯全屏地图 */
