:root {
  --taskbar-h: 48px;
  --win-bg: #ececec;
  --win-header: #1c1c1e;
  --accent: #0a84ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #000;
  user-select: none;
}
[hidden] { display: none !important; }

/* Desktop */
.desktop {
  position: fixed;
  inset: 0 0 var(--taskbar-h) 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(94, 92, 230, 0.35), transparent 55%),
    radial-gradient(circle at 80% 75%, rgba(10, 132, 255, 0.35), transparent 55%),
    linear-gradient(160deg, #1b1140, #0a1e3d 55%, #06122b);
  overflow: hidden;
}
.desktop-icons {
  position: absolute;
  top: 18px; left: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 1;
}
.desktop-icon {
  background: none;
  border: none;
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.desktop-icon:hover, .desktop-icon:focus-visible { background: rgba(255, 255, 255, 0.08); }
.desktop-icon:active { background: rgba(10, 132, 255, 0.28); }
.d-tile {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}
.notepad-tile { background: linear-gradient(160deg, #ffd75e, #f5b800); }
.paint-tile { background: linear-gradient(160deg, #ff5f6d, #a23cff); }
.terminal-tile { background: linear-gradient(160deg, #1c1c1e, #000); }
.calc-tile { background: linear-gradient(160deg, #3a3a3c, #1c1c1e); }
.about-tile { background: linear-gradient(160deg, #6ec6ff, #0a84ff); }
.bin-tile { background: linear-gradient(160deg, #d8d8dc, #b6b6ba); }
.d-label {
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  text-align: center;
  line-height: 1.2;
}

/* Windows */
.windows-layer { position: absolute; inset: 0; }
.win {
  position: absolute;
  width: 420px;
  height: 340px;
  min-width: 260px;
  min-height: 180px;
  background: var(--win-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  animation: win-open 0.18s ease-out;
}
@keyframes win-open {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
.win.maximized {
  top: 0 !important; left: 0 !important;
  width: 100% !important; height: 100% !important;
  border-radius: 0;
}
.win-titlebar {
  background: var(--win-header);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  height: 36px;
  flex-shrink: 0;
  cursor: default;
}
.win-titlebar-icon { width: 16px; height: 16px; flex-shrink: 0; display: flex; }
.win-titlebar-icon svg { width: 100%; height: 100%; }
.win-title { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btn {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.win-btn-min { background: #ffbd2e; }
.win-btn-max { background: #28c840; }
.win-btn-close { background: #ff5f57; }
.win-body { flex: 1; min-height: 0; overflow: auto; background: var(--win-bg); position: relative; }

.win-resize-handle {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
}

/* Notepad */
.notepad-textarea {
  width: 100%; height: 100%;
  border: none; outline: none; resize: none;
  padding: 12px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 14px;
  background: #fff;
  color: #111;
}

/* Paint */
.paint-body { display: flex; flex-direction: column; height: 100%; background: #d9d9dc; }
.paint-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #eee;
  border-bottom: 1px solid #c7c7cc;
  flex-shrink: 0;
}
.paint-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  padding: 0;
}
.paint-swatch.active { border-color: #000; box-shadow: 0 0 0 1.5px #fff inset; }
.paint-size { width: 80px; }
.paint-canvas-wrap { flex: 1; min-height: 0; background: #fff; position: relative; }
.paint-canvas-wrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.paint-btn {
  border: 1px solid #c7c7cc;
  background: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.paint-spacer { flex: 1; }

/* Terminal */
.terminal-body {
  background: #0c0c0c;
  color: #4cff6b;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
  padding: 10px;
  height: 100%;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.terminal-line { margin: 0 0 2px; }
.terminal-input-row { display: flex; gap: 6px; }
.terminal-prompt { flex-shrink: 0; }
.terminal-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #4cff6b;
  font-family: inherit;
  font-size: 13px;
}

/* Calculator (reuses the same look as the phone app) */
.win-calc-body { display: flex; flex-direction: column; height: 100%; background: #000; color: #fff; }
.win-calc-display { text-align: right; font-size: 40px; font-weight: 300; padding: 16px 14px 6px; }
.win-calc-grid { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 6px 10px 10px; }
.win-calc-btn {
  border: none; border-radius: 8px;
  background: #333336; color: #fff;
  font-size: 16px; cursor: pointer;
}
.win-calc-btn:active { filter: brightness(1.4); }
.win-calc-fn { background: #a5a5a5; color: #000; }
.win-calc-op { background: var(--accent); }
.win-calc-op.active-op { background: #fff; color: var(--accent); }

/* About */
.about-body { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; padding: 20px; gap: 4px; background: #fff; }
.about-logo { font-size: 42px; margin-bottom: 6px; }
.about-body h2 { margin: 0; font-size: 18px; }
.about-body p { margin: 2px 0; font-size: 13px; color: #666; }

/* Recycle bin */
.bin-body { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #888; gap: 8px; background: #fff; }

/* Start menu */
.start-menu {
  position: fixed;
  left: 10px;
  bottom: calc(var(--taskbar-h) + 8px);
  width: 230px;
  background: rgba(30, 30, 34, 0.9);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  z-index: 5000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.start-menu-header {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 10px 10px;
  display: flex; align-items: center; gap: 6px;
}
.start-menu-logo { color: var(--accent); }
.start-menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #f2f2f7;
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.start-menu-item:hover { background: rgba(255, 255, 255, 0.1); }
.start-menu-divider { height: 1px; background: rgba(255, 255, 255, 0.1); margin: 6px 4px; }
.start-menu-lock { color: #ff9f0a; }

/* Taskbar */
.taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--taskbar-h);
  background: rgba(20, 20, 23, 0.85);
  backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  z-index: 4000;
}
.start-btn {
  display: flex; align-items: center; gap: 7px;
  background: none; border: none;
  color: #fff; font-size: 13px; font-weight: 600;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.start-btn:hover, .start-btn.active { background: rgba(255, 255, 255, 0.1); }
.start-logo { color: var(--accent); font-size: 15px; }
.taskbar-apps { flex: 1; display: flex; gap: 6px; height: 100%; align-items: center; }
.taskbar-app {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  max-width: 150px;
}
.taskbar-app.focused { background: rgba(10, 132, 255, 0.35); }
.taskbar-app span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray { color: #fff; font-size: 13px; padding: 0 6px; }

/* Lock screen */
.lockscreen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background:
    radial-gradient(circle at 30% 20%, rgba(94, 92, 230, 0.5), transparent 55%),
    radial-gradient(circle at 75% 80%, rgba(10, 132, 255, 0.5), transparent 55%),
    linear-gradient(160deg, #1b1140, #06122b);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
}
.lock-clock { font-size: 88px; font-weight: 200; }
.lock-date { font-size: 18px; color: rgba(255, 255, 255, 0.8); margin-top: -14px; }
.lock-hint { margin-top: 40px; font-size: 13px; color: rgba(255, 255, 255, 0.6); }
