/* Wetter Tessin – base styles (no build step) */
@font-face {
    font-family: "Fredoka";
    src: url("../fonts/fredoka.woff") format("woff");
    font-weight: 300 700;
    font-stretch: 75% 125%;
    font-display: swap;
}
@font-face {
    font-family: "Nunito";
    src: url("../fonts/nunito.woff") format("woff");
    font-weight: 200 1000;
    font-display: swap;
}

/* Palette: Lago di Lugano – lake teal, pine green, Ticino stone, summer sun */
:root {
    --bg: #eaf4f5;
    --surface: #ffffff;
    --surface-2: #e1eff1;
    --text: #173340;
    --muted: #587482;
    --border: #cfe2e6;
    --accent: #137a89;
    --accent-contrast: #ffffff;
    --sun: #e9a52a;
    --sun-text: #a3620a;
    --pine: #2f6b4f;
    --ok: #1e8a4c;
    --warn: #b7791f;
    --bad: #c53030;
    --radius: 16px;
    --shadow: 0 1px 0 rgba(23, 51, 64, .06);
    --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --display: "Fredoka", "Nunito", system-ui, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1c24;
        --surface: #142a34;
        --surface-2: #1a3440;
        --text: #e4f0f2;
        --muted: #93aeb8;
        --border: #24424f;
        --accent: #4fb8c6;
        --accent-contrast: #0d1c24;
        --sun: #f3c25a;
        --sun-text: #f3c25a;
        --pine: #5fae86;
        --ok: #45c37b;
        --warn: #e0a43a;
        --bad: #f06a6a;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; } /* keeps the width when a page needs no scrollbar (desktop) */
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.55 var(--font);
}
a { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .75rem; font-family: var(--display); font-weight: 600; letter-spacing: .005em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Header: animated sky with lake, hills and tents */
.site-header { position: relative; background: var(--bg); }
.sky { --sky-h: clamp(170px, 24vw, 260px); position: relative; height: var(--sky-h); overflow: hidden; background: #8fcfdd; --l-far: #86b3a6; --l-hill: #3f7d5e; --l-meadow: #6aa565; --l-lake: #1f8b9b; --l-wave: #e9f6f7; --l-sand: #dcd3b0; --l-tree: #3a7a4c; --l-tree-dark: #2c633e; --l-palm: #2f7a45; --l-trunk: #7a5a3a; --l-white: #f5f7f8; --l-white-edge: #c6cfd4; --l-snow: #fafcff; }
.sky canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Same vertical scale for both layers (height / 230); the campsite keeps its proportions. */
.sky .landscape { position: absolute; right: 0; bottom: 0; height: 100%; display: block; }
.sky .landscape-bg { width: max(100%, calc(var(--sky-h) * 1200 / 230)); }
.sky .landscape-fg { width: calc(var(--sky-h) * 1200 / 230); }
.sky .landscape { pointer-events: none; }
.scene-title { position: absolute; top: clamp(12px, 3vw, 28px); left: 0; right: 0; pointer-events: none; }
.brand { pointer-events: auto; text-decoration: none; color: #173340; display: inline-flex; flex-direction: column; }
.site-header.is-night .brand { color: #eef6f7; }
.brand { text-shadow: 0 1px 12px rgba(255, 255, 255, .35); }
.site-header.is-night .brand { text-shadow: 0 1px 12px rgba(0, 0, 0, .45); }
.brand strong { font-family: var(--display); font-weight: 600; font-size: clamp(1.6rem, 4vw, 2.6rem); line-height: 1; }
.brand span { font-size: clamp(.9rem, 1.6vw, 1.05rem); opacity: .85; margin-top: .3rem; }
.nav-bar { background: var(--bg); }
/* From 641 px the header stays visible: it is sticky with a negative top, so the
   sky scrolls up until a 90 px strip (lake, campsite) plus the menu remain. */
@media (min-width: 641px) {
    .topbar { position: sticky; top: calc(90px - clamp(170px, 24vw, 260px)); z-index: 700; }
    .topbar .nav-bar { box-shadow: 0 1px 0 var(--border); }
    html { scroll-padding-top: calc(90px + 4rem); }
}
/* Small title in the strip: fades in while the large title scrolls away (scroll-driven
   animation; browsers without support simply do not show it). */
.scene-mini { display: none; }
@keyframes scene-mini-in { to { opacity: 1; } }
@supports (animation-timeline: scroll()) {
    @media (min-width: 641px) {
        .scene-mini { display: block; position: absolute; left: 0; right: 0; top: calc(clamp(170px, 24vw, 260px) - 90px + 10px); pointer-events: none; opacity: 0;
            animation: scene-mini-in linear both; animation-timeline: scroll(root); animation-range: calc(clamp(170px, 24vw, 260px) - 150px) calc(clamp(170px, 24vw, 260px) - 90px); }
        .scene-mini span { display: inline-block; font-family: var(--display); font-weight: 600; font-size: 1.05rem; line-height: 1; padding: .3rem .7rem; border-radius: 999px; color: #173340; background: rgba(255, 255, 255, .78); box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
        .site-header.is-night .scene-mini span { color: #eef6f7; background: rgba(10, 22, 30, .7); }
    }
}
.nav { display: flex; flex-wrap: wrap; gap: .35rem; padding: .75rem 0 .6rem; }
.nav a { font-family: var(--display); font-weight: 500; text-decoration: none; color: var(--text); padding: .4rem .95rem; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--border); }
.nav a:hover { border-color: var(--accent); }
.nav a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.nav a:focus-visible, .btn:focus-visible, .segmented a:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

main { padding: .9rem 0 3rem; }
.site-footer { color: var(--muted); font-size: .85rem; padding: 1.5rem 0 2rem; border-top: 1px solid var(--border); }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

/* Cards / grid */
.card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid .card { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.spacer { flex: 1; }

/* Weather values */
.module-card h2 { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.module-card h2 small { font-family: var(--font); font-weight: 400; color: var(--muted); font-size: .8rem; }
.module-card h2 .icon { width: 1.4em; height: 1.4em; vertical-align: -.3em; margin-right: .35rem; color: var(--accent); }
.module-card[data-chart-metric] { cursor: pointer; transition: border-color .15s; }
.module-card[data-chart-metric]:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.module-card.selected { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.hilo .hi { color: var(--sun-text); font-weight: 700; }
.hilo .lo { color: var(--accent); font-weight: 700; }
.big-value { font-family: var(--display); font-size: 3rem; font-weight: 500; line-height: 1.1; margin: .25rem 0 .5rem; font-variant-numeric: tabular-nums; }
.big-value .unit { font-size: 1.3rem; color: var(--muted); font-weight: 400; margin-left: .15rem; }
.values { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; margin: 0; }
.values dt { color: var(--muted); }
.values dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* The hidden attribute always wins over display rules of classes (e.g. .badge). */
[hidden] { display: none !important; }

/* Status badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); }
.badge.stale { color: var(--warn); }
.badge.missing, .badge.bad { color: var(--bad); }
.badge.off, .badge.paused { color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], select, textarea {
    width: 100%; padding: .55rem .65rem; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
textarea { min-height: 8rem; font-family: var(--mono); font-size: .9rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: 1.1rem; height: 1.1rem; }
.fields-2 { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.inline-form { display: inline; }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1.05rem; font: inherit; font-family: var(--display); font-weight: 500; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

.alert { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.alert.ok { color: var(--ok); border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.alert.bad { color: var(--bad); border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.alert ul { margin: 0; padding-left: 1.2rem; }

/* Segmented control (history ranges): single pills that wrap cleanly */
.segmented { display: flex; flex-wrap: wrap; gap: .35rem; }
.segmented a { font-family: var(--display); padding: .35rem .8rem; text-decoration: none; color: var(--muted); border: 1.5px solid var(--border); border-radius: 999px; background: var(--surface); white-space: nowrap; }
.segmented a:hover { border-color: var(--accent); color: var(--text); }
.segmented a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.chart { width: 100%; height: 420px; }
@media (max-width: 600px) { .chart { height: 320px; } .big-value { font-size: 2.1rem; } }

/* Webcam / timelapse */
.webcam img { border-radius: 4px; width: 100%; display: block; }
.webcam h2, .timelapse h2 { margin-top: 0; }
.webcam-grid { display: grid; gap: 1rem; }
.webcam-grid > .card { margin: 0; }
@media (min-width: 900px) { .webcam-grid.multi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.webcam-stage { position: relative; }
.webcam-zoom { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 4px; }
.webcam-zoom:focus-visible { outline: 3px solid var(--accent, #137a89); outline-offset: 2px; }
.webcam-lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(8, 12, 16, .9); cursor: zoom-out; }
.timelapse.tl-large:fullscreen { width: 100vw; height: 100vh; }
.webcam-lightbox::backdrop { background: rgba(8, 12, 16, .92); }
.webcam-lightbox figure { margin: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 1rem; box-sizing: border-box; }
.webcam-lightbox img { max-width: 100%; max-height: calc(100% - 2.5rem); object-fit: contain; border-radius: 2px; }
.webcam-lightbox figcaption { color: #fff; font-size: .95rem; text-align: center; font-variant-numeric: tabular-nums; }
.webcam-lightbox .badge.bad { color: #ffb4a8; }
.lightbox-close { position: fixed; z-index: 1001; top: .6rem; right: .8rem; width: 2.6rem; height: 2.6rem; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.8rem; line-height: 1; cursor: pointer; }
.webcam-stage.is-offline img { filter: grayscale(.7) brightness(.75); }
.webcam-offline { pointer-events: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100% - 1.5rem); display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .7rem 1.2rem; border-radius: 12px; background: rgba(20, 24, 28, .78); color: #fff; text-align: center; box-shadow: 0 4px 18px rgba(0, 0, 0, .35); }
.webcam-offline strong { font-size: 1.25rem; letter-spacing: .02em; color: #ffb4a8; }
.webcam-offline span { font-size: .9rem; font-variant-numeric: tabular-nums; }
.webcam-offline strong, .webcam-offline span { white-space: nowrap; }
.webcam-offline[hidden] { display: none; }
@media (max-width: 640px) {
    .webcam-offline { padding: .45rem .8rem; border-radius: 10px; }
    .webcam-offline strong { font-size: 1.05rem; }
    .webcam-offline span { font-size: .8rem; }
}
.timelapse-stage { position: relative; background: #000; border-radius: 4px; overflow: hidden; aspect-ratio: 16 / 9; }
.timelapse-stage img { width: 100%; height: 100%; object-fit: contain; }
.timelapse-stage .stamp { position: absolute; left: .75rem; bottom: .6rem; color: #fff; font-weight: 600; text-shadow: 0 1px 3px #000; font-variant-numeric: tabular-nums; }
.timelapse-stage { cursor: zoom-in; }
.timelapse .tl-close { display: none; }
.timelapse.tl-large { position: fixed; inset: 0; z-index: 1000; margin: 0; border: 0; border-radius: 0; display: flex; flex-direction: column; gap: .5rem; padding: .75rem 1rem 1rem; background: rgb(8, 12, 16); color: #fff; }
.timelapse.tl-large h2 { color: #fff; padding-right: 3rem; }
.timelapse.tl-large h2 .muted, .timelapse.tl-large .tl-status { color: rgba(255, 255, 255, .7); }
.timelapse.tl-large .timelapse-stage { flex: 1; min-height: 0; aspect-ratio: auto; cursor: zoom-out; border-radius: 2px; }
.timelapse.tl-large .tl-close { display: block; }
body.tl-large-open { overflow: hidden; }
/* Phone in landscape: the picture uses the full height, controls lie on top of it. */
@media (orientation: landscape) and (max-height: 520px) {
    .timelapse.tl-large { padding: 0; gap: 0; }
    .timelapse.tl-large h2 { display: none; }
    .timelapse.tl-large .timelapse-stage { border-radius: 0; }
    .timelapse.tl-large .timelapse-stage .stamp { bottom: 3.6rem; }
    .timelapse.tl-large .timelapse-controls { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: .4rem .8rem calc(.4rem + env(safe-area-inset-bottom)); flex-wrap: nowrap; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
    .timelapse.tl-large .timelapse-controls .btn { padding: .3rem .8rem; }
    .timelapse.tl-large .tl-status { white-space: nowrap; }
}
.timelapse-controls { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin-top: .75rem; }
.timelapse-controls input[type=range] { flex: 1; min-width: 160px; }

.embed-frame { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.admin-nav { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; }
.admin-nav .brand { padding: 0 .5rem 1rem; }
.admin-nav a.item { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500; }
.admin-nav a.item:hover { background: var(--surface-2); color: var(--text); }
.admin-nav a.item.active { background: var(--accent); color: var(--accent-contrast); }
.admin-nav .section { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; margin: 1rem .6rem .35rem; }
.admin-main { padding: 1.5rem; max-width: 1000px; width: 100%; }
@media (max-width: 800px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-nav { border-right: 0; border-bottom: 1px solid var(--border); }
    .admin-main { padding: 1rem 16px; }
}

.auth-box { max-width: 460px; margin: 3rem auto; padding: 0 16px; }
.wind-arrow { display: inline-block; font-weight: 700; margin-left: .2rem; }

/* Nerd mode */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.stat { background: var(--surface-2); border-radius: 12px; padding: .75rem .9rem; display: flex; flex-direction: column; gap: .15rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-family: var(--display); font-size: 1.5rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font-family: var(--display); font-weight: 500; padding: .2rem .75rem; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); }

/* Nerd mode switch (persisted per visitor) */
.nerd-only { display: none !important; }
html.nerd .nerd-only { display: revert !important; }
html.nerd .nav a.nerd-only { display: inline-block !important; }
.nerd-switch { margin-left: auto; display: inline-flex; align-items: center; gap: .5rem; font: inherit; font-family: var(--display); font-weight: 500; color: var(--muted); background: none; border: 0; padding: .4rem .2rem; cursor: pointer; }
.nerd-switch .track { width: 2.4rem; height: 1.35rem; border-radius: 999px; background: var(--border); position: relative; transition: background .2s; }
.nerd-switch .knob { position: absolute; top: .175rem; left: .2rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.nerd-switch[aria-checked="true"] { color: var(--text); }
.nerd-switch[aria-checked="true"] .track { background: var(--accent); }
.nerd-switch[aria-checked="true"] .knob { transform: translateX(1rem); }
.nerd-switch:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { .nerd-switch .track, .nerd-switch .knob { transition: none; } }
.nerd-note { display: block; font-size: .8rem; color: var(--muted); font-weight: 400; }
.big-value + .nerd-note { margin: -.35rem 0 .5rem; }

/* Sky simulation (nerd mode): never part of the page flow, so nothing shifts. */
.sky-controls { position: fixed; z-index: 900; display: none; flex-direction: column; gap: .35rem; padding: .8rem 1rem 1rem; background: var(--surface); border: 1.5px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.sky-controls label { margin: .25rem 0 0; font-family: var(--display); font-weight: 500; display: flex; justify-content: space-between; gap: .5rem; }
.sky-controls input[type=range] { width: 100%; accent-color: var(--accent); }
.sky-controls output { font-variant-numeric: tabular-nums; font-family: var(--font); font-weight: 600; }
.sky-controls select { width: 100%; }
.sky-controls #sky-live { margin-top: .5rem; align-self: flex-start; }
.sky-head { display: flex; justify-content: space-between; align-items: center; }
.sky-close { border: 0; background: none; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
.sky-fab { position: fixed; z-index: 901; right: 16px; bottom: 16px; width: 3.2rem; height: 3.2rem; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-contrast); box-shadow: 0 6px 18px rgba(0, 0, 0, .3); cursor: pointer; padding: .7rem; }
.sky-fab svg { width: 100%; height: 100%; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html.nerd .sky-fab.nerd-only { display: block !important; }
html.nerd .sky-fab.nerd-only.is-open { display: none !important; }
/* Bottom sheet */
html.nerd .sky-controls.nerd-only { display: none !important; }
html.nerd .sky-controls.nerd-only.open { display: flex !important; left: 50%; transform: translateX(-50%); bottom: 0; width: min(520px, 100%); border-radius: 16px 16px 0 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
/* Wide screens: side panel right of the page, always open in nerd mode */
@media (min-width: 1600px) {
    html.nerd .sky-fab.nerd-only { display: none !important; }
    html.nerd .sky-controls.nerd-only, html.nerd .sky-controls.nerd-only.open { display: flex !important; left: auto; transform: none; right: 16px; bottom: auto; top: 50%; translate: 0 -50%; width: 230px; border-radius: 14px; padding-bottom: 1rem; }
    .sky-close { display: none; }
}
html.nerd .nerd-note.nerd-only { display: block !important; }
.admin-nav .brand strong { font-size: 1.35rem; }
.admin-nav .brand { text-shadow: none; color: var(--text); }
.admin-nav .brand span { color: var(--muted); opacity: 1; }
.admin-tabs { margin-bottom: 1rem; flex-wrap: wrap; }

/* Info: status lists */
.status-grid { margin-bottom: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.status-card h3 { margin-bottom: .5rem; }
.status-list { list-style: none; margin: 0; padding: 0; }
.status-row { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "dot name state" "dot age age"; column-gap: .65rem; row-gap: 0; align-items: center; padding: .6rem 0; border-top: 1px solid var(--border); }
.status-row:first-child { border-top: 0; }
.status-dot { grid-area: dot; width: .8rem; height: .8rem; border-radius: 50%; background: var(--muted); align-self: start; margin-top: .45rem; }
.status-row.ok .status-dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.status-row.stale .status-dot { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 20%, transparent); }
.status-row.missing .status-dot { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 20%, transparent); }
.status-name { grid-area: name; font-weight: 600; }
.status-state { grid-area: state; font-family: var(--display); font-weight: 500; white-space: nowrap; }
.status-row.ok .status-state { color: var(--ok); }
.status-row.stale .status-state { color: var(--warn); }
.status-row.missing .status-state { color: var(--bad); }
.status-row.paused .status-dot { background: var(--muted); box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 20%, transparent); }
.status-row.paused .status-state { color: var(--muted); }
.status-age { grid-area: age; color: var(--muted); font-size: .85rem; }
html.nerd .status-row[data-href] { cursor: pointer; border-radius: 8px; }
html.nerd .status-row[data-href]:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
/* Outage history (nerd mode) */
.outage-tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1rem; }
.outage-tiles .card { margin: 0; }
.outage-percent { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.outage-percent small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.outage-days { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; height: 34px; }
.outage-day { border-radius: 3px; background: var(--border); }
.outage-day.ok { background: var(--ok); }
.outage-day.warn { background: var(--warn); }
.outage-day.bad { background: var(--bad); }
.outage-days-axis { display: flex; justify-content: space-between; margin-top: .3rem; }
tr.ongoing td { color: var(--bad); font-weight: 600; }
@media (max-width: 640px) {
    .outage-table { font-size: .82rem; }
    .outage-table th, .outage-table td { padding: .4rem .35rem; }
    .outage-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .outage-percent { font-size: 1.45rem; }
}
.status-grid { align-items: start; }

/* Login / TOTP */
.sso-btn { width: 100%; justify-content: center; margin-bottom: .5rem; }
.otp-input { font-size: 1.4rem; letter-spacing: .25em; font-variant-numeric: tabular-nums; max-width: 14rem; }
.totp-setup { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.totp-setup .qr { background: #fff; padding: .5rem; border-radius: 12px; line-height: 0; min-width: 120px; }
.totp-setup .qr img { image-rendering: pixelated; max-width: 100%; height: auto; }
.totp-secret { font-size: 1.05rem; word-break: break-all; }
.recovery-codes { background: rgba(19, 122, 137, .08); padding: .8rem 1rem; border-radius: 10px; font-size: 1.05rem; line-height: 1.6; }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: .8rem; }

/* Language switch (public nav) */
.nav .lang-switch { display: inline-flex; align-items: center; margin-left: auto; border: 1.5px solid var(--border); border-radius: 999px; background: var(--surface); overflow: hidden; }
.nav .nerd-switch + .lang-switch { margin-left: .35rem; }
.nav .lang-switch a { border: 0; border-radius: 0; background: transparent; padding: .4rem .6rem; font-size: .85rem; letter-spacing: .02em; color: var(--muted); }
.nav .lang-switch a + a { border-left: 1px solid var(--border); }
.nav .lang-switch a:hover { color: var(--text); }
.nav .lang-switch a.active { background: var(--accent); color: var(--accent-contrast); }

/* Netatmo module names per language (backend) */
.module-name { min-width: 15rem; }
.module-name select { width: 100%; }
.custom-labels { display: grid; gap: .3rem; margin-top: .4rem; }
.custom-labels[hidden] { display: none; }
.custom-label { display: flex; align-items: center; gap: .4rem; margin: 0; font-weight: 400; }
.custom-label span { font-size: .75rem; color: var(--muted); width: 1.6rem; }
.admin-lang { padding: .25rem .6rem; }
.admin-lang .lang-switch, .auth-box .lang-switch { display: inline-flex; border: 1.5px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.admin-lang .lang-switch a, .auth-box .lang-switch a { padding: .3rem .55rem; font-size: .8rem; text-decoration: none; color: var(--muted); font-family: var(--display); font-weight: 500; }
.admin-lang .lang-switch a + a, .auth-box .lang-switch a + a { border-left: 1px solid var(--border); }
.admin-lang .lang-switch a.active, .auth-box .lang-switch a.active { background: var(--accent); color: var(--accent-contrast); }
pre.output { background: rgba(19, 122, 137, .08); padding: .7rem .9rem; border-radius: 10px; white-space: pre-wrap; font-size: .85rem; margin-top: 1rem; max-height: 22rem; overflow: auto; }
.admin-nav .item .badge { margin-left: .3rem; }

/* Netatmo device status (nerd mode) */
.signal { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.signal svg rect { fill: var(--border); }
.signal svg rect.on { fill: var(--accent); }
.signal.lvl-1 svg rect.on { fill: #d64545; }
.signal.lvl-2 svg rect.on { fill: #e0a526; }
.battery { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.battery-body { position: relative; width: 1.6rem; height: .75rem; border: 1.5px solid currentColor; border-radius: 3px; opacity: .85; }
.battery-body::after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: calc(100% - 4px); background: currentColor; border-radius: 0 1px 1px 0; }
.battery-fill { position: absolute; left: 1px; top: 1px; bottom: 1px; max-width: calc(100% - 2px); background: #3aa76d; border-radius: 1px; }
.battery.mid .battery-fill { background: #e0a526; }
.battery.low .battery-fill { background: #d64545; }
.nerd-device { display: flex; gap: .9rem; align-items: center; margin: -.2rem 0 .4rem; }
html.nerd .nerd-device.nerd-only { display: flex !important; }
.devices .warn { color: #d64545; font-weight: 600; }
.module-card [data-chart-type] { cursor: pointer; }
.module-card dt[data-chart-type]:hover, .module-card dt[data-chart-type]:hover + dd,
.module-card dd[data-chart-type]:hover, .module-card dt[data-chart-type]:has(+ dd:hover) { color: var(--accent); }
.module-card .big-value[data-chart-type]:hover { color: var(--accent); }
.embed-frame[scrolling="no"] { overflow: hidden; }
.embed-frame.auto-sized { transition: height .2s ease; }
/* Embeds on phones (mode per embed in the backend) */
.embed-link { display: none; margin: 0; }
@media (max-width: 640px) {
    .embed-card[data-mobile-mode="hide"] { display: none; }
    .embed-card[data-mobile-mode="link"] .embed-frame { display: none; }
    .embed-card[data-mobile-mode="link"] .embed-link { display: block; }
}
td.nowrap { white-space: nowrap; }
.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li { padding: .6rem 0; border-top: 1px solid var(--border); }
.feature-list li:first-child { border-top: 0; }
.feature-list .hint { margin: .15rem 0 0 1.7rem; }

/* Notch / home indicator (viewport-fit=cover) */
.container { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* Bottom tab bar (phones, app and browser) */
.tabbar { display: none; }
@media (max-width: 640px) {
    html .nav > a, html.nerd .nav > a.nerd-only { display: none !important; }
    .nav { justify-content: flex-end; }
    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 800; background: var(--surface); border-top: 1px solid var(--border); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-shadow: 0 -4px 16px rgba(0, 0, 0, .08); }
    .tabbar a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .45rem .1rem .4rem; color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 600; line-height: 1.1; }
    .tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tabbar svg { width: 1.45rem; height: 1.45rem; }
    .tabbar a.active { color: var(--accent); }
    .tabbar a.nerd-only { display: none !important; }
    html.nerd .tabbar a.nerd-only { display: flex !important; }
    body { padding-bottom: calc(3.7rem + env(safe-area-inset-bottom)); }
    .sky-fab { bottom: calc(3.7rem + 14px + env(safe-area-inset-bottom)); }
}

/* "Add to home screen" hint */
.install-hint { position: fixed; z-index: 850; left: 8px; right: 8px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: .75rem; padding: .75rem 2.4rem .75rem .75rem; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 520px; margin: 0 auto; }
.install-hint[hidden] { display: none; }
.install-hint img { border-radius: 10px; flex: none; }
.install-text { display: flex; flex-direction: column; gap: .15rem; font-size: .9rem; line-height: 1.35; flex: 1; }
.install-text [hidden] { display: none; }
.install-share { width: 1.1em; height: 1.1em; vertical-align: -.2em; color: var(--accent); }
.install-close { position: absolute; top: .3rem; right: .45rem; border: 0; background: none; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
@media (max-width: 640px) {
    .install-hint { bottom: calc(3.7rem + 8px + env(safe-area-inset-bottom)); }
    body.install-open .sky-fab { display: none !important; }
}

/* Smooth page changes (Safari 18.2+, Chrome): the sky and the tab bar stay in place. */
@view-transition { navigation: auto; }
.site-header { view-transition-name: sky-header; }
.tabbar { view-transition-name: tabbar; }
/* No cross-fade (it would add time); only keeps the header and tab bar from flickering. */
/* Full page loads (e.g. language switch): short cross-fade, hides a blank first frame. */
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: .15s; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* Test instance (DB_PREFIX): fixed marker, does not move the layout. */
.test-instance-badge { position: fixed; top: calc(env(safe-area-inset-top) + .35rem); left: calc(env(safe-area-inset-left) + .35rem); z-index: 1000; pointer-events: none; padding: .1rem .45rem; border-radius: 4px; background: #c2410c; color: #fff; font: 700 .7rem/1.4 system-ui, sans-serif; letter-spacing: .08em; opacity: .9; }
