/* Senate / Governor forecast hub — bar caption, map key, controls (not home page) */

.forecast-hub-map-head-area {
    position: relative;
}

.forecast-hub-midterm-countdown {
    position: absolute;
    right: 0;
    z-index: 2;
    display: flex;
    flex-direction: row;
    align-items: center;
    pointer-events: none;
    transform: translateY(-50%);
}

.forecast-hub-midterm-countdown__hover {
    margin-right: 16px;
    text-align: right;
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms ease, visibility 120ms ease;
    pointer-events: none;
}

.forecast-hub-midterm-countdown:has(.forecast-hub-midterm-countdown__box:hover) .forecast-hub-midterm-countdown__hover {
    opacity: 1;
    visibility: visible;
}

.forecast-hub-midterm-countdown__hover-line1 {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.2;
    color: #94a3b8;
    white-space: nowrap;
}

.forecast-hub-midterm-countdown__hover-line2 {
    margin: 0.2rem 0 0;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
}

.forecast-hub-midterm-countdown__boxes {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
    pointer-events: auto;
}

.forecast-hub-midterm-countdown__box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(var(--hub-cd-box-size, 48px) * 0.04);
    width: calc(var(--hub-cd-box-size, 48px) - 11px);
    height: calc(var(--hub-cd-box-size, 48px) - 11px);
    box-sizing: border-box;
    padding: calc(var(--hub-cd-box-size, 48px) * 0.04);
    border-radius: 0.3rem;
    background: #4b5563;
    flex-shrink: 0;
}

.forecast-hub-midterm-countdown__value {
    color: #fff;
    font-size: calc(var(--hub-cd-box-size, 48px) * 0.36);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transform: translateY(1px);
}

.forecast-hub-midterm-countdown__unit {
    color: #e2e8f0;
    font-size: calc(var(--hub-cd-box-size, 48px) * 0.155);
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

@media (max-width: 767px) {
    .forecast-hub-midterm-countdown {
        position: static;
        transform: none;
        margin-top: 0.65rem;
        justify-content: flex-end;
        width: 100%;
    }
}

.forecast-hub-seat-block {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.forecast-hub-seat-bar-wrap {
    margin-bottom: 0 !important;
    position: relative;
}

.pollsmax-hub-seat-bar {
    position: relative;
    top: -16px;
}

.forecast-hub-bar-hover-label {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 25;
    pointer-events: none;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #f1f5f9;
    text-transform: uppercase;
    transform: translate(-50%, calc(-100% - 5px));
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.08s ease;
}

.forecast-hub-bar-hover-label--visible {
    opacity: 1;
}

.forecast-hub-bar-hover-label--numeric {
    text-transform: none;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.forecast-hub-bar-seg--race {
    cursor: default;
}

.forecast-hub-bar-seg--link {
    cursor: pointer;
}

.forecast-hub-bar-seg--highlight {
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 1) !important;
}

/* Seat bar: party row → caption → rail → majority hint */
.forecast-hub-seat-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.forecast-hub-bar-stack,
.forecast-hub-bar-track {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.forecast-hub-bar-above-rail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 0 0 10px;
    flex: 0 0 auto;
}

.forecast-hub-seat-bar-wrap .forecast-hub-bar-party-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 !important;
    position: static !important;
    flex: 0 0 auto;
}

.pollsmax-hub-seat-bar .forecast-hub-bar-party-row,
.pollsmax-hub-seat-bar .pollsmax-hub-seat-bar-party {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 0.5rem;
    margin: 0 0 10px !important;
    order: 1;
    letter-spacing: normal;
}

.pollsmax-hub-seat-bar .forecast-hub-bar-party-heading:first-of-type {
    justify-self: start;
}

.pollsmax-hub-seat-bar .forecast-hub-bar-party-heading:last-of-type {
    justify-self: end;
}

.pollsmax-hub-seat-bar .forecast-hub-bar-caption,
.pollsmax-hub-seat-bar .pollsmax-hub-seat-bar-caption {
    margin: 0 !important;
    justify-self: center;
    grid-column: 2;
    position: relative;
    top: 2px;
    white-space: nowrap;
    display: inline-block;
    width: max-content;
    max-width: 100%;
    letter-spacing: 0;
    font-kerning: normal;
    font-variant-numeric: normal;
    font-feature-settings: normal;
}

.pollsmax-hub-seat-bar .forecast-hub-bar-caption .eh-bar-caption-n,
.pollsmax-hub-seat-bar .forecast-hub-bar-caption .eh-bar-caption-tail {
    letter-spacing: inherit;
    font-variant-numeric: normal;
    font-feature-settings: normal;
}

.pollsmax-hub-seat-bar .forecast-hub-bar-party-heading {
    letter-spacing: normal;
}

.forecast-hub-seat-bar-wrap .forecast-hub-bar-caption {
    margin: 0 0 10px !important;
    padding: 0;
    font-size: 0.75rem;
    color: #64748b;
    text-align: center;
    line-height: 1.3;
    transition: opacity 0s, visibility 0s;
}

.forecast-hub-seat-bar-wrap--bar-hover .forecast-hub-bar-caption {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.06s ease, visibility 0.06s ease;
}

.forecast-hub-seat-bar-wrap .forecast-hub-bar-rail,
.forecast-hub-seat-bar-wrap .forecast-hub-bar-track > .relative.w-full.h-12,
.forecast-hub-seat-bar-wrap .forecast-hub-bar-track > .h-12 {
    margin: 0 !important;
    flex: 0 0 auto;
}

.forecast-hub-seat-bar-wrap .forecast-hub-bar-rail > .forecast-hub-bar-majority-stack,
.forecast-hub-seat-bar-wrap .pollsmax-hub-seat-bar-majority {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    margin: 0.35rem 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    width: max-content;
    max-width: 100%;
    pointer-events: none;
    color: #94a3b8;
}

/* Legacy: majority inside .forecast-hub-bar-track */
.forecast-hub-bar-track > .forecast-hub-bar-majority-stack {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    margin-top: 0.35rem;
}

.forecast-hub-bar-majority-triangle {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid currentColor;
}

.forecast-hub-bar-majority-text {
    font-size: 0.75rem;
    line-height: 1.2;
    color: inherit;
    text-align: center;
    white-space: nowrap;
    margin: 0;
}

.forecast-hub-bar-caption .eh-bar-caption-n {
    font-size: 0.75rem;
    font-weight: inherit;
    font-variant-numeric: tabular-nums;
}

.pollsmax-hub-seat-bar .forecast-hub-bar-caption .eh-bar-caption-n {
    font-variant-numeric: normal;
}

.forecast-hub-seat-bar-wrap .forecast-hub-bar-party-heading {
    color: #ffffff;
    font-weight: 400;
    font-size: 1.125rem;
    letter-spacing: 0.025em;
    line-height: 1.2;
    transition: opacity 0s, visibility 0s;
    position: static;
    top: auto;
    transform: none;
}

:root {
    --forecast-hub-key-swatch-h: 0.58rem;
    --forecast-hub-key-swatch-w: 2.05rem;
    --forecast-hub-key-swatch-gap: 0.38rem;
    --forecast-hub-key-swatch-block-h: calc(var(--forecast-hub-key-swatch-h) * 2 + var(--forecast-hub-key-swatch-gap));
    --forecast-hub-key-party-gap: 0.5rem;
    --forecast-hub-key-col-gap: 0.24rem;
}

/* Same width as senate-right section heading rules (border-slate-800/80), below map. */
.forecast-hub-map-below-rule {
    position: relative;
    width: 100%;
    border-bottom: 1px solid rgba(30, 41, 59, 0.8);
    margin-top: 0.5rem;
    margin-bottom: 0;
}

/* Collapsible legend + toggles — chevron above rule; collapsed pulls next section up. */
.forecast-hub-map-legend-shell {
    position: relative;
    margin-top: 0;
}

body.senate-hub-page .forecast-hub-map-legend-shell,
body.gov-hub-page .forecast-hub-map-legend-shell {
    margin-top: -35px;
}

.forecast-hub-map-legend-panel {
    position: relative;
    padding-bottom: 0;
}

.forecast-hub-map-legend-toggle-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 0.65rem;
    margin-bottom: 0.35rem;
    min-height: 1.5rem;
}

.forecast-hub-map-legend-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    line-height: 0;
    transition: color 0.12s ease;
}

.forecast-hub-map-legend-toggle:hover {
    color: #f8fafc;
}

.forecast-hub-map-legend-toggle:focus-visible {
    outline: 2px solid #1181ff;
    outline-offset: 3px;
    border-radius: 2px;
}

.forecast-hub-map-legend-chevron {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    transition: transform 0.18s ease;
}

.forecast-hub-map-legend-shell--collapsed .forecast-hub-map-legend-chevron {
    transform: rotate(180deg);
}

.forecast-hub-map-legend-shell--collapsed .forecast-hub-map-legend-body {
    display: none;
}

.forecast-hub-map-legend-shell--collapsed .forecast-hub-map-legend-toggle-row {
    margin-bottom: 0;
}

/* Collapsed: thin rule hosts the moving full-bleed line; map divider ::after steps aside. */
.forecast-hub-map-legend-shell--collapsed .forecast-hub-map-below-rule {
    border-bottom-color: transparent;
    margin-bottom: 0;
}

/* Collapsed: full-width rule aligned to Search polls line (left = aside vertical, right = viewport bleed). */
.forecast-hub-map-legend-shell--collapsed .forecast-hub-map-below-rule::after {
    content: "";
    position: absolute;
    left: var(--forecast-hub-map-below-rule-left, 0px);
    right: -1rem;
    bottom: 0;
    height: 1px;
    background: rgba(30, 41, 59, 0.8);
    pointer-events: none;
    opacity: 1;
    transition: none;
}

.senate-map-divider.forecast-hub-map-divider--legend-collapsed::after {
    opacity: 0;
    visibility: hidden;
}

@media (min-width: 640px) {
    .forecast-hub-map-legend-shell--collapsed .forecast-hub-map-below-rule::after {
        right: -1.5rem;
    }
}

@media (min-width: 1024px) {
    .forecast-hub-map-legend-shell--collapsed .forecast-hub-map-below-rule::after {
        right: -2.5rem;
    }
}

@media (min-width: 1280px) {
    .forecast-hub-map-legend-shell--collapsed .forecast-hub-map-below-rule::after {
        right: -3.5rem;
    }
}

/* Expanded: inset rule only (no ::after bleed line). */
.forecast-hub-map-legend-shell:not(.forecast-hub-map-legend-shell--collapsed) .forecast-hub-map-below-rule::after {
    content: none;
}

/* Pull the first section below the map up to the rule line above the key; following sections flow normally. */
section.senate-right-divider-inset.forecast-hub-legend-collapse-shifted {
    margin-top: calc(-1 * var(--forecast-hub-legend-collapse-shift, 0px) + 28px);
    transition: none;
}

/* First block below map: sit flush under the aligned rule (no extra top padding). */
section.senate-right-divider-inset.forecast-hub-legend-collapse-shifted--lead {
    padding-top: 0 !important;
}

.forecast-hub-map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-top: calc(0.85rem + 3px);
    margin-bottom: 0;
    min-height: calc(var(--forecast-hub-key-swatch-block-h) + 2.35rem);
}

.forecast-hub-map-key {
    min-width: 0;
}

.forecast-hub-key-matrix {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: var(--forecast-hub-key-party-gap);
    align-items: start;
}

.forecast-hub-key-party-col {
    display: grid;
    grid-template-rows: var(--forecast-hub-key-swatch-h) var(--forecast-hub-key-swatch-h);
    row-gap: var(--forecast-hub-key-swatch-gap);
    align-items: center;
    align-self: start;
}

.forecast-hub-key-party {
    font-size: 0.78rem;
    font-weight: 500;
    color: #94a3b8;
    white-space: nowrap;
    line-height: var(--forecast-hub-key-swatch-h);
    height: var(--forecast-hub-key-swatch-h);
    display: flex;
    align-items: center;
}

.forecast-hub-key-party--dem {
    transform: translateY(1px);
}

/* Five fixed slots (Solid, Likely, Lean, Tilt, Flip) — simple mode uses slots 1–2 only. */
.forecast-hub-key-cols-wrap {
    display: grid;
    grid-template-columns: repeat(5, minmax(var(--forecast-hub-key-swatch-w), 3.05rem));
    column-gap: var(--forecast-hub-key-col-gap);
    align-items: start;
}

.forecast-hub-key-col[data-hub-col="solid"] {
    grid-column: 1;
    grid-row: 1;
}

.forecast-hub-key-col[data-hub-col="likely"] {
    grid-column: 2;
    grid-row: 1;
}

.forecast-hub-key-col[data-hub-col="lean"] {
    grid-column: 3;
    grid-row: 1;
}

.forecast-hub-key-col[data-hub-col="tilt"] {
    grid-column: 4;
    grid-row: 1;
}

.forecast-hub-key-col[data-hub-col="flip"] {
    grid-column: 5;
    grid-row: 1;
}

/* More Detail off: Win stays in Solid slot, Flip in Likely slot; cols 3–5 stay empty. */
.forecast-hub-map-key:not(.forecast-hub-map-key--margins) .forecast-hub-key-col[data-hub-col="flip"] {
    grid-column: 2;
}

.forecast-hub-key-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.14rem;
    min-width: var(--forecast-hub-key-swatch-w);
    width: 100%;
    max-width: 3.05rem;
    justify-self: center;
}

/* Hide inactive columns; grid tracks keep the same spacing as full detail mode. */
.forecast-hub-key-col[data-hub-legend-margins],
.forecast-hub-key-col[data-hub-legend-flip] {
    display: none;
}

.forecast-hub-map-key--margins .forecast-hub-key-col[data-hub-legend-margins] {
    display: flex;
}

.forecast-hub-map-key--flips .forecast-hub-key-col[data-hub-legend-flip] {
    display: flex;
}

.forecast-hub-key-swatch-pair {
    display: grid;
    grid-template-rows: var(--forecast-hub-key-swatch-h) var(--forecast-hub-key-swatch-h);
    row-gap: var(--forecast-hub-key-swatch-gap);
    align-items: center;
    justify-items: center;
    height: var(--forecast-hub-key-swatch-block-h);
}

.forecast-hub-swatch {
    display: block;
    width: var(--forecast-hub-key-swatch-w);
    height: var(--forecast-hub-key-swatch-h);
    border-radius: 1px;
    flex-shrink: 0;
}

.forecast-hub-swatch--dem {
    transform: translateY(-2px);
}

.forecast-hub-swatch--win-r,
.forecast-hub-swatch--r-solid {
    background: #f93636;
}

.forecast-hub-swatch--win-d,
.forecast-hub-swatch--d-solid {
    background: #1181ff;
}

.forecast-hub-swatch--r-likely {
    background: #fc6969;
}

.forecast-hub-swatch--d-likely {
    background: #469fff;
}

.forecast-hub-swatch--r-lean {
    background: #ffa7a8;
}

.forecast-hub-swatch--d-lean {
    background: #89c3ff;
}

.forecast-hub-swatch--r-tilt {
    background: #ffd2d2;
}

.forecast-hub-swatch--d-tilt {
    background: #bdddff;
}

.forecast-hub-swatch--flip-r {
    background: repeating-linear-gradient(-45deg, #f93636, #f93636 3px, #fb6868 3px, #fb6868 6px);
    box-shadow: inset 0 0 0 1px #ffffff;
}

.forecast-hub-swatch--flip-d {
    background: repeating-linear-gradient(-45deg, #1181ff, #1181ff 3px, #4aa3fc 3px, #4aa3fc 6px);
    box-shadow: inset 0 0 0 1px #ffffff;
}

.forecast-hub-key-sub {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    text-align: center;
    width: var(--forecast-hub-key-swatch-w);
    line-height: 1.1;
}

.forecast-hub-key-sub[data-hub-label-solid] {
    display: none;
}

.forecast-hub-map-key--margins .forecast-hub-key-sub[data-hub-label-win] {
    display: none;
}

.forecast-hub-map-key--margins .forecast-hub-key-sub[data-hub-label-solid] {
    display: block;
}

/* Simple mode: "Win" only when Show Flips is on; bare swatches when flips off */
.forecast-hub-map-key:not(.forecast-hub-map-key--margins):not(.forecast-hub-map-key--flips) .forecast-hub-key-sub[data-hub-label-win] {
    display: none;
}

/* Simple mode (More Detail off): Win / Flip labels match margin-mode typography */
.forecast-hub-map-key:not(.forecast-hub-map-key--margins) .forecast-hub-key-sub {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    color: #94a3b8;
}

.forecast-hub-map-key--margins .forecast-hub-key-sub {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    color: #94a3b8;
}

.forecast-hub-key-range {
    display: none;
    font-size: 0.56rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.15;
    text-transform: none;
    color: #94a3b8;
    text-align: center;
    white-space: nowrap;
    width: 100%;
    min-width: 3.05rem;
}

.forecast-hub-map-key--margins .forecast-hub-key-range {
    display: block;
}

.forecast-hub-map-key--margins .forecast-hub-key-col {
    min-width: 3.05rem;
}

.forecast-hub-map-key--margins .forecast-hub-key-sub,
.forecast-hub-map-key--margins .forecast-hub-key-range {
    width: 100%;
}

.forecast-hub-map-controls {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    align-self: flex-start;
    height: var(--forecast-hub-key-swatch-block-h);
    gap: 0.65rem 1.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

.forecast-hub-map-controls .eh-flips-toggle-row {
    margin-top: 0;
}

.forecast-hub-map-stage {
    margin-top: 0.35rem;
    position: relative;
}

body.senate-hub-page .forecast-hub-map-stage,
body.gov-hub-page .forecast-hub-map-stage {
    top: -25px;
}

/* Hub pages only — larger than home (home page unchanged) */
body.senate-hub-page #usMap,
body.gov-hub-page #govMap {
    max-width: 1178px;
    height: 664px;
}

.forecast-hub-map-stage .forecast-map-legend-wrap {
    display: none !important;
}

/* Margin-mode seat bar segments (hub pages only) */
.forecast-hub-bar--margin-mode {
    background: transparent !important;
    box-sizing: border-box;
    box-shadow: none !important;
    border: none;
}

#barR.forecast-hub-bar--margin-mode,
#govBarR.forecast-hub-bar--margin-mode {
    border-radius: 0.375rem 0 0 0.375rem;
}

#barD.forecast-hub-bar--margin-mode,
#govBarD.forecast-hub-bar--margin-mode {
    border-radius: 0 0.375rem 0.375rem 0;
}

/* Full bar outline (top/bottom/ends) — always above segment fills */
.forecast-hub-bar--margin-mode::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
    pointer-events: none;
}

.forecast-hub-bar-segments {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: row;
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
    overflow: hidden;
}

.forecast-hub-bar-segments > span {
    display: block;
    height: 100%;
    flex: 0 0 auto;
    min-width: 0;
    box-sizing: border-box;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
    pointer-events: auto;
}

.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span {
    position: relative;
    box-shadow: none;
    border-right: 1px solid rgba(255, 255, 255, 0.38);
}

.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span:last-child {
    border-right: none;
}

/* 1.5× outline on linked bar/map hover (1px dividers → 1.5px ring on active segment) */
.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span.forecast-hub-bar-seg--highlight {
    z-index: 3;
    box-shadow: none !important;
    filter: brightness(0.88);
}

.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span.forecast-hub-bar-seg--highlight::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 1);
    pointer-events: none;
}

#barR.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span.forecast-hub-bar-seg--highlight[data-bar-edge="outer-start"]::after,
#govBarR.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span.forecast-hub-bar-seg--highlight[data-bar-edge="outer-start"]::after {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

#barD.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span.forecast-hub-bar-seg--highlight[data-bar-edge="outer-end"]::after,
#govBarD.forecast-hub-bar--margin-mode .forecast-hub-bar-segments > span.forecast-hub-bar-seg--highlight[data-bar-edge="outer-end"]::after {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* Seat totals sit above the bar but must not block per-state segment hovers */
.forecast-hub-seat-bar-wrap #numR,
.forecast-hub-seat-bar-wrap #numD,
.forecast-hub-seat-bar-wrap #govNumR,
.forecast-hub-seat-bar-wrap #govNumD {
    pointer-events: none;
    z-index: 6;
    transition: none;
}

#barR:not(.forecast-hub-bar--margin-mode),
#barD:not(.forecast-hub-bar--margin-mode),
#govBarR:not(.forecast-hub-bar--margin-mode),
#govBarD:not(.forecast-hub-bar--margin-mode) {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

#barRFlip,
#barDFlip,
#govBarRFlip,
#govBarDFlip {
    z-index: 1;
}

/* Hub map toggles — base switch in pollsmax-toggle.css */
.forecast-hub-map-controls .eh-flips-toggle__text {
    text-transform: none;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.forecast-hub-map-controls .eh-flips-toggle-row--off .eh-flips-toggle__text {
    color: #64748b;
}

@media (max-width: 639px) {
    .forecast-hub-map-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .forecast-hub-map-controls {
        justify-content: flex-start;
        align-self: stretch;
        height: auto;
    }
}

/* Race list aside collapse (Senate / Governor hubs, lg+) */
.forecast-hub-aside-head-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.forecast-hub-aside-head-row h2 {
    flex: 1;
    min-width: 0;
}

.forecast-hub-aside-collapse-cell {
    width: 5.5rem;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 6px;
    box-sizing: content-box;
}

/* Shrink-wrap the control — align the drawn chevron, not a square hit box. */
.forecast-hub-aside-collapse-toggle {
    display: block;
    width: fit-content;
    max-width: 100%;
    height: fit-content;
    padding: 0;
    margin: 0 0 0 auto;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    line-height: 0;
    transition: color 0.12s ease;
}

.forecast-hub-aside-collapse-toggle:hover {
    color: #f8fafc;
}

.forecast-hub-aside-collapse-toggle:focus-visible {
    outline: 2px solid #1181ff;
    outline-offset: 3px;
    border-radius: 2px;
}

.forecast-hub-aside-collapse-chevron {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    overflow: visible;
    transition: transform 0.18s ease;
}

/* Rotate about the visible stem so the fat edge lines up with margin chips (right). */
.forecast-hub-aside-collapse-toggle--collapse {
    position: relative;
    left: 3px;
}

.forecast-hub-aside-collapse-toggle--collapse .forecast-hub-aside-collapse-chevron {
    transform: rotate(-90deg);
    transform-origin: 72% 50%;
}

/* Tip aligns with the left edge of state flags in the race list. */
.forecast-hub-aside-collapse-toggle--expand .forecast-hub-aside-collapse-chevron {
    transform: rotate(90deg);
    transform-origin: 28% 50%;
}

/* Anchored to page grid (scrolls with content); Y/X captured when race list was visible. */
.forecast-hub-page-grid {
    position: relative;
}

.forecast-hub-aside-expand-row {
    display: none;
    position: absolute;
    top: var(--forecast-hub-aside-toggle-top, -9999px);
    left: var(--forecast-hub-aside-toggle-left, 0);
    z-index: 45;
    align-items: center;
    justify-content: flex-start;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: visible;
    pointer-events: none;
}

.forecast-hub-aside-expand-row .forecast-hub-aside-collapse-toggle {
    pointer-events: auto;
    transform: translateY(-50%);
    margin-left: 0;
}

@media (max-width: 1023px) {

    .forecast-hub-aside-collapse-toggle,
    .forecast-hub-aside-expand-row {
        display: none !important;
    }
}

@media (min-width: 1024px) {

    body.forecast-hub-races-aside-collapsed.senate-hub-page main > .grid,
    body.forecast-hub-races-aside-collapsed.gov-hub-page main > .grid {
        grid-template-columns: minmax(0, 1fr);
    }

    body.forecast-hub-races-aside-collapsed .senate-races-aside {
        display: none !important;
    }

    body.forecast-hub-races-aside-collapsed .senate-right-content {
        grid-column: 1 / -1 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        width: 100%;
        max-width: min(1178px, 100%);
    }

    body.forecast-hub-races-aside-collapsed .forecast-hub-aside-expand-row {
        display: flex;
        transform: translate(-2px, 5px);
    }

    /*
     * Race list hidden: key section rules span ~3000px centered on the forecast column.
     * — above Control Odds / distribution block (map bottom)
     * — above Search polls (bottom of odds section)
     * — below Search polls (same gap as distribution histogram → section rule)
     */
    body.forecast-hub-races-aside-collapsed .senate-map-divider::after,
    body.forecast-hub-races-aside-collapsed .forecast-hub-map-legend-shell--collapsed .forecast-hub-map-below-rule::after,
    body.forecast-hub-races-aside-collapsed .senate-right-content > section.senate-right-divider-inset:first-of-type::after,
    body.forecast-hub-races-aside-collapsed .senate-search-polls-rule-wrap::after,
    body.forecast-hub-races-aside-collapsed .gov-search-polls-rule-wrap::after {
        left: 50% !important;
        right: auto !important;
        width: 3000px !important;
        max-width: none !important;
        margin-left: -1500px !important;
    }

    /* Match distribution section pb-[calc(2rem+3px)] (chart bottom → rule). */
    body.forecast-hub-races-aside-collapsed .senate-search-polls-rule-wrap,
    body.forecast-hub-races-aside-collapsed .gov-search-polls-rule-wrap {
        padding-top: calc(2rem + 3px);
    }

    /* Search polls row: shrink-wrap sidebar (no empty flex stretch below poll rows). */
    body.forecast-hub-races-aside-collapsed .senate-search-left-col,
    body.forecast-hub-races-aside-collapsed .senate-search-left-col + div {
        height: auto !important;
        max-height: none !important;
        align-self: flex-start;
    }

    body.forecast-hub-races-aside-collapsed .senate-search-poll-sidebar {
        height: auto !important;
        max-height: none !important;
        flex: none !important;
    }

    body.forecast-hub-races-aside-collapsed .senate-search-poll-sidebar #senateTable,
    body.forecast-hub-races-aside-collapsed .senate-search-poll-sidebar .sleek-poll-list {
        flex: 0 0 auto !important;
        flex-grow: 0 !important;
        min-height: 0 !important;
    }
}
