/*
 * SPDX-FileCopyrightText: 2026 Jake Wehmeier (BTSpaniel) <https://github.com/BTSpaniel>
 *
 * SPDX-License-Identifier: LicenseRef-ParticleRealms-Alpha
 */

:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --os-bg:          #07090f;
    --os-surface:     #0d1120;
    --os-surface-2:   #121828;
    --os-border:      rgba(255, 255, 255, 0.09);
    --os-accent:      #5b7cff;
    --os-accent-2:    #1fd2b4;
    --os-text:        #f5f7fb;
    --os-text-dim:    rgba(245, 247, 251, 0.55);
    --os-taskbar-h:   68px;
    --os-radius:      14px;
    --os-blur:        20px;
    --os-shadow:      0 8px 40px rgba(0, 0, 0, 0.55);
    --os-hover:       rgba(255,255,255,0.06);   /* subtle interactive surface overlay */
    --os-hover-2:     rgba(255,255,255,0.12);   /* stronger hover / track overlay */
    --term-bg:        #070b10;   /* terminal surface */
    --term-fg:        #b8f0b8;   /* terminal text (green) */
    --term-accent:    #44dd88;   /* terminal prompt / command */

    /* ── ThemeEngine dynamic tokens (overwritten by ThemeEngine._applyToDOM) */
    --os-panel-chrome:          linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 60%), var(--os-taskbar-bg, var(--os-surface));
    --os-panel-chrome-inactive: var(--os-taskbar-bg, var(--os-surface));
    --os-chrome-contrast:       0.5;
    --os-focus-glow:            0 0 0 1.5px rgba(91,124,255,0.35), 0 8px 32px rgba(91,124,255,0.14);
    --os-dot-close:             #ff5f57;
    --os-dot-min:               #febc2e;
    --os-dot-max:               #28c840;

    /* ── Plauna CSS variable aliases ─────────────────────────────────────
       DOMPanel and other Plauna components reference these tokens.
       Map them to the OS palette so panels are never transparent. */
    --bg-primary:          #07090f;
    --bg-secondary:        #0d1120;
    --bg-tertiary:         #121828;
    --border-light:        rgba(255, 255, 255, 0.06);
    --border-medium:       rgba(255, 255, 255, 0.09);
    --border-heavy:        rgba(255, 255, 255, 0.16);
    --border-radius-sm:    6px;
    --border-radius-md:    10px;
    --border-radius-lg:    14px;
    --border-radius-xl:    20px;
    --text-primary:        #f5f7fb;
    --text-secondary:      rgba(245, 247, 251, 0.72);
    --text-tertiary:       rgba(245, 247, 251, 0.45);
    --color-primary:       #5b7cff;
    --color-secondary:     #1fd2b4;
    --color-error:         #ef4444;
    --color-warn:          #f59e0b;
    --color-success:       #22c55e;
    --shadow-sm:           0 2px 8px  rgba(0, 0, 0, 0.35);
    --shadow-md:           0 4px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg:           0 8px 40px rgba(0, 0, 0, 0.55);
    --shadow-xl:           0 14px 56px rgba(0, 0, 0, 0.65);
    --font-weight-semibold: 600;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Suppress Plauna dev-console immediately — Desktop._initPlauna() removes it after mount */
#plauna-console-wrapper { display: none !important; }

html {
    width: 100%; height: 100%;
    overflow: hidden;
    background: var(--os-bg, #07090f); /* dark fallback — AmbientEngine takes over after mount */
    color: var(--os-text);
}

body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: transparent; /* AmbientEngine layer (z-index:-10) shows through */
    color: var(--os-text);
}

/* ── GPU canvas (hidden layer, apps composite onto it) ────────────────── */
.os-gpu-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
}

/* ── Shell layout ─────────────────────────────────────────────────────── */
.os-shell {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

.os-desktop {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* ── Taskbar ──────────────────────────────────────────────────────────── */
.os-taskbar {
    height: var(--os-taskbar-h);
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 21px 0 10px;
    background: var(--os-taskbar-bg, rgba(13, 17, 32, 0.82));
    border-top: 1px solid var(--os-border);
    backdrop-filter: blur(var(--os-blur));
    -webkit-backdrop-filter: blur(var(--os-blur));
    user-select: none;
}

@keyframes start-btn-pulse {
    0%, 100% {
        box-shadow:
            0 0  8px 0   rgba(91,124,255,0.20),
            0 0 24px 0   rgba(31,210,180,0.10),
            inset 0 1px 0 rgba(255,255,255,0.18);
    }
    50% {
        box-shadow:
            0 0 18px 4px rgba(91,124,255,0.45),
            0 0 40px 8px rgba(31,210,180,0.20),
            inset 0 1px 0 rgba(255,255,255,0.28);
    }
}
.taskbar-start {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(255,255,255,0.13) 0%, rgba(255,255,255,0.04) 100%);
    border: 1px solid rgba(255,255,255,0.20);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    cursor: pointer;
    flex-shrink: 0;
    overflow: hidden;
    animation: start-btn-pulse 3s ease-in-out infinite;
    transition: transform 0.14s, border-color 0.14s, background 0.14s;
}
.taskbar-start:hover {
    background: linear-gradient(145deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0.08) 100%);
    border-color: rgba(255,255,255,0.35);
    transform: scale(1.07);
}

.taskbar-apps {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    padding: 0 4px;
    overflow: hidden;
}

@keyframes taskbar-app-in {
    from { opacity: 0; transform: translateY(8px) scale(0.92); }
    to   { opacity: 1; transform: none; }
}

.taskbar-app-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    height: 48px;
    min-width: 48px;
    max-width: 184px;
    padding: 0 14px 0 11px;
    border-radius: 12px;
    background: linear-gradient(150deg, rgba(255,255,255,0.075) 0%, rgba(255,255,255,0.025) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--os-text-dim);
    cursor: pointer;
    font-family: inherit;
    overflow: hidden;
    animation: taskbar-app-in 0.22s cubic-bezier(0.22,1,0.36,1) both;
    transition: background 0.15s, color 0.15s, border-color 0.15s,
                transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.taskbar-app-btn:hover {
    background: linear-gradient(150deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.06) 100%);
    border-color: rgba(255,255,255,0.18);
    color: var(--os-text);
    transform: translateY(-1px);
}
.taskbar-app-btn:active { transform: translateY(0) scale(0.97); }
.taskbar-app-btn.active {
    background: linear-gradient(150deg,
        color-mix(in srgb, var(--os-accent) 30%, transparent) 0%,
        color-mix(in srgb, var(--os-accent) 12%, transparent) 100%);
    border-color: color-mix(in srgb, var(--os-accent) 44%, transparent);
    color: var(--os-text);
    box-shadow: 0 3px 12px color-mix(in srgb, var(--os-accent) 24%, transparent),
                inset 0 1px 0 rgba(255,255,255,0.14);
}
.taskbar-app-btn.minimized { opacity: 0.6; }
.taskbar-app-btn.minimized:hover { opacity: 1; }

/* App icon — larger, with a subtle drop shadow so emoji/glyphs read crisply */
.taskbar-app-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    font-size: 19px;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* App label — pretext-consistent weight/spacing, truncates gracefully */
.taskbar-app-label {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 116px;
}

/* Running / focus indicator — underline bar that grows into an accent pill */
.taskbar-app-indicator {
    position: absolute;
    left: 50%;
    bottom: 3px;
    transform: translateX(-50%);
    width: 16px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255,255,255,0.45);
    transition: width 0.2s cubic-bezier(0.22,1,0.36,1), background 0.2s, box-shadow 0.2s;
}
.taskbar-app-btn:hover .taskbar-app-indicator { width: 22px; background: rgba(255,255,255,0.72); }
.taskbar-app-btn.active .taskbar-app-indicator {
    width: 30px;
    background: var(--os-accent);
    box-shadow: 0 0 8px color-mix(in srgb, var(--os-accent) 70%, transparent);
}
.taskbar-app-btn.minimized .taskbar-app-indicator {
    width: 8px;
    background: rgba(255,255,255,0.3);
    box-shadow: none;
}

.taskbar-dev-badge {
    display: none; /* shown via JS when isDev() */
    align-items: center;
    padding: 2px 9px;
    border-radius: 6px;
    background: rgba(255, 208, 128, 0.15);
    border: 1px solid rgba(255, 208, 128, 0.35);
    color: #ffd080;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 2px;
    transition: background 0.12s;
}
.taskbar-dev-badge:hover { background: rgba(255, 208, 128, 0.28); }

/* Subtle amber border around the whole OS when in dev mode */
html[data-os-mode="developer"] #os-root,
html[data-os-mode="developer"] body {
    outline: 2px solid rgba(255, 208, 128, 0.18);
    outline-offset: -2px;
}

/* ── Status tray ──────────────────────────────────────────────────────── */
.taskbar-tray {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.tray-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.78);
    white-space: nowrap;
    padding: 0 14px;
    height: 42px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.09);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    user-select: none;
}
.tray-item:hover {
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.14);
    color: #f0f2f8;
}
/* Distinct per-item tints */
.tray-item--gpu  { background: rgba(91,124,255,0.10); border-color: rgba(91,124,255,0.16); }
.tray-item--gpu:hover  { background: rgba(91,124,255,0.20); border-color: rgba(91,124,255,0.28); }
.tray-item--fps  { background: rgba(31,210,180,0.09); border-color: rgba(31,210,180,0.15); }
.tray-item--fps:hover  { background: rgba(31,210,180,0.18); border-color: rgba(31,210,180,0.26); }
.tray-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--os-accent-2);
    flex-shrink: 0;
    box-shadow: 0 0 4px currentColor;
}
.tray-dot.warn  { background: #f59e0b; }
.tray-dot.error { background: #ef4444; }

/* ── Plauna DOMPanel hardening + chrome ──────────────────────────────── */
.plauna-panel {
    background: var(--bg-secondary, #0d1120) !important;
    border: 1px solid var(--border-medium, rgba(255,255,255,0.09)) !important;
    box-shadow: var(--shadow-xl, 0 14px 56px rgba(0,0,0,0.65)) !important;
    isolation: isolate;
    transition: box-shadow 0.2s, border-color 0.2s;
}

/* Focused panel — accent glow + stronger border */
.plauna-panel--focused {
    box-shadow: var(--os-focus-glow), var(--shadow-xl, 0 14px 56px rgba(0,0,0,0.65)) !important;
    border-color: color-mix(in srgb, var(--os-accent) 30%, rgba(255,255,255,0.09)) !important;
}

/* Unfocused panel — dims by chrome-contrast amount */
.plauna-panel--unfocused .plauna-panel__titlebar {
    filter: brightness(calc(1 - var(--os-chrome-contrast, 0.5) * 0.45)) saturate(0.7);
}
.plauna-panel--unfocused {
    box-shadow: 0 4px 24px rgba(0,0,0,0.45) !important;
}

/* Titlebar: full gradient chrome with specular sheen */
.plauna-panel__titlebar {
    background: var(--os-panel-chrome) !important;
    border-color: rgba(255,255,255,0.10) !important;
    position: relative;
    overflow: hidden;
    transition: filter 0.2s, background 0.25s;
}

/* Specular sheen pseudo-element (neobrutalist top-edge) */
.plauna-panel__titlebar::after {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: rgba(255,255,255,0.28);
    pointer-events: none;
}

/* Neobrutalist bottom accent divider */
.plauna-panel__titlebar::before {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 1px;
    background: rgba(0,0,0,0.22);
    pointer-events: none;
}

/* ── Desktop shell surfaces ───────────────────────────────────────────── */
.os-desktop-shortcut {
    outline: none;
    -webkit-user-select: none;
    user-select: none;
}
.os-desktop-shortcut:focus-visible {
    background: rgba(255,255,255,0.10) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--os-accent) 58%, transparent), 0 10px 32px rgba(0,0,0,0.44) !important;
}
.os-window-overview {
    position: fixed;
    inset: 0;
    z-index: 9800;
    display: grid;
    place-items: center;
    padding: 48px;
    background: rgba(5, 7, 15, 0.58);
    backdrop-filter: blur(18px) saturate(1.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.1);
    animation: shell-overview-in 0.16s ease-out both;
    -webkit-user-select: none;
    user-select: none;
}
.os-window-overview-grid {
    width: min(980px, 100%);
    max-height: min(720px, calc(100vh - 120px));
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    padding: 4px;
}
.os-window-card {
    min-width: 0;
    display: grid;
    grid-template-rows: 122px auto auto;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(255,255,255,0.105), rgba(255,255,255,0.035));
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    font: inherit;
    box-shadow: 0 16px 48px rgba(0,0,0,0.40);
}
.os-window-card:hover,
.os-window-card:focus-visible {
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--os-accent) 44%, transparent);
    background: linear-gradient(145deg, rgba(255,255,255,0.15), rgba(255,255,255,0.055));
    outline: none;
}
.os-window-card-thumb {
    display: grid;
    place-items: center;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.09);
    background:
        linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255,255,255,0.035) 1px, transparent 1px),
        rgba(12, 15, 29, 0.76);
    background-size: 18px 18px;
    color: var(--text-tertiary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.os-window-card-title {
    min-width: 0;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 780;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.os-window-card-meta {
    min-width: 0;
    color: var(--text-tertiary);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.os-window-empty {
    grid-column: 1 / -1;
    min-height: 180px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 12px;
    color: var(--text-tertiary);
    background: rgba(255,255,255,0.04);
}
@keyframes shell-overview-in {
    from { opacity: 0; transform: scale(0.985); }
    to { opacity: 1; transform: none; }
}

/* ── Start menu ───────────────────────────────────────────────────────── */
.os-start-menu {
    position: fixed;
    bottom: calc(var(--os-taskbar-h) + 10px);
    left: 12px;
    width: min(720px, calc(100vw - 24px));
    max-height: calc(100vh - var(--os-taskbar-h) - 24px);
    background: var(--os-taskbar-bg, rgba(13,17,32,0.82));
    border: 1px solid var(--os-border);
    border-radius: var(--os-radius, 14px);
    box-shadow: var(--os-shadow, 0 24px 80px rgba(0,0,0,.48));
    backdrop-filter: blur(var(--os-blur));
    -webkit-backdrop-filter: blur(var(--os-blur));
    padding: 14px;
    z-index: 9000;  /* always above panels */
    display: none;
    flex-direction: column;
    transform-origin: bottom left;
    /* Tiles/labels must not text-highlight while clicking or dragging to desktop. */
    user-select: none;
    -webkit-user-select: none;
}
.os-start-menu.is-open {
    display: flex;
    animation: sm-open 0.18s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes sm-open {
    from { opacity: 0; transform: scale(0.96) translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.start-menu-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 -4px;
    padding: 0 4px 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.start-menu-list::-webkit-scrollbar { width: 5px; }
.start-menu-list::-webkit-scrollbar-track { background: transparent; }
.start-menu-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.start-menu-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

.start-menu-top { display: grid; grid-template-columns: minmax(210px, 1fr) minmax(260px, 360px); gap: 12px; align-items: center; margin-bottom: 12px; }
.start-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.start-brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--os-accent) 42%, transparent); background: color-mix(in srgb, var(--os-accent) 20%, transparent); color: #fff; box-shadow: 0 0 22px color-mix(in srgb, var(--os-accent) 28%, transparent); }
.start-brand-title { font-size: 15px; font-weight: 820; color: var(--text-primary); }
.start-brand-subtitle { margin-top: 1px; font-size: 11px; color: var(--text-tertiary); }
.start-search {
    width: 100%; min-height: 38px; border: 1px solid var(--border-medium); border-radius: 10px;
    background: rgba(255,255,255,.065); color: var(--text-primary); padding: 9px 12px;
    font: 13px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; outline: none;
    user-select: text; -webkit-user-select: text;
}
.start-search:focus { border-color: color-mix(in srgb, var(--os-accent) 58%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--os-accent) 18%, transparent); }
.start-hero { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.start-metric { border: 1px solid rgba(255,255,255,.09); border-radius: 10px; background: rgba(255,255,255,.045); padding: 8px 10px; min-width: 0; }
.start-metric-label { display: block; color: var(--text-tertiary); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.start-metric-value { display: block; color: var(--text-primary); font-size: 14px; font-weight: 820; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.start-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text-tertiary); font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 9px 2px 7px; }
.start-section-count { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.start-pinned-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; margin-bottom: 6px; }
.start-pinned-tile {
    min-width: 0; display: grid; grid-template-rows: 44px 28px; justify-items: center; gap: 5px;
    border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-secondary);
    padding: 9px 5px 7px; cursor: pointer; font: inherit;
}
.start-pinned-tile:hover, .start-pinned-tile:focus-visible { border-color: var(--border-light); background: rgba(255,255,255,.065); outline: none; }
.start-pinned-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); font-size: 21px; overflow: hidden; }
.start-pinned-icon img, .start-recent-icon img, .start-menu-item .app-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.start-pinned-label { width: 100%; color: var(--text-secondary); font-size: 11px; line-height: 1.2; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.start-recent-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 4px; }
.start-recent-chip {
    max-width: 150px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-light);
    border-radius: 999px; background: rgba(255,255,255,.05); color: var(--text-secondary); padding: 6px 9px; cursor: pointer; font: inherit;
}
.start-recent-chip:hover { background: rgba(255,255,255,.08); color: var(--text-primary); }
.start-recent-icon { width: 18px; height: 18px; display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.start-recent-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.start-category-rail { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.start-category-pill {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-light); border-radius: 999px;
    background: rgba(255,255,255,.04); color: var(--text-secondary); padding: 5px 8px; cursor: pointer; font: inherit; font-size: 11px;
}
.start-category-pill.active, .start-category-pill:hover { border-color: color-mix(in srgb, var(--os-accent) 46%, transparent); background: color-mix(in srgb, var(--os-accent) 17%, transparent); color: var(--text-primary); }
.start-category-count, .start-category-total { color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.start-app-groups { column-count: 2; column-gap: 8px; }
.start-category-group { min-width: 0; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: rgba(255,255,255,.032); overflow: hidden; break-inside: avoid; margin-bottom: 8px; }
.start-category-group.collapsed { background: rgba(255,255,255,.026); }
.start-category-header {
    width: 100%; display: grid; grid-template-columns: 18px 24px minmax(0, 1fr) auto; align-items: center; gap: 7px;
    border: 0; background: rgba(255,255,255,.035); color: var(--text-secondary); padding: 8px 10px; cursor: pointer; font: inherit; text-align: left;
}
.start-category-header:hover { background: rgba(255,255,255,.06); }
.start-chevron { color: var(--text-tertiary); transition: transform .16s; }
.start-chevron.open { transform: rotate(90deg); }
.start-category-icon { text-align: center; }
.start-category-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 780; text-transform: uppercase; letter-spacing: .06em; }
.start-category-body { display: grid; gap: 2px; padding: 4px; }
.start-category-body.collapsed { display: none; }
.start-search-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.start-menu-item {
    width: 100%;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s;
    font: inherit;
    text-align: left;
}
.start-menu-item:hover, .start-menu-item:focus-visible { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,.08); outline: none; }
.start-menu-item .app-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.start-menu-item .app-name { min-width: 0; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.start-menu-item .app-category { font-size: 11px; color: var(--os-text-dim); margin-left: auto; }
.start-footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; border-top: 1px solid rgba(255,255,255,.09); padding-top: 10px; margin-top: 10px; }
.start-footer-btn {
    min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid var(--border-light); border-radius: 10px; background: rgba(255,255,255,.05); color: var(--text-secondary);
    padding: 8px 9px; cursor: pointer; font: inherit;
}
.start-footer-btn:hover { color: var(--text-primary); background: rgba(255,255,255,.08); }
.start-context-menu { position: fixed; z-index: 99999; min-width: 190px; padding: 6px; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; background: rgba(18, 10, 30, .98); box-shadow: 0 14px 44px rgba(0,0,0,.52); color: var(--text-primary); }
.start-context-item { width: 100%; display: flex; align-items: center; gap: 9px; border: 0; border-radius: 7px; background: transparent; color: inherit; padding: 8px 10px; cursor: pointer; font: inherit; text-align: left; }
.start-context-item:hover { background: color-mix(in srgb, var(--os-accent) 20%, transparent); }
.start-context-icon { width: 18px; text-align: center; }
.start-empty { min-height: 160px; display: grid; place-content: center; text-align: center; color: var(--text-tertiary); gap: 4px; }
.start-empty-title { color: var(--text-secondary); font-weight: 780; }
@media (max-width: 760px) {
    .os-start-menu { left: 8px; right: 8px; width: auto; }
    .start-menu-top { grid-template-columns: 1fr; }
    .start-pinned-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .start-app-groups { column-count: 1; }
    .start-search-results { grid-template-columns: 1fr; }
}

/* ── Plauna root overlay ──────────────────────────────────────────────── */
#os-desktop > [data-plauna], .plauna-workspace {
    position: absolute;
    inset: 0;
    pointer-events: auto;
}

/* ── Boot loader ──────────────────────────────────────────────────────── */
.os-boot-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 50% 38%, rgba(91, 124, 255, 0.22), transparent 28rem),
        rgba(7, 9, 15, 0.97);
    transition: opacity 280ms ease, visibility 280ms ease;
}
.os-boot-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.boot-card {
    width: min(400px, calc(100vw - 48px));
    padding: 38px 36px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 26px;
    background: rgba(13, 17, 29, 0.80);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.50);
    text-align: center;
    backdrop-filter: blur(24px);
}

.boot-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--os-accent), var(--os-accent-2));
    box-shadow: 0 0 48px rgba(91, 124, 255, 0.38);
    animation: boot-pulse 1.9s ease-in-out infinite;
}

.boot-card h1 {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.boot-card p {
    margin: 0;
    font-size: 13px;
    color: var(--os-text-dim);
    line-height: 1.6;
}

@keyframes boot-pulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50%       { transform: scale(1.07) rotate(5deg); }
}

/* ════════════════════════════════════════════════════════════════════════
   FLASHBANG MODE — light theme, active when Dark Mode is turned OFF
   (Quick Settings toggles html.theme-light). Blinding-white surfaces, heavy
   bloom, and glowing "flashlight" text where every letter emits light.
   Custom props use !important to override the inline values ThemeEngine
   writes directly on <html>.
   ════════════════════════════════════════════════════════════════════════ */
html.theme-light {
    color-scheme: light;
    --os-bg:          #eef2ff !important;
    --os-surface:     #ffffff !important;
    --os-surface-2:   #f3f6ff !important;
    --os-border:      rgba(120,150,255,0.45) !important;
    --os-text:        #0a0e1a !important;
    --os-text-dim:    rgba(10,14,26,0.6) !important;

    --bg-primary:     #eef2ff !important;
    --bg-secondary:   #ffffff !important;
    --bg-tertiary:    #f3f6ff !important;
    --border-light:   rgba(120,150,255,0.32) !important;
    --border-medium:  rgba(120,150,255,0.5)  !important;
    --border-heavy:   rgba(120,150,255,0.7)  !important;
    --text-primary:   #0a0e1a !important;
    --text-secondary: rgba(10,14,26,0.72) !important;
    --text-tertiary:  rgba(10,14,26,0.5)  !important;

    --os-glow-1:     rgba(255,255,255,0.95) !important;
    --os-glow-2:     rgba(180,200,255,0.75) !important;
    --os-taskbar-bg: rgba(255,255,255,0.72) !important;
    --os-shadow: 0 8px 40px rgba(150,180,255,0.55), 0 0 90px rgba(255,255,255,0.65) !important;
    --shadow-lg: 0 8px 40px rgba(150,180,255,0.55), 0 0 70px rgba(255,255,255,0.6)  !important;
    --shadow-md: 0 4px 20px rgba(150,180,255,0.45), 0 0 44px rgba(255,255,255,0.55) !important;
    --shadow-sm: 0 2px 10px rgba(150,180,255,0.4) !important;
    --os-hover:   rgba(30,50,130,0.07) !important;
    --os-hover-2: rgba(30,50,130,0.14) !important;
    --term-bg:    #eafbea !important;
    --term-fg:    #176117 !important;
    --term-accent:#15803d !important;
}

html.theme-light body { background: #e9eeff; color: var(--os-text); }

/* Glowing "flashlight" text — every letter emits a bright halo (inherited). */
html.theme-light {
    text-shadow:
        0 0 2px  rgba(255,255,255,0.95),
        0 0 7px  rgba(255,255,255,0.85),
        0 0 15px rgba(150,180,255,0.7),
        0 0 28px rgba(120,160,255,0.5);
}

/* Panels glow hot-white. */
html.theme-light .plauna-panel {
    box-shadow:
        0 0 0 1px rgba(150,180,255,0.5),
        0 10px 50px rgba(150,180,255,0.55),
        0 0 95px rgba(255,255,255,0.7) !important;
}

/* WebGPU bloom: an additive (screen-blended) white wash over the desktop so the
   particle world blooms through for a blinding "extra glow from the GPU" look. */
html.theme-light .os-desktop::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(circle at 50% 42%,
        rgba(255,255,255,0.55) 0%,
        rgba(210,224,255,0.24) 38%,
        transparent 70%);
    mix-blend-mode: screen;
    animation: flashbang-breathe 4s ease-in-out infinite;
}
@keyframes flashbang-breathe {
    0%, 100% { opacity: 0.78; }
    50%      { opacity: 1; }
}

/* One-shot blinding entry flash (injected by Quick Settings on activation). */
.flashbang-flash {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    pointer-events: none;
    background: #ffffff;
    animation: flashbang-pop 0.62s ease-out forwards;
}
@keyframes flashbang-pop {
    0%   { opacity: 0; }
    9%   { opacity: 1; }
    100% { opacity: 0; }
}

/* Respect reduced motion — no breathing bloom, no blinding flash. */
html.theme-light.reduce-motion .os-desktop::after { animation: none; opacity: 0.85; }
html.reduce-motion .flashbang-flash { animation: none; opacity: 0; }

/* ── Flashbang skin: re-color components that hardcode dark palettes ──────
   These use class-based <style> blocks, so we override them to theme vars so
   they flip to light. (Inline-styled internals are converted to vars in JS.) */

/* Start menu */
html.theme-light .os-start-menu { background: rgba(255,255,255,0.94) !important; }
html.theme-light .start-menu-item:hover { background: var(--os-hover-2) !important; }
html.theme-light .start-menu-item .app-icon { background: var(--os-hover) !important; }

/* Command palette */
html.theme-light .cp-backdrop { background: rgba(150,180,255,0.28) !important; }
html.theme-light .cp-box { background: rgba(255,255,255,0.98) !important; border-color: var(--os-border) !important; }
html.theme-light .cp-header { border-bottom-color: var(--os-border) !important; }
html.theme-light .cp-input { color: var(--text-primary) !important; }
html.theme-light .cp-input::placeholder { color: var(--text-tertiary) !important; }
html.theme-light .cp-hint,
html.theme-light .cp-cat,
html.theme-light .cp-idesc,
html.theme-light .cp-footer { color: var(--text-tertiary) !important; }
html.theme-light .cp-iname { color: var(--text-primary) !important; }
html.theme-light .cp-iicon { background: var(--os-hover) !important; }
html.theme-light .cp-footer { border-top-color: var(--os-border) !important; }
html.theme-light .cp-footer kbd { background: var(--os-hover) !important; border-color: var(--os-border) !important; color: var(--text-secondary) !important; }

/* Notification history */
html.theme-light .nh-panel { background: rgba(255,255,255,0.98) !important; border-left-color: var(--os-border) !important; color: var(--text-primary) !important; }
html.theme-light .nh-title { color: var(--text-primary) !important; }
html.theme-light .nh-header { border-bottom-color: var(--os-border) !important; }
html.theme-light .nh-btn { background: var(--os-hover) !important; color: var(--text-secondary) !important; }
html.theme-light .nh-btn:hover { background: var(--os-hover-2) !important; color: var(--text-primary) !important; }
html.theme-light .nh-close { color: var(--text-tertiary) !important; }
html.theme-light .nh-empty,
html.theme-light .nh-group-label { color: var(--text-tertiary) !important; }
html.theme-light .nh-item:hover { background: var(--os-hover) !important; }

/* Quick settings */
html.theme-light .qs-panel { background: rgba(255,255,255,0.97) !important; border-color: var(--os-border) !important; color: var(--text-primary) !important; }
html.theme-light .qs-title { color: var(--text-primary) !important; }
html.theme-light .qs-sub,
html.theme-light .qs-stat { color: var(--text-tertiary) !important; }
html.theme-light .qs-row { background: var(--os-hover) !important; }
html.theme-light .qs-row:hover { background: var(--os-hover-2) !important; }
html.theme-light .qs-toggle { background: var(--os-hover-2) !important; }
html.theme-light .qs-divider { background: var(--os-border) !important; }
html.theme-light .qs-qbtn { background: var(--os-hover) !important; border-color: var(--os-border) !important; color: var(--text-secondary) !important; }
html.theme-light .qs-openSettings { border-color: var(--os-border) !important; color: var(--text-secondary) !important; }

/* GPU Manager */
html.theme-light .gpu-root { background: #f3f6ff !important; color: #16203a !important; }
html.theme-light .gpu-header { background: #ffffff !important; border-bottom-color: var(--os-border) !important; }
html.theme-light .gpu-section { background: var(--os-hover) !important; }
html.theme-light .gpu-row { border-bottom-color: var(--os-border) !important; }
html.theme-light .gpu-key { color: rgba(22,32,58,0.55) !important; }
html.theme-light .gpu-val { color: #16203a !important; }
html.theme-light .gpu-bar-wrap { background: var(--os-hover-2) !important; }

/* Permissions manager */
html.theme-light .pm-root { background: #f3f6ff !important; color: #16203a !important; }
html.theme-light .pm-toolbar,
html.theme-light .pm-detail-head,
html.theme-light .pm-apps,
html.theme-light .pm-audit,
html.theme-light .pm-status { border-color: var(--os-border) !important; }
html.theme-light .pm-search { background: var(--os-hover) !important; color: var(--text-primary) !important; border-color: var(--os-border) !important; }
html.theme-light .pm-app-item:hover { background: var(--os-hover) !important; }
html.theme-light .pm-cap-row { background: var(--os-hover) !important; }
html.theme-light .pm-cap-row:hover { background: var(--os-hover-2) !important; }
html.theme-light .pm-app-id,
html.theme-light .pm-detail-id,
html.theme-light .pm-cap-section,
html.theme-light .pm-cap-sublabel,
html.theme-light .pm-cap-state.default,
html.theme-light .pm-empty,
html.theme-light .pm-audit,
html.theme-light .pm-status { color: var(--text-tertiary) !important; }
html.theme-light .pm-audit { background: var(--os-hover) !important; }
html.theme-light .pm-btn { background: var(--os-hover) !important; border-color: var(--os-border) !important; color: var(--text-secondary) !important; }
html.theme-light .pm-btn:hover { background: var(--os-hover-2) !important; }
