/* Desktop Environment Styles */

/* ── Win11 shared design tokens (Phase 1 desktop redesign) ──────────────────
 * Single source of truth for the acrylic/geometry/typography values every
 * Win11-styled surface in this app (taskbar, Start Menu, window chrome,
 * File Manager, Quick Settings, Snap Layouts preview) now draws from,
 * reconciling the 4 independently-chosen blur radii and inconsistent
 * corner-radius scale a prior audit found. Declared once, at the top of
 * this already-linked stylesheet — every other already-linked stylesheet
 * can reference these custom properties regardless of load order.
 */
:root {
    --win11-radius-sm: 6px;
    --win11-radius-md: 8px;
    --win11-radius-lg: 12px;
    --win11-blur: blur(24px) saturate(165%);
    --win11-bg-acrylic-dark: rgba(32, 32, 32, 0.85);
    --win11-bg-acrylic-light: rgba(255, 255, 255, 0.72);
    --win11-bg-solid-dark: #202020;
    --win11-border-subtle: rgba(255, 255, 255, 0.12);
    --win11-border-subtle-light: rgba(0, 0, 0, 0.12);
    --win11-font: 'Segoe UI', 'Segoe UI Variable', Tahoma, Geneva, Verdana, sans-serif;
    --win11-shadow-window: 0 32px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
    --win11-shadow-flyout: 0 8px 32px rgba(0, 0, 0, 0.5);
    /* Accent: sourced from File Manager's existing rgba(0,120,212,*) usage
     * (address-bar focus border, active sidebar item) — the real Windows 11
     * system accent blue (#0078D4), already the most Win11-authentic color
     * literally present in this codebase, per the plan's engineer-latitude
     * note (no single obvious existing "the" accent to canonicalize from
     * otherwise).
     */
    --win11-accent: #0078d4;
}

/* Keep the copyright clear of mobile controls and phone safe areas. */
@media (max-width: 768px) {
    #mdc-copyright {
        left: max(12px, env(safe-area-inset-left, 0px)) !important;
        right: max(12px, env(safe-area-inset-right, 0px));
        bottom: calc(var(--mobile-nav-height, 48px) + 12px + env(safe-area-inset-bottom, 0px)) !important;
        max-width: none !important;
        font-size: 11px !important;
        text-align: center !important;
    }
}

/* Windows 11 style static taskbar */
.win11-taskbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 48px;
    padding: 0 10px 0 12px;
    display: none;
    align-items: center;
    justify-content: flex-start;
    /* justify-content: flex-start matches the flex container default and is
     * made explicit here for self-documentation, not a behavior change. This
     * is Windows 11's "Left" taskbar alignment mode: the Start+icon cluster
     * (__left, __center) packs against the true left edge with no leftover
     * space between them, and __right (the tray) is the sole flex-growing
     * zone below, absorbing all remaining space and pinning itself to the
     * far right edge. gap keeps the same 4px rhythm used elsewhere in the
     * taskbar zones. */
    gap: 4px;
    background: #f3f3f3;
    border-top: 1px solid #c7c7c7;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.16);
    z-index: 10003;
    font-family: 'Segoe UI', 'Segoe UI Variable', Tahoma, Geneva, Verdana, sans-serif;
}

body.logged-in .win11-taskbar {
    display: flex;
}

/* flex: 0 1 auto (grow:0) -- Start no longer grows to consume leftover
 * space; it sizes to its own natural content width and hugs the taskbar's
 * true left edge. justify-content: flex-start is inert given a single
 * child of exactly the box's own width, but kept explicit for clarity and
 * to avoid the box ever silently re-centering #win11-start-btn within it. */
.win11-taskbar__left {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    justify-content: flex-start;
}

/* flex: 1 1 0 (flex-basis:0) -- __right is now the *sole* flex-growing zone
 * (previously it shared that role with __left under the old Center-mode
 * technique). It absorbs 100% of the leftover space after __left and
 * __center's natural widths, and justify-content: flex-end right-aligns its
 * own content (the tray) within that box, landing it flush at the
 * taskbar's true right edge -- unchanged in effect from before this run. */
.win11-taskbar__right {
    display: flex;
    align-items: center;
    flex: 1 1 0;
    justify-content: flex-end;
    gap: 4px;
}

/* ── Taskbar center zone: running/pinned apps (Phase 1 desktop redesign, §D.1) ── */
.win11-taskbar__center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    /* flex: 0 1 auto (not flex: 1) -- sizes to this zone's own natural
     * content width instead of growing to consume the leftover space
     * between __left and __right. That forced growth was what caused the
     * single MDCS icon to self-center in the leftover space rather than
     * cluster with Start. Do NOT "simplify" this back to flex: 1 -- it
     * silently reintroduces the centering bug this rule set fixes (see
     * .win11-taskbar__left/__right above for the paired half of this
     * technique). flex-shrink:1 is kept so this still degrades to
     * overflow-x: auto scrolling if the icon count ever grows again. */
    flex: 0 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.win11-taskbar__center::-webkit-scrollbar {
    display: none;
}

.win11-taskbar__app-btn {
    position: relative;
    width: 40px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--win11-radius-sm, 6px);
    color: #202020;
    cursor: pointer;
    padding: 0;
    flex: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.win11-taskbar__app-btn:hover,
.win11-taskbar__app-btn:focus-visible {
    background: #e5e5e5;
    border-color: #d0d0d0;
}

.win11-taskbar__app-btn:focus-visible {
    outline: 2px solid rgba(120, 180, 255, 0.7);
    outline-offset: 1px;
}

.win11-taskbar__app-btn.is-running {
    background: rgba(0, 0, 0, 0.06);
}

/* Active (focused) app — Win11: the focused window's indicator is wider and
 * uses the accent color; the button itself gets a slightly stronger tint. */
.win11-taskbar__app-btn.is-active {
    background: rgba(0, 0, 0, 0.09);
}

.win11-taskbar__app-btn.is-active .win11-taskbar__app-indicator {
    width: 20px;
    background: var(--win11-accent, #0078d4);
}

/* Taskbar alignment (RUN_ID 20261001-windows-parity). Windows 11's default
 * is a single centered cluster: Start + pinned/running apps centered as one
 * group, tray pinned to the right edge. Centered is the CSS default here
 * (no class needed); body.taskbar-align-left (the pre-existing layout) opts
 * back out. The tray becomes absolutely positioned in centered mode so the
 * 1fr space it used to absorb doesn't push the cluster off-center. */
.win11-taskbar {
    justify-content: center;
}

.win11-taskbar__right {
    position: absolute;
    right: 12px;
    top: 0;
    bottom: 0;
    height: auto;
    margin: auto 0;
    flex: 0 0 auto;
}

body.taskbar-align-left .win11-taskbar {
    justify-content: flex-start;
}

body.taskbar-align-left .win11-taskbar__right {
    position: static;
    flex: 1 1 0;
}

/* Narrow/vertical screens (phones): the centered cluster plus the tray can't
 * fit side by side, and centering an overflowing cluster reads as right-
 * aligned. Force the left-aligned layout, compact the buttons, and let the
 * app cluster scroll horizontally instead. (desktop.css's own media query —
 * frontend/css/mobile.css remains unwired/orphaned, see .sdlc-memory.md.) */
@media (max-width: 768px) {
    .win11-taskbar {
        justify-content: flex-start;
        padding: 0 6px;
    }

    .win11-taskbar__right {
        position: static;
        flex: 1 1 auto;
        justify-content: flex-end;
        min-width: 0;
        overflow: hidden;
    }

    .win11-taskbar__app-btn {
        width: 34px;
        height: 34px;
    }

    .win11-taskbar__app-btn.is-active .win11-taskbar__app-indicator {
        width: 14px;
    }

    #win11-hiddenicons-tray-icon {
        display: none;
    }

    .win11-clock {
        min-width: 0;
    }
}

.win11-taskbar__app-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.win11-taskbar__app-icon--emoji {
    font-size: 16px;
    line-height: 18px;
}

.win11-taskbar__app-indicator {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: var(--win11-accent, #0078d4);
    transition: transform 0.15s ease;
}

.win11-taskbar__app-btn.is-running .win11-taskbar__app-indicator {
    transform: translateX(-50%) scaleX(1);
}

.win11-start {
    width: 42px;
    height: 36px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #3b3b3b;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
    padding: 0;
}

.win11-start svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.win11-start:hover,
.win11-start:focus-visible,
.win11-start[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.16);
}

body.dark-mode .win11-start:hover,
body.night-mode .win11-start:hover,
body.dark-mode .win11-start:focus-visible,
body.night-mode .win11-start:focus-visible,
body.dark-mode .win11-start[aria-expanded="true"],
body.night-mode .win11-start[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.win11-start:active {
    transform: translateY(1px);
}

.win11-start:focus-visible {
    outline: 2px solid rgba(120, 180, 255, 0.7);
    outline-offset: 1px;
}

.win11-tray-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--win11-radius-sm, 4px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(30, 30, 30, 0.75);
    /* Real, clickable tray icons now (Phase 1 desktop redesign, §D.4) —
     * these were previously decorative <span aria-hidden> elements with no
     * button semantics at all; reset the native <button> chrome so they
     * still look identical to the prior decorative version at rest.
     */
    background: transparent;
    border: 1px solid transparent;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

body.dark-mode .win11-tray-icon,
body.night-mode .win11-tray-icon {
    color: rgba(245, 248, 255, 0.9);
}

.win11-tray-icon:hover,
.win11-tray-icon:focus-visible {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.16);
}

body.dark-mode .win11-tray-icon:hover,
body.night-mode .win11-tray-icon:hover,
body.dark-mode .win11-tray-icon:focus-visible,
body.night-mode .win11-tray-icon:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.win11-tray-icon:focus-visible {
    outline: 2px solid rgba(120, 180, 255, 0.7);
    outline-offset: 1px;
}

.win11-tray-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.win11-tray-icon.is-muted {
    color: #ff8a8a;
}

.win11-tray-icon.is-good {
    color: #7fe0a8;
}

.win11-tray-icon.is-bad {
    color: #ff8a8a;
}

.win11-profile {
    position: relative;
    margin-left: 4px;
}

.win11-profile-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.16);
    background: rgba(0, 0, 0, 0.08);
    color: #2b2b2b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    font: inherit;
    padding: 0;
}

body.dark-mode .win11-profile-btn,
body.night-mode .win11-profile-btn {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.12);
    color: #eef4ff;
}

.win11-profile-btn:hover,
.win11-profile-btn:focus-visible,
.win11-profile-btn[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.16);
    border-color: rgba(0, 0, 0, 0.28);
}

body.dark-mode .win11-profile-btn:hover,
body.night-mode .win11-profile-btn:hover,
body.dark-mode .win11-profile-btn:focus-visible,
body.night-mode .win11-profile-btn:focus-visible,
body.dark-mode .win11-profile-btn[aria-expanded="true"],
body.night-mode .win11-profile-btn[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.35);
}

.win11-profile-btn:focus-visible {
    outline: 2px solid rgba(120, 180, 255, 0.7);
    outline-offset: 1px;
}

.win11-profile-initials {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.win11-profile-menu {
    position: absolute;
    right: 0;
    bottom: 38px;
    min-width: 136px;
    display: none;
    padding: 6px;
    border-radius: 8px;
    background: rgba(28, 28, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    z-index: 10005;
}

.win11-profile-menu.show {
    display: block;
    animation: startMenuSlideUp 0.15s ease-out;
}

.win11-profile-menu__item {
    width: 100%;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #ffb3b3;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    padding: 8px 10px;
    text-align: left;
}

.win11-profile-menu__item:hover,
.win11-profile-menu__item:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.win11-network-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    margin-left: 2px;
    border-radius: 11px;
    background: rgba(0, 0, 0, 0.05);
    color: rgba(30, 30, 30, 0.75);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    font-variant-numeric: tabular-nums;
}

body.dark-mode .win11-network-badge,
body.night-mode .win11-network-badge {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(245, 248, 255, 0.9);
}

.win11-network-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
    flex: none;
}

body.dark-mode .win11-network-dot,
body.night-mode .win11-network-dot {
    background: rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
}

.win11-network-badge.is-good .win11-network-dot {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.win11-network-badge.is-warn .win11-network-dot {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.win11-network-badge.is-bad .win11-network-dot,
.win11-network-badge.is-offline .win11-network-dot {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.win11-clock {
    min-width: 74px;
    margin-left: 4px;
    color: #2b2b2b;
    text-align: right;
    line-height: 1.08;
    letter-spacing: 0.1px;
}

body.dark-mode .win11-clock,
body.night-mode .win11-clock {
    color: #edf2ff;
}

.win11-clock__time {
    font-size: 12.5px;
    font-weight: 500;
}

.win11-clock__date {
    margin-top: 1px;
    font-size: 11px;
    color: rgba(43, 43, 43, 0.75);
}

body.dark-mode .win11-clock__date,
body.night-mode .win11-clock__date {
    color: rgba(225, 232, 248, 0.92);
}

/* ── Taskbar appearance modes (RUN_ID 20260930-taskbar-customization) ─────
 * body.taskbar-mode-dark / body.taskbar-mode-accent / body.taskbar-transparency
 * are set by frontend/js/desktop-background.js from localStorage — per-device,
 * exactly like Windows 11's own taskbar settings. Light + opaque is the
 * default and needs no class. Accent mode tints the bar with the shared
 * --win11-accent variable, so "Accent" follows the desktop background's
 * auto-derived accent when a custom solid background color is set.
 */
body.taskbar-mode-dark .win11-taskbar {
    background: var(--win11-bg-solid-dark, #202020);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.4);
}

body.taskbar-mode-dark .win11-taskbar__app-btn {
    color: #f5f5f5;
}

body.taskbar-mode-dark .win11-taskbar__app-btn:hover,
body.taskbar-mode-dark .win11-taskbar__app-btn:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.16);
}

body.taskbar-mode-dark .win11-taskbar__app-btn.is-running {
    background: rgba(255, 255, 255, 0.07);
}

body.taskbar-mode-dark .win11-start {
    color: #f3f3f3;
}

body.taskbar-mode-dark .win11-start:hover,
body.taskbar-mode-dark .win11-start:focus-visible,
body.taskbar-mode-dark .win11-start[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

body.taskbar-mode-dark .win11-tray-icon {
    color: rgba(245, 248, 255, 0.9);
}

body.taskbar-mode-dark .win11-tray-icon:hover,
body.taskbar-mode-dark .win11-tray-icon:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

body.taskbar-mode-dark .win11-profile-btn {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.12);
    color: #eef4ff;
}

body.taskbar-mode-dark .win11-profile-btn:hover,
body.taskbar-mode-dark .win11-profile-btn:focus-visible,
body.taskbar-mode-dark .win11-profile-btn[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.35);
}

body.taskbar-mode-dark .win11-network-badge {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(245, 248, 255, 0.9);
}

body.taskbar-mode-dark .win11-network-dot {
    background: rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
}

body.taskbar-mode-dark .win11-clock {
    color: #edf2ff;
}

body.taskbar-mode-dark .win11-clock__date {
    color: rgba(225, 232, 248, 0.92);
}

/* Accent tint: the bar's own background goes transparent and an accent
 * layer (::before, z -1 — behind the bar's static children but inside its
 * stacking context) tints the backdrop. White text reads on every accent
 * this app derives (lightened dark colors / darkened light colors are both
 * mid-tone). Status-dot colors (is-good/is-warn/is-bad) intentionally win
 * over these — their selectors are more specific. */
body.taskbar-mode-accent .win11-taskbar {
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.35);
}

body.taskbar-mode-accent .win11-taskbar::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--win11-accent, #0078d4);
    pointer-events: none;
}

body.taskbar-mode-accent .win11-taskbar__app-btn {
    color: #fff;
}

body.taskbar-mode-accent .win11-taskbar__app-btn:hover,
body.taskbar-mode-accent .win11-taskbar__app-btn:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
}

body.taskbar-mode-accent .win11-taskbar__app-btn.is-running {
    background: rgba(255, 255, 255, 0.16);
}

body.taskbar-mode-accent .win11-start {
    color: #fff;
}

body.taskbar-mode-accent .win11-start:hover,
body.taskbar-mode-accent .win11-start:focus-visible,
body.taskbar-mode-accent .win11-start[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.22);
}

body.taskbar-mode-accent .win11-tray-icon {
    color: rgba(255, 255, 255, 0.95);
}

body.taskbar-mode-accent .win11-tray-icon:hover,
body.taskbar-mode-accent .win11-tray-icon:focus-visible {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.22);
}

body.taskbar-mode-accent .win11-profile-btn {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

body.taskbar-mode-accent .win11-network-badge {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

body.taskbar-mode-accent .win11-network-dot {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.25);
}

body.taskbar-mode-accent .win11-clock {
    color: #fff;
}

body.taskbar-mode-accent .win11-clock__date {
    color: rgba(255, 255, 255, 0.85);
}

/* Transparency effects (Win11's toggle): the bar gains backdrop blur and
 * translucency. Light and dark get translucent fills; accent keeps its
 * ::before tint layer and lets the blur show through it. */
body.taskbar-transparency .win11-taskbar {
    backdrop-filter: var(--win11-blur, blur(24px) saturate(165%));
    -webkit-backdrop-filter: var(--win11-blur, blur(24px) saturate(165%));
}

body.taskbar-transparency:not(.taskbar-mode-accent) .win11-taskbar {
    background: rgba(243, 243, 243, 0.72);
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.12);
}

body.taskbar-transparency.taskbar-mode-dark .win11-taskbar {
    background: rgba(32, 32, 32, 0.78);
}

body.taskbar-transparency.taskbar-mode-accent .win11-taskbar::before {
    opacity: 0.82;
}

/* ── Quick Settings flyout (Phase 1 desktop redesign, §D.5) ──────────────
 * Reusable popover primitive, same interaction pattern (open/close,
 * click-outside, Escape) already used by .win11-profile-menu/
 * .win11-startmenu__power-menu above — deliberately reuses those same
 * acrylic-dark tokens/geometry rather than inventing a new visual language.
 */
.win11-quick-settings {
    position: fixed;
    right: 10px;
    bottom: 56px;
    width: 300px;
    display: none;
    padding: 12px;
    border-radius: var(--win11-radius-md, 8px);
    background: rgba(28, 28, 30, 0.96);
    backdrop-filter: var(--win11-blur, blur(24px) saturate(165%));
    -webkit-backdrop-filter: var(--win11-blur, blur(24px) saturate(165%));
    border: 1px solid var(--win11-border-subtle, rgba(255, 255, 255, 0.12));
    box-shadow: var(--win11-shadow-flyout, 0 8px 32px rgba(0, 0, 0, 0.5));
    z-index: 10005;
    /* Round-2 runtime fix (Runtime Finding #6): !important is required
     * because frontend/css/fonts.css's pre-existing, untouched blanket rule
     * (`:root, body, body * { font-family: 'Courier New',... !important; }`)
     * always beats a non-!important declaration regardless of specificity.
     * The wildcard companion rule below is required too — fonts.css's
     * `body *` directly matches every descendant of the flyout (rows/
     * labels/buttons), so inheriting from .win11-quick-settings alone
     * isn't enough; each descendant needs its own directly-matching,
     * higher-specificity !important declaration. Scoped to this flyout's
     * own subtree only.
     */
    font-family: var(--win11-font) !important;
    color: #ffffff;
}

.win11-quick-settings,
.win11-quick-settings * {
    font-family: var(--win11-font) !important;
}

.win11-quick-settings.show {
    display: block;
    animation: startMenuSlideUp 0.15s ease-out;
}

.win11-quick-settings__row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.win11-quick-settings__toggle {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: var(--win11-radius-sm, 6px);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.win11-quick-settings__toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.win11-quick-settings__toggle.is-active {
    background: rgba(0, 120, 212, 0.35);
    border-color: var(--win11-accent, #0078d4);
}

.win11-quick-settings__toggle-icon {
    font-size: 16px;
    line-height: 1;
}

.win11-quick-settings__toggle-label {
    font-size: 11px;
}

.win11-quick-settings__section {
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.win11-quick-settings__section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 6px;
}

.win11-quick-settings__connection {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.win11-quick-settings__username {
    font-size: 12.5px;
    font-weight: 500;
}

.win11-quick-settings__signout {
    width: 100%;
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: var(--win11-radius-sm, 6px);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffb3b3;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.win11-quick-settings__signout:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Desktop Icon Styles */
.desktop-icon {
    position: absolute;
    width: 64px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px;
    transition: background 0.2s ease, box-shadow 0.15s ease;
    user-select: none;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
}

.desktop-icon:hover {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}

.desktop-icon.selected {
    background: rgba(0, 120, 215, 0.4);
    border: 1px solid rgba(0, 120, 215, 0.8);
}

.icon-image {
    width: 48px;
    height: 48px;
    margin-bottom: 4px;
}

.icon-label {
    /* White caption by default: pairs with the richer (mid-dark) default
     * desktop background (RUN_ID 20260930-desktop-background). Light custom
     * backgrounds re-enable the dark caption via body.custom-bg-light. */
    color: #ffffff;
    font-size: 11px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    word-wrap: break-word;
    max-width: 60px;
    line-height: 1.2;
}

body.dark-mode .icon-label,
body.night-mode .icon-label {
    color: #ffffff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* Custom solid backgrounds declare their luminance (custom-bg-dark /
 * custom-bg-light, set by frontend/js/desktop-background.js) so icon
 * captions stay readable on any color the user picks. Picture backgrounds
 * are treated as dark: white captions with a dark shadow read best on
 * most photos. */
body.custom-bg-light .icon-label {
    color: #1B1B1B;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.7);
}

/* Desktop Icon Grid */
.desktop-icons-container {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 56px; /* Above taskbar */
    display: block;
    padding: 10px 12px;
    z-index: 999;
    pointer-events: auto;
    overflow: hidden;
}

.desktop-icons-container .desktop-icon {
    position: absolute;
    pointer-events: all;
}

/* Start Menu Styles */
.start-menu {
    display: none;
}

.start-menu.show {
    display: block;
}

@keyframes startMenuSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Windows 11 Start Menu */
.win11-startmenu {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 660px;
    max-width: calc(100vw - 24px);
    background: rgba(32, 32, 32, 0.88);
    backdrop-filter: blur(40px) saturate(165%);
    -webkit-backdrop-filter: blur(40px) saturate(165%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    z-index: 10004;
    overflow: hidden;
    font-family: 'Segoe UI', 'Segoe UI Variable', Tahoma, Geneva, Verdana, sans-serif;
    color: #ffffff;
}

.win11-startmenu.show {
    animation: startMenuSlideUp 0.18s ease-out;
}

.win11-startmenu__search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 300px;
    margin: 24px auto 20px;
    padding: 0 12px;
    height: 36px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
}

.win11-startmenu__search-icon {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.65);
    flex: none;
}

.win11-startmenu__search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 13px;
    font-family: inherit;
}

.win11-startmenu__search-input::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.win11-startmenu__body {
    padding: 0 24px 8px;
    max-height: 380px;
    overflow-y: auto;
}

.win11-startmenu__section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin: 8px 0 12px;
}

.win11-startmenu__section-header--recommended {
    margin-top: 20px;
}

.win11-startmenu__grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.win11-startmenu__tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: center;
}

.win11-startmenu__tile:hover,
.win11-startmenu__tile:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.win11-startmenu__tile-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.win11-startmenu__tile-icon--emoji {
    font-size: 28px;
    line-height: 32px;
}

.win11-startmenu__tile-label {
    font-size: 11px;
    color: #ffffff;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.win11-startmenu__empty {
    display: none;
    padding: 16px 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
}

.win11-startmenu__recommended {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding-bottom: 4px;
}

.win11-startmenu__recommended-empty {
    grid-column: 1 / -1;
    padding: 10px 4px 18px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

.win11-startmenu__recommended-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    cursor: default;
    transition: background 0.15s ease;
}

.win11-startmenu__recommended-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.win11-startmenu__recommended-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex: none;
}

.win11-startmenu__recommended-icon--emoji {
    font-size: 20px;
    line-height: 24px;
}

.win11-startmenu__recommended-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.win11-startmenu__recommended-name {
    font-size: 12px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.win11-startmenu__recommended-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
}

.win11-startmenu__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.win11-startmenu__account {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    color: #ffffff;
}

.win11-startmenu__account:hover {
    background: rgba(255, 255, 255, 0.08);
}

.win11-startmenu__account-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.win11-startmenu__account-name {
    font-size: 12.5px;
}

.win11-startmenu__power-wrap {
    position: relative;
}

.win11-startmenu__power {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.win11-startmenu__power svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.win11-startmenu__power:hover,
.win11-startmenu__power[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
}

.win11-startmenu__power-menu {
    position: absolute;
    right: 0;
    bottom: 42px;
    min-width: 150px;
    display: none;
    padding: 6px;
    border-radius: 8px;
    background: rgba(28, 28, 30, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    z-index: 10005;
}

.win11-startmenu__power-menu.show {
    display: block;
    animation: startMenuSlideUp 0.15s ease-out;
}

.win11-startmenu__power-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 10px;
    text-align: left;
}

.win11-startmenu__power-menu-item svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex: none;
}

.win11-startmenu__power-menu-item:hover,
.win11-startmenu__power-menu-item:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

#win11-startmenu-signout-btn {
    color: #ffb3b3;
}

/* Desktop Context Menu */
.desktop-context-menu {
    position: fixed;
    background: rgba(32, 32, 32, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    display: none;
    min-width: 180px;
    overflow: hidden;
}

.desktop-context-menu.show {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 13px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

.context-menu-item.disabled {
    color: rgba(255, 255, 255, 0.5);
    cursor: default;
}

.context-menu-item.disabled:hover {
    background: transparent;
}

.context-menu-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* Dispatch Console Window */
.dispatcher-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 820px;
    max-width: calc(100% - 80px);
    height: 560px;
    max-height: calc(100% - 140px);
    background: #f0f0f0;
    border: 1px solid #999999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: none;
    z-index: 5000;
    overflow: hidden;
}

.dispatcher-window.show {
    display: block;
}

.dispatcher-content {
    height: calc(100% - 30px);
    overflow: hidden;
}

.dispatch-console-grid {
    display: grid;
    grid-template-columns: minmax(340px, 1.6fr) minmax(220px, 1fr) minmax(220px, 1fr);
    gap: 12px;
    height: 100%;
    box-sizing: border-box;
}

.dispatch-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    min-width: 0;
}

.dispatch-column-form {
    overflow: auto;
    padding-right: 4px;
}

.dispatch-column .dispatch-list {
    flex: 1;
    max-height: none;
}

.dispatch-column-form .dispatch-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.dispatch-location-input {
    flex: 1;
    min-width: 260px;
}

.dispatch-location-line2 {
    margin-left: 74px;
}

.dispatch-code-input {
    width: 80px;
}

.dispatch-priority-input {
    width: 60px;
}

.dispatch-remark-input {
    flex: 1;
    min-width: 220px;
}

.dispatch-upd-input {
    flex: 1;
    min-width: 220px;
}

.dispatch-action-row {
    gap: 6px;
}

.dispatch-simple-submit {
    background: #e6e6e6;
    border: 1px solid #999999;
    height: 24px;
    padding: 0 10px;
    font-family: 'Lucida Console', monospace;
    font-size: 11px;
    cursor: pointer;
}

.dispatch-simple-submit:hover {
    background: #d4d4d4;
}

.dispatch-section-header {
    margin-top: 4px;
}

.dispatch-simple-action {
    background: #e6e6e6;
    border: 1px solid #999999;
    padding: 2px 8px;
    font-size: 10px;
    font-family: 'Lucida Console', monospace;
    cursor: pointer;
}

.dispatch-list {
    border: 1px solid #999999;
    background: #ffffff;
    padding: 4px;
    max-height: 140px;
    overflow: auto;
    font-family: 'Lucida Console', monospace;
    font-size: 11px;
}

.dispatch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 4px;
    gap: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.dispatch-item:last-child {
    border-bottom: none;
}

.dispatch-item.selected {
    background: #d7f0f4;
}

.dispatch-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dispatch-actions {
    display: flex;
    gap: 4px;
}

.dispatch-action {
    background: #e6e6e6;
    border: 1px solid #999999;
    padding: 2px 6px;
    font-size: 10px;
    font-family: 'Lucida Console', monospace;
    cursor: pointer;
}

.dispatch-action.detach {
    color: #b00000;
}

.dispatch-action.delete {
    color: #7a0f0f;
    border-color: #9d6b6b;
}

.dispatch-empty {
    text-align: center;
    padding: 6px;
    color: #555555;
    font-size: 11px;
}

/* Window Animations */
@keyframes windowOpen {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes windowMinimize {
    to {
        opacity: 0;
        transform: translate(-50%, calc(50vh + 200px)) scale(0.05);
    }
}

.window-opening {
    animation: windowOpen 0.3s ease-out;
}

.window-minimizing {
    animation: windowMinimize 0.4s ease-in-out;
}
