/* ============================================================
   macOS Web — system chrome (desktop, menubar, dock, windows)
   ============================================================ */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --menubar-h: 30px;
  --accent: #0a84ff;

  /* light theme */
  --bar-bg: rgba(255, 255, 255, 0.45);
  --bar-text: rgba(0, 0, 0, 0.88);
  --menu-bg: rgba(246, 246, 248, 0.78);
  --menu-text: #1d1d1f;
  --menu-sep: rgba(0, 0, 0, 0.12);
  --dock-bg: rgba(255, 255, 255, 0.32);
  --dock-border: rgba(255, 255, 255, 0.42);
  --win-bg: #f6f6f8;
  --win-titlebar: rgba(246, 246, 248, 0.92);
  --win-title-text: rgba(0, 0, 0, 0.85);
  --win-title-text-dim: rgba(0, 0, 0, 0.35);
  --win-border: rgba(0, 0, 0, 0.18);
  --win-inner-border: rgba(255, 255, 255, 0.25);
  --text: #1d1d1f;
  --text-dim: rgba(0, 0, 0, 0.5);
  --pane-bg: #ffffff;
  --sidebar-bg: rgba(238, 238, 241, 0.85);
  --hover-bg: rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] {
  --bar-bg: rgba(26, 26, 30, 0.45);
  --bar-text: rgba(255, 255, 255, 0.9);
  --menu-bg: rgba(40, 40, 44, 0.82);
  --menu-text: #f2f2f4;
  --menu-sep: rgba(255, 255, 255, 0.16);
  --dock-bg: rgba(40, 40, 46, 0.36);
  --dock-border: rgba(255, 255, 255, 0.16);
  --win-bg: #28282c;
  --win-titlebar: rgba(44, 44, 48, 0.92);
  --win-title-text: rgba(255, 255, 255, 0.88);
  --win-title-text-dim: rgba(255, 255, 255, 0.32);
  --win-border: rgba(0, 0, 0, 0.55);
  --win-inner-border: rgba(255, 255, 255, 0.12);
  --text: #f2f2f4;
  --text-dim: rgba(255, 255, 255, 0.5);
  --pane-bg: #1f1f23;
  --sidebar-bg: rgba(34, 34, 38, 0.85);
  --hover-bg: rgba(255, 255, 255, 0.08);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.hidden { display: none !important; }

/* ---------------- Desktop ---------------- */

#desktop {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: background-image 0.5s ease;
  z-index: 0;
}

/* ---------------- Menu bar ---------------- */

#menubar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--menubar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  background: var(--bar-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  color: var(--bar-text);
  font-size: 13px;
  z-index: 1000;
}

#menubar-left, #menubar-right { display: flex; align-items: center; height: 100%; }

.mb-item {
  display: flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 5px;
  cursor: default;
  white-space: nowrap;
}
.mb-item.mb-apple { padding: 0 12px; }
.mb-item.mb-appname { font-weight: 700; }
.mb-item.open { background: var(--hover-bg); }
.mb-item svg { display: block; }

.mb-status {
  display: flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
}
.mb-status.open { background: var(--hover-bg); }
.mb-clock { padding: 0 10px; font-variant-numeric: tabular-nums; }

/* dropdown menus */
.menu-dropdown {
  position: fixed;
  min-width: 220px;
  padding: 5px;
  border-radius: 10px;
  background: var(--menu-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.18), 0 10px 34px rgba(0,0,0,0.32);
  color: var(--menu-text);
  font-size: 13px;
  z-index: 2000;
  animation: menu-pop 0.12s ease;
}
@keyframes menu-pop { from { opacity: 0; transform: scale(0.98); } }

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: default;
}
.menu-item .shortcut { color: var(--text-dim); font-size: 12.5px; }
.menu-item:hover:not(.disabled) { background: var(--accent); color: #fff; }
.menu-item:hover:not(.disabled) .shortcut { color: rgba(255,255,255,0.75); }
.menu-item.disabled { color: var(--text-dim); }
.menu-sep { height: 1px; margin: 5px 10px; background: var(--menu-sep); }

/* control center panel */
#control-center {
  position: fixed;
  top: 36px; right: 8px;
  width: 320px;
  padding: 12px;
  border-radius: 16px;
  background: var(--menu-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.18), 0 14px 40px rgba(0,0,0,0.35);
  color: var(--menu-text);
  z-index: 2000;
  animation: menu-pop 0.12s ease;
}
.cc-row { margin-bottom: 12px; }
.cc-row:last-child { margin-bottom: 0; }
.cc-label { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.cc-slider-wrap {
  position: relative;
  height: 26px;
  border-radius: 13px;
  background: rgba(120,120,128,0.24);
  overflow: hidden;
}
.cc-slider-fill {
  position: absolute; inset: 0 auto 0 0;
  background: #fff;
  border-radius: 13px;
  box-shadow: 0 0 4px rgba(0,0,0,0.15);
}
.cc-slider-wrap svg { position: absolute; left: 7px; top: 50%; transform: translateY(-50%); z-index: 2; color: #8e8e93; }
.cc-toggles { display: flex; gap: 10px; }
.cc-toggle {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 4px;
  border-radius: 12px;
  background: rgba(120,120,128,0.16);
  font-size: 11px;
  cursor: default;
}
.cc-toggle .cc-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(120,120,128,0.3);
  color: #fff;
}
.cc-toggle.on .cc-dot { background: var(--accent); }

#brightness-overlay {
  position: fixed; inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 5000;
}

/* ---------------- Dock ---------------- */

#dock-wrap {
  position: fixed;
  bottom: 6px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}

#dock {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 5px 7px;
  border-radius: 22px;
  background: var(--dock-bg);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 0.5px solid var(--dock-border);
  box-shadow: 0 10px 32px rgba(0,0,0,0.3);
  pointer-events: auto;
}

.dock-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: var(--size, 52px);
  height: var(--size, 52px);
  transition: width 0.08s ease-out, height 0.08s ease-out;
}
#dock.no-anim .dock-item { transition: none; }

.dock-item svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25)); }

.dock-item .dock-dot {
  position: absolute;
  bottom: -4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--bar-text);
  opacity: 0;
}
.dock-item.running .dock-dot { opacity: 0.85; }

.dock-label {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 11px;
  border-radius: 8px;
  background: var(--menu-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.2), 0 4px 14px rgba(0,0,0,0.25);
  color: var(--menu-text);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}
.dock-item:hover .dock-label { opacity: 1; }

.dock-sep {
  width: 1px;
  align-self: stretch;
  margin: 6px 4px;
  background: var(--menu-sep);
}

@keyframes dock-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-26px); }
  60% { transform: translateY(0); }
  80% { transform: translateY(-12px); }
}
.dock-item.bouncing svg { animation: dock-bounce 0.9s ease; }

/* ---------------- Windows ---------------- */

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  min-height: 120px;
  border-radius: 12px;
  background: var(--win-bg);
  box-shadow:
    0 0 0 0.5px var(--win-border),
    inset 0 0 0 0.5px var(--win-inner-border),
    0 18px 50px rgba(0,0,0,0.25);
  overflow: hidden;
  opacity: 1;
}
.window.active {
  box-shadow:
    0 0 0 0.5px var(--win-border),
    inset 0 0 0 0.5px var(--win-inner-border),
    0 28px 70px rgba(0,0,0,0.42);
}
.window.opening { animation: win-open 0.18s ease-out; }
@keyframes win-open { from { opacity: 0; transform: scale(0.92); } }

.win-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  height: 40px;
  flex: 0 0 40px;
  padding: 0 12px;
  background: var(--win-titlebar);
  cursor: default;
}
.window.chrome-overlay .win-titlebar {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: transparent;
  z-index: 5;
}

.win-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 700;
  color: var(--win-title-text);
  white-space: nowrap;
  pointer-events: none;
}
.window:not(.active) .win-title { color: var(--win-title-text-dim); }

.traffic-lights { display: flex; gap: 8px; }
.tl {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 0.5px solid rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: default;
}
.tl svg { opacity: 0; width: 8px; height: 8px; }
.traffic-lights:hover .tl svg { opacity: 1; }
.tl-close { background: #ff5f57; }
.tl-min   { background: #febc2e; }
.tl-max   { background: #28c840; }
.window:not(.active) .tl { background: #c8c8cd; border-color: rgba(0,0,0,0.08); }
body[data-theme="dark"] .window:not(.active) .tl { background: #5a5a5e; }
.tl:active { filter: brightness(0.8); }

.win-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* resize handles */
.rz { position: absolute; z-index: 10; }
.rz-n  { top: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.rz-s  { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.rz-e  { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.rz-w  { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.rz-ne { top: -5px; right: -5px; width: 12px; height: 12px; cursor: nesw-resize; }
.rz-nw { top: -5px; left: -5px; width: 12px; height: 12px; cursor: nwse-resize; }
.rz-se { bottom: -5px; right: -5px; width: 12px; height: 12px; cursor: nwse-resize; }
.rz-sw { bottom: -5px; left: -5px; width: 12px; height: 12px; cursor: nesw-resize; }

/* ---------------- Notifications ---------------- */

#notifications {
  position: fixed;
  top: 40px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3000;
}
.notification {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 340px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--menu-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.15), 0 10px 32px rgba(0,0,0,0.3);
  color: var(--menu-text);
  animation: notif-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.notification.out { animation: notif-out 0.25s ease forwards; }
@keyframes notif-in { from { opacity: 0; transform: translateX(60px); } }
@keyframes notif-out { to { opacity: 0; transform: translateX(60px); } }
.notification .n-icon { width: 38px; height: 38px; flex: 0 0 38px; }
.notification .n-icon svg { width: 100%; height: 100%; }
.notification .n-title { font-size: 13px; font-weight: 700; }
.notification .n-body { font-size: 13px; color: var(--text-dim); }

/* ---------------- Launchpad ---------------- */

#launchpad {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(20, 20, 26, 0.45);
  backdrop-filter: blur(36px) saturate(140%);
  -webkit-backdrop-filter: blur(36px) saturate(140%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lp-in 0.2s ease;
}
@keyframes lp-in { from { opacity: 0; } }
#launchpad-grid {
  display: grid;
  grid-template-columns: repeat(4, 130px);
  gap: 40px 30px;
}
.lp-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: default;
}
.lp-app svg { width: 84px; height: 84px; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.4)); transition: transform 0.12s; }
.lp-app:hover svg { transform: scale(1.07); }
.lp-app span { color: #fff; font-size: 14px; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }

/* ---------------- Lock screen & shutdown ---------------- */

#lockscreen {
  position: fixed;
  inset: 0;
  z-index: 6000;
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  animation: lp-in 0.4s ease;
}
#lockscreen::before {
  content: "";
  position: absolute; inset: 0;
  backdrop-filter: blur(40px) brightness(0.75);
  -webkit-backdrop-filter: blur(40px) brightness(0.75);
}
.lock-date { position: relative; margin-top: 14vh; font-size: 22px; font-weight: 600; text-shadow: 0 2px 12px rgba(0,0,0,0.4); }
.lock-time { position: relative; font-size: 96px; font-weight: 800; letter-spacing: -2px; text-shadow: 0 4px 24px rgba(0,0,0,0.45); }
.lock-hint { position: relative; margin-top: auto; margin-bottom: 60px; font-size: 14px; opacity: 0.85; }
.lock-avatar {
  position: relative;
  margin-top: 8vh;
  width: 84px; height: 84px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.lock-name { position: relative; margin-top: 12px; font-size: 17px; font-weight: 600; }

#shutdown {
  position: fixed;
  inset: 0;
  z-index: 6000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#shutdown button {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 30px;
  cursor: pointer;
  transition: all 0.2s;
}
#shutdown button:hover { color: #fff; border-color: #fff; box-shadow: 0 0 30px rgba(255,255,255,0.25); }

/* ---------------- Context menu (desktop) ---------------- */

#context-menu {
  position: fixed;
  z-index: 2500;
}
