:root {
    color-scheme: dark;
    --background: oklch(0.15 0 0);
    --foreground: oklch(0.98 0 0);
    --card: oklch(0.23 0 0);
    --card-foreground: oklch(0.98 0 0);
    --primary: oklch(0.98 0 0);
    --primary-foreground: oklch(0.2 0 0);
    --secondary: oklch(0.28 0 0);
    --secondary-foreground: oklch(0.98 0 0);
    --muted: oklch(0.28 0 0);
    --muted-foreground: oklch(0.7 0 0);
    --accent: oklch(0.28 0 0);
    --accent-foreground: oklch(0.98 0 0);
    --destructive: oklch(0.62 0.2 22);
    --border: oklch(1 0 0 / 10%);
    --input: oklch(1 0 0 / 12%);
    --ring: oklch(0.7 0 0);
    --radius: .625rem;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .28), 0 4px 6px -4px rgb(0 0 0 / .28);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--background);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--foreground);
    /* System fonts only: no external font server to wait for on slow or filtered mobile networks. */
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

button,
input {
    font: inherit;
}

svg {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-shell {
    width: min(1040px, calc(100% - 24px));
    min-height: 100vh;
    margin: 0 auto;
    background: var(--background);
}

.page {
    padding: calc(env(safe-area-inset-top) + 16px) 0 128px;
}

.tab-panel[hidden] {
    display: none;
}

.tab-panel {
    min-height: calc(100vh - 128px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.tab-panel.active,
.camera-list,
.home-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
}

.login-form {
    width: min(100%, 408px);
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--card);
    color: var(--card-foreground);
    box-shadow: var(--shadow-lg);
}

.login-form {
    padding: 20px;
}

.login-title {
    margin: 0 0 16px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0;
}

.login-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted-foreground);
    font-size: 14px;
    font-weight: 600;
}

.login-input {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-bottom: 12px;
    padding: 10px 14px;
    border: 1px solid var(--input);
    border-radius: 16px;
    outline: 0;
    background: rgb(255 255 255 / .04);
    color: var(--foreground);
}

.login-input:focus {
    border-color: var(--ring);
}

.login-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    border: 0;
    border-radius: 24px;
    background: var(--primary);
    color: var(--primary-foreground);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: transform .15s ease;
}

.login-button:active,
.gate-button:active,
.refresh-button:active,
.toolbar-refresh:active,
.home-action:active,
.tab-button:active {
    transform: scale(.98);
}

.camera-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: #000;
    box-shadow: var(--shadow-lg);
}

.camera-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
}

.camera-frame iframe,
.camera-frame video,
.camera-frame img {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
    object-fit: cover;
    transition: transform .5s ease;
}

.camera-card:active .camera-frame iframe,
.camera-card:active .camera-frame video,
.camera-card:active .camera-frame img {
    transform: scale(1.02);
}

.empty-camera {
    display: grid;
    min-height: 160px;
    place-items: center;
    color: var(--muted-foreground);
    font-size: 14px;
}

.camera-frame video::-webkit-media-controls,
.camera-frame video::-webkit-media-controls-enclosure,
.camera-frame video::-webkit-media-controls-panel {
    display: none !important;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gate-button,
.refresh-button,
.home-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0;
    transition: transform .15s ease, background-color .15s ease, color .15s ease, opacity .15s ease;
}

.gate-button {
    width: 100%;
    border-radius: 24px;
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: 0 10px 24px rgb(255 255 255 / .1);
    font-size: 16px;
}

/* Hold-to-open: a fill runs across the button while it is held. */
/* Holding the button must not start iOS text selection or the callout menu, on its label either. */
.gate-button,
.gate-button * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.gate-button {
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.gate-button > :not(.gate-progress) {
    position: relative;
}

.gate-progress {
    position: absolute;
    inset: 0;
    background: oklch(0.82 0 0);
    transform: scaleX(0);
    transform-origin: left center;
}

.gate-button.holding .gate-progress {
    transform: scaleX(1);
    transition: transform .9s linear;
}

.gate-button:disabled {
    cursor: wait;
    opacity: .7;
}

/* Result of the gate command, shown on the button itself */
.gate-button.is-sending {
    opacity: 1;
}

.gate-button.is-success,
.gate-button.is-error {
    color: #fff !important;
}

.gate-button.is-success {
    background: oklch(0.62 0.17 150) !important;
}

.gate-button.is-error {
    background: var(--destructive) !important;
}

.gate-button.is-sending .button-icon,
.gate-button.is-success .button-icon,
.gate-button.is-error .button-icon {
    display: none;
}

.gate-button.is-success .gate-label,
.gate-button.is-error .gate-label {
    animation: gate-result-in .25s ease;
}

@keyframes gate-result-in {
    from {
        opacity: 0;
        transform: scale(.92);
    }
}

.gate-hint,
.login-hint {
    margin: -4px 0 0;
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}


/* Only matters in the wide layout, where it groups the caption with the switch. */
.quality-group {
    display: contents;
}

.login-hint {
    margin: -6px 0 16px;
    text-align: left;
    line-height: 1.4;
}

.login-hint a {
    color: var(--foreground);
}

.devices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.devices-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    cursor: pointer;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 700;
    list-style: none;
}

.devices-summary::-webkit-details-marker {
    display: none;
}

.devices-summary::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-right: 4px;
    border-right: 2px solid var(--muted-foreground);
    border-bottom: 2px solid var(--muted-foreground);
    transform: translateY(-2px) rotate(45deg);
    transition: transform .15s ease;
}

.devices[open] .devices-summary::after {
    transform: translateY(2px) rotate(-135deg);
}

.onu-panel {
    grid-column: 1 / -1;
    min-width: 0;
    margin-top: 8px;
}

.onu-panel[open] > .devices-summary {
    border-radius: 18px 18px 0 0;
}

.onu-panel[open] > .devices-summary::after {
    transform: translateY(2px) rotate(-135deg);
}

.onu-content {
    padding: 4px 16px 14px;
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 18px 18px;
    background: var(--card);
}

.onu-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
    margin: 0;
    font-size: 15px;
}

.onu-values[hidden] { display: none; }
.onu-values > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.onu-values dt { color: var(--muted-foreground); }
.onu-values dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.onu-state { grid-column: 1 / -1; }
.onu-values [data-tone="success"] { color: #86d9a2; }
.onu-values [data-tone="warning"] { color: #f0c876; }
.onu-values [data-tone="error"] { color: #f18e8e; }
.onu-stale dd { color: var(--muted-foreground); }
.onu-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 14px; color: var(--muted-foreground); font-size: 13px; }
.onu-content .message:empty { display: none; }
.onu-content .message { margin-bottom: 0; }
.onu-panel > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }

@media (max-width: 600px) {
    .onu-values { grid-template-columns: minmax(0, 1fr); }
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.device-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    padding: 12px 14px;
}

.device-info {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.device-name {
    font-size: 15px;
    font-weight: 700;
}

.device-badge {
    border-radius: 999px;
    background: rgb(255 255 255 / .12);
    color: var(--muted-foreground);
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

.device-meta {
    color: var(--muted-foreground);
    font-size: 12px;
}

.device-actions {
    display: flex;
    gap: 8px;
}

.device-button {
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
}

.device-button.danger {
    color: var(--destructive);
}

.secondary-action-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
}

.refresh-button {
    min-height: 50px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    color: var(--foreground);
    padding: 0 12px;
    font-size: 14px;
    line-height: 1.15;
    text-align: center;
}

/* Quality: two halves, the chosen one is filled */
.quality-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    min-height: 50px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    padding: 4px;
}

.quality-switch button {
    min-width: 52px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0 6px;
    font-size: 13px;
    font-weight: 700;
    transition: background-color .15s ease, color .15s ease;
}

.quality-switch button[aria-checked="true"] {
    background: var(--primary);
    color: var(--primary-foreground);
}

.quality-switch button:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 1px;
}

.button-icon {
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 20px;
}

.message {
    min-height: 18px;
    color: var(--muted-foreground);
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}

.message.error {
    color: var(--destructive);
}

.message.success {
    color: var(--primary);
}

.camera-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toolbar-title,
.toolbar-subtitle {
    margin: 0;
}

.toolbar-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.toolbar-subtitle {
    margin-top: 2px;
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
}

.toolbar-refresh {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--foreground);
    cursor: pointer;
    transition: transform .15s ease;
}

.toolbar-refresh svg {
    width: 16px;
    height: 16px;
}

.home-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

#homePanel {
    justify-content: flex-start;
    gap: 28px;
}

.switches {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Side by side on wide screens, one under another on phones. */
.switch-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    min-height: 64px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    color: var(--foreground);
    cursor: pointer;
    padding: 12px 16px;
    font: inherit;
    text-align: left;
    transition: background-color .15s ease, transform .15s ease;
}

.switch-row:active:not(:disabled) {
    transform: scale(.98);
}

.switch-row:disabled {
    cursor: default;
    opacity: .55;
}

.switch-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.switch-title {
    font-size: 15px;
    font-weight: 700;
}

.switch-state {
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 600;
}

.switch-row[aria-checked="true"] .switch-state {
    color: oklch(0.82 0.15 85);
}

/* The toggle itself */
.switch-toggle {
    position: relative;
    width: 50px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--secondary);
    transition: background-color .2s ease;
}

.switch-toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: oklch(0.75 0 0);
    transition: transform .2s ease, background-color .2s ease;
}

.switch-row[aria-checked="true"] .switch-toggle {
    background: oklch(0.82 0.15 85);
}

.switch-row[aria-checked="true"] .switch-toggle::after {
    background: #fff;
    transform: translateX(20px);
}

.switch-row.pending .switch-toggle {
    opacity: .6;
}

.section-title {
    grid-column: 1 / -1;
    margin: 0 0 4px;
    color: var(--foreground);
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0;
}

.home-controls .message {
    grid-column: 1 / -1;
}

.home-action {
    border-radius: 18px;
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 14px;
}

.home-action-secondary {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--foreground);
}

.home-action:disabled {
    cursor: wait;
    opacity: .7;
}

.tab-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    border-top: 1px solid var(--border);
    background: oklch(0.15 0 0 / 80%);
    backdrop-filter: blur(24px);
}

.tab-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    width: 100%;
    margin: 0 auto;
    padding: 8px 16px calc(env(safe-area-inset-bottom) + 8px);
}

.tab-button {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 0;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 6px 0;
    transition: transform .15s ease, color .15s ease;
}

.tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 32px;
    border-radius: 999px;
    color: inherit;
    transition: background-color .15s ease, color .15s ease;
}

.tab-icon svg {
    width: 20px;
    height: 20px;
}

.tab-label {
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
}

.tab-button.active {
    color: var(--primary);
}

.tab-button.active .tab-icon {
    background: rgb(255 255 255 / .15);
}

/* Camera names and the full-screen button exist only in the wide layout below. */
.camera-overlay {
    display: none;
}

/*
 * Wide screens (PC). Phones keep the layout above unchanged.
 * Navigation moves to a rail on the left; tabs use the width instead of one long column.
 */
@media (min-width: 1024px) {
    .app-shell {
        width: auto;
        margin: 0 0 0 96px;
        padding: 0 24px;
    }

    /* clip: the slide-in animation must not flash a scrollbar while it runs */
    .page {
        overflow: clip;
        padding: 24px 0 32px;
    }

    /* Every tab sits in the middle of the window height when it is shorter than the window. */
    .tab-panel {
        min-height: calc(100vh - 56px);
    }

    .tab-panel.active {
        justify-content: center;
    }

    /* Navigation rail */
    .tab-bar {
        top: 0;
        right: auto;
        bottom: 0;
        width: 96px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        border-top: 0;
        border-right: 1px solid var(--border);
        background: var(--background);
        backdrop-filter: none;
        padding: 20px 0;
    }

    .tab-button {
        flex: 0 0 auto;
        width: 80px;
        padding: 8px 0;
    }

    .tab-button:hover {
        color: var(--foreground);
    }

    .tab-button:not(.active):hover .tab-icon {
        background: rgb(255 255 255 / .07);
    }

    /* Cameras: name in the corner, full screen on hover, no tap zoom */
    .camera-card {
        border-radius: 14px;
        box-shadow: none;
    }

    .camera-card:active .camera-frame iframe,
    .camera-card:active .camera-frame video,
    .camera-card:active .camera-frame img {
        transform: none;
    }

    /* Name and full-screen button appear on hover, so they never cover the recorder's own date stamp. */
    .camera-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        cursor: pointer;
        padding: 10px 12px;
    }

    #gateCameras .camera-overlay {
        cursor: default;
    }

    .camera-name {
        border-radius: 8px;
        background: rgb(0 0 0 / .6);
        color: #fff;
        padding: 5px 10px;
        font-size: 13px;
        font-weight: 700;
        opacity: 0;
        transition: opacity .15s ease;
    }

    .camera-card:hover .camera-name {
        opacity: 1;
    }

    .camera-fullscreen {
        display: grid;
        width: 32px;
        height: 32px;
        place-items: center;
        border: 0;
        border-radius: 8px;
        background: rgb(0 0 0 / .5);
        color: #fff;
        cursor: pointer;
        opacity: 0;
        transition: opacity .15s ease;
    }

    .camera-card:hover .camera-fullscreen,
    .camera-fullscreen:focus-visible {
        opacity: 1;
    }

    .camera-fullscreen svg {
        width: 18px;
        height: 18px;
    }

    .camera-card:fullscreen {
        border: 0;
        border-radius: 0;
    }

    .camera-card:fullscreen .camera-frame {
        height: 100%;
        aspect-ratio: auto;
    }

    .camera-card:fullscreen .camera-overlay {
        background: none;
        cursor: default;
    }

    /*
     * "Камеры": a 3×3 grid like the recorder. One camera takes 2×2, the other five fill the rest.
     * The grid is limited by the window height so all six fit without scrolling.
     */
    #camerasPanel.active {
        gap: 12px;
    }

    .camera-toolbar,
    #allCameras {
        width: 100%;
        max-width: calc((100vh - 136px) * 16 / 9);
        margin: 0 auto;
    }

    #allCameras {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    #allCameras .camera-card.featured {
        grid-column: span 2;
        grid-row: span 2;
        order: -1;
    }

    #allCameras .camera-card.featured .camera-frame {
        height: 100%;
        aspect-ratio: auto;
    }

    /*
     * "Ворота": both cameras side by side; under them one control bar. The gate button is the
     * centre of it, settings sit compactly on the left, command messages on the right.
     */
    #gatePanel.active {
        width: 100%;
        max-width: calc((100vh - 200px) * 32 / 9 + 12px);
        margin: 0 auto;
    }

    #gateCameras {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .actions {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(320px, 420px) minmax(0, 1fr);
        align-items: center;
        gap: 0 24px;
        border: 1px solid var(--border);
        border-radius: 22px;
        background: var(--card);
        padding: 14px 18px;
    }

    .gate-button {
        grid-column: 2;
        grid-row: 1;
        min-height: 56px;
        box-shadow: none;
    }

    /*
     * The hold hint and command messages pop up as a bubble above the gate button,
     * so the bar itself stays one even row.
     */
    .gate-hint,
    .actions > .message {
        position: absolute;
        bottom: calc(100% + 12px);
        left: 50%;
        z-index: 5;
        width: max-content;
        max-width: 420px;
        min-height: 0;
        margin: 0;
        border-radius: 12px;
        background: var(--primary);
        color: var(--primary-foreground);
        padding: 9px 14px;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.3;
        text-align: center;
        box-shadow: 0 8px 24px rgb(0 0 0 / .45);
        pointer-events: none;
        transform: translate(-50%, 4px);
        transition: opacity .2s ease, transform .2s ease;
    }

    /* On PC the hint is hidden until a short tap; phones always show it under the button. */
    .gate-hint {
        opacity: 0;
    }

    .gate-hint.visible {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    .gate-hint::after,
    .actions > .message::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        border: 7px solid transparent;
        border-top-color: var(--primary);
        transform: translateX(-50%);
    }

    .actions > .message,
    .actions > .message.success {
        color: var(--primary-foreground);
        transform: translate(-50%, 0);
    }

    .actions > .message:empty {
        display: none;
    }

    .actions > .message.error {
        background: var(--destructive);
        color: #fff;
    }

    .actions > .message.error::after {
        border-top-color: var(--destructive);
    }

    /* The row's two parts go to opposite sides of the gate button, for balance. */
    .secondary-action-row {
        display: contents;
    }

    .quality-group {
        display: flex;
        grid-column: 1;
        grid-row: 1;
        align-items: center;
        justify-self: start;
        gap: 10px;
    }


    .quality-switch {
        min-height: 44px;
        background: var(--background);
    }


    .refresh-button {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        min-height: 44px;
        border-radius: 999px;
        background: var(--background);
        padding: 0 18px;
    }

    /* Switching sections slides the new one in from the side the wheel or menu points to */
    .tab-panel.enter-down {
        animation: tab-in-down .35s cubic-bezier(.2, .8, .2, 1);
    }

    .tab-panel.enter-up {
        animation: tab-in-up .35s cubic-bezier(.2, .8, .2, 1);
    }

    /*
     * "Дом": switches across the top, the air conditioner under them, and the device list
     * on its own at the very bottom, so opening it never stretches anything else.
     */
    #homePanel.active {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: center;
        align-items: start;
        gap: 28px 24px;
        width: 100%;
        max-width: 1100px;
        margin: 0 auto;
    }

    .switches {
        grid-column: 1 / -1;
    }

    .devices {
        grid-column: 1 / -1;
        margin-top: 24px;
        border-top: 1px solid var(--border);
        padding-top: 24px;
    }

    .device-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }

    /* Hover feedback that phones do not need */
    .switch-row:hover:not(:disabled),
    .devices-summary:hover {
        background: oklch(0.26 0 0);
    }

    .refresh-button:hover,
    .home-action-secondary:hover,
    .toolbar-refresh:hover,
    .device-button:hover {
        border-color: rgb(255 255 255 / .22);
    }

    .gate-button:hover:not(:disabled),
    .home-action:not(.home-action-secondary):hover {
        background: #fff;
    }
}

@keyframes tab-in-down {
    from {
        opacity: 0;
        transform: translateY(48px);
    }
}

@keyframes tab-in-up {
    from {
        opacity: 0;
        transform: translateY(-48px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tab-panel.enter-down,
    .tab-panel.enter-up {
        animation: none;
    }
}

@media (max-width: 380px) {
    .app-shell {
        width: min(100% - 16px, 1040px);
    }

    .tab-bar {
        width: 100%;
    }

    .secondary-action-row,
    .home-controls {
        gap: 10px;
    }

    .refresh-button,
    .home-action {
        font-size: 13px;
    }
}
