* {
  box-sizing: border-box;
}

:root {
  --page-text: #172033;
  --desktop-bg:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    #243447;
  --desktop-bg-size: 32px 32px;
  --window-bg: #f8fafc;
  --window-text: #172033;
  --window-border: #64748b;
  --window-radius: 8px;
  --window-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  --titlebar-bg: #2563eb;
  --titlebar-text: #ffffff;
  --taskbar-bg: rgba(15, 23, 42, 0.94);
  --taskbar-border: rgba(255, 255, 255, 0.18);
  --task-button-bg: rgba(30, 41, 59, 0.9);
  --task-button-active: #2563eb;
  --button-border: rgba(255, 255, 255, 0.28);
  --note-bg: #fffef3;
  --note-border: #cbd5e1;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: Arial, sans-serif;
  color: var(--page-text);
  background: var(--desktop-bg);
  background-size: var(--desktop-bg-size);
}

body[data-theme="light"] {
  --page-text: #172033;
  --desktop-bg:
    linear-gradient(90deg, rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    #dbeafe;
  --window-bg: #ffffff;
  --window-text: #172033;
  --window-border: #94a3b8;
  --titlebar-bg: #e2e8f0;
  --titlebar-text: #0f172a;
  --taskbar-bg: rgba(241, 245, 249, 0.94);
  --taskbar-border: rgba(15, 23, 42, 0.16);
  --task-button-bg: #ffffff;
  --task-button-active: #bfdbfe;
  --button-border: rgba(15, 23, 42, 0.2);
}

body[data-theme="dark"] {
  --page-text: #e5e7eb;
  --desktop-bg:
    radial-gradient(circle at 20% 20%, rgba(34, 197, 94, 0.18), transparent 18rem),
    radial-gradient(circle at 80% 75%, rgba(59, 130, 246, 0.2), transparent 18rem),
    #020617;
  --window-bg: #111827;
  --window-text: #e5e7eb;
  --window-border: #334155;
  --titlebar-bg: #0f172a;
  --titlebar-text: #e5e7eb;
  --taskbar-bg: rgba(2, 6, 23, 0.95);
  --taskbar-border: rgba(148, 163, 184, 0.22);
  --task-button-bg: #111827;
  --task-button-active: #1d4ed8;
  --note-bg: #1f2937;
  --note-border: #475569;
}

body[data-theme="retro"] {
  --page-text: #000000;
  --desktop-bg: #008080;
  --desktop-bg-size: auto;
  --window-bg: #c0c0c0;
  --window-text: #000000;
  --window-border: #000000;
  --window-radius: 0;
  --window-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
  --titlebar-bg: #000080;
  --titlebar-text: #ffffff;
  --taskbar-bg: #c0c0c0;
  --taskbar-border: #ffffff;
  --task-button-bg: #c0c0c0;
  --task-button-active: #ffffff;
  --button-border: #000000;
  --note-bg: #ffffff;
  --note-border: #808080;
}

body[data-theme="unix"] {
  --page-text: #cdd6f4;
  --desktop-bg:
    linear-gradient(135deg, rgba(137, 180, 250, 0.12), transparent 30%),
    linear-gradient(225deg, rgba(249, 226, 175, 0.1), transparent 34%),
    #11111b;
  --window-bg: #1e1e2e;
  --window-text: #cdd6f4;
  --window-border: #89b4fa;
  --window-radius: 6px;
  --window-shadow: 0 14px 38px rgba(0, 0, 0, 0.44);
  --titlebar-bg: #313244;
  --titlebar-text: #cdd6f4;
  --taskbar-bg: rgba(30, 30, 46, 0.92);
  --taskbar-border: rgba(137, 180, 250, 0.35);
  --task-button-bg: #181825;
  --task-button-active: #45475a;
  --button-border: rgba(137, 180, 250, 0.4);
  --note-bg: #181825;
  --note-border: #45475a;
}

.desktop {
  width: 100%;
  height: calc(100% - 54px);
  position: relative;
}

.window {
  width: min(330px, calc(100vw - 32px));
  min-height: 210px;
  position: absolute;
  color: var(--window-text);
  background: var(--window-bg);
  border: 1px solid var(--window-border);
  border-radius: var(--window-radius);
  box-shadow: var(--window-shadow);
  overflow: auto;
  resize: both;
}

.titlebar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 0 14px;
  color: var(--titlebar-text);
  background: var(--titlebar-bg);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.titlebar span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 700;
}

.close-button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: #ef4444;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.close-button:hover,
.close-button:focus-visible {
  background: #b91c1c;
}

.window-content {
  padding: 16px;
}

.window-content h1,
.window-content h2,
.window-content p {
  margin: 0;
}

.window-content h1,
.window-content h2 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

.window-content p {
  line-height: 1.5;
}

.notes-content {
  height: calc(100% - 38px);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-label {
  font-weight: 700;
}

#notes-area {
  min-height: 150px;
  flex: 1;
  resize: none;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px;
  color: var(--window-text);
  background: var(--note-bg);
  font: inherit;
  line-height: 1.45;
}

#notes-area:focus {
  outline: 2px solid #93c5fd;
  border-color: #2563eb;
}

.notes-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #64748b;
  font-size: 0.9rem;
}

.clear-notes-button {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 10px;
  color: #172033;
  background: #ffffff;
  font: inherit;
  cursor: pointer;
}

.clear-notes-button:hover,
.clear-notes-button:focus-visible {
  border-color: #ef4444;
  color: #b91c1c;
}

.terminal-window {
  width: min(520px, calc(100vw - 32px));
  min-height: 285px;
  background: #070b09;
  border-color: #22c55e;
  color: #d1fae5;
}

.terminal-titlebar {
  color: #d1fae5;
  background: #111827;
  border-bottom: 1px solid rgba(34, 197, 94, 0.55);
}

.terminal-content {
  height: calc(100% - 38px);
  min-height: 240px;
  display: flex;
  flex-direction: column;
  padding: 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  background:
    linear-gradient(rgba(34, 197, 94, 0.04) 50%, transparent 50%),
    #070b09;
  background-size: 100% 4px;
}

.terminal-output {
  flex: 1;
  overflow: auto;
}

.terminal-output p {
  margin: 0 0 6px;
  line-height: 1.35;
}

.terminal-command {
  color: #86efac;
  font-weight: 700;
}

.terminal-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.terminal-form label {
  flex: 0 0 auto;
  color: #86efac;
}

.terminal-form input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: #d1fae5;
  background: transparent;
  font: inherit;
  caret-color: #86efac;
}

.taskbar {
  height: 54px;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #ffffff;
  background: var(--taskbar-bg);
  border-top: 1px solid var(--taskbar-border);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.start-button,
.task-button,
.theme-button {
  height: 36px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  color: var(--titlebar-text);
  background: rgba(37, 99, 235, 0.86);
  font: inherit;
  cursor: pointer;
}

.start-button {
  min-width: 82px;
  font-weight: 700;
}

.task-buttons {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
}

.task-button {
  min-width: 112px;
  max-width: 160px;
  padding: 0 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: var(--task-button-bg);
}

.task-button:hover,
.task-button:focus-visible,
.task-button.active {
  background: var(--task-button-active);
  border-color: #bfdbfe;
}

.task-button.closed {
  opacity: 0.55;
}

.clock {
  min-width: 58px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.theme-button {
  min-width: 92px;
  background: var(--task-button-bg);
}

body[data-theme="light"] .taskbar,
body[data-theme="retro"] .taskbar,
body[data-theme="light"] .start-button,
body[data-theme="light"] .task-button,
body[data-theme="light"] .theme-button,
body[data-theme="retro"] .start-button,
body[data-theme="retro"] .task-button,
body[data-theme="retro"] .theme-button,
body[data-theme="light"] .clock,
body[data-theme="retro"] .clock {
  color: #000000;
}

body[data-theme="retro"] .start-button,
body[data-theme="retro"] .task-button,
body[data-theme="retro"] .theme-button,
body[data-theme="retro"] .close-button,
body[data-theme="retro"] #notes-area {
  border-radius: 0;
  box-shadow:
    inset 1px 1px 0 #ffffff,
    inset -1px -1px 0 #808080;
}

@media (max-width: 640px) {
  .window {
    width: calc(100vw - 32px);
  }

  .taskbar {
    gap: 6px;
    padding: 8px;
  }

  .start-button {
    min-width: 64px;
  }

  .task-button {
    min-width: 92px;
  }
}
