/* ==========================================================================
   WINDOW MANAGER — waybar, workspaces, dock, windows, launcher, overlays
   ========================================================================== */

#desktop {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
}

/* ------------------------------------------------------------- WAYBAR */
#bar {
  position: fixed;
  top: 8px; left: 8px; right: 8px;
  height: var(--bar-h);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 0 12px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.82rem;
}
.bar-cluster { display: flex; align-items: center; gap: 10px; }
.bar-mod {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px;
  border-radius: 7px;
  color: var(--dust);
  transition: background 0.15s ease, color 0.15s ease;
}
.bar-mod:hover { background: rgba(232, 228, 220, 0.06); color: var(--bone); }
.bar-mod i { font-size: 0.85rem; }
.bar-mod.clickable { cursor: none; }

.arch-glyph { width: 18px; height: 18px; fill: var(--ember); filter: drop-shadow(0 0 5px var(--ember-glow)); }

/* workspace pills */
#workspaces { display: flex; align-items: center; gap: 5px; }
.ws-pill {
  width: 24px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--faint);
  font-size: 0.72rem;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}
.ws-pill:hover { color: var(--bone); background: rgba(232, 228, 220, 0.05); }
.ws-pill.occupied { color: var(--dust); }
.ws-pill.occupied::after {
  content: ""; position: absolute; margin-top: 16px;
  width: 3px; height: 3px; border-radius: 50%; background: var(--dust);
}
.ws-pill.active {
  color: var(--void); background: var(--ember);
  box-shadow: 0 0 12px var(--ember-glow);
}

#clock { font-weight: 700; color: var(--bone); letter-spacing: 0.03em; }
#clock small { color: var(--dust); font-weight: 400; margin-left: 6px; }

/* tray */
#vpn-tray i { color: var(--ember); }
#vol-mod input[type="range"] { width: 78px; }

/* range inputs (global, used in bar + music apps) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: rgba(232, 228, 220, 0.14);
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember-glow);
  transition: transform 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.35); }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: none; border-radius: 50%;
  background: var(--ember);
}

/* --------------------------------------------------------------- WINDOWS */
#windows-root { position: absolute; inset: 0; z-index: 100; }

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 280px; min-height: 160px;
  background: var(--glass-solid);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.94) translateY(8px);
  pointer-events: none;
  will-change: transform, opacity;
}
.window.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  transition: opacity 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              filter 0.2s ease;
}
.window.closing {
  opacity: 0;
  transform: scale(0.9) translateY(6px);
  filter: blur(4px);
  transition: opacity 0.18s ease, transform 0.18s ease, filter 0.18s ease;
}
.window.minimizing {
  opacity: 0;
  transform: scale(0.2) translateY(60vh);
  filter: blur(6px);
  transition: opacity 0.3s ease, transform 0.32s cubic-bezier(0.4, 0, 1, 1), filter 0.3s ease;
}
.window.active { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember-dim), 0 30px 70px rgba(0, 0, 0, 0.85); }
.window.active .win-title { color: var(--bone); }
.window.maximized {
  top: calc(var(--bar-h) + 16px) !important;
  left: 8px !important;
  width: calc(100vw - 16px) !important;
  height: calc(100vh - var(--bar-h) - var(--dock-h) - 24px) !important;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.win-header {
  flex-shrink: 0;
  height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(232, 228, 220, 0.03);
  border-bottom: 1px solid var(--line);
  cursor: grab;
  user-select: none;
}
.win-header:active { cursor: grabbing; }
.win-title { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--dust); }
.win-title i, .win-title .app-glyph { color: var(--ember); font-size: 0.85rem; }
.win-controls { display: flex; gap: 8px; }
.win-btn {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(232, 228, 220, 0.18);
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.win-btn:hover { transform: scale(1.18); }
.win-btn.min:hover { background: var(--dust); }
.win-btn.max:hover { background: var(--bone); }
.win-btn.close:hover { background: var(--ember); box-shadow: 0 0 10px var(--ember-glow); }

.win-content {
  flex: 1;
  overflow: auto;
  position: relative;
}
.win-pad { padding: 18px; }

/* resize handle */
.win-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  z-index: 5;
}
.win-resize::after {
  content: ""; position: absolute; right: 3px; bottom: 3px;
  width: 7px; height: 7px;
  border-right: 2px solid var(--faint);
  border-bottom: 2px solid var(--faint);
}

/* --------------------------------------------------------------- DOCK */
#dock {
  position: fixed;
  bottom: 8px; left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 2500;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  height: var(--dock-h);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}
#dock::-webkit-scrollbar { display: none; }
.dock-icon {
  position: relative;
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: rgba(232, 228, 220, 0.04);
  border: 1px solid var(--line);
  color: var(--dust);
  font-size: 1.15rem;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.dock-icon img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; }
.dock-icon:hover {
  transform: translateY(-10px) scale(1.15);
  background: var(--ember-dim);
  color: var(--ember-bright);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
.dock-icon.running::after {
  content: "";
  position: absolute;
  bottom: -5px; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember-glow);
}
.dock-tip {
  position: absolute;
  bottom: 56px; left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  background: var(--glass-solid);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--bone);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
}
.dock-icon:hover .dock-tip { opacity: 1; }
.dock-sep { width: 1px; height: 34px; background: var(--line-strong); margin: 0 4px; align-self: center; }

/* --------------------------------------------------------- APP LAUNCHER */
#launcher {
  position: fixed; inset: 0;
  z-index: 4000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(4, 4, 6, 0.55);
  backdrop-filter: blur(6px);
}
#launcher.open { display: flex; animation: fade-in 0.18s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.launcher-box {
  width: min(560px, 92vw);
  background: var(--glass-solid);
  border: 1px solid var(--ember-dim);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(217, 118, 43, 0.15);
  overflow: hidden;
  animation: launcher-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes launcher-pop { from { transform: translateY(-12px) scale(0.98); opacity: 0; } }
.launcher-search {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.launcher-search i { color: var(--ember); }
#launcher-input {
  flex: 1;
  background: transparent; border: none; color: var(--bone);
  font-family: var(--font-mono); font-size: 0.95rem;
}
.launcher-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.launcher-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--dust);
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.launcher-item .li-icon {
  width: 30px; text-align: center; color: var(--bone); font-size: 1rem;
}
.launcher-item .li-icon img { width: 20px; height: 20px; border-radius: 5px; vertical-align: middle; }
.launcher-item .li-name { color: var(--bone); font-weight: 600; }
.launcher-item .li-desc { font-size: 0.74rem; color: var(--faint); margin-left: auto; }
.launcher-item.sel, .launcher-item:hover {
  background: var(--ember-dim);
  color: var(--ember-bright);
  transform: translateX(3px);
}
.launcher-item.sel .li-name { color: var(--ember-bright); }
.launcher-hint { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 0.72rem; color: var(--faint); text-align: center; }
kbd {
  font-family: var(--font-mono);
  background: var(--ash);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.72rem;
  color: var(--bone);
}

/* --------------------------------------------------- KEYBIND OVERLAY */
#keybinds {
  position: fixed; inset: 0; z-index: 4200;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(4, 4, 6, 0.7);
  backdrop-filter: blur(8px);
}
#keybinds.open { display: flex; animation: fade-in 0.18s ease; }
.kb-box {
  width: min(620px, 92vw);
  background: var(--glass-solid);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 26px 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
}
.kb-box h3 { color: var(--ember); margin-bottom: 18px; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.9rem; }
.kb-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.kb-row:last-child { border-bottom: none; }
.kb-keys { display: flex; gap: 6px; }
.kb-action { color: var(--dust); font-size: 0.86rem; }

/* snap preview */
#snap-preview {
  position: fixed;
  z-index: 1500;
  border: 2px solid var(--ember);
  background: var(--ember-dim);
  border-radius: 12px;
  box-shadow: 0 0 30px var(--ember-glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, left 0.12s ease, top 0.12s ease, width 0.12s ease, height 0.12s ease;
}

/* toast */
#toast-wrap { position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%); z-index: 5000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--glass-solid);
  border: 1px solid var(--ember-dim);
  border-left: 3px solid var(--ember);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--bone);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.25s ease, toast-out 0.3s ease 2.6s forwards;
}
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(14px); opacity: 0; } }

/* ------------------------------------------------------- LOCK SCREEN */
#lockscreen {
  position: fixed; inset: 0; z-index: 60000;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(5, 5, 7, 0.55);
  backdrop-filter: blur(22px) saturate(0.8);
  -webkit-backdrop-filter: blur(22px) saturate(0.8);
}
#lockscreen.open { display: flex; animation: fade-in 0.25s ease; }
.lock-inner { text-align: center; }
.lock-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid var(--ember);
  box-shadow: 0 0 40px var(--ember-glow);
  object-fit: cover;
}
.lock-name {
  font-family: var(--font-display);
  font-size: 1.6rem; letter-spacing: 0.12em;
  margin-top: 18px; color: var(--bone);
  text-shadow: 0 0 24px var(--ember-glow);
}
.lock-handle { color: var(--dust); font-size: 0.82rem; margin-top: 2px; }
.lock-clock {
  font-size: clamp(3rem, 9vw, 4.6rem);
  font-weight: 700; letter-spacing: 0.04em;
  color: var(--bone); margin-top: 22px;
  text-shadow: 0 0 30px var(--ember-glow);
  font-variant-numeric: tabular-nums;
}
.lock-date { color: var(--dust); font-size: 0.86rem; margin-top: 4px; }
.lock-hint { color: var(--faint); font-size: 0.76rem; margin-top: 30px; animation: blink 2s steps(1) infinite; }

/* -------------------------------------------------------- SCREENSAVER */
#screensaver {
  position: fixed; inset: 0; z-index: 58000;
  pointer-events: none;
  animation: fade-in 1.4s ease;
}

/* --------------------------------------------- WAYBAR STATS + MEDIA */
#stats-mod { gap: 6px; font-variant-numeric: tabular-nums; }
#stats-mod i { font-size: 0.72rem; color: var(--faint); }
#stats-mod b { color: var(--bone); font-weight: 700; font-size: 0.74rem; min-width: 32px; }
#media-tray { max-width: 220px; overflow: hidden; }
#media-tray[hidden] { display: none !important; }
#media-tray #media-title {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.76rem; color: var(--bone); min-width: 0;
}
#media-tray #media-ic { color: var(--ember); font-size: 0.72rem; flex-shrink: 0; }
@media (max-width: 1180px) { #stats-mod { display: none; } }

/* --------------------------------------------------- MUSIC VISUALIZER */
.np-viz { width: 110px; height: 34px; flex-shrink: 0; opacity: 0.9; }
@media (max-width: 900px) { .np-viz { display: none; } }

/* ------------------------------------------------------ FOCUS STATES */
:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
  border-radius: 4px;
}
