* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    color: #222;
    background: #1a1a1a;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

#sidebar {
    width: 260px;
    background: #f7f7f7;
    border-right: 1px solid #ddd;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#sidebar header h1 {
    margin: 0 0 2px 0;
    font-size: 16px;
    color: #c2552d;
}
#sidebar header .sub {
    color: #888;
    font-size: 11px;
}

#sidebar section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e6e6e6;
}
#sidebar section:last-child { border-bottom: none; }

#sidebar section.inline-section {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

#sidebar label {
    font-weight: 600;
    font-size: 12px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#sidebar label.small {
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    margin-top: 4px;
    color: #777;
}

select, input[type="range"], button {
    font: inherit;
}

select {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
}

input[type="range"] {
    flex: 1;
    accent-color: #c2552d;
}

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

#play-btn {
    width: 32px;
    height: 28px;
    border: none;
    background: #c2552d;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
#play-btn:hover { background: #a64722; }

#time-label {
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: #555;
    font-size: 12px;
}

.var-group-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #999;
    margin: 6px 0 4px 2px;
    font-weight: 600;
}
.var-group-title:first-child { margin-top: 0; }

.var-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 12px;
}
.var-option.active {
    border-color: #c2552d;
    background: #fdf2ec;
}
.var-option input {
    margin: 0;
    accent-color: #c2552d;
}

.profile-row {
    display: flex;
    gap: 6px;
}

#profile-toggle, #profile-clear {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
}
#profile-toggle.active {
    background: #c2552d;
    color: white;
    border-color: #c2552d;
}

/* compact pill toggle for base map */
.pill-toggle {
    display: inline-flex;
    border: 1px solid #ccc;
    border-radius: 999px;
    overflow: hidden;
    background: white;
    width: fit-content;
    font-size: 11px;
}
.pill-toggle.full-width {
    display: flex;
    width: 100%;
}
.pill-toggle.full-width .pill-btn {
    flex: 1;
    text-align: center;
}
.pill-btn {
    border: none;
    background: transparent;
    padding: 3px 12px;
    cursor: pointer;
    color: #555;
}
.pill-btn.active {
    background: #c2552d;
    color: white;
}

/* depth selector disabled state */
#depth-select:disabled {
    background: #eee;
    color: #aaa;
    cursor: not-allowed;
}
#depth-section.disabled label,
#percentile-section.disabled label {
    color: #aaa;
}
#percentile-select:disabled {
    background: #eee;
    color: #aaa;
    cursor: not-allowed;
}

/* platform popup */
.platform-popup h4 {
    margin: 0 0 2px 0;
    font-size: 14px;
}
.platform-popup hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 6px 0;
}
.platform-popup .muted {
    color: #888;
    font-size: 11px;
}
.platform-popup .warn {
    color: #c2552d;
    font-weight: 600;
    margin-top: 4px;
}
.platform-popup .ok {
    color: #2c8b3c;
    margin-top: 4px;
}
.platform-popup div {
    margin: 2px 0;
}

.muted { color: #888; }
.small { font-size: 11px; }

/* floating legend on the map */
#legend-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    font-size: 12px;
    min-width: 240px;
}
#legend-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}
#legend-cbar {
    display: block;
    border: 1px solid #aaa;
    border-radius: 2px;
}
#legend-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #555;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

#main {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: #aad;
}

/* data overlay should not catch clicks; allow browser smoothing for nicer scaling */
.leaflet-image-layer.data-overlay {
    pointer-events: none;
    image-rendering: auto;
    opacity: 1;
}

.leaflet-image-layer.contour-overlay {
    pointer-events: none;
    image-rendering: auto;
}

#profile-panel {
    position: absolute;
    left: 12px;
    bottom: 12px;
    width: 640px;
    max-width: calc(100% - 24px);
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    padding: 8px 10px 10px 10px;
    z-index: 1000;
}
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 6px;
    color: #333;
}
#profile-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #888;
}
.profile-body {
    display: flex;
    align-items: stretch;
}
#profile-y-axis, #profile-cbar {
    display: block;
    background: white;
}
#profile-canvas {
    flex: 1;
    display: block;
    border: 1px solid #ddd;
    image-rendering: auto;
}
#profile-x-axis {
    display: block;
    margin-left: 56px;   /* matches y-axis width */
    margin-right: 56px;
}

/* cursor when in profile-draw mode */
.leaflet-container.profile-mode {
    cursor: crosshair !important;
}
