/* ==========================================================================
   Piper OS — shell: wallpaper, lock screen, menubar, dock, desktop,
   windows, launchpad, spotlight, control center, toasts.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; font-family: var(--font-sans); font-size: var(--text-md); line-height: 1.5;
  color: var(--fg); -webkit-font-smoothing: antialiased; background: #000; user-select: none; -webkit-user-select: none;
}
img, video, svg { display: block; max-width: 100%; }
svg.arrow { width: 1em; height: 1em; display: inline-block; flex: none; vertical-align: -0.15em; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: rgb(var(--accent-rgb) / 0.3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--font-mono); }

/* ---------- Liquid glass material ----------
   Translucent solid tint, backdrop blur and a restrained edge highlight.
   Flat mode uses an opaque plate with a hairline. */
.glass {
  position: relative; isolation: isolate;
  background: var(--chrome-bg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0.5px var(--glass-rim), inset 0 -1px 1px var(--glass-rim-2), var(--chrome-shadow);
  border: 0.5px solid var(--glass-edge);
}

/* ---------- Wallpaper ---------- */
.wallpaper { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--wp-base); transition: background var(--d-5) var(--ease); }
.wallpaper i, .wallpaper::after { display: none; }

:root, [data-wallpaper="aurora"] { --wp-base: #b7c7ff; --wp-1: #6aa8ff; --wp-2: #c48bff; --wp-3: #ff9ccf; --wp-4: #7fe0ff; }
[data-wallpaper="dusk"]  { --wp-base: #f6b8a8; --wp-1: #ff8a6b; --wp-2: #ffc46b; --wp-3: #c86bff; --wp-4: #ff6b9c; }
[data-wallpaper="mint"]  { --wp-base: #b9ecd9; --wp-1: #5fd3a6; --wp-2: #8ad8ff; --wp-3: #e2ff9c; --wp-4: #59b3ff; }
[data-mode="dark"][data-wallpaper="aurora"], [data-mode="dark"]:not([data-wallpaper]) { --wp-base: #0b0f24; --wp-1: #1f3fbf; --wp-2: #6a1fbf; --wp-3: #bf1f6e; --wp-4: #0f6f8f; }
[data-mode="dark"][data-wallpaper="dusk"] { --wp-base: #1d0d12; --wp-1: #a3341f; --wp-2: #8a5a10; --wp-3: #5a1f8a; --wp-4: #8a1f4a; }
[data-mode="dark"][data-wallpaper="mint"] { --wp-base: #06171a; --wp-1: #0f7a5a; --wp-2: #0f5a8a; --wp-3: #4a7a0f; --wp-4: #0f3a8a; }

[data-material="flat"] .wallpaper { background: var(--desktop); }
[data-material="flat"] .wallpaper i, [data-material="flat"] .wallpaper::after { display: none; }

/* ---------- Lock screen ---------- */
.lock {
  position: fixed; inset: 0; z-index: var(--z-lock); display: grid; grid-template-rows: 1fr auto; justify-items: center;
  padding: 12vh 24px 10vh; color: #fff; cursor: pointer;
  background: rgb(0 0 0 / 0.08); -webkit-backdrop-filter: blur(0px); backdrop-filter: blur(0px);
  transition: opacity var(--d-4) var(--ease), transform var(--d-4) var(--ease), backdrop-filter var(--d-4);
}
[data-material="flat"] .lock { color: var(--fg); background: var(--desktop); }
.lock[data-leaving] { opacity: 0; transform: translateY(-4%) scale(1.02); pointer-events: none; }
.lock__time { text-align: center; text-shadow: 0 2px 30px rgb(0 0 0 / 0.15); }
.lock__date { font-size: var(--text-xl); font-weight: 500; opacity: 0.9; }
.lock__clock { font-family: var(--font-display); font-size: clamp(88px, 18vw, 180px); font-weight: 700; letter-spacing: -0.05em; line-height: 0.95; font-variant-numeric: tabular-nums; }
[data-material="flat"] .lock__clock { font-weight: 400; letter-spacing: -0.02em; }
.lock__user { display: grid; justify-items: center; gap: 10px; }
/* Avatar: the goose stands on its own (no plate), with a soft contact
   shadow under its feet so the white body still sits on light wallpapers. */
.lock__avatar { position: relative; width: 120px; height: 176px; margin-top: 40px; transition: transform var(--d-3) var(--ease-spring); }
.lock__avatar::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 64px; height: 10px; margin-left: -32px; border-radius: 50%; background: rgb(0 0 0 / 0.22); filter: blur(4px); }
.lock__pop { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.lock__pop img {
  --gx: 0px; --gy: 0px; --gr: 0deg;
  position: absolute; left: 50%; bottom: 4px; height: 172px; max-width: none;
  transform: translateX(-50%) translate(var(--gx), var(--gy)) rotate(var(--gr));
  transform-origin: 50% 96%; /* the feet: the goose leans away while standing in place */
  filter: drop-shadow(0 0 0.5px rgb(0 0 0 / 0.35)) drop-shadow(0 4px 8px rgb(0 0 0 / 0.14));
  transition: transform 420ms var(--ease-spring);
}
/* While the cursor is near, the goose leans away from it (set from os.js) */
.lock__pop img[data-shy] { transition-duration: 260ms; }
.lock__name { font-size: var(--text-lg); font-weight: 600; }
.lock__hint { font-size: var(--text-sm); opacity: 0.75; display: flex; align-items: center; gap: 8px; }
.lock__hint::after { content: "→"; animation: nudge 1.4s var(--ease) infinite; }
@keyframes nudge { 50% { transform: translateX(4px); } }

/* ---------- Menubar ---------- */
.menubar {
  position: fixed; inset: 0 0 auto; height: var(--menubar-h); z-index: var(--z-menubar);
  display: flex; align-items: center; gap: 2px; padding: 0 8px; font-size: 12.5px; color: var(--menubar-fg);
  background: var(--menubar-bg); -webkit-backdrop-filter: blur(30px) saturate(115%); backdrop-filter: blur(30px) saturate(115%);
  border-bottom: 0.5px solid var(--separator);
}
[data-material="glass"][data-mode="light"] .menubar { color: #111; }
.mb-item { height: 20px; padding: 0 9px; border-radius: var(--r-xs); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; transition: background var(--d-1); }
.mb-item:hover, .mb-item[aria-expanded="true"] { background: var(--hover); }
.mb-item--app { font-weight: 700; }
.mb-item svg { width: 14px; height: 14px; }
.mb-logo img { width: 15px; height: 17px; object-fit: contain; }
[data-mode="dark"] .mb-logo img { filter: invert(1) brightness(2); }
.mb-spacer { flex: 1; }
.mb-clock { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .mb-hide-sm { display: none; } }

.menu {
  position: fixed; top: calc(var(--menubar-h) + 2px); min-width: 230px; padding: 6px; border-radius: var(--r-lg); z-index: var(--z-popover); font-size: var(--text-sm);
  opacity: 0; transform: scale(0.96) translateY(-4px); transform-origin: top left; pointer-events: none;
  transition: opacity var(--d-1) var(--ease), transform var(--d-2) var(--ease-out);
}
.menu[data-open] { opacity: 1; transform: none; pointer-events: auto; }
.menu button, .menu a { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 5px 10px; border-radius: var(--r-xs); text-align: left; }
.menu button:hover, .menu a:hover { background: var(--accent); color: var(--on-accent); }
.menu hr { border: 0; height: 1px; background: var(--separator); margin: 5px 8px; }
.menu kbd { font-family: var(--font-sans); opacity: 0.55; font-size: var(--text-xs); }

/* ---------- Desktop ---------- */
.desktop { position: fixed; inset: var(--menubar-h) 0 0; z-index: var(--z-desktop); }
.desk-icons { position: absolute; top: 18px; right: 18px; display: grid; grid-auto-flow: row; gap: 10px; justify-items: center; }
.desk-icon {
  width: 96px; padding: 8px 4px; border-radius: var(--r-md); display: grid; justify-items: center; gap: 6px; text-align: center;
  font-size: var(--text-xs); font-weight: 600; color: var(--desktop-fg); text-shadow: 0 1px 3px rgb(0 0 0 / 0.35); touch-action: none;
  transition: background var(--d-1);
}
[data-material="flat"] .desk-icon { text-shadow: none; }
.desk-icon:hover { background: rgb(255 255 255 / 0.12); }
.desk-icon[aria-selected="true"] { background: rgb(var(--accent-rgb) / 0.25); }
.desk-icon[aria-selected="true"] span:last-child { background: var(--accent); color: var(--on-accent); border-radius: 4px; padding: 0 5px; text-shadow: none; }
.desk-icon .appicon { --size: 56px; }

/* Desktop widgets (stacked top-left) */
.widgets { position: absolute; top: 22px; left: 22px; width: min(420px, calc(100vw - 44px)); display: grid; gap: 14px; }
.widget { position: relative; border-radius: var(--r-2xl); padding: var(--s5); color: var(--fg); text-align: left; }
.widget--intro { animation: rise var(--d-5) var(--ease-out) 200ms backwards; }
.widget__eyebrow { font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-2); display: flex; align-items: center; gap: 8px; }
.widget h1 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 34px; line-height: 1.05; margin: 12px 0 10px; }
[data-material="flat"] .widget h1 { font-size: 46px; line-height: 1; }
.widget p { color: var(--fg-2); margin: 0 0 var(--s5); font-size: var(--text-md); }
.widget__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.widget--now { display: flex; align-items: center; gap: 14px; padding: 12px; cursor: pointer; animation: rise var(--d-5) var(--ease-out) 340ms backwards; transition: transform var(--d-3) var(--ease-spring); }
.widget--now:hover { transform: translateY(-3px); }
/* Thumb on the left, label + title stacked and centred on the right; the cover may be a <picture>. */
.widget__thumb { flex: none; width: 116px; aspect-ratio: 16 / 10; overflow: hidden; border-radius: var(--r-md); background: var(--field); }
.widget__thumb picture, .widget__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.widget__text { position: relative; z-index: 1; min-width: 0; display: grid; gap: 4px; }
.widget--now small { color: var(--fg-3); font-size: var(--text-2xs); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }
.widget--now strong { font-size: var(--text-md); line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--p-green); box-shadow: 0 0 0 0 rgb(47 191 113 / 0.6); animation: ping 2s var(--ease-out) infinite; flex: none; }
@keyframes ping { 70%, 100% { box-shadow: 0 0 0 7px rgb(47 191 113 / 0); } }

/* ---------- App icon (shared by dock, desktop, launchpad) ---------- */
.appicon {
  --size: 52px;
  width: var(--size); height: var(--size); flex: none; position: relative; border-radius: var(--icon-radius);
  display: grid; place-items: center; background: var(--icon-tile); border: 0.5px solid var(--icon-border);
  box-shadow: inset 0 1px 1px rgb(255 255 255 / 0.6), var(--icon-shadow);
  -webkit-backdrop-filter: blur(14px) saturate(120%); backdrop-filter: blur(14px) saturate(120%);
  overflow: hidden;
}
.appicon svg { width: 62%; height: 62%; filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.12)); }
[data-material="flat"] .appicon { box-shadow: none; backdrop-filter: none; }
[data-material="flat"] .appicon::after { display: none; }
[data-material="flat"] .appicon svg { filter: none; }

/* ---------- Dock ---------- */
.dock-wrap { position: fixed; left: 0; right: 0; bottom: 8px; z-index: var(--z-dock); display: flex; justify-content: center; pointer-events: none; transition: transform var(--d-3) var(--ease-out); }
/* Concentric corners: dock radius = icon radius + padding */
.dock { --dock-icon: 52px; --dock-pad: 7px; pointer-events: auto; display: flex; align-items: flex-end; gap: 6px; padding: var(--dock-pad); border-radius: calc(var(--dock-icon) * var(--icon-round, 0.26) + var(--dock-pad)); }
.dock-item { --size: 52px; position: relative; width: var(--size); height: var(--size); transition: width var(--d-1) var(--ease-out), height var(--d-1) var(--ease-out); }
.dock-item .appicon { --size: 100%; width: 100%; height: 100%; transition: transform var(--d-2) var(--ease-spring), filter var(--d-1); }
.dock-item:active .appicon { filter: brightness(0.82); }
.dock-item[data-bounce] .appicon { animation: dock-bounce 0.55s var(--ease-out) 2; }
@keyframes dock-bounce { 40% { transform: translateY(-22px); } }
.dock-item::after { content: ""; position: absolute; bottom: -6px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--fg); opacity: 0; transition: opacity var(--d-2); }
.dock-item[data-running]::after { opacity: 0.7; }
.dock-tip {
  position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translate(-50%, 4px); padding: 4px 10px; border-radius: var(--r-sm);
  font-size: var(--text-xs); font-weight: 500; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--d-1), transform var(--d-2) var(--ease-out);
}
.dock-item:hover .dock-tip { opacity: 1; transform: translate(-50%, 0); }
.dock-sep { width: 1px; align-self: stretch; margin: 6px 3px; background: var(--separator); }

/* ---------- Windows ---------- */
.win { pointer-events: auto;
  position: absolute; display: flex; flex-direction: column; min-width: 320px; min-height: 220px;
  border-radius: var(--win-radius); color: var(--fg);
  background: var(--win-bg); -webkit-backdrop-filter: var(--win-blur); backdrop-filter: var(--win-blur);
  box-shadow: inset 0 1px 0.5px var(--glass-rim), var(--win-shadow-idle);
  border: 0.5px solid var(--win-border);
  transition: box-shadow var(--d-2);
}
.win[data-focused] { box-shadow: inset 0 1px 0.5px var(--glass-rim), var(--win-shadow); }
.win[data-max] { border-radius: 0; --win-radius: 0px; }
.win[data-anim] { transition: left var(--d-3) var(--ease-out), top var(--d-3) var(--ease-out), width var(--d-3) var(--ease-out), height var(--d-3) var(--ease-out), border-radius var(--d-3); }
.win__bar {
  flex: none; height: 52px; display: flex; align-items: center; gap: var(--s3); padding: 0 14px 0 18px; position: relative;
  touch-action: none;
}
.win__title { position: absolute; left: 50%; transform: translateX(-50%); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; pointer-events: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; }
.win__tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.win__body { flex: 1; min-height: 0; overflow: auto; position: relative; background: var(--win-content); border-top: 0.5px solid var(--separator); user-select: text; -webkit-user-select: text; border-radius: 0 0 var(--win-radius) var(--win-radius); }
/* The window itself doesn't clip (so resize handles can reach the corners); bar and body carry the rounding */
.win__bar { border-radius: var(--win-radius) var(--win-radius) 0 0; }
.win__body--flush { border-top: 0; }
/* Resize handles on every edge (6px) and corner (16px) */
.win__rz { position: absolute; z-index: 3; touch-action: none; }
.win__rz[data-rz="n"] { top: -4px; left: 18px; right: 18px; height: 8px; cursor: ns-resize; }
.win__rz[data-rz="s"] { bottom: -4px; left: 18px; right: 18px; height: 9px; cursor: ns-resize; }
.win__rz[data-rz="e"] { right: -4px; top: 18px; bottom: 18px; width: 9px; cursor: ew-resize; }
.win__rz[data-rz="w"] { left: -4px; top: 18px; bottom: 18px; width: 9px; cursor: ew-resize; }
.win__rz[data-rz="ne"] { top: -4px; right: -4px; width: 22px; height: 22px; cursor: nesw-resize; }
.win__rz[data-rz="sw"] { bottom: -4px; left: -4px; width: 22px; height: 22px; cursor: nesw-resize; }
.win__rz[data-rz="nw"] { top: -4px; left: -4px; width: 22px; height: 22px; cursor: nwse-resize; }
.win__rz[data-rz="se"] { bottom: -4px; right: -4px; width: 22px; height: 22px; cursor: nwse-resize; }
.win[data-max] .win__rz { display: none; }
.win[data-resizing] { user-select: none; }

/* Traffic lights */
.lights { display: flex; gap: 8px; }
.lights button { width: 13px; height: 13px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.18); transition: transform var(--d-1); }
.lights button:nth-child(1) { background: var(--p-red); }
.lights button:nth-child(2) { background: var(--p-yellow); }
.lights button:nth-child(3) { background: var(--p-lime); }
.lights svg { width: 7px; height: 7px; opacity: 0; color: rgb(0 0 0 / 0.6); transition: opacity var(--d-1); }
.lights:hover svg { opacity: 1; }
.lights button:active { transform: scale(0.88); }
.win:not([data-focused]) .lights button { background: var(--press); box-shadow: none; }
.win:not([data-focused]) .lights:hover button:nth-child(1) { background: var(--p-red); }
.win:not([data-focused]) .lights:hover button:nth-child(2) { background: var(--p-yellow); }
.win:not([data-focused]) .lights:hover button:nth-child(3) { background: var(--p-lime); }
[data-material="flat"] .lights button { width: 12px; height: 12px; box-shadow: none; }

/* ---------- Controls ---------- */
.btn {
  height: 32px; padding: 0 14px; border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 600; white-space: nowrap; position: relative; overflow: hidden;
  background: var(--control); border: 0.5px solid var(--control-border); color: var(--fg); cursor: pointer;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25);
  transition: background var(--d-1), transform var(--d-2) var(--ease-spring), box-shadow var(--d-2);
}
.btn:hover { background: var(--control-hover); }
.btn:active { transform: scale(0.95); transition-duration: 60ms; }
.btn--primary { background: var(--accent); color: var(--on-accent); border-color: transparent; box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.3), 0 4px 14px -4px rgb(var(--accent-rgb) / 0.6); }
.btn--primary:hover { background: color-mix(in oklab, var(--accent) 88%, #fff); }
.btn--icon { width: 32px; padding: 0; }
.btn svg { width: 15px; height: 15px; transition: transform var(--d-2) var(--ease-spring); }
.btn:hover .arrow { transform: translateX(3px); }
.btn--lg { height: 40px; padding: 0 20px; font-size: var(--text-md); }
[data-material="flat"] .btn { box-shadow: none; }
[data-material="flat"] .btn--primary { background: var(--fg); color: var(--win-bg); box-shadow: none; }
[data-material="flat"] .btn--primary:hover { background: color-mix(in oklab, var(--fg) 85%, var(--win-bg)); }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: 0.2; pointer-events: none; transform: scale(0); animation: ripple 600ms var(--ease-out) forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

.seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--field); gap: 2px; position: relative; }
.seg button { height: 26px; padding: 0 12px; border-radius: var(--r-pill); font-size: var(--text-xs); font-weight: 600; color: var(--fg-2); position: relative; z-index: 1; cursor: pointer; transition: color var(--d-1); }
.seg button[aria-pressed="true"] { color: var(--fg); }
.seg__thumb { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: var(--r-pill); background: var(--win-bg); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15), inset 0 1px 0 rgb(255 255 255 / 0.4); transition: transform var(--d-3) var(--spring), width var(--d-3) var(--spring); }
[data-mode="dark"] .seg__thumb { background: rgb(255 255 255 / 0.16); }

.switch { position: relative; width: 42px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; z-index: 1; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--press); transition: background var(--d-2); }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgb(0 0 0 / 0.25); transition: transform var(--d-3) var(--spring), width var(--d-2) var(--ease); }
.switch input:checked + span { background: var(--p-green); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:active + span::after { width: 28px; }
.switch input:checked:active + span::after { transform: translateX(10px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--text-xs); font-weight: 600; background: var(--field); color: var(--fg-2); white-space: nowrap; }
.chip--accent { background: rgb(var(--accent-rgb) / 0.14); color: var(--accent); }
.chip--mono { font-family: var(--font-mono); font-weight: 500; }
.field { height: 32px; border-radius: var(--r-pill); background: var(--field); border: 0; outline: 0; padding: 0 12px; min-width: 0; font-size: var(--text-sm); transition: box-shadow var(--d-2); }
.field:focus { box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.35); }
.swatch-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.2); cursor: pointer; position: relative; transition: transform var(--d-2) var(--ease-spring); }
.swatch-dot:hover { transform: scale(1.12); }
.swatch-dot[aria-pressed="true"]::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); animation: pop var(--d-3) var(--ease-spring); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

/* ---------- Overlays: launchpad, spotlight, control center, toast ---------- */
.scrim { position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--d-2); }
.scrim[data-open] { opacity: 1; pointer-events: auto; }

.launchpad {
  position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; padding: 60px 24px 120px;
  background: rgb(0 0 0 / 0.12); -webkit-backdrop-filter: blur(40px) saturate(115%); backdrop-filter: blur(40px) saturate(115%);
  opacity: 0; pointer-events: none; transition: opacity var(--d-3) var(--ease);
}
[data-material="flat"] .launchpad { background: color-mix(in oklab, var(--desktop) 92%, transparent); }
.launchpad[data-open] { opacity: 1; pointer-events: auto; }
.launchpad__inner { width: min(760px, 100%); display: grid; gap: var(--s6); justify-items: center; transform: scale(1.08); transition: transform var(--d-4) var(--ease-out); }
.launchpad[data-open] .launchpad__inner { transform: none; }
/* Launchpad search: a solid window-like surface with a hairline, glyph and accent focus */
.lp-search {
  --lp-fill: rgb(250 250 252 / 0.94); --lp-stroke: rgb(0 0 0 / 0.1); --lp-stroke-hover: rgb(0 0 0 / 0.18);
  display: flex; align-items: center; gap: 8px; width: min(320px, 100%); height: 40px; padding: 0 14px;
  border-radius: var(--r-pill); background: var(--lp-fill); border: 1px solid var(--lp-stroke); color: var(--fg);
  -webkit-backdrop-filter: var(--win-blur); backdrop-filter: var(--win-blur); box-shadow: var(--win-shadow-idle);
  cursor: text; transition: border-color var(--d-2), box-shadow var(--d-2);
}
[data-mode="dark"] .lp-search { --lp-fill: rgb(34 34 38 / 0.94); --lp-stroke: rgb(255 255 255 / 0.12); --lp-stroke-hover: rgb(255 255 255 / 0.22); }
[data-material="flat"] .lp-search { --lp-fill: var(--win-bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
.lp-search:hover { border-color: var(--lp-stroke-hover); }
.lp-search:focus-within { border-color: var(--accent); box-shadow: var(--win-shadow-idle), 0 0 0 3px rgb(var(--accent-rgb) / 0.28); }
.lp-search svg { width: 16px; height: 16px; flex: none; color: var(--fg-2); }
.lp-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: inherit; font: inherit; font-size: var(--text-sm); -webkit-appearance: none; appearance: none; }
.lp-search input::placeholder { color: var(--fg-2); opacity: 1; }
.lp-search input:focus-visible { outline: 0; }
.lp-search input::-webkit-search-cancel-button { cursor: pointer; }
.lp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--s5) var(--s4); width: 100%; }
.lp-app { display: grid; justify-items: center; gap: 8px; font-size: var(--text-sm); font-weight: 500; color: var(--desktop-fg); text-shadow: 0 1px 3px rgb(0 0 0 / 0.3); cursor: pointer; }
[data-material="flat"] .lp-app { text-shadow: none; color: var(--fg); }
.lp-app .appicon { --size: 72px; transition: transform var(--d-3) var(--ease-spring); }
.lp-app:hover .appicon { transform: scale(1.08) translateY(-2px); }
.launchpad[data-open] .lp-app { animation: lp-in var(--d-4) var(--ease-out) backwards; animation-delay: calc(var(--i) * 25ms); }
@keyframes lp-in { from { opacity: 0; transform: scale(0.8); } }

.spotlight {
  position: fixed; top: 16vh; left: 50%; width: min(640px, calc(100vw - 32px)); z-index: var(--z-popover); border-radius: var(--r-2xl); overflow: hidden;
  transform: translateX(-50%) scale(0.95); opacity: 0; pointer-events: none; transition: opacity var(--d-1), transform var(--d-3) var(--ease-spring);
}
.spotlight[data-open] { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.spotlight__field { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.spotlight__field svg { width: 22px; height: 22px; color: var(--fg-2); flex: none; }
.spotlight__field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 22px; font-weight: 400; }
.spotlight__list { max-height: 52vh; overflow: auto; padding: 6px; border-top: 0.5px solid var(--separator); }
.spotlight__list:empty { display: none; }
.sp-group { padding: 8px 12px 4px; font-size: var(--text-2xs); font-weight: 700; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; }
.sp-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: var(--r-md); text-align: left; font-size: var(--text-md); }
.sp-item .appicon { --size: 30px; }
.sp-item img.thumb { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.sp-item small { margin-left: auto; color: var(--fg-3); font-size: var(--text-xs); }
.sp-item[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.sp-item[aria-selected="true"] small { color: inherit; opacity: 0.8; }

.cc {
  position: fixed; top: calc(var(--menubar-h) + 6px); right: 8px; width: min(330px, calc(100vw - 16px)); z-index: var(--z-popover); padding: 12px; border-radius: var(--r-2xl);
  display: grid; gap: 10px; transform-origin: top right; opacity: 0; transform: scale(0.92); pointer-events: none;
  transition: opacity var(--d-1), transform var(--d-3) var(--ease-spring);
}
.cc[data-open] { opacity: 1; transform: none; pointer-events: auto; }
.cc-tile { padding: 12px; border-radius: var(--r-xl); background: var(--hover); display: grid; gap: 10px; }
.cc-tile h4 { margin: 0; font-size: var(--text-xs); font-weight: 700; }
.cc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--text-sm); }
.cc-mats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cc-mat { padding: 10px; border-radius: var(--r-lg); display: grid; gap: 8px; text-align: left; font-size: var(--text-xs); font-weight: 600; cursor: pointer; background: var(--hover); border: 1.5px solid transparent; transition: border-color var(--d-2), transform var(--d-2) var(--ease-spring); }
.cc-mat:active { transform: scale(0.96); }
.cc-mat[aria-pressed="true"] { border-color: var(--accent); }
.cc-mat i { height: 46px; border-radius: 10px; display: block; }
.cc-mat--glass i { background: #dcecff; box-shadow: inset 0 1px 0 #fff; }
.cc-mat--flat i { background: #f3f2ef; border: 1px solid #e6e5e1; }

.toast {
  position: fixed; top: calc(var(--menubar-h) + 10px); right: 10px; z-index: var(--z-toast); width: min(340px, calc(100vw - 20px)); padding: 12px 14px; border-radius: var(--r-xl);
  display: flex; gap: 12px; align-items: center; font-size: var(--text-sm); animation: toast-in var(--d-4) var(--spring);
}
.toast .appicon { --size: 36px; }
.toast strong { display: block; }
.toast span { color: var(--fg-2); }
.toast[data-leaving] { animation: toast-out var(--d-3) var(--ease-in) forwards; }
@keyframes toast-in { from { transform: translateX(calc(100% + 20px)); } }
@keyframes toast-out { to { transform: translateX(calc(100% + 20px)); opacity: 0; } }

/* ---------- Mobile: home-screen + full-screen sheets ---------- */
@media (max-width: 760px) {
  .desk-icons { display: none; }
  .widgets { position: static; width: auto; margin: 14px; }
  .desktop { overflow: auto; padding-bottom: 110px; }
  .m-grid { display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 18px 8px; padding: 6px 14px; }
  .win { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; position: fixed; inset: var(--menubar-h) 0 0 !important; height: auto !important; }
  .win__rz { display: none; }
  .win__body { padding-bottom: 84px; }
  .dock { --dock-icon: 50px; --dock-pad: 6px; gap: 4px; }
  .dock-item { --size: 50px !important; }
  .dock-item--desk, .dock-sep { display: none; }
  .dock-tip { display: none; }
}
.m-grid { display: none; }
.m-app { display: grid; justify-items: center; gap: 6px; font-size: var(--text-2xs); font-weight: 600; color: var(--desktop-fg); text-shadow: 0 1px 3px rgb(0 0 0 / 0.3); }
[data-material="flat"] .m-app { text-shadow: none; }
.m-app .appicon { --size: 60px; }

/* While locked, only the wallpaper shows; the shell fades/slides in on unlock */
.menubar, .desktop, .dock-wrap, #windows { transition: opacity var(--d-4) var(--ease), transform var(--d-5) var(--ease-out); }
[data-locked] .menubar { opacity: 0; transform: translateY(-100%); }
[data-locked] .desktop, [data-locked] #windows { opacity: 0; transform: scale(1.03); }
[data-locked] .dock-wrap { opacity: 0; transform: translateY(120%); }
[data-locked] .wallpaper { filter: blur(0); }
.lock { background: rgb(0 0 0 / 0.06); }

/* ---------- Valley wallpaper: sunset ⇄ sunrise ----------
   --n runs 0 (day) → 1 (night) over ~3.2s. Going dark, the sun sinks behind
   the horizon while the sky warms to gold/pink, then night spreads down from
   the top of the sky. Going light plays it backwards: the sun rises.
   --peak is 0 at day and night and 1 at golden hour (mid-transition). */
@property --n { syntax: "<number>"; inherits: true; initial-value: 0; }
.wallpaper {
  --n: 0;
  --peak: calc(1 - max(var(--n) * 2 - 1, 1 - var(--n) * 2));
  transition: background var(--d-5) var(--ease), --n calc(var(--d-5) * 4.6) cubic-bezier(0.4, 0, 0.25, 1);
}
[data-mode="dark"] .wallpaper { --n: 1; }
.wp-img, .wp-tint, .wp-sunbox, .wp-glow { position: absolute; inset: 0; display: none; pointer-events: none; }
.wp-img { background: center / cover no-repeat; }

/* Day: the Valley photo dims and warms as the sun goes down */
.wp-day {
  background-image: url("../assets/img/wallpaper-day.jpg");
  filter: brightness(calc(1 - var(--n) * 0.5)) sepia(calc(var(--peak) * 0.35)) saturate(calc(1 + var(--peak) * 0.35));
}
/* Golden hour: a flat warm tint over the photo, strongest mid-transition */
.wp-tint {
  opacity: var(--peak);
  background: rgb(255 150 90 / 0.55);
  mix-blend-mode: overlay;
}
/* Sun: sinks from the upper sky to behind the horizon, getting larger and redder */
.wp-sunbox { clip-path: inset(0 0 40%); }
.wp-sun {
  position: absolute; left: 76%; top: calc(22% + var(--n) * 46%);
  width: calc(8vmin + var(--peak) * 3vmin); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  opacity: clamp(0, calc((0.92 - var(--n)) * 3), 1);
  background: color-mix(in oklab, #fff3cc, #ff8a4c calc(var(--n) * 100%));
}
/* Night: the Valley night photo fades in as the light leaves */
.wp-night {
  background-image: url("../assets/img/wallpaper-night.jpg");
  opacity: clamp(0, calc(var(--n) * 1.5 - 0.2), 1);
}
.wp-glow { display: none; }
[data-wallpaper="valley"] :is(.wp-img, .wp-tint, .wp-sunbox) { display: block; }
[data-wallpaper="valley"] .wallpaper i, [data-wallpaper="valley"] .wallpaper::after { display: none; }
[data-wallpaper="valley"] .wallpaper { background: #0f1a3a; }
[data-material="flat"] :is(.wp-img, .wp-tint, .wp-sunbox, .wp-glow) { display: none !important; }

/* While the sky changes, let the whole UI fade between light and dark with it */
@media (prefers-reduced-motion: no-preference) {
  html[data-sky]:not([data-motion="reduced"]) :not(.wallpaper, .wallpaper *, .intent-demo, .intent-demo *),
  html[data-sky]:not([data-motion="reduced"]) :not(.wallpaper, .intent-demo, .intent-demo *)::before,
  html[data-sky]:not([data-motion="reduced"]) :not(.wallpaper, .intent-demo, .intent-demo *)::after {
    transition: background-color 2.2s var(--ease) 0.4s, color 2.2s var(--ease) 0.4s, border-color 2.2s var(--ease) 0.4s, box-shadow 2.2s var(--ease) 0.4s, fill 2.2s var(--ease) 0.4s !important;
  }
}

/* ---------- Free-form desktop (drag & drop) ---------- */
.desk-free .widgets, .desk-free .desk-icons { position: absolute; inset: 0; width: auto; display: block; pointer-events: none; }
.desk-free [data-drag] { position: absolute; margin: 0; pointer-events: auto; }
[data-drag] { touch-action: none; transition: scale var(--d-2) var(--ease-spring), filter var(--d-2); }
[data-drag][data-dragging] { outline: none; scale: 1.04; cursor: grabbing; filter: drop-shadow(0 18px 30px rgb(0 0 0 / 0.25)); }
.desk-icon[data-dragging] { opacity: 0.85; }
[data-drag][data-settle] { transition: left 380ms cubic-bezier(0.3, 1.3, 0.5, 1), top 380ms cubic-bezier(0.3, 1.3, 0.5, 1), scale var(--d-2) var(--ease-spring); }

/* ---------- Bento grid: tile sizing ---------- */
.desk-free .desk-icon { display: grid; align-content: center; padding: 6px 4px; }
.desk-free .widget { overflow: hidden; }
.desk-free .widget--intro { display: flex; flex-direction: column; justify-content: center; padding: 22px 24px; }
.desk-free .widget--intro h1 { font-size: 31px; margin: 10px 0 8px; }
[data-material="flat"] .desk-free .widget--intro h1 { font-size: 40px; }
.desk-free .widget--intro p { font-size: 13.5px; line-height: 1.5; margin-bottom: 26px; }
.desk-free .widget--now { padding: 12px; }
.desk-free .widget__thumb { height: 100%; aspect-ratio: 16 / 10; width: auto; }

/* ---------- Liquid widget shells (see Goo in os.js) ----------
   On the bento desktop the widget's own background, border and shadow move
   into .shells so the shell itself can melt into neighbours while dragging. */
.shells { position: absolute; inset: 0; z-index: 0; pointer-events: none; display: none; }
.desk-free .shells { display: block; }
.shells i { position: absolute; display: none; background: var(--shell); border: 0.5px solid var(--glass-edge); box-shadow: inset 0 1px 0.5px var(--glass-rim), var(--chrome-shadow); }
body[data-goo] .shells { filter: url(#goo) drop-shadow(0 12px 26px rgb(0 0 0 / 0.16)); }
body[data-goo] .shells i { background: var(--shell-solid); border-color: transparent; box-shadow: none; }
.desk-free .widget.glass { background: transparent; box-shadow: none; border-color: transparent; }
/* --shell / --shell-solid / --shell-alpha live in tokens.css (tinted by the accent) */

/* Flat always uses a solid paper desktop. */
[data-material="flat"][data-wallpaper] .wallpaper { background: var(--desktop); }

/* Pointer clicks on draggable widgets shouldn't leave a focus ring; keyboard focus still shows one */
[data-drag]:focus:not(:focus-visible) { outline: none; }

/* ---------- Dock auto-hide while reading a full-screen window ---------- */
.dock-zone { position: fixed; left: 0; right: 0; bottom: 0; height: 10px; z-index: calc(var(--z-dock) - 1); display: none; }
body[data-dock-auto] .dock-zone { display: block; }
body[data-dock-auto]:not([data-dock-peek]) .dock-wrap { transform: translateY(calc(100% + 14px)); }

/* ---------- View switch: the single way between Piper OS and Simple ---------- */
.viewswitch {
  position: fixed; left: 16px; bottom: 16px; z-index: calc(var(--z-lock) + 1); width: max-content;
  display: flex; padding: 4px; border-radius: var(--r-pill); font-size: var(--text-sm); color: var(--fg);
  animation: rise var(--d-5) var(--ease-out) 300ms backwards;
}
.viewswitch button { position: relative; z-index: 1; white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--r-pill); font-weight: 500; color: var(--fg-2); cursor: pointer; transition: color var(--d-2); }
.viewswitch button svg { width: 15px; height: 15px; }
.viewswitch button[aria-checked="true"] { color: var(--on-accent); }
.viewswitch button:not([aria-checked="true"]):hover { color: var(--fg); }
.viewswitch__thumb { position: absolute; top: 4px; bottom: 4px; left: 0; border-radius: var(--r-pill); background: var(--accent); box-shadow: 0 4px 12px -4px rgb(var(--accent-rgb) / 0.5); transition: transform var(--d-4) var(--spring), width var(--d-4) var(--spring); }
/* Simple view: plain, quiet surface instead of glass */
html[data-view="simple"] .viewswitch { background: var(--s-soft); border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; color: var(--s-fg); }
html[data-view="simple"] .viewswitch::before { display: none; }
html[data-view="simple"] .viewswitch button:not([aria-checked="true"]) { color: var(--s-muted); }
/* Simple: a compact icon pill in the header's top-left corner, balancing the theme button on the right */
html[data-view="simple"] .viewswitch { top: 16px; bottom: auto; left: 20px; padding: 5px; box-shadow: none; animation: none; }
html[data-view="simple"] .viewswitch button { width: 38px; height: 36px; padding: 0; justify-content: center; }
html[data-view="simple"] .viewswitch button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html[data-view="simple"] .viewswitch button svg { width: 18px; height: 18px; }
html[data-view="simple"] .viewswitch button[aria-checked="true"] { color: var(--on-accent); }
html[data-view="simple"] .viewswitch__thumb { top: 5px; bottom: 5px; background: var(--accent); box-shadow: none; }
html[data-view="simple"][data-reading] .viewswitch { display: none; }
/* Phones: sit above the dock in the OS */
@media (max-width: 760px) {
  .viewswitch { bottom: 84px; }
}
@media (max-width: 640px) {
  html[data-view="simple"] .viewswitch { top: 12px; left: 12px; }
  html[data-view="simple"] .viewswitch button { width: 34px; }
}
.widget__tagline { display: inline-block; text-wrap: balance; }

/* Sound toggle shared by the Simple hero and the Playground */
.sound-toggle { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--s-muted, var(--fg-2)); cursor: pointer; transition: color var(--d-2), background-color var(--d-2); }
.sound-toggle:hover { color: var(--s-fg, var(--fg)); background: color-mix(in srgb, currentColor 10%, transparent); }
.sound-toggle[aria-pressed="false"] { opacity: 0.7; }
.sound-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
