body {
    margin: 0;
    padding: 0;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

#menu {
    background: rgba(255, 255, 255, 0) !important;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    position: absolute;
    z-index: 1;
    top: 10px;
    right: 10px;
    border-radius: 5px;
    min-width: 160px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    font-family: 'Open Sans', sans-serif;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.menu-section {
    margin-bottom: 12px;
}

.menu-section:last-child {
    margin-bottom: 0;
}

.basemap-toggle-group {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.basemap-btn {
    flex: 1;
    padding: 5px 6px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    color: rgba(0,0,0,0.75);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.basemap-btn:hover {
    background: rgba(255,255,255,0.14);
    color: #000;
}

.basemap-btn.active {
    background: rgba(134,194,116,0.35);
    border-color: #86C274;
    color: #000;
    font-weight: 600;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.section-title {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#menu-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 0 2px;
    line-height: 1;
}

#menu-toggle:hover {
    color: #333;
}

#menu.collapsed #menu-body {
    display: none;
}

/* Hide the "Layers" title when expanded — only show it in the collapsed state */
#menu:not(.collapsed) .menu-header .section-title {
    display: none;
}

#menu:not(.collapsed) .menu-header {
    justify-content: flex-end;
    margin-bottom: 4px;
}

.radio-group label,
.checkbox-group label {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #404040;
    margin-bottom: 6px;
    cursor: pointer;
}

.radio-group label:last-child,
.checkbox-group label:last-child {
    margin-bottom: 0;
}

.radio-group input[type="radio"],
.checkbox-group input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
}

.radio-group span,
.checkbox-group span {
    margin-left: 6px;
}

#menu input[type="checkbox"] {
    cursor: pointer;
}

/* Layer groups */
.layer-group {
    margin-bottom: 8px;
}

.layer-group:last-child {
    margin-bottom: 0;
}

.layer-group-title {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 6px;
    list-style: none;
}

.layer-group-title::-webkit-details-marker {
    display: none;
}

.layer-group-title::before {
    content: '▾ ';
    font-size: 10px;
    color: #999;
}

details.layer-group:not([open]) .layer-group-title::before {
    content: '▸ ';
}

.layer-item {
    margin-bottom: 6px;
    padding-left: 8px;
}

.layer-item:last-child {
    margin-bottom: 0;
}

.layer-toggle {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #404040;
    cursor: pointer;
}

.layer-toggle input[type="checkbox"] {
    margin: 0 6px 0 0;
    cursor: pointer;
}

/* Version selector for versioned layers */
.version-select {
    display: block;
    margin: 4px 0 0 22px;
    font-size: 12px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    color: #404040;
    cursor: pointer;
    max-width: 200px;
}

.version-select option {
    background: rgba(255, 255, 255, 0.95);
    color: #404040;
}

/* Glass effect for species richness dropdown */
#species-taxon {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    color: #404040;
    padding: 4px 8px;
    cursor: pointer;
}

#species-taxon option {
    background: rgba(255, 255, 255, 0.95);
    color: #404040;
}

/* Legend styles */
#legend {
    background: rgba(255, 255, 255, 0) !important;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    position: absolute;
    z-index: 1;
    bottom: 10px;
    left: 10px;
    border-radius: 5px;
    max-width: 280px;
    max-height: 80vh;
    border: 1px solid rgba(0, 0, 0, 0.2);
    font-family: 'Open Sans', sans-serif;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

#legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(248, 249, 250, 0);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

#legend-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

#legend-toggle {
    background: none;
    border: none;
    font-size: 20px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color 0.2s;
}

#legend-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

#legend-content {
    padding: 10px 15px 15px;
    max-height: calc(80vh - 60px);
    overflow-y: auto;
}

#legend-content.collapsed {
    display: none;
}

.legend-section {
    margin-bottom: 15px;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-section h4 {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-colorbar {
    height: 12px;
    border-radius: 2px;
    margin: 4px 0 2px;
    border: 1px solid rgba(0,0,0,0.1);
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #666;
    margin-bottom: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 11px;
    color: #333;
    margin-bottom: 5px;
    line-height: 1.3;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-item span {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 8px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

/* Scrollbar styling for legend */
#legend-content::-webkit-scrollbar {
    width: 6px;
}

#legend-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#legend-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#legend-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* H3 hex grid toggle */
#h3-toggle {
    position: absolute;
    z-index: 1;
    bottom: 14px;
    left: 14px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    font-size: 18px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    padding: 0;
}

#h3-toggle:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #555;
}

#h3-toggle.active {
    background: rgba(0, 124, 191, 0.12);
    color: #007cbf;
    border-color: rgba(0, 124, 191, 0.35);
}

/* Hover tooltip */
.map-tooltip {
    display: none;
    position: fixed;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    color: #333;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    max-width: 260px;
}

.map-tooltip table {
    border-collapse: collapse;
    width: 100%;
}

.map-tooltip th {
    font-weight: 600;
    color: #666;
    text-align: left;
    padding: 2px 10px 2px 0;
    white-space: nowrap;
}

.map-tooltip td {
    color: #333;
    padding: 2px 0;
    word-break: break-word;
}

#h3-res-badge {
    position: absolute;
    z-index: 1;
    bottom: 52px;
    left: 14px;
    font-family: 'Open Sans', sans-serif;
    font-size: 10px;
    color: #555;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    pointer-events: none;
}