/* Stratosphere viewer. Full-viewport app under the site header: top bar
   (mode switch, Save Image), then the docked side menu beside the active
   view (map or chart); on narrow screens a tab bar at the bottom instead,
   opening the menu's parts as a sheet. strat.js sizes the map canvas
   square to fit #map-wrap; strat-ts.js sizes the chart SVG to #ts-wrap. */

.strat-app {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-h, 44px));
    height: calc(100dvh - var(--header-h, 44px));
    min-height: 420px;
}

/* Author display rules beat the UA [hidden] rule; restore it. */
.strat-app [hidden] { display: none !important; }

/* --- Top bar -------------------------------------------------------------- */

.strat-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
    padding: 0.45rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .strat-bar { background: var(--accent-soft); }
.strat-bar h1 { font-size: 1.1rem; letter-spacing: -0.02em; margin: 0; }

.strat-seg {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    background: var(--bg-card);
}
.strat-seg button {
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.2rem 0.95rem;
    border: 0;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}
.strat-seg button + button { border-left: 1px solid var(--border); }
.strat-seg button:hover { color: var(--text); }
.strat-seg button.active { background: var(--accent); color: #fff; }

/* --- Body: side menu + view ------------------------------------------------ */

.strat-body {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
}

.strat-side {
    flex: none;
    width: 300px;
    overflow-y: auto;
    padding: 0.75rem 0.9rem 1rem;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
}
.strat-app.side-closed .strat-side { display: none; }

.side-group + .side-group { margin-top: 1.1rem; }
.side-group h2 {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.4rem;
}
.side-note { font-size: 0.82rem; color: var(--text-muted); margin: 0.4rem 0 0; line-height: 1.4; }

.side-btns { display: flex; flex-direction: column; gap: 0.3rem; }
.side-btns-row { flex-direction: row; }
.side-btns button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}
.side-btns-row button { flex: 1; justify-content: center; }
.side-btns-tight { gap: 0.25rem; }
.side-btns-tight button { padding: 0.35rem 0.2rem; min-width: 0; }
.side-btns button svg { width: 15px; height: 15px; flex: none; }
.side-btns button:hover { border-color: var(--accent); }
.side-btns button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.side-btns button:disabled { opacity: 0.4; cursor: default; }

.side-checks { display: flex; flex-direction: column; gap: 0.15rem; }
.side-checks label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    cursor: pointer;
    padding: 0.1rem 0;
}
.side-checks input { accent-color: var(--accent); margin: 0; }
.side-checks-top { margin-top: 0.5rem; }
.side-checks .side-field { cursor: default; flex-wrap: wrap; gap: 0.3rem; }
.side-field select {
    font: inherit;
    font-size: 0.85rem;
    padding: 0.05rem 0.2rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
}

.side-checks .sub { font-size: 0.76rem; color: var(--text-muted); margin-left: auto; }
.side-checks h3 {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0.35rem 0 0.1rem;
}
.swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; }
.swatch.ens { height: 0; border-top: 3px dashed; background: none !important; }

.strat-view {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

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

.strat-map-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}
#map { display: block; border-radius: 6px; cursor: crosshair; }

.strat-readout {
    position: absolute;
    pointer-events: none;
    padding: 0.25rem 0.5rem;
    font-size: 0.82rem;
    line-height: 1.35;
    white-space: nowrap;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    box-shadow: var(--shadow);
    z-index: 2;
}
.strat-status {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    pointer-events: none;
}

/* Colorbar beside the map (wide map area) or under it (strat.js resize sets
   .legend-below), as tall / wide as the map. The canvas is drawn at its CSS
   size: vertical with its labels only, or horizontal under the title span. */
.strat-map-wrap { gap: 0.75rem; }
.strat-map-wrap.legend-below { flex-direction: column; gap: 0.35rem; }
.strat-legend { flex: none; display: flex; flex-direction: column; align-items: center; }
.strat-legend-label { font-size: 0.78rem; color: var(--text-muted); text-align: center; }
.strat-map-wrap:not(.legend-below) .strat-legend-label { display: none; }
#legend { display: block; }

/* ---------------------------------------------------------------------------
   Forecast-hour loop bar, ported from the models viewer (models/assets/models.css
   .loop-bar ... .loop-fhr, itself from the tropics page). Here it sits in the
   map view's flow under the map rather than fixed to the viewport.
   --------------------------------------------------------------------------- */
.loop-bar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 44px;
    padding: 0 0.9rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}
.loop-btn {
    width: 28px;
    height: 28px;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}
.loop-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.loop-btn:disabled { opacity: 0.35; cursor: default; }

.loop-speed {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    height: 28px;
    margin-right: 0.35rem;
    padding: 0 0.1rem 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
}
.loop-speed:hover, .loop-speed:focus-within { border-color: var(--accent); }
.loop-speed svg { width: 15px; height: 15px; flex: none; }
.loop-bar .loop-speed select {
    padding: 0.2rem 0.25rem;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}
.loop-bar .loop-speed select:focus { outline: none; }

/* Frame slider: the native range keeps dragging, keys and a11y with an
   invisible thumb the size of .loop-thumb; the bubble is drawn on top at
   left = p * (track - thumb). --loop-buf (set from JS) marks loaded hours. */
.loop-track {
    --p: 0;
    --thumb-w: 46px;
    --thumb-h: 22px;
    --loop-buf-color: #4da3ff;
    position: relative;
    flex: 1;
    min-width: 80px;
    height: 28px;
    display: flex;
    align-items: center;
}
[data-theme="dark"] .loop-track { --loop-buf-color: rgba(90, 162, 238, 0.38); }
.loop-track input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 30px;
    margin: 0;
    background: transparent;
    cursor: pointer;
}
.loop-track input[type="range"]:focus { outline: none; }
.loop-track input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    border: 0;
    box-shadow: none;
    background: var(--loop-buf, none), var(--border);
}
.loop-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--thumb-w);
    height: var(--thumb-h);
    margin-top: calc((6px - var(--thumb-h)) / 2);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 0;
}
.loop-track input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: var(--loop-buf, none), var(--border);
}
.loop-track input[type="range"]::-moz-range-progress { background: transparent; }
.loop-track input[type="range"]::-moz-range-thumb {
    width: var(--thumb-w);
    height: var(--thumb-h);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 0;
}
.loop-thumb {
    position: absolute;
    top: 50%;
    left: calc(var(--p) * (100% - var(--thumb-w)));
    box-sizing: border-box;
    width: var(--thumb-w);
    height: var(--thumb-h);
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    transition: transform 0.12s ease;
}
.loop-track:hover .loop-thumb,
.loop-track input[type="range"]:active + .loop-thumb { transform: translateY(-50%) scale(1.08); }
.loop-track input[type="range"]:focus-visible + .loop-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }

.loop-preload {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.74rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.loop-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    animation: loop-spin 0.7s linear infinite;
}
@keyframes loop-spin { to { transform: rotate(360deg); } }

/* Hour, then Valid: small caption over the value, a hairline between them. */
.loop-fhr, .loop-hour {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.loop-fhr { min-width: 2.6rem; margin-left: 0.35rem; }
.loop-hour { min-width: 128px; margin-left: 0.15rem; padding-left: 0.6rem; border-left: 1px solid var(--border); }
.loop-hour-cap {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.loop-hour-val { font-size: 0.84rem; font-weight: 700; color: var(--text); }

@media (max-width: 720px) {
    /* Two rows: transport + Speed left, readouts right; the slider below at full width. */
    .loop-bar { height: 72px; gap: 0.35rem; padding: 0 0.5rem; flex-wrap: wrap; align-content: center; row-gap: 2px; }
    .loop-speed { margin-right: auto; padding-left: 0.4rem; }
    .loop-speed-word { display: none; }
    .loop-track { order: 10; flex: 1 1 100%; min-width: 64px; }
    .loop-hour { min-width: 0; padding-left: 0.4rem; }
    .loop-hour .loop-hour-cap, .loop-hour-sep { display: none; }
    .loop-fhr { min-width: 0; margin-left: 0.15rem; }
    .loop-fhr .loop-hour-cap { font-size: 0.58rem; }
    .loop-fhr .loop-hour-val { font-size: 0.74rem; line-height: 1.2; }
    .loop-hour-val { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.74rem; line-height: 1.2; }
}

.side-field-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; }

/* --- Time-series view -------------------------------------------------------- */

.ts-wrap { position: relative; flex: 1; min-height: 0; padding: 0.5rem 0.75rem 0; }
.strat-chart { display: block; width: 100%; height: 100%; color: var(--text); font-family: inherit; }
.strat-chart .grid line { stroke: var(--border); }
.strat-chart .axis text { fill: var(--text-muted); font-size: 13px; }
.strat-chart .axis-title { fill: var(--text-muted); font-size: 13.5px; }
.strat-chart .zero { stroke: var(--text); stroke-width: 1.2; opacity: 0.7; }
.strat-chart .frame { fill: none; stroke: var(--border); }
.strat-chart .cursor { stroke: var(--text); stroke-width: 1; opacity: 0.55; }
.strat-chart .now { stroke: var(--accent); stroke-dasharray: 2 3; }
.strat-chart .now-label { fill: var(--accent); font-size: 12px; }
.ts-tip { line-height: 1.45; }
.ts-tip table { border-collapse: collapse; }
.ts-tip td { padding: 0 0.3rem; }
.ts-tip td.v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.ts-tip td.f { color: var(--text-muted); font-size: 0.75rem; }
.ts-tip .hd { font-weight: 600; margin-bottom: 0.15rem; }

.ts-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 1.1rem;
    padding: 0.35rem 1rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.ts-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.ts-legend b { color: var(--text); font-weight: 600; }

/* --- Narrow screens: the side menu floats over the view ------------------------ */

@media (max-width: 760px) {
    .strat-bar { padding-left: 0.75rem; padding-right: 0.75rem; }
}
/* Narrow screens (strat.js's narrow query: the same width): the menu is a
   sheet rising over the view from the tab bar at the bottom, showing only
   the open tab's part (data-sheet; the section bands give way to the sheet's
   own head). */
.sheet-bar, .sheet-head { display: none; }
@media (max-width: 900px) {
    .strat-side {
        position: absolute;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
        max-height: 72%;
        z-index: 5;
        padding-top: 0;
        border-right: 0;
        border-top: 1px solid var(--border);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.18);
    }
    .sheet-head {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 -0.9rem 0.6rem;
        padding: 0.55rem 0.9rem 0.45rem;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
    }
    .sheet-name { font-size: 0.95rem; font-weight: 700; }
    .sheet-close {
        width: 2rem; height: 2rem; padding: 0; font: inherit; font-size: 1.4rem; line-height: 1;
        border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer;
    }
    .strat-side .pane-title { display: none; }
    .strat-app .ts-bar { display: none; }   /* (its Chart type and Parameter / Model: tabs of the bar at the bottom) */
    .strat-side .pane-section + .pane-section { margin-top: 0; }
    .strat-app[data-sheet="model"] .strat-side [data-sheet]:not([data-sheet~="model"]),
    .strat-app[data-sheet="cycle"] .strat-side [data-sheet]:not([data-sheet~="cycle"]),
    .strat-app[data-sheet="param"] .strat-side [data-sheet]:not([data-sheet~="param"]),
    .strat-app[data-sheet="settings"] .strat-side [data-sheet]:not([data-sheet~="settings"]),
    .strat-app[data-sheet="models"] .strat-side [data-sheet]:not([data-sheet~="models"]),
    .strat-app[data-sheet="season"] .strat-side [data-sheet]:not([data-sheet~="season"]),
    .strat-app[data-sheet="layers"] .strat-side [data-sheet]:not([data-sheet~="layers"]),
    .strat-app[data-sheet="range"] .strat-side [data-sheet]:not([data-sheet~="range"]) { display: none !important; }
    .sheet-bar {
        flex: none;
        display: flex;
        gap: 4px;
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-card);
        border-top: 1px solid var(--border);
    }
    .sheet-bar button {
        flex: 1;
        min-width: 0;
        font: inherit;
        font-size: 0.84rem;
        font-weight: 600;
        padding: 0.6rem 0.25rem;
        border: 0;
        border-radius: 8px;
        background: none;
        color: var(--text-muted);
        cursor: pointer;
        white-space: nowrap;
    }
    .sheet-bar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
    .sheet-bar button:hover { color: var(--text); }
    .sheet-bar button.active { background: var(--accent-soft); color: var(--accent); }
    /* (a tab's current choice under its name: plain, smaller, cut to the tab) */
    .tab-name { line-height: 1.15; }
    .tab-val { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 0.72rem; font-weight: 400; line-height: 1.2;
               color: var(--text); opacity: 0.8; }
    .tab-val:empty { display: none; }
    .sheet-bar button.has-val { padding-top: 0.4rem; padding-bottom: 0.4rem; }
    .tab-menu .dd-opt.disabled { opacity: 0.45; cursor: default; }
}

/* --- Modal (vortex-gap chart) ------------------------------------------------- */

.strat-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(8, 14, 22, 0.55);
}
.strat-modal[hidden] { display: none; }
.strat-modal-box {
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    height: min(620px, 100%);
    padding: 0.8rem 1rem 0.4rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.strat-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.strat-modal-head h2 { font-size: 1.05rem; margin: 0; }
.strat-modal-close {
    font: inherit;
    font-size: 1.5rem;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}
.strat-modal-close:hover { border-color: var(--accent); }
.gap-wrap { padding: 0.25rem 0 0; }
.strat-modal-head .bar-save { margin-left: auto; margin-right: -0.5rem; }
.side-btns-top { margin-top: 0.5rem; }

/* ---------------------------------------------------------------------------
   Styled dropdowns (dropdown.js), ported from the models viewer's models.css
   (.dd-btn ... .dd-list.compact): a button in the side menu, a list in a
   fixed-position popup attached to <body>.
   --------------------------------------------------------------------------- */
.strat-app .dd-btn { display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; min-height: 40px;
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text);
    font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; }
.strat-app .dd-btn:hover:not(:disabled) { border-color: var(--accent); }
.strat-app .dd.open .dd-btn, .strat-app .dd-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.strat-app .dd-btn:disabled { cursor: default; opacity: 0.75; }
.strat-app .dd-btn svg { flex: none; width: 16px; height: 16px; color: var(--text-muted); margin-left: auto; transition: transform 0.18s ease; }
.strat-app .dd.open .dd-btn svg { transform: rotate(180deg); }
.dd-label { display: grid; min-width: 0; flex: 1; }
.dd-main { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-sub { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-badge { flex: none; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--accent);
    background: var(--accent-soft); border-radius: 999px; padding: 2px 7px; }
.dd-list { position: fixed; z-index: 150; box-sizing: border-box; overflow-y: auto; padding: 5px; outline: none;
    background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 10px 30px rgba(16, 34, 56, 0.18), 0 2px 6px rgba(16, 34, 56, 0.08);
    font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; line-height: 1.35;
    animation: dd-in 0.14s ease; transform-origin: top center; }
.dd-list.up { transform-origin: bottom center; }
.dd-list[hidden] { display: none !important; }
[data-theme="dark"] .dd-list { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.dd-list.up { animation-name: dd-in-up; }
@keyframes dd-in-up { from { opacity: 0; transform: translateY(4px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .dd-list { animation: none; } }
.dd-group { padding: 8px 9px 3px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.dd-group:first-child { padding-top: 4px; }
.dd-opt { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 7px; cursor: pointer; }
.dd-opt.active { background: var(--accent-soft); }
.dd-opt.selected .dd-main { color: var(--accent); }
.dd-opt.selected::after { content: '\2713'; flex: none; color: var(--accent); font-weight: 700; }
.dd-list.compact .dd-label { display: flex; align-items: baseline; gap: 8px; }
.dd-list.compact .dd-opt { padding: 5px 9px; }

/* Cycle menu + Trend button on one row; the trend slider below (hidden until it's on), as the
   models viewer's .cycle-row / .trend-btn / .cycle-slider / .trend-track */
.cycle-row { display: flex; align-items: stretch; gap: 6px; }
.cycle-row .dd { flex: 1; min-width: 0; }
.season-row .loop-btn { width: 34px; height: auto; font-size: 1.15rem; }
.trend-btn { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted); font: inherit; font-size: 12px;
    font-weight: 600; white-space: nowrap; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.trend-btn svg { width: 15px; height: 15px; }
.trend-btn:hover { color: var(--text); border-color: var(--accent); }
.trend-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cycle-slider { display: grid; gap: 2px; padding: 6px 2px 0; }
.trend-track { --thumb-w: 68px; flex: none; width: 100%; min-width: 0; }
.trend-track input:disabled { cursor: default; }
.trend-track:has(input:disabled) .loop-thumb { opacity: 0.6; }
.cycle-ends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-muted); }

/* Toggle switches, as the models viewer's (models.css .switch / .pick-option):
   the label left, the switch right. */
.switch { position: relative; flex: 0 0 auto; width: 40px; height: 22px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.15s ease;
    pointer-events: none;
}
.switch .slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled { cursor: default; }
.switch input:disabled + .slider { opacity: 0.45; }
.pick-option { display: flex; align-items: center; gap: 6px; padding: 2px 2px 2px 4px;
    font-size: 0.88rem; font-weight: 600; color: var(--text); user-select: none; }
.pick-option > label { display: flex; align-items: center; gap: 0.45rem; flex: 1; min-width: 0; cursor: pointer; }
.pick-option .switch { transform: scale(0.9); transform-origin: right center; margin-left: auto; }
.pick-option .sub { font-size: 0.76rem; font-weight: 400; color: var(--text-muted); margin-left: auto; }
.pick-option.off > label { color: var(--text-muted); }

/* Climatology underlay (strat-ts.js createChart opts.underlay): gray bands
   under the lines, the mean solid, the records dotted. */
.strat-chart .climo-outer { fill: var(--text-muted); fill-opacity: 0.13; stroke: none; }
.strat-chart .climo-inner { fill: var(--text-muted); fill-opacity: 0.16; stroke: none; }
.strat-chart .climo-mean { fill: none; stroke: var(--text-muted); stroke-width: 2.6; opacity: 0.9; }
/* Records: dashed, red for the record high, blue for the record low (>= 3:1 on both themes). */
.strat-chart .climo-rec-high,
.strat-chart .climo-rec-low { fill: none; stroke-width: 2; stroke-dasharray: 6 4; }
.strat-chart .climo-rec-high { stroke: #d6403a; }
.strat-chart .climo-rec-low { stroke: #3b7dd8; }
.swatch.rec-high-sw { height: 0; background: none !important; border-top: 2px dashed #d6403a; }
.swatch.rec-low-sw { height: 0; background: none !important; border-top: 2px dashed #3b7dd8; }
.swatch.climo-sw { background: var(--text-muted); }
.swatch.block { height: 10px; width: 12px; border-radius: 2px; }
.swatch.climo-outer-sw { background: color-mix(in srgb, var(--text-muted) 22%, transparent); }
.swatch.climo-inner-sw { background: color-mix(in srgb, var(--text-muted) 40%, transparent); }

/* Time Series: Lines or Climo rank (one stacked panel per ensemble); the
   status pill over either. History uses the same chart layout. */
.ts-view { position: relative; }
.ts-lines { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ts-rank { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0.4rem 0.75rem 0; }
.rank-panels { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.rank-panel { flex: 1; min-height: 160px; display: flex; flex-direction: column; }
.rank-panel h3 { margin: 0; font-size: 0.85rem; font-weight: 600; }
.rank-panel h3 .f { color: var(--text-muted); font-weight: 400; margin-left: 0.4rem; }
.rank-wrap { position: relative; flex: 1; min-height: 0; }
.ts-rank .ts-legend .f { color: var(--text-muted); }

/* History: highlighted-season chips under the menu */
.hist-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
.hist-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.25rem 0.1rem 0.5rem;
    border: 1px solid var(--border); border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.hist-chip button { border: 0; background: none; color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.hist-chip button:hover { color: var(--text); }

/* Dual-handle range, ported from the tropics viewer (tropics.css .dual-range):
   two stacked transparent sliders over a drawn track; only the thumbs take
   pointer events. */
.dual-range { position: relative; height: 26px; }
.dual-range .dual-track,
.dual-range .dual-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    border-radius: 2px;
}
.dual-range .dual-track { left: 0; right: 0; background: var(--border); }
.dual-range .dual-fill { background: var(--accent); }
.dual-range input[type="range"] {
    position: absolute;
    inset: 0;
    width: 100%;
    margin: 0;
    background: none;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    pointer-events: auto;
    cursor: pointer;
}
.dual-range input[type="range"]::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    pointer-events: auto;
    cursor: pointer;
}
.dual-range input[type="range"]::-moz-range-track { background: transparent; }
.dual-range input[type="range"]:disabled::-webkit-slider-thumb { border-color: var(--border); }
.dual-range input[type="range"]:disabled::-moz-range-thumb { border-color: var(--border); }
.range-label { margin-top: 2px; text-align: center; font-size: 0.82rem; font-weight: 600; color: var(--text); }
.range-foot { display: flex; align-items: baseline; justify-content: space-between; }
.range-foot .side-note { margin: 0.2rem 0 0; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 0.82rem; color: var(--accent); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--text-muted); cursor: default; text-decoration: none; }

/* History's season axis: month names bolder (the month-start rules are plain grid lines). */
.strat-chart .axis .month-label { fill: var(--text); font-weight: 600; font-size: 13.5px; }

/* Side-menu sections (Maps): full-width title bands, as the models viewer's
   .pane-section / .pane-title (models.css, its --title-bg / --title-fg). */
.strat-app { --title-bg: #2c4a6e; --title-fg: #ffffff; }
[data-theme="dark"] .strat-app { --title-bg: #2b3d55; --title-fg: #e4ebf3; }
.pane-section { display: grid; gap: 9px; align-content: start; }
.pane-section + .pane-section { margin-top: 16px; }
.pane-title {
    margin: 0 -0.9rem 2px;
    padding: 7px 0.9rem;
    text-align: center;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--title-bg);
    color: var(--title-fg);
}
.side-panel > .pane-section:first-child > .pane-title,
.side-panel > #ts-menu > .pane-section:first-child > .pane-title { margin-top: -0.75rem; }   /* (flush with the menu's top) */
.pane-field { display: grid; gap: 4px; }
.pane-label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
/* History sub-sections: centered heading between hairlines, set apart from the field */
.side-panel[data-for="hist"] .pane-field + .pane-field { margin-top: 12px; }
.side-panel[data-for="hist"] .pane-label {
    display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
    font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em; color: var(--text);
}
.side-panel[data-for="hist"] .pane-label::before,
.side-panel[data-for="hist"] .pane-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Parameter rows: the choice, then its (i). */
.product-list { display: grid; gap: 0.3rem; }
.product-row { display: flex; align-items: center; gap: 0.2rem; }
.product-btn {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}
.product-btn:hover { border-color: var(--accent); }
.product-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Information button, as the tropics viewer's .info-btn (tropics.css). */
.info-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex: 0 0 auto;
}
.info-btn:hover { background: var(--accent-soft); color: var(--text); }
.info-btn svg { width: 17px; height: 17px; }

/* Information modal (the (i) buttons), sized as the tropics viewer's .info-modal. */
.strat-modal-box.info-modal { width: min(560px, 100%); height: auto; max-height: min(80vh, 640px); padding: 0.8rem 1rem 1rem; }
.info-body { overflow-y: auto; padding: 0.6rem 0.2rem 0; font-size: 0.92rem; }
.info-body p { margin: 0 0 0.7rem; line-height: 1.5; }
.info-body ul { margin: 0 0 0.7rem; padding-left: 1.2rem; line-height: 1.5; }
.info-body li { margin: 0.2rem 0; }
.info-body .info-src { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0; }

/* The map's info box (top-left, strat.js setInfoBox): the index value, then the vortex diagnostic. */
.vortex-box {
    position: absolute;
    z-index: 2;
    max-width: 290px;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text);
    background: color-mix(in srgb, var(--bg-card) 88%, transparent);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    pointer-events: none;
}
.pick-option.with-info > label { flex: 0 1 auto; }
.pick-option .info-btn { width: 22px; height: 22px; margin-right: auto; }

.vortex-box .vb-group + .vb-group { margin-top: 0.3rem; padding-top: 0.3rem; border-top: 1px solid var(--border); }

/* Time Series: the bar over the chart (white in light mode): the parameters for
   Chart, the ensembles for Percentile Rank, as pill buttons. */
.ts-bar {
    flex: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    min-height: 44px;
    padding: 0.35rem 0.9rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.bar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.6rem; }
.bar-item { display: inline-flex; align-items: center; gap: 0.1rem; }
.ts-bar .product-btn {
    flex: none;
    padding: 0.25rem 0.85rem;
    border-radius: 999px;
    font-size: 0.86rem;
    background: var(--bg);
}
.ts-bar .product-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.bar-note { font-size: 0.8rem; color: var(--text-muted); margin-left: 0.3rem; }
/* The bar's Plot type menu (dropdown.js): at the left, a divider after it. */
.bar-type { flex: none; display: flex; align-items: center; gap: 0.5rem; padding-right: 0.9rem; margin-right: 0.1rem;
    border-right: 1px solid var(--border); align-self: stretch; }
.bar-type .dd { width: 172px; }
/* Labels left of each bar control: Chart Type, Parameter / Model */
.bar-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
    white-space: nowrap; margin-right: 0.15rem; }
.strat-app .bar-type .dd-btn { min-height: 32px; padding: 4px 10px; }

/* In-plot legend (strat-ts.js createChart opts.legend) */
.strat-chart .legend-bg { fill: var(--bg-card); fill-opacity: 0.92; stroke: var(--border); }
.strat-chart .legend-text { fill: var(--text); font-size: 13px; }

/* Time Series models: deterministic rows; each ensemble's row with its layer
   chips under it, sliding open while the ensemble is on. */
#ts-models-field { display: grid; gap: 10px; }
.model-group { display: grid; gap: 2px; }
.ens-item { border-radius: 7px; transition: background 0.2s ease; }
.ens-item.open { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.ens-cfg { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 0.22s ease, opacity 0.18s ease; }
.ens-item.open .ens-cfg { grid-template-rows: 1fr; opacity: 1; }
.ens-cfg-inner { overflow: hidden; min-height: 0; }
.ens-chips { display: flex; gap: 4px; padding: 1px 6px 7px 26px; }
.ens-chip {
    flex: 1;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.16rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ens-chip:hover { border-color: var(--accent); color: var(--text); }
.ens-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .ens-cfg, .ens-item { transition: none; } }

/* History: one toggle per forecast line, under the Latest forecasts switch */
.hist-fcst-models { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 2px 0 4px; }
.hist-fcst-chip { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 0.2rem 0.3rem; border-radius: 7px; }
.hist-fcst-name { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; }
.hist-fcst-run { font-size: 0.66rem; font-weight: 500; opacity: 0.85; }
.hist-fcst-chip[aria-pressed="false"] { opacity: 0.7; }
.hist-fcst-cap { grid-column: 1 / -1; font-size: 0.72rem; font-weight: 600; color: var(--text-muted); margin-top: 2px; }
.hist-fcst-chip { overflow: hidden; text-overflow: ellipsis; }
.hist-fcst-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hist-fcst-chip[aria-pressed="false"] .dot { opacity: 0.35; }

/* The model groups as cards: a small header strip over their rows. */
.model-card { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); overflow: hidden; }
.model-card-head {
    margin: 0;
    padding: 5px 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--accent-soft) 60%, var(--bg-card));
    border-bottom: 1px solid var(--border);
}
.model-card .model-group { padding: 4px; }
.model-card .pick-option { padding: 3px 4px 3px 6px; }

/* Chart readouts and the rank panel titles, sized with the larger chart text. */
.ts-tip { font-size: 0.9rem; }
.rank-panel h3 { font-size: 0.98rem; }

.strat-chart .x-title { fill: var(--text); font-weight: 700; }

/* The plot area's background: white in light mode, the card color in dark. */
.strat-chart .plot-bg { fill: var(--bg-card); }

/* Model rows' Trend button, as the tropics viewer's Models tab (.item-actions
   .info-btn: icon over a small caption); on while that model's trend is shown. */
.model-card .item-trend {
    flex-direction: column;
    gap: 1px;
    width: auto;
    min-width: 32px;
    height: auto;
    padding: 3px 4px 2px;
    margin-right: 4px;
    border-radius: 6px;
}
.model-card .item-trend svg { width: 15px; height: 15px; }
.model-card .item-trend .ia-lbl { font-size: 0.62rem; line-height: 1; letter-spacing: 0.01em; }
.model-card .item-trend.on { color: var(--accent); background: var(--accent-soft); }

/* Model trend mode: the panel standing in for the menu (model name, red exit,
   line thickness), and the cycle colorbar beside the chart. */
.mt-panel { display: grid; gap: 12px; }
.mt-title { margin: 0.2rem 0 0; text-align: center; font-size: 1.2rem; letter-spacing: -0.01em; }
.mt-exit {
    justify-self: center;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    padding: 0.4rem 1.1rem;
    border: 1px solid #c0392b;
    border-radius: 999px;
    background: #d6403a;
    color: #fff;
    cursor: pointer;
}
.mt-exit:hover { background: #b8322d; border-color: #a12a26; }
/* Trend panel fields: a readable label with its value on the right, then the control. */
.mt-field { display: grid; gap: 6px; }
.mt-field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
    font-size: 0.92rem; font-weight: 600; color: var(--text); }
.mt-val { font-size: 0.85rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.mt-note { font-size: 0.8rem; color: var(--text-muted); text-align: right; }
#ts-mt-panel .pick-option { font-size: 0.92rem; }
/* The thickness slider: a rounded track filled up to a round accent thumb (--p set by strat-ts.js). */
.mt-width {
    --p: 30%;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    margin: 0;
    background: transparent;
    cursor: pointer;
}
.mt-width:focus { outline: none; }
.mt-width::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--accent) var(--p), var(--border) var(--p));
}
.mt-width::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--bg-card);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.mt-width::-moz-range-track { height: 6px; border-radius: 3px; background: var(--border); }
.mt-width::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.mt-width::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--bg-card);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.mt-width:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }

.ts-plot-row { flex: 1; min-height: 0; display: flex; }
.ts-plot-row .ts-wrap { flex: 1; min-width: 0; }
#hist-wrap { padding-top: 0.15rem; }   /* (right under its title band) */
.ts-cbar { flex: none; width: 112px; padding: 2.2rem 0.6rem 0 0.2rem; display: flex; flex-direction: column; }
.cbar-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 0.35rem; }
.cbar-bands { display: flex; flex-direction: column; }
.cbar-cell { display: flex; align-items: center; gap: 0.45rem; height: 22px; }
.cbar-sw { flex: none; width: 16px; height: 100%; }
.cbar-cell:first-child .cbar-sw { border-radius: 3px 3px 0 0; }
.cbar-cell:last-child .cbar-sw { border-radius: 0 0 3px 3px; }
.cbar-lbl { font-size: 0.8rem; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Percentile Rank's colorbar (strat-ts.js createChart opts.colorbar): in the chart, right of the
   plot at its full height, or under it on narrow charts. */
.strat-chart .cb-frame { fill: none; stroke: var(--border); }
.strat-chart .cb-tick { stroke: var(--text-muted); }
.strat-chart .cb-label { fill: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.strat-chart .cb-end { fill: var(--text); font-size: 12px; font-weight: 600; }

/* Over the Time Series / History charts: the saved image's title band, on
   the page (the title left, the initialization etc. right, stacked lines),
   its type scaled down with the viewport; the right side drops under the
   title when the two don't fit side by side. */
.chart-head {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.15rem 1.25rem;
    padding: 0.55rem 0.9rem 0.1rem;
}
.chart-head:empty { display: none; }
.chart-title { font-size: clamp(0.98rem, 0.62rem + 1.05vw, 1.375rem); font-weight: 700; color: var(--text); line-height: 1.25; }
.chart-sub { display: flex; flex-direction: column; align-items: flex-end; margin-left: auto;
             font-size: clamp(0.82rem, 0.6rem + 0.62vw, 1.03rem); color: var(--text-muted); line-height: 1.3; text-align: right; }
.chart-sub .init { font-weight: 700; }
.chart-lsub { font-size: clamp(0.8rem, 0.6rem + 0.55vw, 0.95rem); color: var(--text-muted); line-height: 1.3; margin-top: 1px; }
.chart-head.stacked { flex-direction: column; justify-content: center; text-align: center; }
.chart-head.stacked .chart-sub { margin-left: 0; align-items: center; text-align: center; }

/* Save Image, at the right end of the bar over the chart. */
.bar-save {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    padding: 0.3rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
}
.bar-save svg { width: 16px; height: 16px; }
.bar-save:hover { border-color: var(--accent); color: var(--accent); }

/* SSW probability (ensembles only): no deterministic card, no per-ensemble layer chips. */
#ts-models-field.ssw #ts-det-card { display: none; }
#ts-models-field.ssw .ens-cfg { display: none; }
#ts-models-field.ssw .ens-item.open { background: none; }
