html,
body {
  height: 100%;
  margin: 0;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #202020;
  color: rgba(255, 255, 255, 0.90);
  overflow: hidden;
  touch-action: none;
}

#kernel-root {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#desktop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 20%, rgba(96, 205, 255, 0.08), #202020 60%);
  touch-action: none;
}


/* Session timer (session time remaining) */
#session-timer-overlay {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 35001;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.90);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  user-select: none;
  pointer-events: none;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

#session-timer-overlay.timer-green {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.35);
  color: rgba(187, 247, 208, 0.95);
}

#session-timer-overlay.timer-yellow {
  background: rgba(234, 179, 8, 0.18);
  border-color: rgba(234, 179, 8, 0.35);
  color: rgba(254, 240, 138, 0.95);
}

#session-timer-overlay.timer-red {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
  color: rgba(254, 202, 202, 0.95);
}

#drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 40000;
  display: none;
  cursor: grabbing;
  user-select: none;
}

#drag-overlay.active {
  display: block;
}

#drag-overlay .drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-9999px, -9999px);
  pointer-events: none;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(45, 45, 45, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 28px rgba(10, 10, 35, 0.6), 0 4px 8px rgba(10, 10, 35, 0.35);
  color: rgba(255, 255, 255, 0.90);
  font-size: 12px;
  max-width: 280px;
  backdrop-filter: blur(40px);
}

#drag-overlay .drag-ghost .title {
  font-weight: 700;
}

#drag-overlay .drag-ghost .meta {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
}

.window.drag-target {
  outline: 2px solid rgba(96, 205, 255, 0.50);
  outline-offset: -2px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(96, 205, 255, 0.20);
}

.window.no-outline,
.window.no-outline.drag-target {
  border: 0;
  outline: none;
  outline-offset: 0;
}

.window.no-outline.drag-target {
  box-shadow: none;
}

.window {
  position: absolute;
  top: 80px;
  left: 80px;
  width: 640px;
  height: 420px;
  background: rgba(45, 45, 45, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top-color: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: visible;
  box-shadow: 0 8px 24px rgba(10, 10, 30, 0.55), 0 4px 8px rgba(10, 10, 30, 0.4),
              0 0 0 1px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.window.animating {
  transition: left 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              top 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              width 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              height 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.window.minimizing {
  animation: minimizeOut 0.15s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

/* Win11-style: minimize toward taskbar button position */
.window.minimizing-to-taskbar {
  --min-tx: 0px;
  --min-ty: 0px;
  animation: minimizeToTaskbar 0.15s cubic-bezier(0.4, 0, 0.8, 1) forwards;
  pointer-events: none;
}

@keyframes minimizeOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.85) translateY(40px);
  }
}

@keyframes minimizeToTaskbar {
  from {
    opacity: 1;
    transform: scale(1) translate(0, 0);
  }
  to {
    opacity: 0;
    transform: scale(0.15) translate(var(--min-tx), var(--min-ty));
  }
}

.window.restoring-from-min {
  animation: restoreFromMin 0.15s cubic-bezier(0, 0, 0.2, 1) forwards;
}

@keyframes restoreFromMin {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.window.no-radius {
  border-radius: 0;
}

.window.no-radius .titlebar {
  border-radius: 0;
}

.window.no-radius .appframe,
.window.no-radius .appcanvas-wrap {
  border-radius: 0;
}

.resize-handle {
  position: absolute;
  z-index: 6;
  background: transparent;
}

.resize-n,
.resize-s {
  left: 8px;
  right: 8px;
  height: 8px;
}

.resize-e,
.resize-w {
  top: 8px;
  bottom: 8px;
  width: 8px;
}

.resize-n {
  top: -4px;
  cursor: ns-resize;
}

.resize-s {
  bottom: -4px;
  cursor: ns-resize;
}

.resize-e {
  right: -4px;
  cursor: ew-resize;
}

.resize-w {
  left: -4px;
  cursor: ew-resize;
}

.resize-ne,
.resize-nw,
.resize-se,
.resize-sw {
  width: 12px;
  height: 12px;
}

.resize-ne {
  top: -6px;
  right: -6px;
  cursor: nesw-resize;
}

.resize-nw {
  top: -6px;
  left: -6px;
  cursor: nwse-resize;
}

.resize-se {
  bottom: -6px;
  right: -6px;
  cursor: nwse-resize;
}

.resize-sw {
  bottom: -6px;
  left: -6px;
  cursor: nesw-resize;
}

.window.focused {
  border-color: rgba(96, 205, 255, 0.35);
  border-top-color: rgba(96, 205, 255, 0.5);
  box-shadow: 0 20px 40px rgba(10, 10, 35, 0.65), 0 8px 16px rgba(10, 10, 35, 0.45),
              0 0 0 1px rgba(0, 0, 0, 0.3);
}

.window.focused .titlebar {
  background: rgba(255, 255, 255, 0.06);
}

/* Mica-style titlebar: subtle tint, no blur (blur reserved for acrylic flyouts) */
.titlebar {
  height: 32px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  cursor: move;
  user-select: none;
  transition: background 0.2s ease, color 0.2s ease;
  border-radius: 8px 8px 0 0;
}

.window.focused .titlebar {
  color: rgba(255, 255, 255, 0.90);
}

/* Mica-style: very subtle noise, no blur on window body (unlike acrylic flyouts) */
.window::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px;
  border-radius: inherit;
}

/* Push window content above noise layer */
.window > *:not(.resize-handle) {
  position: relative;
  z-index: 1;
}

.titlebar .title-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Win11-style caption buttons: flat rectangles, no bg until hover */
.titlebar .title-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 32px;
  margin-left: 0;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  box-shadow: none;
  transition: background 0.1s ease, color 0.1s ease;
}

.titlebar .title-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.90);
  box-shadow: none;
}

.titlebar .title-btn:active {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

.titlebar .title-btn.close:hover {
  background: #c42b1c;
  color: #ffffff;
  box-shadow: none;
}

.titlebar .title-btn.close:active {
  background: #b4271a;
  color: rgba(255, 255, 255, 0.7);
  box-shadow: none;
}

.titlebar .title-btn svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.window.chrome-less .close-overlay {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: #e6e6e6;
  font-size: 14px;
  line-height: 18px;
  user-select: none;
  transition: background 0.12s ease, transform 0.1s ease;
}

.window.chrome-less .close-overlay:hover {
  background: rgba(0, 0, 0, 0.55);
}

.window.chrome-less .close-overlay:active {
  transform: scale(0.88);
  background: rgba(0, 0, 0, 0.65);
}

.appframe {
  width: 100%;
  height: calc(100% - 32px);
  border: 0;
  background: #2b2b2b;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  touch-action: none;
}

.appcanvas {
  width: 100%;
  height: calc(100% - 32px);
  border: 0;
  display: block;
  background: #000;
}

.appcanvas-wrap {
  width: 100%;
  height: calc(100% - 32px);
  background: #000;
  overflow: hidden;
  border-radius: 0 0 8px 8px;
}

.appcanvas-wrap .appcanvas {
  width: 100%;
  height: 100%;
}

.appcanvas-wrap:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.window.chrome-less .appcanvas-wrap {
  height: 100%;
}

.window.chrome-less .appcanvas {
  height: 100%;
}

.system-surface {
  position: absolute;
  top: 0;
  left: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  touch-action: none;
}

.system-surface .appframe {
  width: 100%;
  height: 100%;
  background: transparent;
  border-radius: 0;
}

.system-surface .appcanvas {
  width: 100%;
  height: 100%;
}

.system-surface .appcanvas-wrap {
  width: 100%;
  height: 100%;
}

.fullscreen-backdrop {
  position: fixed;
  inset: 0;
  background: #000;
}

.window.fullscreen {
  background: #000;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.window.fullscreen .titlebar {
  display: none;
}

.window.fullscreen .resize-handle {
  display: none;
}

.window.fullscreen .appframe,
.window.fullscreen .appcanvas {
  height: 100%;
}

.window.fullscreen .appcanvas-wrap {
  height: 100%;
}

.window.fullscreen .close-overlay {
  display: none;
}

/* Snap hint overlay */
#snap-hint {
  position: fixed;
  z-index: 39999;
  pointer-events: none;
  background: rgba(96, 165, 250, 0.12);
  border: 2px solid rgba(96, 165, 250, 0.45);
  border-radius: 8px;
  opacity: 0;
  transform: scale(0.96);
  box-shadow: 0 0 24px rgba(96, 165, 250, 0.1);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
              left 0.18s cubic-bezier(0.16, 1, 0.3, 1), top 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              width 0.18s cubic-bezier(0.16, 1, 0.3, 1), height 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

#snap-hint.visible {
  opacity: 1;
  transform: scale(1);
}

/* Win11-style window open: gentle scale-up, no spring overshoot */
.window.window-opening {
  animation: windowOpen 0.15s cubic-bezier(0, 0, 0.2, 1) forwards;
}

@keyframes windowOpen {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Win11-style window close: subtle fade-shrink */
.window.window-closing {
  animation: windowClose 0.15s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

@keyframes windowClose {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* Boot splash screen */
#boot-splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #101010;
  color: rgba(255, 255, 255, 0.90);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  transition: opacity 0.5s ease;
}

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

#boot-splash .boot-logo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 32px;
  opacity: 0.9;
}

#boot-splash .boot-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: rgba(96, 205, 255, 0.8);
  border-radius: 50%;
  animation: bootSpin 0.8s linear infinite;
}

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

/* ─── Global scrollbar styling ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Window loading spinner overlay */
.window-loading-overlay {
  position: absolute;
  inset: 0;
  top: 32px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 30, 0.85);
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}
.window-loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}
.window-loading-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: rgba(96, 165, 250, 0.85);
  border-radius: 50%;
  animation: loadSpin 0.7s linear infinite;
}
@keyframes loadSpin {
  to { transform: rotate(360deg); }
}

/* GPU-accelerated drag hint */
.window.dragging {
  will-change: left, top;
}

/* Alt+Tab switcher overlay */
#alt-tab-overlay {
  position: fixed;
  inset: 0;
  z-index: 90000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
#alt-tab-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
#alt-tab-list {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(40, 40, 40, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  max-width: 80vw;
  overflow-x: auto;
}
.alt-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 80px;
  max-width: 120px;
  transition: background 0.1s ease;
}
.alt-tab-item.selected {
  background: rgba(96, 165, 250, 0.25);
  outline: 2px solid rgba(96, 165, 250, 0.6);
}
.alt-tab-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.alt-tab-item .tab-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.alt-tab-item .tab-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.alt-tab-item .tab-title {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
}

/* Desktop context menu */
#desktop-context-menu {
  position: fixed;
  z-index: 80000;
  min-width: 200px;
  background: rgba(40, 40, 40, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: none;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
#desktop-context-menu.visible {
  display: block;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s ease;
}
.ctx-item:hover {
  background: rgba(96, 165, 250, 0.18);
}
.ctx-item svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.ctx-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}
