:root {
  --bg: #050505;
  --panel: #c0c0c0;
  --panel-light: #ffffff;
  --text: #000000;
  --desktop-text: #ffffff;
  --taskbar: #b7b7b7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  overflow: hidden;
  background:
    url("https://www.transparenttextures.com/patterns/stardust.png"),
    radial-gradient(circle at top, #0a1c1b 0%, #050505 50%, #000000 100%);
  font-family: "Verdana", "Tahoma", sans-serif;
  color: var(--desktop-text);
}

.hidden {
  display: none !important;
}

.desktop-shell {
  width: 100%;
  height: 100%;
  position: relative;
}

.topbar {
  height: 34px;
  border-bottom: 2px solid #00d9ff;
  background: linear-gradient(to right, #071919, #0f3b3b);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-family: "Comic Sans MS", cursive;
  color: #b9fff5;
  text-shadow: 0 0 6px rgba(0, 255, 213, 0.45);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-trigger {
  cursor: pointer;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #00ff73;
  box-shadow: 0 0 8px #00ff73;
}

.desktop {
  position: relative;
  width: 100%;
  height: calc(100% - 68px);
  overflow: hidden;
}

.desktop-icon {
  position: absolute;
  width: 86px;
  padding: 6px 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--desktop-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  font-family: "Comic Sans MS", cursive;
}

.desktop-icon:hover,
.desktop-icon:focus {
  border: 1px dashed rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.icon-frame {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 2px outset #dadada;
  background: linear-gradient(135deg, #0e0e0e, #1b1b1b);
  box-shadow: 0 0 10px rgba(0, 255, 213, 0.18);
}

.desktop-svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-user .desktop-svg { stroke: #9cffd7; }
.icon-folder .desktop-svg { stroke: #ffe27a; }
.icon-server .desktop-svg { stroke: #88d7ff; }
.icon-log .desktop-svg { stroke: #ffb2f6; }
.icon-terminal .desktop-svg { stroke: #68ff9a; }
.icon-network .desktop-svg { stroke: #9a8cff; }
.icon-exe .desktop-svg { stroke: #ff8f8f; }
.icon-music .desktop-svg { stroke: #ffd36b; }
.icon-debug .desktop-svg { stroke: #8effcf; }

.icon-label {
  font-size: 13px;
  line-height: 1.05;
  text-align: center;
  text-shadow: 1px 1px 0 #000;
}

.desktop-hotspot {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 34px;
  height: 34px;
  opacity: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}

.window {
  position: absolute;
  border-top: 2px solid var(--panel-light);
  border-left: 2px solid var(--panel-light);
  border-right: 2px solid #000;
  border-bottom: 2px solid #000;
  background: var(--panel);
  color: var(--text);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
  min-width: 280px;
  max-width: 92vw;
}

.hidden-window {
  display: none;
}

.titlebar {
  height: 28px;
  background: linear-gradient(to right, #000080, #1084d0);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  cursor: move;
  user-select: none;
  font-size: 13px;
  font-weight: bold;
}

.debug-titlebar {
  background: linear-gradient(to right, #1d0025, #009a95);
}

.titlebar-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}

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

.window-control,
.retro-button,
.start-button,
.start-item,
.taskbar-button,
.boot-button,
.taskbar-mini-button,
.tray-item,
.tiny-button,
.danger-button {
  font-family: "Tahoma", sans-serif;
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #4d4d4d;
  border-bottom: 2px solid #4d4d4d;
  background: #c0c0c0;
  color: #000;
}

.window-control {
  width: 22px;
  height: 20px;
  padding: 0;
  font-size: 12px;
  cursor: pointer;
}

.window-body {
  padding: 14px;
  line-height: 1.45;
  font-size: 14px;
}

.window-body p {
  margin-top: 0;
}

.retro-list {
  padding-left: 18px;
  margin: 8px 0 0;
}

.mini-status {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #103d3f;
}

.subtle-note {
  margin: 10px 0 0;
  color: #2d3d58;
  font-size: 13px;
}

.terminal-block {
  white-space: pre-wrap;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-card {
  background: #e2e2e2;
  padding: 10px;
  border: 2px inset #efefef;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-transform: lowercase;
}

.meter {
  width: 100%;
  height: 12px;
  border: 2px inset #efefef;
  background: #bcbcbc;
  overflow: hidden;
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, #00a651, #5dff9b);
  transition: width 0.35s ease;
}

.network-map {
  margin: 0;
  font-family: "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

.terminal-shell {
  background: #07110c;
  color: #76ffb8;
  border: 2px inset #1f1f1f;
  padding: 8px;
  font-family: "Courier New", monospace;
}

.terminal-output {
  min-height: 240px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 6px;
  white-space: pre-wrap;
}

.terminal-line {
  margin-bottom: 4px;
}

.terminal-line.error {
  color: #ff9e9e;
}

.terminal-line.warning {
  color: #ffe57d;
}

.terminal-line.success {
  color: #a7ffc7;
}

.terminal-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.terminal-prompt {
  color: #d6ffe8;
  white-space: nowrap;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #76ffb8;
  font: inherit;
}

.retro-button {
  padding: 6px 10px;
  cursor: pointer;
}

.taskbar {
  height: 34px;
  background: var(--taskbar);
  border-top: 2px solid #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
}

.start-button {
  padding: 4px 12px;
  font-weight: bold;
  cursor: pointer;
  min-width: 70px;
}

.taskbar-mini-button {
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  cursor: pointer;
}

.taskbar-buttons {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.taskbar-button {
  min-width: 120px;
  max-width: 200px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.taskbar-button.active {
  background: #dfdfdf;
}

.system-tray {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tray-item {
  min-width: 44px;
  height: 26px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
}

#tray-archer.online {
  color: #0a7a28;
}

#tray-network.online {
  color: #004aad;
}

#tray-alerts.has-alerts {
  color: #a10000;
}

#tray-popups.off {
  color: #7f0000;
  background: #ebc4c4;
}

#tray-popups.on {
  color: #0b6924;
}

#tray-music.playing {
  color: #7b0088;
}

.taskbar-clock {
  min-width: 78px;
  text-align: center;
  padding: 4px 8px;
  border: 2px inset #fff;
  font-size: 13px;
  background: #cfcfcf;
  color: #000;
}

.start-menu {
  position: absolute;
  left: 6px;
  bottom: 38px;
  width: 230px;
  background: #c0c0c0;
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #000;
  border-bottom: 2px solid #000;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 9998;
}

.start-menu-header {
  background: linear-gradient(to right, #5b005b, #da37da);
  color: white;
  padding: 8px;
  font-weight: bold;
  margin-bottom: 6px;
  font-family: "Comic Sans MS", cursive;
}

.start-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  margin-bottom: 4px;
  cursor: pointer;
}

.music-player {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.music-now-playing {
  border: 2px inset #efefef;
  background: #e7e7e7;
  padding: 10px;
}

.music-label {
  font-size: 12px;
  text-transform: lowercase;
  color: #3f3f3f;
  margin-bottom: 4px;
}

.music-track-title {
  font-weight: bold;
  color: #111;
  word-break: break-word;
}

.music-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.music-controls .retro-button {
  min-width: 56px;
}

.music-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.music-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #333;
}

.music-volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.music-volume-row input,
.music-progress-wrap input {
  flex: 1;
}

.music-playlist-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.music-playlist {
  max-height: 170px;
  overflow-y: auto;
  border: 2px inset #efefef;
  background: #e7e7e7;
  padding: 6px;
}

.music-playlist-item {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 4px;
  padding: 6px 8px;
  border: 1px solid #9a9a9a;
  background: #f2f2f2;
  cursor: pointer;
  font-family: "Tahoma", sans-serif;
  font-size: 13px;
}

.music-playlist-item:hover {
  background: #dfefff;
}

.music-playlist-item.active {
  background: #c8e6ff;
  border-color: #5f8db8;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(0, 255, 213, 0.08), transparent 40%),
    #000;
}

.boot-panel {
  width: min(720px, 92vw);
  min-height: 320px;
  border: 2px solid #00ffd5;
  background: rgba(0, 0, 0, 0.92);
  box-shadow: 0 0 20px rgba(0, 255, 213, 0.22);
  padding: 18px;
  font-family: "Courier New", monospace;
  color: #8effcf;
}

.boot-title {
  margin-bottom: 12px;
  color: #d9fff1;
  font-size: 18px;
}

.boot-log {
  margin: 0 0 16px;
  height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.3;
}

.boot-button {
  padding: 8px 14px;
  cursor: pointer;
}

.boot-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.crash-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 25000;
  display: grid;
  place-items: center;
}

.crash-text {
  color: #d6fce2;
  font-family: "Courier New", monospace;
  font-size: 18px;
  white-space: pre-wrap;
  text-align: left;
  text-shadow: 0 0 12px rgba(162, 255, 196, 0.35);
}

.debug-window {
  background: #aeb3b7;
}

.debug-shell {
  background: #cad0d4;
}

.debug-banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 2px inset #efefef;
  background: #e2e6e8;
  font-family: "Courier New", monospace;
  font-size: 13px;
}

.debug-version {
  cursor: pointer;
  user-select: none;
}

.debug-status-pill {
  color: #0f5250;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.debug-panel {
  min-height: 138px;
  border: 2px inset #efefef;
  background: #dde2e6;
  padding: 10px;
}

.debug-panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
}

.debug-pre,
.debug-list,
.debug-permissions,
.debug-buttons,
.debug-log {
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.debug-pre {
  margin: 0;
  white-space: pre-wrap;
}

.debug-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.debug-list li {
  margin-bottom: 4px;
}

.debug-permissions,
.debug-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tiny-button,
.danger-button {
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12px;
}

.danger-zone {
  background: #e8d7d7;
}

.danger-button {
  background: #e2c0c0;
}

.debug-log-wrap {
  margin-top: 12px;
  border: 2px inset #efefef;
  background: #e2e6e8;
  padding: 10px;
}

.debug-log {
  min-height: 82px;
  max-height: 120px;
  overflow-y: auto;
}

.window.jitter {
  animation: jitter 0.22s linear 4;
}

body.chaos-mode .topbar {
  animation: glowPulse 3s infinite alternate;
}

body.chaos-mode .icon-frame {
  box-shadow: 0 0 14px rgba(255, 70, 180, 0.18);
}

.window a {
  color: #0015cc;
}

.window a:hover {
  color: #8b00b8;
}

@keyframes jitter {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -2px); }
  100% { transform: translate(0, 0); }
}

@keyframes glowPulse {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(28deg); }
}

@media (max-width: 1100px) {
  .debug-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .window {
    width: min(92vw, 420px) !important;
  }

  .status-grid,
  .debug-grid {
    grid-template-columns: 1fr;
  }
}
