/* =========================================================
   Design system — imported from the Weather app design
   (mobile Weather.dc.html + desktop Weather Desktop.dc.html).
   Text always sits on a real photo, so all copy is light with
   a legibility shadow; light/dark is driven by the background
   image's day/night, exposed as [data-bg-dark] on <html>.
   ========================================================= */
@property --card {
    syntax: '<color>';
    inherits: true;
    initial-value: #294969;
}
:root {
    --sh: 0 1px 3px rgba(0, 0, 0, 0.4);
    --accent: #b0d0ff;
    --track: rgba(255, 255, 255, 0.15);
    --card: #294969;
    --card-sheen: rgba(255, 255, 255, 0.115);
    /* Shared by the main screen's UV bar and the detail popup's copy of it */
    --uv-gradient: linear-gradient(90deg,
        #4fc3a1 0%,      /* UV 0  */
        #8ed07c 18.2%,   /* UV 2  */
        #ffd97a 36.4%,   /* UV 4  — yellow */
        #ffc95e 45.5%,   /* UV 5  — yellow */
        #ff9f45 54.5%,   /* UV 6  — orange */
        #f97316 63.6%,   /* UV 7  — orange into red */
        #e8442e 72.7%,   /* UV 8  — red */
        #c62828 100%     /* UV 11 */
    );
    transition: --card 600ms ease;
    /* Glass — light-background variant (default) */
    --glass-bg: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.45);
    --glass-filter: blur(12px) saturate(0.9);
}
[data-bg-dark="true"] {
    /* Glass — dark-background variant */
    --glass-bg: rgba(0, 0, 0, 0.20);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-filter: blur(12px) saturate(1.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    color: #fff;
    overscroll-behavior-y: none;
}

/* ---------- Background: crossfading photo layers ---------- */
/* Mobile: full-bleed adaptive-brightness photo.
   Desktop: the SAME scene as a heavily blurred surround. */
#bg { position: fixed; inset: -60px; z-index: -2; overflow: hidden; pointer-events: none; background-color: oklch(20% 0.01 250); } /* overscan so bounce/toolbar-reveal strips stay covered; solid base fill under the photo layers */
#bg .bg-layer {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    opacity: 0; transition: opacity 700ms ease;
}
[data-bg-dark="false"] #bg .bg-layer { filter: brightness(1.08); }

/* Mobile scrim for hero/text legibility over the full-bleed photo */
#bg-scrim {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(180deg,
        rgba(6, 12, 24, 0.09) 0%,
        rgba(6, 12, 24, 0.04) 30%,
        rgba(6, 12, 24, 0) 75%,
        rgba(4, 10, 20, 0) 100%);
}

@media (min-width: 768px) {
    #bg { inset: -80px; }                         /* overscan so blurred edges never gap */
    #bg .bg-layer { filter: blur(20px); }          /* dark surround: natural brightness */
    [data-bg-dark="false"] #bg .bg-layer { filter: blur(56px) brightness(1.12) saturate(1.05); }
    #bg-scrim { background: rgba(0, 0, 0, 0.02); }  /* desktop: framed panel carries its own contrast */
}

/* ---------- Typography tokens ---------- */
.t-display     { font-weight: 300; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 2px 12px rgba(0,0,0,0.3); font-size: 112px; line-height: 1; letter-spacing: -2px; }
.t-title       { font-weight: 600; color: #fff; text-shadow: var(--sh); font-size: 26px; }
.t-value       { font-weight: 300; color: #fff; text-shadow: var(--sh); font-size: 24px; line-height: 1; }
.t-body        { font-weight: 400; color: rgba(242, 239, 233, 0.94); text-shadow: var(--sh); font-size: 16px; }
.t-body-emph   { font-weight: 600; color: #fff; text-shadow: var(--sh); font-size: 16px; }
.t-label       { font-weight: 600; color: #fff; text-shadow: var(--sh); font-size: 14px; }
.t-cap-heading { font-weight: 600; color: rgba(242, 239, 233, 0.94); text-shadow: var(--sh); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.t-cap         { font-weight: 400; color: rgba(242, 239, 233, 0.94); text-shadow: var(--sh); font-size: 13px; }
.t-cap-emph    { font-weight: 600; color: rgba(242, 239, 233, 0.94); text-shadow: var(--sh); font-size: 13px; }
.t-cap-accent  { font-weight: 600; color: var(--accent); text-shadow: var(--sh); font-size: 13px; }
.t-condition   { font-weight: 400; color: rgba(242, 239, 233, 0.97); text-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 10px rgba(0,0,0,0.3); font-size: 26px; }
@media (min-width: 768px) {
    .t-display     { font-size: 108px; letter-spacing: -3px; }
    .t-title       { font-size: 26px; }
    .t-value       { font-size: 28px; }
    .t-body        { font-size: 17px; }
    .t-body-emph   { font-size: 17px; }
    .t-label       { font-size: 15px; }
    .t-cap-heading { font-size: 13px; }
    .t-cap         { font-size: 13px; }
    .t-cap-emph    { font-size: 13px; }
    .t-cap-accent  { font-size: 13px; }
    .t-condition   { font-size: 26px; }
}

/* ---------- Glass surface ---------- */
.glass {
    border-radius: 20px;
    background:
        linear-gradient(
            145deg,
            var(--card-sheen) 0%,
            rgba(255, 255, 255, 0.045) 30%,
            rgba(255, 255, 255, 0) 58%
        ),
        var(--card);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        inset 0 -1px 0 rgba(0, 0, 0, 0.14),
        0 8px 24px rgba(0, 0, 0, 0.18);
}

.wx-icon { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35)); }

/* ---------- Layout shell ---------- */
main {
    max-width: 1900px;
    margin: 0 auto;
    padding: 8px 14px 28px;
}
@media (min-width: 768px) {
    main { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 10px 18px 18px; overflow: hidden; }
    #weather-card { flex: 1 1 auto; min-height: 0; }
}

/* ---------- Header: search + language toggle ---------- */
.app-header {
    position: relative; z-index: 30;
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 10px; max-width: 480px;
}
@media (min-width: 768px) { .app-header { flex-shrink: 0; margin-bottom: 8px; } }
.search-wrap { position: relative; flex: 1; }

.search-pill {
    display: flex; align-items: center; gap: 10px;
    border-radius: 999px; height: 42px; padding: 0 16px;
}
#weather-search-input {
    flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
    color: #fff; text-shadow: var(--sh); font-size: 14px; font-family: inherit;
}
#weather-search-input::placeholder { color: rgba(255, 255, 255, 0.7); }
#weather-search-btn {
    flex-shrink: 0; border: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; margin: 0; background: transparent;
    color: #fff; text-shadow: var(--sh);
    transition: opacity 0.2s;
}
#weather-search-btn:hover { opacity: 0.85; }
#weather-search-btn:active { transform: scale(0.94); }

.icon-btn {
    flex-shrink: 0; cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; padding: 0;
    color: #fff; text-shadow: var(--sh); font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
    transition: opacity 0.2s;
}
.icon-btn:hover { opacity: 0.75; }
.icon-btn:active { transform: scale(0.95); }

/* iOS Safari auto-zooms on focus when input font-size < 16px */
@media (max-width: 767px), (pointer: coarse) {
    #weather-search-input { font-size: 16px; line-height: 20px; }
}

/* Search autocomplete dropdown — opaque enough to read over any photo */
#search-dropdown {
    position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 40;
    border-radius: 16px; overflow-y: auto; max-height: 288px; padding: 6px;
    background: rgba(18, 22, 30, 0.72);
    backdrop-filter: blur(18px) saturate(1.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.search-option {
    display: block; width: 100%; text-align: left; border: 0; background: transparent;
    padding: 9px 12px; border-radius: 10px; cursor: pointer;
    font-size: 14px; color: #fff; font-family: inherit;
}
.search-option[aria-selected="true"], .search-option:hover { background: rgba(255, 255, 255, 0.12); }
.search-muted { color: rgba(255, 255, 255, 0.55); }

/* ---------- Weather layout ---------- */
.wx-layout { display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 768px) {
    .wx-layout { flex-direction: row; gap: 16px; height: 100%; align-items: stretch; min-height: 0; }
}

/* Left panel — plain on mobile, framed photo card on desktop */
.wx-panel { position: relative; min-width: 0; }
@media (min-width: 768px) {
    .wx-panel {
        flex: 1 1 70%; min-height: 0; overflow: hidden;
        border-radius: 28px; border: 1px solid var(--glass-border);
        box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
    }
}
.panel-photo { display: none; }
.panel-photo .pp-layer {
    position: absolute; inset: 0; background-size: cover; background-position: center;
    opacity: 0; transition: opacity 700ms ease; filter: brightness(1.05);
}
@media (min-width: 768px) { .panel-photo { display: block; position: absolute; inset: 0; z-index: 0; } }

/* Top-weighted scrim so hero + rail text stays legible on bright photos.
   Strong for light scenes, gentle for already-dark ones. Desktop only —
   mobile legibility is carried by the full-bleed #bg-scrim. */
.panel-scrim { display: none; }
@media (min-width: 768px) {
    .panel-scrim {
        display: block; position: absolute; inset: 0; z-index: 0; pointer-events: none;
        background: linear-gradient(180deg, rgba(8,14,24,0.13) 0%, rgba(8,14,24,0.07) 22%, rgba(8,14,24,0.03) 45%, rgba(8,14,24,0) 66%);
    }
}
[data-bg-dark="true"] .panel-scrim {
    background: linear-gradient(180deg, rgba(0,0,0,0.06) 0%, rgba(0,0,0,0.02) 40%, rgba(0,0,0,0) 66%);
}

.panel-inner { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 768px) { .panel-inner { gap: 18px; padding: 12px 20px 18px; height: 100%; overflow-y: auto; } }

/* Hero */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 10px; }
.hero-top { order: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hero-temp { order: 2; margin: 6px 0 0; text-transform: none; }
.hero-bottom { order: 3; display: flex; flex-direction: column; align-items: center; gap: 3px; margin-top: 2px; }
.hero-city { text-transform: capitalize; }
@media (min-width: 768px) {
    .hero { display: grid; grid-template-columns: auto 1fr; column-gap: 24px; align-items: center; text-align: left; padding-top: 0; flex: 0 0 auto; }
    .hero-temp { order: 0; grid-column: 1; grid-row: 1 / span 2; align-self: center; margin: 0; }
    .hero-top { order: 0; grid-column: 2; grid-row: 1; align-self: end; flex-direction: row; align-items: baseline; gap: 14px; }
    .hero-bottom { order: 0; grid-column: 2; grid-row: 2; align-self: start; align-items: flex-start; text-align: left; }
}

/* Hourly rail */
.rail-outer { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rail-viewport { position: relative; margin: 0 -14px; padding: 0 14px; }
@media (min-width: 768px) {
    .rail-outer { flex: 0 0 auto; min-height: 0; margin-top: auto; }
    .rail-viewport { margin: 0 -20px; padding: 0 20px; }
}
.rail-chevron {
    position: absolute; top: 50%; width: 14px; text-align: center; transform: translateY(-50%);
    pointer-events: none; font-size: 31px; line-height: 1; font-weight:400;
    -webkit-text-stroke: 0.6px currentColor; color: #fff; opacity: 0.4; z-index: 2;
}
.rail {
    display: flex; gap: 8px; width: 100%; overflow-x: auto;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding: 4px 0 6px;
}
@media (min-width: 768px) { .rail { gap: 10px; padding: 6px 0 16px; align-items: flex-start; } }
.rail::-webkit-scrollbar { display: none; }
.rail { -ms-overflow-style: none; scrollbar-width: none; }
.hour-card {
    flex: 0 0 auto; width: 84px; min-height: 160px; scroll-snap-align: start;
    display: grid; grid-template-rows: 21px 38px 30px 20px 20px 19px; row-gap: 3px;
    justify-items: center; align-items: center; padding: 9px 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.30);
}
@media (min-width: 768px) {
    .hour-card { width: 90px; height: clamp(195px, 29vh, 275px); min-height: 0; grid-template-rows: 16px 34px 22px 16px 16px 14px; row-gap: 4px; align-content: space-between; }
}
.hour-icon { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; }
@media (min-width: 768px) { .hour-icon { width: 36px; height: 36px; } }

/* Secondary cards */
.secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 768px) { .secondary { grid-template-columns: repeat(4, 1fr); gap: 14px; flex: 0 0 auto; } }
.info-card { padding: 14px; display: flex; flex-direction: column; gap: 5px; }
@media (min-width: 768px) { .info-card { padding: 14px; justify-content: space-between; } }
.info-value-row { display: flex; align-items: center; gap: 8px; min-height: 30px; }
@media (min-width: 768px) { .info-value-row { min-height: 38px; } }
.bar-track { width: 100%; height: 4px; border-radius: 3px; background: var(--track); overflow: hidden; }
@media (min-width: 768px) { .bar-track { height: 5px; } }
.uv-bar-wrap { display: flex; flex-direction: column; gap: 5px; }
#uv-bar {
    background-image: var(--uv-gradient);
    background-repeat: no-repeat;
    transition: width 400ms ease, background-size 400ms ease;
}

/* Right column: 14-day forecast */
.wx-right { min-width: 0; }
@media (min-width: 768px) { .wx-right { flex: 1 1 30%; min-height: 0; display: flex; } }
.forecast-card { padding: 13px 14px; display: flex; flex-direction: column; }
@media (min-width: 768px) { .forecast-card { padding: 20px 22px; flex: 1; min-height: 0; } }
.forecast-heading { margin-bottom: 8px; }
.forecast-scroll { display: flex; flex-direction: column; }
@media (min-width: 768px) { .forecast-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; } }
.forecast-scroll::-webkit-scrollbar { display: none; }
.forecast-scroll { -ms-overflow-style: none; scrollbar-width: none; }
.day-row {
    display: grid; grid-template-columns: 42px 26px 40px 1fr 34px; align-items: center; gap: 10px;
    padding: 7px 0; border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.day-row:first-child { border-top: 0; }
@media (min-width: 768px) { .day-row { grid-template-columns: 44px 28px 40px 1fr 40px; padding: 9px 0; flex: 1 0 auto; min-height: 44px; } }
.day-icon { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
/* Low temp + bar share the flexible column; high temp gets its own fixed column */
.day-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.day-hi { text-align: right; }
/* 14-day temperature range bar — fixed dimensions so every row is identical;
   only fill length/position and colors differ per temperature. */
.temp-track {
    position: relative; flex: 1 1 0; align-self: center;
    height: 5px; min-height: 5px; max-height: 5px; border-radius: 999px;
    background: var(--track); overflow: hidden;
}
.temp-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }

/* ---------- State screens ---------- */
.state-wrap { padding-top: 40px; }
@media (min-width: 768px) { .state-wrap { padding-top: 64px; } }
/* Card that holds the loading / error / empty blocks. showState() removes
   `hidden` and sets display:flex on whichever block is active, so the
   flex layout on .state-block only takes effect once that block is shown. */
.state-card {
    width: 100%; max-width: 360px; margin: 0 auto; padding: 44px 32px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
}
.state-block { flex-direction: column; align-items: center; gap: 12px; }
.state-block--loading { gap: 20px; }
.state-title { margin: 4px 0 0; }
.loading-message { opacity: 1; }
.empty-icon { color: rgba(255, 255, 255, 0.75); }
.state-retry-btn {
    border-radius: 999px; padding: 8px 20px; margin-top: 6px;
    color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; text-shadow: var(--sh);
}
.spinner {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }
.hidden { display: none !important; }

/* ---------- Hour / day detail popup trigger feedback ---------- */
.hour-card, .day-row { cursor: pointer; transition: box-shadow 120ms ease, opacity 120ms ease, background 120ms ease; }
.hour-card:active { opacity: 0.85; }
.day-row:active { opacity: 0.8; }
.hour-card:focus-visible, .day-row:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
/* :hover gated so a tap on touch devices doesn't leave a "stuck" highlight */
@media (hover: hover) {
    .hour-card:hover { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.30), inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
    .day-row:hover { background: rgba(255, 255, 255, 0.05); }
}

/* ---------- Hour / day detail popup ---------- */
body.detail-open { overflow: hidden; }

#detail-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0; pointer-events: none;
    transition: opacity 220ms ease;
}
#detail-overlay.is-open { opacity: 1; pointer-events: auto; }

#detail-dialog {
    position: fixed; z-index: 201;
    display: flex; flex-direction: column;
    color: #fff;
    opacity: 0; pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease;
    /* Mobile: bottom sheet */
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%;
    height: 92vh; height: 92dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    /* Bottom for the home-indicator area; left/right for a landscape phone's notch */
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
#detail-dialog.is-open { opacity: 1; pointer-events: auto; transform: translateY(0); }
#detail-dialog.is-dragging { transition: none; }
/* The container is only focused programmatically (tabindex=-1) to seed the focus trap */
#detail-dialog:focus { outline: none; }

@media (max-height: 480px) and (orientation: landscape) {
    #detail-dialog { height: 100vh; height: 100dvh; min-height: 260px; }
}

@media (min-width: 768px) {
    #detail-dialog {
        left: 50%; right: auto; bottom: auto; top: 50%;
        width: 95vw; max-width: 900px;
        height: 80vh; height: 80dvh;
        border-radius: 28px;
        transform: translate(-50%, -50%) scale(0.96);
        padding-bottom: 0; padding-left: 0; padding-right: 0;
    }
    #detail-dialog.is-open { transform: translate(-50%, -50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    #detail-overlay, #detail-dialog { transition: none; }
}

.detail-grabber {
    flex: 0 0 auto; width: 100%; padding: 10px 0 4px;
    display: flex; justify-content: center; touch-action: none;
}
.detail-grabber::before {
    content: ''; width: 36px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.35);
}
@media (min-width: 768px) { .detail-grabber { display: none; } }

.detail-header {
    flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
    padding: 8px 14px 12px; touch-action: none;
}
@media (min-width: 768px) { .detail-header { padding: 18px 22px 14px; } }

.detail-back {
    display: flex; align-items: center; gap: 4px; border: 0; background: transparent; cursor: pointer;
    color: #fff; text-shadow: var(--sh); font-size: 14px; font-family: inherit; padding: 6px 4px; margin-right: 2px;
    transition: opacity 0.15s;
}

.detail-nav-btn, .detail-close {
    flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    color: #fff; text-shadow: var(--sh);
    transition: background 0.15s, opacity 0.15s, transform 0.15s;
}
.detail-nav-btn:active, .detail-close:active { transform: scale(0.93); }
.detail-nav-btn:disabled { opacity: 0.3; cursor: default; }
.detail-close { margin-left: auto; }
.detail-back:focus-visible, .detail-nav-btn:focus-visible, .detail-close:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
@media (hover: hover) {
    .detail-back:hover { opacity: 0.8; }
    .detail-nav-btn:hover, .detail-close:hover { background: rgba(255, 255, 255, 0.1); }
    .detail-nav-btn:disabled:hover { background: transparent; }
}

.detail-heading { flex: 1 1 auto; min-width: 0; text-align: center; }
.detail-heading .t-cap { margin-top: 1px; }

.detail-body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: 4px 14px 20px;
}
@media (min-width: 768px) { .detail-body { padding: 4px 22px 24px; } }


/* ---------- Detail chart ---------- */
.chart-wrap { display: flex; flex-direction: column; gap: 10px; }

.chart-tabs {
    display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    -ms-overflow-style: none; scrollbar-width: none;
}
.chart-tabs::-webkit-scrollbar { display: none; }
.chart-tab {
    flex: 0 0 auto; cursor: pointer; border-radius: 999px; padding: 6px 13px;
    font-family: inherit; font-size: 13px; font-weight: 600;
    color: rgba(242, 239, 233, 0.90); text-shadow: var(--sh);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chart-tab[aria-selected="true"] {
    color: #fff; background: rgba(255, 255, 255, 0.20); border-color: rgba(255, 255, 255, 0.30);
}
.chart-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) {
    .chart-tab:hover { background: rgba(255, 255, 255, 0.13); }
}

.chart-panel { display: flex; flex-direction: column; gap: 8px; }
.chart-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 14px; }

.chart-plot { position: relative; width: 100%; height: 190px; }
@media (min-width: 768px) { .chart-plot { height: 240px; } }
/* pan-y (never pan-x): a vertical drag must still scroll the popup body */
.chart-svg { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.chart-empty {
    display: flex; align-items: center; justify-content: center;
    height: 100%; opacity: 0.7;
}

.chart-tooltip {
    position: absolute; top: 8px; left: 0; z-index: 3; pointer-events: none;
    padding: 7px 10px; border-radius: 12px;
    background: rgba(18, 22, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
    opacity: 0; transition: opacity 120ms ease;
}
.chart-tooltip.is-visible { opacity: 1; }
.chart-tt-time { font-size: 12px; font-weight: 600; color: #fff; margin-bottom: 3px; }
.chart-tt-row {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: rgba(242, 239, 233, 0.94); white-space: nowrap;
}
.chart-tt-swatch { flex: 0 0 auto; width: 10px; height: 3px; border-radius: 2px; }

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

@media (prefers-reduced-motion: reduce) {
    .chart-tooltip, .chart-tab { transition: none; }
}

/* ---------- Detail popup content ---------- */
/* Two columns only once there is genuinely room for a chart beside tiles */
.detail-cols { display: flex; flex-direction: column; gap: 16px; }
.detail-col-main, .detail-col-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 1100px) {
    .detail-cols { flex-direction: row; align-items: flex-start; gap: 22px; }
    .detail-col-main { flex: 1 1 56%; }
    .detail-col-side { flex: 1 1 44%; }
}

.detail-hero { display: flex; align-items: center; gap: 16px; padding: 4px 0 2px; }
.detail-hero-icon { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 72px; height: 72px; }
.detail-hero-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.detail-hero-temp {
    font-weight: 300; font-size: 46px; line-height: 1.05; letter-spacing: -1.5px;
    color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 2px 12px rgba(0,0,0,0.3);
}
@media (min-width: 768px) { .detail-hero-temp { font-size: 56px; } }

.confidence-badge {
    align-self: flex-start; padding: 5px 12px; border-radius: 999px;
    background: rgba(255, 197, 49, 0.16);
    border: 1px solid rgba(255, 197, 49, 0.42);
    color: #ffe0a3;
}
.confidence-badge--low {
    background: rgba(255, 138, 101, 0.16);
    border-color: rgba(255, 138, 101, 0.42);
    color: #ffb8a3;
}
.confidence-high { color: #a8e6b0; }
.confidence-medium { color: #ffe0a3; }
.confidence-low { color: #ffb8a3; }

/* Tiles sit on the popup's own glass, so they are a lighter inner surface */
.detail-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.detail-tile {
    display: flex; flex-direction: column; gap: 6px;
    padding: 12px 13px; border-radius: 16px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.tile-note { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.65; }
.tile-value-row { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.tile-unit { font-size: 13px; color: rgba(242, 239, 233, 0.94); text-shadow: var(--sh); }
.tile-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.layer-row { display: grid; grid-template-columns: 34px 1fr 38px; align-items: center; gap: 8px; }
.layer-name { min-width: 0; }
.layer-value { text-align: right; }
.bar-track.mini { height: 4px; }
.mini-fill { height: 100%; border-radius: 3px; }
.uv-fill {
    height: 100%; border-radius: 3px;
    background-image: var(--uv-gradient); background-repeat: no-repeat;
}

.detail-section {
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px 13px; border-radius: 16px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.section-muted { opacity: 0.7; }

.aq-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.aq-band { font-size: 15px; font-weight: 600; text-shadow: var(--sh); }
.aq-scale { position: relative; display: flex; gap: 2px; height: 8px; }
.aq-scale-band { flex: 1 1 0; border-radius: 2px; opacity: 0.85; }
.aq-marker {
    position: absolute; top: -3px; width: 3px; height: 14px; border-radius: 2px;
    background: #fff; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.45); transform: translateX(-50%);
}
.aq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.aq-chip {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 9px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.3);
}
.aq-chip-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }

.pollen-row { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 9px; }
.pollen-name { min-width: 0; }
/* Not nowrap: name + level + hour can exceed a 320px screen; wrap rather than overflow */
.pollen-value { text-align: right; }

.detail-attribution {
    margin-top: 4px; padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center; opacity: 0.6;
}
.detail-attribution a { color: inherit; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.35); }
.detail-attribution a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
@media (hover: hover) {
    .detail-attribution a:hover { text-decoration-color: currentColor; }
}

/* ---------- Day popup ---------- */
.hero-temp-min { font-size: 0.55em; opacity: 0.7; }
.day-compare { opacity: 0.85; }
.day-summary { line-height: 1.45; }
.tile-sub {
    display: flex; flex-direction: column; gap: 2px;
    margin-top: 2px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.10);
}
.tile-foot { margin-top: 2px; opacity: 0.85; }
.sun-arc { display: block; margin: 2px 0 4px; overflow: visible; }

.day-hour-block { display: flex; flex-direction: column; gap: 8px; }
.day-hour-strip {
    display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    -ms-overflow-style: none; scrollbar-width: none;
}
.day-hour-strip::-webkit-scrollbar { display: none; }
/* Fixed box so a re-render can never shift the row */
.day-hour-card {
    flex: 0 0 auto; width: 62px; cursor: pointer;
    display: grid; grid-template-rows: 16px 28px 20px 16px 16px; row-gap: 2px;
    justify-items: center; align-items: center;
    padding: 8px 4px; border-radius: 14px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.10);
    transition: background 0.15s, opacity 0.15s;
}
.day-hour-card:active { opacity: 0.8; }
.day-hour-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.day-hour-card.is-now {
    background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.34);
}
.day-hour-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
@media (hover: hover) {
    .day-hour-card:hover { background: rgba(255, 255, 255, 0.14); }
}

@media (prefers-reduced-motion: reduce) { .day-hour-card { transition: none; } }

/* ---------- Forecast confidence tile skeleton ---------- */
.confidence-skeleton-line {
    height: 12px; margin: 3px 0; border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    animation: skeletonPulse 1.3s ease-in-out infinite;
}
@keyframes skeletonPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .confidence-skeleton-line { animation: none; opacity: 0.7; }
}
