@font-face {
    font-family: "Luma Sans";
    src: url("../fonts/open_sans/OpenSans-Regular.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Luma Sans";
    src: url("../fonts/open_sans/OpenSans-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-display: swap;
}

:root {
    color-scheme: light;
    --luma-accent: #6d5ee8;
    --luma-accent-rgb: 109, 94, 232;
    --desktop-ink: #f7f7ff;
    --surface: rgba(250, 249, 255, .94);
    --surface-solid: #faf9ff;
    --surface-muted: #f0eef8;
    --surface-raised: #ffffff;
    --ink: #17182a;
    --ink-muted: #626478;
    --line: rgba(35, 37, 64, .1);
    --taskbar: rgba(237, 238, 255, .76);
    --taskbar-ink: #16182b;
    --window-shadow: 0 22px 70px rgba(13, 18, 46, .24), 0 3px 12px rgba(13, 18, 46, .12);
    --panel-shadow: 0 18px 54px rgba(13, 18, 46, .25), 0 2px 8px rgba(13, 18, 46, .12);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --taskbar-height: 64px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --surface: rgba(17, 26, 55, .95);
    --surface-solid: #111a37;
    --surface-muted: #1a2548;
    --surface-raised: #202d55;
    --ink: #f5f6ff;
    --ink-muted: #b9c2dd;
    --line: rgba(230, 235, 255, .12);
    --taskbar: rgba(12, 20, 44, .78);
    --taskbar-ink: #f5f6ff;
}

:root[data-theme="luma"] {
    color-scheme: dark;
    --surface: rgba(11, 27, 64, .93);
    --surface-solid: #0d214a;
    --surface-muted: #162f60;
    --surface-raised: #1b3970;
    --ink: #f6f8ff;
    --ink-muted: #c1cff0;
    --line: rgba(193, 217, 255, .14);
    --taskbar: rgba(13, 26, 59, .72);
    --taskbar-ink: #f7f8ff;
}

:root[data-density="compact"] {
    --taskbar-height: 58px;
}

:root[data-density="compact"] .taskbar { height: 46px; }
:root[data-density="compact"] .luma-window { grid-template-rows: 42px minmax(0, 1fr); }
:root[data-density="compact"] .document-row { min-height: 42px; }

:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    font-family: "Luma Sans", sans-serif;
    color: var(--ink);
    background: #0d1532 url("../../images/backgrounds/luma-aurora.webp") center / cover no-repeat;
    user-select: none;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

button:not(:disabled) {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--luma-accent), white 24%);
    outline-offset: 2px;
}

.icon-sprite {
    position: fixed;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none !important;
}

.desktop,
.session-root {
    width: 100%;
    height: 100%;
}

.desktop {
    position: relative;
    isolation: isolate;
    color: var(--desktop-ink);
}

.desktop::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(120deg, rgba(4, 10, 31, .14), transparent 45%, rgba(23, 14, 70, .12));
    pointer-events: none;
}

.desktop-brand {
    position: fixed;
    top: 22px;
    left: 26px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: -.02em;
    text-shadow: 0 2px 12px rgba(2, 6, 22, .5);
}

.desktop-brand .icon {
    width: 25px;
    height: 25px;
    color: #a9b4ff;
}

.desktop-shortcuts {
    position: fixed;
    top: 78px;
    left: 18px;
    display: grid;
    gap: 8px;
}

.desktop-shortcut {
    width: 86px;
    min-height: 88px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 7px;
    padding: 8px 5px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: transparent;
    text-shadow: 0 2px 7px rgba(0, 0, 0, .72);
}

.desktop-shortcut:hover,
.desktop-shortcut:focus-visible {
    background: rgba(231, 235, 255, .16);
    backdrop-filter: blur(12px);
}

.desktop-shortcut > span:last-child {
    max-width: 80px;
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.app-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 7px 16px rgba(4, 7, 24, .2);
}

.app-icon .icon {
    width: 19px;
    height: 19px;
}

.app-icon--documents { background: linear-gradient(145deg, #42bde7, #5271df); }
.app-icon--settings { background: linear-gradient(145deg, #8d76ff, #5a4dcc); }
.app-icon--trash { background: linear-gradient(145deg, #6f86a5, #394d70); }
.app-icon--browser { background: linear-gradient(145deg, #36c8aa, #177cbd); }
.app-icon--jellyfin { background: linear-gradient(145deg, #9754e9, #5533a9); }

.window-layer {
    position: fixed;
    inset: 0 0 var(--taskbar-height);
    overflow: hidden;
    pointer-events: none;
}

.luma-window {
    position: absolute;
    top: 8vh;
    left: 16vw;
    width: min(920px, calc(100vw - 48px));
    height: min(680px, calc(100vh - 112px));
    min-width: 360px;
    min-height: 300px;
    display: grid;
    grid-template-rows: 46px minmax(0, 1fr);
    overflow: hidden;
    border-radius: 15px;
    color: var(--ink);
    background: var(--surface);
    box-shadow: var(--window-shadow);
    backdrop-filter: blur(28px) saturate(128%);
    pointer-events: auto;
    animation: window-arrive 360ms var(--ease-out) both;
}

@keyframes window-arrive {
    from { opacity: .72; transform: translateY(14px) scale(.985); filter: blur(6px); box-shadow: 0 8px 28px rgba(13, 18, 46, .18); }
}

.luma-window[data-state="maximized"] {
    inset: 8px 8px 8px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 12px;
}

.luma-window[data-state="snap-left"] {
    inset: 8px calc(50% + 4px) 8px 8px !important;
    width: auto !important;
    height: auto !important;
}

.luma-window[data-state="snap-right"] {
    inset: 8px 8px 8px calc(50% + 4px) !important;
    width: auto !important;
    height: auto !important;
}

.luma-window[data-state="minimized"] {
    display: none;
}

.luma-window.is-active {
    box-shadow: 0 26px 76px rgba(4, 8, 30, .32), 0 3px 14px rgba(4, 8, 30, .16);
}

.window-titlebar {
    display: flex;
    align-items: center;
    min-width: 0;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 54%, transparent);
    touch-action: none;
}

.window-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 13px;
    font-size: 13px;
    font-weight: 600;
}

.window-heading .app-icon {
    width: 25px;
    height: 25px;
    border-radius: 7px;
    box-shadow: none;
}

.window-heading .icon {
    width: 15px;
    height: 15px;
}

.window-heading span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.window-drag-region {
    min-width: 24px;
    align-self: stretch;
    flex: 1;
}

.window-controls {
    align-self: stretch;
    display: flex;
}

.window-control {
    width: 46px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: transparent;
}

.window-control .icon {
    width: 14px;
    height: 14px;
}

.window-control:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.window-control--close:hover { color: #fff; background: #d83a52; }

.window-content {
    min-height: 0;
    overflow: auto;
    background: var(--surface-solid);
    container-type: inline-size;
}

.window-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

.taskbar {
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 10px;
    min-width: 290px;
    max-width: calc(100vw - 24px);
    height: 52px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    color: var(--taskbar-ink);
    border-radius: 16px;
    background: var(--taskbar);
    box-shadow: 0 16px 38px rgba(4, 8, 30, .28), 0 2px 8px rgba(4, 8, 30, .12);
    backdrop-filter: blur(26px) saturate(150%);
    transform: translateX(-50%);
}

.taskbar-button,
.status-button,
.icon-button {
    position: relative;
    min-width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 11px;
    background: transparent;
}

.taskbar-button:hover,
.status-button:hover,
.icon-button:hover,
.taskbar-button[aria-pressed="true"] {
    background: color-mix(in srgb, var(--taskbar-ink) 9%, transparent);
}

.taskbar-launcher {
    color: color-mix(in srgb, var(--luma-accent), white 22%);
}

.taskbar-launcher .icon { width: 25px; height: 25px; }

.taskbar-apps {
    min-width: 0;
    display: flex;
    gap: 4px;
    overflow: auto hidden;
    scrollbar-width: none;
}

.taskbar-app {
    min-width: 118px;
    max-width: 158px;
    grid-template-columns: 28px minmax(0, 1fr);
    justify-content: start;
    gap: 8px;
    padding: 0 10px;
}

.taskbar-app::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 2px;
    width: 24px;
    height: 3px;
    border-radius: 4px;
    background: var(--luma-accent);
    transform: translateX(-50%) scaleX(.22);
    transition: transform 180ms var(--ease-out);
}

.taskbar-app.is-active::after { transform: translateX(-50%) scaleX(1); }
.taskbar-app.is-minimized { opacity: .76; }
.taskbar-app .app-icon { width: 27px; height: 27px; border-radius: 8px; box-shadow: none; }
.taskbar-app > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

.taskbar-status {
    display: flex;
    align-items: center;
    margin-left: 3px;
    padding-left: 5px;
    border-left: 1px solid color-mix(in srgb, var(--taskbar-ink) 12%, transparent);
}

.status-button { min-width: 34px; width: 34px; }
.status-button .icon { width: 17px; height: 17px; }

.clock {
    min-width: 65px;
    display: grid;
    gap: 1px;
    padding: 2px 7px;
    border: 0;
    border-radius: 9px;
    color: inherit;
    text-align: right;
    background: transparent;
}

.clock:hover { background: color-mix(in srgb, var(--taskbar-ink) 9%, transparent); }
.clock span { font-size: 12px; font-weight: 600; }
.clock small { font-size: 10px; color: color-mix(in srgb, var(--taskbar-ink) 72%, transparent); }

.start-panel {
    position: fixed;
    z-index: 999;
    left: 50%;
    bottom: 72px;
    width: min(560px, calc(100vw - 24px));
    max-height: min(640px, calc(100vh - 92px));
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 20px;
    padding: 22px;
    overflow: hidden;
    color: var(--ink);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(30px) saturate(135%);
    transform: translateX(-50%);
    animation: panel-arrive 280ms var(--ease-out) both;
}

@keyframes panel-arrive {
    from { opacity: .55; transform: translate(-50%, 18px) scale(.98); filter: blur(6px); }
}

.start-search {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    border-radius: 11px;
    background: var(--surface-muted);
}

.start-search .icon { width: 17px; height: 17px; color: var(--ink-muted); }
.start-search input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; }
.start-search input::placeholder { color: var(--ink-muted); opacity: 1; }

.start-panel__heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.start-panel__heading h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.start-panel__heading span { color: var(--ink-muted); font-size: 12px; }

.start-apps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow: auto;
}

.start-app {
    min-width: 0;
    min-height: 86px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 10px 6px;
    border: 0;
    border-radius: 12px;
    color: var(--ink);
    background: transparent;
}

.start-app:hover { background: var(--surface-muted); }
.start-app span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

.start-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 -22px -22px;
    padding: 13px 22px;
    background: color-mix(in srgb, var(--surface-muted) 72%, transparent);
}

.account-chip { min-width: 0; display: flex; align-items: center; gap: 10px; }
.account-chip > span:last-child { min-width: 0; display: grid; }
.account-chip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-chip small { color: var(--ink-muted); font-size: 11px; }

.account-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    background: linear-gradient(145deg, var(--luma-accent), #31b8e6);
}

.session-actions { display: flex; align-items: center; gap: 4px; }
.session-actions > button:first-child { min-height: 38px; padding: 0 12px; border: 0; border-radius: 9px; color: var(--ink); background: transparent; }
.session-actions > button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }

.toast-region {
    position: fixed;
    z-index: 2000;
    right: 18px;
    bottom: 78px;
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    width: min(360px, calc(100vw - 36px));
    padding: 13px 16px;
    border-radius: 12px;
    color: var(--ink);
    background: var(--surface-raised);
    box-shadow: var(--panel-shadow);
    animation: toast-arrive 260ms var(--ease-out) both;
}

@keyframes toast-arrive { from { opacity: .3; transform: translateY(12px); filter: blur(4px); } }

@media (max-width: 720px) {
    :root { --taskbar-height: 70px; }
    .desktop-brand { top: 14px; left: 16px; }
    .desktop-shortcuts { top: 58px; left: 8px; }
    .luma-window,
    .luma-window[data-state] {
        inset: 4px 4px 6px !important;
        width: auto !important;
        height: auto !important;
        min-width: 0;
        border-radius: 12px;
    }
    .taskbar { bottom: 8px; width: calc(100vw - 16px); justify-content: center; }
    .taskbar-app { min-width: 42px; width: 42px; padding: 0 7px; grid-template-columns: 1fr; }
    .taskbar-app > span:last-child { display: none; }
    .taskbar-status { margin-left: auto; }
    .status-button { display: none; }
    .start-apps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .window-resize { display: none; }
}

@media (max-width: 430px) {
    .clock small { display: none; }
    .clock { min-width: 48px; }
    .taskbar { min-width: 0; }
    .session-actions > button:first-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
