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

:root {
  --deep-space: #0a0a2e;
  --electric-purple: #7b2ff7;
  --cyan: #00f0ff;
  --gold: #ffd700;
  --magenta: #ff00ff;
  --dark-bg: #0d0d35;
  --glass-bg: rgba(15, 15, 60, 0.75);
  --glass-border: rgba(123, 47, 247, 0.3);
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background: var(--deep-space);
  cursor: crosshair;
}

/* Boot screen */
.boot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 1s ease;
}

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

.boot-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.4;
}

.boot-text {
  position: relative;
  z-index: 2;
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  text-align: left;
  width: 500px;
  max-width: 90vw;
}

.boot-text .line {
  opacity: 0;
  animation: fadeInLine 0.3s forwards;
}

@keyframes fadeInLine {
  to { opacity: 1; }
}

.boot-logo {
  position: relative;
  z-index: 2;
  font-size: 48px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--electric-purple), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 30px;
  letter-spacing: -1px;
}

/* Desktop */
.desktop {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.wallpaper-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Desktop Icons */
.desktop-icons {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 8px;
  max-height: calc(100vh - 80px);
}

.desktop-icon {
  width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.desktop-icon:hover {
  background: rgba(123, 47, 247, 0.2);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.desktop-icon .icon-glyph {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: rgba(123, 47, 247, 0.15);
  border-radius: 12px;
  border: 1px solid rgba(123, 47, 247, 0.3);
  transition: all 0.2s ease;
}

.desktop-icon:hover .icon-glyph {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
  transform: scale(1.05);
}

.desktop-icon .icon-label {
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  line-height: 1.2;
}

/* Taskbar */
.taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  z-index: 9000;
  background: rgba(10, 10, 46, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(123, 47, 247, 0.3);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
}

.start-btn {
  width: 40px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: linear-gradient(135deg, rgba(123, 47, 247, 0.3), rgba(0, 240, 255, 0.15));
  color: var(--cyan);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.start-btn:hover {
  background: linear-gradient(135deg, rgba(123, 47, 247, 0.5), rgba(0, 240, 255, 0.3));
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.taskbar-apps {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  overflow-x: auto;
}

.taskbar-app {
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: none;
  background: rgba(123, 47, 247, 0.15);
  color: #ccc;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.taskbar-app:hover {
  background: rgba(123, 47, 247, 0.3);
}

.taskbar-app.active {
  background: rgba(0, 240, 255, 0.15);
  color: var(--cyan);
  border-bottom: 2px solid var(--cyan);
}

.system-tray {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  padding-right: 8px;
}

.system-tray .clock {
  color: var(--cyan);
  font-weight: 500;
}

.system-tray .battery {
  color: var(--gold);
}

.fractal-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(123, 47, 247, 0.3);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Start Menu */
.start-menu {
  position: fixed;
  bottom: 52px;
  left: 8px;
  width: 320px;
  max-height: 500px;
  background: rgba(10, 10, 46, 0.92);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(123, 47, 247, 0.3);
  border-radius: 12px;
  z-index: 9500;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(123, 47, 247, 0.15);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.start-menu-search {
  padding: 12px;
  border-bottom: 1px solid rgba(123, 47, 247, 0.2);
}

.start-menu-search input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(123, 47, 247, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  outline: none;
}

.start-menu-search input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.start-menu-search input::placeholder {
  color: rgba(255,255,255,0.3);
}

.start-menu-apps {
  max-height: 350px;
  overflow-y: auto;
  padding: 8px;
}

.start-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.start-menu-item:hover {
  background: rgba(123, 47, 247, 0.2);
}

.start-menu-item .smi-icon {
  font-size: 22px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(123, 47, 247, 0.15);
  border-radius: 8px;
}

.start-menu-item .smi-info {
  flex: 1;
}

.start-menu-item .smi-name {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.start-menu-item .smi-desc {
  color: rgba(255,255,255,0.4);
  font-size: 11px;
}

.start-menu-footer {
  padding: 8px 12px;
  border-top: 1px solid rgba(123, 47, 247, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shutdown-btn {
  background: rgba(255, 50, 50, 0.2);
  border: 1px solid rgba(255, 50, 50, 0.3);
  color: #ff6666;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  transition: all 0.15s;
}

.shutdown-btn:hover {
  background: rgba(255, 50, 50, 0.4);
}

/* Window */
.os-window {
  position: absolute;
  background: rgba(13, 13, 53, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(123, 47, 247, 0.25);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(123, 47, 247, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 300px;
  min-height: 200px;
  transition: box-shadow 0.2s;
}

.os-window.focused {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.3);
}

.os-window.minimized {
  transform: scale(0.1);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.os-window.maximized {
  border-radius: 0;
}

.window-titlebar {
  height: 36px;
  background: linear-gradient(90deg, rgba(123, 47, 247, 0.3), rgba(0, 240, 255, 0.15), rgba(255, 0, 255, 0.15));
  display: flex;
  align-items: center;
  padding: 0 10px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.window-titlebar:active {
  cursor: grabbing;
}

.window-title {
  flex: 1;
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.window-title .wt-icon {
  font-size: 14px;
}

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

.window-controls button {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0;
}

.win-close { background: #ff5f57; }
.win-close:hover { background: #ff3b30; box-shadow: 0 0 6px rgba(255, 59, 48, 0.5); }
.win-min { background: #febc2e; }
.win-min:hover { background: #f5a623; box-shadow: 0 0 6px rgba(245, 166, 35, 0.5); }
.win-max { background: #28c840; }
.win-max:hover { background: #1db954; box-shadow: 0 0 6px rgba(29, 185, 84, 0.5); }

.window-body {
  flex: 1;
  overflow: auto;
  position: relative;
}

.window-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 10;
}

/* App specific styles */
.app-content {
  padding: 16px;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  height: 100%;
}

/* Fractal Explorer */
.fractal-explorer {
  display: flex;
  height: 100%;
}

.fractal-explorer canvas {
  flex: 1;
  cursor: crosshair;
}

.fractal-sidebar {
  width: 200px;
  background: rgba(0,0,0,0.3);
  padding: 12px;
  overflow-y: auto;
  border-left: 1px solid rgba(123, 47, 247, 0.2);
  flex-shrink: 0;
}

.fractal-sidebar label {
  display: block;
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  margin-bottom: 4px;
  margin-top: 10px;
}

.fractal-sidebar label:first-child {
  margin-top: 0;
}

.fractal-sidebar select,
.fractal-sidebar input[type="range"],
.fractal-sidebar button {
  width: 100%;
  margin-bottom: 4px;
}

.fractal-sidebar select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(123, 47, 247, 0.3);
  border-radius: 4px;
  color: #fff;
  padding: 4px 6px;
  font-size: 12px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.fractal-sidebar input[type="range"] {
  accent-color: var(--cyan);
}

.fractal-sidebar button {
  background: linear-gradient(135deg, rgba(123, 47, 247, 0.4), rgba(0, 240, 255, 0.2));
  border: 1px solid rgba(123, 47, 247, 0.4);
  color: #fff;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  margin-top: 6px;
  transition: all 0.15s;
}

.fractal-sidebar button:hover {
  background: linear-gradient(135deg, rgba(123, 47, 247, 0.6), rgba(0, 240, 255, 0.3));
}

.fractal-sidebar .coord-display {
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  margin-top: 8px;
  line-height: 1.6;
  word-break: break-all;
}

/* Terminal */
.terminal-app {
  background: #0a0a1a;
  height: 100%;
  padding: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: #00ff88;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-app .term-line {
  margin-bottom: 2px;
  line-height: 1.4;
}

.terminal-app .term-line.output {
  color: rgba(255,255,255,0.7);
}

.terminal-app .term-line.error {
  color: #ff5f57;
}

.terminal-app .term-line.info {
  color: var(--cyan);
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-input-line .prompt {
  color: var(--electric-purple);
  font-weight: 600;
}

.terminal-input-line input {
  flex: 1;
  background: transparent;
  border: none;
  color: #00ff88;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  outline: none;
  caret-color: var(--cyan);
}

/* Notepad */
.notepad-app {
  height: 100%;
  position: relative;
}

.notepad-app textarea {
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 30, 0.9);
  border: none;
  color: rgba(255,255,255,0.85);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 16px;
  resize: none;
  outline: none;
  line-height: 1.6;
}

/* Calculator */
.calculator-app {
  padding: 12px;
  max-width: 280px;
  margin: 0 auto;
}

.calc-display {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(123, 47, 247, 0.3);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--cyan);
  font-size: 24px;
  min-height: 50px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  word-break: break-all;
  overflow: hidden;
}

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

.calc-btn {
  padding: 12px 4px;
  border-radius: 8px;
  border: 1px solid rgba(123, 47, 247, 0.2);
  background: rgba(123, 47, 247, 0.1);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.1s;
}

.calc-btn:hover {
  background: rgba(123, 47, 247, 0.3);
  border-color: var(--cyan);
}

.calc-btn.op {
  background: rgba(0, 240, 255, 0.15);
  color: var(--cyan);
}

.calc-btn.special {
  background: rgba(255, 215, 0, 0.1);
  color: var(--gold);
  font-size: 12px;
}

.calc-btn.equals {
  background: linear-gradient(135deg, rgba(123, 47, 247, 0.4), rgba(0, 240, 255, 0.3));
  color: #fff;
  font-weight: 600;
}

/* Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px;
}

.gallery-item {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(123, 47, 247, 0.2);
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(0,0,0,0.3);
}

.gallery-item:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
  transform: translateY(-2px);
}

.gallery-item canvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
}

.gallery-item .gi-info {
  padding: 8px;
}

.gallery-item .gi-name {
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}

.gallery-item .gi-desc {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  margin-top: 2px;
  line-height: 1.3;
}

/* Settings */
.settings-app {
  padding: 16px;
}

.settings-group {
  margin-bottom: 20px;
}

.settings-group h3 {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

.setting-row label {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
}

.setting-row select,
.setting-row input[type="range"] {
  width: 160px;
}

.setting-row select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(123, 47, 247, 0.3);
  border-radius: 4px;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.setting-row input[type="range"] {
  accent-color: var(--cyan);
}

/* About */
.about-app {
  text-align: center;
  padding: 30px 20px;
}

.about-logo {
  font-size: 64px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--cyan), var(--electric-purple), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

.about-version {
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  margin-bottom: 16px;
}

.about-tagline {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-style: italic;
  margin-bottom: 20px;
  line-height: 1.5;
}

.about-link {
  color: var(--cyan);
  text-decoration: none;
  font-size: 12px;
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 6px 16px;
  border-radius: 6px;
  display: inline-block;
  transition: all 0.2s;
}

.about-link:hover {
  background: rgba(0, 240, 255, 0.1);
}

/* BSOD */
.bsod-screen {
  position: fixed;
  inset: 0;
  background: #0a0a2e;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  text-align: center;
  padding: 40px;
}

.bsod-screen .bsod-face {
  font-size: 80px;
  margin-bottom: 20px;
}

.bsod-screen h1 {
  font-size: 28px;
  margin-bottom: 16px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.bsod-screen p {
  color: rgba(255,255,255,0.5);
  max-width: 500px;
  line-height: 1.6;
  margin-bottom: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(123, 47, 247, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(123, 47, 247, 0.5);
}