:root {
    --accent: #4fc3f7;
    --accent-hover: #81d4fa;
    --accent-soft: rgba(79, 195, 247, 0.16);
    --accent-border: rgba(79, 195, 247, 0.32);
    --accent-glow: rgba(79, 195, 247, 0.12);

    --text-primary: #e8f4f8;
    --text-secondary: rgba(232, 244, 248, 0.78);
    --text-muted: rgba(232, 244, 248, 0.52);

    --surface-shell: rgba(10, 18, 26, 0.92);
    --surface-card: rgba(79, 195, 247, 0.06);
    --surface-raised: rgba(79, 195, 247, 0.08);
    --surface-input: rgba(79, 195, 247, 0.04);

    --border-subtle: rgba(79, 195, 247, 0.14);
    --border-strong: rgba(79, 195, 247, 0.24);

    --status-error: #ff8a80;
    --status-error-bg: rgba(255, 138, 128, 0.14);
    --status-error-border: rgba(255, 138, 128, 0.28);

    --status-success: #69f0ae;
    --status-success-bg: rgba(105, 240, 174, 0.14);
    --status-success-border: rgba(105, 240, 174, 0.28);

    --status-warn: #ffd180;
    --status-warn-bg: rgba(255, 209, 128, 0.16);
    --status-warn-border: rgba(255, 209, 128, 0.3);
}

html {
    background: transparent;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", "Microsoft YaHei", Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    user-select: none;
    color: var(--text-primary);
}

body.desktop-mode {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
}

body.compact-mode {
    justify-content: flex-end;
    align-items: flex-end;
}

html.widget-mode-root,
body.widget-mode {
    background: transparent !important;
}

body.widget-mode {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

body.desktop-mode .floating-widget,
body.compact-mode .floating-widget {
    display: none !important;
    pointer-events: none;
    visibility: hidden;
}

body.widget-mode .desktop-shell {
    display: none !important;
    pointer-events: none;
    visibility: hidden;
}

/* ---- Desktop shell ---- */

.desktop-shell {
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    background: var(--surface-shell);
    backdrop-filter: blur(18px) saturate(1.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.1);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

body.desktop-mode .desktop-shell {
    width: 100%;
    height: 100%;
    border-radius: 12px 0 0 12px;
    border-right: none;
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.38);
}

body.compact-mode .desktop-shell {
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
}

body.compact-mode .desktop-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background: var(--surface-shell);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
    pointer-events: none;
}

body.compact-mode .desktop-shell {
    position: relative;
    isolation: isolate;
}

body.compact-mode .desktop-shell > * {
    position: relative;
    z-index: 1;
}

.window-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 12px;
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-subtle);
    -webkit-app-region: drag;
    app-region: drag;
    cursor: move;
    flex-shrink: 0;
}

body.compact-mode .window-title-bar,
body.compact-mode .desktop-col-right {
    display: none;
}

.window-title-text {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent-hover);
    letter-spacing: 0.02em;
}

.title-close-btn {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

.title-close-btn:hover {
    background: var(--status-error-bg);
    border-color: var(--status-error-border);
    color: var(--status-error);
}

.desktop-main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 10px;
    overflow: hidden;
    padding: 0 10px 8px;
    box-sizing: border-box;
}

body.compact-mode .desktop-main {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    padding: 0;
    gap: 0;
}

.desktop-col-left,
.desktop-col-right {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.desktop-col-left .remote-container {
    flex: 1;
    min-height: 0;
}

.desktop-col-left .tab-panels,
.desktop-col-left .tab-content.active,
.desktop-col-left #ac-panel .controls {
    flex: 1;
    min-height: 0;
}

.col-section-label {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 4px 0;
    font-size: 0.82rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.2;
    min-height: 1.2em;
    text-align: center;
}

.col-section-label-spacer {
    visibility: hidden;
    pointer-events: none;
    user-select: none;
}

.col-section-label--aux {
    display: flex;
    align-items: center;
    padding: 6px 4px 0;
    min-height: 1.2em;
}

.col-section-label--aux .aux-tab-row {
    padding: 0;
    margin: 0;
    gap: 14px;
    justify-content: center;
    width: 100%;
}

.aux-tab-header {
    position: relative;
    z-index: 8;
    flex-shrink: 0;
    padding: 8px 12px 4px;
    pointer-events: auto;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

.aux-tab-header .aux-tab-row {
    padding: 0;
    margin: 0;
    gap: 16px;
    justify-content: center;
    width: 100%;
    pointer-events: auto;
}

.aux-tab-header .tab-btn,
.col-section-label--aux .tab-btn {
    background: transparent;
    border: none;
    padding: 4px 10px;
    min-height: 28px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.02em;
    line-height: 1.2;
    cursor: pointer;
    pointer-events: auto;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

.aux-tab-header .tab-btn:hover,
.col-section-label--aux .tab-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.72);
}

.aux-tab-header .tab-btn.active,
.col-section-label--aux .tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: rgba(255, 255, 255, 0.92);
    box-shadow: none;
}

body.compact-mode .col-section-label,
body.compact-mode .col-section-label--aux,
body.compact-mode .aux-tab-header {
    display: none;
}

.right-section {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
}

.right-section.hidden {
    display: none !important;
}

.lights-section .sidebar-devices,
.fresh-air-section .sidebar-devices,
.covers-section .sidebar-devices {
    flex: 1 1 0;
    min-height: 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 6px;
    flex-shrink: 0;
    text-align: left;
}

.section-header--fresh-air {
    justify-content: space-between;
}

.section-header-metrics {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.section-metric {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: calc(0.58rem * var(--sidebar-density, 1));
    font-weight: 600;
    color: var(--accent-hover);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.2;
    white-space: nowrap;
}

.section-header::before {
    content: "";
    width: 3px;
    height: 12px;
    border-radius: 999px;
    background: var(--accent);
    flex-shrink: 0;
}

.section-header-text {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--accent-hover);
    letter-spacing: 0.04em;
}

.sidebar-devices {
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 10px 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    gap: 6px;
    align-content: stretch;
    align-items: stretch;
    --sidebar-density: 1;
    --sidebar-name-lines: 2;
    --toggle-w: calc(52.8px * var(--sidebar-density, 1));
    --toggle-h: calc(28.8px * var(--sidebar-density, 1));
    --toggle-knob: calc(24px * var(--sidebar-density, 1));
}

.sidebar-devices[data-layout-tier="single"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}

.sidebar-devices[data-layout-tier="dual"] {
    grid-template-rows: minmax(0, 1fr);
}

.sidebar-device-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: calc(4px * var(--sidebar-density, 1));
    padding: calc(10px * var(--sidebar-density, 1)) calc(6px * var(--sidebar-density, 1)) calc(8px * var(--sidebar-density, 1));
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.sidebar-shared-icon {
    --sidebar-shared-size: calc(18px * var(--sidebar-density, 1));
    position: absolute;
    top: calc(4px * var(--sidebar-density, 1));
    right: calc(4px * var(--sidebar-density, 1));
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--sidebar-shared-size);
    height: var(--sidebar-shared-size);
    min-width: var(--sidebar-shared-size);
    min-height: var(--sidebar-shared-size);
    padding: calc(2px * var(--sidebar-density, 1));
    border-radius: calc(5px * var(--sidebar-density, 1));
    box-sizing: border-box;
    color: #a5b4fc;
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.34) 0%, rgba(79, 70, 229, 0.24) 100%);
    border: 1px solid rgba(129, 140, 248, 0.38);
    box-shadow:
        2px 2px 5px rgba(15, 23, 42, 0.28),
        -1px -1px 4px rgba(255, 255, 255, 0.06),
        inset 1px 1px 1px rgba(255, 255, 255, 0.12);
    pointer-events: auto;
    cursor: help;
}

.sidebar-shared-icon > svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(99, 102, 241, 0.45));
}

.sidebar-device-card.has-shared-device,
.sidebar-device-card.is-readonly-shared {
    overflow: visible;
}

.ac-remote-card {
    position: relative;
    overflow: visible;
}

.ac-shared-icon {
    --sidebar-density: 1;
    --sidebar-shared-size: 20px;
}

.header .ac-shared-icon,
.ac-remote-card > .ac-shared-icon {
    position: absolute;
    top: 8px;
    right: 10px;
    left: auto;
    bottom: auto;
    z-index: 6;
    pointer-events: auto;
    cursor: help;
}

.ac-shared-icon:not(.hidden) {
    display: inline-flex;
}

body.desktop-mode .header .ac-shared-icon {
    top: 6px;
    right: 8px;
}

.sidebar-devices:has(.sidebar-device-card:only-child) {
    grid-template-columns: minmax(0, 1fr);
}

.sidebar-devices:has(.sidebar-device-card:only-child) .sidebar-device-card {
    max-width: 100%;
}

.sidebar-device-card.is-on {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.04);
}

.sidebar-device-name {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    text-align: center;
    font-size: calc(0.68rem * var(--sidebar-density, 1));
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.2;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--sidebar-name-lines, 2);
    overflow: hidden;
    word-break: break-all;
}

.sidebar-device-card.has-drawer .sidebar-card-visual .sidebar-vector {
    min-height: calc(22px * var(--sidebar-density, 1));
    max-height: calc(40px * var(--sidebar-density, 1));
    height: calc(34px * var(--sidebar-density, 1));
    flex-shrink: 0;
}

.sidebar-vector {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: calc(24px * var(--sidebar-density, 1));
    max-height: calc(46px * var(--sidebar-density, 1));
    height: calc(40px * var(--sidebar-density, 1));
}

.sidebar-vector-svg {
    width: min(100%, calc(46px * var(--sidebar-density, 1)));
    height: min(100%, calc(46px * var(--sidebar-density, 1)));
    max-width: calc(46px * var(--sidebar-density, 1));
    max-height: calc(46px * var(--sidebar-density, 1));
    display: block;
    filter: drop-shadow(0 0 8px var(--light-glow, transparent));
    transition: filter 0.35s ease, transform 0.35s ease;
}

.sidebar-device-card.is-on .sidebar-vector-svg {
    transform: scale(1.02);
}

.sidebar-device-card .light-toggle {
    flex: 0 0 auto;
    --toggle-travel: calc(var(--toggle-w) - var(--toggle-knob) - 4px);
    width: var(--toggle-w);
    height: var(--toggle-h);
    border-radius: calc(var(--toggle-h) / 2);
}

.sidebar-device-card .light-toggle::before {
    width: var(--toggle-knob);
    height: var(--toggle-knob);
}

.sidebar-device-card .light-toggle.on::before {
    transform: translateX(var(--toggle-travel));
}

.sidebar-light-controls {
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: calc(5px * var(--sidebar-density, 1));
    padding: 0 2px calc(2px * var(--sidebar-density, 1));
}

.sidebar-light-row {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.sidebar-light-row-label {
    flex-shrink: 0;
    font-size: calc(0.52rem * var(--sidebar-density, 1));
    color: rgba(255, 255, 255, 0.45);
    line-height: 1;
}

.sidebar-light-range {
    flex: 1;
    min-width: 0;
    height: 4px;
    margin: 0;
    accent-color: var(--light-accent, #ffd54f);
    cursor: pointer;
}

.sidebar-light-range--ct {
    accent-color: #81d4fa;
}

.sidebar-light-row--colors {
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
}

.sidebar-color-swatch {
    width: calc(15px * var(--sidebar-density, 1));
    height: calc(15px * var(--sidebar-density, 1));
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: var(--swatch, #fff);
    padding: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-color-swatch:hover {
    transform: scale(1.08);
}

.sidebar-color-swatch.is-active {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.72);
    transform: scale(1.12);
}

.sidebar-fan-controls {
    width: 100%;
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--sidebar-density, 1));
    padding: 0 2px calc(2px * var(--sidebar-density, 1));
    overflow: hidden;
}

.sidebar-fan-controls .fresh-air-speed-row {
    margin: 0;
    padding: 0;
    width: 100%;
}

.sidebar-fan-controls .control-label {
    display: none;
}

.sidebar-fan-controls .fresh-air-speed-slider-wrap {
    gap: 4px;
}

.sidebar-fan-controls .fresh-air-speed-value {
    min-width: 30px;
    font-size: 0.58rem;
}

.sidebar-fan-controls .fresh-air-speed-range {
    height: 4px;
    accent-color: #4fc3f7;
}

.sidebar-fan-controls .fresh-air-percent-select,
.sidebar-fan-controls .fresh-air-speed-select {
    width: 100%;
    font-size: calc(0.62rem * var(--sidebar-density, 1));
    padding: calc(2px * var(--sidebar-density, 1)) calc(4px * var(--sidebar-density, 1));
    min-height: calc(22px * var(--sidebar-density, 1));
}

.sidebar-fan-controls .fresh-air-speed-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.sidebar-fan-controls .fresh-air-speed-btn {
    min-width: 0;
    padding: calc(3px * var(--sidebar-density, 1)) calc(6px * var(--sidebar-density, 1));
    font-size: calc(0.58rem * var(--sidebar-density, 1));
    line-height: 1.2;
}

.lights-section .sidebar-device-card.has-drawer.is-drawer-open,
.fresh-air-section .sidebar-device-card.has-drawer.is-drawer-open,
.covers-section .sidebar-device-card.has-drawer.is-drawer-open {
    min-height: 0;
    justify-content: center;
    overflow: hidden;
}

.sidebar-card-name {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    text-align: center;
    font-size: var(--sidebar-device-name-size, calc(0.68rem * var(--sidebar-density, 1)));
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.2;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--sidebar-name-lines, 2);
    overflow: hidden;
    word-break: break-word;
}

.sidebar-card-visual {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    padding: 0;
}

.sidebar-card-visual .sidebar-vector {
    flex: 0 0 auto;
    width: var(--sidebar-card-icon);
    height: var(--sidebar-card-icon);
    min-width: var(--sidebar-card-icon);
    min-height: var(--sidebar-card-icon);
    max-width: var(--sidebar-card-icon);
    max-height: var(--sidebar-card-icon);
}

.sidebar-card-visual .sidebar-vector-svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

.sidebar-card-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 0 0 auto;
    gap: calc(10px * var(--sidebar-density, 1));
    padding: 0;
    box-sizing: border-box;
}

.sidebar-card-menu-btn {
    flex: 0 0 calc(32px * var(--sidebar-density, 1));
    width: calc(32px * var(--sidebar-density, 1));
    height: calc(32px * var(--sidebar-density, 1));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.55);
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-card-menu-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.82);
}

.sidebar-card-menu-icon {
    display: block;
    width: calc(16px * var(--sidebar-density, 1));
    height: calc(2px * var(--sidebar-density, 1));
    background: currentColor;
    border-radius: 999px;
    box-shadow:
        0 calc(5px * var(--sidebar-density, 1)) 0 currentColor,
        0 calc(10px * var(--sidebar-density, 1)) 0 currentColor;
}

.sidebar-card-drawer {
    width: 100%;
    flex: 0 0 auto;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
    padding: 0;
    box-sizing: border-box;
}

.sidebar-device-card.is-drawer-open .sidebar-card-drawer {
    max-height: calc(160px * var(--sidebar-density, 1));
    opacity: 1;
    overflow: visible;
    padding-top: calc(4px * var(--sidebar-density, 1));
}

.sidebar-card-drawer .sidebar-light-controls,
.sidebar-card-drawer .sidebar-fan-controls {
    width: 100%;
    align-items: center;
}

.sidebar-card-drawer .sidebar-light-row {
    justify-content: center;
}

.sidebar-card-drawer .sidebar-fan-controls .fresh-air-speed-buttons {
    justify-content: center;
    flex-wrap: wrap;
}

.sidebar-device-card .light-toggle.has-shared-knob {
    overflow: visible;
}

.sidebar-device-card .light-toggle.has-shared-knob::before {
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.34) 0%, rgba(79, 70, 229, 0.24) 100%);
    border: 1px solid rgba(129, 140, 248, 0.38);
}

.sidebar-device-card .light-toggle.has-shared-knob.on::before {
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.42) 0%, rgba(79, 70, 229, 0.32) 100%);
}

.light-toggle-share-icon {
    position: absolute;
    top: 2px;
    left: 2px;
    width: var(--toggle-knob, 20px);
    height: var(--toggle-knob, 20px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #c7d2fe;
    pointer-events: none;
    transition: transform 0.3s ease;
    z-index: 1;
}

.sidebar-device-card .light-toggle.on .light-toggle-share-icon {
    transform: translateX(var(--toggle-travel));
}

.light-toggle-share-icon svg {
    width: 58%;
    height: 58%;
    display: block;
    filter: drop-shadow(0 1px 1px rgba(99, 102, 241, 0.35));
}

.lights-section .sidebar-device-card.has-drawer,
.fresh-air-section .sidebar-device-card.has-drawer,
.covers-section .sidebar-device-card.has-drawer {
    --sidebar-card-icon: calc(54px * var(--sidebar-density, 1));
}

.sidebar-vector-svg .vector-glow,
.sidebar-vector-svg .vector-halo {
    transform-origin: 32px 30px;
}

.sidebar-vector-svg.is-on .vector-glow,
.sidebar-vector-svg.is-on .vector-halo {
    animation: vector-pulse 2.4s ease-in-out infinite;
}

.sidebar-vector-svg .vector-rays {
    transform-origin: 32px 30px;
}

.sidebar-vector-svg.is-on .vector-rays {
    animation: vector-rays-spin 8s linear infinite;
}

.sidebar-vector-svg.is-on .vector-strip-fill {
    animation: vector-strip-glow 2s ease-in-out infinite;
}

.sidebar-vector-svg.is-on .vector-strip-flow circle {
    animation: vector-strip-flow 1.4s ease-in-out infinite;
}

.sidebar-vector-svg.is-on .vector-strip-flow circle:nth-child(2) {
    animation-delay: 0.15s;
}

.sidebar-vector-svg.is-on .vector-strip-flow circle:nth-child(3) {
    animation-delay: 0.3s;
}

.sidebar-vector-svg.is-on .vector-strip-flow circle:nth-child(4) {
    animation-delay: 0.45s;
}

.sidebar-vector-svg.is-on .vector-strip-flow circle:nth-child(5) {
    animation-delay: 0.6s;
}

.sidebar-vector-svg.is-on .vector-strip-beam {
    animation: vector-strip-beam 2.2s ease-in-out infinite;
}

.sidebar-vector-svg.is-on .vector-strip-beam-2 {
    animation: vector-strip-beam 2.2s ease-in-out infinite reverse;
    animation-delay: 0.4s;
}

.sidebar-vector-svg.is-on .vector-fan-blades {
    transform-origin: 32px 32px;
    animation: vector-fan-spin 1.8s linear infinite;
}

.sidebar-vector-svg.is-on .vector-fan-reverse {
    animation: vector-fan-spin-reverse 1.8s linear infinite;
}

.sidebar-vector-svg.is-on .vector-air-in,
.sidebar-vector-svg.is-on .vector-air-out {
    animation: vector-air-flow 1.2s ease-in-out infinite;
}

@keyframes vector-pulse {
    0%, 100% { opacity: 0.72; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

@keyframes vector-rays-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes vector-strip-glow {
    0%, 100% { opacity: 0.82; }
    50% { opacity: 1; }
}

@keyframes vector-strip-flow {
    0%, 100% { opacity: 0.35; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(4px); }
}

@keyframes vector-strip-beam {
    0%, 100% { opacity: 0.35; stroke-dashoffset: 0; }
    50% { opacity: 0.85; stroke-dashoffset: 6; }
}

@keyframes vector-fan-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes vector-fan-spin-reverse {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@keyframes vector-air-flow {
    0%, 100% { opacity: 0.45; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(3px); }
}

.sidebar-reason {
    margin: 6px 8px 0;
    width: auto;
}

.sidebar-devices .light-item,
.sidebar-devices .fresh-air-item {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-devices .light-name {
    color: rgba(255, 255, 255, 0.82);
}

.sidebar-devices .device-icon-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-devices .light-item {
    gap: 10px;
}

.sidebar-devices .fresh-air-speed-row {
    margin-top: 6px;
    padding: 0 4px 4px;
}

.sidebar-devices .fresh-air-speed-row .control-label {
    color: rgba(255, 255, 255, 0.55);
}

.sidebar-devices .fresh-air-item-block + .fresh-air-item-block {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.sidebar-devices .light-empty,
.sidebar-devices .light-error {
    grid-column: 1 / -1;
    padding: 16px 8px;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    font-size: 0.72rem;
}

/* ---- AC remote card (dark panel) ---- */

.remote-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    padding-bottom: 10px;
    box-sizing: border-box;
    overflow: hidden;
    isolation: isolate;
    background: transparent;
}

.remote-container.ac-remote-card {
    overflow: visible;
}

.ac-remote-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background: rgba(24, 28, 36, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    pointer-events: none;
    transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.ac-remote-card.mode-cool::before,
.ac-remote-card.ac-powered-on.mode-cool::before {
    background: linear-gradient(165deg, rgba(14, 165, 233, 0.28) 0%, rgba(24, 28, 36, 0.94) 58%);
    border-color: rgba(79, 195, 247, 0.38);
    box-shadow: inset 0 1px 0 rgba(129, 212, 250, 0.12);
}

.ac-remote-card.mode-heat::before,
.ac-remote-card.ac-powered-on.mode-heat::before {
    background: linear-gradient(165deg, rgba(249, 115, 22, 0.32) 0%, rgba(24, 28, 36, 0.94) 58%);
    border-color: rgba(255, 107, 107, 0.38);
    box-shadow: inset 0 1px 0 rgba(255, 171, 145, 0.12);
}

.ac-remote-card.mode-fan_only::before,
.ac-remote-card.ac-powered-on.mode-fan_only::before {
    background: linear-gradient(165deg, rgba(16, 185, 129, 0.26) 0%, rgba(24, 28, 36, 0.94) 58%);
    border-color: rgba(102, 187, 106, 0.38);
    box-shadow: inset 0 1px 0 rgba(129, 199, 132, 0.12);
}

.ac-remote-card.mode-dry::before,
.ac-remote-card.ac-powered-on.mode-dry::before,
.ac-remote-card.mode-auto::before,
.ac-remote-card.ac-powered-on.mode-auto::before {
    background: linear-gradient(165deg, rgba(171, 71, 188, 0.24) 0%, rgba(24, 28, 36, 0.94) 58%);
    border-color: rgba(206, 147, 216, 0.36);
    box-shadow: inset 0 1px 0 rgba(206, 147, 216, 0.1);
}

.ac-remote-card.mode-off::before,
.ac-remote-card.ac-powered-off::before {
    background: rgba(24, 28, 36, 0.92);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.aux-remote-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background: rgba(24, 28, 36, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.aux-tab-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.aux-tab-panels {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aux-tab-panel {
    display: none;
    flex: 1 1 0;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.aux-tab-panel.active {
    display: flex;
}

.aux-tab-panel.hidden {
    display: none !important;
}

.aux-remote-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

/* Right sidebar: uniform inset spacing (card-to-card = card-to-border) */
.lights-section.right-section,
.covers-section.right-section,
.fresh-air-section.right-section {
    --sidebar-grid-inset: 12px;
    box-sizing: border-box;
}

.lights-section .sidebar-devices,
.covers-section .sidebar-devices,
.fresh-air-section .sidebar-devices {
    --sidebar-card-icon: calc(58px * var(--sidebar-density, 1));
    --sidebar-device-name-size: 0.8rem;
    --toggle-w: calc(58px * var(--sidebar-density, 1));
    --toggle-h: calc(32px * var(--sidebar-density, 1));
    --toggle-knob: calc(26px * var(--sidebar-density, 1));
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    width: 100%;
    padding: 0;
    gap: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.lights-section .sidebar-devices-grid,
.covers-section .sidebar-devices-grid,
.fresh-air-section .sidebar-devices-grid {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(var(--sidebar-card-rows, 1), minmax(0, 1fr));
    gap: var(--sidebar-grid-inset);
    padding: var(--sidebar-grid-inset);
    box-sizing: border-box;
    overflow: hidden;
    align-content: stretch;
}

.lights-section .sidebar-devices-grid .sidebar-device-card,
.covers-section .sidebar-devices-grid .sidebar-device-card,
.fresh-air-section .sidebar-devices-grid .sidebar-device-card {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    align-self: stretch;
    justify-self: stretch;
}

.lights-section .sidebar-devices-grid .sidebar-device-card:last-child:nth-child(odd):not(:only-child),
.covers-section .sidebar-devices-grid .sidebar-device-card:last-child:nth-child(odd):not(:only-child),
.fresh-air-section .sidebar-devices-grid .sidebar-device-card:last-child:nth-child(odd):not(:only-child) {
    grid-column: auto;
    width: 100%;
    max-width: 100%;
    justify-self: stretch;
}

.lights-section .sidebar-devices[data-layout-tier="single"] .sidebar-devices-grid .sidebar-device-card:only-child,
.fresh-air-section .sidebar-devices[data-layout-tier="single"] .sidebar-devices-grid .sidebar-device-card:only-child,
.covers-section .sidebar-devices[data-layout-tier="single"] .sidebar-devices-grid .sidebar-device-card:only-child {
    grid-row: 1;
    align-self: stretch;
    height: 100%;
    max-height: 100%;
}

.lights-section .sidebar-device-card,
.fresh-air-section .sidebar-device-card,
.covers-section .sidebar-device-card {
    --sidebar-card-icon: calc(58px * var(--sidebar-density, 1));
    --sidebar-card-inner-gap: calc(8px * var(--sidebar-density, 1));
    --sidebar-name-font: var(--sidebar-device-name-size, 0.8rem);
    --sidebar-name-line-height: 1.2;
    --sidebar-name-max-lines: 2;
    align-items: center;
    justify-content: center;
    gap: var(--sidebar-card-inner-gap);
    padding: calc(4px * var(--sidebar-density, 1)) calc(4px * var(--sidebar-density, 1)) calc(4px * var(--sidebar-density, 1));
    width: 100%;
    max-width: 100%;
    min-height: 0;
    box-sizing: border-box;
    justify-self: stretch;
    align-self: stretch;
    container-type: inline-size;
}

.lights-section .sidebar-card-name,
.lights-section .sidebar-device-name,
.fresh-air-section .sidebar-card-name,
.fresh-air-section .sidebar-device-name,
.covers-section .sidebar-card-name,
.covers-section .sidebar-device-name {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: calc(var(--sidebar-name-font) * var(--sidebar-name-line-height) * var(--sidebar-name-max-lines));
    font-size: var(--sidebar-name-font);
    font-weight: 400;
    line-height: var(--sidebar-name-line-height);
    text-align: center;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--sidebar-name-max-lines);
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
}

.fresh-air-section .sidebar-device-card {
    gap: var(--sidebar-card-inner-gap, calc(8px * var(--sidebar-density, 1)));
    padding: calc(6px * var(--sidebar-density, 1)) calc(6px * var(--sidebar-density, 1)) calc(6px * var(--sidebar-density, 1));
}

.lights-section .sidebar-card-visual,
.fresh-air-section .sidebar-card-visual,
.covers-section .sidebar-card-visual {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--sidebar-card-icon);
    min-height: var(--sidebar-card-icon);
    max-height: var(--sidebar-card-icon);
}

.lights-section .sidebar-card-actions,
.covers-section .sidebar-card-actions {
    gap: calc(10px * var(--sidebar-density, 1));
}

.lights-section .sidebar-card-actions,
.fresh-air-section .sidebar-card-actions,
.covers-section .sidebar-card-actions {
    flex: 0 0 auto;
}

.fresh-air-section .sidebar-card-actions {
    gap: calc(15px * var(--sidebar-density, 1));
}

.lights-section .sidebar-card-menu-btn,
.fresh-air-section .sidebar-card-menu-btn,
.covers-section .sidebar-card-menu-btn {
    flex: 0 0 calc(32px * var(--sidebar-density, 1));
    width: calc(32px * var(--sidebar-density, 1));
    height: calc(32px * var(--sidebar-density, 1));
}

.lights-section .sidebar-card-menu-icon,
.fresh-air-section .sidebar-card-menu-icon,
.covers-section .sidebar-card-menu-icon {
    width: calc(16px * var(--sidebar-density, 1));
    height: calc(2px * var(--sidebar-density, 1));
    box-shadow:
        0 calc(5px * var(--sidebar-density, 1)) 0 currentColor,
        0 calc(10px * var(--sidebar-density, 1)) 0 currentColor;
}

/* 右侧灯光/新风/窗帘：三条杠详情侧向浮层，无背景虚化 */
.sidebar-flyout-backdrop {
    display: none !important;
}

.sidebar-flyout-backdrop.hidden {
    display: none !important;
}

.lights-section .sidebar-device-card .sidebar-card-drawer,
.fresh-air-section .sidebar-device-card .sidebar-card-drawer,
.covers-section .sidebar-device-card .sidebar-card-drawer {
    position: fixed;
    z-index: 1200;
    left: 0;
    top: 0;
    width: var(--sidebar-flyout-width, 200px);
    max-width: calc(100vw - 24px);
    max-height: 0;
    flex: none;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    padding: 0;
    margin: 0;
    border-radius: 10px;
    background: rgba(18, 24, 38, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: opacity 0.18s ease, visibility 0.18s ease;
    box-sizing: border-box;
}

.lights-section .sidebar-device-card.is-drawer-open .sidebar-card-drawer,
.fresh-air-section .sidebar-device-card.is-drawer-open .sidebar-card-drawer,
.covers-section .sidebar-device-card.is-drawer-open .sidebar-card-drawer {
    max-height: min(320px, calc(100vh - 24px));
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px 12px 12px;
}

.lights-section .sidebar-device-card.has-drawer.is-drawer-open,
.fresh-air-section .sidebar-device-card.has-drawer.is-drawer-open,
.covers-section .sidebar-device-card.has-drawer.is-drawer-open {
    justify-content: center;
    overflow: hidden;
}

.lights-section .sidebar-devices:has(.is-drawer-open),
.fresh-air-section .sidebar-devices:has(.is-drawer-open),
.covers-section .sidebar-devices:has(.is-drawer-open) {
    grid-auto-rows: minmax(0, 1fr);
    align-content: stretch;
    overflow: hidden;
}

.lights-section .sidebar-card-drawer .sidebar-light-controls,
.fresh-air-section .sidebar-card-drawer .sidebar-light-controls,
.covers-section .sidebar-card-drawer .sidebar-light-controls,
.lights-section .sidebar-card-drawer .sidebar-fan-controls,
.fresh-air-section .sidebar-card-drawer .sidebar-fan-controls,
.covers-section .sidebar-card-drawer .sidebar-fan-controls {
    padding: 0;
}

.lights-section .sidebar-device-card.is-drawer-open .sidebar-card-menu-btn,
.fresh-air-section .sidebar-device-card.is-drawer-open .sidebar-card-menu-btn,
.covers-section .sidebar-device-card.is-drawer-open .sidebar-card-menu-btn {
    background: rgba(99, 102, 241, 0.18);
    color: rgba(255, 255, 255, 0.92);
}

.lights-section .sidebar-devices-grid .sidebar-device-card.has-drawer.is-drawer-open,
.fresh-air-section .sidebar-devices-grid .sidebar-device-card.has-drawer.is-drawer-open,
.covers-section .sidebar-devices-grid .sidebar-device-card.has-drawer.is-drawer-open,
.lights-section .sidebar-devices-grid .sidebar-device-card.is-drawer-open,
.fresh-air-section .sidebar-devices-grid .sidebar-device-card.is-drawer-open,
.covers-section .sidebar-devices-grid .sidebar-device-card.is-drawer-open {
    height: 100%;
    max-height: 100%;
}

.desktop-col-left .remote-container,
.desktop-col-right .remote-container {
    flex: 1;
    min-height: 0;
    width: 100%;
}

body.compact-mode .ac-remote-card::before {
    background: transparent;
    border: none;
    box-shadow: none;
}

body.compact-mode .remote-container {
    border-radius: 0;
    padding-bottom: 16px;
    overflow: visible;
}

body.compact-mode .ac-remote-card::before {
    background: var(--surface-shell);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
    box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.45);
}

.remote-container > * {
    position: relative;
    z-index: 1;
}

.remote-container > .ac-shared-icon {
    position: absolute;
    z-index: 6;
}

.header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 40px 8px 72px;
    min-height: 42px;
    overflow: visible;
    -webkit-app-region: drag;
    app-region: drag;
    cursor: move;
}

body.desktop-mode .header {
    padding: 6px 36px 4px 68px;
    min-height: 34px;
    -webkit-app-region: no-drag;
    app-region: no-drag;
    cursor: default;
}

body.desktop-mode .controls {
    padding: 2px 12px;
    gap: 4px;
    overflow: hidden;
}

body.desktop-mode .temp-display {
    font-size: 1.85rem;
}

body.desktop-mode .small {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    font-size: 1rem;
}

body.desktop-mode .power {
    width: 54px;
    height: 54px;
    min-width: 54px;
    min-height: 54px;
    font-size: 0.78rem;
}

body.desktop-mode .reason-box {
    padding: 5px 8px;
    font-size: 0.68rem;
    margin-top: 2px;
}

body.desktop-mode .remote-container {
    padding-bottom: 4px;
}

body.desktop-mode .desktop-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 0 10px;
    padding: 0 10px 8px;
}

/* 桌面双列：右栏 2 行灯光/新风卡；左栏空调卡片与之等高底对齐 */
body.desktop-mode {
    --sc-light-card-h: 116px;
    --sc-light-grid-gap: 10px;
    --sc-light-grid-inset: 10px;
    --sc-aux-tab-header-h: 46px;
    --sc-light-grid-body-h: calc(var(--sc-light-card-h) * 2 + var(--sc-light-grid-gap) + var(--sc-light-grid-inset) * 2);
    --sc-remote-block-h: var(--sc-light-grid-body-h);
}

body.desktop-mode .desktop-main {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    align-items: stretch;
    overflow: visible;
}

body.desktop-mode .desktop-col-left,
body.desktop-mode .desktop-col-right {
    height: auto;
    min-height: 0;
    overflow: visible;
}

body.desktop-mode .desktop-col-left > .remote-container.ac-remote-card,
body.desktop-mode .desktop-col-right > .remote-container.aux-remote-card {
    flex: 0 0 auto !important;
    height: var(--sc-remote-block-h) !important;
    min-height: var(--sc-remote-block-h) !important;
    max-height: var(--sc-remote-block-h) !important;
}

body.desktop-mode .aux-remote-card,
body.desktop-mode .aux-tab-panels,
body.desktop-mode .aux-tab-panel.active,
body.desktop-mode .lights-section.active,
body.desktop-mode .fresh-air-section.active,
body.desktop-mode .covers-section.active {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
}

body.desktop-mode #lights-sidebar.sidebar-devices,
body.desktop-mode #fresh-air-sidebar.sidebar-devices,
body.desktop-mode #covers-sidebar.sidebar-devices {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
}

body.desktop-mode #lights-sidebar .sidebar-devices-grid,
body.desktop-mode #fresh-air-sidebar .sidebar-devices-grid,
body.desktop-mode #covers-sidebar .sidebar-devices-grid {
    flex: none !important;
    height: auto !important;
    grid-template-rows: repeat(var(--sidebar-card-rows, 2), var(--sc-light-card-h)) !important;
    grid-auto-rows: var(--sc-light-card-h) !important;
    gap: var(--sc-light-grid-gap) !important;
    padding: var(--sc-light-grid-inset) !important;
    align-content: start;
    overflow: visible;
}

body.desktop-mode #lights-sidebar .sidebar-devices-grid .sidebar-device-card,
body.desktop-mode #fresh-air-sidebar .sidebar-devices-grid .sidebar-device-card,
body.desktop-mode #covers-sidebar .sidebar-devices-grid .sidebar-device-card {
    height: var(--sc-light-card-h) !important;
    min-height: var(--sc-light-card-h) !important;
    max-height: var(--sc-light-card-h) !important;
    align-self: stretch;
    justify-self: stretch;
}

body.desktop-mode .desktop-shell {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
}

body.desktop-mode .desktop-col-left,
body.desktop-mode .desktop-col-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: visible;
    gap: 4px;
}

body.desktop-mode .desktop-col-left > .remote-container,
body.desktop-mode .desktop-col-right > .remote-container {
    flex: 0 0 auto !important;
    min-height: 0;
    width: 100%;
    margin: 0;
}

body.desktop-mode .desktop-col-left .tab-panels,
body.desktop-mode .desktop-col-left .tab-content.active,
body.desktop-mode #ac-panel .controls {
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
}

body.desktop-mode .ac-remote-card {
    overflow: hidden;
}

body.desktop-mode .aux-remote-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.desktop-mode .aux-tab-panels {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

body.desktop-mode .aux-tab-panel.active {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.desktop-mode .col-section-label--aux,
body.desktop-mode .aux-tab-header {
    position: relative;
    z-index: 20;
    flex-shrink: 0;
    pointer-events: auto;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

body.desktop-mode .col-section-label {
    min-height: var(--sc-aux-tab-header-h);
    padding: 6px 12px 4px;
}

body.desktop-mode .col-section-label--aux .aux-tab-row,
body.desktop-mode .aux-tab-header .aux-tab-row {
    gap: 16px;
    justify-content: center;
    width: 100%;
    pointer-events: auto;
}

body.desktop-mode .col-section-label--aux .tab-btn,
body.desktop-mode .aux-tab-header .tab-btn {
    position: relative;
    z-index: 21;
    pointer-events: auto;
    -webkit-app-region: no-drag;
    app-region: no-drag;
    cursor: pointer;
}

body.desktop-mode .aux-tab-panel.right-section.active {
    justify-content: flex-start;
    align-items: stretch;
}

body.desktop-mode .fresh-air-section.aux-tab-panel.active {
    justify-content: flex-start;
}

body.desktop-mode .aux-tab-panel.hidden {
    display: none !important;
}

body.desktop-mode .right-section .section-header {
    padding: 4px 8px 2px;
}

body.desktop-mode .right-section .section-header--fresh-air {
    padding: var(--sidebar-grid-inset, 12px) var(--sidebar-grid-inset, 12px) 0;
}

body.desktop-mode .right-section .section-header-text {
    font-size: 0.68rem;
}

body.desktop-mode #ac-panel .controls {
    justify-content: flex-start;
    gap: 8px;
    padding: 4px 12px 8px;
    overflow: visible;
    flex: 1 1 auto;
    min-height: 0;
}

body.desktop-mode #ac-panel .device-info,
body.desktop-mode #ac-panel .temp-row,
body.desktop-mode #ac-panel .controls-row,
body.desktop-mode #ac-panel .row:has(.power),
body.desktop-mode #ac-panel .reason-box {
    flex-shrink: 0;
}

body.desktop-mode #ac-panel .row:has(.power) {
    margin-top: auto;
}

body.desktop-mode #ac-panel .reason-box:not(.hidden) {
    margin-top: 0;
}

body.desktop-mode #lights-sidebar.sidebar-devices,
body.desktop-mode #covers-sidebar.sidebar-devices,
body.desktop-mode #fresh-air-sidebar.sidebar-devices {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0;
    padding: 0;
    gap: 0;
    overflow: visible;
}

body.desktop-mode #lights-sidebar .sidebar-devices-grid,
body.desktop-mode #covers-sidebar .sidebar-devices-grid,
body.desktop-mode #fresh-air-sidebar .sidebar-devices-grid {
    flex: none !important;
    min-height: 0;
    width: 100%;
    height: auto !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(var(--sidebar-card-rows, 2), var(--sc-light-card-h)) !important;
    grid-auto-rows: var(--sc-light-card-h) !important;
    gap: var(--sc-light-grid-gap) !important;
    padding: var(--sc-light-grid-inset) !important;
    box-sizing: border-box;
    align-content: start;
    overflow: visible;
}

body.desktop-mode #fresh-air-sidebar .sidebar-devices-grid {
    flex: 1 1 auto !important;
    height: 100% !important;
    grid-template-rows: repeat(2, var(--sc-light-card-h)) !important;
}

body.desktop-mode #fresh-air-sidebar .sidebar-devices-grid .sidebar-device-card {
    grid-row: 2 !important;
}

body.desktop-mode #lights-sidebar .sidebar-devices-grid .sidebar-device-card,
body.desktop-mode #covers-sidebar .sidebar-devices-grid .sidebar-device-card,
body.desktop-mode #fresh-air-sidebar .sidebar-devices-grid .sidebar-device-card {
    width: 100% !important;
    max-width: 100% !important;
    height: var(--sc-light-card-h) !important;
    min-height: var(--sc-light-card-h) !important;
    max-height: var(--sc-light-card-h) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: center !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    overflow: hidden;
    box-sizing: border-box;
}

body.desktop-mode .lights-section .sidebar-card-name,
body.desktop-mode .lights-section .sidebar-device-name,
body.desktop-mode .fresh-air-section .sidebar-card-name,
body.desktop-mode .fresh-air-section .sidebar-device-name,
body.desktop-mode .covers-section .sidebar-card-name,
body.desktop-mode .covers-section .sidebar-device-name {
    flex: 0 0 auto;
    width: 100%;
    min-height: calc(0.72rem * 1.2 * 2);
    max-height: calc(0.72rem * 1.2 * 2);
    font-size: 0.72rem;
    line-height: 1.2;
    font-weight: 400;
    text-align: center;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
}

body.desktop-mode .lights-section .sidebar-card-visual,
body.desktop-mode .fresh-air-section .sidebar-card-visual,
body.desktop-mode .covers-section .sidebar-card-visual {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 46px;
    min-height: 46px;
    max-height: 46px;
}

body.desktop-mode .lights-section .sidebar-card-actions,
body.desktop-mode .fresh-air-section .sidebar-card-actions,
body.desktop-mode .covers-section .sidebar-card-actions {
    flex: 0 0 auto;
}

body.desktop-mode .sidebar-device-card {
    padding: calc(3px * var(--sidebar-density, 1)) calc(3px * var(--sidebar-density, 1)) calc(3px * var(--sidebar-density, 1));
    gap: calc(2px * var(--sidebar-density, 1));
    justify-content: center;
    align-items: center;
}

.lights-section .sidebar-card-drawer,
.fresh-air-section .sidebar-card-drawer,
.covers-section .sidebar-card-drawer {
    flex: 0 0 auto;
    width: 100%;
}

body.desktop-mode .lights-section .sidebar-device-card,
body.desktop-mode .fresh-air-section .sidebar-device-card,
body.desktop-mode .covers-section .sidebar-device-card {
    justify-content: center;
    gap: var(--sidebar-card-inner-gap, calc(8px * var(--sidebar-density, 1)));
}

body.desktop-mode .lights-section .sidebar-card-name,
body.desktop-mode .lights-section .sidebar-device-name,
body.desktop-mode .fresh-air-section .sidebar-card-name,
body.desktop-mode .fresh-air-section .sidebar-device-name,
body.desktop-mode .covers-section .sidebar-card-name,
body.desktop-mode .covers-section .sidebar-device-name {
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.2;
}

body.desktop-mode .sidebar-card-name,
body.desktop-mode .sidebar-device-name {
    font-size: var(--sidebar-device-name-size, 0.8rem);
    line-height: 1.15;
    font-weight: 700;
}

body.desktop-mode .sidebar-vector {
    min-height: calc(20px * var(--sidebar-density, 1));
    max-height: calc(42px * var(--sidebar-density, 1));
    height: calc(36px * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-vector-svg {
    width: min(100%, calc(42px * var(--sidebar-density, 1)));
    height: min(100%, calc(42px * var(--sidebar-density, 1)));
    max-width: calc(42px * var(--sidebar-density, 1));
    max-height: calc(42px * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-device-card.has-drawer .sidebar-card-visual .sidebar-vector {
    min-height: var(--sidebar-card-icon);
    max-height: var(--sidebar-card-icon);
    height: var(--sidebar-card-icon);
}

body.desktop-mode .lights-section .sidebar-device-card.has-drawer.is-drawer-open,
body.desktop-mode .fresh-air-section .sidebar-device-card.has-drawer.is-drawer-open,
body.desktop-mode .covers-section .sidebar-device-card.has-drawer.is-drawer-open {
    min-height: 0;
    justify-content: center;
    overflow: hidden;
}

body.desktop-mode .lights-section .sidebar-devices-grid .sidebar-device-card.has-drawer.is-drawer-open,
body.desktop-mode .fresh-air-section .sidebar-devices-grid .sidebar-device-card.has-drawer.is-drawer-open,
body.desktop-mode .covers-section .sidebar-devices-grid .sidebar-device-card.has-drawer.is-drawer-open {
    height: 100%;
    max-height: 100%;
}

body.desktop-mode .lights-section .sidebar-devices,
body.desktop-mode .fresh-air-section .sidebar-devices,
body.desktop-mode .covers-section .sidebar-devices,
body.desktop-mode .lights-section .sidebar-device-card,
body.desktop-mode .fresh-air-section .sidebar-device-card,
body.desktop-mode .covers-section .sidebar-device-card {
    --sidebar-card-icon: calc(64px * var(--sidebar-density, 1));
    --sidebar-device-name-size: 0.8rem;
}

body.desktop-mode .fresh-air-section .sidebar-devices:has(.is-drawer-open) {
    overflow: hidden;
}

body.desktop-mode .lights-section .sidebar-devices:has(.is-drawer-open),
body.desktop-mode .covers-section .sidebar-devices:has(.is-drawer-open) {
    overflow: hidden;
}

body.desktop-mode .lights-section .sidebar-device-card.has-drawer,
body.desktop-mode .fresh-air-section .sidebar-device-card.has-drawer,
body.desktop-mode .covers-section .sidebar-device-card.has-drawer {
    --sidebar-card-icon: calc(58px * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-card-visual .sidebar-vector {
    flex: 0 0 var(--sidebar-card-icon);
    width: var(--sidebar-card-icon);
    height: var(--sidebar-card-icon);
    min-width: var(--sidebar-card-icon);
    min-height: var(--sidebar-card-icon);
    max-width: var(--sidebar-card-icon);
    max-height: var(--sidebar-card-icon);
}

body.desktop-mode .lights-section .sidebar-card-menu-btn,
body.desktop-mode .fresh-air-section .sidebar-card-menu-btn,
body.desktop-mode .covers-section .sidebar-card-menu-btn {
    flex: 0 0 calc(34px * var(--sidebar-density, 1));
    width: calc(34px * var(--sidebar-density, 1));
    height: calc(34px * var(--sidebar-density, 1));
}

body.desktop-mode .lights-section .sidebar-card-actions,
body.desktop-mode .covers-section .sidebar-card-actions {
    gap: calc(8px * var(--sidebar-density, 1));
}

body.desktop-mode .fresh-air-section .sidebar-device-card {
    gap: calc(3px * var(--sidebar-density, 1));
    padding: calc(6px * var(--sidebar-density, 1));
}

body.desktop-mode .fresh-air-section .sidebar-card-actions {
    gap: calc(12px * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-card-visual .sidebar-vector-svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

body.desktop-mode .sidebar-fan-controls {
    gap: 3px;
    padding: 0 1px 1px;
}

body.desktop-mode .sidebar-fan-controls .fresh-air-speed-range {
    height: 3px;
}

body.desktop-mode .sidebar-fan-controls .fresh-air-speed-value {
    min-width: calc(26px * var(--sidebar-density, 1));
    font-size: calc(0.54rem * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-fan-controls .fresh-air-speed-buttons {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body.desktop-mode .sidebar-fan-controls .fresh-air-speed-buttons::-webkit-scrollbar {
    display: none;
}

body.desktop-mode .sidebar-fan-controls .fresh-air-speed-btn {
    flex: 0 0 auto;
    padding: calc(2px * var(--sidebar-density, 1)) calc(5px * var(--sidebar-density, 1));
    font-size: calc(0.54rem * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-light-controls {
    gap: calc(4px * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-light-range {
    height: 3px;
}

body.desktop-mode .sidebar-color-swatch {
    width: calc(13px * var(--sidebar-density, 1));
    height: calc(13px * var(--sidebar-density, 1));
}

body.desktop-mode .sidebar-devices[data-layout-tier="multi"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
}

body.desktop-mode .lights-section .sidebar-devices[data-layout-tier="multi"],
body.desktop-mode .fresh-air-section .sidebar-devices[data-layout-tier="multi"],
body.desktop-mode .covers-section .sidebar-devices[data-layout-tier="multi"] {
    grid-auto-rows: auto;
    align-content: space-evenly;
}

body.desktop-mode .sidebar-reason {
    flex-shrink: 0;
    margin: 2px 10px 0;
    padding: 4px 8px;
    font-size: 0.64rem;
}

.room-name-header {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent-hover);
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.status-corner-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    right: auto;
    z-index: 4;
    padding: 3px 8px;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
    line-height: 1.35;
    transform: none;
    transform-origin: center center;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent-hover);
    box-shadow: none;
    pointer-events: none;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

.status-corner-badge--ok {
    background: var(--status-success-bg);
    border-color: var(--status-success-border);
    color: var(--status-success) !important;
}

.status-corner-badge--warn {
    background: var(--status-warn-bg);
    border-color: var(--status-warn-border);
    color: var(--status-warn) !important;
}

.compact-close-btn {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.82);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

.compact-close-btn:hover {
    background: var(--status-error-bg);
    color: var(--status-error);
}

body.compact-mode .compact-close-btn {
    display: flex;
}

body.compact-mode .header .ac-shared-icon {
    right: 36px;
}

.license-panel {
    margin: 0 15px 8px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.license-panel.hidden,
.reason-box.hidden,
.covers-section.hidden,
.floating-widget.hidden,
.desktop-shell.hidden {
    display: none;
}

.license-message {
    font-size: 0.78rem;
    text-align: center;
    color: var(--status-warn);
}

.tab-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 5px 15px 8px;
    position: relative;
    z-index: 10;
    isolation: isolate;
    flex-shrink: 0;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

body.desktop-mode .tab-row {
    display: none;
}

.tab-panels {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

body.desktop-mode .tab-panels {
    pointer-events: auto;
}

body.desktop-mode #ac-panel {
    display: flex !important;
    pointer-events: auto;
    visibility: visible;
}

body.desktop-mode #light-panel,
body.desktop-mode #fresh-air-panel,
body.desktop-mode #cover-panel {
    display: none !important;
    pointer-events: none;
    visibility: hidden;
}

.tab-btn {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    padding: 6px 16px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.tab-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
}

.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
    color: #fff;
}

.tab-content.active {
    display: flex;
    pointer-events: auto;
    visibility: visible;
}

.controls {
    padding: 4px 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.device-info {
    width: 100%;
    text-align: center;
    margin-bottom: 3px;
}

#current-temp,
#light-count,
#fresh-air-count,
#cover-count {
    font-size: 0.75rem;
    opacity: 0.7;
    color: rgba(255, 255, 255, 0.75);
}

.policy-summary {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.policy-tag {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent-hover);
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.temp-row {
    gap: 15px;
}

.temp-display {
    font-size: 2rem;
    font-weight: 300;
    display: flex;
    align-items: flex-start;
    min-width: 70px;
    justify-content: center;
    transition: color 0.3s ease;
    color: #fff;
}

.temp-display.mode-cool {
    color: #4fc3f7;
}

.temp-display.mode-heat {
    color: #ff6b6b;
}

.temp-display.mode-fan_only {
    color: #66bb6a;
}

.temp-display.mode-dry {
    color: #ffd54f;
}

.control-group.mode-group.mode-heat_cool,
.control-group.mode-group.mode-heatcool {
    background: rgba(171, 71, 188, 0.16);
    border-color: rgba(171, 71, 188, 0.42);
}

.control-group.mode-group.mode-heat_cool .select-box,
.control-group.mode-group.mode-heat_cool .icon-wrapper,
.control-group.mode-group.mode-heatcool .select-box,
.control-group.mode-group.mode-heatcool .icon-wrapper {
    color: #ce93d8;
}

.temp-display.mode-heat_cool,
.temp-display.mode-heatcool {
    color: #ce93d8;
}

.unit {
    font-size: 0.85rem;
    margin-top: 5px;
}

.btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn:active {
    background: rgba(255, 255, 255, 0.05);
}

.round {
    border-radius: 50%;
}

.small {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    font-size: 1.1rem;
}

.power {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: rgba(40, 167, 69, 0.22);
    color: #4caf50;
    font-weight: 700;
    font-size: 0.82rem;
    border: 1px solid rgba(40, 167, 69, 0.45);
    transition: all 0.3s ease;
}

.power:hover {
    background: rgba(40, 167, 69, 0.38);
}

.power.off {
    color: #ff453a;
    background: rgba(255, 69, 58, 0.2);
    border: 1px solid rgba(255, 69, 58, 0.3);
}

.power.off:hover {
    background: rgba(255, 69, 58, 0.4);
}

.controls-row {
    justify-content: space-between;
    gap: 4px;
    padding: 0 2px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    flex: 1;
    justify-content: center;
}

.control-group:hover {
    background: rgba(255, 255, 255, 0.1);
}

.control-group.mode-group.mode-cool {
    background: rgba(79, 195, 247, 0.16);
    border-color: rgba(79, 195, 247, 0.42);
}

.control-group.mode-group.mode-cool .select-box,
.control-group.mode-group.mode-cool .icon-wrapper {
    color: #4fc3f7;
}

.control-group.mode-group.mode-heat {
    background: rgba(255, 107, 107, 0.16);
    border-color: rgba(255, 107, 107, 0.42);
}

.control-group.mode-group.mode-heat .select-box,
.control-group.mode-group.mode-heat .icon-wrapper {
    color: #ff6b6b;
}

.control-group.mode-group.mode-fan_only {
    background: rgba(102, 187, 106, 0.16);
    border-color: rgba(102, 187, 106, 0.42);
}

.control-group.mode-group.mode-fan_only .select-box,
.control-group.mode-group.mode-fan_only .icon-wrapper {
    color: #66bb6a;
}

.control-group.mode-group.mode-dry {
    background: rgba(255, 213, 79, 0.16);
    border-color: rgba(255, 213, 79, 0.42);
}

.control-group.mode-group.mode-dry .select-box,
.control-group.mode-group.mode-dry .icon-wrapper {
    color: #ffd54f;
}

.control-group.mode-group.mode-auto {
    background: rgba(171, 71, 188, 0.16);
    border-color: rgba(171, 71, 188, 0.42);
}

.control-group.mode-group.mode-auto .select-box,
.control-group.mode-group.mode-auto .icon-wrapper {
    color: #ce93d8;
}

.control-group.mode-group.mode-off {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.control-group.mode-group.mode-off .select-box,
.control-group.mode-group.mode-off .icon-wrapper {
    color: rgba(255, 255, 255, 0.55);
}

.icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
}

.select-box {
    background: transparent;
    border: none;
    color: #fff;
    padding: 2px 0;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    width: auto;
    min-width: 0;
}

.select-box option {
    background: rgba(20, 20, 20, 0.95);
    color: #fff;
}

.reason-box {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--status-warn-bg);
    border: 1px solid var(--status-warn-border);
    color: var(--status-warn);
    font-size: 0.72rem;
    line-height: 1.5;
    text-align: center;
    box-sizing: border-box;
    white-space: normal;
    word-break: break-word;
    flex-shrink: 0;
}

.sidebar-reason {
    background: var(--status-warn-bg);
    border-color: var(--status-warn-border);
    color: var(--status-warn);
}

.btn:disabled,
.select-box:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lights-container,
.device-list-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 5px 0;
}

body.compact-mode .lights-container,
body.compact-mode .device-list-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    align-content: stretch;
    align-items: stretch;
    gap: 6px;
    padding: 4px 0 8px;
}

body.compact-mode .light-item,
body.compact-mode .fresh-air-item-block {
    margin: 0;
    min-height: 0;
    height: 100%;
}

body.compact-mode .fresh-air-item-block {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 15px;
    padding: 12px 14px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

body.compact-mode .fresh-air-item {
    flex: 1;
    display: flex;
    align-items: center;
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border: none;
}

body.compact-mode .fresh-air-item-block + .fresh-air-item-block {
    margin-top: 0;
    padding-top: 12px;
    border-top: none;
}

body.compact-mode .fresh-air-speed-row {
    flex-shrink: 0;
    margin-top: 0;
}

body.compact-mode .light-item {
    min-height: 56px;
    padding: 12px 14px;
    box-sizing: border-box;
}

body.compact-mode #ac-panel .controls {
    justify-content: space-evenly;
    gap: 10px;
}

body.compact-mode .temp-display {
    font-size: 2.35rem;
}

body.compact-mode .power {
    width: 64px;
    height: 64px;
}

#light-panel .controls,
#fresh-air-panel .controls,
#cover-panel .controls {
    align-items: stretch;
}

#light-panel .device-info,
#light-panel .reason-box,
#fresh-air-panel .device-info,
#fresh-air-panel .reason-box,
#cover-panel .device-info,
#cover-panel .reason-box {
    flex-shrink: 0;
}

.light-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.light-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.light-name {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    flex: 1;
}

.light-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(203, 213, 225, 0.55);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
    border: none;
    padding: 0;
    flex-shrink: 0;
}

.light-toggle::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease, background 0.3s ease;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.light-toggle.on {
    background: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.55);
}

.light-toggle.on::before {
    transform: translateX(20px);
    background: #fff;
}

.light-loading,
.light-error,
.light-empty {
    text-align: center;
    padding: 20px;
    font-size: 0.8rem;
}

.light-loading,
.light-empty {
    color: rgba(100, 116, 139, 0.85);
}

.light-error {
    color: #ff453a;
}

.fresh-air-item-block + .fresh-air-item-block {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.fresh-air-item {
    margin-bottom: 8px;
}

.fresh-air-speed-row {
    margin-top: 12px;
    padding: 0 4px;
}

.fresh-air-speed-row .control-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 8px;
}

.fresh-air-speed-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fresh-air-speed-btn {
    min-width: 52px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fresh-air-speed-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
}

.fresh-air-speed-btn.is-active {
    background: rgba(40, 167, 69, 0.22);
    border-color: rgba(40, 167, 69, 0.45);
    color: #9be7a0;
}

.fresh-air-speed-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.fresh-air-speed-select,
.fresh-air-percent-select {
    width: 100%;
    margin-top: 0;
}

.fresh-air-speed-slider-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fresh-air-speed-range {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    accent-color: #28a745;
    cursor: pointer;
}

.fresh-air-speed-range:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.fresh-air-speed-value {
    min-width: 42px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.82);
    text-align: right;
}

/* ---- Floating temperature widget ---- */

.floating-widget {
    position: relative;
    width: 86px;
    height: 86px;
    flex-shrink: 0;
    touch-action: none;
    background: transparent;
    pointer-events: none;
    overflow: visible;
    isolation: isolate;
}

.floating-widget.is-dragging .widget-restore-btn {
    cursor: grabbing;
}

.widget-close-btn {
    position: absolute;
    top: 10px;
    right: 16px;
    z-index: 4;
    width: 16px;
    height: 16px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #64748b;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.18s ease, background 0.18s ease, color 0.18s ease;
    pointer-events: auto;
}

.floating-widget:hover .widget-close-btn,
.floating-widget.is-dragging .widget-close-btn {
    opacity: 1;
}

.widget-close-btn:hover {
    background: rgba(255, 69, 58, 0.15);
    color: #ff453a;
}

.widget-restore-btn {
    position: relative;
    display: block;
    width: 86px;
    height: 86px;
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 50%;
    cursor: grab;
    overflow: hidden;
    padding: 0;
    pointer-events: auto;
    isolation: isolate;
    /* 液体颜色：仅由模式类控制，外壳始终为白玻 */
    --wave-top: rgba(144, 224, 255, 0.82);
    --wave-bottom: rgba(41, 182, 246, 0.98);
    --wave-back-top: rgba(79, 195, 247, 0.62);
    --wave-back-bottom: rgba(2, 136, 209, 0.94);
    --temp-color: #1565c0;
    background:
        radial-gradient(circle at 28% 16%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 38%),
        radial-gradient(circle at 78% 82%, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 46%),
        linear-gradient(155deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0.14) 44%, rgba(255, 255, 255, 0.32) 100%);
    backdrop-filter: blur(22px) saturate(1.55) brightness(1.06);
    -webkit-backdrop-filter: blur(22px) saturate(1.55) brightness(1.06);
    box-shadow:
        0 14px 36px rgba(15, 23, 42, 0.13),
        0 4px 12px rgba(15, 23, 42, 0.07),
        inset 0 1.5px 1px rgba(255, 255, 255, 0.88),
        inset 0 -3px 10px rgba(255, 255, 255, 0.06),
        inset 0 0 0 0.5px rgba(255, 255, 255, 0.32);
    filter: drop-shadow(0 10px 20px rgba(15, 23, 42, 0.11));
    transition:
        border-color 0.35s ease,
        box-shadow 0.35s ease,
        filter 0.35s ease,
        transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.widget-restore-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    z-index: 5;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% -8%, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0) 52%),
        conic-gradient(
            from 225deg at 50% 50%,
            rgba(255, 255, 255, 0) 0deg,
            rgba(255, 255, 255, 0.28) 64deg,
            rgba(255, 255, 255, 0) 128deg,
            rgba(255, 255, 255, 0.14) 200deg,
            rgba(255, 255, 255, 0) 280deg,
            rgba(255, 255, 255, 0.2) 360deg
        );
    opacity: 0.78;
    mix-blend-mode: soft-light;
}

.widget-restore-btn::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    z-index: 3;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.08) 34%, rgba(255, 255, 255, 0) 58%),
        radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 58%);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
    mask-image: linear-gradient(180deg, #000 0%, #000 46%, transparent 74%);
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 46%, transparent 74%);
}

.widget-restore-btn:hover {
    transform: scale(1.045);
    border-color: rgba(255, 255, 255, 0.78);
    box-shadow:
        0 18px 42px rgba(15, 23, 42, 0.15),
        0 6px 14px rgba(15, 23, 42, 0.09),
        inset 0 1.5px 1px rgba(255, 255, 255, 0.95),
        inset 0 -3px 10px rgba(255, 255, 255, 0.08),
        inset 0 0 0 0.5px rgba(255, 255, 255, 0.38);
    filter: drop-shadow(0 12px 26px rgba(15, 23, 42, 0.13));
}

.widget-restore-btn.mode-cool {
    --wave-top: rgba(144, 224, 255, 0.82);
    --wave-bottom: rgba(41, 182, 246, 0.98);
    --wave-back-top: rgba(79, 195, 247, 0.62);
    --wave-back-bottom: rgba(2, 136, 209, 0.94);
    --temp-color: #1565c0;
}

.widget-restore-btn.mode-heat {
    --wave-top: rgba(255, 171, 145, 0.82);
    --wave-bottom: rgba(239, 83, 80, 0.98);
    --wave-back-top: rgba(229, 115, 115, 0.58);
    --wave-back-bottom: rgba(198, 40, 40, 0.94);
    --temp-color: #c62828;
}

.widget-restore-btn.mode-fan_only {
    --wave-top: rgba(200, 230, 201, 0.82);
    --wave-bottom: rgba(102, 187, 106, 0.98);
    --wave-back-top: rgba(129, 199, 132, 0.58);
    --wave-back-bottom: rgba(46, 125, 50, 0.94);
    --temp-color: #2e7d32;
}

.widget-restore-btn.mode-dry {
    --wave-top: rgba(255, 236, 179, 0.82);
    --wave-bottom: rgba(255, 202, 40, 0.98);
    --wave-back-top: rgba(255, 213, 79, 0.58);
    --wave-back-bottom: rgba(249, 168, 37, 0.94);
    --temp-color: #e65100;
}

.widget-restore-btn.mode-auto {
    --wave-top: rgba(225, 190, 231, 0.82);
    --wave-bottom: rgba(171, 71, 188, 0.98);
    --wave-back-top: rgba(186, 104, 200, 0.58);
    --wave-back-bottom: rgba(123, 31, 162, 0.94);
    --temp-color: #7b1fa2;
}

.widget-restore-btn.mode-off {
    --wave-top: rgba(207, 216, 220, 0.76);
    --wave-bottom: rgba(120, 144, 156, 0.94);
    --wave-back-top: rgba(176, 190, 197, 0.52);
    --wave-back-bottom: rgba(84, 110, 122, 0.9);
    --temp-color: #546e7a;
}

.widget-restore-btn:active {
    cursor: grabbing;
    transform: scale(0.97);
}

.widget-sphere-shine {
    position: absolute;
    top: 7%;
    left: 12%;
    width: 46%;
    height: 28%;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.62) 24%, rgba(255, 255, 255, 0) 72%);
    z-index: 6;
    pointer-events: none;
    filter: blur(0.2px);
}

.widget-liquid {
    position: absolute;
    inset: 5px;
    overflow: hidden;
    border-radius: 50%;
    pointer-events: none;
    --liquid-level: 48%;
    z-index: 1;
    background: rgba(255, 255, 255, 0.06);
    box-shadow:
        inset 0 2px 8px rgba(255, 255, 255, 0.22),
        inset 0 -8px 16px rgba(15, 23, 42, 0.06);
}

.widget-liquid::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.06) 28%, rgba(255, 255, 255, 0) 52%);
    z-index: 2;
}

.widget-wave {
    position: absolute;
    left: -18%;
    right: -18%;
    bottom: -4px;
    height: var(--liquid-level, 48%);
    transform-origin: center bottom;
    will-change: transform, border-radius;
    filter: saturate(1.12);
}

.widget-wave-1 {
    background: linear-gradient(180deg, var(--wave-top) 0%, var(--wave-bottom) 100%);
    border-radius: 46% 54% 42% 58% / 38% 36% 64% 62%;
    animation:
        widget-liquid-morph 5.5s ease-in-out infinite,
        widget-liquid-rise 3.6s ease-in-out infinite;
    opacity: 0.94;
    z-index: 1;
}

.widget-wave-2 {
    left: -24%;
    right: -24%;
    background: linear-gradient(180deg, var(--wave-back-top) 0%, var(--wave-back-bottom) 100%);
    border-radius: 58% 42% 52% 48% / 44% 58% 42% 56%;
    animation:
        widget-liquid-morph 4.1s ease-in-out infinite reverse,
        widget-liquid-rise 2.8s ease-in-out infinite reverse;
    opacity: 0.86;
    z-index: 0;
}

@keyframes widget-liquid-morph {
    0%, 100% {
        border-radius: 46% 54% 42% 58% / 38% 36% 64% 62%;
        transform: translate3d(0, 0, 0) scaleX(1);
    }
    33% {
        border-radius: 58% 42% 55% 45% / 52% 58% 42% 48%;
        transform: translate3d(-2px, -1px, 0) scaleX(1.04);
    }
    66% {
        border-radius: 42% 58% 48% 52% / 58% 44% 56% 42%;
        transform: translate3d(2px, -2px, 0) scaleX(0.98);
    }
}

@keyframes widget-liquid-rise {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

.widget-temp {
    position: relative;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.96rem;
    font-weight: 800;
    color: var(--temp-color, #1565c0);
    letter-spacing: -0.02em;
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 1),
        0 0 14px rgba(255, 255, 255, 0.55),
        0 2px 10px rgba(15, 23, 42, 0.1);
    pointer-events: none;
    transition: color 0.35s ease;
}

@media (max-width: 560px) {
    body.desktop-mode:not(.demo-fs-desktop) .desktop-main {
        grid-template-columns: 1fr;
    }

    body.desktop-mode:not(.demo-fs-desktop) .desktop-col-right {
        display: none;
    }

    body.desktop-mode:not(.demo-fs-desktop) .tab-row {
        display: flex;
    }
}

.reason-box .shared-virtual-badge {
    margin-left: 0;
    margin-right: 4px;
    vertical-align: baseline;
}

.shared-virtual-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    color: #5b21b6;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.28);
    vertical-align: middle;
}

.is-readonly-shared .light-toggle:disabled,
.sidebar-device-card.is-readonly-shared .light-toggle:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}
