/* =========================================================================
   Fluent Web OS 11 Pro — Modern Fluent Mica Design System (Dark & Light)
   ========================================================================= */
:root {
    color-scheme: light dark;
    &:has(> head > meta[name="color-scheme"][content="dark"]) {
        color-scheme: dark;
    }
    &:has(> head > meta[name="color-scheme"][content="light"]) {
        color-scheme: light;
    }

    /* Base Theme Tokens (Dark Default) */
    --glass-bg: rgba(20, 23, 38, 0.72);
    --glass-bg-elevated: rgba(26, 30, 48, 0.86);
    --glass-surface: rgba(255, 255, 255, 0.06);
    --glass-surface-hover: rgba(255, 255, 255, 0.13);
    --glass-border: rgba(255, 255, 255, 0.16);
    --glass-border-strong: rgba(255, 255, 255, 0.28);
    --text-main: #f8fafc;
    --text-muted: rgba(248, 250, 252, 0.66);
    --input-bg: rgba(0, 0, 0, 0.32);
    --panel-subtle: rgba(0, 0, 0, 0.24);
    --shadow-win: 0 22px 58px rgba(0, 0, 0, 0.55);

    --accent: #00d2ff;
    --accent-fg: #041019;
    --accent-text: #38bdf8;
    --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
    --accent-border: color-mix(in srgb, var(--accent) 55%, transparent);
    --danger: #ff4757;
    --danger-text: #ff6b81;
    --warning: #ffa502;
    --success: #2ed573;
    --spring-easing: cubic-bezier(0.16, 1, 0.3, 1);

    /* Dynamic Wallpaper Variables */
    --bg-c1: #0f0c29;
    --bg-c2: #302b63;
    --bg-c3: #24243e;
    --orb-1: #ff0844;
    --orb-2: #00d2ff;
    --orb-3: #7a00ff;

    --scrollbar-thumb: rgba(255, 255, 255, 0.25);
    --scrollbar-track: transparent;
    accent-color: var(--accent);
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

:root[data-theme="light"] {
    color-scheme: light;
    --glass-bg: rgba(246, 248, 253, 0.84);
    --glass-bg-elevated: rgba(255, 255, 255, 0.94);
    --glass-surface: rgba(15, 23, 42, 0.055);
    --glass-surface-hover: rgba(15, 23, 42, 0.11);
    --glass-border: rgba(15, 23, 42, 0.14);
    --glass-border-strong: rgba(15, 23, 42, 0.26);
    --text-main: #0f172a;
    --text-muted: rgba(15, 23, 42, 0.68);
    --input-bg: rgba(255, 255, 255, 0.86);
    --panel-subtle: rgba(15, 23, 42, 0.05);
    --shadow-win: 0 20px 50px rgba(15, 23, 42, 0.22);
    --scrollbar-thumb: rgba(15, 23, 42, 0.28);
    --accent-text: #0369a1;
    --danger-text: #dc2626;
}

select option {
    background-color: #1a1e30;
    color: #f8fafc;
}
:root[data-theme="light"] select option {
    background-color: #ffffff;
    color: #0f172a;
}

@supports not (scrollbar-color: auto) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    ::-webkit-scrollbar-thumb {
        background: var(--scrollbar-thumb);
        border-radius: 4px;
    }
    ::-webkit-scrollbar-track {
        background: var(--scrollbar-track);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI Variable', 'Segoe UI', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #05050a;
    color: var(--text-main);
}

button, input, select, textarea {
    color: inherit;
    font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ================= 1. WALLPAPER & DISPLAY FILTER ================= */
#desktop-bg {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--bg-c1), var(--bg-c2), var(--bg-c3));
    z-index: 0;
    overflow: hidden;
    transition: background 0.8s ease;
}

#desktop-bg.custom-wallpaper .aurora-orb {
    display: none;
}

.aurora-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.52;
    animation: floatOrb 22s infinite alternate ease-in-out;
    pointer-events: none;
    @media (prefers-reduced-motion: reduce) {
        animation: none;
    }
}

:root[data-reduced-motion="true"] .aurora-orb {
    animation: none !important;
}

.orb-1 {
    width: 65vw;
    height: 65vw;
    background: radial-gradient(circle, var(--orb-1), transparent 70%);
    top: -25%;
    left: -15%;
}
.orb-2 {
    width: 55vw;
    height: 55vw;
    background: radial-gradient(circle, var(--orb-2), transparent 70%);
    bottom: -20%;
    right: -10%;
    animation-delay: -7s;
    animation-duration: 28s;
}
.orb-3 {
    width: 45vw;
    height: 45vw;
    background: radial-gradient(circle, var(--orb-3), transparent 70%);
    top: 25%;
    left: 35%;
    animation-delay: -14s;
    animation-duration: 19s;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(6vw, 5vh) scale(1.1); }
    100% { transform: translate(-5vw, -6vh) scale(0.94); }
}

#display-filter-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 99990;
    transition: background 0.35s ease, box-shadow 0.2s ease;
}

/* ================= 2. DESKTOP CANVAS, MARQUEE & ICONS ================= */
#desktop {
    position: relative;
    width: 100vw;
    height: calc(100vh - 76px);
    z-index: 1;
    padding: 16px;
    -webkit-user-select: none;
    user-select: none;
}

#desktop-icons {
    display: grid;
    grid-template-columns: repeat(auto-fill, 96px);
    grid-template-rows: repeat(auto-fill, 100px);
    grid-auto-flow: column;
    gap: 10px;
    height: 100%;
    align-content: start;
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 4px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.16s var(--spring-easing), background 0.16s ease, border-color 0.16s ease;
    text-align: center;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.desktop-icon:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
}

.desktop-icon.selected {
    background: var(--accent-soft, rgba(0, 210, 255, 0.22));
    border-color: var(--accent-border, rgba(0, 210, 255, 0.55));
}

.desktop-icon .icon-svg {
    width: 44px;
    height: 44px;
    margin-bottom: 6px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35));
    pointer-events: none;
    flex-shrink: 0;
}

.desktop-icon span {
    font-size: 12px;
    font-weight: 500;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: keep-all;
    overflow-wrap: anywhere;
    pointer-events: none;
}

#marquee-box {
    position: fixed;
    border: 1px solid var(--accent);
    background: var(--accent-soft, rgba(0, 210, 255, 0.16));
    pointer-events: none;
    z-index: 5;
    display: none;
    border-radius: 3px;
}

/* ================= 3. AERO SNAP PREVIEW & WINDOW ENGINE ================= */
#snap-preview {
    position: fixed;
    z-index: 8900;
    pointer-events: none;
    border-radius: 14px;
    border: 2px solid var(--accent);
    background: var(--accent-soft, rgba(0, 210, 255, 0.14));
    backdrop-filter: blur(8px);
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.16s ease, transform 0.16s ease, left 0.16s ease, top 0.16s ease, width 0.16s ease, height 0.16s ease;
}

#snap-preview.visible {
    opacity: 1;
    transform: scale(1);
}

#windows-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.os-window {
    position: fixed;
    margin: 0;
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-win);
    opacity: 0.94;
    transform: scale(0.92);
    transition: transform 0.26s var(--spring-easing),
                opacity 0.24s ease,
                width 0.24s var(--spring-easing),
                height 0.24s var(--spring-easing),
                top 0.24s var(--spring-easing),
                left 0.24s var(--spring-easing),
                border-radius 0.2s ease;
    @media (prefers-reduced-motion: reduce) {
        transition: opacity 0.12s ease;
    }
}

:root[data-reduced-motion="true"] .os-window {
    transition: opacity 0.1s ease !important;
}

.os-window.open {
    transform: scale(1);
}

.os-window.focused {
    opacity: 1;
    border-color: var(--glass-border-strong);
}

.os-window.dragging,
.os-window.resizing {
    transition: none !important;
}

.os-window.minimized {
    transform: translateY(42vh) scale(0.2) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.os-window.desktop-hidden {
    display: none !important;
}

.os-window.closing {
    transform: scale(0.88) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.os-window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 72px) !important;
    border-radius: 0 !important;
}

/* Dedicated Drag Handle per `drag` guidance */
.win-titlebar {
    height: 40px;
    background: var(--glass-surface);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 14px;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    flex-shrink: 0;
}

.win-titlebar.dragging {
    cursor: grabbing;
}

.win-title-left {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    pointer-events: none;
}

.win-title-left svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.win-title-text {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.win-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
}

.win-btn {
    width: 30px;
    height: 28px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

.win-btn:hover {
    background: var(--glass-surface-hover);
}

.win-btn.close-btn:hover {
    background: var(--danger);
    color: #fff;
}

/* Windows 11 Snap Layout Flyout on Maximize Hover */
.snap-layout-popup {
    position: absolute;
    top: 34px;
    right: 28px;
    background: var(--glass-bg-elevated);
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border-strong);
    border-radius: 10px;
    padding: 8px;
    display: none;
    grid-template-columns: repeat(3, 52px);
    gap: 8px;
    z-index: 60;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.snap-layout-popup.open {
    display: grid;
}

.snap-group {
    height: 36px;
    display: grid;
    gap: 3px;
    padding: 3px;
    border-radius: 5px;
    background: var(--panel-subtle);
    border: 1px solid var(--glass-border);
}

.snap-group.two-col { grid-template-columns: 1fr 1fr; }
.snap-group.wide-col { grid-template-columns: 1.7fr 1fr; }
.snap-group.four-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.snap-zone-btn {
    border: 1px solid var(--glass-border-strong);
    background: var(--glass-surface);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.snap-zone-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.win-content {
    flex: 1;
    overflow: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 8-Directional Resize Handles */
.win-resize-handle {
    position: absolute;
    z-index: 25;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.os-window.maximized .win-resize-handle {
    display: none;
}
.resizer-n  { top: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.resizer-s  { bottom: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.resizer-e  { right: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.resizer-w  { left: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.resizer-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.resizer-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.resizer-se { bottom: 0; right: 0; width: 14px; height: 14px; cursor: nwse-resize; }
.resizer-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }

/* ================= 4. FLOATING TASKBAR & DOCK ================= */
#taskbar-container {
    position: fixed;
    bottom: 10px;
    left: 14px;
    right: 14px;
    height: 54px;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}

.taskbar-module {
    pointer-events: auto;
    height: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(26px) saturate(190%);
    -webkit-backdrop-filter: blur(26px) saturate(190%);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.tb-left {
    gap: 9px;
    padding: 0 13px;
    cursor: pointer;
    border: 1px solid var(--glass-border);
}
.tb-left:hover {
    background: var(--glass-bg-elevated);
}

.weather-info {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    line-height: 1.2;
    text-align: left;
}
.weather-temp { font-weight: 700; font-size: 12.5px; }
.weather-desc { color: var(--text-muted); }

.tb-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    gap: 5px;
    padding: 0 10px;
    max-width: calc(100vw - 380px);
    overflow-x: auto;
    scrollbar-width: none;
}

:root[data-taskbar-align="left"] .tb-center {
    position: static;
    transform: none;
    margin-right: auto;
    margin-left: 10px;
}

.tb-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.18s var(--spring-easing), background 0.15s ease;
}

.tb-icon-btn:hover {
    background: var(--glass-surface-hover);
    transform: translateY(-2px);
}

.tb-icon-btn:active {
    transform: scale(0.92);
}

.tb-icon-btn svg {
    width: 24px;
    height: 24px;
}

.tb-divider {
    width: 1px;
    height: 22px;
    background: var(--glass-border);
    margin: 0 3px;
    flex-shrink: 0;
}

.app-dot {
    position: absolute;
    bottom: 3px;
    width: 0;
    height: 3.5px;
    border-radius: 2px;
    background: var(--text-muted);
    transition: width 0.25s var(--spring-easing), opacity 0.2s ease, background 0.2s ease;
    opacity: 0;
}

.tb-icon-btn.other-desktop .app-dot {
    width: 5px;
    opacity: 0.65;
    background: var(--warning);
}

.tb-icon-btn.running .app-dot {
    width: 6px;
    opacity: 1;
}

.tb-icon-btn.focused .app-dot {
    width: 16px;
    background: var(--accent);
    opacity: 1;
}

.tb-right {
    gap: 10px;
    padding: 0 12px;
}

.tray-pill-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 6px 8px;
    border-radius: 9px;
    cursor: pointer;
}
.tray-pill-btn:hover {
    background: var(--glass-surface-hover);
}
.tray-pill-btn svg {
    width: 16px;
    height: 16px;
}

.tray-clock-btn {
    text-align: right;
    font-size: 11.5px;
    line-height: 1.25;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 5px 8px;
    border-radius: 9px;
    position: relative;
}
.tray-clock-btn:hover {
    background: var(--glass-surface-hover);
}
.clock-time { font-weight: 600; }
.clock-date { font-size: 11px; color: var(--text-muted); }

.notif-badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    display: none;
}
.notif-badge-dot.visible {
    display: block;
}

/* ================= 5. START MENU, FLYOUTS, TOASTS & CONTEXT MENU ================= */
.flyout-panel {
    position: fixed;
    background: var(--glass-bg-elevated);
    backdrop-filter: blur(30px) saturate(190%);
    -webkit-backdrop-filter: blur(30px) saturate(190%);
    border: 1px solid var(--glass-border-strong);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    z-index: 8999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.26s var(--spring-easing), opacity 0.2s ease, visibility 0.2s ease;
    @media (prefers-reduced-motion: reduce) {
        transition: opacity 0.12s ease;
    }
}

.flyout-panel.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#start-menu {
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%) translateY(20px) scale(0.97);
    width: 560px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 96px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

:root[data-taskbar-align="left"] #start-menu {
    left: 14px;
    transform: translateY(20px) scale(0.97);
}

#start-menu.open {
    transform: translateX(-50%) translateY(0) scale(1);
}
:root[data-taskbar-align="left"] #start-menu.open {
    transform: translateY(0) scale(1);
}

.start-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-bottom: 2px solid var(--accent);
    border-radius: 10px;
    padding: 9px 13px;
}

.start-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 13px;
}

.start-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 0 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.start-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}

.start-app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 11px 6px;
    border-radius: 10px;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    text-align: center;
    transition: background 0.15s ease, transform 0.15s ease;
}

.start-app-item:hover {
    background: var(--glass-surface-hover);
    border-color: var(--glass-border);
}

.start-app-item svg {
    width: 34px;
    height: 34px;
    margin-bottom: 6px;
}

.start-app-item span {
    font-size: 12px;
    line-height: 1.2;
}

.start-recent-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 6px;
}

.start-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--panel-subtle);
    border: 1px solid transparent;
    cursor: pointer;
    text-align: left;
}
.start-recent-item:hover {
    background: var(--glass-surface-hover);
    border-color: var(--glass-border);
}
.start-recent-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.start-recent-meta { min-width: 0; flex: 1; }
.start-recent-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.start-recent-sub { font-size: 10.5px; color: var(--text-muted); }

.start-footer {
    padding-top: 12px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d2ff, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.power-actions {
    display: flex;
    gap: 6px;
}

.os-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--glass-surface);
    color: var(--text-main);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease;
}
.os-btn:hover {
    background: var(--glass-surface-hover);
    border-color: var(--glass-border-strong);
}
.os-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.os-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-fg, #041019);
    font-weight: 600;
}
.os-btn.danger {
    border-color: rgba(255, 71, 87, 0.45);
    background: rgba(255, 71, 87, 0.14);
    color: var(--danger-text, #ff6b81);
}
.os-btn.danger:hover {
    background: var(--danger);
    color: #fff;
}

/* Context Menu */
#context-menu {
    position: fixed;
    min-width: 215px;
    background: var(--glass-bg-elevated);
    backdrop-filter: blur(26px) saturate(190%);
    -webkit-backdrop-filter: blur(26px) saturate(190%);
    border: 1px solid var(--glass-border-strong);
    border-radius: 11px;
    padding: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    z-index: 9500;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.94);
    transform-origin: top left;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s var(--spring-easing), visibility 0.14s ease;
    -webkit-user-select: none;
    user-select: none;
}

#context-menu.open {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

.ctx-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    border: none;
    background: transparent;
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 12.5px;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
}
.ctx-item:hover {
    background: var(--accent-soft, rgba(0, 210, 255, 0.2));
}
.ctx-item-left {
    display: flex;
    align-items: center;
    gap: 9px;
}
.ctx-kbd {
    font-size: 11px;
    color: var(--text-muted);
}
.ctx-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 5px 4px;
}

/* Toast Notification Stack */
#toast-container {
    position: fixed;
    right: 16px;
    bottom: 76px;
    z-index: 9600;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 340px;
}

.os-toast {
    pointer-events: auto;
    background: var(--glass-bg-elevated);
    backdrop-filter: blur(22px);
    border: 1px solid var(--glass-border-strong);
    border-left: 4px solid var(--accent);
    border-radius: 11px;
    padding: 11px 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: slideToastIn 0.24s var(--spring-easing);
}
.os-toast.error { border-left-color: var(--danger); }
.os-toast.success { border-left-color: var(--success); }
.os-toast-title { font-size: 12.5px; font-weight: 700; display: flex; justify-content: space-between; }
.os-toast-msg { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

@keyframes slideToastIn {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Reboot & Lock Overlays */
#reboot-screen, #lock-screen {
    position: fixed;
    inset: 0;
    z-index: 99980;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#reboot-screen {
    background: #03050a;
    color: #fff;
}

#lock-screen {
    background: linear-gradient(145deg, rgba(8, 12, 28, 0.86), rgba(20, 16, 48, 0.92));
    backdrop-filter: blur(28px);
    color: #fff;
}

#reboot-screen.active, #lock-screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    @media (prefers-reduced-motion: reduce) {
        animation: none;
        opacity: 0.65;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================= 6. CORE APPS STYLING ================= */
.notepad-wrap { display: flex; flex-direction: column; height: 100%; }
.notepad-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--panel-subtle);
    border-bottom: 1px solid var(--glass-border);
    font-size: 12px;
}
.notepad-body {
    flex: 1;
    display: flex;
    min-height: 0;
}
.notepad-area {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    padding: 14px 16px;
    font-size: 13.5px;
    line-height: 1.65;
    resize: none;
    font-family: 'Cascadia Mono', 'Consolas', monospace;
}
.notepad-md-preview {
    flex: 1;
    padding: 14px 18px;
    overflow-y: auto;
    border-left: 1px solid var(--glass-border);
    font-size: 13.5px;
    line-height: 1.65;
    display: none;
}
.notepad-md-preview.visible { display: block; }
.notepad-md-preview h1, .notepad-md-preview h2, .notepad-md-preview h3 { margin: 8px 0 6px; }
.notepad-md-preview ul { padding-left: 20px; margin: 6px 0; }
.notepad-md-preview code { background: var(--panel-subtle); padding: 2px 5px; border-radius: 4px; font-family: Consolas, monospace; }

.notepad-statusbar {
    height: 27px;
    background: var(--panel-subtle);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Calculator Pro */
.calc-wrap { display: flex; flex-direction: column; height: 100%; padding: 12px; gap: 8px; min-height: 0; overflow-y: auto; }
.calc-mode-bar { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-wrap: wrap; }
.calc-mode-tabs { display: flex; gap: 4px; }
.calc-screen {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 11px;
    padding: 10px 14px;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 76px;
}
.calc-history { font-size: 12px; color: var(--text-muted); min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-main-display { font-size: 26px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-sci-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-sci-keys .calc-key { font-size: 12.5px; padding: 6px 2px; min-height: 30px; }
.calc-keys { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; min-height: 190px; }
.calc-key {
    border-radius: 9px;
    border: 1px solid var(--glass-border);
    background: var(--glass-surface);
    color: var(--text-main);
    font-size: 15.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.1s ease;
}
.calc-key:hover { background: var(--glass-surface-hover); }
.calc-key:active, .calc-key.neon-burst { transform: scale(0.95); background: var(--accent-soft, rgba(0, 210, 255, 0.28)); border-color: var(--accent); }
.calc-key.op-key { color: var(--accent-text, var(--accent)); }
.calc-key.eq-key { background: var(--accent); color: var(--accent-fg, #041019); border-color: var(--accent); }
.calc-key.clear-key { color: var(--danger-text, #ff6b81); }
.calc-tape {
    min-height: 88px;
    max-height: 120px;
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--panel-subtle);
    border: 1px solid var(--glass-border);
    border-radius: 9px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}
.calc-tape-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    text-align: right;
    width: 100%;
}
.calc-tape-item:hover { background: var(--glass-surface-hover); }
.calc-conv-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 4px 2px;
}
.calc-conv-card {
    background: var(--panel-subtle);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Cyber Terminal */
.term-wrap {
    position: relative;
    height: 100%;
    background: rgba(8, 10, 18, 0.92);
    color: #34d399;
    color-scheme: dark;
    display: flex;
    flex-direction: column;
    font-family: 'Cascadia Mono', 'Consolas', monospace;
    overflow: hidden;
}
.term-matrix-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 0;
}
.term-matrix-canvas.active { opacity: 0.34; }
.term-body {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 12px 14px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.55;
}
.term-line { margin-bottom: 5px; word-break: break-word; white-space: pre-wrap; }
.term-input-row {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    padding: 8px 14px 12px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.term-prompt { color: #38bdf8; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.term-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #f8fafc;
    font-family: 'Cascadia Mono', 'Consolas', monospace;
    font-size: 13px;
}

/* System Info */
.sys-wrap { padding: 18px; display: flex; flex-direction: column; gap: 14px; height: 100%; overflow-y: auto; }
.sys-header {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--panel-subtle);
    border: 1px solid var(--glass-border);
    padding: 14px;
    border-radius: 12px;
}
.sys-logo {
    width: 50px;
    height: 50px;
    border-radius: 13px;
    background: linear-gradient(135deg, #00d2ff, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.sys-card {
    background: var(--panel-subtle);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px;
}
.sys-card-header { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-bottom: 6px; }
.sys-card-val { font-size: 19px; font-weight: 700; margin-bottom: 8px; }
.sys-bar-bg { width: 100%; height: 7px; background: var(--glass-surface-hover); border-radius: 4px; overflow: hidden; }
.sys-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #00d2ff, #2ed573); transition: width 0.5s ease; }
.sys-specs {
    background: var(--panel-subtle);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.sys-spec-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--glass-border); padding-bottom: 6px; }
.sys-spec-row:last-child { border-bottom: none; padding-bottom: 0; }
.sys-spec-label { color: var(--text-muted); flex-shrink: 0; }
.sys-spec-val { font-weight: 500; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:root[data-reduced-motion="true"] .spinner {
    animation: none;
    opacity: 0.65;
}
:root[data-reduced-motion="true"] .flyout-panel,
:root[data-reduced-motion="true"] .os-toast,
:root[data-reduced-motion="true"] .tb-icon-btn {
    animation: none;
    transition: opacity 0.1s ease;
}

@media (max-width: 680px) {
    #taskbar-container { left: 8px; right: 8px; gap: 6px; }
    .tb-left .weather-info { display: none; }
    .tb-left { padding: 0 10px; flex-shrink: 0; }
    .tb-center {
        position: static;
        transform: none;
        flex: 1;
        min-width: 0;
        max-width: none;
        padding: 0 6px;
    }
    .tb-right { padding: 0 8px; gap: 4px; flex-shrink: 0; }
    .tray-pill-btn { padding: 6px 5px; gap: 5px; }
    .clock-date { display: none; }
    #desktop-icons { grid-template-columns: repeat(auto-fill, 80px); grid-template-rows: repeat(auto-fill, 88px); }
}
