:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --status-height: 32px;
    --dock-height: 88px;
    --dock-gap: 14px;
    --pagination-space: 18px;
    --page-gap: 20px;
    --desktop-keyboard-offset: 0px;
    --ink: #111315;
    --muted: #62686d;
    --surface: rgba(255, 255, 255, 0.44);
    --surface-strong: rgba(255, 255, 255, 0.72);
    --line: rgba(255, 255, 255, 0.5);
    --focus: #2367d1;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    letter-spacing: 0;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    min-width: 280px;
    overflow: hidden;
    overscroll-behavior: none;
}

html {
    background: #e9edf1;
}

body {
    color: var(--ink);
    background: linear-gradient(135deg, #e3e8ed 0%, #f6f7f8 58%, #e9eff2 100%);
}


.startup-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    place-items: center;
    padding-right: var(--safe-right);
    padding-left: var(--safe-left);
    overflow: hidden;
    background: #fff;
    opacity: 1;
    isolation: isolate;
    transition: opacity 1s ease-in-out;
}

.startup-loader.is-complete {
    opacity: 0;
    pointer-events: none;
}

.startup-loader__core {
    position: relative;
    width: min(400px, 100%);
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.startup-loader__backdrop {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    transform: translate(-50%, -50%);
}

.startup-loader__split-word {
    position: relative;
    margin-bottom: -10px;
    color: transparent;
    font-family: Didot, "Bodoni MT", "Times New Roman", serif;
    font-size: min(80px, 20vw);
    line-height: 1;
    letter-spacing: min(12px, 2vw);
}

.startup-loader__split-word::before,
.startup-loader__split-word::after {
    position: absolute;
    top: 0;
    left: 0;
    color: rgba(0, 0, 0, 0.03);
    content: attr(data-text);
}

.startup-loader__split-word::before {
    clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
    transform: translateX(-6px);
}

.startup-loader__split-word::after {
    clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
    transform: translateX(6px);
}

.startup-loader__time-word::before {
    transform: translateX(6px);
}

.startup-loader__time-word::after {
    transform: translateX(-6px);
}

.startup-loader__sparkle {
    position: absolute;
    z-index: 2;
    background: #ccc;
    clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
    animation: startup-loader-twinkle var(--twinkle-duration) ease-in-out infinite alternate;
}

.startup-loader__galaxy {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 10;
    width: 320px;
    height: 320px;
    transform: translate(-50%, -50%);
}

.startup-loader__planet {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 20;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #fff;
    box-shadow:
        inset -4px -4px 10px rgba(0, 0, 0, 0.02),
        inset 4px 4px 10px #fff,
        0 0 20px rgba(0, 0, 0, 0.03);
    transform: translate(-50%, -50%);
}

.startup-loader__orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--orbit-size);
    height: var(--orbit-size);
    border: 1px solid rgba(0, 0, 0, 0.015);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.startup-loader__spinner {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 1px solid transparent;
    border-radius: 50%;
}

.startup-loader__spinner--clockwise {
    border-top-color: rgba(0, 0, 0, var(--tail-opacity));
    border-bottom-color: rgba(0, 0, 0, calc(var(--tail-opacity) * 0.08));
    border-left-color: rgba(0, 0, 0, calc(var(--tail-opacity) * 0.4));
    animation: startup-loader-rotate-clockwise var(--spin-speed) linear infinite;
}

.startup-loader__spinner--counterclockwise {
    border-top-color: rgba(0, 0, 0, var(--tail-opacity));
    border-right-color: rgba(0, 0, 0, calc(var(--tail-opacity) * 0.4));
    border-bottom-color: rgba(0, 0, 0, calc(var(--tail-opacity) * 0.08));
    animation: startup-loader-rotate-counterclockwise var(--spin-speed) linear infinite;
}

.startup-loader__spinner::after {
    position: absolute;
    top: -1.5px;
    left: 50%;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #aaa;
    box-shadow: 0 0 6px 1px rgba(0, 0, 0, 0.05);
    content: "";
    transform: translateX(-50%);
}

.startup-loader__brand {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 30;
    color: #999;
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 6px;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.startup-loader__info {
    position: absolute;
    left: 50%;
    bottom: -80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transform: translateX(-50%);
}

.startup-loader__percentage {
    display: flex;
    align-items: baseline;
    color: #555;
    font-size: 32px;
    font-weight: 300;
    letter-spacing: 2px;
}

.startup-loader__percentage-symbol {
    margin-left: 4px;
    color: #bbb;
    font-size: 14px;
    font-weight: 200;
}

.startup-loader__label {
    color: #aaa;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 8px;
    text-transform: uppercase;
}

.startup-loader__theme {
    color: #bbb;
    font-family: "Songti SC", SimSun, serif;
    font-size: 10px;
    letter-spacing: 4px;
    opacity: 0.5;
}

@keyframes startup-loader-twinkle {
    0% { opacity: 0; transform: scale(0.3) rotate(0deg); }
    50% { opacity: 0; }
    100% { opacity: 0.8; transform: scale(1) rotate(45deg); }
}

@keyframes startup-loader-rotate-clockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes startup-loader-rotate-counterclockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@media (max-width: 430px), (max-height: 620px) {
    .startup-loader__core {
        transform: scale(0.82);
    }
}

@media (max-width: 340px) {
    .startup-loader__core {
        transform: scale(0.68);
    }
}

body.pref-reduced-motion *,
body.pref-reduced-motion *::before,
body.pref-reduced-motion *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

button,
input {
    color: inherit;
    font: inherit;
}

button {
    border: 0;
}

button:not(:disabled) {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

[hidden],
.is-hidden {
    display: none !important;
}

.noscript-message {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #f4f6f7;
    color: #1f2529;
    text-align: center;
}

.glass-3d {
    background: var(--desktop-tile-surface, var(--surface));
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 0.5px solid var(--desktop-tile-border, var(--line));
    border-radius: 24px;
    box-shadow: var(--desktop-tile-shadow, none);
}

.system-status-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1000;
    width: 100%;
    height: calc(var(--status-height) + var(--safe-top));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: var(--safe-top) max(24px, var(--safe-right)) 7px max(24px, var(--safe-left));
    color: #24282b;
    font-size: 0.75rem;
    font-weight: 650;
    pointer-events: none;
}

.status-icons {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 22px;
    font-size: 0.9rem;
    pointer-events: auto;
}

.status-action {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    margin-right: 2px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    color: #1e2428;
    font-size: 1rem;
}

.desktop-container {
    display: flex;
    width: 100%;
    height: 100%;
    padding-top: calc(var(--status-height) + var(--safe-top));
    padding-bottom: calc(var(--dock-height) + var(--dock-gap) * 2 + var(--pagination-space) + var(--safe-bottom));
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    cursor: grab;
    -webkit-overflow-scrolling: touch;
}

.desktop-container::-webkit-scrollbar,
.screen::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.desktop-container.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
}

.desktop-container.is-dragging * {
    user-select: none;
}

body.is-settings-open .desktop-container,
body.is-settings-open .pagination,
body.is-settings-open .dock-container,
body.is-settings-open .system-status-bar {
    visibility: hidden;
    pointer-events: none;
}
.desktop-container.is-item-dragging,
.dock-container.is-item-dragging {
    cursor: grabbing;
    touch-action: none;
}

.desktop-container.is-item-dragging .desktop-item,
.dock-container.is-item-dragging .desktop-item {
    user-select: none;
    -webkit-user-select: none;
}

.desktop-item {
    translate: calc(var(--desktop-drag-x, 0px) + var(--desktop-reflow-x, 0px)) calc(var(--desktop-drag-y, 0px) + var(--desktop-reflow-y, 0px));
    touch-action: none;
    transition: translate 160ms ease, scale 160ms ease, filter 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.desktop-drag-placeholder {
    display: block;
    grid-column: span var(--desktop-placeholder-columns, 1);
    grid-row: span var(--desktop-placeholder-rows, 1);
    width: var(--desktop-placeholder-width, auto);
    height: var(--desktop-placeholder-height, auto);
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
    flex: 0 0 var(--desktop-placeholder-width, 0px);
    visibility: hidden;
    pointer-events: none;
}

.desktop-layout-grid > .desktop-drag-placeholder {
    width: auto;
    min-height: var(--desktop-placeholder-height, 0px);
    flex: none;
}
.desktop-item.is-drag-proxy {
    position: fixed !important;
    z-index: 1000 !important;
    left: var(--desktop-proxy-left, 0px) !important;
    top: var(--desktop-proxy-top, 0px) !important;
    width: var(--desktop-proxy-width, auto) !important;
    height: var(--desktop-proxy-height, auto) !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    translate: 0 0 !important;
    pointer-events: none;
    transition: none !important;
    filter: brightness(0.99) drop-shadow(0 16px 22px rgba(22, 29, 33, 0.2));
}

.desktop-item.is-drag-proxy .app-icon {
    width: var(--desktop-proxy-icon-size, 60px);
    height: var(--desktop-proxy-icon-size, 60px);
    flex-basis: var(--desktop-proxy-icon-size, 60px);
}

.desktop-item.is-drag-proxy.is-long-pressing {
    scale: 1;
    opacity: 0.96;
}
.desktop-item.is-drag-proxy.is-dock-proxy .app-name {
    display: none;
}

.desktop-container.is-item-editing .desktop-item:not(.is-drag-proxy),
.dock-container.is-item-editing .desktop-item:not(.is-drag-proxy) {
    animation: desktop-item-wiggle 180ms ease-in-out infinite alternate;
}

@keyframes desktop-item-wiggle {
    from { rotate: -0.65deg; }
    to { rotate: 0.65deg; }
}

.desktop-item.is-long-pressing {
    z-index: 30;
    cursor: grabbing;
    touch-action: none;
    filter: brightness(0.98);
    opacity: 0.9;
    scale: 1.035;
    transition: none;
}


.desktop-container.is-item-dragging .desktop-item:not(.is-long-pressing) {
    transition: translate 120ms ease, scale 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.screen {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--page-gap);
    padding: 20px max(20px, var(--safe-right)) 20px max(20px, var(--safe-left));
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    scrollbar-width: none;
    overscroll-behavior-y: contain;
}

.pagination {
    position: fixed;
    z-index: 90;
    left: 50%;
    bottom: calc(var(--dock-height) + var(--dock-gap) + var(--safe-bottom) + 5px - var(--desktop-keyboard-offset));
    display: flex;
    gap: 8px;
    transform: translateX(-50%);
}

.dot {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    background: transparent;
    border-radius: 50%;
}

.dot::after {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(17, 19, 21, 0.18);
    transition: transform 180ms ease, background-color 180ms ease;
}

.dot.active::after {
    background: var(--ink);
    transform: scale(1.2);
}

.dock-container {
    position: fixed;
    z-index: 100;
    left: 50%;
    bottom: calc(var(--dock-gap) + var(--safe-bottom) - var(--desktop-keyboard-offset));
    width: min(calc(100% - max(40px, var(--safe-left) + var(--safe-right))), 620px);
    height: var(--dock-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 12px;
    border-radius: 28px;
    transform: translateX(-50%);
    touch-action: none;
    cursor: grab;
}

.dock-container.is-dragging {
    cursor: grabbing;
}

.dock-container .app-name {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: more) {
    .glass-3d {
        border: 1px solid var(--desktop-tile-border, rgba(17, 19, 21, 0.38));
        background: var(--desktop-tile-surface, rgba(255, 255, 255, 0.76));
    }
}
