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

:root {
    --accent: #F97115;
    --ink: #353660;
    --highlight: #E7FF89;
    --text: #2b2e48;
    --text-dim: rgba(43, 46, 72, 0.55);
    --panel: rgba(255, 255, 255, 0.65);
    --panel-strong: rgba(255, 255, 255, 0.85);
    --panel-border: rgba(53, 54, 96, 0.12);
    --shadow: 0 10px 40px rgba(53, 54, 96, 0.18);
    --radius: 16px;
    font-size: 15px;
}

html, body { height: 100%; }

body {
    font-family: var(--tools-font);
    color: var(--text);
    overflow: hidden;
    background: #eef0f6;
}

/* Wallpaper variants — clean, near-flat. Any tint is drawn ONLY from the
   MPC logo colors (navy ink / orange accent), one soft corner glow, no
   scattered blobs. Personal wallpaper (Settings app) overrides via inline
   style on <body>. */
body[data-wallpaper="light"] {
    background:
        radial-gradient(1000px 720px at 88% 6%, color-mix(in srgb, var(--ink) 7%, transparent) 0%, transparent 60%),
        linear-gradient(168deg, #f6f7fb 0%, #eceef4 100%);
}
body[data-wallpaper="warm"] {
    background:
        radial-gradient(1000px 720px at 88% 6%, color-mix(in srgb, var(--accent) 10%, transparent) 0%, transparent 60%),
        linear-gradient(168deg, #faf7f3 0%, #f2ede6 100%);
}
body[data-wallpaper="cool"] {
    background:
        radial-gradient(1000px 720px at 88% 6%, color-mix(in srgb, var(--ink) 12%, transparent) 0%, transparent 60%),
        linear-gradient(168deg, #f1f4fa 0%, #e6ebf4 100%);
}
body[data-wallpaper="dark"],
body[data-theme="dark"] {
    --text: #eef2f7;
    --text-dim: rgba(238, 242, 247, 0.55);
    --panel: rgba(20, 20, 20, 0.76);
    --panel-strong: rgba(28, 28, 28, 0.94);
    --panel-border: rgba(255, 255, 255, 0.12);
    --shadow: 0 12px 44px rgba(0, 0, 0, 0.45);
    /* Neutral graphite like the tools themselves; orange remains an action
       accent rather than tinting the entire desktop. */
    background:
        radial-gradient(980px 700px at 88% 5%, color-mix(in srgb, var(--accent) 5%, transparent) 0%, transparent 62%),
        linear-gradient(168deg, #101010 0%, #181818 100%);
}
body[data-theme="dark"] .mb-btn:hover { background: rgba(255, 255, 255, 0.1); }
body[data-theme="dark"] .pop-app:hover { background: rgba(255, 255, 255, 0.08); }
body[data-theme="dark"] .pop-title input { background: rgba(0, 0, 0, 0.25); }
body { background-attachment: fixed; }
button, input, select, textarea { font-family: inherit; }

/* ---------- branding bits ---------- */

.logo-badge {
    display: inline-grid;
    place-items: center;
    padding: 3px 8px;
    border-radius: 7px;
    background: var(--ink);
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.06em;
}
.logo-name { font-weight: 700; letter-spacing: -0.01em; }
/* menubar buttons set the bar height, so the mark can grow without
   making the bar taller */
.logo-img { height: 29px; display: block; }

/* MPC wordmark (inline SVG, uses page Inter + live theme colors) */
.mpc-mark { display: inline-flex; }
.mpc-mark svg { height: 26px; width: auto; display: block; }
.mpc-word { font-family: "Inter", sans-serif; font-weight: 800; font-size: 34px; letter-spacing: -2px; }
.mpc-sub  { font-family: "Inter", sans-serif; font-weight: 700; font-size: 8.2px; letter-spacing: 3.4px; }
.login-brand .mpc-mark svg { height: 38px; }
/* the real logo is dark navy on transparent — give it a light chip on dark chrome */
body[data-theme="dark"] .mb-brand .logo-img,
body[data-theme="dark"] .login-brand .logo-img {
    background: rgba(255, 255, 255, 0.92);
    padding: 3px 7px;
    border-radius: 7px;
}

/* ---------- login ---------- */

.login-wall { height: 100%; display: grid; place-items: center; }

.login-card {
    width: min(390px, 90vw);
    padding: 42px 36px;
    background: var(--panel-strong);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow: var(--shadow);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 21px;
    padding: 6px 0 2px;
}
.login-brand .logo-badge { font-size: 14px; padding: 5px 10px; }
.login-brand .logo-img { height: 52px; }

.auth-state-card { gap: 20px; }
.auth-state-icon {
    width: 58px;
    height: 58px;
    margin: 2px auto 0;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: color-mix(in srgb, var(--accent) 12%, white);
    color: var(--accent);
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
}
.auth-state-copy { display: grid; gap: 8px; }
.auth-state-copy h1 {
    color: var(--text);
    font-size: 23px;
    line-height: 1.15;
    letter-spacing: -0.035em;
}
.auth-state-copy p,
.auth-state-hint {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.55;
}
.auth-primary {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: var(--ink);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transition: transform 140ms ease, box-shadow 140ms ease;
}
.auth-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--ink) 20%, transparent);
}
.auth-primary:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent);
    outline-offset: 3px;
}
.auth-state-hint { font-size: 12px; }

.login-sub { color: var(--text-dim); font-size: 14px; }

.login-card input {
    padding: 13px 15px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.8);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}
body[data-wallpaper="dark"] .login-card input { background: rgba(0,0,0,0.25); }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

.login-card button {
    padding: 13px;
    border: none;
    border-radius: 12px;
    background: var(--ink);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
}
.login-card button:hover { background: var(--accent); }

.login-msg { font-size: 13px; color: var(--text-dim); min-height: 1.2em; }
.login-msg a { color: var(--accent); font-weight: 600; }

/* ---------- desktop chrome ---------- */

#desktop { height: 100%; display: flex; flex-direction: column; }

#menubar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--panel-border);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    font-size: 13px;
    z-index: 500;
}

.mb-brand { display: flex; align-items: center; gap: 8px; font-size: 14px; }
body.editing .mb-brand { cursor: pointer; outline: 1.5px dashed var(--accent); outline-offset: 4px; border-radius: 6px; }
.mb-spacer { flex: 1; }
.mb-user, .mb-clock { color: var(--text-dim); font-weight: 500; }
.mb-btn.mb-user { width: 28px; height: 28px; padding: 0; border-radius: 50%; background: var(--panel-border); font-size: 10px; font-weight: 500; }
.mb-clock { font-size: 12px; font-variant-numeric: tabular-nums; }

.mb-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    padding: 4px 12px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.mb-btn:hover { background: rgba(53, 54, 96, 0.08); }
.mb-btn.active { background: var(--accent); color: #fff; }

/* ---------- platform notice ---------- */

#noticeBar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 7px 16px;
    background: color-mix(in srgb, #F4B740 16%, #fffdf6);
    border-bottom: 1px solid color-mix(in srgb, #B87715 30%, transparent);
    color: #6b4a10;
    font-size: 13px;
    font-weight: 500;
    z-index: 490;
}
#noticeBar button {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0.7;
}
#noticeBar button:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
body[data-theme="dark"] #noticeBar {
    background: #3a3120;
    border-bottom-color: rgba(244, 183, 64, 0.3);
    color: #f0d9a6;
}

/* ---------- application launcher (Launchpad) ---------- */

#stage { flex: 1; overflow: auto; padding: 40px 24px 132px; }
.launcher {
    width: min(940px, 100%); /* 8 × 110px tracks + gaps */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
}

.lp-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(320px, 84vw);
    padding: 8px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    color: var(--text-dim);
    transition: border-color .15s ease;
}
.lp-search:focus-within { border-color: color-mix(in srgb, var(--ink) 34%, transparent); }
.lp-search svg { width: 15px; height: 15px; flex: none; }
.lp-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    outline: none;
}

.lp-sections { width: 100%; display: flex; flex-direction: column; gap: 34px; }
.lp-section-title {
    margin: 0 0 14px 8px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .015em;
    color: var(--text-dim);
}
/* Fixed-width tracks, left-packed: icons keep tight spacing and wrap
   with the window instead of stretching across the full width.
   Container width allows up to 8 per row. */
.lp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 110px);
    gap: 20px 6px;
    justify-content: start;
    justify-items: center;
}

.lp-tile {
    width: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 10px 4px 9px;
    border: none;
    border-radius: 16px;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: background .14s ease;
}
.lp-tile:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
body[data-theme="dark"] .lp-tile:hover { background: rgba(255, 255, 255, 0.06); }
.lp-tile:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; }
.lp-tile:active .lp-icon { transform: scale(0.94); }

.lp-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    font-size: 40px;
    transition: transform .12s ease;
}
.lp-icon img {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 3px 7px rgba(23, 26, 43, 0.18));
}
/* emoji fallback (user-added apps without an icon file) gets a neutral tile */
.lp-icon:not(:has(img)) {
    border-radius: 15px;
    background: linear-gradient(180deg, #ffffff 0%, #f2f3f6 100%);
    border: 1px solid var(--panel-border);
}
body[data-theme="dark"] .lp-icon:not(:has(img)) { background: linear-gradient(180deg, #2b2b2b 0%, #1d1d1d 100%); }

.lp-name {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: break-word; /* wrap at spaces first — never split a word mid-name unless it can't fit at all */
    max-width: 100%;
}

.app-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 44px 20px;
    color: var(--text-dim);
}
.app-empty strong { color: var(--text); font-weight: 600; }

/* ---------- dock ---------- */

#dockWrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 12px;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 600;
}

#dock {
    pointer-events: auto;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    box-shadow: var(--shadow);
    max-width: calc(100vw - 32px);
    overflow: visible;
    transition: padding 0.12s ease-out;
}

.dock-sep {
    width: 1px;
    align-self: stretch;
    margin: 6px 5px;
    background: var(--panel-border);
    flex: none;
}
#dock.compact { overflow-x: auto; overflow-y: hidden; }

.dock-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: none;
    background: transparent;
    color: var(--text); /* buttons don't inherit — tip text was black in dark mode */
    cursor: pointer;
    padding: 0 2px;
    flex: none;
    transition: transform 0.12s ease-out;
    transform-origin: bottom center;
    will-change: transform;
}
.dock-item:hover { z-index: 2; }
.dock-item.drop-before { box-shadow: -3px 0 0 var(--tools-focus); }
#dock.drag-active { outline: 2px solid var(--tools-focus); outline-offset: 4px; }
.dock-item.pinned .dot { background: var(--text-dim); opacity: .35; }
.dock-item.pinned.running .dot { background: var(--text); opacity: 1; }
.app-menu {
    position: fixed; z-index: 20000; width: 200px; padding: 5px;
    background: var(--panel-strong); backdrop-filter: blur(24px);
    border: 1px solid var(--panel-border); border-radius: 8px;
    box-shadow: var(--shadow); color: var(--text);
}
.app-menu button { display: block; width: 100%; border: 0; padding: 9px 11px; text-align: left; background: transparent; color: inherit; border-radius: 4px; font-size: 13px; cursor: pointer; }
.app-menu button:hover, .app-menu button:focus-visible { background: var(--tools-action); color: var(--tools-on-action); outline: none; }
.app-menu button:disabled { opacity: .35; cursor: default; }
.dock-save-status { position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%); z-index: 20001; background: var(--panel-strong); color: var(--text); border: 1px solid var(--panel-border); border-radius: 6px; padding: 10px 14px; font-size: 13px; }
.dock-sep { transition: transform 0.12s ease-out; }

/* The icon artwork IS the tile (full-bleed squircle SVGs) — no plate
   behind it, like the real macOS dock. Emoji fallbacks keep a neutral
   plate so user-added apps without an icon file still look intentional. */
.dock-icon {
    width: var(--dock-size, 52px);
    height: var(--dock-size, 52px);
    display: grid;
    place-items: center;
    font-size: 32px;
    border-radius: 14px;
}
.dock-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 5px rgba(23, 26, 43, 0.22));
}
.dock-icon:not(:has(img)):not(.folder) {
    background: linear-gradient(180deg, #ffffff 0%, #eef0f6 100%);
    border: 1px solid var(--panel-border);
    box-shadow: 0 3px 10px rgba(53, 54, 96, 0.15);
    overflow: hidden;
}

/* One shared plate for transparent brand logos; complete app tiles stay intact. */
:is(.lp-icon, .dock-icon).logo-icon {
    border-radius: 24%;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(23, 26, 43, 0.07), 0 2px 5px rgba(23, 26, 43, 0.12);
}
:is(.lp-icon, .dock-icon).logo-icon > img {
    width: 74%;
    height: 74%;
    object-fit: contain;
    filter: none;
}

/* tooltip label */
.dock-item .tip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--panel-strong);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
}
/* while visible, the tip catches the pointer — hovering it keeps the
   dock magnified (it's a dock child, so no mouseleave fires) and a
   click on it bubbles to the app button */
.dock-item:hover .tip { opacity: 1; pointer-events: auto; }
/* while its flyout is open, the folder's tooltip stays hidden */
.dock-item.pop-open .tip { opacity: 0 !important; pointer-events: none !important; }

/* running indicator */
.dock-item .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: transparent;
    margin-top: 3px;
}
.dock-item.running .dot { background: var(--accent); }

.dock-item.minimized-item { margin-left: 2px; }
.dock-item.minimized-item .dock-icon {
    width: 46px;
    height: 46px;
    border-radius: 11px;
    filter: saturate(.78);
    opacity: .92;
}
.min-badge {
    position: absolute;
    right: -1px;
    bottom: 7px;
    width: 16px;
    height: 16px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--panel-border);
    background: var(--panel-strong);
    color: var(--text);
    font-size: 11px;
    font-weight: 800;
    box-shadow: 0 2px 7px rgba(0,0,0,.22);
}

/* folder tile: translucent neutral square holding mini app icons, macOS-style */
.dock-icon.folder {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    place-items: center;
    gap: 2px;
    padding: calc(var(--dock-size, 52px) * .135);
    font-size: 15px;
    background: color-mix(in srgb, var(--ink) 7%, rgba(255, 255, 255, 0.72));
    border: 1px solid var(--panel-border);
    overflow: hidden;
}
.dock-icon.folder img { width: calc(var(--dock-size, 52px) * .327); height: calc(var(--dock-size, 52px) * .327); padding: 0; filter: none; }
.dock-icon.folder span { line-height: 1; }

/* drag & drop states (edit mode) */
body.editing .dock-item { cursor: grab; }
body.editing .dock-item.dragging { opacity: 0.35; }
body.editing .dock-item.drop-hint .dock-icon { outline: 2px dashed var(--accent); outline-offset: 2px; }
.dock-item.add-btn .dock-icon {
    background: transparent;
    border-style: dashed;
    color: var(--text-dim);
    font-size: 24px;
    box-shadow: none;
}
.dock-item.add-btn:hover .dock-icon { color: var(--accent); border-color: var(--accent); }

/* ---------- folder popover ---------- */

#folderPopover {
    position: fixed;
    z-index: 590;
    background: var(--panel-strong);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    backdrop-filter: blur(28px) saturate(1.5);
    -webkit-backdrop-filter: blur(28px) saturate(1.5);
    box-shadow: var(--shadow);
    padding: 16px 18px 14px;
    max-width: min(480px, calc(100vw - 32px));
}
#folderPopover::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: var(--arrow-x, 50%);
    transform: translateX(-50%) rotate(45deg);
    width: 13px;
    height: 13px;
    background: var(--panel-strong);
    border-right: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
}

.pop-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pop-title input {
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    padding: 2px 8px;
    width: 140px;
}
.pop-title .mini-btn {
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 5px;
}
.pop-title .mini-btn:hover { background: rgba(53,54,96,0.08); color: #c0392b; }

/* fixed three-up grid, centered — no auto-fill slack on the right */
.pop-grid {
    display: grid;
    grid-template-columns: repeat(3, 86px);
    justify-content: center;
    gap: 6px 4px;
    min-height: 80px;
}

.pop-app {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 2px;
    border-radius: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}
.pop-app:hover { background: rgba(53, 54, 96, 0.07); }
.pop-app .dock-icon { width: 44px; height: 44px; font-size: 26px; border-radius: 12px; }
.pop-app .label {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    line-height: 1.2;
    overflow-wrap: anywhere;
}
body.editing .pop-app { cursor: grab; }
body.editing .pop-app.dragging { opacity: 0.35; }

/* ---------- windows ---------- */

.window {
    position: fixed;
    min-width: 320px;
    min-height: 240px;
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(53, 54, 96, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    z-index: 100;
}
.window.focused { box-shadow: 0 28px 80px rgba(53, 54, 96, 0.42); }
.window.no-resize { resize: none; }
.window { max-width: calc(100vw - 24px); max-height: calc(100vh - 138px); }
.window.win-large { min-width: min(680px, calc(100vw - 24px)); min-height: min(460px, calc(100vh - 140px)); }

/* entrance: stay invisible while the tool loads & sizes itself,
   then fade in with a slight zoom (95% → 100%) */
.window { transition: opacity 0.22s ease-out, transform 0.22s ease-out; transform-origin: center; }
.window.win-loading { opacity: 0; transform: scale(0.95); pointer-events: none; }
.window.minimizing { pointer-events: none; }
.window.minimized { display: none; }

.win-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-height: 34px;
    background: linear-gradient(180deg, #fafbfe 0%, #f1f3f9 100%);
    border-bottom: 1px solid var(--panel-border);
    cursor: move;
    user-select: none;
    font-size: 13px;
}

/* macOS traffic lights */
.traffic { display: flex; gap: 8px; margin-right: 4px; }
.tl {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 8px;
    color: transparent;
    padding: 0;
}
.tl.close { background: #ff5f57; }
.tl.min   { background: #febc2e; }
.tl.zoom  { background: #28c840; }
.traffic:hover .tl, .traffic:focus-within .tl { color: rgba(0, 0, 0, 0.7); }
.tl:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* Window chrome follows the shared platform theme. */
.win-title { flex: 1; font-weight: 600; color: #2b2e48; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-right { width: 76px; display: flex; justify-content: flex-end; }
.win-btn {
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    border-radius: 6px;
    padding: 2px 7px;
}
.win-btn:hover { background: rgba(53, 54, 96, 0.08); color: var(--text); }

.window iframe { flex: 1; border: none; background: #fff; }

/* Finder-style folder window: same chrome, icon grid instead of iframe */
.finder-body { flex: 1; overflow: auto; padding: 18px; background: #fff; }
.window .pop-app .label { color: #2b2e48; } /* white body even in dark mode */
.window .pop-app:hover { background: rgba(53, 54, 96, 0.07); }
body.win-dragging iframe { pointer-events: none; }
body.win-dragging { user-select: none; }

#snapPreview {
    position: fixed;
    z-index: 99;
    pointer-events: none;
    opacity: 0;
    border: 1px solid color-mix(in srgb, var(--accent) 72%, white);
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent) 14%, var(--panel-strong));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow);
    transition: opacity .12s ease, left .12s ease, top .12s ease, width .12s ease, height .12s ease;
    backdrop-filter: blur(10px);
}
#snapPreview.visible { opacity: .86; }

body[data-theme="dark"] .dock-icon:not(:has(img)):not(.folder) {
    background: linear-gradient(180deg, #2b2b2b 0%, #1d1d1d 100%);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .38);
}
body[data-theme="dark"] .dock-icon.folder {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.14);
}
body[data-theme="dark"] .window {
    background: #141414;
    border-color: #3a3a3a;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .58);
}
body[data-theme="dark"] .window.focused { box-shadow: 0 28px 82px rgba(0, 0, 0, .72); }
body[data-theme="dark"] .win-titlebar {
    background: linear-gradient(180deg, #242424 0%, #1c1c1c 100%);
    border-bottom-color: #353535;
}
body[data-theme="dark"] .win-title { color: #ededed; }
body[data-theme="dark"] .win-btn { color: #9a9a9a; }
body[data-theme="dark"] .win-btn:hover { background: rgba(255, 255, 255, .08); color: #ededed; }
body[data-theme="dark"] .window iframe { background: #141414; }
body[data-theme="dark"] .finder-body { background: #171717; }
body[data-theme="dark"] .window .pop-app .label { color: #ededed; }
body[data-theme="dark"] .window .pop-app:hover { background: rgba(255, 255, 255, .07); }

/* ---------- modals (edit mode) ---------- */

.modal-wall {
    position: fixed;
    inset: 0;
    background: rgba(35, 36, 64, 0.35);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    z-index: 900;
}
.modal {
    width: min(430px, 92vw);
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 13px;
    color: #2b2e48;
}
.modal h2 { font-size: 17px; letter-spacing: -0.01em; }
.modal label { font-size: 12px; font-weight: 600; color: #78809a; display: block; margin-bottom: 4px; }
.modal input, .modal select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d8dce8;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #fff;
    color: inherit;
}
.modal input:focus, .modal select:focus { border-color: var(--accent); }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal .actions .danger { margin-right: auto; }
.modal button {
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid #d8dce8;
    background: #fff;
    font-family: inherit;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    color: inherit;
}
.modal button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.modal button.primary:hover { background: var(--accent); border-color: var(--accent); }
.modal button.danger { border-color: #f3c1c1; color: #c0392b; }
.modal button.danger:hover { background: #fbe4e4; }
.modal input[type="color"] { padding: 2px; height: 38px; cursor: pointer; }
.modal .check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 1px;
    color: inherit;
    font-size: 13px;
    cursor: pointer;
}
.modal .check-row input { width: auto; accent-color: var(--accent); }

body[data-theme="dark"] .modal-wall { background: rgba(0, 0, 0, .58); }
body[data-theme="dark"] .modal {
    background: #1c1c1c;
    border: 1px solid #363636;
    color: #ededed;
}
body[data-theme="dark"] .modal label { color: #9a9a9a; }
body[data-theme="dark"] .modal input,
body[data-theme="dark"] .modal select,
body[data-theme="dark"] .modal button {
    background: #242424;
    border-color: #3d3d3d;
    color: #ededed;
}
body[data-theme="dark"] .modal button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Cmd+K palette ---------- */

.palette-wall { align-items: start; padding-top: 14vh; display: flex; justify-content: center; }
.palette {
    width: min(520px, 92vw);
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
    color: #2b2e48;
}
.palette input {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-bottom: 1px solid #eef0f5;
    font-size: 17px;
    font-family: inherit;
    outline: none;
    color: inherit;
    background: #fff;
}
.pal-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.pal-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: inherit;
}
.pal-row.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pal-icon { width: 32px !important; height: 32px !important; font-size: 20px !important; border-radius: 9px !important; flex: none; }
.pal-name { font-size: 14.5px; font-weight: 600; flex: 1; }
.pal-group { font-size: 12px; color: #78809a; }

body[data-theme="dark"] .palette { background: #1c1c1c; color: #ededed; border: 1px solid #363636; }
body[data-theme="dark"] .palette input { background: #1c1c1c; color: #ededed; border-bottom-color: #363636; }
body[data-theme="dark"] .pal-group { color: #8f8f8f; }

/* ---------- settings ---------- */

.seg { display: flex; gap: 6px; }
.seg-btn {
    flex: 1;
    padding: 8px 6px;
    border: 1px solid #d8dce8;
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    color: #2b2e48;
}
.seg-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
    width: 46px;
    height: 46px;
    border-radius: 11px;
    border: 1px solid rgba(53,54,96,0.18);
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #9aa0b4;
    font-size: 15px;
    outline-offset: 2px;
}
.swatch.on { outline: 2.5px solid var(--accent); }

.dropzone {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px dashed #c6cbdd;
    border-radius: 12px;
    cursor: pointer;
    background: #fafbfe;
    transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: #fff5ef; }
.dz-icon { font-size: 22px; flex: none; }
.dz-text { font-size: 13px; color: #5a607a; line-height: 1.35; }
.dz-text small { color: #9aa0b4; }
.dz-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; min-height: 20px; }
.dz-name { font-size: 12px; color: #78809a; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 820px) {
    #stage { padding-top: 28px; }
}

@media (max-width: 560px) {
    #menubar { gap: 7px; padding-inline: 10px; }
    .mb-clock, .logo-name { display: none; }
    #stage { padding: 20px 14px 116px; }
    .launcher { gap: 26px; }
    .lp-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 16px 4px; }
    .lp-tile { width: 86px; }
    .lp-icon { width: 56px; height: 56px; font-size: 34px; }
}


/* Settings uses the shared Tools typography and control tokens. */
.settings-wall { padding: 16px; background: #171c283d; backdrop-filter: blur(5px); }
body[data-theme] .modal.settings-dialog {
    --settings-bg: #fff; --settings-ink: #24272b; --settings-muted: #686e76;
    --settings-line: #e2e5e9; --settings-soft: #f5f6f8;
    width: min(520px, 100%); max-height: calc(100dvh - 32px); padding: 0; gap: 0;
    border: 1px solid var(--settings-line); border-radius: 14px; overflow: hidden;
    background: var(--settings-bg); color: var(--settings-ink); font: 400 14px/1.5 var(--tools-font);
    letter-spacing: 0; box-shadow: 0 24px 80px #10152226;
}
body[data-theme="dark"] .modal.settings-dialog {
    --settings-bg: #1c1e21; --settings-ink: #eceef1; --settings-muted: #a7adb6;
    --settings-line: #393d44; --settings-soft: #26292e;
}
.settings-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding: 24px 24px 20px; flex: none; }
body[data-theme] .modal.settings-dialog h2 { font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: 0; }
.settings-header p { color: var(--settings-muted); margin-top: 6px; }
.settings-content { overflow-y: auto; overscroll-behavior: contain; padding: 0 24px; }
.settings-section { padding: 20px 0; border-top: 1px solid var(--settings-line); }
.settings-section h3 { font-size: 14px; font-weight: 600; }
.settings-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.settings-section-heading > span { color: var(--settings-muted); font-size: 11px; }
body[data-theme] .modal.settings-dialog button { min-height: var(--tools-control-height); padding: 7px 12px; border: 1px solid var(--settings-line); border-radius: var(--tools-control-radius); background: var(--settings-bg); color: var(--settings-ink); font: 500 13px/20px var(--tools-font); }
body[data-theme] .modal.settings-dialog button:hover { background: var(--settings-soft); }
body[data-theme] .modal.settings-dialog :focus-visible { outline: 2px solid var(--tools-focus); outline-offset: 3px; }
body[data-theme] .modal.settings-dialog button.primary { background: var(--tools-action); border-color: var(--tools-action); color: var(--tools-on-action); }
body[data-theme] .modal.settings-dialog button.primary:hover { filter: brightness(.92); }
body[data-theme] .modal.settings-dialog .settings-close { width: 32px; min-height: 32px; padding: 0; border-color: transparent; font-size: 23px; color: var(--settings-muted); }
.settings-themes { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-top: 14px; }
body[data-theme] .modal.settings-dialog .settings-theme { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 6px 6px 8px; font-size: 12px; }
body[data-theme] .modal.settings-dialog .settings-theme.on { border-color: var(--tools-focus); box-shadow: 0 0 0 1px var(--tools-focus); }
.settings-theme-preview { height: 46px; display: flex; align-items: end; gap: 4px; padding: 8px; border-radius: 3px; background: #edf0f5; border: 1px solid #20252e0f; }
.settings-theme-preview i { display: block; width: 28%; height: 100%; border-radius: 2px; background: #fff; box-shadow: 0 1px 3px #0001; }
.settings-theme-preview i + i { width: 64%; height: 75%; }
.settings-theme[data-theme="warm"] .settings-theme-preview { background: #f1e7db; }
.settings-theme[data-theme="cool"] .settings-theme-preview { background: #dfe8f5; }
.settings-theme[data-theme="dark"] .settings-theme-preview { background: #17191d; }
.settings-theme[data-theme="dark"] .settings-theme-preview i { background: #393e47; }
.settings-walls { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 8px; margin-bottom: 16px; }
body[data-theme] .modal.settings-dialog .settings-wall-option { display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 0; border: 0; background: transparent; font-size: 11px; color: var(--settings-muted); }
.settings-wall-swatch { display: grid; place-items: center; height: 38px; border-radius: 5px; border: 1px solid var(--settings-line); font-size: 20px; color: var(--settings-muted); }
.settings-wall-option.on .settings-wall-swatch { outline: 2px solid var(--tools-focus); outline-offset: 2px; }
body[data-theme] .modal.settings-dialog .settings-wall-option.on { color: var(--settings-ink); }
body[data-theme] .modal.settings-dialog .settings-upload { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-style: dashed; text-align: left; }
.settings-upload svg, .settings-access svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.settings-upload > span:nth-child(2), .settings-access > span:nth-child(2) { flex: 1; min-width: 0; }
.settings-dialog strong { display: block; font-size: 13px; font-weight: 600; }
.settings-dialog small { display: block; color: var(--settings-muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
.settings-chevron { font-size: 22px; color: var(--settings-muted); }
body[data-theme] .modal.settings-dialog .settings-upload.drag { border-color: var(--tools-focus); background: var(--settings-soft); }
.settings-image-status { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.settings-image-status[hidden] { display: none; }
.settings-image-status > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--settings-muted); font-size: 12px; }
body[data-theme] .modal.settings-dialog .settings-image-status button { font-size: 12px; padding: 4px 8px; min-height: 30px; }
.settings-admin-badge { padding: 2px 7px; border: 1px solid var(--settings-line); border-radius: 4px; font-weight: 500; }
.settings-access { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--settings-line); border-radius: var(--tools-control-radius); color: inherit; text-decoration: none; }
.settings-access:hover { background: var(--settings-soft); border-color: var(--settings-muted); }
.settings-access-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--settings-soft); }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--settings-line); flex: none; }
.settings-footer > span { color: var(--settings-muted); font-size: 11px; }
@media (max-width: 420px) {
    .settings-wall { padding: 10px; }
    .modal.settings-dialog { max-height: calc(100dvh - 20px); }
    .settings-header { padding: 20px 18px 18px; }
    .settings-content { padding: 0 18px; }
    .settings-themes { gap: 7px; }
    .settings-walls { gap: 7px; }
    .settings-footer { padding: 14px 18px; }
}
