/* ============================================================
   MyPortal Desktop — Windows 11 / Fluent theme
   This file is self-contained: it hides the old dashboard shell
   and adds the desktop, taskbar, Start menu, and window chrome.
   All existing apps are re-used; their modals/boards are
   relocated into windows via the scoped overrides below.
   ============================================================ */

:root {
    --desk-font: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Inter', Roboto, sans-serif;

    --accent:        #4cc2ff;
    --accent-strong: #2ba6f0;
    --accent-soft:   rgba(76, 194, 255, 0.16);

    --win-bg:        #202020;
    --win-bg-2:      #2b2b2b;
    --win-text:      #ffffff;
    --win-text-2:    #cfcfcf;
    --win-border:    rgba(255, 255, 255, 0.08);
    --win-border-2:  rgba(255, 255, 255, 0.14);

    --acrylic:       rgba(32, 32, 32, 0.78);
    --shadow-win:    0 24px 60px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
    --radius:        8px;
    --radius-lg:     12px;
    --taskbar-h:     48px;

    /* Default dark-gray wallpaper. To use your own image, set:
       --wallpaper: url('/images/wallpaper.jpg') center / cover no-repeat, <gradients>; */
    --wallpaper:
        radial-gradient(1100px 760px at 74% 22%, rgba(140, 140, 152, 0.10), transparent 60%),
        radial-gradient(820px 620px at 22% 78%, rgba(90, 90, 100, 0.12), transparent 62%),
        linear-gradient(135deg, #131315 0%, #17171a 46%, #1d1d21 100%);
}

body.desktop-mode {
    font-family: var(--desk-font);
    background: #131315;
    overflow: hidden;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}

/* Hide the legacy dashboard shell (it stays in the DOM so app JS keeps working) */
body.desktop-mode .top-nav,
body.desktop-mode .sidebar,
body.desktop-mode .main-content,
body.desktop-mode .content-container,
body.desktop-mode #aiChatOverlay {
    display: none !important;
}

/* Body-level overlays/toasts from existing apps must stay above the desktop shell */
body.desktop-mode .notification-toast {
    z-index: 2500;
    bottom: calc(var(--taskbar-h) + 16px);
}
body.desktop-mode .stream-player-modal,
body.desktop-mode .music-dialog-overlay,
body.desktop-mode .image-lightbox,
body.desktop-mode .image-lightbox-overlay,
body.desktop-mode .modal {
    z-index: 2500;
}

/* The desktop surface is non-selectable; app windows keep normal text selection */
body.desktop-mode .win-mount {
    user-select: text;
    -webkit-user-select: text;
}

/* ---------- Desktop ---------- */
#desktop-shell {
    position: fixed;
    inset: 0;
    z-index: 900;
}

#desktop {
    position: absolute;
    inset: 0;
    background: var(--wallpaper);
    overflow: hidden;
}

/* Central accent halo — slow "breathing" */
#desktop::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 42%;
    width: 660px;
    height: 660px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(226, 230, 240, 0.06), transparent 62%);
    filter: blur(9px);
    pointer-events: none;
    z-index: 0;
}

/* ---------- Ambient layered background (subtle, GPU-friendly) ---------- */
.desk-amb { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.desk-amb::before {  /* top light + bottom vignette for depth */
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(120% 80% at 50% -12%, rgba(255, 255, 255, 0.05), transparent 55%),
        radial-gradient(150% 120% at 50% 122%, rgba(0, 0, 0, 0.55), transparent 62%);
}
.desk-glow {
    position: absolute;
    width: 54vmax; height: 54vmax;
    border-radius: 50%;
    filter: blur(72px);
    opacity: 0.5;
    will-change: transform;
}
.desk-glow.g-a {
    left: -9%; top: -15%;
    background: radial-gradient(circle, rgba(152, 172, 204, 0.16), transparent 60%);
}
.desk-glow.g-b {
    right: -11%; bottom: -19%;
    background: radial-gradient(circle, rgba(118, 128, 150, 0.14), transparent 60%);
}
.desk-grid {
    position: absolute; inset: -2px;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(120% 92% at 50% 44%, #000 28%, transparent 80%);
    mask-image: radial-gradient(120% 92% at 50% 44%, #000 28%, transparent 80%);
    opacity: 0.5;
    animation: deskGridBreathe 52s ease-in-out infinite alternate;
}
@keyframes deskGridBreathe { from { opacity: 0.4; } to { opacity: 0.62; } }

/* ---------- Unified silver icon theme (all icon contexts share one look) ---------- */
.desk-icon .ic, .win-title .win-icon, .tb-btn .ic, .sm-app .ic, .win-placeholder .ph-ic {
    color: #dfe4ec;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)) drop-shadow(0 -0.6px 0.6px rgba(255, 255, 255, 0.28));
}
.desk-icon .ic svg, .win-icon svg, .tb-btn .ic svg, .sm-app .ic svg, .ph-ic svg {
    width: 1em; height: 1em; display: block;
}
.up-av-app {
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #dfe4ec;
    font-size: 17px;
}

/* ---------- Boot-in: background + icons settle into place ---------- */
body.desktop-mode.booting #desktop { animation: deskFadeIn 0.9s ease both; }
body.desktop-mode.booting .desk-icon {
    animation: deskIconIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(140ms + var(--i, 0) * 75ms);
}
@keyframes deskFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes deskIconIn { from { opacity: 0; transform: translateY(16px) scale(0.9); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .desk-amb *, .desk-glow, .desk-grid, #desktop::after, body.desktop-mode.booting .desk-icon { animation: none !important; }
}

/* BATTERY (mobile): phones keep the static wallpaper — no continuous
   background animation, and the big blur layers (54vmax glow at 72px blur,
   660px halo) are the desktop surface's main GPU cost. They buy nothing
   on a phone screen, so phones get the cheaper static versions. */
@media (pointer: coarse), (max-width: 768px) {
    .desk-grid { animation: none; opacity: 0.4; }
    .desk-glow { filter: blur(34px); opacity: 0.36; }
    #desktop::after { width: 440px; height: 440px; filter: blur(4px); }
    body.desktop-mode.booting .desk-icon { animation: none; }
}

#desktop-icons {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 4px;
    height: calc(100% - var(--taskbar-h));
    z-index: 1;
}

.desk-icon {
    width: 86px;
    padding: 10px 6px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    color: #fff;
    text-align: center;
    transition: background 0.12s ease;
}
.desk-icon:hover { background: rgba(255, 255, 255, 0.14); }
.desk-icon:active { background: rgba(255, 255, 255, 0.2); }
.desk-icon .ic {
    font-size: 34px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}
.desk-icon .lb {
    font-size: 12px;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ---------- Taskbar ---------- */
#taskbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--taskbar-h);
    background: var(--acrylic);
    backdrop-filter: blur(30px) saturate(1.3);
    -webkit-backdrop-filter: blur(30px) saturate(1.3);
    border-top: 1px solid var(--win-border);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 0 4px;
    z-index: 2000;
}

#taskbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

/* Running apps: left-aligned, flowing after the search box (no longer centered) */
#taskbar-center {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 42vw;
    margin-left: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
#taskbar-center::-webkit-scrollbar { display: none; }

/* App buttons must flow horizontally and fit inside the taskbar */
#taskbar-apps {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

/* Taskbar search: a live typeable input (no separate search bar inside the menu) */
.tb-search {
    height: 36px;
    width: 230px;
    max-width: 24vw;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--win-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--win-text-2);
    font-family: inherit;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.tb-search:hover { background: rgba(255, 255, 255, 0.10); }
.tb-search:focus-within {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(102, 139, 255, 0.55);
}
.tb-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--win-text);
    font-family: inherit;
    font-size: 12.5px;
    outline: none;
}
.tb-search input::placeholder { color: var(--win-text-2); }

.tb-btn {
    height: 40px;
    min-width: 40px;
    padding: 0 8px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--win-text);
    position: relative;
    font-family: inherit;
    font-size: 13px;
    transition: background 0.12s ease;
}
.tb-btn:hover { background: rgba(255, 255, 255, 0.1); }
.tb-btn:active { background: rgba(255, 255, 255, 0.16); }
.tb-btn .ic { font-size: 20px; line-height: 1; }
/* Unread badge on the Communication Center taskbar button */
.tb-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--accent-strong, #2ba6f0);
    color: #04121c;
    font-size: 10px; font-weight: 700;
    line-height: 16px; text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    z-index: 2;
}
/* Desktop-tile variant: pill in the top-right corner of the tile */
.desk-icon { position: relative; }
.desk-icon .tb-badge {
    position: absolute;
    top: 2px; right: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
    background: var(--accent-strong, #2ba6f0);
}
/* Start-menu variant: small pill in the top-right corner of the tile */
.sm-app { position: relative; }
.sm-app .tb-badge {
    position: absolute;
    top: 4px; right: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    background: var(--accent, #4cc2ff);
}
/* Phase C: red badge when there is an unread @mention anywhere */
.tb-badge.mention,
.desk-icon .tb-badge.mention,
.sm-app .tb-badge.mention {
    background: #f23f43;
    color: #fff;
}
.tb-btn.running::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 3px;
    border-radius: 3px;
    background: var(--accent);
}
.tb-btn.active { background: rgba(255, 255, 255, 0.12); }
.tb-btn.active::after { width: 16px; }

/* ---- Virtual LAN taskbar toggle ---- */
.tb-vlan { position: relative; color: var(--win-text-2); }
.tb-vlan:hover { color: #fff; }
.tb-vlan.on { color: var(--accent); }
.tb-vlan.on:hover { color: #7fd4ff; }
.tb-vlan-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.tb-vlan.on .tb-vlan-dot {
    background: #2fd27a;
    box-shadow: 0 0 6px rgba(47, 210, 122, 0.9);
}

/* ---- Virtual LAN popover ---- */
.vlan-pop {
    position: absolute;
    bottom: calc(var(--taskbar-h) + 12px);
    left: 8px;
    z-index: 2600;
    width: 320px;
    max-width: calc(100vw - 24px);
    background: var(--win-bg-2);
    border: 1px solid var(--win-border-2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-win);
    padding: 14px;
    font-family: var(--desk-font);
    color: var(--win-text);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    pointer-events: none;
}
.vlan-pop.open { opacity: 1; transform: none; pointer-events: auto; }
.vp-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.vp-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--win-text);
}
.vp-title svg { color: var(--accent); flex: 0 0 auto; }
.vp-state {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--win-text-2);
}
.vp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    flex: 0 0 auto;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.vp-dot.on { background: #2fd27a; box-shadow: 0 0 8px rgba(47, 210, 122, 0.8); }
.vp-dot.err { background: #ff6b6b; }

.vp-status-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 8px;
    margin-bottom: 10px;
}
.vp-iplabel { font-size: 11.5px; color: var(--win-text-2); }
.vp-ip { font-size: 13px; font-weight: 600; color: #fff; font-family: Consolas, 'Cascadia Mono', monospace; }

.vp-toggle {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #04263a;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.vp-toggle:hover { background: #6fd0ff; }
.vp-toggle:active { transform: scale(0.98); }
.vp-toggle:disabled { background: rgba(255, 255, 255, 0.1); color: var(--win-text-2); cursor: wait; }
.vp-toggle.off { background: #e8493f; color: #fff; }
.vp-toggle.off:hover { background: #ff5c52; }

.vp-peers-wrap { margin-top: 12px; }
.vp-peers-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--win-text-2);
    margin-bottom: 6px;
}
.vp-peers-n {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    padding: 0 7px;
    font-size: 10.5px;
    line-height: 17px;
}
.vp-peers { list-style: none; margin: 0; padding: 0; max-height: 168px; overflow-y: auto; }
.vp-peers li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--win-border);
    margin-bottom: 5px;
    font-size: 12.5px;
}
.vp-p-dot { width: 7px; height: 7px; border-radius: 50%; background: #2fd27a; flex: 0 0 auto; }
.vp-p-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--win-text); }
.vp-p-meta { display: inline-flex; gap: 8px; font-size: 11px; color: var(--win-text-2); font-family: Consolas, monospace; }

/* ---- VLAN rooms (regional hosts) ---- */
.vp-rooms { margin-top: 14px; border-top: 1px solid var(--win-border); padding-top: 12px; }
.vp-rooms-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--win-text);
    margin-bottom: 8px;
}
.vp-mini {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--win-border);
    color: var(--win-text);
    font-size: 11.5px;
    font-family: inherit;
    padding: 4px 9px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s ease;
    white-space: nowrap;
}
.vp-mini:hover { background: rgba(111, 208, 255, 0.25); border-color: rgba(111, 208, 255, 0.5); }
.vp-mini:active { transform: scale(0.97); }
.vp-mini:disabled { opacity: 0.55; cursor: wait; }
.vp-mini.go { background: rgba(111, 208, 255, 0.9); color: #062033; border-color: transparent; font-weight: 600; }
.vp-mini.go:hover { background: #6fd0ff; }

.vp-room-list { display: flex; flex-direction: column; gap: 8px; }
.vp-room {
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 9px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vp-room.on { border-color: rgba(47, 210, 122, 0.45); background: rgba(47, 210, 122, 0.06); }
.vp-room-top { display: flex; align-items: center; gap: 7px; }
.vp-room-name { font-size: 12.5px; font-weight: 600; color: var(--win-text); }
.vp-room-badge {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(111, 208, 255, 0.18);
    color: #6fd0ff;
    text-transform: uppercase;
}
.vp-room-badge.join { background: rgba(255, 196, 111, 0.16); color: #ffc46f; }
.vp-room-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.25); margin-left: auto; flex: 0 0 auto; }
.vp-room-dot.on { background: #2fd27a; box-shadow: 0 0 7px rgba(47, 210, 122, 0.8); }
.vp-room-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 11px; color: var(--win-text-2); font-family: Consolas, monospace; }
.vp-room-meta .vp-room-sep { opacity: 0.5; }
.vp-room-ipcopy {
    background: rgba(111, 208, 255, 0.12);
    border: 1px solid rgba(111, 208, 255, 0.35);
    color: #6fd0ff;
    font-family: Consolas, monospace;
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.vp-room-ipcopy:hover { background: rgba(111, 208, 255, 0.28); border-color: rgba(111, 208, 255, 0.6); }
.vp-room-ipcopy:active { transform: scale(0.97); }
.vp-room-ipcopy.peer { background: rgba(47, 210, 122, 0.12); border-color: rgba(47, 210, 122, 0.35); color: #2fd27a; }
.vp-room-ipcopy.peer:hover { background: rgba(47, 210, 122, 0.28); border-color: rgba(47, 210, 122, 0.6); }
.vp-reach {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 11px;
    line-height: 1.45;
    padding: 6px 9px;
    border-radius: 7px;
    border: 1px solid transparent;
    cursor: default;
}
.vp-reach .vp-reach-ico { flex: 0 0 auto; font-size: 9px; line-height: 1.7; }
.vp-reach .vp-reach-txt { color: var(--win-text-2); }
.vp-reach .vp-reach-txt b { color: var(--win-text); font-weight: 600; }
.vp-reach.ok { background: rgba(47, 210, 122, 0.08); border-color: rgba(47, 210, 122, 0.30); }
.vp-reach.ok .vp-reach-ico { color: #2fd27a; }
.vp-reach.no { background: rgba(255, 111, 111, 0.08); border-color: rgba(255, 111, 111, 0.30); }
.vp-reach.no .vp-reach-ico { color: #ff6f6f; }
.vp-room-code {
    display: flex;
    gap: 5px;
    align-items: center;
}
.vp-room-code input {
    flex: 1;
    min-width: 0;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    color: var(--win-text);
    font-family: Consolas, monospace;
    font-size: 10.5px;
    padding: 4px 7px;
    outline: none;
}
.vp-room-actions { display: flex; gap: 6px; align-items: center; }
.vp-room-actions .vp-room-toggle {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--win-border);
    color: var(--win-text);
    font-size: 11.5px;
    font-weight: 600;
    font-family: inherit;
    padding: 5px 8px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s ease;
}
.vp-room-actions .vp-room-toggle:hover { background: rgba(255, 255, 255, 0.18); }
.vp-room-actions .vp-room-toggle:disabled { opacity: 0.55; cursor: wait; }
.vp-room-actions .vp-room-toggle.off { background: #e8493f; border-color: transparent; color: #fff; }
.vp-room-actions .vp-room-toggle.off:hover { background: #ff5c52; }
.vp-room-actions .vp-room-del {
    flex: 0 0 auto;
    background: rgba(232, 73, 63, 0.10);
    border: 1px solid rgba(232, 73, 63, 0.42);
    color: #ff9d97;
    font-size: 11px;
    line-height: 1;
    font-family: inherit;
    padding: 5px 8px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.vp-room-actions .vp-room-del:hover { background: rgba(232, 73, 63, 0.24); border-color: rgba(255, 92, 82, 0.7); color: #ffb3ad; }
.vp-room-actions .vp-room-del:active { transform: scale(0.96); }
.vp-room-actions .vp-room-del:disabled { opacity: 0.55; cursor: wait; }

.vp-join { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.vp-join-form { display: flex; flex-direction: column; gap: 7px; }
.vp-join-form input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--win-border);
    border-radius: 7px;
    color: var(--win-text);
    font-size: 11.5px;
    font-family: Consolas, monospace;
    padding: 6px 9px;
    outline: none;
}
.vp-join-form input:focus { border-color: rgba(111, 208, 255, 0.6); }
.vp-join-row { display: flex; gap: 6px; }
.vp-join-row input { flex: 1; }
.vp-join-msg { font-size: 11px; color: var(--win-text-2); min-height: 12px; }
.vp-join-msg.err { color: #ff8a80; }
.vp-join-msg.ok { color: #2fd27a; }
.vp-rooms-hint { margin: 10px 0 0; font-size: 10.5px; line-height: 1.45; color: var(--win-text-2); opacity: 0.75; }

.vp-install { padding: 2px 0; }
.vp-install p {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--win-text-2);
    margin: 0 0 10px;
}
.vp-install p b { color: var(--win-text); }
.vp-dl {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #04263a;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}
.vp-dl:hover { background: #6fd0ff; }
.vp-installed { margin-top: 10px; font-size: 11.5px; opacity: 0.8; }
.vp-outdated {
    border: 1px solid rgba(255, 190, 90, 0.35);
    background: rgba(255, 170, 60, 0.07);
    border-radius: 10px;
    padding: 12px;
}
.vp-outdated .vp-outd-title { font-weight: 700; color: #ffcf87; margin-bottom: 8px; }
.vp-outd-steps {
    margin: 0 0 10px;
    padding-left: 18px;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--win-text-2);
}
.vp-outd-steps b { color: var(--win-text); }
.vp-foot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--win-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10.5px;
    color: var(--win-text-2);
}
.vp-foot > span { flex: 1; min-width: 0; }
.vp-dlmini {
    flex: 0 0 auto;
    background: rgba(111, 208, 255, 0.14);
    border: 1px solid rgba(111, 208, 255, 0.4);
    color: #6fd0ff;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.vp-dlmini:hover { background: rgba(111, 208, 255, 0.28); border-color: rgba(111, 208, 255, 0.6); }
.vp-dlmini:active { transform: scale(0.97); }
.vp-dlmini:disabled { opacity: 0.6; cursor: wait; }

#startBtn { padding: 2px 4px; position: relative; transition: background 0.15s ease; gap: 6px; justify-content: flex-start; }
#startBtn:hover { background: rgba(255, 255, 255, 0.1); }
/* Start "morphs" into a profile segment: avatar + username + gear + sign out.
   The name/gear/sign-out collapse to zero width when the menu is closed.
   margin-right on the wrap leaves room for the online-count badge (fully right of the avatar). */
#startBtn.menu-open { background: rgba(255, 255, 255, 0.14); }
.start-avatar-wrap { position: relative; display: inline-flex; margin-right: 14px; }
.start-avatar-wrap .start-badges { position: absolute; inset: 0; pointer-events: none; }
.start-name {
    max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap;
    font-size: 12.5px; font-weight: 600; color: var(--win-text);
    transition: max-width 0.22s ease, opacity 0.18s ease;
}
#startBtn.menu-open .start-name { max-width: 280px; opacity: 1; }
.start-act {
    width: 26px; height: 26px; padding: 0; border: none; border-radius: 6px;
    background: transparent; color: var(--win-text-2); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    max-width: 0; opacity: 0; overflow: hidden; flex: 0 0 auto;
    transition: max-width 0.22s ease, opacity 0.18s ease, background 0.12s ease, color 0.12s ease;
}
#startBtn.menu-open .start-act { max-width: 26px; opacity: 1; }
.start-act:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
/* Gear sits in the expanded row, just left of Sign out */
.start-gear {
    width: 26px; height: 26px; padding: 0; border: none; border-radius: 6px;
    background: transparent; color: var(--win-text-2); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    max-width: 0; opacity: 0; overflow: hidden; flex: 0 0 auto;
    transition: max-width 0.22s ease, opacity 0.18s ease, background 0.12s ease, color 0.12s ease;
}
#startBtn.menu-open .start-gear { max-width: 26px; opacity: 1; }
.start-gear svg { width: 13px; height: 13px; }
.start-gear:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* Start avatar badges: live dot (top-left), online count (bottom-right), unread DMs (top-right) */
.start-badges { position: absolute; inset: 0; pointer-events: none; }
#startBadges[hidden] { display: none; }
.start-live-dot {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e81123;
    border: 2px solid rgba(18, 18, 18, 0.9);
    animation: livePulse 1.6s ease-out infinite;
}
.start-live-dot[hidden] { display: none; }
.start-count {
    position: absolute;
    bottom: -5px; /* aligned with the avatar's lowest point */
    right: -15px; /* fully right of the avatar, no overlap */
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    /* dark shadow + green glow = online-users indicator */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 7px rgba(96, 220, 130, 0.55);
    gap: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.start-count svg { flex: 0 0 auto; color: #c9c9ce; opacity: 0.95; text-shadow: none; }
.start-dm {
    position: absolute;
    top: -4px;
    right: -5px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    background: #e81123;
    border: 1.5px solid rgba(18, 18, 18, 0.9);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.start-dm[hidden] { display: none; }
/* Start button = user avatar (blue circle with initial, same square footprint as the old logo) */
.start-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex: 0 0 auto;
    /* v50: white/gray frame ring. Badges sit on top with their own chip
       background, so the ring reads as "cut" where a badge crosses it. */
    box-shadow: 0 0 0 2px rgba(232, 234, 238, 0.92), 0 0 0 3.5px rgba(8, 8, 10, 0.5);
}
/* v50: online-count badge breaks the ring — chip background behind the number */
.start-count {
    background: rgba(26, 26, 29, 0.95);
    border-radius: 8px;
    padding: 0 4px;
}

@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(232, 17, 35, 0.55); }
    100% { box-shadow: 0 0 0 8px rgba(232, 17, 35, 0); }
}

/* ---- Tray: online users (matches the search box) ---- */
#trayUsers {
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--win-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--win-text-2);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
#trayUsers:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--win-text);
}
#trayUsersCount {
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid var(--win-border);
    color: var(--win-text);
    font-size: 10.5px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---- Tray: mini music player (controls + title row, progress line below) ---- */
/* Engraved into the taskbar: no box, just a faint inset ring that wakes on hover */
.tray-media {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 36px;
    min-width: 0;
    padding: 4px 6px 5px 8px;
    border-radius: 8px;
    border: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    background: transparent;
    color: var(--win-text-2);
    cursor: default;
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease,
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease,
                background 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}
.tray-media:hover { background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); color: var(--win-text); }
/* Far-right of the taskbar; engraved in as if part of it — max 1/5 of screen width */
.tray-media { max-width: min(420px, calc(100vw / 5)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), inset 0 1px 3px rgba(0, 0, 0, 0.32); }
.tray-media-row { display: flex; align-items: center; gap: 3px; min-width: 0; }
/* Volume button — a vertical slider popup opens ABOVE it (never spills past the ×) */
.tray-media-vol { position: relative; display: inline-flex; align-items: center; flex: 0 0 auto; }
.vol-pop {
    position: absolute; bottom: calc(100% + 8px); right: -2px;
    width: 26px; height: 104px; padding: 8px 0;
    background: rgba(17, 19, 24, 0.97);
    border: 1px solid var(--win-border);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    z-index: 30;
}
.vol-pop[hidden] { display: none; }
.vol-pop input[type=range] {
    -webkit-appearance: none; appearance: none;
    position: absolute; left: 50%; top: 50%;
    width: 84px; height: 3px; margin: 0;
    transform: translate(-50%, -50%) rotate(-90deg);
    border-radius: 2px; background: rgba(255, 255, 255, 0.22);
    outline: none; cursor: pointer;
}
.vol-pop input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--win-text); border: none; transition: transform 0.12s ease;
}
.vol-pop input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.3); }
.vol-pop input[type=range]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--win-text); border: none; }
.vol-pop input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.22); }
.tray-btn.muted { color: #e0655f; }
/* Mobile-only search bar rendered inside the start menu (hidden on desktop) */
.sm-search { display: none; }
/* Hidden until music actually plays (or until the user dismisses it) — animated collapse */
.tb-media-hidden {
    display: flex;
    max-width: 0;
    min-width: 0;
    width: 0;
    padding: 0;
    opacity: 0;
    transform: translateX(18px);
    overflow: hidden;
    pointer-events: none;
    background: transparent;
    box-shadow: none;
}
/* Spacers push the media bar toward the middle while respecting other taskbar items */
.tb-spacer { flex: 1 1 0; min-width: 0; }
.tray-btn {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.tray-btn.tray-btn-big { width: 32px; height: 32px; }
.tray-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.tray-media-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 11.5px;
    color: var(--win-text-2);
    white-space: nowrap;
    overflow: hidden;
    padding: 0 4px;
    cursor: pointer;
}
.tray-media-title:hover { color: var(--win-text); }
/* Track title that overflows the box ping-pongs instead of clipping (distance/duration set inline by JS) */
.tray-media-title .tm-in { display: inline-block; white-space: nowrap; padding-right: 14px; will-change: transform; }
.tray-media-title.tm-overflow .tm-in { animation: tmMarquee var(--mq-dur, 8s) ease-in-out infinite alternate; }
@keyframes tmMarquee {
    0%   { transform: translateX(0); }
    100% { transform: translateX(calc(-1 * var(--mq-dist, 120px))); }
}
.tray-close {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-left: 2px;
    border: none;
    background: transparent;
    border-radius: 5px;
    color: var(--win-text-2);
    font-size: 13px;
    line-height: 1;
    opacity: 0.5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.tray-close:hover { background: rgba(255, 255, 255, 0.14); color: #fff; opacity: 1; }
/* Progress line under the controls (click to seek, hover for thumb + time) */
.tray-progress {
    flex: 0 0 auto;
    position: relative;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.14);
    cursor: pointer;
    transition: background 0.15s ease;
}
.tray-progress:hover { background: rgba(255, 255, 255, 0.22); }
.tray-progress[hidden] { display: none; }
.tray-progress i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
}
.tray-progress .tray-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.tray-progress:hover .tray-thumb { opacity: 1; }
.tray-progress .tray-time {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 15, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 10.5px;
    color: var(--win-text);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.tray-progress:hover .tray-time { opacity: 1; }

/* ---------- Start menu ----------
   Anchored flush to the taskbar avatar: the start button "morphs" into the menu. */
#startMenu {
    position: absolute;
    left: 0;
    bottom: calc(var(--taskbar-h) + 6px);
    width: 640px;
    max-width: calc(100vw - 24px);
    background: rgba(28, 28, 28, 0.88);
    backdrop-filter: blur(44px) saturate(1.4);
    -webkit-backdrop-filter: blur(44px) saturate(1.4);
    border: 1px solid var(--win-border-2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-win);
    padding: 22px;
    z-index: 2100;
    display: none;
}
/* Open: slides in left → right · Close: pushed back right → left (JS adds .closing) */
#startMenu.open {
    display: block;
    animation: smIn 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}
#startMenu.open.closing {
    animation: smOut 0.14s ease-in forwards;
    pointer-events: none;
}
/* PC: rises up from the taskbar (bottom → top) and falls back down */
@keyframes smIn {
    from { opacity: 0; transform: translateY(26px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes smOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(60vh); } /* full exit, Win11-style fast snap */
}

/* In-menu settings overlay (gear badge on the avatar) — expands over the whole menu */
#smSettings {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    background: rgba(28, 28, 28, 0.97);
    backdrop-filter: blur(44px) saturate(1.4);
    -webkit-backdrop-filter: blur(44px) saturate(1.4);
    border-radius: var(--radius-lg);
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}
#smSettings[hidden] { display: none; }
#smSettings.show { opacity: 1; transform: none; pointer-events: auto; }
.sm-settings-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sm-setback {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    color: var(--win-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.12s ease;
}
.sm-setback:hover { background: rgba(102, 139, 255, 0.28); }
.sm-settings-title { font-size: 13px; font-weight: 600; color: var(--win-text); }
.sm-settings-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px 18px 20px;
}
.smset-sec {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.smset-sec:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.smset-label {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--win-text-2);
    margin: 0 0 8px 0;
}
.smset-profile { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.smset-av {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.smset-av img { width: 100%; height: 100%; object-fit: cover; }
.smset-av-ic { color: #fff; font-size: 18px; font-weight: 600; line-height: 1; }
.smset-av-cam {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.smset-av:hover .smset-av-cam { opacity: 1; }
.smset-pinfo { min-width: 0; }
.smset-pinfo .nm { font-size: 13.5px; font-weight: 600; color: var(--win-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smset-pinfo .sub { font-size: 11px; color: var(--win-text-2); }
.smset-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.smset-btn {
    padding: 6px 14px;
    border: 1px solid var(--win-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--win-text);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.12s ease;
}
.smset-btn:hover { background: rgba(102, 139, 255, 0.22); }
.smset-btn.smset-danger { background: rgba(232, 17, 35, 0.12); border-color: rgba(232, 17, 35, 0.3); color: #ff8a94; }
.smset-btn.smset-danger:hover { background: rgba(232, 17, 35, 0.24); color: #ffb3ba; }
.smset-field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
.smset-field:last-child { margin-bottom: 0; }
.smset-field > label { font-size: 12px; color: var(--win-text-2); font-weight: 500; }
.smset-sel {
    width: 100%;
    padding: 6px 8px;
    border-radius: 7px;
    border: 1px solid var(--win-border);
    background: rgba(20, 20, 22, 0.9);
    color: var(--win-text);
    font-family: inherit;
    font-size: 12.5px;
    outline: none;
    cursor: pointer;
}
.smset-sel:focus { border-color: var(--accent); }
.smset-field input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.smset-radio { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--win-text); cursor: pointer; padding: 2px 0; }
.smset-radio input { accent-color: var(--accent); cursor: pointer; }
.smset-sub { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); display: flex; flex-direction: column; gap: 4px; }
.smset-sub label { font-size: 11.5px; color: var(--win-text-2); }
.smset-sub[hidden] { display: none; }
.smset-keyrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 8px; margin: 0 -8px; border-radius: 8px; transition: background .15s ease, box-shadow .15s ease; }
.smset-keyrow:hover { background: rgba(102, 139, 255, 0.10); box-shadow: inset 0 0 0 1px rgba(102, 139, 255, 0.14), 0 2px 10px rgba(0, 0, 0, .25); }
.smset-keyrow span { font-size: 12.5px; color: var(--win-text); }
.smset-key {
    min-width: 52px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--win-border);
    background: rgba(255, 255, 255, 0.07);
    color: var(--win-text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease;
}
.smset-key:hover { background: rgba(102, 139, 255, 0.22); }
.smset-wait { font-size: 12px; color: var(--win-text-2); padding: 4px 0; }
/* per-sound rows (on/off + level + ▶ preview) */
.smset-snd-row { display: flex; align-items: center; gap: 8px; padding: 3px 8px; margin: 0 -8px; border-radius: 8px; transition: background .15s ease, box-shadow .15s ease; }
.smset-snd-row:hover { background: rgba(102, 139, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(102, 139, 255, 0.16), 0 2px 10px rgba(0, 0, 0, .28); }
.smset-snd-on { flex: 1 1 auto; min-width: 0; }
.smset-snd-row input[type="range"] { flex: 0 1 90px; min-width: 56px; width: auto; }
.smset-snd-play { flex: 0 0 auto; min-width: 32px; padding: 3px 8px; font-size: 11px; }

/* Two-column body: profile + people on the left, apps/search results on the right */
.sm-body {
    display: grid;
    grid-template-columns: 235px minmax(0, 1fr);
    gap: 16px;
    height: clamp(320px, calc(100vh - var(--taskbar-h) - 90px), 520px);
}
.sm-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    border-right: 1px solid var(--win-border);
    padding-right: 14px;
}
.sm-right { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.sm-profile {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 12px;
}
.sm-profile .sm-user { width: 100%; }
.sm-user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sm-user-nm { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-user-sub { font-size: 11px; color: var(--win-text-2); }
.sm-gear {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    color: var(--win-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
}
.sm-gear:hover { background: rgba(102, 139, 255, 0.28); color: #fff; }
.sm-profile-acts { display: flex; gap: 6px; margin-top: 10px; }
.sm-pbtn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--win-border);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 7px;
    color: var(--win-text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
}
.sm-pbtn:hover { background: rgba(102, 139, 255, 0.22); color: #fff; }
.sm-section-label { margin: 0 4px 4px; font-size: 12px; }
.sm-users { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1 1 auto; min-height: 56px; }
/* Left column order: Users list first, profile pinned to the bottom */
.sm-left .sm-profile { order: 9; flex: 0 0 auto; margin-top: auto; }
/* Profile as one compact row: avatar (with gear badge at bottom-left) + name, then Sign out */
.sm-profile { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.sm-profile .sm-user { display: contents; }
.sm-profile .sm-profile-acts { display: contents; }
.sm-profile .sm-av-wrap { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
.sm-profile .av { flex: 0 0 auto; width: 40px; height: 40px; font-size: 17px; }
.sm-profile .sm-user-meta { flex: 1 1 auto; min-width: 0; gap: 1px; }
.sm-profile .sm-pbtn { flex: 0 0 auto; width: 30px; height: 30px; }
/* Change avatar / change password now live in the in-menu settings panel */
.sm-legacy { display: none !important; }
/* Profile row merged into the taskbar start button (avatar + name + sign out + gear) */
.sm-profile { display: none; }
/* Gear: small badge just outside the avatar circle, bottom-left (Discord-style) */
.sm-gear {
    position: absolute;
    left: -3px;
    bottom: -3px;
    z-index: 2;
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid rgba(30, 30, 32, 0.92);
    background: #2c2c30;
    color: var(--win-text-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}
.sm-gear svg { width: 10px; height: 10px; }
.sm-gear:hover { color: #fff; background: #3a3a40; transform: scale(1.08); }
/* Section counter chip (e.g. Users 1/13) */
.sm-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--win-text-2);
    background: rgba(255, 255, 255, 0.07);
    padding: 1px 8px;
    border-radius: 9px;
}
/* hidden sections in the left column (author display rules beat the hidden attr) */
.sm-section-label[hidden], .sm-users[hidden] { display: none; }
/* Slim themed scrollbars inside the start menu */
.sm-users, .sm-results, #startMenu { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
#startMenu ::-webkit-scrollbar { width: 8px; height: 8px; }
#startMenu ::-webkit-scrollbar-track { background: transparent; }
#startMenu ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}
#startMenu ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid transparent;
    background-clip: content-box;
}
.sm-apps-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sm-results { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
#smResults[hidden] { display: none; }
.sr-head {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--win-text-2);
    padding: 7px 8px 2px;
}
/* Desktop: the in-menu search bar stays hidden — it is mobile-only (see the ≤768px block) */
.sm-search {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--win-border);
    border-radius: 20px;
    color: var(--win-text-2);
    font-size: 13px;
}
.sm-search input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--win-text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}
.sm-section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--win-text);
    margin: 20px 4px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 4px;
    min-height: 0;
    overflow-y: auto;
}
.sm-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
    text-align: center;
    min-width: 0;
    transition: background 0.12s ease;
}
.sm-app:hover { background: rgba(255, 255, 255, 0.1); }
.sm-app .ic { font-size: 30px; line-height: 1; }
.sm-app .lb { font-size: 12px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-app.soon { opacity: 0.62; }

.sm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--win-border);
    margin-top: 18px;
    padding-top: 14px;
}
.sm-user { display: flex; align-items: center; gap: 10px; color: var(--win-text); }
.sm-user .av {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
}
.sm-user .nm { font-size: 13px; font-weight: 500; }
.sm-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    color: var(--win-text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}
.sm-logout:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- Windows ---------- */
.win {
    position: absolute;
    display: flex;
    flex-direction: column;
    background: var(--win-bg);
    border: 1px solid var(--win-border-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow-win);
    min-width: 340px;
    min-height: 220px;
    overflow: hidden;
    animation: winOpen 0.16s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.win.closing { animation: winClose 0.13s ease forwards; }
.win.minimized { display: none; }
.win.maximized { border-radius: 0; border-left: none; border-right: none; border-bottom: none; }
.win.maximized .win-resizer { display: none; }

@keyframes winOpen { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes winClose { to { opacity: 0; transform: scale(0.96) translateY(10px); } }

.win-titlebar {
    height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    background: var(--win-bg-2);
    position: relative;
    user-select: none;
    touch-action: none;
}
.win-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    font-size: 13px;
    color: var(--win-text-2);
    flex: 1;
    height: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.win-title .win-icon { font-size: 16px; line-height: 1; }

.win-controls { display: flex; height: 100%; align-items: stretch; }
.win-ctrl {
    width: 46px;
    border: none;
    background: transparent;
    color: var(--win-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s ease;
}
.win-ctrl svg { width: 11px; height: 11px; display: block; }
.win-ctrl:hover { background: rgba(255, 255, 255, 0.1); }
.win-ctrl.close:hover { background: #e81123; }
.win-ctrl.close:hover svg path { stroke: #fff; }
/* Extra title-bar buttons (retry ↻ + Desktop Mode) */
.win-extras { display: flex; height: 100%; align-items: stretch; }
.win-ctrl-retry[hidden] { display: none; }
/* Pop-out mode ON — the ↗ button shows its active state */
.win-ctrl-popout.active { background: rgba(76, 194, 255, 0.14); }
.win-ctrl-popout.active svg { color: var(--accent, #4cc2ff); }

.win-body { flex: 1 1 auto; min-height: 0; position: relative; background: var(--win-bg); }
.win-mount { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; }
/* Dark Fluent-style scrollbars inside window bodies */
.win-mount { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }
.win-mount::-webkit-scrollbar { width: 10px; height: 10px; }
.win-mount::-webkit-scrollbar-track { background: transparent; }
.win-mount::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
.win-mount::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); background-clip: content-box; }

.win-resizer { position: absolute; z-index: 6; touch-action: none; }
.win-resizer[data-dir="n"]  { top: -4px; left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.win-resizer[data-dir="s"]  { bottom: -4px; left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.win-resizer[data-dir="e"]  { right: -4px; top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.win-resizer[data-dir="w"]  { left: -4px; top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.win-resizer[data-dir="ne"] { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.win-resizer[data-dir="nw"] { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.win-resizer[data-dir="se"] { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.win-resizer[data-dir="sw"] { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }

.win-placeholder, .win-error {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 32px;
    color: var(--win-text-2);
}
.win-placeholder .ph-ic { font-size: 54px; }
.win-placeholder h3, .win-error h3 { color: var(--win-text); font-size: 20px; font-weight: 600; }
.win-placeholder p { max-width: 420px; font-size: 13.5px; line-height: 1.5; }
.win-error h3 { color: #ff9d9d; }

/* ============================================================
   Scoped overrides: relocate existing app DOM into windows.
   These target IDs inside .win-mount, so they only affect
   apps opened in the desktop (not the old hidden dashboard).
   ============================================================ */

/* ---- AI Chat ---- */
/* The chat's fullscreen blurred backdrop must never render in desktop mode
   (it is the "second blurred window" behind the chat) */
body.desktop-mode .ai-chat-overlay { display: none !important; }

.win-mount #aiChatModal {
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: var(--win-bg); /* no second dark shade showing around the app */
}
.win-mount #aiChatModal .modal-header { display: none !important; }
.win-mount #aiChatModal .modal-body { height: 100% !important; padding: 0 !important; }
/* Duplicate inner header (☰ + "New Chat") — the window titlebar already covers this */
.win-mount #aiChatModal .chat-main-header { display: none !important; }
.win-mount .ai-chat-app { height: 100% !important; border-radius: 0 !important; }

/* Re-theme AI Chat from its indigo/slate palette to the desktop Fluent palette */
.win-mount #aiChatModal {
    --chat-bg-primary: var(--win-bg);
    --chat-bg-secondary: var(--win-bg-2);
    --chat-bg-tertiary: #262626;
    --chat-border-color: var(--win-border);
    --chat-text-primary: var(--win-text);
    --chat-text-secondary: var(--win-text-2);
    --chat-text-muted: #8a8a8a;
    --chat-primary: var(--accent);
    --chat-primary-hover: var(--accent-strong);
    font-family: var(--desk-font);
}

/* ai-chat.css is injected at runtime (loads AFTER this file) and hardcodes the
   old indigo/violet palette on a few elements — neutralize those inside windows */
.win-mount #aiChatModal .conversation-item.active {
    background: rgba(255, 255, 255, 0.10);
    color: var(--win-text);
}
.win-mount #aiChatModal .conversation-item.active .conv-title,
.win-mount #aiChatModal .conversation-item.active .conv-preview { color: var(--win-text); }
.win-mount #aiChatModal .conversation-item.active .conv-time { color: var(--win-text-2); }
.win-mount #aiChatModal .conversation-item.active .conv-icon {
    background: rgba(255, 255, 255, 0.12);
    color: var(--win-text);
}
.win-mount #aiChatModal .message.user .message-avatar { background: var(--accent); }
.win-mount #aiChatModal .message.assistant .message-avatar { color: var(--accent); }
.win-mount #aiChatModal .token-bar-fill { background: var(--accent); }
.win-mount #aiChatModal .empty-chat-icon { background: rgba(255, 255, 255, 0.06); color: var(--accent); }
.win-mount .new-chat-btn {
    background: var(--accent);
    box-shadow: none;
    border-radius: 8px;
}
.win-mount .new-chat-btn:hover {
    background: var(--accent-strong);
    transform: none;
    box-shadow: none;
}
.win-mount .ai-chat-sidebar .active,
.win-mount .sidebar-chat-item.active,
.win-mount .chat-msg.user .chat-bubble,
.win-mount .chat-input-container textarea:focus,
.win-mount .chat-input-container input:focus {
    border-color: var(--accent);
}
.win-mount .chat-send-btn,
.win-mount .ai-chat-send-btn { background: var(--accent); }
.win-mount .chat-send-btn:hover, .win-mount .ai-chat-send-btn:hover { background: var(--accent-strong); }

/* ---- Reaction Test ---- */
.win-mount #reactionGameModal {
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
}
.win-mount #reactionGameModal .modal-header { display: none !important; }
.win-mount #reactionGameModal .modal-body { height: 100% !important; overflow: auto !important; }

/* ---- Chess ---- */
.win-mount #chessView { height: 100% !important; max-height: none !important; display: flex !important; }

/* Re-theme Chess from its indigo/slate palette to the desktop Fluent palette
   (custom properties here win the cascade for everything inside the window) */
.win-mount #chessView {
    --primary-color: var(--accent);
    --primary-hover: var(--accent-strong);
    --primary-light: var(--accent-soft);
    --bg-secondary: var(--win-bg-2);
    --bg-tertiary: #1a1a1a;
    --text-primary: var(--win-text);
    --text-secondary: var(--win-text-2);
    --text-muted: #8f8f8f;
    --border-color: var(--win-border-2);
    background: var(--win-bg);
    font-family: var(--desk-font);
}

/* Glass panels -> solid Fluent surfaces (match Files/Music/Video) */
.win-mount #chessView .chess-settings-panel.visible,
.win-mount #chessView .chess-info-panel,
.win-mount #chessView .lobby-card,
.win-mount #chessView .glass-panel {
    background: var(--win-bg-2);
    backdrop-filter: none;
    border-color: var(--win-border);
}

/* Primary actions: solid accent, no green gradients */
.win-mount #chessView .chess-settings-start-btn,
.win-mount #chessView .lobby-create-btn,
.win-mount #chessView .lobby-join-btn,
.win-mount #chessView .waiting-game-join-btn {
    background: var(--accent);
    color: #06202f;
    box-shadow: none;
}
.win-mount #chessView .chess-settings-start-btn:hover,
.win-mount #chessView .lobby-create-btn:hover,
.win-mount #chessView .lobby-join-btn:hover,
.win-mount #chessView .waiting-game-join-btn:hover {
    background: var(--accent-strong);
    filter: none;
    transform: none;
    box-shadow: none;
}
.win-mount #chessView .chess-settings-start-btn:disabled {
    background: var(--win-bg-2);
    color: var(--win-text-2);
    border: 1px solid var(--win-border-2);
}
/* "Available Games" ships with an inline purple gradient - override it */
.win-mount #chessView #waitingGamesToggleBtn {
    background: var(--accent) !important;
    color: #06202f !important;
}

/* Avatars: drop the purple gradient tail */
.win-mount #chessView .chess-player-avatar,
.win-mount #chessView .lobby-game-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}
.win-mount #chessView .theme-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Dialogs + toast are appended to <body> (outside the window, z 2500) -
   they must render ABOVE the window, same fix class as the reaction test */
.chess-dialog-overlay,
.chess-promotion-dialog,
.chess-toast { z-index: 3000; }
.chess-dialog { background: var(--win-bg-2); border-color: var(--win-border-2); }
.chess-dialog-btn.primary { background: var(--accent); color: #06202f; }
.chess-promotion-dialog { background: var(--win-bg-2); border-color: var(--win-border-2); }
.chess-promotion-dialog button { background: var(--win-bg); border-color: var(--win-border-2); }

/* Chess's standalone-page mobile bottom nav (position:fixed) would sit on top
   of the desktop taskbar - hide it and keep the compact page header instead
   (chess.css hides that header at <=768px; restore it inside the window) */
.win-mount #chessView .chess-mobile-bottom-nav { display: none !important; }
@media (max-width: 768px) {
    .win-mount #chessView .chess-page-header { display: flex !important; }
    .win-mount #chessView .chess-view-inner { padding-bottom: 0 !important; }
    .win-mount #chessView .chess-page-header h2 { display: none; }
    .win-mount #chessView .chess-page-header-actions { flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
    .win-mount #chessView .chess-settings-panel.visible { padding: 8px 10px; }
    .win-mount #chessView .chess-settings-row { gap: 8px; }
}

/* ---- Files (Fluent / Explorer feel, matching the dark theme) ---- */
.fw-wrap { height: 100%; display: flex; flex-direction: column; background: var(--win-bg); overflow: hidden; }
.fw-wrap .active-uploads { flex: 0 0 auto; }
.fw-wrap .files-container {
    flex: 1 1 auto;
    min-height: 0;
    max-width: none !important;
    margin: 0 !important;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    border: none;
    overflow-y: auto !important; /* base .files-container is overflow:hidden — this makes the list scroll inside the window */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
.fw-wrap .files-container::-webkit-scrollbar { width: 10px; }
.fw-wrap .files-container::-webkit-scrollbar-track { background: transparent; }
.fw-wrap .files-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
/* Toolbar — slim, sticky, Explorer-style */
.fw-wrap .files-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--win-bg-2);
    border-bottom: 1px solid var(--win-border);
    padding: 10px 14px;
    gap: 10px;
}
.fw-wrap .files-search {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 6px 12px;
    max-width: 380px;
    flex: 1;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.fw-wrap .files-search:focus-within {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
}
.fw-wrap .files-search svg { color: var(--win-text-2); width: 16px; height: 16px; flex: 0 0 auto; }
.fw-wrap .files-search input { color: var(--win-text); font-size: 13px; padding: 4px 0; }
.fw-wrap .files-search input::placeholder { color: var(--win-text-2); opacity: 0.75; }

/* Browse Files button — solid accent, no gradient */
.fw-wrap .upload-btn {
    background: var(--accent);
    color: #06202f;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    box-shadow: none;
}
.fw-wrap .upload-btn:hover { transform: none; box-shadow: none; background: var(--accent-strong); }

/* Sort control */
.fw-wrap .sort-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--win-text-2);
    font-size: 13px;
}
.fw-wrap .sort-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--win-text); }
.fw-wrap .sort-menu {
    background: var(--win-bg-2);
    border: 1px solid var(--win-border-2);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    min-width: 170px;
}
.fw-wrap .sort-option { color: var(--win-text); font-size: 13px; padding: 9px 14px; }
.fw-wrap .sort-option:hover { background: rgba(255, 255, 255, 0.08); }

/* Filter row */
.fw-wrap .files-filters { padding: 10px 14px; background: var(--win-bg); border-bottom: 1px solid var(--win-border); gap: 10px; }
.fw-wrap .filter-label { color: var(--win-text-2); font-size: 12.5px; }
.fw-wrap .filter-select {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    color: var(--win-text);
    padding: 7px 30px 7px 10px;
    font-size: 12.5px;
}
.fw-wrap .filter-select:hover { border-color: var(--win-border-2); }
.fw-wrap .filter-select:focus { outline: none; border-color: var(--accent); }

/* File rows — Explorer list style */
.fw-wrap .files-list { padding: 6px 10px; }
.fw-wrap .file-row { padding: 8px 10px; gap: 12px; border-radius: 6px; }
.fw-wrap .file-row:hover { background: rgba(255, 255, 255, 0.05); }
.fw-wrap .file-icon {
    width: 40px;
    height: 40px;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 8px;
}
.fw-wrap .file-name { font-size: 13.5px; font-weight: 500; color: var(--win-text); margin-bottom: 2px; }
.fw-wrap .file-meta { font-size: 12px; color: var(--win-text-2); }
.fw-wrap .user-badge {
    background: var(--accent-soft);
    color: #bfe6ff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11.5px;
}
.fw-wrap .user-badge.other { background: rgba(255, 255, 255, 0.07); color: var(--win-text-2); }
.fw-wrap .file-action-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--win-text-2);
}
.fw-wrap .file-action-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--win-text); }
.fw-wrap .file-action-btn.delete:hover { background: rgba(232, 17, 35, 0.9); color: #fff; }
/* Action buttons: subtle until the row is hovered (pointer devices only) */
@media (hover: hover) {
    .fw-wrap .file-row .file-actions { opacity: 0.45; transition: opacity 0.12s ease; }
    .fw-wrap .file-row:hover .file-actions { opacity: 1; }
}

/* Empty state / loader */
.fw-wrap .empty-state { color: var(--win-text-2); padding: 48px 20px; }
.fw-wrap .empty-state h3 { color: var(--win-text); font-size: 16px; }
.fw-wrap .empty-state svg { color: var(--win-text-2); }
.fw-wrap .infinite-scroll-loader { color: var(--win-text-2); }
.fw-wrap .loader-spinner { border-color: rgba(255, 255, 255, 0.15); border-top-color: var(--accent); }
.fw-wrap .end-of-results { color: var(--win-text-2); border-color: var(--win-border); }
.fw-wrap .files-loaded-count { color: var(--win-text-2); }

/* ---- Music window ---- */
.win-mount #tab-music { display: block !important; height: 100%; overflow: hidden; }
.win-mount .music-container {
    height: 100%;
    overflow-y: auto;
    padding: 14px 16px 118px; /* real margins + room for the docked player bar */
}
/* The bottom player is fixed to the viewport in the old dashboard; dock it to the window */
.win-mount .music-bottom-player-container {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 20;
}

/* Theme: re-map the old indigo/blue dashboard look to the dark gray + accent scheme */
.win-mount .music-container { gap: 14px; }

/* Toolbar */
.win-mount .music-search {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 7px 12px;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.win-mount .music-search:focus-within { border-color: var(--accent); background: rgba(0, 0, 0, 0.4); }
.win-mount .music-search svg { color: var(--win-text-2); }
.win-mount .music-search input { color: var(--win-text); }
.win-mount .music-search input::placeholder { color: var(--win-text-2); opacity: 0.75; }
.win-mount .music-stats { color: var(--win-text-2); }
.win-mount .music-view-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 8px 14px;
    color: var(--win-text-2);
}
.win-mount .music-view-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--win-border-2); color: var(--win-text); }
.win-mount .music-view-btn.upload-btn { background: var(--accent); border-color: transparent; color: #06202f; font-weight: 600; }
.win-mount .music-view-btn.upload-btn:hover { background: var(--accent-strong); transform: none; box-shadow: none; color: #06202f; }
/* v59: canonical Upload button inside app windows (Music toolbar and any
   other .upload-btn not covered by .fw-wrap) — same solid accent look as
   the Files button, matching dashboard.css on the site. Previously the
   Music button had NO styles in the app, so it rendered as a plain
   browser button. */
.win-mount .upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    min-height: 36px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: #06202f;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.win-mount .upload-btn:hover { background: var(--accent-strong); transform: none; box-shadow: none; color: #06202f; }
.win-mount .upload-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.win-mount .music-view-switcher { background: rgba(0, 0, 0, 0.28); border-color: var(--win-border); border-radius: 6px; }
.win-mount .music-view-switch-btn { color: var(--win-text-2); border-radius: 5px; }
.win-mount .music-view-switch-btn.active { background: rgba(255, 255, 255, 0.14); color: var(--win-text); }
.win-mount .music-view-switch-btn:hover:not(.active) { color: var(--win-text); }
.win-mount .files-tabs { background: rgba(0, 0, 0, 0.28); border-color: var(--win-border); border-radius: 6px; }
.win-mount .files-tab { color: var(--win-text-2); border-radius: 5px; }
.win-mount .files-tab.on { background: rgba(255, 255, 255, 0.14); color: var(--win-text); }
.win-mount .files-tab:hover:not(.on) { color: var(--win-text); }

/* Track list */
.win-mount .music-track-list {
    background: var(--win-bg-2);
    border-color: var(--win-border);
    border-radius: 8px;
}
.win-mount .music-track-list-header { color: var(--win-text-2); border-bottom-color: var(--win-border); }
.win-mount .music-track-row:hover { background: rgba(255, 255, 255, 0.05); }
.win-mount .music-track-row.playing { background: var(--accent-soft); border-bottom-color: var(--accent); }
.win-mount .music-track-num { color: var(--win-text-2); }
.win-mount .music-track-title { color: var(--win-text); }
.win-mount .music-track-row.playing .music-track-title,
.win-mount .music-track-row.playing .music-track-num { color: #82d3ff; }
.win-mount .music-track-artist { color: var(--win-text-2); opacity: 0.85; }
.win-mount .music-track-duration, .win-mount .music-track-album { color: var(--win-text-2); opacity: 0.7; }
.win-mount .music-track-genre { background: rgba(255, 255, 255, 0.06); color: var(--win-text-2); }
.win-mount .music-track-thumb-placeholder { background-color: var(--accent-soft); }
.win-mount .music-add-playlist-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--win-border);
    color: var(--win-text-2);
}
.win-mount .music-add-playlist-btn:hover { background: var(--accent); border-color: transparent; color: #06202f; }
.win-mount .music-delete-btn { color: var(--win-text-2); opacity: 0.7; }
.win-mount .music-delete-btn:hover { background: rgba(232, 17, 35, 0.2); color: #ff7d87; }

/* Library groups */
.win-mount .music-artist-group { background: var(--win-bg-2); border-color: var(--win-border); }
.win-mount .music-artist-header { background: rgba(255, 255, 255, 0.04); }
.win-mount .music-artist-header:hover { background: rgba(255, 255, 255, 0.08); }
.win-mount .music-artist-avatar { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
.win-mount .music-artist-name { color: var(--win-text); }
.win-mount .music-artist-count { color: var(--win-text-2); opacity: 0.8; }
.win-mount .music-artist-chevron { color: var(--win-text-2); }
.win-mount .music-album-group { border-top-color: var(--win-border); }
.win-mount .music-album-header { background: rgba(0, 0, 0, 0.2); color: var(--win-text-2); }

/* Tracks toolbar row (Play all / Play selected / filters) */
.win-mount .music-tracks-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--win-border);
    border-radius: 8px;
    padding: 8px 10px;
}
.win-mount .music-tracks-bar.inline { background: transparent; border: none; padding: 0 0 10px; }
.win-mount .mtb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--win-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--win-text-2);
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.win-mount .mtb-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--win-text); }
.win-mount .mtb-btn.primary { background: var(--accent); border-color: transparent; color: #06202f; font-weight: 600; }
.win-mount .mtb-btn.primary:hover { background: var(--accent-strong); color: #06202f; }
.win-mount .mtb-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--win-text-2);
    cursor: pointer;
    user-select: none;
}
.win-mount .mtb-check input, .win-mount .music-track-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.win-mount .mtb-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    color: var(--win-text-2);
    border-radius: 6px;
    padding: 7px 8px;
    font-size: 12.5px;
    cursor: pointer;
}
.win-mount .mtb-select:focus { border-color: var(--accent); outline: none; }
.win-mount .mtb-select option { background: var(--win-bg-2); color: var(--win-text); }

/* Track rows: checkbox column, uploader line, inline play button */
.win-mount .music-track-list-header,
.win-mount .music-track-row {
    grid-template-columns: 28px 36px 36px minmax(0, 1fr) minmax(0, 1fr) 60px 100px 70px 96px;
}
.win-mount .music-track-check { display: flex; align-items: center; justify-content: center; }
.win-mount .music-track-row.selected { background: rgba(76, 194, 255, 0.08); }
.win-mount .music-track-title { white-space: normal; overflow: visible; line-height: 1.3; }
.win-mount .music-track-uploader {
    font-size: 10.5px;
    font-weight: 400;
    color: var(--win-text-2);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.win-mount .music-play-row-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--win-text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.12s ease;
}
.win-mount .music-play-row-btn:hover { background: var(--accent); color: #06202f; }
.win-mount .music-track-row.playing .music-play-row-btn { color: #82d3ff; }

/* Playlists: sections, lock toggle, shared cards, inline list */
.win-mount .music-pl-heading {
    color: var(--win-text);
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 12px;
}
.win-mount .music-pl-section + .music-pl-section { margin-top: 22px; }
.win-mount .music-playlist-card { position: relative; }
.win-mount .music-playlist-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.win-mount .music-lock-toggle {
    border: none;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1;
    padding: 4px 7px;
    cursor: pointer;
    color: var(--win-text);
    transition: background 0.12s ease;
}
.win-mount .music-lock-toggle:hover { background: var(--accent-soft); }
.win-mount .music-lock-toggle.static { cursor: default; opacity: 0.8; }
.win-mount .music-pl-remove {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--win-text-2);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.12s ease;
}
.win-mount .music-pl-remove:hover { background: rgba(232, 17, 35, 0.2); color: #ff7d87; }
.win-mount .music-playlist-tracks { margin-top: 20px; }
.win-mount .music-dialog-hint { color: var(--win-text-2); font-size: 12px; opacity: 0.8; }

/* Playlists (cards) */
.win-mount .music-playlist-card { background: rgba(255, 255, 255, 0.045); border-color: var(--win-border); }
.win-mount .music-playlist-card:hover { border-color: rgba(76, 194, 255, 0.4); }
.win-mount .music-playlist-card::before { background: linear-gradient(135deg, var(--accent-soft), transparent); }
.win-mount .music-playlist-icon { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
.win-mount .music-playlist-name { color: var(--win-text); }
.win-mount .music-playlist-meta, .win-mount .music-playlist-track-count { color: var(--win-text-2); opacity: 0.85; }

/* Empty state / loader */
.win-mount .music-empty-state { color: var(--win-text-2); }
.win-mount .music-empty-state h3 { color: var(--win-text); }
.win-mount .music-empty-state svg { color: var(--win-text-2); }
.win-mount .infinite-scroll-loader { color: var(--win-text-2); }
.win-mount .loader-spinner { border-color: rgba(255, 255, 255, 0.15); border-top-color: var(--accent); }

/* Bottom player */
.win-mount .music-bottom-player { background: rgba(28, 28, 28, 0.88); border-top-color: var(--win-border); }
.win-mount .music-progress-bar-fill { background: var(--accent); }
.win-mount .music-progress-bar-fill::after { background: #fff; }
.win-mount .visualizer-wave-segment { background: linear-gradient(to top, var(--accent), rgba(228, 222, 235, 0.527), transparent); }
.win-mount .music-track-title-mini { color: var(--win-text); }
.win-mount .music-track-artist-mini { color: var(--win-text-2); opacity: 0.8; }
.win-mount .music-ctrl-btn { color: var(--win-text-2); }
.win-mount .music-ctrl-btn:hover { background: rgba(255, 255, 255, 0.12); color: var(--win-text); }
.win-mount .music-ctrl-btn.play-btn { background: var(--accent); box-shadow: 0 2px 10px rgba(76, 194, 255, 0.35); }
.win-mount .music-ctrl-btn.play-btn:hover { box-shadow: 0 4px 14px rgba(76, 194, 255, 0.5); }
.win-mount .music-thumbnail-mini { background: rgba(255, 255, 255, 0.06); }
.win-mount .music-volume-slider { background: rgba(255, 255, 255, 0.2); }
.win-mount .music-close-btn { color: var(--win-text-2); }
.win-mount .music-close-btn:hover { background: rgba(232, 17, 35, 0.25); color: #ff7d87; }

/* Add-to-playlist dialog (body-level overlay) */
.music-dialog { background: var(--win-bg-2); border-color: var(--win-border-2); }
.music-dialog-header { border-bottom-color: var(--win-border); }
.music-dialog-header h3 { color: var(--win-text); }
.music-dialog-close { color: var(--win-text-2); }
.music-dialog-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--win-text); }
.music-dialog-track, .music-playlist-option { background: rgba(255, 255, 255, 0.05); border-color: var(--win-border); color: var(--win-text); }
.music-playlist-option:hover { border-color: var(--accent); background: var(--accent-soft); }
.music-playlist-count, .music-dialog-empty { color: var(--win-text-2); }
.music-dialog-create input { background: rgba(0, 0, 0, 0.3); border-color: var(--win-border); color: var(--win-text); }
.music-dialog-create input:focus { border-color: var(--accent); }
.music-dialog-create-btn { background: var(--accent); color: #06202f; }
.music-dialog-create-btn:hover { transform: none; opacity: 0.9; }

/* ---- Live window ---- */
.win-mount #tab-live { display: block !important; height: 100%; overflow-y: auto; }
.win-mount .live-container { padding: 18px 20px; }

/* ---- Video window (Fluent, matching Files/Music) ---- */
.win-mount #tab-video { display: block !important; height: 100%; overflow: hidden; }
.win-mount .video-viewer-container {
    height: 100%;
    overflow-y: auto;
    padding: 14px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
.win-mount .video-viewer-container::-webkit-scrollbar { width: 10px; }
.win-mount .video-viewer-container::-webkit-scrollbar-track { background: transparent; }
.win-mount .video-viewer-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }

/* Header + toolbar */
.win-mount .video-viewer-header { margin-bottom: 10px; gap: 10px; }
.win-mount .video-viewer-header .page-title { font-size: 16px; font-weight: 600; color: var(--win-text); }
.win-mount .video-viewer-header .page-title svg { color: var(--accent); }
.win-mount .video-viewer-toolbar { gap: 8px; }
.win-mount .video-search {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 6px 12px;
    min-width: 180px;
    flex: 1 1 auto;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.win-mount .video-search:focus-within { border-color: var(--accent); background: rgba(0, 0, 0, 0.4); }
.win-mount .video-search svg { color: var(--win-text-2); width: 16px; height: 16px; flex: 0 0 auto; }
.win-mount .video-search input { color: var(--win-text); font-size: 13px; padding: 4px 0; }
.win-mount .video-search input::placeholder { color: var(--win-text-2); opacity: 0.75; }
.win-mount .video-view-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 7px 12px;
    color: var(--win-text-2);
    font-size: 13px;
    gap: 6px;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.win-mount .video-view-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--win-text); border-color: var(--win-border-2); }
/* Primary action: solid accent, like Files' Upload */
.win-mount #videoUploadBtn { background: var(--accent); border-color: transparent; color: #06202f; font-weight: 600; }
.win-mount #videoUploadBtn:hover { background: var(--accent-strong); border-color: transparent; color: #06202f; }
.win-mount #videoUploadBtn svg { fill: #06202f; }

/* Stats */
.win-mount .video-stats { color: var(--win-text-2); font-size: 12.5px; margin-bottom: 14px; }

/* Gallery grid + cards */
.win-mount .video-gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.win-mount .video-gallery-wrapper.dragover { background: var(--accent-soft); border-color: var(--accent); }
.win-mount .video-card { background: var(--win-bg-2); border-color: var(--win-border); border-radius: 8px; }
.win-mount .video-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
/* Card text block — compact: one-line title + single row of uploader · size · date · delete */
.win-mount .video-info { padding: 7px 10px; }
.win-mount .video-name {
    color: var(--win-text);
    font-size: 0.8rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.win-mount .video-card-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.win-mount .uploader-badge { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(255, 255, 255, 0.07); color: var(--win-text-2); border: 1px solid var(--win-border); font-size: 0.65rem; padding: 1px 7px; }
.win-mount .uploader-badge.owner { background: var(--accent-soft); color: #bfe6ff; border-color: transparent; }
.win-mount .video-card-meta { flex: 0 0 auto; font-size: 0.68rem; color: var(--win-text-2); white-space: nowrap; }
.win-mount .video-card-delete { width: 24px; height: 24px; border-radius: 5px; color: var(--win-text-2); border-color: var(--win-border-2); opacity: 0.7; }
.win-mount .video-card-delete:hover { background: rgba(232, 17, 35, 0.9); border-color: rgba(232, 17, 35, 0.9); color: #fff; opacity: 1; }
@media (hover: hover) {
    .win-mount .video-card-actions { opacity: 0; transition: opacity 0.12s ease; }
    .win-mount .video-card:hover .video-card-actions { opacity: 1; }
}

/* Empty state / infinite scroll */
.win-mount .empty-gallery { color: var(--win-text-2); }
.win-mount .empty-gallery h3 { color: var(--win-text); }
.win-mount .infinite-scroll-loader { color: var(--win-text-2); }
.win-mount .loader-spinner { border-color: rgba(255, 255, 255, 0.15); border-top-color: var(--accent); }
.win-mount .end-of-results { color: var(--win-text-2); border-color: var(--win-border); }

/* Inline player */
.win-mount .video-inline-player { margin-bottom: 16px; border-radius: 10px; border-color: var(--win-border); }
.win-mount .inline-player-header { background: var(--win-bg-2); border-bottom-color: var(--win-border); padding: 10px 14px; }
.win-mount #inlineVideoName { color: var(--win-text); font-size: 0.9rem; }
.win-mount #inlineVideoMeta { color: var(--win-text-2); }
.win-mount .inline-player-btn { color: #fff; }
.win-mount .inline-player-close { background: rgba(255, 255, 255, 0.06); color: var(--win-text); }
.win-mount .inline-player-close:hover { background: rgba(232, 17, 35, 0.9); color: #fff; }
.win-mount .inline-progress-played { background: var(--accent); }
.win-mount .inline-loading-spinner .spinner { border-top-color: var(--accent); }

/* Inline image viewer */
.win-mount .image-inline-viewer { margin-bottom: 14px; border-radius: 10px; background: transparent; border: none; }
.win-mount .iiv-header { background: var(--win-bg-2); border-bottom-color: var(--win-border); }
.win-mount #iivName { color: var(--win-text); font-size: 0.9rem; }
.win-mount #iivMeta { color: var(--win-text-2); }
.win-mount .iiv-btn { color: #fff; }
.win-mount .iiv-close { background: rgba(255, 255, 255, 0.06); color: var(--win-text); }
.win-mount .iiv-close:hover { background: rgba(232, 17, 35, 0.9); color: #fff; }
.win-mount .iiv-cluster { background: rgba(0, 0, 0, 0.45); border-color: var(--win-border); }
.win-mount .iiv-cluster .iiv-btn { background: rgba(255, 255, 255, 0.06); color: var(--win-text); }
.win-mount .iiv-cluster .iiv-btn:hover { background: rgba(255, 255, 255, 0.16); }
.win-mount .iiv-footer { background: var(--win-bg-2); border-top-color: var(--win-border); }
.win-mount #iivCounter { color: var(--win-text-2); }

/* Speed / subtitle menus */
.win-mount .inline-speed-menu,
.win-mount .inline-subtitle-menu { background: var(--acrylic); border-color: var(--win-border-2); }
.win-mount .inline-speed-option,
.win-mount .inline-subtitle-option,
.win-mount .inline-audio-option { color: var(--win-text); }
.win-mount .inline-speed-option:hover,
.win-mount .inline-subtitle-option:hover,
.win-mount .inline-audio-option:hover { background: rgba(255, 255, 255, 0.08); }
.win-mount .inline-subtitle-option.active,
.win-mount .inline-audio-option.active { background: var(--accent); color: #06202f; }
.win-mount .inline-menu-section { color: var(--win-text-2); border-color: var(--win-border); }

/* ---- Images window (Fluent, matching Files/Video; lightbox stays a fullscreen overlay) ---- */
.win-mount #tab-images { display: block !important; height: 100%; overflow: hidden; }
.win-mount .image-viewer-container {
    height: 100%;
    overflow-y: auto;
    padding: 14px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
.win-mount .image-viewer-container::-webkit-scrollbar { width: 10px; }
.win-mount .image-viewer-container::-webkit-scrollbar-track { background: transparent; }
.win-mount .image-viewer-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }

/* Header + toolbar */
.win-mount .image-viewer-header { margin-bottom: 10px; gap: 10px; }
.win-mount .image-viewer-header .page-title { font-size: 16px; font-weight: 600; color: var(--win-text); margin-bottom: 0; }
.win-mount .image-viewer-header .page-title svg { color: var(--accent); }
.win-mount .image-viewer-toolbar { gap: 8px; }
.win-mount .image-search {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 6px 12px;
    min-width: 180px;
    flex: 1 1 auto;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.win-mount .image-search:focus-within { border-color: var(--accent); background: rgba(0, 0, 0, 0.4); }
.win-mount .image-search svg { color: var(--win-text-2); width: 16px; height: 16px; flex: 0 0 auto; }
.win-mount .image-search input { color: var(--win-text); font-size: 13px; padding: 4px 0; }
.win-mount .image-search input::placeholder { color: var(--win-text-2); opacity: 0.75; }
.win-mount .image-search input:-webkit-autofill, .win-mount .image-search input:-webkit-autofill:hover, .win-mount .image-search input:-webkit-autofill:focus, .win-mount .image-search input:-webkit-autofill:active { -webkit-box-shadow: 0 0 0 30px rgba(0, 0, 0, 0.28) inset !important; -webkit-text-fill-color: var(--win-text) !important; }
.win-mount .image-view-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 7px 12px;
    color: var(--win-text-2);
    font-size: 13px;
    gap: 6px;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.win-mount .image-view-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--win-text); border-color: var(--win-border-2); }
/* Primary action: solid accent, like Files' Upload */
.win-mount #imageUploadBtn { background: var(--accent); border-color: transparent; color: #06202f; font-weight: 600; }
.win-mount #imageUploadBtn:hover { background: var(--accent-strong); border-color: transparent; color: #06202f; }
.win-mount #imageUploadBtn svg { fill: #06202f; }

/* Stats */
.win-mount .image-stats { color: var(--win-text-2); font-size: 12.5px; margin-bottom: 14px; }

/* Gallery grid + cards */
.win-mount .image-gallery { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.win-mount .image-gallery-wrapper.dragover { background: var(--accent-soft); border-color: var(--accent); border: 2px dashed var(--accent); }
.win-mount .image-card { background: var(--win-bg-2); border-color: var(--win-border); border-radius: 8px; }
.win-mount .image-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.win-mount .image-thumbnail { background: rgba(0, 0, 0, 0.3); }
/* Card text block — compact: one-line title + single row of uploader · size · date · delete */
.win-mount .image-info { padding: 0; }
.win-mount .image-name {
    color: var(--win-text-2);
    font-size: 0.65rem;
    font-weight: 500;
    margin: 0;
    padding: 4px 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.win-mount .image-card-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.win-mount .uploader-badge { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(255, 255, 255, 0.07); color: var(--win-text-2); border: 1px solid var(--win-border); font-size: 0.65rem; padding: 1px 7px; }
.win-mount .uploader-badge.owner { background: var(--accent-soft); color: #bfe6ff; border-color: transparent; }
.win-mount .image-card-meta { flex: 0 0 auto; font-size: 0.68rem; color: var(--win-text-2); white-space: nowrap; }
.win-mount .image-card-delete { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 5px; color: #fff; background: rgba(0, 0, 0, 0.6); border-color: var(--win-border-2); opacity: 0.45; margin: 0; z-index: 2; }
.win-mount .image-card-delete:hover { background: rgba(232, 17, 35, 0.9); border-color: rgba(232, 17, 35, 0.9); color: #fff; opacity: 1; }
@media (hover: hover) {
    .win-mount .image-card-delete { opacity: 0.45; transition: opacity 0.12s ease; }
    .win-mount .image-card:hover .image-card-delete { opacity: 1; }
}

/* Empty state / infinite scroll */
.win-mount .empty-gallery { color: var(--win-text-2); }
.win-mount .empty-gallery h3 { color: var(--win-text); }
.win-mount .infinite-scroll-loader { color: var(--win-text-2); }
.win-mount .loader-spinner { border-color: rgba(255, 255, 255, 0.15); border-top-color: var(--accent); }
.win-mount .end-of-results { color: var(--win-text-2); border-color: var(--win-border); }

/* ---- Images lightbox (Windows Photos style; rendered on body, not in a window) ---- */
body.desktop-mode .image-lightbox-overlay { background: rgba(5, 5, 7, 0.96); backdrop-filter: blur(6px); }
body.desktop-mode .image-lightbox { background: #101013; flex-direction: column; }

/* Top bar */
body.desktop-mode .lb-topbar {
    display: flex; align-items: center; gap: 12px;
    height: 52px; padding: 0 10px 0 16px;
    background: rgba(27, 27, 30, 0.72);
    backdrop-filter: blur(18px) saturate(1.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex: 0 0 auto; z-index: 2;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
body.desktop-mode .lb-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 auto; }
body.desktop-mode .lb-counter { color: rgba(255, 255, 255, 0.55); font-size: 12px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
body.desktop-mode .lb-filename { color: #f2f2f4; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
body.desktop-mode .lb-detail { display: flex; align-items: center; gap: 8px; color: rgba(255, 255, 255, 0.5); font-size: 12px; flex: 0 0 auto; }
body.desktop-mode .lb-dot { opacity: 0.5; }

/* Buttons */
body.desktop-mode .lb-btn {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: 6px;
    color: rgba(255, 255, 255, 0.85); cursor: pointer; flex: 0 0 auto;
    transition: background 0.12s ease;
}
body.desktop-mode .lb-btn:hover { background: rgba(255, 255, 255, 0.12); }
body.desktop-mode .lb-btn:active { background: rgba(255, 255, 255, 0.2); }
body.desktop-mode .lb-danger:hover { background: rgba(232, 17, 35, 0.28); color: #ff98a1; }

/* Stage */
body.desktop-mode .lb-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; touch-action: none; }
body.desktop-mode #lightboxImage {
    max-width: calc(100% - 96px); max-height: 100%;
    object-fit: contain; user-select: none; -webkit-user-select: none;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    will-change: transform;
}

/* Side navigation */
body.desktop-mode .lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 42px; height: 56px; display: flex; align-items: center; justify-content: center;
    background: rgba(24, 24, 28, 0.6); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 8px;
    color: rgba(255, 255, 255, 0.85); cursor: pointer; z-index: 3;
    transition: background 0.12s ease, opacity 0.25s ease;
    backdrop-filter: blur(12px);
}
body.desktop-mode .lb-nav:hover { background: rgba(255, 255, 255, 0.14); }
body.desktop-mode .lb-prev { left: 12px; }
body.desktop-mode .lb-next { right: 12px; }

/* Bottom floating toolbar */
body.desktop-mode .lb-toolbar {
    flex: 0 0 auto; align-self: center;
    display: flex; align-items: center; gap: 2px;
    background: rgba(27, 27, 30, 0.82);
    backdrop-filter: blur(18px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px; padding: 4px;
    margin: 0 16px 18px; max-width: calc(100% - 32px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    transition: transform 0.25s ease, opacity 0.25s ease;
    z-index: 2;
}
body.desktop-mode .lb-group { display: flex; align-items: center; gap: 2px; }
body.desktop-mode .lb-sep { width: 1px; height: 26px; background: rgba(255, 255, 255, 0.12); margin: 0 6px; }
body.desktop-mode .lb-zoom-slider {
    -webkit-appearance: none; appearance: none;
    width: 110px; height: 4px; border-radius: 2px;
    background: rgba(255, 255, 255, 0.18); outline: none; margin: 0 8px; cursor: pointer;
}
body.desktop-mode .lb-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: #ffffff; border: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); cursor: grab;
}
body.desktop-mode .lb-zoom-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: none; }

/* Fullscreen: UI hides until pointer moves */
body.desktop-mode .image-lightbox.ui-hidden .lb-topbar { transform: translateY(-100%); opacity: 0; pointer-events: none; }
body.desktop-mode .image-lightbox.ui-hidden .lb-toolbar { transform: translateY(140%); opacity: 0; pointer-events: none; }
body.desktop-mode .image-lightbox.ui-hidden .lb-nav { opacity: 0; pointer-events: none; }

/* ---- Social window (was a fixed full-page overlay) ---- */
.win-mount #socialPage {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    display: flex !important;
    height: 100%;
}
.win-mount .social-full-container { height: 100%; min-height: 0; }

/* ---------- Online users panel ---------- */
#usersPanel {
    position: absolute;
    right: 6px;
    bottom: calc(var(--taskbar-h) + 12px);
    width: 320px;
    max-width: calc(100vw - 24px);
    max-height: calc(100% - var(--taskbar-h) - 24px);
    overflow-y: auto;
    background: rgba(28, 28, 28, 0.92);
    backdrop-filter: blur(44px) saturate(1.4);
    -webkit-backdrop-filter: blur(44px) saturate(1.4);
    border: 1px solid var(--win-border-2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-win);
    padding: 14px;
    z-index: 2100;
    display: none;
}
#usersPanel.open { display: block; animation: panelIn 0.14s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.up-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--win-text);
    padding: 4px 6px 8px;
}
.up-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--win-text-2);
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 8px;
    border-radius: 9px;
}
.up-list { display: flex; flex-direction: column; gap: 2px; }
.up-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
}
.up-item:hover { background: rgba(255, 255, 255, 0.07); }
.up-item.off { opacity: 0.55; }
.up-av {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border: 1.5px solid rgba(255,255,255,.18);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.up-av img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.up-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid #1c1c1c;
    background: #22c55e;
}
.up-dot.dnd { background: #e81123; }
.up-dot.idle { background: #f59e0b; }
.up-dot.off { background: #555; }
.up-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.up-name { font-size: 12.5px; color: var(--win-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-sub { font-size: 11px; color: var(--win-text-2); }
.up-friend { color: var(--accent); font-size: 13px; padding: 0 4px; }
.up-acts { display: flex; align-items: center; gap: 3px; flex: none; }
.up-add {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: var(--win-text);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.up-add:hover { background: var(--accent); color: #06202f; }
/* LIVE badge — first item in a user row's actions (left of 💬), click → Live page */
.up-live {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #ff6b78;
    background: rgba(232, 17, 35, 0.14);
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease;
}
.up-live:hover { background: rgba(232, 17, 35, 0.3); }
.up-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e81123;
    box-shadow: 0 0 6px 1px rgba(232, 17, 35, 0.6);
    animation: livePulse 1.6s ease-out infinite;
    flex: 0 0 auto;
}
.up-empty { font-size: 12px; color: var(--win-text-2); padding: 6px 8px; }

/* ---------- Drop-to-upload overlay ---------- */
#dropOverlay {
    position: absolute;
    inset: 0;
    z-index: 2400;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 16, 34, 0.55);
    backdrop-filter: blur(4px);
}
#dropOverlay.show { display: flex; }
#dropOverlay::before {
    content: '';
    position: absolute;
    inset: 10px;
    border: 3px dashed rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    pointer-events: none;
}
.do-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 34px 48px;
    background: rgba(28, 28, 28, 0.85);
    border: 1px solid var(--win-border-2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-win);
    color: var(--win-text);
    animation: panelIn 0.12s ease;
}
.do-ic { font-size: 40px; }
.do-card h3 { margin: 0; font-size: 18px; font-weight: 600; }
.do-card p { margin: 0; font-size: 12.5px; color: var(--win-text-2); }

/* ---------- Toast (Fluent) ---------- */
.desk-toast {
    position: fixed;
    right: 20px;
    bottom: calc(var(--taskbar-h) + 16px);
    z-index: 3000;
    background: rgba(40, 40, 40, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--win-border-2);
    border-radius: 10px;
    box-shadow: var(--shadow-win);
    padding: 14px 18px;
    min-width: 260px;
    max-width: 360px;
    color: var(--win-text);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: toastIn 0.2s ease;
}
.desk-toast .ti { font-size: 22px; line-height: 1; }
.desk-toast .tt { font-size: 13px; font-weight: 600; }
.desk-toast .tm { font-size: 12.5px; color: var(--win-text-2); line-height: 1.4; margin-top: 2px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Mobile / small screens ---------- */
/* Windows go fullscreen (Win11 mobile pattern); keep the titlebar with close */
@media (max-width: 900px) {
    .win { min-width: 0; min-height: 0; }
}

@media (max-width: 768px) {
    /* Taller taskbar for touch, but compact so running-app buttons fit */
    :root { --taskbar-h: 52px; }
    #taskbar { gap: 3px; padding: 0 3px; }
    #taskbar-left { gap: 3px; min-width: 0; }
    #startBtn { padding: 2px; gap: 4px; }
    .start-avatar-wrap { margin-right: 12px; }
    .start-avatar { width: 28px; height: 28px; font-size: 13px; }
    .start-name { font-size: 12px; }
    #startBtn.menu-open .start-name { max-width: 200px; }
    /* Taskbar search is removed on mobile — it lives inside the start menu instead */
    .tb-search { display: none; }
    .sm-search {
        display: flex;
        align-items: center;
        gap: 8px;
        height: 44px;
        padding: 0 12px;
        margin-top: 10px;
        border-radius: 9px;
        border: 1px solid var(--win-border);
        background: rgba(255, 255, 255, 0.06);
        color: var(--win-text-2);
    }
    .sm-search:focus-within { border-color: rgba(102, 139, 255, 0.55); background: rgba(255, 255, 255, 0.10); }
    .sm-search input { flex: 1; min-width: 0; border: none; background: transparent; color: var(--win-text); font-size: 13px; outline: none; }
    .sm-search input::placeholder { color: var(--win-text-2); }
    /* Start menu: single column stack on small screens */
    .sm-body {
        grid-template-columns: 1fr;
        height: auto;
        max-height: calc(100vh - var(--taskbar-h) - 118px);
        overflow-y: auto;
    }
    .sm-left { border-right: none; padding-right: 0; border-bottom: 1px solid var(--win-border); padding-bottom: 10px; }
    .sm-left .sm-users { max-height: none; overflow-y: visible; }
    /* While searching: hide the users list so results sit at the top of the
       column and stay visible above the virtual keyboard. */
    #startMenu.sm-searching .sm-left { display: none; }
    /* Mobile: horizontal push (left↔right), close a bit faster */
    #startMenu.open { animation-name: smInX; }
    #startMenu.open.closing { animation-name: smOutX; animation-duration: 0.12s; }
    @keyframes smInX {
        from { opacity: 0; transform: translateX(-26px); }
        to { opacity: 1; transform: translateX(0); }
    }
    @keyframes smOutX {
        from { opacity: 1; transform: translateX(0); }
        to { opacity: 0; transform: translateX(-110vw); } /* full exit off the left edge */
    }
    .start-live-dot { width: 8px; height: 8px; top: -2px; left: -2px; }
    .start-count { min-width: 13px; height: 14px; font-size: 11px; bottom: -4px; right: -14px; border: none; gap: 2px; padding: 0 3px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 6px rgba(96, 220, 130, 0.6); }
    .start-count svg { width: 9px; height: 9px; flex: 0 0 auto; color: #c9c9ce; opacity: 0.95; text-shadow: none; }
    .start-dm { min-width: 13px; height: 13px; font-size: 8.5px; bottom: -4px; right: -4px; }
    .start-dm { top: -3px; }
    /* Running apps flow in a scrollable row instead of an absolute center that collides */
    #taskbar-center {
        position: static;
        transform: none;
        max-width: none;
        flex: 1 1 0;
        min-width: 0;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }
    #taskbar-center::-webkit-scrollbar { display: none; }
    #taskbar-apps { gap: 2px; height: 100%; }
    #taskbar-apps .tb-btn { height: 40px; min-width: 40px; padding: 0 4px; }
    #taskbar-apps .tb-btn .ic { font-size: 18px; }
    /* Tray: icon-sized, labels hidden */
    #trayUsers { height: 38px; padding: 0 9px; }
    #trayUsers svg { width: 18px; height: 18px; }
    #trayUsersCount { min-width: 14px; height: 14px; font-size: 10px; padding: 0 3px; }
    /* Full width of the remaining taskbar — app buttons keep their own space, no overlap.
       Timeline on top (column-reverse) for easier thumb reach. */
    #taskbar-center { flex: 0 1 auto; }
    .tray-media { flex: 1 1 0; min-width: 148px; max-width: none; height: auto; min-height: 44px; padding: 3px 6px 4px 6px; gap: 3px; flex-direction: column-reverse; justify-content: center; }
    .tray-media-row { flex: 1 1 auto; }
    .tray-media-title { display: block; font-size: 11px; }
    .tray-btn { width: 32px; height: 32px; }
    .tray-btn.tray-btn-big { width: 36px; height: 36px; }
    .tray-close { width: 28px; height: 28px; font-size: 15px; }
    .tray-progress { height: 3px; }
    .tray-progress .tray-thumb { width: 9px; height: 9px; }
    .tray-progress .tray-time { display: none; }
    .sm-gear { width: 22px; height: 22px; }
    .sm-gear svg { width: 12px; height: 12px; }
    .up-live { padding: 1px 6px; font-size: 10px; }
    .smset-actions { flex-wrap: wrap; }

    .win-ctrl { width: 46px; } /* comfortable touch targets */

    /* Files app on small screens */
    .fw-wrap .files-toolbar { padding: 8px 10px; }
    .fw-wrap .files-search { max-width: none; min-width: 0; }
    .fw-wrap .upload-btn { flex: 1 1 auto; justify-content: center; min-height: 40px; }
    .fw-wrap .sort-btn { min-height: 40px; }
    .fw-wrap .files-filters { padding: 8px 10px; }
    .fw-wrap .file-row { min-height: 48px; padding: 10px 8px; gap: 10px; }
    .fw-wrap .file-actions { opacity: 1 !important; }
    .fw-wrap .file-action-btn { width: 42px; height: 42px; }
    .fw-wrap .filter-select { min-height: 40px; }

    /* Video app on small screens */
    .win-mount .video-viewer-container { padding: 10px 12px; }
    .win-mount .video-viewer-header { flex-direction: column; align-items: stretch; }
    .win-mount .video-viewer-toolbar { flex-wrap: wrap; }
    .win-mount .video-search { min-width: 0; flex: 1 1 100%; }
    .win-mount .video-view-btn { flex: 1 1 auto; justify-content: center; min-height: 40px; }
    .win-mount .video-gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .win-mount .video-info { padding: 8px 10px; }
    .win-mount .vcm-date { display: none; }
    /* Compact controls: must stay shorter than the video so the timeline sits at the bottom */
    .win-mount .inline-player-controls { padding: 14px 8px 8px; }
    .win-mount .inline-progress-container { padding-bottom: 6px; }
    .win-mount .inline-controls-row { flex-wrap: wrap; gap: 4px 6px; }
    .win-mount .inline-controls-left, .win-mount .inline-controls-right { flex: 1 1 auto; flex-wrap: wrap; gap: 2px; justify-content: space-evenly; }
    .win-mount .inline-player-btn { width: 34px; height: 34px; }
    .win-mount .inline-volume-control { gap: 2px; }
    .win-mount .inline-volume-slider { width: 56px; }
    .win-mount .inline-time-display { margin: 0 4px; font-size: 0.7rem; }
    .win-mount .inline-speed-menu, .win-mount .inline-subtitle-menu { right: 10px; left: auto; max-width: calc(100vw - 20px); }

    /* Images app on small screens */
    .win-mount .image-viewer-container { padding: 10px 12px; }
    .win-mount .image-viewer-header { flex-direction: column; align-items: stretch; }
    .win-mount .image-viewer-toolbar { flex-wrap: wrap; }
    .win-mount .image-search { min-width: 0; flex: 1 1 100%; }
    .win-mount .image-view-btn { flex: 1 1 auto; justify-content: center; min-height: 40px; }
    .win-mount .image-gallery { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
    .image-gallery-wrapper.iiv-compact .image-gallery { max-height: 100px; }
    .win-mount .image-name { padding: 3px 4px; font-size: 0.6rem; }
    .win-mount .icm-date { display: none; }
    .win-mount .image-card-delete { opacity: 0.7; }

    /* Images lightbox on small screens */
    body.desktop-mode .lb-topbar { height: 46px; padding: 0 6px 0 12px; gap: 8px; }
    body.desktop-mode .lb-filename { font-size: 13px; }
    body.desktop-mode .lb-detail { display: none; }
    body.desktop-mode #lightboxImage { max-width: 100%; }
    body.desktop-mode .lb-nav { width: 36px; height: 52px; }
    body.desktop-mode .lb-prev { left: 6px; }
    body.desktop-mode .lb-next { right: 6px; }
    body.desktop-mode .lb-toolbar { margin: 0 8px 10px; border-radius: 12px; padding: 3px; max-width: calc(100% - 16px); }
    body.desktop-mode .lb-btn { width: 38px; height: 38px; }
    body.desktop-mode .lb-zoom-slider { width: 70px; margin: 0 4px; }
    body.desktop-mode .lb-sep { margin: 0 3px; }

    /* Music app on small screens */
    .win-mount .music-container { gap: 10px; padding: 10px 10px 96px; }
    .win-mount .music-toolbar { gap: 8px; }
    .win-mount .music-search { min-width: 100%; }
    .win-mount .music-view-btn { flex: 1 1 auto; justify-content: center; min-height: 40px; }
    .win-mount .music-view-switcher { flex: 1 1 100%; justify-content: center; }
    .win-mount .music-tracks-bar { padding: 8px; gap: 6px; }
    .win-mount .mtb-btn { flex: 1 1 auto; justify-content: center; min-height: 40px; }
    .win-mount .mtb-check { flex: 1 1 auto; justify-content: center; min-height: 40px; }
    .win-mount .mtb-select { flex: 1 1 auto; min-height: 40px; }
    .win-mount .music-track-list-header,
    .win-mount .music-track-row {
        grid-template-columns: 28px 28px 28px minmax(0, 1fr) 50px 76px;
        padding: 8px 10px;
    }
    .win-mount .music-track-artist,
    .win-mount .music-track-album,
    .win-mount .music-track-genre,
    .win-mount .header-artist,
    .win-mount .header-album,
    .win-mount .header-genre { display: none; }
    .win-mount .music-track-actions { display: flex; opacity: 1; }
    .win-mount .music-play-row-btn,
    .win-mount .music-add-playlist-btn,
    .win-mount .music-delete-btn { width: 36px; height: 36px; }
    .win-mount .music-lock-toggle { min-width: 36px; min-height: 32px; }
    .win-mount .music-ctrl-btn { width: 38px; height: 38px; }
    .win-mount .music-close-btn { width: 36px; height: 36px; }
}

@media (max-width: 480px) {
    .win-mount .music-track-list-header,
    .win-mount .music-track-row {
        grid-template-columns: 28px 28px minmax(0, 1fr) 50px 76px; /* thumb hidden by base css */
    }
    .win-mount .video-gallery { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .win-mount .inline-player-btn { width: 36px; height: 36px; }
    .win-mount .inline-volume-slider { width: 50px; }
}

@media (max-width: 720px) {
    .sm-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
    #startMenu { width: calc(100vw - 16px); }
    .tb-spacer { flex: 0 0 4px; min-width: 0; }
    .desk-icon { width: 74px; }
}

@media (max-width: 480px) {
    #desktop-icons { gap: 2px; }
    .desk-icon { width: 62px; padding: 8px 4px 6px; }
    .sm-grid { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
    #startMenu { padding: 14px; left: 4px; }
}

/* ================= SITE-WIDE TOASTS (Win11-style) ================= */
#mpToasts {
    position: fixed;
    bottom: 60px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
}
.mp-toast.mp-toast-click { cursor: pointer; }
.mp-toast {
    pointer-events: auto;
    width: 340px;
    max-width: calc(100vw - 32px);
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.12);
    border-left: 3px solid transparent; /* v56: tone accent slot */
    background: rgba(28,28,32,.92);
    backdrop-filter: blur(12px);
    box-shadow: 0 16px 40px rgba(0,0,0,.5);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: mpToastIn .2s ease;
}
/* v56 polish: tone accents use the app's own palette —
   success #22c55e (online dot), warning #f0b232 (away dot / warn items),
   info = the cyan --accent. */
.mp-tone-ok   { border-left-color: #22c55e; }
.mp-tone-warn { border-left-color: #f0b232; }
.mp-tone-info { border-left-color: var(--accent, #4cc2ff); }
@keyframes mpToastIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: none; }
}
/* v56: icon chip — same shape language as the app's icon tiles */
.mp-ti {
    flex: none;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 7px;
    color: var(--accent, #4cc2ff);
    background: rgba(255,255,255,.06);
    font-size: 15px; line-height: 1; /* covers text icons like ↗ / ✕ */
}
.mp-ti svg { display: block; width: 17px; height: 17px; }
.mp-tone-ok .mp-ti   { color: #22c55e; background: rgba(34,197,94,.14); }
.mp-tone-warn .mp-ti { color: #f0b232; background: rgba(240,178,50,.15); }
.mp-tone-info .mp-ti { color: var(--accent, #4cc2ff); background: rgba(76,194,255,.13); }
.mp-tbody { flex: 1; min-width: 0; padding-top: 2px; }
.mp-tt { font-size: 13px; font-weight: 700; color: var(--win-text, #fff); } /* v56: white like the rest of the app's headings (was all-cyan) */
.mp-tm { margin-top: 2px; font-size: 12px; color: var(--win-text-2, #cfcfcf); line-height: 1.45; }
.mp-x {
    flex: none;
    width: 22px; height: 22px;
    border: none; background: transparent;
    color: var(--win-text-2, #cfcfcf);
    font-size: 13px;
    cursor: pointer;
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
}
.mp-x:hover { background: rgba(255,255,255,.1); color: #fff; }
.mp-acts { display: flex; gap: 6px; margin-top: 10px; }
.mp-act {
    padding: 5px 12px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.06);
    border-radius: 7px; /* v56: match .soc-btn radius */
    color: var(--win-text, #fff);
    font-size: 12px;
    cursor: pointer;
    transition: background .12s;
}
.mp-act:hover { background: var(--accent, #4cc2ff); color: #06202f; }
/* Destructive confirm (e.g. Sign out) — red tint, matches --danger usage elsewhere */
.mp-act-danger { border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.12); color: #fca5a5; }
.mp-act-danger:hover { background: #ef4444; border-color: #ef4444; color: #fff; }

/* Mobile: toasts at the top (never cover the bottom controls) and more
   compact — swipe them in any direction to dismiss. */
@media (max-width: 768px) {
    #mpToasts {
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: auto;
        max-width: none;
        align-items: stretch;
        gap: 8px;
    }
    .mp-toast {
        width: auto;
        padding: 8px 10px;
        gap: 8px;
    }
    .mp-ti { width: 24px; height: 24px; font-size: 15px; }
    .mp-ti svg { width: 15px; height: 15px; }
    .mp-tt { font-size: 12px; }
    .mp-tm { font-size: 11px; }
    .mp-x { width: 20px; height: 20px; font-size: 12px; }
    .mp-acts { margin-top: 8px; }
    .mp-act { padding: 4px 10px; font-size: 11px; }
}

/* ================= DM BADGES ================= */
.up-badge {
    flex: none;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    background: var(--accent, #4cc2ff);
    color: #06202f;
    font-size: 10px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
}
.tray-dm-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 14px; height: 14px;
    border-radius: 7px;
    background: #e81123;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    line-height: 1;
}
.tray-dm-badge[hidden] { display: none !important; }
#trayUsers { position: relative; }

/* ================= GLOBAL CONNECTION INDICATOR (engraved) ================= */
#connIndicator {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    z-index: 0; /* etched into the wallpaper — app windows stack above it */
}
#connIndicator[hidden] { display: none; }
#connIndicator { transition: opacity .55s ease; }
#connIndicator.ci-fade { opacity: 0; }
/* Taskbar mode (desktop) — sits in the search bar's slot as a compact pill */
#connIndicator.ci-taskbar {
    position: static;
    transform: none;
    flex-direction: row;
    gap: 8px;
    min-height: 36px; /* min, not fixed — the fail-state sentence may wrap to two lines instead of spilling out of the pill */
    padding: 0 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    max-width: 52vw;
}
#connIndicator.ci-taskbar .ci-txt { font-size: 12.5px; min-width: 0; line-height: 1.3; } /* wraps instead of nowrap — nowrap + max-width made the fail sentence overflow the pill */
#connIndicator.ci-taskbar .ci-dots { font-size: 14px; }
#connIndicator.ci-taskbar .ci-cables { flex: none; } /* cable art keeps its size; only the text may shrink/wrap */
#connIndicator.ci-taskbar .ci-btn { flex: none; padding: 5px 10px; font-size: 11.5px; border-radius: 7px; white-space: nowrap; }
/* Connect celebration: "Connected!" flashes green, the pill folds into the
   slot, and the search bar springs open with a green shine hand-off. */
#connIndicator.ci-success { animation: ciGlow 1.05s ease; }
#connIndicator.ci-success .ci-txt { color: #4ade80; text-shadow: 0 0 12px rgba(74, 222, 128, 0.55); }
@keyframes ciGlow {
    0%   { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.10); box-shadow: none; }
    30%  { background: rgba(74, 222, 128, 0.24);  border-color: rgba(74, 222, 128, 0.80); box-shadow: 0 0 20px rgba(74, 222, 128, 0.40); }
    70%  { background: rgba(74, 222, 128, 0.16);  border-color: rgba(74, 222, 128, 0.55); box-shadow: 0 0 12px rgba(74, 222, 128, 0.25); }
    100% { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.10); box-shadow: none; }
}
/* The pill folds toward the search bar's anchor point, handing over the slot */
#connIndicator.ci-collapse { opacity: 0; transition: transform .3s cubic-bezier(.55, 0, .75, .4), opacity .26s ease; }
#connIndicator.ci-taskbar.ci-collapse { transform: scaleX(0); transform-origin: left center; }
/* Mobile: no taskbar search bar — the pill sits in the MIDDLE of the taskbar */
#connIndicator.ci-taskbar.ci-mobile-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: min(88vw, 330px); /* 52vw is too narrow for cable + sentence + button — give the text real room to wrap */
}
/* Fail/retry states on mobile: cable + sentence + button is TALLER than the
   taskbar, so centering it inside the bar pushed the text out of the pill
   and the button below the bottom of the screen. Dock it ABOVE the taskbar
   as a compact popup card instead, stacked vertically. Falls back to the
   wrapping row layout on browsers without :has(). */
#connIndicator.ci-taskbar.ci-mobile-center:has(#ciReload:not([hidden]), #ciRetry:not([hidden])) {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    top: auto;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    max-width: min(88vw, 330px);
    background: rgba(19, 19, 22, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 9999;
}
#connIndicator.ci-taskbar.ci-mobile-center:has(#ciReload:not([hidden]), #ciRetry:not([hidden])) .ci-txt {
    font-size: 13px;
}
#connIndicator.ci-taskbar.ci-mobile-center:has(#ciReload:not([hidden]), #ciRetry:not([hidden])) .ci-btn {
    padding: 8px 18px;
    font-size: 13px;
}
#connIndicator.ci-taskbar.ci-mobile-center.ci-collapse { transform: translate(-50%, -50%) scale(.85); }
/* Search bar reveal: springs open from the left, icon pops in, shine sweeps */
.tb-search[hidden] { display: none !important; }
.tb-search.ci-become {
    position: relative;
    overflow: hidden;
    transform-origin: left center;
    animation: tbGrow .55s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes tbGrow {
    0%   { opacity: 0; transform: scaleX(.35); }
    60%  { opacity: 1; }
    100% { opacity: 1; transform: scaleX(1); }
}
.tb-search.ci-become svg { animation: tbIconPop .5s .16s cubic-bezier(.34, 1.9, .64, 1) backwards; }
@keyframes tbIconPop {
    0%   { opacity: 0; transform: scale(0) rotate(-90deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
.tb-search.ci-become input { animation: tbInFade .4s .1s ease backwards; }
@keyframes tbInFade { from { opacity: 0; } to { opacity: 1; } }
.tb-search.ci-become::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -60%;
    width: 45%;
    pointer-events: none;
    background: linear-gradient(105deg, transparent, rgba(74, 222, 128, 0.30), transparent);
    animation: tbShine .7s .22s ease forwards;
}
@keyframes tbShine { to { left: 125%; } }
/* First-visit "Connecting" — dots light up one, two, three and repeat */
.ci-dots { display: inline-flex; gap: 2px; font-size: 16px; font-weight: 700; line-height: .6; color: rgba(255, 255, 255, .75); }
.ci-dots[hidden] { display: none; }
.ci-dots i { font-style: normal; opacity: 0; animation: ciDot 1.2s infinite; }
.ci-dots i:nth-child(2) { animation-delay: .18s; }
.ci-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes ciDot { 0% { opacity: 0; } 18% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
/* "two cables trying to connect" — the plug keeps nudging into the socket */
.ci-cables { display: flex; align-items: center; }
.ci-cable { width: 26px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.5); }
.ci-plug {
    position: relative;
    width: 22px; height: 16px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.55);
    animation: ciPlug 1.5s ease-in-out infinite;
}
.ci-plug i {
    position: absolute;
    right: -6px;
    width: 6px; height: 3px;
    background: rgba(255, 255, 255, 0.55);
}
.ci-plug i:first-child { top: 2px; }
.ci-plug i:last-child { top: 11px; }
.ci-socket {
    position: relative;
    width: 22px; height: 20px;
    margin-left: 8px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.4);
}
.ci-socket i {
    position: absolute;
    left: 3px;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.ci-socket i:first-child { top: 2px; }
.ci-socket i:last-child { top: 12px; }
@keyframes ciPlug {
    0%, 100% { transform: translateX(0); }
    45%, 60% { transform: translateX(14px); }
    75% { transform: translateX(10px); }
}
.ci-cables.ci-idle .ci-plug { animation: none; }
.ci-cables.ci-fail .ci-plug, .ci-cables.ci-fail .ci-socket, .ci-cables.ci-fail .ci-cable { opacity: 0.45; }
.ci-txt {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    max-width: 280px;
    min-width: 0; /* as a flex item it must be allowed to shrink, or long text overflows its box */
}
.ci-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.07);
    color: #e8e8ec;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 9px;
    cursor: pointer;
}
.ci-btn:hover { background: rgba(255, 255, 255, 0.14); }
.ci-btn[hidden] { display: none; }

/* ================= MOBILE PULL-TO-REFRESH (mist bloom) =================
   Pull down → a light-blue mist blooms from the top edge and a glowing
   refresh orb rises with it. --pr (0..1) = pull progress, --pr2 = eased
   mist amount. Full pull (ready) → orb pulses bright; release → the mist
   dissipates upward like smoke. Pure gradients (no blur filters) so it
   composites cheaply on phones. */
#pullRefresh {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
#pullRefresh[hidden] { display: none; }
.pr-mist {
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 52vh;
    /* Center X follows the side the pull started from (--prx, 15..85%), so
       the bloom reads as light spilling in from where the finger pulled. */
    background: radial-gradient(130% 105% at calc(var(--prx, 50) * 1%) -4%,
        rgba(178, 210, 255, 0.95) 0%,
        rgba(130, 175, 250, 0.5) 34%,
        rgba(110, 160, 240, 0.18) 58%,
        transparent 80%);
    opacity: var(--pr2, 0);
    mix-blend-mode: screen;
}
/* Release: the mist quickly dissipates upward and vanishes like smoke. */
#pullRefresh.release .pr-mist {
    opacity: 0;
    transform: translateY(-18%);
    transition: opacity 0.32s ease-in, transform 0.45s cubic-bezier(0.3, 0.6, 0.3, 1);
}

/* ================= ONLINE-COUNT LOADING PLACEHOLDER ================= */
.start-count.loading .start-count-n,
.start-count.loading svg { display: none; }
.start-count.loading::after {
    content: '';
    width: 10px; height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: rgba(255, 255, 255, 0.85);
    animation: startCountSpin 0.8s linear infinite;
}
@keyframes startCountSpin { to { transform: rotate(360deg); } }
