/* =============================================================
   Azores Live Cams – design tokens
   ============================================================= */

:root {
    color-scheme: light;

    --bg: #f1f0ee;
    --surface: #ffffff;
    --surface-2: #f7f6f4;
    --surface-3: #eceae6;
    --text: #1a1a18;
    --text-soft: #4c4c48;
    --muted: #6f6f69;
    --border: #e3e1dd;
    --border-strong: #ccc9c3;

    --accent: #4f7a33;
    --accent-soft: #e8efe1;
    --accent-text: #ffffff;
    --live: #d1453b;
    --warn: #b4761d;

    --sun: #e0a02a;
    --moon: #8e8e96;
    --cloud: #96968f;
    --cloud-fill: rgba(150, 150, 143, .16);
    --rain: #6f8b9c;
    --snow: #a9b5bb;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .07), 0 1px 3px rgba(0, 0, 0, .05);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, .10), 0 2px 6px rgba(0, 0, 0, .06);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .18);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;

    --topbar-h: 60px;
    --panel-w: clamp(300px, 26vw, 380px);
    --detail-w: min(460px, 38vw);

    --ease: cubic-bezier(.32, .72, 0, 1);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0b0b0b;
    --surface: #161615;
    --surface-2: #1e1e1d;
    --surface-3: #292927;
    --text: #ececea;
    --text-soft: #b6b6b1;
    --muted: #8a8a84;
    --border: #2c2c2a;
    --border-strong: #3d3d3a;

    --accent: #94b673;
    --accent-soft: rgba(148, 182, 115, .14);
    --accent-text: #14200a;
    --live: #e5564d;
    --warn: #d9a441;

    --sun: #e8b451;
    --moon: #c7c7c0;
    --cloud: #9a9a93;
    --cloud-fill: rgba(154, 154, 147, .18);
    --rain: #8ea6b4;
    --snow: #c3ccd0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .65);
}

/* =============================================================
   Base
   ============================================================= */

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
a { color: var(--accent); }

button, input { font: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--accent-text); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    top: -60px; left: 12px;
    z-index: 5000;
    padding: 10px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* =============================================================
   App shell
   ============================================================= */

.app {
    display: grid;
    /* The extra row height clears the status bar when installed to an iOS home screen. */
    grid-template-rows: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)) 1fr;
    height: 100vh;
    height: 100dvh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 14px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border);
    z-index: 1250;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand__mark {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    flex: none;
    border-radius: 11px;
    background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 88%, #ffffff), color-mix(in srgb, var(--accent) 65%, #1c2416));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.brand__mark svg { width: 24px; height: 24px; }

.brand__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}
.brand__text strong { font-size: 15px; letter-spacing: -.02em; }
.brand__text small {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__actions { display: flex; gap: 8px; flex: none; }

/* =============================================================
   Buttons
   ============================================================= */

.icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    transition: background .18s, color .18s, border-color .18s, transform .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

.icon-btn svg {
    width: 20px; height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn.is-on {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}
.icon-btn.is-on .ui-icon { fill: currentColor; }

.icon-btn__dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--muted);
    transition: background .2s;
}
.icon-btn.is-on .icon-btn__dot {
    background: #fff;
    animation: pulse 2s infinite;
}

.icon-btn.is-busy svg { animation: spin 1s linear infinite; }

.theme-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-btn .icon-moon { display: block; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
    transition: background .18s, border-color .18s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.ui-icon { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ui-icon.is-filled { fill: currentColor; }
.flip { display: grid; transform: rotate(180deg); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }

/* =============================================================
   Workspace + map
   ============================================================= */

.workspace {
    position: relative;
    display: grid;
    grid-template-columns: var(--panel-w) 1fr;
    min-height: 0;
}

.map-wrap { position: relative; min-height: 0; }

#map {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--surface-3);
}

.map-hint {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    margin: 0;
    padding: 7px 14px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    color: var(--text-soft);
    font-size: 12.5px;
    white-space: nowrap;
    z-index: 600;
    pointer-events: none;
}

/* Leaflet chrome */
.leaflet-container {
    font: inherit;
    background: var(--surface-3);
}
.leaflet-control-zoom {
    border: 1px solid var(--border) !important;
    border-radius: 11px !important;
    overflow: hidden;
    box-shadow: var(--shadow-sm) !important;
}
.leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--text-soft) !important;
    border-bottom-color: var(--border) !important;
    width: 34px; height: 34px; line-height: 32px;
}
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.leaflet-control-attribution {
    background: color-mix(in srgb, var(--surface) 82%, transparent) !important;
    color: var(--muted) !important;
    font-size: 10.5px !important;
    border-radius: 8px 0 0 0;
    padding: 2px 8px !important;
}
.leaflet-control-attribution a { color: var(--text-soft) !important; }
[data-theme="dark"] .map-tiles { filter: brightness(.94) contrast(1.05); }

/* =============================================================
   Map markers
   ============================================================= */

.cam-marker { width: 0 !important; height: 0 !important; }
.cam-marker.is-hidden { display: none; }
.cam-marker:hover, .cam-marker.is-active { z-index: 800 !important; }

.cam-marker__inner {
    position: absolute;
    left: 0; top: 0;
    display: block;
    transform: translate(-50%, -100%);
    transition: transform .18s var(--ease);
    cursor: pointer;
}

/* -- dot mode (low zoom) -- */
.cam-marker__dot {
    display: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2.5px solid var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform .18s var(--ease);
}

.map-wrap.is-compact .cam-marker__inner { transform: translate(-50%, -50%); }
.map-wrap.is-compact .cam-marker__card { display: none; }
.map-wrap.is-compact .cam-marker__dot { display: block; }
.map-wrap.is-compact .cam-marker:hover .cam-marker__dot,
.map-wrap.is-compact .cam-marker.is-active .cam-marker__dot { transform: scale(1.45); }

/* -- thumbnail mode -- */
.cam-marker__card {
    display: block;
    width: 104px;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .22));
    transition: transform .18s var(--ease);
}
.cam-marker:hover .cam-marker__card { transform: scale(1.12) translateY(-2px); }

.cam-marker__frame {
    position: relative;
    display: block;
    height: 70px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface-3);
    border: 2px solid var(--surface);
    outline: 1px solid rgba(0, 0, 0, .06);
}
.cam-marker.is-active .cam-marker__frame { border-color: var(--accent); }

.cam-marker__frame::after {
    content: "";
    position: absolute;
    left: 50%; bottom: -8px;
    width: 10px; height: 10px;
    background: var(--surface);
    transform: translateX(-50%) rotate(45deg);
    border-radius: 2px;
}

/* Leaflet forces `width: auto` on any img in the marker pane, which would leave the
   photo at its 4:3 ratio inside the frame – match that specificity to win the cascade. */
.cam-marker .cam-marker__frame img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity .35s ease;
}
.cam-marker .cam-marker__frame img[data-loaded="true"] { opacity: 1; }

/* the card is the positioning context for the label and HD tag */
.cam-marker__card { position: relative; }

.cam-marker__name {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 12px 6px 4px;
    font-size: 10.5px;
    font-weight: 600;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
    background: linear-gradient(to top, rgba(0, 0, 0, .78), transparent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    border-radius: 0 0 8px 8px;
}

.cam-marker__hd {
    position: absolute;
    top: 4px; right: 4px;
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(0, 0, 0, .62);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
}

.cam-marker__skeleton,
.cam-card__skeleton,
.detail__skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%);
    background-size: 220% 100%;
    animation: shimmer 1.4s linear infinite;
}
.cam-marker__img[data-loaded="true"] ~ .cam-marker__skeleton,
.cam-card__thumb img[data-loaded="true"] ~ .cam-card__skeleton,
.detail__media.is-ready .detail__skeleton { display: none; }

@keyframes shimmer { to { background-position: -220% 0; } }

.cam-marker.is-offline .cam-marker__frame { filter: grayscale(1); opacity: .6; }
.cam-marker.is-offline .cam-marker__frame::before {
    content: "offline";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, .45);
    z-index: 2;
}

.user-marker { width: 0 !important; height: 0 !important; }
.user-dot {
    position: absolute;
    left: 0; top: 0;
    transform: translate(-50%, -50%);
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--sun);
    border: 3px solid var(--surface);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
    display: block;
}
.user-dot i {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--sun) 40%, transparent);
    animation: ping 2.4s ease-out infinite;
}
@keyframes ping { 70%, 100% { transform: scale(2.1); opacity: 0; } }

/* =============================================================
   Panel (sidebar / bottom sheet)
   ============================================================= */

.panel {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 1100;
}

.panel__grip { display: none; }

.panel__head {
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.search {
    position: relative;
    display: flex;
    align-items: center;
}
.search__icon {
    position: absolute;
    left: 11px;
    width: 18px; height: 18px;
    fill: none; stroke: var(--muted);
    stroke-width: 1.8; stroke-linecap: round;
    pointer-events: none;
}
.search input {
    width: 100%;
    padding: 10px 36px 10px 36px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    font-size: 14px;
    transition: border-color .18s, background .18s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.search input::-webkit-search-cancel-button { display: none; }

.search__clear {
    position: absolute;
    right: 6px;
    display: grid;
    place-items: center;
    width: 28px; height: 28px;
    border: 0; border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.search__clear:hover { background: var(--surface-3); color: var(--text); }
.search__clear svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.chips {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

/* Fades the right edge while there is more of the row to scroll to (touch layouts). */
.chips.has-overflow {
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: none;
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 550;
    white-space: nowrap;
    cursor: pointer;
    transition: background .16s, color .16s, border-color .16s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}
.chip__count {
    font-size: 11px;
    opacity: .7;
    font-variant-numeric: tabular-nums;
}

.panel__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel__foot {
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11.5px;
    text-align: center;
}
.panel__foot a { color: var(--text-soft); text-decoration: none; }
.panel__foot a:hover { color: var(--accent); text-decoration: underline; }

/* -- cam cards -- */

.cam-card {
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius);
    transition: background .16s;
}
.cam-card:hover { background: var(--surface-2); }
.cam-card.is-active { background: var(--accent-soft); }

.cam-card__open {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.cam-card__thumb {
    position: relative;
    flex: none;
    width: 76px; height: 52px;
    border-radius: 9px;
    overflow: hidden;
    background: var(--surface-3);
}
.cam-card__thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity .35s ease;
}
.cam-card__thumb img[data-loaded="true"] { opacity: 1; }
.cam-card.is-offline .cam-card__thumb { filter: grayscale(1); opacity: .55; }

.tag {
    position: absolute;
    top: 4px; left: 4px;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
    background: rgba(0, 0, 0, .62);
    color: #fff;
}
.detail__meta .tag,
.tag--inline {
    position: static;
    background: var(--accent-soft);
    color: var(--accent);
}

.cam-card__text { display: flex; flex-direction: column; min-width: 0; }
.cam-card__name {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cam-card__meta { font-size: 11.5px; color: var(--muted); }

.cam-card__fav {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px; height: 34px;
    margin-right: 4px;
    border: 0; border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color .16s, background .16s;
}
.cam-card__fav:hover { background: var(--surface-3); color: var(--text); }
.cam-card__fav.is-on { color: var(--sun); }
.cam-card__fav svg { width: 18px; height: 18px; }

.empty {
    margin: 24px 12px;
    padding: 18px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 13.5px;
    text-align: center;
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* =============================================================
   Detail drawer
   ============================================================= */

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 18, .5);
    backdrop-filter: blur(2px);
    z-index: 1150;
}

.detail {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: var(--detail-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform .3s var(--ease);
    z-index: 1200;
    overflow: hidden;
}
.detail.is-open { transform: none; }

.detail__inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.detail__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--border);
}
.detail__titles { min-width: 0; }
.detail__head h2 { font-size: 18px; line-height: 1.25; }
.detail__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}
.detail__tools { display: flex; gap: 6px; flex: none; }
.detail__tools .icon-btn { width: 36px; height: 36px; }
.detail__tools .icon-btn.is-on { color: var(--accent-text); background: var(--sun); border-color: var(--sun); }

.detail__stage { flex: none; min-height: 0; }

.detail__media {
    position: relative;
    margin: 14px 14px 0;
    aspect-ratio: 4 / 3;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    flex: none;
}
.detail__media img {
    width: 100%; height: 100%;
    /* Never crop the camera frame – the whole shot is the content here. */
    object-fit: contain;
    display: block;
    opacity: 0;
    transition: opacity .3s ease;
}
.detail__media.is-ready img { opacity: 1; }

/* Fills the letterbox with a blurred copy of the same frame instead of dead bars. */
.detail__backdrop {
    position: absolute;
    inset: 0;
    object-fit: cover !important;
    filter: blur(22px) saturate(1.15) brightness(.75);
    transform: scale(1.15);
}
.detail__media.is-ready .detail__backdrop { opacity: .7; }
#detail-img { position: relative; z-index: 1; }
.detail__media:fullscreen {
    aspect-ratio: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #000;
}
.detail__media:fullscreen img { object-fit: contain; }
.detail__media:fullscreen .detail__backdrop { display: none; }

/* Fallback zoom for browsers without element fullscreen (iOS Safari). */
.detail__media.is-zoomed {
    position: fixed;
    inset: 0;
    z-index: 2000;
    margin: 0;
    border: 0;
    border-radius: 0;
    aspect-ratio: auto !important;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    background: #000;
    cursor: zoom-out;
}
.detail__media.is-zoomed img { object-fit: contain; }
.detail__media.is-zoomed .detail__backdrop { display: none; }

.live-badge {
    position: absolute;
    top: 10px; left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 99px;
    background: rgba(0, 0, 0, .58);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .07em;
    z-index: 2; /* above the contained frame, which sits on its own layer */
}
.live-badge i {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--live);
    animation: pulse 1.6s infinite;
}

.detail__stamp {
    position: absolute;
    right: 10px; bottom: 10px;
    padding: 4px 9px;
    border-radius: 99px;
    background: rgba(0, 0, 0, .58);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    z-index: 2;
}

.detail__offline {
    display: none;
    position: absolute;
    inset: 0;
    margin: 0;
    place-items: center;
    align-content: center;
    gap: 10px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    color: var(--text-soft);
    font-size: 13.5px;
    text-align: center;
    padding: 20px;
    z-index: 3;
}
.detail__offline svg { width: 28px; height: 28px; }
.detail__media.is-offline .detail__offline { display: grid; }

.detail__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
}

.detail__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.detail__step { display: flex; gap: 6px; }
.detail__step .icon-btn { width: 36px; height: 36px; }

/* =============================================================
   Weather
   ============================================================= */

.now {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, var(--surface-2), var(--surface));
}

.now__main { display: flex; align-items: center; gap: 14px; }
.now__icon { width: 62px; height: 62px; flex: none; }
.now__temp { display: flex; flex-direction: column; min-width: 0; }
.now__value { font-size: 34px; font-weight: 650; letter-spacing: -.03em; line-height: 1; }
.now__unit { font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.now__desc { margin-top: 4px; font-size: 14px; font-weight: 550; }
.now__feels { font-size: 12.5px; color: var(--muted); }

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0 0;
}
.stat {
    padding: 9px 11px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}
.stat dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat dd {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 2px 0 0;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.stat__hint { display: block; font-size: 11.5px; color: var(--muted); }

.uv { font-weight: 600; }
.uv--low { color: var(--accent); }
.uv--medium { color: var(--warn); }
.uv--high { color: var(--live); }

.wind-arrow {
    width: 17px; height: 17px;
    flex: none;
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.wind-arrow--sm { width: 13px; height: 13px; stroke-width: 2.2; }

/* -- hourly strip -- */

.forecast {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    padding-bottom: 6px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
}

.day { flex: none; }
.day__label {
    position: sticky;
    left: 0;
    display: inline-block;
    margin-bottom: 8px;
    padding: 2px 9px;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.day__hours { display: flex; gap: 6px; }

.hour {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: none;
    width: 62px;
    padding: 9px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    scroll-snap-align: center;
    font-variant-numeric: tabular-nums;
}
.hour.is-now {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.hour__time { font-size: 11px; font-weight: 600; color: var(--text-soft); }
.hour.is-now .hour__time { color: var(--accent); }
.hour__icon { width: 30px; height: 30px; }
.hour__temp { font-size: 14px; font-weight: 650; }
.hour__meter {
    display: block;
    width: 38px; height: 4px;
    border-radius: 99px;
    background: var(--surface-3);
    overflow: hidden;
}
.hour__meter i {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: var(--rain);
}
.hour__wind {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text-soft);
}
.hour__rain { font-size: 11px; color: var(--muted); }
.hour__rain.is-wet { color: var(--rain); font-weight: 650; }

/* -- weather icons -- */

.wi { width: 100%; height: 100%; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wi-sun { stroke: var(--sun); }
.wi-moon, .wi .wi-moon { stroke: var(--moon); fill: color-mix(in srgb, var(--moon) 20%, transparent); }
.wi-cloud { stroke: var(--cloud); fill: var(--cloud-fill); }
.wi-rain { stroke: var(--rain); stroke-width: 2; }
.wi-snow { stroke: var(--snow); fill: var(--snow); }
.wi-fog { stroke: var(--cloud); stroke-width: 1.8; }
.wi-bolt { stroke: var(--sun); stroke-width: 1.8; }

/* -- skeleton -- */

.weather-skeleton { display: grid; gap: 8px; }
.sk {
    display: block;
    height: 46px;
    border-radius: var(--radius);
    background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
    background-size: 220% 100%;
    animation: shimmer 1.4s linear infinite;
}
.sk--lg { height: 104px; border-radius: var(--radius-lg); }
.weather-skeleton { grid-template-columns: 1fr 1fr; }
.weather-skeleton .sk--lg { grid-column: span 2; }

/* =============================================================
   Mobile
   ============================================================= */

@media (max-width: 900px) {
    :root { --topbar-h: 56px; --detail-w: 100%; }

    .brand__mark { width: 34px; height: 34px; }
    .icon-btn { width: 38px; height: 38px; }

    .workspace { grid-template-columns: 1fr; }

    .panel {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: 86dvh;
        border-right: 0;
        border-top: 1px solid var(--border);
        border-radius: 20px 20px 0 0;
        box-shadow: var(--shadow-lg);
        transform: translateY(var(--sheet-offset, calc(100% - 152px)));
        transition: transform .32s var(--ease);
        touch-action: none;
    }
    .panel.is-dragging { transition: none; }
    .panel[data-state="hidden"] { --sheet-offset: calc(100% - 34px - env(safe-area-inset-bottom, 0px)); }
    .panel[data-state="peek"] { --sheet-offset: calc(100% - 152px - env(safe-area-inset-bottom, 0px)); }
    .panel[data-state="half"] { --sheet-offset: 45%; }
    .panel[data-state="full"] { --sheet-offset: 0%; }

    /* Roomy hit area – a 4px handle is far too small to feel draggable. */
    .panel__grip {
        display: grid;
        place-items: center;
        width: 100%;
        height: 34px;
        padding: 0;
        border: 0;
        background: transparent;
        cursor: grab;
        touch-action: none;
    }
    .panel__grip:active { cursor: grabbing; }
    .panel__grip span {
        display: block;
        width: 44px; height: 5px;
        border-radius: 99px;
        background: var(--border-strong);
        transition: width .2s var(--ease), background .2s;
    }
    .panel__grip:active span { width: 56px; background: var(--accent); }

    /* Collapsed: only the grab bar floats over the map. */
    .panel[data-state="hidden"] { box-shadow: 0 -6px 20px rgba(0, 0, 0, .28); }
    .panel[data-state="hidden"] .panel__grip span { width: 56px; }

    .panel__list { touch-action: pan-y; }
    .panel__foot { display: none; }
    .panel[data-state="full"] .panel__foot { display: block; }

    .detail {
        top: auto;
        left: 0; right: 0; bottom: 0;
        width: auto;
        /* Full screen on phones: it is a modal with its own close button, and the
           reclaimed app-bar height goes straight into the live frame. */
        height: 100dvh;
        border-left: 0;
        border-radius: 0;
        transform: translateY(102%);
        z-index: 1300; /* above the app bar – it covers the whole screen */
    }
    .detail.is-open { transform: none; }

    /*
     * Everything should be readable without scrolling: the weather blocks keep their
     * natural height and the photo takes whatever room is left over.
     */
    /*
     * The stage claims whatever space the weather blocks do not need; the frame is
     * then fitted inside it at the camera's own ratio (set on load), so the card
     * never crops the shot and never shows letterbox bars in either direction.
     */
    /*
     * The stage hugs the frame rather than claiming the leftover height: panoramic
     * cameras are short and wide, and a stretched stage would float them in a gap.
     */
    .detail__stage {
        flex: 0 1 auto;
        min-height: 96px;
        display: grid;
        place-items: center;
        padding: 12px 12px 0;
    }
    .detail__media {
        width: auto;
        height: auto;
        max-width: 100%;
        /* Shrinks with the stage when the weather blocks need the room. */
        max-height: 100%;
        margin: 0;
    }
    /* Never squeezed: any shortfall is taken out of the frame above, not the readings. */
    .detail__body {
        flex: 0 0 auto;
        min-height: 0;
        padding: 12px;
    }

    .detail__head { padding: max(12px, env(safe-area-inset-top)) 12px 10px; }
    .detail__head h2 { font-size: 16.5px; }

    .detail__row { margin-bottom: 10px; }
    .detail__row .btn { padding: 7px 12px; }
    .detail__step .icon-btn,
    .detail__tools .icon-btn { width: 34px; height: 34px; }

    .now { padding: 12px; }
    .now__icon { width: 52px; height: 52px; }
    .now__value { font-size: 30px; }
    .now__desc { font-size: 13.5px; margin-top: 2px; }
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        margin-top: 10px;
    }
    .stat { padding: 7px 9px; }
    .stat dd { font-size: 14px; }

    .forecast { margin-top: 10px; gap: 10px; }
    .day__label { margin-bottom: 6px; }
    .hour { width: 56px; padding: 7px 3px; gap: 3px; }
    .hour__icon { width: 26px; height: 26px; }
    .hour__temp { font-size: 13px; }
    .map-hint { bottom: 164px; font-size: 12px; padding: 6px 12px; }
    .leaflet-control-zoom { margin-bottom: 162px !important; }
    .leaflet-control-attribution { margin-bottom: 152px !important; }

    /* With the sheet collapsed the map owns the screen – drop its controls back down. */
    .panel[data-state="hidden"] ~ .map-wrap .map-hint { bottom: 52px; }
    .panel[data-state="hidden"] ~ .map-wrap .leaflet-control-zoom { margin-bottom: 46px !important; }
    .panel[data-state="hidden"] ~ .map-wrap .leaflet-control-attribution { margin-bottom: 36px !important; }

    .cam-marker__card { width: 92px; }
    .cam-marker__frame { height: 62px; }
}

/* Short phones (SE-class): trim the secondary lines so the card still fits one screen. */
@media (max-width: 900px) and (max-height: 700px) {
    .detail__head { padding-bottom: 8px; }
    .detail__media { margin-top: 10px; }

    .now { padding: 10px; }
    .now__icon { width: 44px; height: 44px; }
    .now__value { font-size: 26px; }
    .stat__hint { display: none; }
    .stat { padding: 6px 9px; }
    .stats { margin-top: 8px; }

    .forecast { margin-top: 8px; }
    .day__label { margin-bottom: 4px; }
    .hour { padding: 5px 3px; }
}

@media (max-width: 400px) {
    .brand__text { max-width: 46vw; }
    .brand__text strong { font-size: 14px; }
}

@media (min-width: 901px) {
    .scrim { display: none; }

    /* A mouse cannot swipe a chip row – show every island at once, compactly. */
    .chips {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 5px;
    }
    .chips.has-overflow { mask-image: none; }
    .chip {
        padding: 4px 9px;
        font-size: 12px;
    }
    .chip__count { font-size: 10.5px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
