:root {
    --bg: #eef1f3;
    --panel: #ffffff;
    --ink: #172026;
    --muted: #63717a;
    --line: #d5dde1;
    --bloom: #dc2626;
    --unusable: #6b7280;
    --accent: #0f5d7a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a {
    color: var(--accent);
}

[hidden] {
    display: none !important;
}

/* Header --------------------------------------------------------------- */

.site-header {
    background: #102a36;
    color: #ffffff;
    border-bottom: 3px solid var(--bloom);
}

.site-header-inner {
    max-width: 1900px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.header-link {
    color: #ffffff;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.9rem;
}

.header-link:hover,
.header-link:focus-visible {
    background: rgba(255, 255, 255, 0.14);
}

/* Page ----------------------------------------------------------------- */

.page {
    max-width: 1900px;
    margin: 0 auto;
    padding: 22px 24px 44px;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(1.5rem, 2vw, 2rem);
    letter-spacing: -0.02em;
}

.lead {
    margin: 4px 0 0;
    color: var(--muted);
    max-width: 900px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px 28px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    margin: 18px 0;
}

.control {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

.control select {
    font: inherit;
    font-weight: 500;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid #b7c3c9;
    border-radius: 7px;
    padding: 7px 10px;
    min-width: 230px;
}

.slider-control {
    min-width: min(360px, 100%);
}

.slider-control span {
    white-space: nowrap;
}

.slider-control output {
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.slider-control input {
    width: 260px;
    max-width: 100%;
    accent-color: var(--bloom);
}

.status {
    margin: 0 0 2px auto;
    color: var(--muted);
    font-size: 0.9rem;
}

.status.error {
    color: #a32222;
    font-weight: 600;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 18px;
    align-items: start;
}

/* Map ------------------------------------------------------------------ */

.map-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    min-width: 0;
}

.map-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 6px;
    background: #101820;
    user-select: none;
}

.map-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}

.map-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.tooltip {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    background: rgba(15, 23, 28, 0.94);
    color: #ffffff;
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.map-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 10px 4px 2px;
    font-size: 0.86rem;
    color: var(--muted);
}

.legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.legend-item,
.count-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.swatch {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 3px;
    flex: 0 0 auto;
}

.swatch-bloom {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.35), rgba(220, 38, 38, 0.95));
    border: 1px solid rgba(150, 18, 18, 0.55);
}

.swatch-unusable {
    background: rgba(107, 114, 128, 0.55);
    border: 1px solid rgba(75, 85, 99, 0.55);
}

.swatch-none {
    background: transparent;
    border: 1px dashed #85939b;
}

.visible-note {
    font-variant-numeric: tabular-nums;
}

/* Side panel ----------------------------------------------------------- */

.side {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
}

.card h2 {
    margin: 0 0 4px;
    font-size: 1rem;
    letter-spacing: 0.01em;
}

.card-subtitle {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.84rem;
}

.counts {
    border-top: 1px solid var(--line);
}

.count-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid #edf1f3;
}

.count-row strong {
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.muted {
    color: var(--muted);
    font-size: 0.85rem;
}

#count-total {
    margin: 10px 0 0;
}

.details {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 16px;
    margin: 0;
}

.details dt {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.86rem;
}

.details dd {
    margin: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #ffffff;
}

.badge-bloom {
    background: var(--bloom);
}

.badge-no-bloom {
    background: var(--accent);
}

.badge-unusable {
    background: var(--unusable);
}

.badge-none {
    background: #9aa7ae;
}

/* API test ------------------------------------------------------------- */

.api-test {
    margin-top: 18px;
    scroll-margin-top: 18px;
}

.api-page .api-test {
    margin-top: 22px;
}

.api-page code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.api-test-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-bottom: 14px;
}

.api-test-head .muted {
    margin: 2px 0 0;
}

.api-test-head .status {
    margin: 0;
}

.api-calls {
    display: grid;
    gap: 10px;
}

.api-call {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 12px;
}

.api-call-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-call-name {
    font-size: 0.88rem;
    font-weight: 700;
}

.api-method {
    border-radius: 4px;
    background: #e3f0f5;
    color: var(--accent);
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.api-call-url {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    font: 0.92rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--ink);
    background: #f8fafb;
    border: 1px solid #b7c3c9;
    border-radius: 7px;
    padding: 10px 12px;
}

.api-call-url:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.api-call-button {
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 7px;
    min-height: 46px;
    padding: 10px 22px;
    cursor: pointer;
}

.api-call-button:hover {
    background: #0b4a61;
}

.api-call-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.api-result {
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.api-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f5f8f9;
    border-bottom: 1px solid var(--line);
    padding: 8px 12px;
}

.api-result-head h3 {
    margin: 0;
    font-size: 0.9rem;
}

.api-output {
    margin: 0;
    padding: 12px;
    max-height: 360px;
    overflow: auto;
    background: #0f1b22;
    color: #d9e6ec;
    font: 0.82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 700px) {
    .api-call {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .api-call-head {
        grid-column: 1 / -1;
    }
}

.footnote {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

/* Responsive ----------------------------------------------------------- */

@media (max-width: 1350px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .side {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .page {
        padding: 16px 12px 32px;
    }

    .site-header-inner {
        padding: 10px 14px;
    }

    .controls {
        align-items: stretch;
    }

    .control select,
    .slider-control,
    .slider-control input {
        width: 100%;
    }

    .slider-control span {
        white-space: normal;
    }

    .status {
        margin-left: 0;
    }

    .side {
        grid-template-columns: minmax(0, 1fr);
    }

    .map-card {
        padding: 6px;
    }
}
