/* ==========================================================================
   Interface — styles
   Mobile rules hang off `body.mobile`, which js/shell.js toggles using the
   breakpoint in config.js.
   ========================================================================== */

:root {
  /* colours (dark theme; the light one is below) */
  --text: #f3f5fa;
  --muted: rgba(243, 245, 250, 0.64);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #7db0ff;
  --accent-rgb: 125 176 255;
  --ink: 255 255 255;          /* tints laid over a surface: hover, borders, chips */
  --well: 0 0 0;               /* sunken areas such as lists and tables */
  --panel: 28 33 56;           /* solid-ish panels: menus, pop-ups */
  --surface: rgba(17, 21, 38, 0.86);
  --head: #1b2140;             /* table headings that stay put while scrolling */
  --sheet: #151a33;            /* fully solid panels */
  --bg: #0a0f24;
  --danger: #ff9c9c;
  --ok: #a6efc3;
  --glass-bg: rgba(255, 255, 255, 0.11);
  --glass-line: rgba(255, 255, 255, 0.2);
  --label-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  --scheme: dark;
  --tb-h: 58px;          /* taskbar height (desktop) */
  --dock-space: 106px;   /* room reserved for the dock (mobile) */
  --tile: 56px;          /* app tile size */
  --cols: 4;             /* mobile apps across */
}

* { box-sizing: border-box; }

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

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
input { user-select: text; -webkit-user-select: text; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- light theme: the same names, light values ---------- */
:root[data-theme="light"] {
  --text: #142033;
  --muted: rgba(20, 32, 51, 0.6);
  --line: rgba(20, 32, 51, 0.14);
  --accent: #2f6ee6;
  --accent-rgb: 47 110 230;
  --ink: 20 32 51;
  --well: 255 255 255;
  --panel: 246 248 252;
  --surface: rgba(246, 248, 252, 0.9);
  --head: #eef2f8;
  --sheet: #f7f9fc;
  --bg: #e9eef7;
  --danger: #c0362c;
  --ok: #157a43;
  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-line: rgba(255, 255, 255, 0.8);
  --label-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
  --scheme: light;
}
:root[data-theme="light"] .wallpaper {
  background:
    radial-gradient(60% 50% at 12% 18%, #a9c0ff 0%, transparent 62%),
    radial-gradient(50% 45% at 88% 12%, #d8c2ff 0%, transparent 60%),
    radial-gradient(60% 60% at 72% 96%, #9fe3dc 0%, transparent 62%),
    linear-gradient(160deg, #eef2fb, #e6ebf7 50%, #dfe6f4);
}
:root[data-theme="light"] .glass { box-shadow: 0 12px 40px rgba(30, 41, 80, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7); }
:root[data-theme="light"] .window { box-shadow: 0 18px 50px rgba(30, 41, 80, 0.2); }
:root[data-theme="light"] .window.active { box-shadow: 0 24px 70px rgba(30, 41, 80, 0.3); }

/* ---------- shared pieces ---------- */

.wallpaper {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60% 50% at 12% 18%, #3558d6 0%, transparent 62%),
    radial-gradient(50% 45% at 88% 12%, #7a3fd0 0%, transparent 60%),
    radial-gradient(60% 60% at 72% 96%, #0d8a98 0%, transparent 62%),
    linear-gradient(160deg, #0c1330, #141b3d 50%, #0a0f24);
}

.screen { position: fixed; inset: 0; }

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.field {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgb(var(--ink) / 0.08);
  outline: none;
}
.field::placeholder { color: var(--muted); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.25); }

.btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgb(var(--ink) / 0.1);
  white-space: nowrap;
  transition: background 0.15s;
}
.btn:hover { background: rgb(var(--ink) / 0.18); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.primary { background: #3d7bf0; border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #558cf5; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgb(var(--ink) / 0.1); }
.btn.wide { width: 100%; height: 42px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.end { justify-content: flex-end; }

.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgb(var(--ink) / 0.3);
  background: linear-gradient(140deg, #5b8def, #8a5cf0);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.avatar.big { width: 48px; height: 48px; font-size: 16px; }

/* The coloured square behind every app icon. Colour comes from --c. */
.tile {
  --c: #64748b;
  width: var(--tile);
  height: var(--tile);
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 26%;
  color: #fff;
  background: linear-gradient(145deg, color-mix(in srgb, var(--c) 78%, white), var(--c) 55%, color-mix(in srgb, var(--c) 78%, black));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.tile svg { width: 54%; height: 54%; }

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

.login { display: grid; place-items: center; padding: 20px; overflow: auto; }

.login-card {
  width: min(400px, 100%);
  padding: 34px 30px 26px;
  border-radius: 24px;
  text-align: center;
}
.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(140deg, #5b8def, #8a5cf0 60%, #19b3c4);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.login-card h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; }
.login-card form { display: grid; gap: 10px; margin-top: 22px; }
.login-card form p { font-size: 13px; }
.sso { display: grid; gap: 8px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-error { min-height: 20px; margin: 12px 0 2px; color: var(--danger); font-size: 13px; }

/* ---------- search ---------- */

.search {
  position: absolute;
  z-index: 3;
  top: 22px;
  left: 50%;
  width: min(50vw, 680px);          /* never wider than half a desktop screen */
  transform: translateX(-50%);
  border-radius: 18px;
}
.search-bar { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; }
.search-ico { display: grid; color: var(--muted); }
.search-ico svg { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
.search kbd {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font: 11px/1.5 inherit;
  white-space: nowrap;
}
.search-results { display: none; max-height: min(62vh, 560px); padding: 6px; border-top: 1px solid var(--line); overflow-y: auto; }
.search.has-results .search-results { display: block; }
.result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  font-size: 14px;
}
.result .tile { --tile: 30px; flex: none; box-shadow: none; }
.result.sel, button.result:hover { background: rgb(var(--ink) / 0.14); }
.result.none { color: var(--muted); }
/* results come in groups (Apps, then whatever the search providers return) */
.result-group { padding: 10px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.result-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.result-title, .result-sub { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.result-sub { color: var(--muted); font-size: 12px; }
.result-note { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.result mark { border-radius: 3px; background: rgb(var(--accent-rgb) / 0.34); color: inherit; }
.result.child { width: calc(100% - 26px); margin-left: 26px; padding: 5px 10px; font-size: 13px; }
.result.child .tile { --tile: 22px; }
.result-more { margin-left: 70px; padding: 2px 0 6px; color: var(--muted); font-size: 12px; }
.search-foot {
  position: sticky;
  bottom: -6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 6px -6px -6px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: rgb(var(--panel) / 0.92);
  color: var(--muted);
  font-size: 12px;
}
.search-foot kbd { margin-right: 4px; }

/* ---------- desktop icons ---------- */

/* The icons sit on one or more pages laid side by side; one shows at a time.
   Swiping scrolls between them and each page snaps into place. */
.icons {
  position: absolute;
  inset: 0 0 var(--tb-h) 0;
  z-index: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.icons::-webkit-scrollbar { display: none; }
.icon-page { position: relative; flex: 0 0 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; }

/* one dot per page: soft for the others, strong for the page showing */
.pages {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tb-h) + 6px);
  z-index: 2;
  display: flex;
  gap: 4px;
  transform: translateX(-50%);
}
.pages button { width: 16px; height: 16px; padding: 0; border: 0; background: none; cursor: pointer; }
.pages button::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  margin: auto;
  border-radius: 50%;
  background: rgb(var(--ink) / 0.34);
  transition: background 0.2s, transform 0.2s;
}
.pages button:hover::before { background: rgb(var(--ink) / 0.6); }
.pages button.on::before { background: rgb(var(--ink)); transform: scale(1.3); }

.pages-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tb-h) + 32px);
  z-index: 2;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.25s, transform 0.25s;
}
.pages-hint.show { opacity: 1; transform: translate(-50%, 0); }
.pages-hint kbd { padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; font: inherit; }

.app-icon { cursor: pointer; touch-action: none; }
.app-icon[data-zone="desktop"] { touch-action: pan-x; }

.app-icon[data-zone="desktop"] { position: absolute; width: 96px; min-height: 100px; }
.app-icon[data-zone="desktop"], .app-icon[data-zone="folder"] {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 4px 6px;
  border-radius: 12px;
  transition: background 0.15s;
}
.app-icon[data-zone="desktop"]:hover, .app-icon[data-zone="folder"]:hover { background: rgb(var(--ink) / 0.09); }

/* a folder's tile: frosted square with a 2 x 2 preview of its apps */
.tile.folder-tile {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  place-items: stretch;
  gap: 6%;
  padding: 9%;
  background: rgb(var(--ink) / 0.2);
  border: 1px solid rgb(var(--ink) / 0.28);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.folder-tile .tile { width: 100%; height: 100%; box-shadow: none; }
.folder-tile .tile svg { width: 62%; height: 62%; stroke-width: 2.4; }

/* the open folder */
.folder-layer { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
.folder-layer.drag-hide { opacity: 0; }
.folder-panel {
  --tile: 90px;          /* size of the app icons inside an open folder */
  position: absolute;
  width: min(390px, calc(100vw - 24px));
  padding: 14px 14px 12px;
  border-radius: 22px;
  background: rgb(var(--panel) / 0.78);
  pointer-events: auto;
  animation: win-in 0.14s ease-out;
}
.folder-layer.drag-hide .folder-panel { pointer-events: none; }
.folder-name {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  outline: none;
  background: none;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
}
.folder-name:hover { background: rgb(var(--ink) / 0.08); }
.folder-name:focus { border-color: var(--accent); background: rgb(var(--ink) / 0.08); }
.folder-grid .label { font-size: 13.5px; }
.folder-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 2px; max-height: 52vh; margin-top: 8px; overflow-y: auto; }
.folder-hint { margin-top: 8px; color: var(--muted); font-size: 12px; text-align: center; }

.label {
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12.5px;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  text-shadow: var(--label-shadow);
}
/* small dot next to the name of an open app */
.app-icon.open .label::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

.app-icon.drag-src { opacity: 0.3; }
.app-icon.ghost {
  position: fixed !important;
  z-index: 999;
  left: 0 !important;
  top: 0 !important;
  margin: 0;
  pointer-events: none;
  opacity: 0.95;
  background: none !important;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.5));
}
body.dragging, body.dragging * { cursor: grabbing !important; }
body.win-dragging iframe { pointer-events: none; }

/* ---------- taskbar (desktop) ---------- */

.taskbar {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tb-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-width: 1px 0 0;
  transition: background 0.15s;
}
.taskbar.drop-target { background: rgb(var(--ink) / 0.2); }
.tb-group { display: flex; align-items: center; gap: 4px; }
#tb-pinned { position: relative; min-width: 46px; min-height: 46px; flex: 0 1 auto; overflow-x: auto; overflow-y: hidden;
  border-radius: 12px; scrollbar-width: none; }
#tb-pinned::-webkit-scrollbar { display: none; }
#tb-pinned > .app-icon { flex: none; }
.drop-line.bar-line { width: 4px; }
body.dragging #tb-pinned { outline: 1px dashed rgb(var(--ink) / 0.4); outline-offset: 3px; }
.tb-sep { width: 1px; height: 26px; margin: 0 4px; background: var(--line); }
.tb-spacer { flex: 1; }
.tb-tray { display: flex; align-items: center; gap: 12px; }
.clock { display: grid; text-align: right; font-size: 12px; line-height: 1.3; }
.clock b { font-weight: 600; }
.clock span { color: var(--muted); }

.app-icon[data-zone="taskbar"] {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  transition: background 0.15s;
}
.app-icon[data-zone="taskbar"] .tile { --tile: 32px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.app-icon[data-zone="taskbar"] .label { display: none; }
.app-icon[data-zone="taskbar"]:hover { background: rgb(var(--ink) / 0.1); }

/* open / focused indicator */
.app-icon[data-zone="taskbar"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 0;
  height: 3px;
  border-radius: 2px;
  background: rgb(var(--ink));
  opacity: 0;
  transform: translateX(-50%);
  transition: width 0.18s, opacity 0.18s, background 0.18s;
}
.app-icon[data-zone="taskbar"].open { background: rgb(var(--ink) / 0.09); }
.app-icon[data-zone="taskbar"].open::after { width: 6px; opacity: 0.75; }
.app-icon[data-zone="taskbar"].active { background: rgb(var(--ink) / 0.2); }
.app-icon[data-zone="taskbar"].active::after { width: 18px; opacity: 1; background: var(--accent); }

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

.windows { position: absolute; inset: 0 0 var(--tb-h) 0; z-index: 5; overflow: hidden; pointer-events: none; }

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  border: 1px solid rgb(var(--ink) / 0.16);
  border-radius: 14px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
  animation: win-in 0.16s ease-out;
  transition: opacity 0.16s, transform 0.16s, visibility 0s;
}
.window.active { border-color: rgb(var(--ink) / 0.28); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55); }
/* minimised: hidden but kept in the page so its content stays alive */
.window.minimized {
  opacity: 0;
  transform: translateY(36px) scale(0.95);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s, transform 0.16s, visibility 0s 0.16s;
}
.window.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
  border-width: 0;
}
@keyframes win-in { from { opacity: 0; transform: scale(0.97); } }

.win-bar {
  flex: none;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--line);
  touch-action: none;
}
.win-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.win-title .tile { --tile: 22px; box-shadow: none; }
.win-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; font-size: 13px; }
.win-ctl { display: flex; gap: 2px; }
.win-ctl button {
  width: 36px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: none;
  transition: background 0.12s;
}
.win-ctl svg { width: 15px; height: 15px; }
.win-ctl button:hover { background: rgb(var(--ink) / 0.14); }
.win-ctl button[data-act="close"]:hover { background: #e5484d; color: #fff; }

.win-body { flex: 1; min-height: 0; overflow: auto; border-radius: 0 0 13px 13px; }
.empty { height: 100%; display: grid; place-items: center; color: rgb(var(--ink) / 0.3); font-size: 13px; }

/* resize handles */
.rz { position: absolute; z-index: 2; touch-action: none; }
.rz-n, .rz-s { left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.rz-e, .rz-w { top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.rz-n { top: -4px; } .rz-s { bottom: -4px; } .rz-e { right: -4px; } .rz-w { left: -4px; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 16px; height: 16px; }
.rz-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.rz-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.rz-se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.rz-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.window.maximized .rz { display: none; }

/* ---------- menus, pickers, toast ---------- */

.overlay { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.overlay > * { position: absolute; pointer-events: auto; animation: win-in 0.12s ease-out; }
.overlay .glass { background: rgb(var(--panel) / 0.82); }

.menu { min-width: 210px; padding: 6px; border-radius: 14px; }
.menu hr { height: 1px; margin: 5px 8px; border: 0; background: var(--line); }
.menu-head { display: grid; padding: 8px 10px 10px; margin-bottom: 5px; border-bottom: 1px solid var(--line); }
.menu-head span { color: var(--muted); font-size: 12px; }
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  text-align: left;
}
.menu-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.menu-item:hover:not(:disabled) { background: rgb(var(--ink) / 0.14); }
.menu-item:disabled { opacity: 0.45; cursor: default; }
.menu-item.danger { color: var(--danger); }

.dialog { width: min(300px, calc(100vw - 16px)); padding: 16px; border-radius: 16px; }
.dialog h4 { margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.dialog form { display: grid; gap: 12px; }

.pick-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.pick {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
}
.pick svg { width: 20px; height: 20px; }
.pick:hover { background: rgb(var(--ink) / 0.14); }
.pick.on { border-color: var(--accent); background: rgb(var(--accent-rgb) / 0.2); }
.pick-grid.colors { grid-template-columns: repeat(6, 1fr); gap: 10px; }
.swatch { aspect-ratio: 1; padding: 0; border: 2px solid transparent; border-radius: 50%; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.swatch:hover { transform: scale(1.08); }
.swatch.on { border-color: var(--text); }
.custom-color { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); cursor: pointer; }
.custom-color input { width: 44px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(var(--tb-h) + 18px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgb(var(--panel) / 0.86);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Settings app ---------- */

.settings { max-width: 640px; margin: 0 auto; padding: 24px 20px 32px; display: grid; gap: 16px; }
.settings h2 { font-size: 20px; font-weight: 650; }
.card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgb(var(--ink) / 0.05); }
.card h3 { margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.card > .muted { margin-bottom: 14px; font-size: 13px; }
.acct { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.pw-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.pw-form .field { height: 38px; }
.pw-form + p { margin-top: 8px; }
.rules-form { display: grid; gap: 10px; margin-top: 10px; justify-items: start; }
.rules-form label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.rules-form .field { width: 84px; height: 36px; }
.rules-form input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.acct-text { flex: 1; min-width: 0; display: grid; }
.acct-text span { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.badge { padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgb(var(--accent-rgb) / 0.16); font-size: 11px; font-weight: 600; text-transform: capitalize; }

.layout-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 18px; }
.seg { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgb(var(--well) / 0.2); }
.seg button { display: grid; gap: 1px; min-width: 104px; padding: 8px 14px; border: 0; border-radius: 9px; background: none; font-weight: 600; }
.seg small { color: var(--muted); font-size: 11px; font-weight: 400; }
.seg button:hover { background: rgb(var(--ink) / 0.08); }
.seg button.on { background: #3d7bf0; color: #fff; }
.seg button.on small { color: rgba(255, 255, 255, 0.85); }

/* tiny phone preview of the chosen layout */
.phone { width: 84px; height: 148px; display: flex; flex-direction: column; justify-content: space-between; padding: 12px 8px 8px; border: 2px solid rgb(var(--ink) / 0.35); border-radius: 16px; background: rgb(var(--well) / 0.25); }
.phone-grid { display: grid; gap: 6px 5px; }
.phone-grid i, .phone-dock i { aspect-ratio: 1; border-radius: 26%; background: rgb(var(--ink) / 0.55); }
.phone-dock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 8px; background: rgb(var(--ink) / 0.16); }
.phone-dock i { background: var(--accent); }

/* ==========================================================================
   Mobile layout
   ========================================================================== */

body.mobile { --tile: 60px; }
body.mobile[data-cols="3"] { --tile: 72px; }

body.mobile .search { top: calc(14px + env(safe-area-inset-top)); width: 90vw; }
body.mobile .search kbd, body.mobile .search-foot { display: none; }

/* each page is a grid of icons; it runs underneath the glass search bar and dock */
body.mobile .icons { inset: 0; }
body.mobile .icon-page {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  align-content: start;
  gap: 22px 6px;
  padding: calc(88px + env(safe-area-inset-top)) 5vw calc(var(--dock-space) + 24px + env(safe-area-inset-bottom));
}
body.mobile .pages { bottom: calc(var(--dock-space) + 2px + env(safe-area-inset-bottom)); }
body.mobile .pages-hint { bottom: calc(var(--dock-space) + 26px + env(safe-area-inset-bottom)); }
body.mobile .app-icon[data-zone="desktop"] {
  position: static;
  width: auto;
  min-height: 0;
  padding: 4px 0;
}
body.mobile .app-icon[data-zone="desktop"]:hover { background: none; }
body.mobile[data-cols="3"] .label { font-size: 13.5px; }

/* the taskbar becomes a floating dock holding only the pinned apps */
body.mobile .taskbar {
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  height: 86px;
  padding: 0 8px;
  border-width: 1px;
  border-radius: 28px;
}
body.mobile .tb-sep, body.mobile #tb-running, body.mobile .tb-spacer, body.mobile .tb-tray { display: none; }
/* The dock shows four at a time; swipe it for the rest. */
body.mobile #tb-pinned { flex: 1; height: 100%; justify-content: flex-start; gap: 0; outline: none; scroll-snap-type: x mandatory; }
body.mobile #tb-pinned > .app-icon { flex: 0 0 25%; scroll-snap-align: start; }
body.mobile .app-icon[data-zone="taskbar"] { width: 66px; height: 74px; background: none; }
body.mobile .app-icon[data-zone="taskbar"] .tile { --tile: 56px; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
body.mobile .app-icon[data-zone="taskbar"]::after { bottom: 0; height: 5px; border-radius: 3px; }
body.mobile .app-icon[data-zone="taskbar"].open::after { width: 5px; opacity: 0.85; }
body.mobile .app-icon[data-zone="taskbar"].active::after { width: 18px; }
body.mobile .app-icon[data-zone="taskbar"].open .tile {
  box-shadow: 0 0 0 2px rgb(var(--ink) / 0.4), 0 0 18px color-mix(in srgb, var(--c) 75%, transparent);
}

/* apps open full screen above the dock */
body.mobile .windows { bottom: calc(var(--dock-space) + env(safe-area-inset-bottom)); }
body.mobile .window {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-width: 0 0 1px;
  border-radius: 0 0 18px 18px;
}
body.mobile .win-bar { height: calc(46px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
body.mobile .win-ctl button { width: 42px; height: 36px; }
body.mobile .win-ctl [data-act="max"], body.mobile .rz { display: none; }
body.mobile .toast { bottom: calc(var(--dock-space) + 14px + env(safe-area-inset-bottom)); }
body.mobile .pick-grid:not(.colors) { grid-template-columns: repeat(6, 1fr); }
body.mobile .pick { min-height: 40px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- a window's subtitle, and the list of an app's open windows ---------- */

.win-sub { overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.win-list { min-width: 240px; max-width: 340px; }
.win-list-row { display: flex; align-items: center; gap: 2px; border-radius: 9px; }
.win-list-row.on { background: rgb(var(--ink) / 0.1); }
.win-list-row .menu-item { flex: 1; min-width: 0; }
.win-list-row .tile { --tile: 22px; box-shadow: none; }
.win-list-row.min .menu-item { opacity: 0.7; }
.win-list-text { min-width: 0; display: grid; text-align: left; }
.win-list-text b, .win-list-text small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.win-list-text b { font-weight: 500; }
.win-list-text small { color: var(--muted); font-size: 11px; }
.win-list-text small:empty { display: none; }
.win-list-close { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; opacity: 0.6; }
.win-list-close:hover { opacity: 1; background: rgb(var(--ink) / 0.12); }
.win-list-close svg { width: 13px; height: 13px; }
.tb-peek { position: absolute; z-index: 21; background: rgb(var(--panel) / 0.92); animation: win-in 0.12s ease-out; }

/* ---------- the search box in front, Show desktop, the drop line ---------- */

/* Clicked, the search box comes up above the windows (which sit at 5). */
.search.front { z-index: 6; }

.show-desktop { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 9px;
  background: none; color: var(--muted); cursor: pointer; }
.show-desktop svg { width: 18px; height: 18px; }
.show-desktop:hover { background: rgb(var(--ink) / 0.12); color: var(--text); }
.show-desktop.on { border-color: rgb(var(--ink) / 0.25); background: rgb(var(--ink) / 0.14); color: var(--text); }

/* Where a dragged icon will go when it is dropped between others. */
.drop-line { position: absolute; z-index: 4; width: 4px; border-radius: 4px; background: var(--accent, #5b8def);
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb, 91 141 239) / 0.25); pointer-events: none; }
.drop-line.across { height: 4px; }
.drop-line[hidden] { display: none; }
.app-icon.drop-into { border-radius: 18px; background: rgb(var(--ink) / 0.12); outline: 2px dashed rgb(var(--ink) / 0.45); outline-offset: -2px; }

/* The bell on the taskbar, and its list of notifications */
.bell { position: relative; }
.bell-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--taskbar-bg, #0c1330); }
.bell-badge[hidden] { display: none; }
.notify-panel { position: absolute; right: 12px; bottom: calc(var(--taskbar-h, 56px) + 10px); z-index: 60; width: min(380px, calc(100vw - 24px));
  max-height: min(520px, 70vh); display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; }
.notify-panel header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notify-panel h4 { margin: 0; font-size: 14px; }
.notify-all { padding: 0; border: 0; background: none; color: var(--accent, #5b8def); font-size: 12px; cursor: pointer; }
.notify-all[hidden] { display: none; }
.notify-list { overflow: auto; padding: 6px; display: grid; gap: 2px; }
.notify-empty { margin: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.notify-item { display: grid; gap: 3px; width: 100%; padding: 9px 10px 9px 22px; border: 0; border-radius: 10px; background: none;
  color: var(--text); font: inherit; font-size: 13px; line-height: 1.35; text-align: left; cursor: pointer; position: relative; }
.notify-item:hover { background: rgb(var(--ink) / 0.1); }
.notify-item small { color: var(--muted); font-size: 11px; }
.notify-item.unread { font-weight: 600; }
.notify-item.unread::before { content: ""; position: absolute; left: 8px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; }
body.mobile .notify-panel { right: 8px; left: 8px; width: auto; }

/* ---------- snap: two windows side by side ---------- */
/* Left and right halves split at --snap-split (set on the window layer). */
body:not(.mobile) .window.snapped { top: 0 !important; height: 100% !important; border-radius: 0; border-width: 0; }
body:not(.mobile) .window.snap-left { left: 0 !important; width: var(--snap-split, 50%) !important; border-right-width: 1px; }
body:not(.mobile) .window.snap-right { left: var(--snap-split, 50%) !important; width: calc(100% - var(--snap-split, 50%)) !important; }
.window.snapped .rz { display: none; }
body:not(.mobile) .window.snap-left .rz-e, body:not(.mobile) .window.snap-right .rz-w { display: block; top: 0; bottom: 0; width: 10px; }
.window.snap-left .rz-e { right: -5px; } .window.snap-right .rz-w { left: -5px; }

.snap-menu { position: absolute; z-index: 9000; pointer-events: auto; display: flex; gap: 4px; padding: 6px; border-radius: 12px; animation: win-in 0.12s ease-out; }
.snap-menu button { display: grid; justify-items: center; gap: 4px; padding: 7px 8px 5px; border: 0; border-radius: 9px; background: none; color: var(--text); cursor: pointer; }
.snap-menu button:hover, .snap-menu button:focus-visible, .snap-menu button.on { background: rgb(var(--ink) / 0.12); outline: none; }
.snap-menu small { font-size: 11px; white-space: nowrap; color: var(--muted); }
.snap-pic { width: 46px; height: 30px; display: flex; gap: 2px; padding: 2px; border: 1.5px solid rgb(var(--ink) / 0.45); border-radius: 5px; }
.snap-pic i { flex: 1; border-radius: 2px; background: rgb(var(--ink) / 0.12); }
.snap-pic-left i:first-child, .snap-pic-right i:last-child, .snap-pic-full i { background: var(--accent, #5b8def); }
.snap-pic-full { gap: 0; } .snap-pic-full i:first-child { border-radius: 2px 0 0 2px; } .snap-pic-full i:last-child { border-radius: 0 2px 2px 0; }
.snap-pic-own i:first-child { flex: none; width: 60%; margin: 3px 0 3px 4px; background: var(--accent, #5b8def); } .snap-pic-own i:last-child { background: none; }

.snap-assist { position: absolute; top: 0; bottom: 0; z-index: 8999; pointer-events: auto; display: flex; flex-direction: column; gap: 10px; padding: 18px;
  background: rgb(0 0 0 / 0.35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: win-in 0.14s ease-out; }
.snap-assist-left { left: 0; width: var(--snap-split, 50%); }
.snap-assist-right { left: var(--snap-split, 50%); right: 0; }
.snap-assist p { margin: 0; color: #fff; font-weight: 600; font-size: 14px; }
.snap-assist-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; overflow: auto; align-content: start; }
.snap-assist-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid rgb(var(--ink) / 0.18); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.snap-assist-item:hover, .snap-assist-item:focus-visible { border-color: var(--accent, #5b8def); outline: none; }
.snap-assist-item .tile { --tile: 30px; flex: none; }
.snap-assist-text { display: grid; min-width: 0; }
.snap-assist-text b, .snap-assist-text small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.snap-assist-text b { font-size: 13px; } .snap-assist-text small { color: var(--muted); font-size: 11px; }
.snap-assist-skip { align-self: flex-start; padding: 6px 12px; border: 0; border-radius: 8px; background: rgb(255 255 255 / 0.14); color: #fff; font: inherit; font-size: 12px; cursor: pointer; }

.snap-preview { position: absolute; top: 6px; bottom: 6px; z-index: 8998; border: 2px solid var(--accent, #5b8def); border-radius: 12px;
  background: rgb(91 141 239 / 0.16); pointer-events: none; transition: left 0.12s, width 0.12s; }
.snap-preview-left { left: 6px; width: calc(var(--snap-split, 50%) - 12px); }
.snap-preview-right { left: calc(var(--snap-split, 50%) + 6px); right: 6px; }
.snap-preview-full { left: 6px; right: 6px; }
