* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --blur: saturate(180%) blur(20px);
    --link: #0a67ff;
}

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

body {
    font-family: var(--font);
    color: #1d1d1f;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

/* ===== DESKTOP / WALLPAPER ===== */
#desktop {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background:
        radial-gradient(120% 80% at 15% 10%, rgba(255,170,120,0.55), transparent 45%),
        radial-gradient(120% 90% at 85% 20%, rgba(168,120,255,0.55), transparent 50%),
        radial-gradient(140% 120% at 50% 100%, rgba(40,110,255,0.65), transparent 55%),
        linear-gradient(160deg, #17123a 0%, #3a2170 38%, #7a3a86 68%, #c76a7e 100%);
}

#desktop::after {
    /* soft vignette */
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 240px rgba(0,0,0,0.35);
}

/* ===== MENU BAR ===== */
#menubar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 26px;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    color: #fff;
    font-size: 13px;
    background: rgba(0,0,0,0.28);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
}

.menu-left, .menu-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.menu-left .apple {
    cursor: pointer;
    padding: 0 3px;
    display: inline-flex;
    align-items: center;
}

.menu-left .apple svg {
    width: 14px;
    height: 16px;
    display: block;
}

.menu-left { position: relative; }

/* Apple dropdown menu */
.apple-menu {
    position: absolute;
    top: 26px;
    left: -4px;
    min-width: 210px;
    padding: 5px;
    border-radius: 8px;
    background: rgba(245,245,245,0.72);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 0.5px solid rgba(0,0,0,0.15);
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
    color: #1d1d1f;
    font-size: 13px;
    z-index: 9500;
}

.apple-menu.hidden { display: none; }

.apple-menu .mi {
    padding: 4px 10px;
    border-radius: 5px;
    cursor: default;
}

.apple-menu .mi:hover {
    background: #0a67ff;
    color: #fff;
}

.apple-menu .sep {
    height: 1px;
    margin: 5px 8px;
    background: rgba(0,0,0,0.14);
}

.menu-left .app-name {
    font-weight: 700;
}

.menu-right .status-icon {
    opacity: 0.95;
    display: inline-flex;
}

.menu-right #clock {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
}

/* ===== DESKTOP ICONS (freely draggable) ===== */
#desktop-icons {
    position: absolute;
    inset: 0;
    z-index: 10;
}

.desktop-icon {
    position: absolute;
    width: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 4px 6px;
    border-radius: 8px;
    cursor: default;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.desktop-icon .di-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 9px rgba(0,0,0,0.35);
    pointer-events: none;
}

.desktop-icon .di-icon svg { width: 100%; height: 100%; display: block; }

.desktop-icon .di-label {
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    text-align: center;
    padding: 1px 7px;
    border-radius: 4px;
    line-height: 1.25;
    pointer-events: none;
}

.desktop-icon.selected .di-icon {
    filter: brightness(0.75);
}

.desktop-icon.selected .di-label {
    background: #0a67ff;
    text-shadow: none;
}

@media (max-width: 640px) {
    #desktop-icons { display: none; }
}

/* ===== DOCK ===== */
#dock {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    z-index: 8000;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 22px;
    background: rgba(255,255,255,0.22);
    border: 0.5px solid rgba(255,255,255,0.35);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.dock-item {
    position: relative;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.2,0.8,0.2,1);
    transform-origin: bottom center;
}

.dock-item:hover {
    transform: scale(1.32) translateY(-6px);
}

.dock-item:active {
    transform: scale(1.1) translateY(-2px);
}

.app-icon {
    width: 54px;
    height: 54px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.4);
}

.app-icon svg { width: 100%; height: 100%; display: block; }

/* dock tooltip */
.dock-item .tip {
    position: absolute;
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: rgba(30,30,30,0.9);
    color: #fff;
    font-size: 12px;
    padding: 4px 9px;
    border-radius: 7px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
}

.dock-item:hover .tip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* running indicator dot */
.dock-item .run-dot {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
    opacity: 0;
}

.dock-item.running .run-dot { opacity: 1; }

@media (max-width: 640px) {
    .app-icon { width: 44px; height: 44px; border-radius: 11px; }
    #dock { gap: 8px; padding: 7px 10px; }
    .dock-item:hover { transform: scale(1.12) translateY(-3px); }
}

/* ===== WINDOWS ===== */
.window {
    position: absolute;
    min-width: 320px;
    min-height: 200px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(0,0,0,0.45), 0 0 0 0.5px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.94);
    transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.2,0.8,0.2,1);
}

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

.window.closing {
    opacity: 0;
    transform: scale(0.94);
}

.titlebar {
    height: 38px;
    flex: 0 0 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: linear-gradient(#f6f6f6, #ececec);
    border-bottom: 0.5px solid #d3d3d3;
    cursor: grab;
}

.titlebar:active { cursor: grabbing; }

/* ===== WINDOW RESIZE HANDLES ===== */
.resize-handle {
    position: absolute;
    z-index: 5;
    touch-action: none;
}

.rz-n  { top: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.rz-s  { bottom: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.rz-e  { top: 12px; right: 0; bottom: 12px; width: 6px; cursor: ew-resize; }
.rz-w  { top: 12px; left: 0; bottom: 12px; width: 6px; cursor: ew-resize; }
.rz-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.rz-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.rz-se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.rz-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }

.lights {
    display: flex;
    gap: 8px;
    align-items: center;
}

.light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    line-height: 1;
    color: rgba(0,0,0,0.45);
    cursor: pointer;
}

.light.red { background: #ff5f57; }
.light.yellow { background: #febc2e; }
.light.green { background: #28c840; }
.light .glyph { opacity: 0; }
.lights:hover .glyph { opacity: 1; }

.titlebar .win-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #4a4a4a;
    margin-right: 52px; /* balance the traffic lights */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Safari-style address bar */
.titlebar.safari .win-title { display: none; }

.addressbar {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-right: 52px;
}

.addressbar .url-pill {
    background: #e6e6e6;
    border-radius: 7px;
    padding: 4px 14px;
    font-size: 12px;
    color: #333;
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.addressbar .open-ext {
    font-size: 12px;
    color: #666;
    text-decoration: none;
    cursor: pointer;
}

.window-body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.window-body.pad {
    padding: 26px 30px;
    user-select: text;
}

.window-body iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #fff;
}

/* ===== WINDOW CONTENT TYPOGRAPHY ===== */
.window-body.pad h1 {
    font-size: 22px;
    margin-bottom: 4px;
}

.window-body.pad .subtitle {
    color: #86868b;
    font-size: 14px;
    margin-bottom: 18px;
}

.window-body.pad h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #86868b;
    margin: 20px 0 8px;
    font-weight: 700;
}

.window-body.pad p { margin-bottom: 6px; line-height: 1.5; font-size: 14px; }
.window-body.pad a { color: var(--link); text-decoration: none; }
.window-body.pad a:hover { text-decoration: underline; }
.window-body.pad .tag { color: #86868b; font-size: 12px; }
.window-body.pad .detail { color: #86868b; font-size: 12px; }

.about-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 6px;
}

.about-head img {
    width: 62px;
    height: 62px;
    border-radius: 15px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 26px;
}

@media (max-width: 560px) {
    .cols { grid-template-columns: 1fr; gap: 6px; }
}
