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

body {
  font-family: var(--font-mono, 'Courier New', monospace);
  background: var(--bg, #080808);
  color: var(--fg, #c8d4c0);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  user-select: none;
  cursor: default;
}

/* ── Desktop ── */
#desktop {
  position: absolute;
  inset: 0;
  bottom: 48px;
  overflow: hidden;
}

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

/* scanline overlay */
#desktop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px, transparent 3px,
    rgba(0,0,0,0.07) 3px, rgba(0,0,0,0.07) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* ── Desktop icons ── */
#desktop-icons {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  width: 78px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.app-icon:hover {
  background: rgba(0,255,65,0.07);
  border-color: rgba(0,255,65,0.2);
}
.app-icon.selected {
  background: rgba(0,255,65,0.12);
  border-color: rgba(0,255,65,0.38);
}

.icon-glyph {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--bg-raise, #131313);
  border: 1px solid var(--border, #242424);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
}
.icon-glyph::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, transparent 55%);
}
.app-icon:hover .icon-glyph {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5), 0 0 16px var(--icon-glow, rgba(0,255,65,0.2));
  border-color: rgba(255,255,255,0.12);
}

.icon-label {
  font-size: 0.61rem;
  color: rgba(255,255,255,0.72);
  text-align: center;
  line-height: 1.3;
  text-shadow: 0 1px 5px rgba(0,0,0,0.9);
}

/* ── Windows ── */
.os-window {
  position: absolute;
  min-width: 380px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  background: var(--bg, #080808);
  border: 1px solid var(--border, #242424);
  border-radius: 10px;
  box-shadow:
    0 2px 0 rgba(255,255,255,0.035) inset,
    0 18px 54px rgba(0,0,0,0.75),
    0 0 0 1px rgba(0,0,0,0.5);
  overflow: hidden;
  z-index: 100;
  transition: box-shadow 0.15s;
}
.os-window.focused {
  border-color: rgba(0,255,65,0.28);
  box-shadow:
    0 2px 0 rgba(0,255,65,0.05) inset,
    0 22px 64px rgba(0,0,0,0.85),
    0 0 0 1px rgba(0,255,65,0.07),
    0 0 28px rgba(0,255,65,0.05);
}
.os-window.minimized { display: none; }
.os-window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: calc(100vh - 48px) !important;
  border-radius: 0 !important;
}

@keyframes winOpen {
  from { opacity: 0; transform: scale(0.93) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.os-window.opening { animation: winOpen 0.2s cubic-bezier(0.34, 1.5, 0.64, 1); }

/* ── Titlebar ── */
.win-titlebar {
  height: 38px;
  background: var(--bg-raise, #131313);
  border-bottom: 1px solid var(--border, #242424);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  cursor: move;
  flex-shrink: 0;
  position: relative;
}
.win-titlebar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.025) 0%, transparent 100%);
  pointer-events: none;
}

.wc-group { display: flex; gap: 7px; flex-shrink: 0; }
.wc {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: filter 0.1s, transform 0.1s;
  flex-shrink: 0;
}
.wc:hover { filter: brightness(1.3); transform: scale(1.12); }
.wc.close    { background: #ff5f57; box-shadow: 0 0 0 1px rgba(200,40,40,0.4); }
.wc.minimize { background: #febc2e; box-shadow: 0 0 0 1px rgba(180,130,0,0.4); }
.wc.maximize { background: #28c840; box-shadow: 0 0 0 1px rgba(20,160,40,0.4); }

.win-icon  { font-size: 0.9rem; opacity: 0.65; flex-shrink: 0; }
.win-title {
  flex: 1;
  font-size: 0.68rem;
  color: var(--fg-dim, #555);
  text-align: center;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* ── Window body ── */
.win-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.win-body iframe {
  width: 100%; height: 100%;
  border: none; display: block;
}
.win-body.drag-shield::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 9999;
  cursor: inherit;
}

/* ── Resize handle ── */
.resize-grip {
  position: absolute;
  bottom: 0; right: 0;
  width: 18px; height: 18px;
  cursor: se-resize;
  z-index: 10;
}
.resize-grip::before {
  content: '';
  position: absolute;
  bottom: 4px; right: 4px;
  width: 10px; height: 10px;
  border-right: 1.5px solid rgba(255,255,255,0.12);
  border-bottom: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 0 0 2px 0;
}

/* ── Taskbar ── */
#taskbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 48px;
  background: rgba(8,8,8,0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border, #242424);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  z-index: 9000;
}
#taskbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,255,65,0.012) 0%, transparent 100%);
  pointer-events: none;
}

#start-btn {
  height: 32px;
  padding: 0 14px;
  background: rgba(0,255,65,0.08);
  border: 1px solid rgba(0,255,65,0.22);
  border-radius: 7px;
  color: var(--green, #00ff41);
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
#start-btn:hover, #start-btn.active {
  background: rgba(0,255,65,0.15);
  box-shadow: 0 0 18px rgba(0,255,65,0.14);
}

.start-icon { font-size: 0.95em; }

.tb-sep {
  width: 1px; height: 22px;
  background: var(--border, #242424);
  flex-shrink: 0;
}

#tb-apps {
  flex: 1;
  display: flex;
  gap: 4px;
  overflow: hidden;
  align-items: center;
}

.tb-app {
  height: 32px;
  padding: 0 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  color: rgba(255,255,255,0.42);
  font-family: var(--font-mono, monospace);
  font-size: 0.67rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.1s;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
}
.tb-app:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); }
.tb-app.active {
  background: rgba(0,255,65,0.09);
  border-color: rgba(0,255,65,0.24);
  color: var(--green, #00ff41);
}
.tb-app.is-min {
  opacity: 0.5;
  border-style: dashed;
}

#tb-clock {
  font-family: var(--font-mono, monospace);
  font-size: 0.69rem;
  color: rgba(255,255,255,0.38);
  text-align: right;
  line-height: 1.5;
  flex-shrink: 0;
  padding-right: 2px;
}

.tb-clock-date {
  font-size: 0.59rem;
  opacity: 0.55;
  display: block;
}

/* ── Launcher ── */
#launcher {
  position: fixed;
  bottom: 54px;
  left: 12px;
  width: 238px;
  background: var(--bg-raise, #131313);
  border: 1px solid var(--border, #242424);
  border-radius: 12px;
  padding: 14px;
  z-index: 8999;
  box-shadow: 0 -14px 48px rgba(0,0,0,0.75), 0 0 0 1px rgba(255,255,255,0.025);
  display: none;
  animation: launcherIn 0.14s ease-out;
}
@keyframes launcherIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#launcher.open { display: block; }

.launcher-hdr {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.22);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

#launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.launcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.launcher-item:hover {
  background: rgba(0,255,65,0.07);
  border-color: rgba(0,255,65,0.15);
}
.launcher-item-icon {
  width: 40px; height: 40px;
  background: var(--bg, #080808);
  border: 1px solid var(--border, #242424);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.launcher-item-label {
  font-size: 0.57rem;
  color: rgba(255,255,255,0.48);
  text-align: center;
  line-height: 1.2;
}

/* ── Power button ── */
.power-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--green, #00ff41);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.power-btn:hover {
  color: var(--red, #ff5f57);
  border-color: rgba(255,95,87,0.4);
  box-shadow: 0 0 16px rgba(255,95,87,0.2);
}
.power-btn:active { transform: scale(0.93); }
