:root {
  --xp-teal: #008080;
  --xp-blue: #245edb;
  --xp-blue-dark: #1941a5;
  --xp-blue-light: #3c8cf0;
  --xp-title-start: #0a246a;
  --xp-title-end: #a6caf0;
  --xp-taskbar-top: #1e52b5;
  --xp-taskbar-bot: #245edc;
  --xp-start-green: #3c8a2e;
  --xp-start-green-dark: #216012;
  --xp-window-bg: #ece9d8;
  --xp-border: #0054e3;
  --font: Tahoma, "Segoe UI", Geneva, Verdana, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
}

img {
  display: block;
  max-width: 100%;
  pointer-events: none;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: grid;
  place-items: center;
  transition: opacity 0.45s ease;
}

.boot-screen.hide {
  opacity: 0;
  pointer-events: none;
}

.boot-logo {
  text-align: center;
  color: #fff;
}

.boot-flag {
  width: 88px;
  height: 66px;
  margin: 0 auto 18px;
  background:
    linear-gradient(90deg, #f25022 50%, #7fba00 50%) top / 100% 50% no-repeat,
    linear-gradient(90deg, #00a4ef 50%, #ffb900 50%) bottom / 100% 50% no-repeat;
  border-radius: 2px;
}

.boot-brand {
  margin: 0 0 28px;
  font-size: 22px;
  letter-spacing: 0.04em;
}

.boot-bar {
  width: 180px;
  height: 14px;
  margin: 0 auto;
  border: 1px solid #3a3a3a;
  background: #1a1a1a;
  overflow: hidden;
  position: relative;
}

.boot-bar span {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 42px;
  background: linear-gradient(90deg, #245edb, #6ba3ff, #245edb);
  animation: boot-slide 1.1s linear infinite;
}

@keyframes boot-slide {
  from {
    left: -42px;
  }
  to {
    left: 100%;
  }
}

.desktop {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: var(--xp-teal) center / cover no-repeat;
  background-image: url("../assets/wallpaper.jpg");
  overflow: hidden;
}

.icon-layer {
  position: absolute;
  inset: 0 0 30px 0;
  z-index: 1;
}

.desktop-icon {
  position: absolute;
  width: 76px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: default;
  z-index: 2;
  touch-action: none;
}

.desktop-icon .icon-image {
  width: 48px;
  height: 48px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.45));
  background: transparent;
}

.desktop-icon[data-id="veil"] .icon-image {
  image-rendering: pixelated;
}

.desktop-icon .icon-label {
  color: #fff;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  text-shadow: 1px 1px 2px #000, -1px 0 1px #000, 1px 0 1px #000;
  padding: 1px 3px;
  max-width: 74px;
  word-break: break-word;
}

.desktop-icon.selected .icon-label {
  background: rgba(10, 36, 106, 0.72);
  outline: 1px dotted rgba(255, 255, 255, 0.85);
}

.desktop-icon.selected .icon-image {
  filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.45)) brightness(0.92)
    contrast(1.05);
}

.desktop-icon.dragging {
  opacity: 0.85;
  z-index: 50;
}

.desktop-icon.drop-target {
  outline: 1px dotted #fff;
}

.window-layer {
  position: absolute;
  inset: 0 0 30px 0;
  z-index: 10;
  pointer-events: none;
}

.xp-window {
  position: absolute;
  min-width: 280px;
  min-height: 180px;
  background: var(--xp-window-bg);
  border: 2px solid var(--xp-border);
  border-radius: 8px 8px 0 0;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  overflow: hidden;
}

.xp-window.inactive {
  filter: saturate(0.75) brightness(0.97);
}

.xp-window .titlebar {
  height: 26px;
  padding: 0 4px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  background: linear-gradient(
    180deg,
    #0997ff 0%,
    #0053ee 8%,
    #0050ee 40%,
    #0066ff 88%,
    #0066ff 100%
  );
  cursor: move;
}

.xp-window.inactive .titlebar {
  background: linear-gradient(180deg, #7a96df, #2657c5 40%, #3f74d5);
}

.titlebar-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  image-rendering: pixelated;
}

.titlebar-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
}

.title-controls {
  display: flex;
  gap: 2px;
}

.title-btn {
  width: 21px;
  height: 21px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 3px;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  background: linear-gradient(180deg, #3c91ff, #0060ef);
  display: grid;
  place-items: center;
  padding: 0;
}

.title-btn:hover {
  filter: brightness(1.12);
}

.title-btn.close {
  background: linear-gradient(180deg, #e87654, #d1260f);
}

.window-toolbar {
  display: flex;
  gap: 2px;
  padding: 3px 6px;
  border-bottom: 1px solid #aca899;
  background: linear-gradient(180deg, #fff, #ece9d8);
  font-size: 11px;
}

.window-toolbar span {
  padding: 2px 8px;
  color: #000;
}

.window-address {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px solid #aca899;
  background: #ece9d8;
  font-size: 11px;
}

.window-address input {
  flex: 1;
  border: 1px solid #7f9db9;
  height: 20px;
  padding: 0 6px;
  font-family: inherit;
  font-size: 11px;
  background: #fff;
}

.window-body {
  flex: 1;
  background: #fff;
  overflow: auto;
  position: relative;
  min-height: 140px;
}

.window-body.folder-view {
  background: #fff;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  align-content: start;
}

.window-body.browser-view {
  padding: 0;
  overflow: hidden;
  display: flex;
  background: #fff;
}

.browser-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.window-status {
  height: 22px;
  border-top: 1px solid #aca899;
  background: #ece9d8;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  color: #222;
}

.folder-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  cursor: default;
  border: 1px solid transparent;
  touch-action: none;
}

.folder-item:hover {
  background: rgba(49, 106, 197, 0.08);
}

.folder-item.selected {
  background: #316ac5;
  color: #fff;
}

.folder-item img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
}

.folder-item .name {
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
  max-width: 80px;
  word-break: break-word;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #666;
  font-size: 12px;
  pointer-events: none;
}

.selection-box {
  position: absolute;
  border: 1px dotted #fff;
  background: rgba(10, 36, 106, 0.25);
  z-index: 5;
  pointer-events: none;
}

.taskbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30px;
  z-index: 100;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 0 4px 0 0;
  background: linear-gradient(
    180deg,
    #3168d5 0%,
    #245edc 8%,
    #245edc 88%,
    #1941a5 100%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.start-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 0 8px;
  margin: 0;
  border: none;
  border-radius: 0 12px 12px 0;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  font-style: italic;
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  background: linear-gradient(
    180deg,
    #3ba03b 0%,
    #2d8a2d 12%,
    #2d8a2d 70%,
    #1f6b1f 100%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.start-button:hover,
.start-button.active {
  filter: brightness(1.08);
}

.start-orb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fff 0 12%, transparent 13%),
    conic-gradient(#f25022 0 25%, #7fba00 0 50%, #00a4ef 0 75%, #ffb900 0);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.taskbar-windows {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow: hidden;
  padding: 3px 0;
}

.task-btn {
  height: 24px;
  max-width: 160px;
  min-width: 100px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 3px;
  color: #fff;
  font-size: 11px;
  background: linear-gradient(180deg, #3c81f3, #245edc);
  cursor: pointer;
  overflow: hidden;
}

.task-btn img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  image-rendering: pixelated;
}

.task-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-btn.active {
  background: linear-gradient(180deg, #1c4fbf, #163f9a);
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.35);
}

.tray {
  display: flex;
  align-items: center;
  padding: 0 10px;
  margin: 3px 0;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  background: linear-gradient(180deg, #1290e8, #0a78d0);
  color: #fff;
  font-size: 11px;
}

.clock {
  min-width: 52px;
  text-align: center;
}

.start-menu {
  position: absolute;
  left: 0;
  bottom: 30px;
  width: min(380px, 92vw);
  z-index: 120;
  border: 1px solid #0831d9;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.4);
  background: #fff;
}

.start-menu-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(180deg, #1b5fd6, #245edc);
}

.start-avatar {
  width: 42px;
  height: 42px;
  border-radius: 4px;
  border: 2px solid #fff;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #008080, #245edb);
  font-size: 14px;
}

.start-menu-body {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  min-height: 220px;
}

.start-left {
  background: #fff;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.start-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}

.start-item:hover {
  background: #316ac5;
  color: #fff;
}

.start-item img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}

.start-right {
  background: #d3e5fa;
  border-left: 1px solid #94b2e1;
  padding: 14px 12px;
}

.start-right-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: #00156e;
}

.start-right-copy {
  margin: 0;
  font-size: 11px;
  color: #234;
  line-height: 1.45;
}

.start-menu-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #245edc, #1941a5);
}

.start-footer-btn {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 3px;
}

.start-footer-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.dialog-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.25);
  display: none;
  place-items: center;
}

.dialog-root:not([hidden]) {
  display: grid;
}

.xp-dialog {
  width: min(420px, 92vw);
  background: var(--xp-window-bg);
  border: 2px solid var(--xp-border);
  border-radius: 8px 8px 0 0;
  box-shadow: 3px 3px 14px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.dialog-titlebar {
  height: 26px;
  padding: 0 4px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  background: linear-gradient(180deg, #0997ff, #0050ee 40%, #0066ff);
}

.dialog-body {
  display: flex;
  gap: 14px;
  padding: 18px 16px 10px;
  align-items: flex-start;
}

.dialog-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f2c200;
  color: #000;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 2px solid #c49a00;
}

.dialog-body p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #111;
  white-space: pre-line;
}

.dialog-actions {
  display: flex;
  justify-content: center;
  padding: 8px 12px 14px;
}

.xp-btn {
  min-width: 74px;
  height: 23px;
  border: 1px solid #003c74;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff, #ece9d8);
  font-size: 11px;
  cursor: pointer;
}

.xp-btn:hover {
  background: linear-gradient(180deg, #fff, #dfe8f5);
}

.xp-btn:focus {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

.trash-highlight {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #245edb !important;
  border-radius: 4px;
}

@media (max-width: 640px) {
  .desktop-icon {
    width: 70px;
  }

  .xp-window {
    min-width: 240px;
  }

  .start-menu-body {
    grid-template-columns: 1fr;
  }

  .start-right {
    display: none;
  }
}
