/* ============ desktop ============ */
#desktop {
  position: fixed; inset: 0;
  background-size: cover; background-position: center;
  transition: background-image .4s;
}
#desktop::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
#windows-layer { position: absolute; inset: 0; z-index: 100; }

/* ============ windows ============ */
.window {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-window);
  min-width: 260px; min-height: 140px;
  transition: border-radius var(--dur-fast);
  overflow: hidden;
}
.window.focused { box-shadow: var(--shadow-window-focused); }
.window.maximized { border-radius: 0; }
.window.tiled { border-radius: 0; }
.window.opening { animation: win-open var(--dur-med) var(--ease-decel); }
@keyframes win-open {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}
.window.closing { animation: win-close var(--dur-fast) var(--ease-accel) forwards; pointer-events: none; }
@keyframes win-close {
  to { opacity: 0; transform: scale(.92); }
}
.window.minimizing { animation: win-min var(--dur-med) var(--ease-accel) forwards; pointer-events: none; }
@keyframes win-min {
  to { opacity: 0; transform: scale(.4) translateY(60%); }
}
.window.unminimizing { animation: win-unmin var(--dur-med) var(--ease-decel); }
@keyframes win-unmin {
  from { opacity: 0; transform: scale(.4) translateY(60%); }
  to { opacity: 1; transform: none; }
}
.window.snap-anim { transition: left var(--dur-med) var(--ease-standard), top var(--dur-med) var(--ease-standard),
  width var(--dur-med) var(--ease-standard), height var(--dur-med) var(--ease-standard),
  border-radius var(--dur-fast); }

/* headerbar */
.win-header {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 8px;
  background: var(--headerbar);
  border-bottom: 1px solid rgba(0,0,0,.35);
  flex: none;
  transition: background var(--dur-med);
}
.window:not(.focused) .win-header { background: var(--headerbar-backdrop); }
.win-title {
  flex: 1; text-align: center; font-size: 13.5px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 4px;
  color: var(--fg);
}
.window:not(.focused) .win-title { color: var(--fg-dim); }
.win-title .win-subtitle { display: block; font-size: 11px; font-weight: 400; color: var(--fg-dim); }

.win-btns { display: flex; gap: 8px; align-items: center; }
.win-btn {
  width: 24px; height: 24px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--fg-dim); padding: 0;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.win-btn svg { width: 14px; height: 14px; }
.win-btn:hover { background: rgba(255,255,255,.12); color: var(--fg); }
:root[data-style="light"] .win-btn:hover { background: rgba(0,0,0,.08); }
.win-btn.close:hover { background: var(--accent); color: var(--accent-fg); }
.window:not(.focused) .win-btn { color: var(--fg-faint); }

/* body */
.win-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; background: var(--bg); }

/* resize handles */
.rz { position: absolute; z-index: 5; }
.rz-n { top: -3px; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.rz-s { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.rz-e { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: e-resize; }
.rz-w { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: w-resize; }
.rz-ne { top: -3px; right: -3px; width: 12px; height: 12px; cursor: ne-resize; }
.rz-nw { top: -3px; left: -3px; width: 12px; height: 12px; cursor: nw-resize; }
.rz-se { bottom: -3px; right: -3px; width: 12px; height: 12px; cursor: se-resize; }
.rz-sw { bottom: -3px; left: -3px; width: 12px; height: 12px; cursor: sw-resize; }
.window.maximized .rz, .window.tiled .rz { display: none; }

/* snap preview */
#snap-preview {
  position: fixed; z-index: 4900;
  background: var(--accent-subtle);
  border: 2px solid var(--accent);
  border-radius: 12px;
  pointer-events: none;
  animation: snap-in var(--dur-fast) var(--ease-decel);
}
@keyframes snap-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

/* ============ alt-tab ============ */
#alttab {
  position: fixed; top: 15%; left: 50%; transform: translateX(-50%);
  z-index: 8800;
  display: flex; gap: 8px; padding: 12px;
  background: var(--popover-bg); border-radius: 16px;
  box-shadow: var(--shadow-popover);
  animation: pop-in var(--dur-fast) var(--ease-decel);
}
.alttab-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 96px; padding: 10px 6px; border-radius: 10px;
}
.alttab-item img, .alttab-item svg.app-icon { width: 48px; height: 48px; }
.alttab-item .at-label { font-size: 11px; color: var(--fg-dim); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alttab-item.selected { background: var(--accent-subtle); }
.alttab-item.selected .at-label { color: var(--fg); }
