/* ============================================================
   Geospatial Explorer - Styles
   ============================================================ */

:root {
    --panel-bg: rgba(10, 10, 10, 0.82);
    --left-panel-width: 360px;
    --right-panel-width: 360px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Honor the HTML `hidden` attribute even on flex/grid containers. */
[hidden] {
    display: none !important;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Map ---- */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ---- Global backdrop blur (applied consistently to all UI panels) ---- */
.panel,
.search-input,
.search-results,
.legend-card,
.stack-card {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* ---- Panels (shared) ---- */
.panel {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 8;
    background: var(--panel-bg);
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    /* Visible so the resize handle can extend over the map; .panel-body scrolls. */
    overflow: visible;
    transition: transform 0.3s ease;
}

.panel-left {
    left: 0;
    width: var(--left-panel-width);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-right {
    right: 0;
    width: var(--right-panel-width);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-resize-handle {
    position: absolute;
    top: 0;
    width: 12px;
    height: 100%;
    cursor: col-resize;
    z-index: 9;
    touch-action: none;
}

.panel-left .panel-resize-handle {
    right: -6px;
}

.panel-right .panel-resize-handle {
    left: -6px;
}

.panel-hidden .panel-resize-handle {
    visibility: hidden;
    pointer-events: none;
}

.panel-resize-handle:hover,
.panel-resize-handle:focus-visible,
.panel-resize-handle.is-dragging {
    background: rgba(255, 255, 255, 0.16);
}

.panel-resize-handle:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.35);
    outline-offset: -1px;
}

body.panel-resizing {
    cursor: col-resize;
    user-select: none;
}

body.panel-resizing #bottom-left-stack,
body.panel-resizing #bottom-right-stack {
    transition: none;
}

.panel-hidden.panel-left {
    transform: translateX(-100%);
}

.panel-hidden.panel-right {
    transform: translateX(100%);
}

/* ---- Panel header ---- */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #f0f0f0;
}

/* ---- Panel body (scrollable) ---- */
.panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0;
}

/* ---- Buttons ---- */
.panel-toggle-btn,
.panel-close-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #9a9a9a;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.3s ease, border-color 0.3s ease,
        transform 0.3s ease, border-radius 0.3s ease;
}

.panel-toggle-btn:hover,
.panel-close-btn:hover {
    color: #f0f0f0;
    background: rgba(255, 255, 255, 0.08);
}

.panel-toggle-btn .toggle-arrow {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* When a panel slides offscreen, hide the in-header toggle — external edge
   controls (see .panel-mobile-edge) reopen it. Arrow flip kept for the open
   state close affordance. */
#left-panel.panel-hidden .panel-toggle-btn,
#right-panel.panel-hidden .panel-toggle-btn {
    visibility: hidden;
    pointer-events: none;
}

.panel-hidden .panel-toggle-btn .toggle-arrow {
    transform: scaleX(-1);
}

/* Right-panel toggle is hidden until the panel has something to show. */
#right-panel:not(.has-content) .panel-toggle-btn {
    display: none;
}

/* Basemap card radio options */
.basemap-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 13px;
}

.basemap-option input[type="radio"] {
    accent-color: #8ab4f8;
    cursor: pointer;
}

.basemap-option:hover span {
    color: #f0f0f0;
}

.panel-open-left {
    left: 0;
}

.panel-open-right {
    right: 0;
    border-radius: 6px 0 0 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-right: none;
}

/* ---- Floating search bar ---- */
#search-section {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    width: 320px;
}

.search-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 9px 16px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.search-input:focus {
    border-color: #9a9a9a;
    background: var(--panel-bg);
}

.search-input::placeholder {
    color: #707070;
}

.search-results {
    display: none;
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 10;
}

.search-results.visible {
    display: block;
}

.search-result-item {
    padding: 10px 16px;
    font-size: 13px;
    color: #e0e0e0;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.search-result-item.active {
    background: rgba(255, 255, 255, 0.14);
}

.search-result-item:first-child {
    border-radius: 8px 8px 0 0;
}

.search-result-item:last-child {
    border-radius: 0 0 8px 8px;
}

.search-no-results {
    padding: 10px 16px;
    font-size: 12px;
    color: #707070;
}

/* ---- Bottom-left stack (filters + legends) ---- */
#bottom-left-stack {
    position: absolute;
    top: 1rem;
    left: calc(var(--left-panel-width) + 8px);
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    transition: left 0.3s ease;
}

body.left-panel-collapsed #bottom-left-stack {
    left: 44px;
}

/* ---- Bottom-right stack (legends + pin bucket legend) ---- */
/* Default right offset = 44px to leave room for the right-panel toggle when
   the right panel is collapsed; mirrors body.left-panel-collapsed's
   left: 44px on #bottom-left-stack. When the right panel is open the whole
   stack slides left by the panel width. */
#bottom-right-stack {
    position: absolute;
    top: 1rem;
    right: 44px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    transition: right 0.3s ease;
}

body:has(#right-panel:not(.panel-hidden)) #bottom-right-stack {
    right: calc(var(--right-panel-width) + 12px);
}

.stack-card {
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    max-width: 220px;
    pointer-events: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.stack-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    user-select: none;
}

.stack-card-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #c0c0c0;
}

.stack-card-chevron {
    font-size: 9px;
    color: #707070;
}

.stack-card-body {
    padding: 8px 10px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.stack-card.collapsed .stack-card-body {
    display: none;
}

/* ---- Filter card ---- */
#filter-card-body > div + div {
    margin-top: 10px;
}

#filter-card-body [id^="cat-filter-"] {
    width: 100%;
}

.filter-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #707070;
    margin-bottom: 6px;
}

.filter-hint {
    font-size: 11px;
    color: #8a8a8a;
    margin: -2px 0 8px;
    line-height: 1.35;
}

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

.year-select {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 6px 8px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.year-select:focus {
    border-color: #9a9a9a;
}

.year-select option {
    background: #1a1a1a;
    color: #e0e0e0;
}


.date-mode-row {
    margin-bottom: 6px;
    gap: 12px;
}

.date-mode-option {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #c0c0c0;
    cursor: pointer;
}

.date-mode-option input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.month-input {
    font-family: inherit;
    color-scheme: dark;
}

/* ---- Layer list ---- */
.layer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.layer-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.layer-drag-handle {
    color: #505050;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
}

.layer-row:active .layer-drag-handle {
    cursor: grabbing;
}

.layer-row.dragging {
    opacity: 0.4;
}

.layer-row.drag-over-top {
    box-shadow: inset 0 2px 0 0 #9a9a9a;
}

.layer-row.drag-over-bottom {
    box-shadow: inset 0 -2px 0 0 #9a9a9a;
}

.layer-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #505050;
    border-radius: 3px;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.layer-row input[type="checkbox"]:checked {
    background: #9a9a9a;
    border-color: #9a9a9a;
}

.layer-row input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.layer-name {
    flex: 1;
    font-size: 13px;
    color: #c0c0c0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-color-swatch {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    background-color: var(--swatch-color, #e0e0e0);
    clip-path: var(--swatch-clip, none);
}

.layer-years,
.layer-count {
    font-size: 11px;
    color: #707070;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
    min-width: 24px;
    text-align: center;
}

.layer-years:empty {
    display: none;
}

.layer-year-warn {
    font-size: 11px;
    color: #3d3000;
    background: #f5c518;
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
    min-width: 24px;
    text-align: center;
    cursor: help;
}

.layer-year-warn[hidden] {
    display: none;
}

.layer-zoom-warn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    color: #f5a524;
}

/* Beat .layer-row [data-vdp-tip] { cursor: pointer } so the warn keeps help cursor */
.layer-row .layer-zoom-warn {
    cursor: help;
}

.layer-zoom-warn[hidden] {
    display: none;
}

.layer-zoom-warn-icon {
    display: block;
}

.panel-temporal-warnings {
    margin: 0 0 10px 0;
}

.panel-temporal-warn {
    font-size: 11px;
    color: #3d3000;
    background: #f5c518;
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: help;
    line-height: 1.35;
}

.layer-options-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 6px 48px;
    font-size: 11px;
    color: #9a9a9a;
}

.layer-options-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #707070;
}

.layer-options-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.layer-options-group input[type="radio"] {
    margin: 0 2px 0 0;
    cursor: pointer;
}

.layer-options-choice {
    cursor: pointer;
    color: #c0c0c0;
}

/* ---- Per-layer categorical filters (under each layer row) ---- */
.layer-cat-filters {
    padding: 6px 16px 10px 44px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.layer-cat-filter + .layer-cat-filter {
    margin-top: 8px;
}

.layer-cat-filter .filter-label {
    margin-bottom: 4px;
}

/* ---- Custom tooltip (shared, fixed-position to escape panel overflow) ---- */
#vdp-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: 260px;
    padding: 8px 10px;
    background: rgba(20, 20, 20, 0.96);
    color: #e0e0e0;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    white-space: normal;
    word-wrap: break-word;
}

#vdp-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

#vdp-tooltip.rich p {
    margin: 0 0 0.5em;
}

#vdp-tooltip.rich p:last-child {
    margin-bottom: 0;
}

#vdp-tooltip.rich ul {
    margin: 0.25em 0 0.5em;
    padding-left: 1.2em;
}

#vdp-tooltip.rich li {
    margin-bottom: 0.25em;
}

#vdp-tooltip.rich strong {
    color: #f0f0f0;
    font-weight: 600;
}

#vdp-tooltip.rich a {
    color: #93c5fd;
    text-decoration: underline;
}

[data-vdp-tip] {
    cursor: help;
}

.detail-key {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.field-help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: #707070;
    line-height: 0;
    cursor: help;
    vertical-align: middle;
}

.field-help-tip:hover,
.field-help-tip:focus {
    color: #a0a0a0;
    outline: none;
}

.field-help-tip:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.25);
    outline-offset: 2px;
    border-radius: 50%;
}

.field-help-icon {
    display: block;
}

.prop-key .detail-key,
.panel-stats-key .detail-key,
.field-stats-windowed-label .detail-key {
    max-width: 100%;
}

.layer-row [data-vdp-tip] {
    cursor: pointer;
}

/* ---- Placeholder / empty state ---- */
.panel-placeholder {
    padding: 24px 16px;
    color: #707070;
    font-size: 13px;
    text-align: center;
}

/* ---- Right-panel key-value table ---- */
.right-panel-table {
    width: 100%;
    border-collapse: collapse;
}

.right-panel-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.right-panel-table td {
    padding: 8px 16px;
    font-size: 12px;
    vertical-align: top;
}

.right-panel-table .prop-key {
    color: #9a9a9a;
    font-weight: 500;
    width: 40%;
    word-break: break-word;
}

.right-panel-table .prop-val {
    color: #e0e0e0;
    word-break: break-word;
}

.popup-preliminary-note {
    padding: 8px 16px 12px;
    font-size: 11px;
    font-style: italic;
    color: #b8a96a;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.right-panel-layer-header {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #9a9a9a;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.right-panel-layer-header:first-child {
    border-top: none;
}

.right-panel-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 2px 16px;
}

/* ---- Observation history (SMAP / NDVI drill-down) ---- */
.obs-history {
    margin-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.obs-history-header {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #9a9a9a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.obs-history-header-label {
    flex: 1 1 auto;
    min-width: 0;
}

.obs-csv-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #c8c8c8;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    padding: 4px 8px;
}

.obs-csv-download-btn:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.3);
    color: #f0f0f0;
}

.obs-csv-download-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 2px;
}

.obs-csv-download-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.obs-history-body {
    padding: 0 0 8px;
}

.obs-history-loading,
.obs-history-empty,
.obs-history-note {
    padding: 6px 16px 10px;
    font-size: 12px;
    color: #9a9a9a;
}

.obs-history-scroll {
    overflow-y: auto;
    /* max-height is set in JS from leftover panel space (see layoutObsHistoryScrolls). */
}

.obs-history-table {
    width: 100%;
    border-collapse: collapse;
}

.obs-history-table th,
.obs-history-table td {
    padding: 6px 16px;
    font-size: 12px;
    text-align: left;
}

.obs-history-table th {
    color: #9a9a9a;
    font-weight: 500;
    position: sticky;
    top: 0;
    background: #1a1a1a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.obs-history-table td {
    color: #e0e0e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.obs-history-scroll::-webkit-scrollbar {
    width: 5px;
}

.obs-history-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

/* ---- Scrollbar styling ---- */
.panel-body::-webkit-scrollbar,
#bottom-right-stack::-webkit-scrollbar,
#bottom-left-stack::-webkit-scrollbar {
    width: 5px;
}

.panel-body::-webkit-scrollbar-track,
#bottom-right-stack::-webkit-scrollbar-track,
#bottom-left-stack::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb,
#bottom-right-stack::-webkit-scrollbar-thumb,
#bottom-left-stack::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

.panel-body::-webkit-scrollbar-thumb:hover,
#bottom-right-stack::-webkit-scrollbar-thumb:hover,
#bottom-left-stack::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---- Logo / header ---- */
.floating-logo {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    max-height: 28px;
    width: auto;
    pointer-events: none;
}

/* ---- Spider cluster points ---- */
.spider-point {
    width: 18px;
    height: 18px;
    cursor: pointer;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
    transition: transform 0.1s ease;
    background-color: var(--swatch-color, #e0e0e0);
    clip-path: var(--swatch-clip, none);
}

.spider-point:hover {
    transform: scale(1.4);
    z-index: 10;
}

/* ---- Pin marker ---- */
.pin-marker {
    width: 24px;
    height: 24px;
    background: #e0e0e0;
    border: 3px solid #1a1a1a;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ---- County stats ---- */
.panel-stats-header {
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: #f0f0f0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-stats-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.panel-stats-header-label {
    min-width: 0;
    flex: 1;
}

.field-shp-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #c8c8c8;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    padding: 4px 8px;
}

.field-shp-download-btn:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.3);
    color: #f0f0f0;
}

.field-shp-download-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 2px;
}

.field-shp-download-btn:disabled {
    cursor: default;
    opacity: 0.5;
}

.field-shp-download-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.field-multi-select-hint {
    font-size: 11px;
    color: #8a8a8a;
    line-height: 1.35;
}

.field-multi-select-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-multi-clear-btn {
    align-self: flex-start;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #c8c8c8;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
}

.field-multi-clear-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: #f0f0f0;
}

.field-multi-select-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.field-multi-select-item:last-child {
    border-bottom: none;
}

.field-multi-select-item-main {
    font-size: 13px;
    color: #e8e8e8;
}

.field-multi-select-item-meta {
    font-size: 11px;
    color: #8a8a8a;
    margin-top: 2px;
}

.panel-stats-section {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-stats-layer-name {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #9a9a9a;
    margin-bottom: 6px;
}

.panel-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    font-size: 12px;
}

.panel-stats-breakdown-label {
    margin-top: 8px;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    color: #c8c8c8;
}

.panel-stats-key {
    color: #9a9a9a;
}

.panel-stats-val {
    color: #e0e0e0;
    text-align: right;
    max-width: 55%;
    word-break: break-word;
}

.panel-stats-sub {
    padding: 10px 16px 4px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7f8ea3;
}

/* ---- Field stats: windowed metric sub-table (7d / 30d / 90d / 12mo) ---- */
.field-stats-windowed-header,
.field-stats-windowed-row {
    display: grid;
    grid-template-columns: 1.4fr repeat(4, 1fr);
    gap: 4px;
    align-items: baseline;
    padding: 3px 0;
    font-size: 12px;
}

.field-stats-windowed-header {
    color: #7f8ea3;
    font-size: 10px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 4px;
}

.field-stats-windowed-label {
    color: #9a9a9a;
}

.field-stats-windowed-cell {
    color: #e0e0e0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.field-stats-windowed-header .field-stats-windowed-cell {
    color: #7f8ea3;
}

.field-stats-month-table {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    row-gap: 2px;
    margin: 2px 0 4px 0;
}

.field-stats-month-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    padding: 1px 0;
}

.field-stats-month-label {
    color: #9a9a9a;
}

.field-stats-month-val {
    color: #e0e0e0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.field-stats-footnote {
    font-size: 11px;
    color: #8b9bad;
    padding: 2px 0 4px 0;
    font-style: italic;
}

.pin-section-sep {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 0 0 0;
}

.pin-rings-header {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr 1fr;
    gap: 6px;
    padding: 6px 16px 4px 16px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9a9a9a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pin-rings-col-head {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.pin-ring-swatch {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: var(--swatch-color);
}

.hail-pin-tooltip {
    font: 11px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

.pin-rings-row {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr 1fr;
    gap: 6px;
    align-items: baseline;
    padding: 3px 0;
    font-size: 12px;
}

.pin-rings-key {
    color: #9a9a9a;
    text-align: left;
    word-break: break-word;
}

.pin-rings-cell {
    color: #e0e0e0;
    text-align: right;
    word-break: break-word;
}

.pin-rings-skipped {
    padding: 6px 16px 10px 16px;
    font-size: 10px;
    color: #6b7280;
    font-style: italic;
}

/* ---- Legend ---- */
#legend-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-card {
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    max-width: 220px;
    pointer-events: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* ---- Pin bucket + ring legend sections (inside a .legend-card) ---- */
.pin-bucket-section + .pin-bucket-section {
    margin-top: 8px;
}

.pin-bucket-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #707070;
    margin: 0 0 4px;
}

/* Override .legend-swatch's square look — hail buckets map to circular dots. */
.pin-bucket-swatch {
    border-radius: 50%;
}

.pin-ring-dash {
    width: 12px;
    height: 0;
    flex-shrink: 0;
    border-top: 2px dashed var(--swatch-color);
}

.legend-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    user-select: none;
}

.legend-card-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #c0c0c0;
}

.legend-chevron {
    font-size: 9px;
    color: #707070;
    transition: transform 0.15s ease;
}

.legend-card-body {
    padding: 6px 10px 8px;
}

.legend-card.collapsed .legend-card-body {
    display: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
    background-color: var(--swatch-color, transparent);
}

.legend-label {
    font-size: 11px;
    color: #c0c0c0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-gradient {
    height: 12px;
    border-radius: 3px;
    width: 100%;
    background: var(--gradient-stops, transparent);
}

.legend-gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #9a9a9a;
    margin-top: 3px;
}

/* Legend scrollbar */
.legend-card-body::-webkit-scrollbar {
    width: 4px;
}
.legend-card-body::-webkit-scrollbar-track {
    background: transparent;
}
.legend-card-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

/* ---- Map chrome ---- */
body.map-app {
    position: relative;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#user-bar {
    position: absolute;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 7;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: calc(100vw - 24px);
    padding: 8px 12px;
    background: var(--panel-bg);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-size: 13px;
    pointer-events: auto;
}

.user-bar-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 14rem;
}

.user-bar-link {
    color: #8ab4f8;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.user-bar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #f85149;
    background: none;
    border: 0;
    cursor: pointer;
    padding: 2px;
    line-height: 0;
    flex-shrink: 0;
}

.user-bar-logout:hover {
    color: #ff7b72;
}

.user-bar-link:hover {
    text-decoration: underline;
}

/* Edge controls live outside transformed panels so they stay visible when collapsed. */
.panel-mobile-edge {
    display: none;
}

.panel-mobile-edge:not([hidden]) {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top, 0px));
    z-index: 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 10px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.panel-mobile-edge-left {
    left: 0;
    border-left-color: transparent;
    border-radius: 0 6px 6px 0;
}

.panel-mobile-edge-right {
    right: 0;
    border-right-color: transparent;
    border-radius: 6px 0 0 6px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    :root {
        --left-panel-width: 240px;
        --right-panel-width: 240px;
    }

    .panel {
        z-index: 8;
    }

    .panel-right {
        width: var(--right-panel-width);
    }

    .panel-resize-handle {
        display: none;
    }

    #search-section {
        width: 260px;
    }

    /* Hide the search bar while either slide-out panel is open — the panel's
       z-index sits below the search, which then overlaps it. */
    body.mobile-panel-open #search-section { display: none; }

    #user-bar {
        bottom: calc(52px + env(safe-area-inset-bottom, 0px));
        font-size: 12px;
        padding: 7px 10px;
        gap: 8px;
    }

    .user-bar-email {
        max-width: 10rem;
    }

    /* Hide bottom stacks by default — only visible inside the overlay. */
    #bottom-left-stack,
    #bottom-right-stack { display: none; }

    /* Funnel button — fixed top-left, clearing the left-panel edge toggle. */
    .mobile-stack-toggle {
        position: fixed;
        top: calc(12px + env(safe-area-inset-top, 0px));
        left: calc(56px + env(safe-area-inset-left, 0px));
        z-index: 6;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--panel-bg);
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 6px;
        color: #e0e0e0;
        cursor: pointer;
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }
    .mobile-stack-toggle[hidden] { display: none !important; }
    body.mobile-panel-open .mobile-stack-toggle { display: none; }

    /* Filters/legends full-screen sheet */
    body.mobile-stack-overlay #search-section,
    body.mobile-stack-overlay .floating-logo,
    body.mobile-stack-overlay .panel-mobile-edge,
    body.mobile-stack-overlay #user-bar {
        display: none !important;
    }

    body.mobile-stack-overlay #bottom-left-stack {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100vw;
        max-height: 100dvh;
        margin: 0;
        background: var(--panel-bg);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 20;
        padding: calc(56px + env(safe-area-inset-top, 0px)) 16px
            calc(16px + env(safe-area-inset-bottom, 0px));
        gap: 12px;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    body.mobile-stack-overlay #bottom-right-stack {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100vw;
        max-height: min(45dvh, 360px);
        margin: 0;
        background: linear-gradient(to top, var(--panel-bg) 85%, transparent);
        z-index: 21;
        padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
        gap: 12px;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
        pointer-events: none;
    }

    body.mobile-stack-overlay #bottom-right-stack > * {
        pointer-events: auto;
    }

    body.mobile-stack-overlay .stack-card,
    body.mobile-stack-overlay .legend-card {
        max-width: none;
        width: 100%;
    }

    body.mobile-stack-overlay .stack-card-body {
        max-height: none;
    }

    /* Funnel button acts as close control above the sheet */
    body.mobile-stack-overlay .mobile-stack-toggle {
        z-index: 22;
        background: rgba(255, 255, 255, 0.16);
        color: #ffffff;
    }
}

@media (max-width: 480px) {
    .panel-left {
        width: 100%;
        border-right: none;
    }

    .panel-right {
        width: 100%;
        border-left: none;
    }

    #search-section {
        width: 220px;
    }
}
