/* ═══════════════════════════════════════════════════════════
   ALICE DISPLAY - RESPONSIVE STYLES
   Device-specific layouts and media queries (consolidated)
   ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   PHONE PORTRAIT (max-width: 480px, portrait)
   Detection: max-width 480px AND portrait orientation
   ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) and (orientation: portrait) {
    /* Container */
    .display-container {
        background: var(--color-bg-primary);
    }
    
    /* Image positioning */
    .image-layer {
        padding-top: 100px;
        padding-top: max(100px, calc(env(safe-area-inset-top, 0px) + 50px));
        padding-bottom: 60px;
        padding-bottom: max(60px, calc(env(safe-area-inset-bottom, 0px) + 40px));
        box-sizing: border-box;
    }
    
    .image-layer img {
        max-height: calc(100dvh - 140px);
        max-width: 100vw;
        width: auto;
        height: auto;
        border-radius: var(--radius-sm);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    /* Weather widget - top-left horizontal bar */
    /* iPhone notch: safe-area-inset-top is ~47px, need extra padding */
    .weather-widget {
        top: 60px;
        top: max(60px, calc(env(safe-area-inset-top, 0px) + 12px));
        bottom: auto;
        left: 12px;
        right: auto;
        transform: none;
        min-width: auto;
        max-width: 65vw;
        width: auto;
        padding: 10px 14px;
        border-radius: var(--radius-lg);
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-sm);
    }
    
    .weather-widget.collapsed {
        top: 60px;
        top: max(60px, calc(env(safe-area-inset-top, 0px) + 12px));
        left: 20px;
        width: 50px;
        height: 50px;
        min-width: 50px;
        max-width: 50px;
        padding: 8px;
        border-radius: var(--radius-full);
    }
    
    .weather-widget.collapsed .weather-widget-icon {
        font-size: 26px;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
    }
    
    .weather-widget-header {
        margin-bottom: 0;
        gap: 6px;
        flex-shrink: 0;
    }
    
    .weather-widget-icon { font-size: 24px; }
    .weather-widget-temp { font-size: 20px; }
    .weather-widget-temp .unit { font-size: 12px; }
    .weather-widget-condition { font-size: 12px; margin-bottom: 0; }
    .weather-widget-description { font-size: 9px; display: none; }
    .weather-widget-divider { display: none; }
    .weather-widget-time { display: none; }
    
    .weather-widget-details {
        font-size: 10px;
        flex-direction: row;
        gap: 12px;
        margin-left: auto;
    }
    
    .weather-widget-detail-value { font-size: 12px; }
    .weather-widget-detail-label { font-size: 8px; }
    
    /* Portrait clock - top right */
    .portrait-clock {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        position: fixed;
        top: 60px;
        top: max(60px, calc(env(safe-area-inset-top, 0px) + 12px));
        right: 15px;
        z-index: var(--z-widget);
        color: white;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    }
    
    .portrait-clock-time {
        font-size: 32px;
        font-weight: 300;
        letter-spacing: 1px;
        font-variant-numeric: tabular-nums;
        line-height: 1;
    }
    
    .portrait-clock-period {
        font-size: 11px;
        font-weight: 500;
        opacity: 0.9;
        margin-top: 4px;
        background: rgba(0, 0, 0, 0.4);
        padding: 3px 8px;
        border-radius: 6px;
    }
    
    /* Status overlay */
    .status-overlay {
        bottom: 20px;
        bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 10px));
        left: 20px;
        min-height: 44px;
        padding: 12px 20px;
        font-size: 14px;
        gap: var(--space-md);
    }
    
    .status-overlay.collapsed {
        width: 50px;
        height: 50px;
        min-height: 50px;
        border-radius: var(--radius-full);
        padding: 0;
        justify-content: center;
        align-items: center;
    }
    
    .status-item .icon { font-size: 18px; }
    .status-item .value { font-size: 14px; font-weight: 600; }
    .status-item .label { font-size: 12px; }
    
    /* Command center - positioned in dark footer area, aligned with status overlay */
    .command-center {
        top: auto !important;
        bottom: 20px !important;
        bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 10px)) !important;
        right: 20px !important;
        position: fixed !important;
    }
    
    .command-center-button {
        width: 44px;
        height: 44px;
        font-size: 18px;
        box-shadow: 0 3px 12px var(--accent-primary);
    }
    
    .command-center-popup {
        bottom: 0;
        right: 52px;
        flex-direction: row;
        gap: var(--space-sm);
    }
    
    .command-center-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
    
    /* Image control panel */
    .image-control-panel {
        bottom: 200px;
        right: 20px;
        min-width: 220px;
        max-width: 260px;
        padding: var(--space-md);
        border-radius: var(--radius-lg);
    }
    
    .image-control-btn {
        padding: 12px 14px;
        border-radius: var(--radius-sm);
        font-size: 13px;
        min-height: 48px;
    }
    
    .image-control-btn-icon { font-size: 18px; }
    
    /* Vacuum panel */
    .vacuum-panel {
        bottom: 200px;
        right: 20px;
        min-width: 240px;
        max-width: 280px;
    }
    
    /* Lights panel */
    .lights-panel {
        bottom: 200px;
        right: 20px;
        min-width: 220px;
        max-width: 260px;
    }
    
    /* Hide title overlay */
    .title-overlay {
        display: none !important;
    }
    
    /* Install banner */
    .install-banner {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .install-banner-content {
        flex-direction: column;
    }
    
    .install-banner-actions {
        width: 100%;
    }
    
    .install-btn, .dismiss-btn {
        flex: 1;
    }
}

/* Browser-specific: Safari iOS phone portrait - align with status overlay */
.browser-safari.platform-ios .command-center {
    bottom: 20px !important;
}

/* ─────────────────────────────────────────────────────────────
   PHONE LANDSCAPE (max-height: 480px, landscape)
   Detection: max-height 480px AND landscape orientation
   ───────────────────────────────────────────────────────────── */
@media (max-height: 480px) and (orientation: landscape) {
    .display-container {
        background: var(--color-bg-primary);
        justify-content: center;
        padding: 0;
    }
    
    /* Image positioning */
    .image-layer {
        padding: 12px 80px 12px 60px;
        box-sizing: border-box;
    }
    
    .image-layer img {
        max-height: calc(100vh - 24px);
        max-width: calc(100vw - 140px);
        width: auto;
        height: auto;
        border-radius: var(--radius-md);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    /* Weather widget - ultra-compact left sidebar */
    .weather-widget {
        position: fixed;
        top: 50%;
        left: 8px;
        left: max(8px, calc(env(safe-area-inset-left, 0px) + 8px));
        transform: translateY(-50%);
        bottom: auto;
        right: auto;
        width: 40px;
        min-width: 40px;
        max-width: 40px;
        height: auto;
        max-height: 200px;
        padding: 12px 6px;
        border-radius: var(--radius-xl);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(30, 30, 50, 0.9) 100%);
        backdrop-filter: blur(10px);
        border: 1px solid var(--white-15);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }
    
    .weather-widget-header {
        flex-direction: column;
        align-items: center;
        gap: 4px;
        margin-bottom: 0;
        width: 100%;
    }
    
    .weather-widget-icon { font-size: 20px; line-height: 1; }
    .weather-widget-temp { font-size: 14px; font-weight: 700; text-align: center; line-height: 1; }
    .weather-widget-temp .unit { font-size: 10px; opacity: 0.8; }
    .weather-widget-condition { display: none; }
    .weather-widget-description { display: none; }
    .weather-widget-divider { width: 20px; height: 1px; background: var(--white-20); margin: 6px 0; display: block; }
    .weather-widget-details { display: none; }
    .weather-widget-time { display: none; }
    
    /* Landscape clock - bottom-right */
    .landscape-clock {
        position: fixed;
        bottom: 12px;
        bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
        right: 12px;
        right: max(12px, calc(env(safe-area-inset-right, 0px) + 12px));
        display: flex;
        align-items: baseline;
        gap: 6px;
        color: white;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(8px);
        padding: 6px 12px;
        border-radius: var(--radius-lg);
        border: 1px solid var(--white-10);
        z-index: var(--z-widget);
    }
    
    .landscape-clock-time {
        font-size: 16px;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
        line-height: 1;
    }
    
    .landscape-clock-period {
        font-size: 12px;
        font-weight: 500;
        opacity: 0.8;
    }
    
    /* Status overlay - left side vertical */
    .status-overlay {
        position: fixed;
        top: 50%;
        left: 58px;
        left: max(58px, calc(env(safe-area-inset-left, 0px) + 58px));
        bottom: auto;
        right: auto;
        transform: translateY(-50%);
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 12px;
        border-radius: var(--radius-lg);
        font-size: 12px;
        gap: var(--space-sm);
        min-height: auto;
        width: auto;
        max-width: 120px;
        background: var(--overlay-glass);
        backdrop-filter: blur(8px);
        border: 1px solid var(--white-10);
    }
    
    .status-overlay.collapsed {
        width: 36px;
        height: 36px;
        min-height: 36px;
        border-radius: var(--radius-full);
        padding: 0;
        justify-content: center;
        align-items: center;
        flex-direction: row;
    }
    
    .status-item {
        gap: 6px;
        font-size: 11px;
        width: 100%;
    }
    
    .status-item .icon { font-size: 14px; }
    .status-item .value { font-size: 12px; font-weight: 600; }
    .status-item .label { font-size: 10px; opacity: 0.7; line-height: 1.2; }
    
    /* Command center - right side */
    .command-center {
        position: fixed;
        top: 50%;
        right: 12px;
        right: max(12px, calc(env(safe-area-inset-right, 0px) + 12px));
        bottom: auto;
        transform: translateY(-50%);
    }
    
    .command-center-button {
        width: 48px;
        height: 48px;
        font-size: 20px;
        box-shadow: 0 4px 16px var(--accent-primary);
    }
    
    .command-center-popup {
        bottom: auto;
        top: -10px;
        right: 0;
        gap: var(--space-sm);
        transform: translateY(-100%);
    }
    
    .command-center-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Panels */
    .image-control-panel {
        top: 20px;
        right: 12px;
        right: max(12px, calc(env(safe-area-inset-right, 0px) + 12px));
        bottom: auto;
        min-width: 200px;
        max-width: 220px;
        border-radius: var(--radius-lg);
        padding: var(--space-md);
    }
    
    .image-control-btn {
        padding: 10px 12px;
        border-radius: 10px;
        font-size: 13px;
        min-height: 40px;
    }
    
    .image-control-btn-icon { font-size: 18px; }
    
    /* Fullscreen button */
    .fullscreen-btn {
        bottom: 12px;
        bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
        right: 70px;
        right: max(70px, calc(env(safe-area-inset-right, 0px) + 70px));
        top: auto;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Hide elements */
    .portrait-clock { display: none !important; }
    .title-overlay { display: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   TABLET PORTRAIT (481px-1024px width, portrait)
   Detection: 481px-1024px width AND portrait orientation
   ───────────────────────────────────────────────────────────── */
@media (min-width: 481px) and (max-width: 1024px) and (orientation: portrait) {
    .display-container {
        background: var(--color-bg-primary);
        padding: 20px;
    }
    
    /* Image positioning */
    .image-layer {
        padding-top: 100px;
        padding-bottom: 100px;
        padding-left: 20px;
        padding-right: 20px;
        box-sizing: border-box;
    }
    
    .image-layer img {
        max-width: 85vw;
        max-height: calc(100vh - 220px);
        width: auto;
        height: auto;
        border-radius: var(--radius-lg);
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    }
    
    /* Weather widget - top-left, full vertical */
    .weather-widget {
        top: 30px;
        left: 30px;
        bottom: auto;
        right: auto;
        transform: none;
        min-width: 280px;
        max-width: 320px;
        width: auto;
        padding: var(--space-lg);
        border-radius: var(--radius-xl);
        display: flex;
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .weather-widget-header {
        display: flex;
        align-items: center;
        gap: var(--space-md);
        margin-bottom: 0;
    }
    
    .weather-widget-icon { font-size: 48px; flex-shrink: 0; }
    .weather-widget-temp { font-size: 36px; font-weight: 300; }
    .weather-widget-temp .unit { font-size: 20px; }
    .weather-widget-condition { font-size: 18px; font-weight: 500; margin-bottom: 4px; }
    .weather-widget-description { font-size: 14px; opacity: 0.7; display: block; }
    .weather-widget-divider { height: 1px; background: var(--white-10); margin: var(--space-md) 0; display: block; }
    
    .weather-widget-details {
        display: flex;
        justify-content: space-between;
        font-size: 14px;
    }
    
    .weather-widget-detail-value { font-weight: 600; font-size: 16px; }
    .weather-widget-detail-label { opacity: 0.6; font-size: 12px; }
    
    .weather-widget-time {
        margin-top: var(--space-md);
        padding-top: var(--space-md);
        border-top: 1px solid var(--white-10);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .weather-widget-clock { font-size: 28px; font-weight: 300; font-variant-numeric: tabular-nums; }
    .weather-widget-period { font-size: 16px; opacity: 0.9; background: var(--white-10); padding: 6px 12px; border-radius: var(--radius-md); }
    
    /* Status overlay - bottom-left */
    .status-overlay {
        bottom: 30px;
        left: 30px;
        top: auto;
        right: auto;
        transform: none;
        padding: var(--space-md) var(--space-lg);
        border-radius: var(--radius-xl);
        font-size: 16px;
        gap: var(--space-lg);
        min-height: 60px;
    }
    
    .status-overlay.collapsed {
        width: 60px;
        height: 60px;
        border-radius: var(--radius-full);
        padding: 0;
        min-height: 60px;
    }
    
    .status-item { gap: 10px; }
    .status-item .icon { font-size: 22px; }
    .status-item .value { font-size: 16px; font-weight: 600; }
    .status-item .label { font-size: 14px; opacity: 0.8; }
    
    /* Command center - bottom-right */
    .command-center {
        bottom: 30px;
        right: 30px;
    }
    
    .command-center-button {
        width: 64px;
        height: 64px;
        font-size: 28px;
        border-radius: var(--radius-full);
        box-shadow: var(--shadow-glow);
    }
    
    .command-center-button:hover {
        transform: scale(1.1);
    }
    
    .command-center-popup {
        bottom: 80px;
        right: 0;
        gap: var(--space-md);
    }
    
    .command-center-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
        border-radius: var(--radius-full);
    }
    
    .command-center-icon:hover {
        transform: scale(1.15);
        box-shadow: 0 6px 20px var(--white-20);
    }
    
    /* Image control panel */
    .image-control-panel {
        bottom: 120px;
        right: 30px;
        min-width: 280px;
        border-radius: var(--radius-xl);
        padding: 20px;
    }
    
    .image-control-btn {
        padding: 18px 20px;
        border-radius: var(--radius-lg);
        font-size: 16px;
        min-height: 60px;
    }
    
    .image-control-btn-icon { font-size: 24px; }
    
    /* Hide portrait clock (weather widget has time) */
    .portrait-clock { display: none !important; }
    
    /* Show title overlay */
    .title-overlay {
        display: block !important;
        top: 30px;
        font-size: 18px;
        padding: 12px 24px;
        border-radius: var(--radius-lg);
        max-width: 70%;
    }
    
    /* Fullscreen button */
    .fullscreen-btn {
        bottom: 30px;
        right: 120px;
        width: 52px;
        height: 52px;
        font-size: 24px;
        background: var(--white-15);
        backdrop-filter: blur(10px);
        opacity: 0.6;
    }
    
    .fullscreen-btn:hover {
        opacity: 1;
        transform: scale(1.1);
        background: var(--white-20);
    }
    
    /* Safe area handling */
    .weather-widget {
        top: max(30px, calc(env(safe-area-inset-top, 0px) + 20px));
    }
    
    .status-overlay,
    .command-center,
    .fullscreen-btn {
        bottom: max(30px, calc(env(safe-area-inset-bottom, 0px) + 20px));
    }
}

/* ─────────────────────────────────────────────────────────────
   TABLET LANDSCAPE (769px-1199px width, landscape)
   Detection: 769px-1199px width AND landscape orientation
   ───────────────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1199px) and (orientation: landscape) {
    .display-container {
        background: var(--color-bg-primary);
        display: flex;
        flex-direction: row;
        align-items: stretch;
        padding: 0;
    }
    
    /* Image positioning */
    .image-layer {
        flex: 1;
        padding: 20px 30px 20px 0;
        box-sizing: border-box;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: 280px;
        width: calc(100vw - 280px);
        flex: none;
    }
    
    .image-layer img {
        max-width: 100%;
        max-height: calc(100vh - 40px);
        width: auto;
        height: auto;
        border-radius: var(--radius-lg);
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    }
    
    /* Weather widget - left sidebar */
    .weather-widget {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: none;
        width: 280px;
        height: 100vh;
        padding: 30px 24px;
        border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
        display: flex;
        flex-direction: column;
        gap: 20px;
        background: linear-gradient(135deg, var(--overlay-darkest) 0%, rgba(30, 30, 50, 0.95) 100%);
        backdrop-filter: blur(20px);
        border-right: 1px solid var(--white-10);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .weather-widget-header {
        display: flex;
        align-items: center;
        gap: var(--space-md);
        margin-bottom: 0;
    }
    
    .weather-widget-icon { font-size: 52px; flex-shrink: 0; }
    .weather-widget-temp { font-size: 40px; font-weight: 300; line-height: 1.2; }
    .weather-widget-temp .unit { font-size: 22px; opacity: 0.8; }
    .weather-widget-condition { font-size: 20px; font-weight: 600; margin-bottom: 6px; color: var(--white-95); }
    .weather-widget-description { font-size: 16px; opacity: 0.7; display: block; text-transform: capitalize; }
    
    .weather-widget-divider {
        height: 2px;
        background: linear-gradient(90deg, var(--white-20) 0%, transparent 100%);
        margin: 20px 0;
        display: block;
        border-radius: 1px;
    }
    
    .weather-widget-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px 12px;
        font-size: 14px;
    }
    
    .weather-widget-detail {
        text-align: center;
        padding: 12px 8px;
        background: var(--white-5);
        border-radius: var(--radius-md);
        transition: background var(--transition-fast);
    }
    
    .weather-widget-detail:hover { background: var(--white-10); }
    .weather-widget-detail-value { font-weight: 700; font-size: 18px; display: block; margin-bottom: 4px; }
    .weather-widget-detail-label { opacity: 0.6; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
    
    .weather-widget-time {
        margin-top: auto;
        padding-top: var(--space-lg);
        border-top: 1px solid var(--white-10);
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .weather-widget-clock { font-size: 32px; font-weight: 200; font-variant-numeric: tabular-nums; text-align: center; }
    .weather-widget-period { font-size: 18px; opacity: 0.9; background: var(--white-10); padding: 8px 16px; border-radius: var(--radius-lg); text-align: center; font-weight: 500; }
    
    /* Status overlay - bottom distributed */
    .status-overlay {
        position: fixed;
        bottom: 30px;
        left: 320px;
        right: 30px;
        top: auto;
        transform: none;
        padding: var(--space-md) var(--space-xl);
        border-radius: var(--radius-xl);
        font-size: 16px;
        gap: var(--space-xl);
        min-height: 64px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: var(--overlay-darker);
        backdrop-filter: blur(15px);
        border: 1px solid var(--white-10);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
    
    .status-overlay.collapsed {
        width: 64px;
        height: 64px;
        left: auto;
        right: 160px;
        justify-content: center;
        gap: 0;
    }
    
    .status-item {
        gap: 12px;
        flex: 1;
        justify-content: center;
    }
    
    .status-item .icon { font-size: 24px; }
    .status-item .value { font-size: 18px; font-weight: 700; }
    .status-item .label { font-size: 14px; opacity: 0.8; }
    
    /* Command center - top-right */
    .command-center {
        position: fixed;
        top: 30px;
        right: 30px;
        bottom: auto;
    }
    
    .command-center-button {
        width: 64px;
        height: 64px;
        font-size: 28px;
        border-radius: var(--radius-full);
        box-shadow: var(--shadow-glow);
    }
    
    .command-center-button:hover {
        transform: scale(1.1);
    }
    
    .command-center-popup {
        bottom: auto;
        top: 80px;
        right: 0;
        gap: var(--space-md);
    }
    
    .command-center-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
        border-radius: var(--radius-full);
    }
    
    /* Image control panel */
    .image-control-panel {
        position: fixed;
        top: 120px;
        right: 30px;
        bottom: auto;
        min-width: 280px;
        border-radius: var(--radius-xl);
        padding: 20px;
    }
    
    /* Hide elements */
    .portrait-clock { display: none !important; }
    
    /* Title overlay */
    .title-overlay {
        display: block !important;
        top: 30px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 18px;
        padding: 12px 24px;
        border-radius: var(--radius-lg);
        max-width: 60%;
        margin-left: 140px;
    }
    
    /* Fullscreen button */
    .fullscreen-btn {
        position: fixed;
        top: 30px;
        right: 120px;
        bottom: auto;
        width: 52px;
        height: 52px;
        font-size: 24px;
        background: var(--white-15);
        backdrop-filter: blur(10px);
        opacity: 0.6;
    }
    
    .fullscreen-btn:hover {
        opacity: 1;
        transform: scale(1.1);
        background: var(--white-20);
    }
    
    /* Safe area handling */
    .weather-widget {
        left: max(0px, env(safe-area-inset-left, 0px));
        padding-left: max(24px, calc(env(safe-area-inset-left, 0px) + 24px));
    }
    
    .status-overlay {
        left: max(320px, calc(280px + env(safe-area-inset-left, 0px) + 40px));
        right: max(30px, calc(env(safe-area-inset-right, 0px) + 30px));
        bottom: max(30px, calc(env(safe-area-inset-bottom, 0px) + 20px));
    }
    
    .command-center,
    .fullscreen-btn {
        top: max(30px, calc(env(safe-area-inset-top, 0px) + 20px));
        right: max(30px, calc(env(safe-area-inset-right, 0px) + 30px));
    }
}

/* ─────────────────────────────────────────────────────────────
   DESKTOP (1200px+ width)
   Detection: 1200px+ width (any orientation)
   ───────────────────────────────────────────────────────────── */
@media (min-width: 1200px) {
    body {
        overflow-y: auto;
        height: auto;
    }
    
    .display-container {
        background: var(--color-bg-primary);
        display: grid;
        grid-template-columns: 320px 1fr 300px;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "header header header"
            "sidebar-left main sidebar-right"
            "footer footer footer";
        min-height: 100vh;
        padding: 0;
        overflow: visible;
    }
    
    /* Left sidebar - weather */
    .weather-widget {
        position: static;
        transform: none;
        grid-area: sidebar-left;
        width: 100%;
        height: fit-content;
        max-height: none;
        padding: 30px 24px;
        margin: 20px 0 0 20px;
        border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
        background: linear-gradient(145deg, rgba(0, 0, 0, 0.95) 0%, rgba(30, 30, 60, 0.98) 100%);
        backdrop-filter: blur(25px);
        border-right: 2px solid var(--white-10);
        border-top: 1px solid var(--white-5);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
        display: flex;
        flex-direction: column;
        gap: var(--space-lg);
    }
    
    .weather-widget-header {
        display: flex;
        align-items: center;
        gap: 20px;
        margin-bottom: 0;
        padding-bottom: 20px;
        border-bottom: 1px solid var(--white-10);
    }
    
    .weather-widget-icon { font-size: 64px; flex-shrink: 0; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3)); }
    .weather-widget-temp { font-size: 48px; font-weight: 100; line-height: 1; color: var(--white-95); }
    .weather-widget-temp .unit { font-size: 24px; opacity: 0.7; vertical-align: top; }
    .weather-widget-condition { font-size: 22px; font-weight: 600; margin-bottom: 8px; color: rgba(255, 255, 255, 0.9); text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
    .weather-widget-description { font-size: 16px; opacity: 0.7; display: block; text-transform: capitalize; line-height: 1.4; }
    
    .weather-widget-divider {
        height: 2px;
        background: linear-gradient(90deg, var(--white-30) 0%, var(--white-10) 50%, transparent 100%);
        margin: 20px 0;
        display: block;
        border-radius: 1px;
    }
    
    .weather-widget-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-md);
        font-size: 14px;
    }
    
    .weather-widget-detail {
        text-align: center;
        padding: var(--space-md) 12px;
        background: linear-gradient(135deg, var(--white-10) 0%, var(--white-5) 100%);
        border-radius: var(--radius-lg);
        border: 1px solid var(--white-5);
        transition: all var(--transition-normal);
        cursor: default;
    }
    
    .weather-widget-detail:hover {
        background: linear-gradient(135deg, var(--white-15) 0%, var(--white-5) 100%);
        border-color: var(--white-20);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    }
    
    .weather-widget-detail-value { font-weight: 700; font-size: 20px; display: block; margin-bottom: 6px; color: var(--white-95); }
    .weather-widget-detail-label { opacity: 0.6; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; }
    
    .weather-widget-time {
        margin-top: var(--space-lg);
        padding: var(--space-lg) 20px;
        background: linear-gradient(135deg, rgba(100, 100, 180, 0.15) 0%, rgba(80, 80, 140, 0.05) 100%);
        border-radius: var(--radius-xl);
        border: 1px solid rgba(100, 100, 180, 0.2);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    
    .weather-widget-clock { font-size: 36px; font-weight: 200; font-variant-numeric: tabular-nums; text-align: center; color: var(--white-95); text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
    .weather-widget-period { font-size: 16px; opacity: 0.8; background: var(--white-10); padding: 8px 20px; border-radius: var(--radius-xl); text-align: center; font-weight: 600; letter-spacing: 1px; }
    
    /* Main image area */
    .image-layer {
        grid-area: main;
        padding: 40px;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 600px;
    }
    
    .image-layer img {
        max-width: 100%;
        max-height: calc(100vh - 120px);
        width: auto;
        height: auto;
        border-radius: var(--radius-xl);
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 8px 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 var(--white-10);
        transition: all var(--transition-normal);
    }
    
    .image-layer img:hover {
        transform: scale(1.02);
        box-shadow: 0 35px 80px rgba(0, 0, 0, 0.6), 0 12px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 var(--white-10);
    }
    
    /* Right sidebar - info panel */
    .desktop-info-panel {
        grid-area: sidebar-right;
        padding: 30px 20px;
        margin: 20px 20px 0 0;
        background: linear-gradient(145deg, rgba(20, 20, 40, 0.95) 0%, rgba(40, 40, 70, 0.9) 100%);
        backdrop-filter: blur(20px);
        border-radius: var(--radius-xl) 0 0 var(--radius-xl);
        border-left: 2px solid var(--white-10);
        border-top: 1px solid var(--white-5);
        box-shadow: -4px 0 30px rgba(0, 0, 0, 0.3);
        color: white;
        overflow-y: auto;
        max-height: calc(100vh - 40px);
    }
    
    .desktop-info-title {
        font-size: 20px;
        font-weight: 700;
        margin-bottom: 20px;
        padding-bottom: var(--space-md);
        border-bottom: 1px solid var(--white-10);
        color: var(--white-95);
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .desktop-info-section { margin-bottom: var(--space-lg); }
    
    .desktop-info-section-title {
        font-size: 14px;
        font-weight: 600;
        color: var(--white-80);
        margin-bottom: 12px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    
    .desktop-info-item {
        display: flex;
        justify-content: space-between;
        padding: 10px 0;
        border-bottom: 1px solid var(--white-5);
        font-size: 14px;
    }
    
    .desktop-info-item:last-child { border-bottom: none; }
    .desktop-info-label { opacity: 0.7; font-weight: 500; }
    .desktop-info-value { font-weight: 600; color: var(--white-95); text-align: right; word-break: break-word; max-width: 60%; }
    
    /* Status bar - full width footer */
    .status-overlay {
        position: static;
        grid-area: footer;
        transform: none;
        bottom: auto;
        left: auto;
        right: auto;
        width: 100%;
        padding: var(--space-md) 40px;
        border-radius: 0;
        border-top: 2px solid var(--white-10);
        font-size: 14px;
        gap: 40px;
        min-height: 60px;
        margin: 20px 0 0 0;
        background: linear-gradient(135deg, var(--overlay-darkest) 0%, rgba(20, 20, 40, 0.95) 100%);
        backdrop-filter: blur(15px);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .status-overlay.collapsed {
        width: 100%;
        height: auto;
        min-height: 60px;
        border-radius: 0;
        padding: var(--space-md) 40px;
        justify-content: space-between;
    }
    
    .status-item {
        gap: 12px;
        font-size: 14px;
        padding: 8px 16px;
        background: var(--white-5);
        border-radius: var(--radius-md);
        transition: all var(--transition-normal);
        cursor: default;
        border: 1px solid var(--white-10);
    }
    
    .status-item:hover {
        background: var(--white-10);
        border-color: var(--white-20);
        transform: translateY(-2px);
    }
    
    .status-item .icon { font-size: 18px; }
    .status-item .value { font-size: 16px; font-weight: 700; }
    .status-item .label { font-size: 12px; opacity: 0.8; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
    
    /* Command center - bottom-right */
    .command-center {
        position: fixed;
        bottom: 30px;
        right: 30px;
        top: auto;
    }
    
    .command-center-button {
        width: 72px;
        height: 72px;
        font-size: 32px;
        border-radius: var(--radius-full);
        box-shadow: 0 8px 32px var(--accent-primary);
        transition: all var(--transition-normal);
    }
    
    .command-center-button:hover {
        transform: scale(1.15);
        box-shadow: 0 12px 40px var(--accent-primary-strong);
        background: linear-gradient(135deg, rgba(120, 120, 200, 0.9) 0%, rgba(100, 100, 160, 0.95) 100%);
    }
    
    .command-center-popup {
        bottom: 88px;
        right: 0;
        gap: 12px;
    }
    
    .command-center-icon {
        width: 64px;
        height: 64px;
        font-size: 28px;
        border-radius: var(--radius-full);
        transition: all var(--transition-normal);
        position: relative;
        overflow: hidden;
    }
    
    .command-center-icon:hover {
        transform: scale(1.2);
        box-shadow: 0 8px 25px var(--white-20);
    }
    
    /* Desktop tooltips */
    .command-center-icon::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%) translateY(-8px);
        background: var(--overlay-darkest);
        color: white;
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-normal), transform var(--transition-normal);
        z-index: 100;
    }
    
    .command-center-icon:hover::after {
        opacity: 1;
        transform: translateX(-50%) translateY(-4px);
    }
    
    /* Hide elements */
    .portrait-clock,
    .landscape-clock {
        display: none !important;
    }
    
    /* Title overlay - header area */
    .title-overlay {
        display: block !important;
        position: static;
        grid-area: header;
        transform: none;
        top: auto;
        left: auto;
        margin: 20px 40px 0;
        font-size: 24px;
        font-weight: 700;
        padding: 20px 32px;
        border-radius: var(--radius-lg);
        text-align: center;
        max-width: none;
        background: linear-gradient(135deg, rgba(100, 100, 180, 0.2) 0%, rgba(80, 80, 140, 0.1) 100%);
        border: 1px solid rgba(100, 100, 180, 0.3);
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    /* Image control panel - in sidebar */
    .image-control-panel {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        grid-area: sidebar-right;
        margin-top: var(--space-lg);
        min-width: auto;
        border-radius: var(--radius-lg);
        padding: 20px;
        background: linear-gradient(145deg, rgba(60, 60, 100, 0.2) 0%, rgba(40, 40, 80, 0.1) 100%);
        border: 1px solid var(--white-10);
    }
    
    .image-control-btn {
        padding: 14px 18px;
        border-radius: var(--radius-md);
        font-size: 15px;
        min-height: auto;
        transition: all var(--transition-normal);
    }
    
    .image-control-btn:hover {
        transform: translateX(4px);
        box-shadow: 0 4px 15px var(--white-10);
    }
    
    /* Desktop sub-adjustments */
    @media (max-width: 1400px) {
        .display-container {
            grid-template-columns: 280px 1fr 260px;
        }
        
        .weather-widget {
            padding: 24px 20px;
        }
        
        .weather-widget-temp { font-size: 40px; }
        .weather-widget-icon { font-size: 56px; }
    }
    
    @media (min-width: 1600px) {
        .display-container {
            grid-template-columns: 360px 1fr 320px;
        }
        
        .weather-widget {
            padding: 36px 28px;
        }
    }
}

/* ─────────────────────────────────────────────────────────────
   CRITICAL OVERRIDE: iPhone Safari Command Center Position
   Forces gear button to footer area on all mobile portrait screens
   70px accounts for Safari's bottom toolbar and home indicator
   ───────────────────────────────────────────────────────────── */
@media screen and (max-width: 500px) and (orientation: portrait) {
    #command-center,
    .command-center,
    div.command-center {
        position: fixed !important;
        bottom: 70px !important;
        top: auto !important;
        right: 20px !important;
        left: auto !important;
        transform: none !important;
    }
}
