:root {
  --taskbar-height: 72px;
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.2);
  --border: rgba(255, 255, 255, 0.18);
  --text: #f5f9ff;
  --text-dark: #20242e;
  --win-bg: rgba(245, 249, 255, 0.9);
  --shadow: 0 14px 40px rgba(6, 17, 37, 0.28);
  --accent: #4ea1ff;
  --accent-soft: rgba(78, 161, 255, 0.18);
  --desktop-gap: 18px;
  --desktop-item-size: 90px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  user-select: none;
}

button,
input,
textarea {
  font: inherit;
}

body {
  background: #0d1b33;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  transition: background 0.35s ease;
}

.wallpaper-default {
  background: linear-gradient(135deg, #0f3f7c 0%, #2576db 45%, #7ab5ff 100%);
}

.wallpaper-sunset {
  background: linear-gradient(135deg, #22134f 0%, #8a2be2 38%, #ff6f91 100%);
}

.wallpaper-forest {
  background: linear-gradient(135deg, #0f3b2e 0%, #0e7a57 48%, #87d9b1 100%);
}

.wallpaper-night {
  background: linear-gradient(135deg, #090d18 0%, #10264f 45%, #233c7b 100%);
}

.wallpaper-aurora {
  background: linear-gradient(135deg, #0a1120 0%, #0a4f6d 35%, #4bbf9f 70%, #d5f5ea 100%);
}

.desktop {
  position: absolute;
  inset: 0 0 var(--taskbar-height) 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: var(--desktop-gap);
}

.desktop-icon {
  width: var(--desktop-item-size);
  min-height: 92px;
  padding: 8px 6px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  gap: 8px;
  transition: background 0.18s ease, transform 0.18s ease;
  position: relative;
}

.desktop-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

.desktop-icon.selected {
  background: rgba(255, 255, 255, 0.18);
  outline: 1px solid rgba(255, 255, 255, 0.22);
}

.desktop-icon .icon-visual {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,.12));
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 8px 20px rgba(0,0,0,.18);
}

.desktop-icon .icon-name {
  font-size: 13px;
  line-height: 1.15;
  padding: 2px 6px;
  border-radius: 8px;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.desktop-icon input.rename-input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 8px;
  background: rgba(20, 27, 40, 0.8);
  color: white;
  text-align: center;
  padding: 4px 6px;
}

.taskbar-shell {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px;
}

.taskbar {
  width: 100%;
  height: calc(var(--taskbar-height) - 10px);
  border-radius: 22px;
  background: rgba(22, 26, 36, 0.35);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 12px;
}

.taskbar-center {
  grid-column: 2;
  display: flex;
  gap: 8px;
  align-items: center;
}

.taskbar-right {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.taskbar-icon,
.clock-button,
.ghost-btn,
.window-control,
.calc-btn,
.start-app,
.explorer-nav-item,
.file-card,
.context-menu button,
.paint-toolbar button,
.paint-toolbar input,
.recycle-row button,
.note-save-btn,
.wallpaper-card {
  border: none;
  border-radius: 14px;
  cursor: pointer;
}

.taskbar-icon {
  width: 46px;
  height: 46px;
  background: transparent;
  display: grid;
  place-items: center;
  color: white;
  font-size: 22px;
  position: relative;
  transition: background 0.18s ease, transform 0.18s ease;
}

.taskbar-icon:hover,
.taskbar-icon.active {
  background: rgba(255,255,255,.12);
  transform: translateY(-1px);
}

.taskbar-icon.running::after {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 16px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
}

.system-tray {
  display: flex;
  gap: 4px;
  padding: 0 10px;
}

.tray-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
}

.clock-button {
  background: rgba(255,255,255,.08);
  color: white;
  min-width: 110px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.clock-button:hover,
.ghost-btn:hover {
  background: rgba(255,255,255,.16);
}

.start-menu {
  position: absolute;
  left: 50%;
  bottom: calc(var(--taskbar-height) + 10px);
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 28px));
  min-height: 500px;
  max-height: min(78vh, 760px);
  overflow: auto;
  padding: 18px;
  border-radius: 28px;
  background: rgba(24, 30, 42, 0.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(30px) saturate(160%);
  box-shadow: var(--shadow);
  color: white;
  z-index: 6000;
  animation: riseIn 0.22s ease;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.hidden {
  display: none !important;
}

.start-search {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-radius: 18px;
  background: rgba(255,255,255,.14);
  color: rgba(255,255,255,.88);
}

.start-section-header,
.start-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}

.ghost-btn {
  background: rgba(255,255,255,.1);
  color: white;
  padding: 10px 14px;
}

.pinned-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.start-app {
  background: rgba(255,255,255,.08);
  padding: 14px 10px;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 96px;
}

.start-app:hover,
.file-card:hover,
.explorer-nav-item:hover,
.wallpaper-card:hover,
.calc-btn:hover,
.note-save-btn:hover,
.recycle-row button:hover,
.context-menu button:hover,
.paint-toolbar button:hover {
  background: rgba(255,255,255,.18);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: grid;
  place-items: center;
}

.context-menu {
  position: absolute;
  width: 220px;
  background: rgba(28, 35, 46, 0.78);
  border: 1px solid var(--border);
  backdrop-filter: blur(28px) saturate(150%);
  border-radius: 18px;
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: 7000;
}

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: transparent;
  color: white;
}

.menu-separator {
  height: 1px;
  background: rgba(255,255,255,.12);
  margin: 6px 0;
}

.windows-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.app-window {
  position: absolute;
  min-width: 320px;
  min-height: 240px;
  width: 720px;
  height: 470px;
  background: var(--win-bg);
  color: var(--text-dark);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
  pointer-events: auto;
}

.app-window.active {
  outline: 1px solid rgba(78,161,255,.35);
}

.window-header {
  height: 48px;
  background: linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,.55));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 16px;
  cursor: move;
}

.window-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.window-controls {
  display: flex;
  gap: 6px;
}

.window-control {
  width: 36px;
  height: 36px;
  background: transparent;
  color: #1b2430;
}

.window-control.close:hover {
  background: #db4f5c;
  color: white;
}

.window-body {
  height: calc(100% - 48px);
  background: rgba(255,255,255,.5);
}

.resize-handle {
  position: absolute;
  z-index: 3;
}

.resize-handle.se { right: 0; bottom: 0; width: 16px; height: 16px; cursor: se-resize; }
.resize-handle.e { top: 0; right: 0; width: 8px; height: 100%; cursor: ew-resize; }
.resize-handle.s { left: 0; bottom: 0; width: 100%; height: 8px; cursor: ns-resize; }
.resize-handle.w { top: 0; left: 0; width: 8px; height: 100%; cursor: ew-resize; }
.resize-handle.n { left: 0; top: 0; width: 100%; height: 8px; cursor: ns-resize; }
.resize-handle.ne { top: 0; right: 0; width: 14px; height: 14px; cursor: ne-resize; }
.resize-handle.nw { top: 0; left: 0; width: 14px; height: 14px; cursor: nw-resize; }
.resize-handle.sw { left: 0; bottom: 0; width: 14px; height: 14px; cursor: sw-resize; }

.explorer-layout,
.personalize-layout {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 200px 1fr;
}

.explorer-sidebar,
.personalize-sidebar {
  padding: 14px;
  background: rgba(231, 238, 248, 0.65);
  border-right: 1px solid rgba(23, 33, 47, 0.08);
}

.explorer-nav-item {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: transparent;
  text-align: left;
}

.explorer-nav-item.active {
  background: rgba(78,161,255,.16);
}

.explorer-content,
.personalize-content,
.recycle-layout,
.games-layout {
  padding: 16px;
  overflow: auto;
}

.file-grid,
.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.file-card,
.wallpaper-card {
  min-height: 96px;
  padding: 12px;
  background: rgba(228, 236, 246, 0.76);
  color: var(--text-dark);
  text-align: left;
}

.notepad-layout,
.paint-layout,
.calculator-layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.notepad-toolbar,
.paint-toolbar {
  padding: 12px;
  border-bottom: 1px solid rgba(23,33,47,.08);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.note-save-btn,
.paint-toolbar button {
  padding: 10px 14px;
  background: rgba(78,161,255,.14);
}

.notepad-textarea {
  width: 100%;
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 16px;
  background: rgba(255,255,255,.45);
}

.calculator-layout {
  padding: 14px;
  gap: 10px;
}

.calc-display {
  height: 90px;
  border-radius: 18px;
  background: rgba(226,234,245,.9);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
}

.calc-expression {
  color: #5b6472;
  min-height: 22px;
}

.calc-result {
  font-size: 32px;
  font-weight: 600;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  flex: 1;
}

.calc-btn {
  min-height: 54px;
  background: rgba(228,236,246,.92);
  font-size: 18px;
}

.calc-btn.action,
.calc-btn.equal {
  background: rgba(78,161,255,.16);
}

.paint-layout {
  padding: 0;
}

.paint-canvas-wrap {
  flex: 1;
  padding: 14px;
  background: linear-gradient(180deg, rgba(244,248,255,.9), rgba(222,231,244,.85));
}

#paintCanvas {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(20,25,35,.08);
  cursor: crosshair;
}

.recycle-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: rgba(228,236,246,.76);
  padding: 12px;
  border-radius: 16px;
  margin-bottom: 10px;
}

.recycle-row button {
  padding: 8px 12px;
  background: rgba(78,161,255,.16);
}

.empty-state {
  padding: 24px;
  border-radius: 18px;
  background: rgba(228,236,246,.66);
}

.selection-box {
  position: absolute;
  border: 1px solid rgba(132, 204, 255, 0.95);
  background: rgba(132, 204, 255, 0.18);
  z-index: 2000;
}

.snake-board {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  max-width: 360px;
}

.snake-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(220,228,240,.95);
}

.snake-cell.snake { background: rgba(78,161,255,.65); }
.snake-cell.food { background: rgba(219,79,92,.65); }

@media (max-width: 900px) {
  .app-window {
    width: min(92vw, 720px);
    height: min(72vh, 520px);
  }

  .explorer-layout,
  .personalize-layout {
    grid-template-columns: 1fr;
  }

  .explorer-sidebar,
  .personalize-sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(23,33,47,.08);
  }
}

@media (max-width: 640px) {
  .taskbar {
    grid-template-columns: auto 1fr auto;
  }

  .taskbar-center {
    overflow-x: auto;
    padding: 0 8px;
  }

  .desktop {
    padding: 14px;
    gap: 12px;
  }

  .desktop-icon {
    width: 82px;
  }

  .start-menu {
    min-height: 420px;
  }
}
