.container {
    width: 100%;
}

body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
}

/*.navbar-brand {*/
/*    float: left;*/
/*    padding: 16px 15px;*/
/*    line-height: 18px;*/
/*    height: 50px;*/
/*    font-size: 20px;*/
/*    font-weight: 700;*/
/*    color: #dc2626;*/
/*    letter-spacing: -0.5px;*/
/*}*/
/*.navbar-brand:hover,*/
/*.navbar-brand:focus {*/
/*    text-decoration: none;*/
/*    color: #dc2626;*/
/*}*/
/*.navbar-brand span {*/
/*    color: #d97706;*/
/*}*/

/* ── Header ── */
.header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: #dc2626;
    letter-spacing: -0.5px;
}

.logo span {
    color: #d97706;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: #6b7280;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #dc2626;
}

.nav-links .active {
    color: #dc2626;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right a {
    color: #6b7280;
    text-decoration: none;
    font-size: 12px;
}

.header-right a:hover {
    color: #dc2626;
}

/* ── View tab ── */
.view-tab-bar {
    background: #fff;
    border-bottom: 2px solid #e5e7eb;
    padding: 0 24px;
    flex-shrink: 0;
    display: flex;
}

.view-tab {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #d97706;
    cursor: default;
    border-bottom: 3px solid #dc2626;
    margin-bottom: -2px;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

/* ── Main content ── */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Sidebar ── */
.sidebar {
    width: 300px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar h3 {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    /*text-transform: uppercase;*/
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.filter-select {
    width: 100%;
    padding: 9px 12px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.filter-select:focus {
    border-color: #dc2626;
}

.filter-select option {
    background: #fff;
    color: #1f2937;
}

.filter-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Stats box */
.species-info-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    margin-top: 4px;
    display: none;
}

.species-info-box.visible {
    display: block;
}

.species-info-box .info-label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.species-info-box .info-name {
    font-size: 16px;
    font-weight: 600;
    color: #d97706;
    margin: 4px 0;
    font-style: italic;
}

.species-info-box .info-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.species-info-box .info-count {
    font-size: 32px;
    font-weight: 700;
    color: #dc2626;
}

.info-sub {
    font-size: 12px;
    color: #6b7280;
}

/* Help text */
.help-text {
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.6;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

/* ── Map container ── */
.map-container {
    flex: 1;
    position: relative;
    background: #c9ddec;
    overflow: hidden;
    cursor: grab;
}

.map-container:active {
    cursor: grabbing;
}

#map {
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* ── Tooltip ── */
.tooltip-map {
    position: absolute;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    max-width: 240px;
}

.tooltip-map .tt-name {
    font-weight: 600;
    font-size: 13px;
    color: #d97706;
    margin-bottom: 2px;
}

.tooltip-map .tt-status {
    font-size: 12px;
    color: #6b7280;
}

.tooltip-map .tt-status.present {
    color: #dc2626;
    font-weight: 600;
}

.tooltip-map .tt-status.absent {
    color: #9ca3af;
}

/* ── Legend ── */
.legend-container {
    position: absolute;
    bottom: 24px;
    left: 24px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 14px 16px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.legend-title {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #4b5563;
}

.legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── Zoom controls ── */
.zoom-controls {
    position: absolute;
    top: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #4b5563;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.zoom-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.zoom-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* ── Loading ── */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(240, 242, 245, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #dc2626;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.species-modal-dialog {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    width: 520px;
    max-width: 94vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}

.species-modal-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.modal-region-name {
    font-size: 20px;
    font-weight: 700;
    color: #d97706;
}

.modal-close {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #6b7280;
    font-size: 16px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.modal-stats {
    display: flex;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-stat {
    text-align: center;
    flex: 1;
}

.modal-stat-val {
    font-size: 24px;
    font-weight: 700;
    color: #dc2626;
}

.modal-stat-lbl {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.modal-current-sp {
    padding: 10px 20px;
    font-size: 13px;
    border-bottom: 1px solid #e5e7eb;
    display: none;
    background: #fef3c7;
    color: #92400e;
}

.modal-current-sp.visible {
    display: block;
}

.modal-current-sp .present-tag {
    color: #16a34a;
    font-weight: 600;
}

.modal-current-sp .absent-tag {
    color: #dc2626;
    font-weight: 600;
}

.modal-body {
    padding: 12px 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-subf-header {
    font-size: 14px;
    font-weight: 600;
    color: #dc2626;
    /*text-transform: uppercase;*/
    letter-spacing: 0.5px;
    margin: 12px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-genus-header {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-left: 6px;
}

.modal-subf-header:first-child {
    margin-top: 0;
}

.modal-sp-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-bottom: 8px;
}

.modal-sp-a {
    text-decoration: none;
}

.modal-sp-item {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.15s;
}

.modal-sp-item:hover {
    color: #d97706;
    background: #fef3c7;
}

.modal-sp-item.selected {
    color: #d97706;
    background: #fef3c7;
    font-weight: 600;
}

.no-species-hint {
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
    padding: 40px 0;
}

/* ── Footer ── */
.footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
}

.footer a {
    color: #6b7280;
    text-decoration: none;
}

.footer a:hover {
    color: #dc2626;
}

/* ── Mobile sidebar close button ── */
.sidebar-close {
    display: none;
    position: absolute;
    top: 2px;
    right: 5px;
    width: 32px;
    height: 32px;
    border: none;
    background: #fff;
    color: #6b7280;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    z-index: 60;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    /*border-radius: 50%;*/
    /*border: 1px solid #d1d5db;*/
    /*background: #f9fafb;*/
}

.sidebar-close:hover {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

/* ── Mobile sidebar toggle button ── */
.sidebar-toggle {
    display: none;
    position: absolute;
    /*bottom: 24px;*/
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(220, 38, 38, 0.35);
    gap: 6px;
    align-items: center;
    white-space: nowrap;

    bottom: calc(14px + env(safe-area-inset-bottom));
    max-width: calc(100% - 24px);
}

.sidebar-toggle.visible {
    display: flex;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f0f2f5;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ═══════════════════════════════════
   Mobile responsive (< 768px)
   ═══════════════════════════════════ */
@media (max-width: 768px) {
    body,html{height:100%;margin:0;}
    /* Header: compact */
    .header {
        padding: 0 12px;
        height: 46px;
    }

    .logo {
        font-size: 16px;
    }

    .nav-links {
        display: none;
    }

    .header-right {
        gap: 8px;
    }

    .header-right a {
        font-size: 11px;
    }

    /* View tab: compact */
    .view-tab-bar {
        padding: 0 12px;
    }

    .view-tab {
        padding: 8px 14px;
        font-size: 13px;
    }

    /* Main content: stack vertically, map first */
    .main-content {
        flex-direction: column-reverse;
    }

    /* Sidebar: bottom sheet, collapsible */
    .sidebar {
        width: 100%;
        max-height: 55vh;
        border-right: none;
        border-top: 1px solid #e5e7eb;
        border-radius: 16px 16px 0 0;
        padding: 16px 14px 12px;
        gap: 10px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: #fff;
    }

    .sidebar.expanded {
        transform: translateY(0);
    }

    .sidebar.expanded .sidebar-close {
        display: flex;
    }

    .sidebar h3 {
        font-size: 11px;
    }

    .filter-select {
        padding: 11px 12px;
        font-size: 14px;
    }

    .species-info-box {
        padding: 10px;
    }

    .species-info-box .info-name {
        font-size: 14px;
    }

    .species-info-box .info-count {
        font-size: 26px;
    }

    .help-text {
        font-size: 11px;
        padding-top: 8px;
    }

    /* Map: full width */
    .map-container {
        flex: 1;
        height: auto;
    }

    /* Legend: smaller, reposition */
    .legend-container {
        bottom: calc(12px + env(safe-area-inset-bottom));
        left:12px;
        max-height:40vh; /* 限制最大高度，防止向下溢出屏幕 */
        overflow-y:auto; /* 内容多就内部滚动 */
        max-width: calc(100% - 24px);
    }

    .legend-title{font-size:11px;}
    .legend-row{font-size:11px;}

    .legend-swatch {
        width: 12px;
        height: 12px;
    }

    /* Zoom controls: bigger touch targets, reposition */
    .zoom-controls {
        top: 12px;
        left: 12px;
        gap: 6px;
    }

    .zoom-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        border-radius: 8px;
    }

    .zoom-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Tooltip: larger, mobile-friendly */
    .tooltip-map {
        font-size: 14px;
        padding: 10px 16px;
        max-width: 200px;
    }

    /* Modal: near-fullscreen */
    .species-modal-dialog {
        width: 100%;
        max-width: 100vw;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        margin: 0;
    }

    .modal-overlay {
        align-items: flex-end;
    }

    .species-modal-header {
        padding: 14px 16px 10px;
    }

    .modal-region-name {
        font-size: 17px;
    }

    .modal-close {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .modal-stats {
        padding: 10px 16px;
        gap: 8px;
    }

    .modal-stat-val {
        font-size: 20px;
    }

    .modal-stat-lbl {
        font-size: 10px;
    }

    .modal-current-sp {
        padding: 8px 16px;
        font-size: 12px;
    }

    .modal-body {
        padding: 10px 16px;
    }

    .modal-subf-header {
        font-size: 11px;
        margin: 8px 0 4px;
    }

    .modal-sp-item {
        font-size: 11px;
        padding: 3px 7px;
    }

    /* Footer: hide on mobile to save space */
    .footer {
        display: none;
    }

    .search-group{
        margin-top: 20px;
    }
}

/* Landscape phone: sidebar takes less height */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        max-height: 70vh;
    }

    .main-content {
        flex-direction: row;
    }

    .sidebar {
        width: 240px;
        max-height: none;
        border-radius: 0;
        border-top: none;
        border-right: 1px solid #e5e7eb;
        transform: none;
        position: relative;
        box-shadow: none;
    }

    .sidebar-toggle {
        display: none !important;
    }
}
.navbar-right {
    margin-right: 0;
}

/* 定位基准容器 */
.search-input-wrap-box {
    position: relative; /* 核心：子元素absolute以此为参照 */
}
.search-input-wrap {
    display: flex;
    gap: 6px;
    margin: 8px 0;
}
#ant-search-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}
.search-btn {
    padding: 6px 10px;
    background: #d7301f;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.search-btn:hover {
    background: #b30000;
}
/* 悬浮下拉核心样式 */
.search-result-list {
    position: absolute; /* 脱离文档流，悬浮覆盖下方 */
    top: 100%;         /* 紧贴输入框底部 */
    left: 0;
    right: 0;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(0,0,0,0.12); /* 浮层阴影区分层级 */
    z-index: 999;       /* 层级最高，盖住下方亚科下拉 */
    display: none;
}
.search-result-item {
    padding: 6px 8px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item:hover {
    background: #fff3e8;
}
.search-result-item .level-tag {
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 2px;
    margin-right: 6px;
}
.level-subfamily { background:#e1f5fe; color:#0277bd; }
.level-genus { background:#f3e5f5; color:#7b1fa2; }
.level-species { background:#ffebee; color:#c62828; }
.search-empty {
    padding: 8px;
    text-align: center;
    color: #666;
    font-size: 12px;
}