:root {
    --bg-day: #31465c;
    --bg-day-soft: #3f5870;

    --bg-evening: #111b27;
    --bg-night: #05080c;

    --panel: rgba(18, 31, 45, 0.88);
    --panel-day: rgba(29, 48, 67, 0.88);
    --panel-soft: rgba(255, 255, 255, 0.045);

    --text: #f5f7fb;
    --text-soft: #a9b6c7;

    --border: rgba(255, 255, 255, 0.10);

    --radius: 22px;

    --success: #4ed68b;
    --warning: #ffc857;
    --danger: #ff6767;

    --shadow: 0 18px 50px rgba(0, 0, 0, 0.20);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;

    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.14), transparent 36%),
        radial-gradient(circle at 92% 0%, rgba(86, 151, 201, 0.20), transparent 32%),
        linear-gradient(145deg, var(--bg-day-soft), var(--bg-day));
}

body[data-mode="day"] .panel,
body[data-mode="day"] .topbar-block {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 48%),
        var(--panel-day);
}

body[data-mode="evening"] {
    background:
        radial-gradient(circle at top left, rgba(48, 82, 128, 0.18), transparent 35%),
        var(--bg-evening);
}

body[data-mode="night-idle"],
body[data-mode="night-presence"] {
    background: var(--bg-night);
}

button {
    font: inherit;
}

.app {
    width: 100%;
    height: 100vh;
    padding:
        max(12px, env(safe-area-inset-top))
        max(12px, env(safe-area-inset-right))
        max(12px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
    overflow: hidden;
}

.topbar {
    display: grid;
    grid-template-columns: 1.05fr 2.55fr 0.95fr;
    gap: 9px;
    height: 86px;
    margin-bottom: 10px;
}

.topbar-block {
    min-width: 0;
    min-height: 0;
    padding: 10px 13px;

    display: flex;
    flex-direction: column;
    justify-content: center;

    border: 1px solid var(--border);
    border-radius: 17px;

    background: rgba(16, 25, 37, 0.78);
    backdrop-filter: blur(14px);
}

.topbar-block strong {
    font-size: clamp(0.98rem, 1.8vw, 1.35rem);
    white-space: nowrap;
}

.topbar-block span:not(.label) {
    overflow: hidden;
    color: var(--text-soft);
    font-size: 0.75rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.label,
.panel-kicker,
.eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    color: var(--text-soft);
    text-transform: uppercase;
}

.topbar-time {
    position: relative;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    overflow: hidden;
}

.clock {
    flex: 0 0 auto;
    transform: none;
    font-size: clamp(3.55rem, 6.4vw, 5.25rem);
    font-weight: 800;
    line-height: 0.82;
    letter-spacing: -0.065em;
    white-space: nowrap;
}

.date-block {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    min-width: 74px;
    max-width: 88px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    text-align: right;
    line-height: 1;
}

.weekday {
    width: 100%;
    overflow: hidden;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: capitalize;
    text-align: right;
    white-space: nowrap;
}

.calendar-date {
    width: 100%;
    color: var(--text-soft);
    font-size: 0.98rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.topbar-time .clock {
    max-width: calc(100% - 96px);
}



.topbar-weather {
    justify-content: center;
    padding: 7px 12px;
    cursor: pointer;
}

.weather-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.weather-slot {
    position: relative;
    min-width: 0;
    height: 100%;
    padding: 2px 96px 2px 12px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.weather-slot:first-child {
    padding-left: 0;
    border-left: none;
}

.weather-period {
    display: block;
    margin-bottom: 2px;
    color: var(--text-soft);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.weather-mainline {
    display: block;
    min-width: 0;
}

.weather-mainline strong {
    display: block;
    font-size: clamp(3.1rem, 5.4vw, 4.8rem);
    line-height: 0.80;
    letter-spacing: -0.055em;
}

.topbar-block span.weather-icon {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 58px;
    font-size: 3.55rem !important;
    line-height: 1;
    overflow: visible;
}

.weather-desc {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    color: var(--text);
    font-size: 0.70rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar-home {
    align-items: flex-end;
    justify-content: center;
    text-align: right;
    padding-right: 12px;
}

.topbar-home .label {
    width: 100%;
    text-align: right;
    margin-bottom: 2px;
}

.topbar-home strong {
    display: block;
    width: 100%;
    text-align: right;
    font-size: clamp(2.9rem, 4.8vw, 4.25rem);
    line-height: 0.78;
    letter-spacing: -0.055em;
}

.topbar-home #home-humidity {
    display: block;
    width: 100%;
    margin-top: 4px;
    text-align: right;
    font-size: 0.72rem;
    line-height: 1;
    overflow: visible;
    text-overflow: clip;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    height: calc(100vh - 118px);
    min-height: 0;
}

.panel {
    position: relative;

    min-width: 0;
    min-height: 0;
    height: 100%;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 45%),
        var(--panel);

    box-shadow: var(--shadow);

    cursor: pointer;

    transition:
        transform 160ms ease,
        border-color 160ms ease,
        background 160ms ease;
}

.panel:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.16);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    padding: 15px 16px 5px;
}

.panel-header h2 {
    margin: 3px 0 0;

    font-size: clamp(1.25rem, 2.5vw, 1.9rem);
    line-height: 1;
}

.expand-btn {
    width: 35px;
    height: 35px;

    border: 1px solid var(--border);
    border-radius: 11px;

    background: rgba(255, 255, 255, 0.05);

    color: var(--text);

    cursor: pointer;
}

.panel-content {
    height: calc(100% - 59px);
    padding: 8px 16px 14px;
    overflow: hidden;
}

.metric-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;

    margin-bottom: 9px;
}

.metric {
    padding: 9px 10px;

    border: 1px solid var(--border);
    border-radius: 13px;

    background: var(--panel-soft);
}

.metric-label {
    display: block;

    margin-bottom: 4px;

    color: var(--text-soft);
    font-size: 0.66rem;
}

.metric strong {
    font-size: clamp(1.18rem, 2.4vw, 1.65rem);
}

.home-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.action-card {
    width: 100%;
    min-height: 44px;

    display: flex;
    align-items: center;
    gap: 9px;

    padding: 7px 9px;

    text-align: left;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--panel-soft);
    color: var(--text);

    cursor: pointer;
}

.action-card:hover {
    background: rgba(255, 255, 255, 0.075);
}

.action-icon {
    width: 28px;

    text-align: center;
    font-size: 1.05rem;
}

.action-card strong,
.action-card small {
    display: block;
}

.action-card strong {
    font-size: 0.78rem;
}

.action-card small {
    margin-top: 2px;
    color: var(--text-soft);
    font-size: 0.64rem;
}

.now-playing {
    margin-top: 8px;
    padding: 7px 9px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--panel-soft);
}

.now-playing strong,
.now-playing small {
    display: block;
}

.now-playing strong {
    margin-top: 3px;
    font-size: 0.78rem;
}

.now-playing small {
    margin-top: 1px;
    color: var(--text-soft);
    font-size: 0.63rem;
}

.status-card {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 11px;

    margin-bottom: 7px;

    border: 1px solid var(--border);
    border-radius: 13px;

    background: var(--panel-soft);
}

.status-dot {
    width: 9px;
    height: 9px;

    flex: 0 0 auto;

    border-radius: 999px;

    background: var(--text-soft);
}

.status-card.success .status-dot {
    background: var(--success);
    box-shadow: 0 0 14px rgba(78, 214, 139, 0.48);
}

.status-card.warning .status-dot {
    background: var(--warning);
}

.status-card.danger .status-dot {
    background: var(--danger);
}

.status-card strong,
.status-card small {
    display: block;
}

.status-card strong {
    font-size: 0.82rem;
}

.status-card small {
    margin-top: 2px;
    color: var(--text-soft);
    font-size: 0.68rem;
}

.marseille-footer {
    display: flex;
    justify-content: space-between;

    margin-top: 8px;

    color: var(--text-soft);
    font-size: 0.67rem;
}

.radar {
    position: relative;

    width: min(100%, 240px);
    max-height: calc(100% - 58px);
    aspect-ratio: 1 / 1;

    margin: 0 auto 8px;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 999px;

    background:
        radial-gradient(circle, rgba(83, 180, 255, 0.08), transparent 62%),
        rgba(4, 10, 17, 0.58);
}

.radar-ring {
    position: absolute;

    top: 50%;
    left: 50%;

    border: 1px solid rgba(135, 195, 255, 0.14);
    border-radius: 999px;

    transform: translate(-50%, -50%);
}

.radar-ring-1 {
    width: 42%;
    height: 42%;
}

.radar-ring-2 {
    width: 72%;
    height: 72%;
}

.radar-cross {
    position: absolute;

    background: rgba(135, 195, 255, 0.11);
}

.radar-cross-v {
    width: 1px;
    height: 100%;

    left: 50%;
    top: 0;
}

.radar-cross-h {
    height: 1px;
    width: 100%;

    top: 50%;
    left: 0;
}

.airport {
    position: absolute;

    top: 50%;
    left: 50%;

    display: flex;
    flex-direction: column;
    align-items: center;

    transform: translate(-50%, -50%);

    font-size: 0.62rem;
    color: var(--text-soft);
}

.airport-dot {
    width: 9px;
    height: 9px;

    margin-bottom: 3px;

    border-radius: 999px;

    background: #fff;
}

.aircraft {
    position: absolute;

    font-size: 1.05rem;

    transform: rotate(-25deg);
}

.aircraft small {
    display: block;

    margin-top: -2px;

    font-size: 0.52rem;
    color: var(--text-soft);
}

.aircraft-1 {
    top: 24%;
    left: 63%;
}

.aircraft-2 {
    top: 66%;
    left: 24%;
}

.aviation-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);

    gap: 6px;
}

.aviation-stats > div {
    padding: 7px 5px;

    text-align: center;

    border: 1px solid var(--border);
    border-radius: 11px;

    background: var(--panel-soft);
}

.aviation-stats span,
.aviation-stats strong {
    display: block;
}

.aviation-stats span {
    color: var(--text-soft);
    font-size: 0.58rem;
}

.aviation-stats strong {
    margin-top: 3px;
    font-size: 0.78rem;
}

/* Overlay plein écran */

.panel-overlay {
    position: fixed;

    inset: 0;

    z-index: 100;

    display: none;

    padding: 12px;

    background: rgba(3, 6, 10, 0.78);
    backdrop-filter: blur(18px);
}

.panel-overlay.open {
    display: flex;
}

.overlay-content {
    position: relative;

    width: 100%;
    height: 100%;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 22px;

    background: #0d1621;

    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.overlay-close {
    position: fixed;

    top: 24px;
    right: 24px;

    z-index: 110;

    width: 44px;
    height: 44px;

    border: 1px solid var(--border);
    border-radius: 999px;

    background: rgba(15, 23, 35, 0.9);

    color: var(--text);

    font-size: 1.65rem;

    cursor: pointer;
}

#overlay-inner {
    height: 100%;
    padding: 24px;
    overflow: hidden;
}

#overlay-inner .panel {
    min-height: 100%;
    height: 100%;

    cursor: default;
}

#overlay-inner .expand-btn {
    display: none;
}


/* Détail météo 7 jours */

.weather-detail {
    position: fixed;
    left: 7px;
    right: 7px;
    bottom: 7px;
    z-index: 150;
    height: calc(100vh - 88px);
    display: none;
    padding: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 45%),
        rgba(18, 31, 45, 0.98);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(18px);
}

.weather-detail.open {
    display: block;
}

.weather-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    margin-bottom: 10px;
}

.weather-detail-kicker {
    color: var(--text-soft);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.weather-detail-header h2 {
    margin: 2px 0 0;
    font-size: 1.45rem;
}

.weather-detail-close {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
}

.weather-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    height: calc(100% - 64px);
}

.weather-day {
    min-width: 0;
    height: 100%;
    display: grid;
    grid-template-rows: auto auto 1fr auto auto auto auto;
    align-items: center;
    justify-items: center;
    padding: 14px 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    text-align: center;
}

.weather-day-name {
    color: var(--text);
    font-size: 1.55rem;
    font-weight: 850;
    text-transform: uppercase;
}

.weather-day-date {
    margin-top: 5px;
    color: var(--text-soft);
    font-size: 1.18rem;
    font-weight: 650;
}

.weather-day-icon {
    align-self: center;
    margin: 4px 0;
    font-size: 6rem;
    line-height: 1;
}

.weather-day-max {
    font-size: 2.75rem;
    font-weight: 900;
    line-height: 1;
}

.weather-day-min {
    margin-top: 5px;
    color: var(--text-soft);
    font-size: 1.28rem;
    font-weight: 650;
}

.weather-day-desc {
    min-height: 0;
    margin-top: 7px;
    color: var(--text);
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.15;
}

.weather-day-rain {
    margin-top: 7px;
    color: var(--text-soft);
    font-size: 0.98rem;
    font-weight: 650;
}

/* Nuit */

.night-screen {
    position: fixed;

    inset: 0;

    z-index: 200;

    display: none;

    align-items: center;
    justify-content: center;
    flex-direction: column;

    background: #000;

    color: rgba(255, 255, 255, 0.16);

    user-select: none;
}

body[data-mode="night-idle"] .app {
    display: none;
}

body[data-mode="night-idle"] .night-screen {
    display: flex;
}

body[data-mode="night-presence"] .app {
    display: none;
}

body[data-mode="night-presence"] .night-screen {
    display: flex;

    background: #050505;
    color: rgba(255, 255, 255, 0.42);
}

.night-clock {
    font-size: clamp(4rem, 18vw, 10rem);
    font-weight: 650;

    letter-spacing: -0.04em;
}

.night-temps {
    display: flex;
    gap: 36px;

    margin-top: 18px;
}

.night-temps div {
    text-align: center;
}

.night-temps span {
    display: block;

    margin-bottom: 4px;

    font-size: 0.72rem;
    letter-spacing: 0.12em;
}

.night-temps strong {
    font-size: clamp(1.5rem, 5vw, 2.8rem);
}

.night-weather {
    margin-top: 18px;

    font-size: 0.8rem;
}

/* Tablettes paysage, notamment Galaxy Tab Active3 */

@media (max-width: 1100px) and (orientation: landscape) {

    .app {
        padding: 7px;
    }

    .topbar {
        grid-template-columns: 1.12fr 2.65fr 0.9fr;
        gap: 5px;
        height: 72px;
        margin-bottom: 6px;
    }

    .topbar-block {
        padding: 6px 8px;
        border-radius: 12px;
    }

    .topbar-time {
        position: relative;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        overflow: hidden;
    }

    .clock {
        transform: none;
        font-size: 3.72rem;
        line-height: 0.80;
        letter-spacing: -0.065em;
    }

    .date-block {
        position: absolute;
        top: 50%;
        right: 8px;
        transform: translateY(-50%);
        min-width: 68px;
        max-width: 76px;
        align-items: flex-end;
        gap: 4px;
        text-align: right;
    }

    .weekday {
        font-size: 0.90rem;
        font-weight: 700;
        text-align: right;
    }

    .calendar-date {
        font-size: 0.82rem;
        font-weight: 600;
        text-align: right;
    }

    .topbar-time .clock {
        max-width: calc(100% - 84px);
    }

    .topbar-block strong {
        font-size: 0.86rem;
    }

    .topbar-block span:not(.label) {
        font-size: 0.58rem;
    }

    .label {
        font-size: 0.53rem;
    }

    .dashboard-grid {
        height: calc(100vh - 85px);
        gap: 6px;
    }


        .topbar-weather {
        padding: 5px 8px;
    }

    .weather-grid {
        gap: 5px;
    }

    .weather-slot {
        position: relative;
        height: 100%;
        padding: 1px 74px 1px 7px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .weather-period {
        margin-bottom: 1px;
        font-size: 0.54rem;
    }

    .weather-mainline {
        display: block;
    }

    .weather-mainline strong {
        display: block;
        font-size: 2.85rem;
        line-height: 0.80;
        letter-spacing: -0.055em;
    }

    .topbar-block span.weather-icon {
        right: 2px;
        width: 56px;
        height: 48px;
        font-size: 3.00rem !important;
        line-height: 1;
        overflow: visible;
    }

    .weather-desc {
        margin-top: 2px;
        font-size: 0.53rem;
    }

    .topbar-home {
        align-items: flex-end;
        justify-content: center;
        padding: 4px 8px 4px 6px;
        text-align: right;
    }

    .topbar-home .label {
        width: 100%;
        margin-bottom: 1px;
        text-align: right;
        font-size: 0.50rem;
        line-height: 1;
    }

    .topbar-home strong {
        display: block;
        width: 100%;
        text-align: right;
        font-size: 2.95rem;
        line-height: 0.78;
        letter-spacing: -0.055em;
    }

    .topbar-home #home-humidity {
        display: block;
        width: 100%;
        margin-top: 2px;
        text-align: right;
        font-size: 0.55rem;
        line-height: 1;
        overflow: visible;
        text-overflow: clip;
    }


    .weather-detail {
        left: 7px;
        right: 7px;
        bottom: 7px;
        height: calc(100vh - 85px);
        padding: 10px;
        border-radius: 14px;
    }

    .weather-detail-header {
        height: 42px;
        margin-bottom: 7px;
    }

    .weather-detail-header h2 {
        font-size: 1.12rem;
    }

    .weather-detail-close {
        width: 34px;
        height: 34px;
        font-size: 1.25rem;
    }

    .weather-week {
        gap: 5px;
        height: calc(100% - 49px);
    }

    .weather-day {
        height: 100%;
        display: grid;
        grid-template-rows: auto auto 1fr auto auto auto auto;
        align-items: center;
        justify-items: center;
        padding: 8px 3px;
        border-radius: 10px;
    }

    .weather-day-name {
        font-size: 1.18rem;
        font-weight: 850;
    }

    .weather-day-date {
        margin-top: 2px;
        font-size: 0.92rem;
        font-weight: 650;
    }

    .weather-day-icon {
        align-self: center;
        margin: 2px 0;
        font-size: 4.65rem;
        line-height: 1;
    }

    .weather-day-max {
        font-size: 2.15rem;
        font-weight: 900;
        line-height: 1;
    }

    .weather-day-min {
        margin-top: 2px;
        font-size: 1.02rem;
        font-weight: 650;
    }

    .weather-day-desc {
        min-height: 0;
        margin-top: 3px;
        font-size: 0.90rem;
        font-weight: 700;
        line-height: 1.10;
    }

    .weather-day-rain {
        margin-top: 3px;
        font-size: 0.82rem;
        font-weight: 650;
    }

    .panel {
        border-radius: 14px;
    }

    .panel-header {
        padding: 9px 10px 3px;
    }

    .panel-header h2 {
        font-size: 1.08rem;
    }

    .panel-kicker {
        font-size: 0.51rem;
    }

    .panel-content {
        height: calc(100% - 45px);
        padding: 5px 10px 8px;
    }

    .expand-btn {
        width: 29px;
        height: 29px;
        border-radius: 9px;
    }

    .metric-row {
        gap: 5px;
        margin-bottom: 6px;
    }

    .metric {
        padding: 6px 7px;
        border-radius: 10px;
    }

    .metric strong {
        font-size: 1.08rem;
    }

    .metric-label {
        margin-bottom: 2px;
        font-size: 0.56rem;
    }

    .home-actions {
        gap: 5px;
    }

    .action-card {
        min-height: 37px;
        padding: 5px 7px;
        border-radius: 10px;
    }

    .action-icon {
        width: 23px;
        font-size: 0.9rem;
    }

    .action-card strong {
        font-size: 0.69rem;
    }

    .action-card small {
        margin-top: 1px;
        font-size: 0.56rem;
    }

    .now-playing {
        margin-top: 6px;
        padding: 5px 7px;
        border-radius: 10px;
    }

    .now-playing strong {
        font-size: 0.69rem;
    }

    .now-playing small,
    .eyebrow {
        font-size: 0.54rem;
    }

    .status-card {
        gap: 8px;
        padding: 7px;
        margin-bottom: 5px;
        border-radius: 10px;
    }

    .status-card strong {
        font-size: 0.69rem;
    }

    .status-card small {
        font-size: 0.57rem;
    }

    .marseille-footer {
        margin-top: 5px;
        font-size: 0.56rem;
    }

    .radar {
        width: min(100%, 185px);
        margin: 0 auto 5px;
    }

    .aviation-stats {
        gap: 4px;
    }

    .aviation-stats > div {
        padding: 5px 3px;
        border-radius: 9px;
    }

    .aviation-stats span {
        font-size: 0.51rem;
    }

    .aviation-stats strong {
        margin-top: 2px;
        font-size: 0.69rem;
    }
}

/* Portrait : fallback responsive */

@media (max-width: 700px) and (orientation: portrait) {

    html,
    body {
        overflow: auto;
    }

    .app {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .topbar {
        height: auto;
        grid-template-columns: 1fr 1fr;
    }

    .topbar-time {
        grid-column: span 2;
    }

    .dashboard-grid {
        height: auto;
        grid-template-columns: 1fr;
    }

    .panel {
        min-height: 420px;
    }
}


/* =========================================================
   MAISON — V16
   Vue synthétique = raccourcis.
   Vue ouverte = cockpit détaillé.
   ========================================================= */

.home-expanded-only {
    display: none;
}

.home-compact-only {
    height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 9px;
}

.panel-home .panel-content {
    position: relative;
}

.home-scene-strip {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.home-scene-btn {
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.055);
    color: var(--text);
    cursor: pointer;
    font: inherit;
}

.home-scene-btn:hover,
.home-scene-btn:active {
    background: rgba(255,255,255,.10);
}

.home-scene-btn > span {
    font-size: 1.12rem;
    line-height: 1;
}

.home-scene-btn > strong {
    min-width: 0;
    font-size: .73rem;
    line-height: 1;
    white-space: nowrap;
}

.home-scene-night {
    background: rgba(68, 82, 114, .28);
}

.home-music-compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 63px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.045);
}

.home-music-main {
    min-width: 0;
}

.home-music-main strong,
.home-music-main small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-music-main strong {
    margin-top: 2px;
    font-size: .78rem;
}

.home-music-main small {
    margin-top: 3px;
    color: var(--text-soft);
    font-size: .60rem;
}

.home-music-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.home-control-btn {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(255,255,255,.065);
    color: var(--text);
    font-size: .88rem;
    cursor: pointer;
}

.home-volume-value {
    min-width: 34px;
    text-align: center;
    color: var(--text-soft);
    font-size: .63rem;
    font-weight: 750;
}

.home-action-toast {
    position: absolute;
    left: 50%;
    bottom: 10px;
    z-index: 20;
    max-width: calc(100% - 24px);
    transform: translate(-50%, 8px);
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(10,18,28,.94);
    color: var(--text);
    font-size: .66rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    white-space: nowrap;
}

.home-action-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Maison ouverte */

#overlay-inner .panel-home .home-compact-only {
    display: none;
}

#overlay-inner .panel-home .home-expanded-only {
    display: block;
    height: 100%;
}

#overlay-inner .panel-home .panel-content {
    height: calc(100% - 62px);
    padding: 8px 16px 15px;
}

.home-expanded-grid {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.08fr .92fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
}

.home-expanded-card {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(255,255,255,.04);
}

.home-section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px;
}

.home-section-title > span {
    color: var(--text-soft);
    font-size: .60rem;
    font-weight: 800;
    letter-spacing: .13em;
}

.home-section-title > strong {
    font-size: .80rem;
}

.home-scene-grid {
    height: calc(100% - 29px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.home-scene-large {
    flex-direction: column;
    gap: 5px;
}

.home-scene-large > span {
    font-size: 1.8rem;
}

.home-scene-large > strong {
    font-size: .86rem;
}

.home-player {
    height: calc(100% - 29px);
    display: grid;
    grid-template-rows: minmax(0,1fr) auto;
    gap: 8px;
}

.home-player-status {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
}

.home-player-status strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.06rem;
}

.home-player-status small {
    margin-top: 5px;
    color: var(--text-soft);
    font-size: .70rem;
}

.home-player-buttons {
    display: grid;
    grid-template-columns: 54px 44px minmax(54px,1fr) 44px;
    gap: 7px;
    align-items: center;
}

.home-player-btn {
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255,255,255,.065);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
}

.home-player-volume {
    text-align: center;
    font-size: 1rem;
    font-weight: 850;
}

.home-status-grid {
    height: calc(100% - 29px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    grid-template-rows: repeat(3, minmax(0,1fr));
    gap: 7px;
}

.home-status-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255,255,255,.035);
}

.home-status-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-soft);
    font-size: .62rem;
}

.home-status-item strong {
    margin-top: 4px;
    font-size: .86rem;
}

.home-light-grid {
    height: calc(100% - 29px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    grid-template-rows: repeat(2, minmax(0,1fr));
    gap: 7px;
}

.home-light-btn {
    min-width: 0;
    display: grid;
    grid-template-columns: 26px minmax(0,1fr);
    grid-template-rows: auto auto;
    align-content: center;
    column-gap: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255,255,255,.035);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.home-light-btn > span {
    grid-row: 1 / 3;
    align-self: center;
    font-size: 1.25rem;
}

.home-light-btn > strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .72rem;
}

.home-light-btn > small {
    margin-top: 3px;
    color: var(--text-soft);
    font-size: .60rem;
}

.home-light-btn.is-on {
    background: rgba(255, 222, 135, .11);
    border-color: rgba(255, 222, 135, .28);
}

@media (orientation: landscape) and (max-height: 800px) {
    .home-scene-strip {
        gap: 5px;
    }

    .home-scene-btn {
        padding: 5px 6px;
        border-radius: 10px;
    }

    .home-scene-btn > span {
        font-size: .95rem;
    }

    .home-scene-btn > strong {
        font-size: .64rem;
    }

    .home-music-compact {
        min-height: 51px;
        padding: 6px 7px;
        border-radius: 10px;
    }

    .home-control-btn {
        width: 27px;
        height: 27px;
        border-radius: 8px;
        font-size: .78rem;
    }

    .home-music-main strong {
        font-size: .69rem;
    }

    .home-music-main small,
    .home-volume-value {
        font-size: .55rem;
    }

    #overlay-inner .panel-home .panel-content {
        height: calc(100% - 45px);
        padding: 5px 10px 8px;
    }

    .home-expanded-grid {
        gap: 7px;
    }

    .home-expanded-card {
        padding: 8px;
        border-radius: 11px;
    }

    .home-section-title {
        margin-bottom: 6px;
    }

    .home-section-title > span {
        font-size: .49rem;
    }

    .home-section-title > strong {
        font-size: .68rem;
    }

    .home-scene-large > span {
        font-size: 1.35rem;
    }

    .home-scene-large > strong {
        font-size: .70rem;
    }

    .home-player-status {
        padding: 6px 8px;
    }

    .home-player-status strong {
        font-size: .86rem;
    }

    .home-player-status small {
        margin-top: 3px;
        font-size: .57rem;
    }

    .home-player-buttons {
        grid-template-columns: 42px 36px minmax(46px,1fr) 36px;
        gap: 5px;
    }

    .home-player-btn {
        height: 34px;
        font-size: .90rem;
    }

    .home-player-volume {
        font-size: .82rem;
    }

    .home-status-grid,
    .home-light-grid {
        gap: 5px;
    }

    .home-status-item {
        padding: 5px 7px;
    }

    .home-status-item span {
        font-size: .51rem;
    }

    .home-status-item strong {
        margin-top: 2px;
        font-size: .68rem;
    }

    .home-light-btn {
        grid-template-columns: 22px minmax(0,1fr);
        padding: 5px 7px;
    }

    .home-light-btn > span {
        font-size: 1rem;
    }

    .home-light-btn > strong {
        font-size: .59rem;
    }

    .home-light-btn > small {
        font-size: .51rem;
    }
}


/* =========================================================
   MAISON — V17
   Compact : scènes courtes + vue directe de tous les Sonos.
   ========================================================= */

.home-compact-only {
    grid-template-rows: 42px minmax(0, 1fr);
    gap: 7px;
}

.home-scene-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: 42px;
    gap: 5px;
}

.home-scene-btn {
    padding: 4px 5px;
    gap: 5px;
    border-radius: 10px;
}

.home-scene-btn > span {
    font-size: 1rem;
}

.home-scene-btn > strong {
    font-size: .78rem;
    font-weight: 850;
    letter-spacing: -.01em;
}

.home-music-compact {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 27px minmax(0, 1fr);
    gap: 5px;
    padding: 7px 8px 8px;
}

.home-music-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.home-music-header .eyebrow {
    font-size: .58rem;
}

.home-music-header > strong {
    font-size: .74rem;
}

.home-speaker-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 5px;
}

.home-speaker-card {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 35px 28px;
    align-items: center;
    gap: 5px;
    padding: 4px 5px 4px 7px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(255,255,255,.035);
}

.home-speaker-card.is-playing {
    background: rgba(255,255,255,.075);
}

.home-speaker-info {
    min-width: 0;
}

.home-speaker-info strong,
.home-speaker-info small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-speaker-info strong {
    font-size: .69rem;
    line-height: 1.05;
}

.home-speaker-info small {
    margin-top: 2px;
    color: var(--text-soft);
    font-size: .52rem;
    line-height: 1;
}

.home-speaker-volume {
    text-align: right;
    color: var(--text-soft);
    font-size: .56rem;
    font-weight: 800;
}

.home-speaker-play {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,.065);
    color: var(--text);
    font-size: .76rem;
    cursor: pointer;
}

@media (orientation: landscape) and (max-height: 800px) {
    .home-compact-only {
        grid-template-rows: 36px minmax(0, 1fr);
        gap: 5px;
    }

    .home-scene-strip {
        grid-template-rows: 36px;
        gap: 4px;
    }

    .home-scene-btn {
        padding: 3px 4px;
        gap: 4px;
        border-radius: 8px;
    }

    .home-scene-btn > span {
        font-size: .90rem;
    }

    .home-scene-btn > strong {
        font-size: .72rem;
    }

    .home-music-compact {
        grid-template-rows: 22px minmax(0, 1fr);
        gap: 4px;
        padding: 5px 6px 6px;
    }

    .home-music-header .eyebrow {
        font-size: .50rem;
    }

    .home-music-header > strong {
        font-size: .64rem;
    }

    .home-speaker-grid {
        gap: 4px;
    }

    .home-speaker-card {
        grid-template-columns: minmax(0, 1fr) 31px 25px;
        gap: 4px;
        padding: 3px 4px 3px 6px;
        border-radius: 8px;
    }

    .home-speaker-info strong {
        font-size: .61rem;
    }

    .home-speaker-info small {
        font-size: .46rem;
    }

    .home-speaker-volume {
        font-size: .49rem;
    }

    .home-speaker-play {
        width: 25px;
        height: 25px;
        border-radius: 7px;
        font-size: .68rem;
    }
}


/* =========================================================
   MAISON — V18
   3 scènes en haut + Bonne nuit pleine largeur.
   Le reste de la hauteur est réservé à la musique.
   ========================================================= */

.home-compact-only {
    grid-template-rows: 78px minmax(0, 1fr);
    gap: 6px;
}

.home-scene-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: 36px 36px;
    gap: 6px;
}

.home-scene-btn {
    min-width: 0;
    width: 100%;
    padding: 4px 6px;
    border-radius: 9px;
}

.home-scene-btn > span {
    display: none;
}

.home-scene-btn > strong {
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .86rem;
    font-weight: 850;
    line-height: 1;
}

.home-scene-goodnight {
    grid-column: 1 / -1;
    grid-row: 2;
}

.home-scene-goodnight > strong {
    font-size: .90rem;
}

.home-music-compact {
    min-height: 0;
    height: 100%;
}

@media (orientation: landscape) and (max-height: 800px) {
    .home-compact-only {
        grid-template-rows: 68px minmax(0, 1fr);
        gap: 5px;
    }

    .home-scene-strip {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-rows: 32px 31px;
        gap: 5px;
    }

    .home-scene-btn {
        padding: 3px 5px;
        border-radius: 8px;
    }

    .home-scene-btn > strong {
        font-size: .79rem;
    }

    .home-scene-goodnight > strong {
        font-size: .82rem;
    }
}
