/* ============================================================
   SIJY OS - stylesheet
   palette: void-black / ghost-white / alert-red
   chrome: classic Win95 bevels, recolored for the dark side
   ============================================================ */

:root {
  --void: #0a0a0a;          /* desktop / deep background */
  --panel: #161616;         /* window chrome */
  --panel-2: #1f1f1f;       /* raised surfaces */
  --inset: #0d0d0d;         /* sunken surfaces (inputs, canvases) */
  --ghost: #e8e8e8;         /* primary text */
  --dim: #8f8f8f;           /* secondary text */
  --alert: #ff2a2a;         /* accent */
  --alert-deep: #7e0d0d;    /* accent, dark end of gradients */
  --alert-glow: rgba(255, 42, 42, 0.35);
  --alert-soft: #ffb3b3;   /* light accent: strings, builtins, soft red */

  --bv-hi: #4a4a4a;         /* bevel highlight */
  --bv-lo: #000000;         /* bevel shadow */
  --bv-mid: #2c2c2c;

  --taskbar-h: 40px;
  --titlebar-h: 28px;

  --font-ui: Tahoma, Verdana, "Segoe UI", sans-serif;
  --font-mono: "VT323", "Cascadia Mono", Consolas, monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ghost);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
::selection { background: var(--alert); color: var(--void); }

/* the hidden attribute must always win, even over display: flex */
[hidden] { display: none !important; }

/* classic bevels */
.bevel-out { border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi); background: var(--panel); }
.bevel-in  { border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo); background: var(--inset); }

/* ============ BOOT SCREEN ============ */
#boot {
  position: fixed; inset: 0; z-index: 9000;
  background: var(--void);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 16px;
  font-family: var(--font-mono);
}
#boot-logo { color: var(--alert); font-size: 11px; line-height: 1.1; text-shadow: 0 0 12px var(--alert-glow); user-select: none; }
#boot-lines { min-height: 110px; width: min(520px, 92vw); color: var(--dim); font-family: var(--font-mono); font-size: 17px; line-height: 1.35; }
#boot-lines .ok { color: var(--ghost); }
#boot-lines .ok b { color: var(--alert); font-weight: normal; }
#boot-bar-wrap { width: min(520px, 92vw); height: 18px; border: 2px solid var(--ghost); padding: 2px; }
#boot-bar { height: 100%; width: 0%; background: repeating-linear-gradient(90deg, var(--alert) 0 10px, transparent 10px 14px); transition: width .15s steps(4); }
#boot-hint { color: var(--ghost); font-family: var(--font-mono); font-size: 20px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ============ DESKTOP ============ */
#desktop {
  position: fixed; inset: 0 0 var(--taskbar-h) 0;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(255, 42, 42, 0.06), transparent 60%),
    var(--void);
  overflow: hidden;
}

#watermark {
  position: absolute; right: 14px; bottom: 10px;
  text-align: right; color: var(--dim); opacity: .55;
  font-family: var(--font-mono); font-size: 20px; line-height: 1.05;
  user-select: none; cursor: default;
}
#watermark span { font-size: 12px; font-family: var(--font-ui); }

/* desktop icons: absolutely positioned on an invisible grid */
#icons {
  position: absolute; inset: 8px;
  pointer-events: none;
}
.dicon {
  position: absolute;
  pointer-events: auto;
  width: 86px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 1px dotted transparent;
  user-select: none; -webkit-user-select: none; cursor: default;
  touch-action: none; /* we handle drag ourselves */
  transition: left .22s ease, top .22s ease; /* snap + snake slither */
}
.dicon.dragging { transition: none; z-index: 60; opacity: .85; cursor: grabbing; }
#icons.snake-mode .dicon { transition: left .15s linear, top .15s linear, opacity .4s; cursor: default; }
#icons.snake-mode .dicon:not(.snake-seg) { opacity: .18; } /* spectators */
#icons.snake-mode .snake-seg { opacity: 1; filter: drop-shadow(0 0 6px var(--alert-glow)); }
.snake-food {
  position: absolute; width: 40px; height: 40px; pointer-events: none;
  animation: food-pulse .8s ease-in-out infinite alternate;
}
.snake-food svg { width: 100%; height: 100%; display: block; }
@keyframes food-pulse { from { transform: scale(.85); } to { transform: scale(1.1); } }
.dicon.selected { border-color: var(--alert); background: rgba(255, 42, 42, 0.08); }
.dicon .glyph { width: 40px; height: 40px; }
.dicon .glyph svg { width: 100%; height: 100%; display: block; filter: drop-shadow(2px 2px 0 rgba(0,0,0,.8)); }
.dicon .label { font-size: 11px; text-align: center; color: var(--ghost); text-shadow: 1px 1px 0 #000; line-height: 1.2; word-break: break-word; }
.dicon.wiggle { animation: wiggle .4s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

/* ============ WINDOWS ============ */
#windows { position: absolute; inset: 0; pointer-events: none; } /* layer must not eat desktop clicks */
.window { pointer-events: auto; } /* parent-agnostic: modals live in #overlays */

.window {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 220px; min-height: 140px;
  background: var(--panel);
  border: 2px solid;
  border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  outline: 1px solid #000;
}
.window.maximized { box-shadow: none; }

.titlebar {
  height: var(--titlebar-h); flex: 0 0 var(--titlebar-h);
  display: flex; align-items: center; gap: 6px;
  padding: 0 4px 0 8px;
  background: linear-gradient(90deg, #2a2a2a, #1a1a1a);
  color: var(--dim);
  user-select: none; -webkit-user-select: none;
  touch-action: none;            /* critical: no scroll/zoom while dragging */
  cursor: default;
}
.window.focused .titlebar {
  background: linear-gradient(90deg, var(--alert-deep), var(--alert));
  color: var(--void);
}
.window.focused .titlebar .t-title { color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.45); }
.titlebar .t-icon { width: 16px; height: 16px; flex: 0 0 16px; }
.titlebar .t-icon svg { width: 100%; height: 100%; display: block; }
.titlebar .t-title {
  flex: 1; font-weight: bold; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win-btn {
  width: 22px; height: 20px; flex: 0 0 22px;
  display: grid; place-items: center;
  font-family: var(--font-ui); font-size: 11px; font-weight: bold; line-height: 1;
  background: var(--panel-2); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  touch-action: manipulation;
}
.win-btn:active { border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo); }
.win-btn.close:hover { background: var(--alert); color: var(--void); }

.win-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}

.resize-handle {
  position: absolute; right: 0; bottom: 0;
  width: 22px; height: 22px; z-index: 5;
  cursor: nwse-resize;
  touch-action: none;
  background:
    linear-gradient(135deg, transparent 50%, var(--bv-hi) 50% 56%, transparent 56% 66%,
      var(--bv-hi) 66% 72%, transparent 72% 82%, var(--bv-hi) 82% 88%, transparent 88%);
}
.window.maximized .resize-handle { display: none; }

/* invisible resize strips on every edge and corner (windows-style).
   corners come after edges in source order, so they win the overlap */
.rh { position: absolute; z-index: 5; touch-action: none; }
.rh-n  { top: -3px; left: 12px; right: 12px; height: 7px; cursor: ns-resize; }
.rh-s  { bottom: -3px; left: 12px; right: 12px; height: 7px; cursor: ns-resize; }
.rh-e  { right: -3px; top: 12px; bottom: 12px; width: 7px; cursor: ew-resize; }
.rh-w  { left: -3px; top: 12px; bottom: 12px; width: 7px; cursor: ew-resize; }
.rh-ne { top: -3px; right: -3px; width: 16px; height: 16px; cursor: nesw-resize; }
.rh-nw { top: -3px; left: -3px; width: 16px; height: 16px; cursor: nwse-resize; }
.rh-se { bottom: -3px; right: -3px; width: 18px; height: 18px; cursor: nwse-resize; }
.rh-sw { bottom: -3px; left: -3px; width: 16px; height: 16px; cursor: nesw-resize; }
.window.maximized .rh { display: none; }

/* generic app furniture */
.toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 4px; background: var(--panel);
  border-bottom: 1px solid var(--bv-lo);
}
.tb-btn {
  padding: 4px 10px; font-size: 12px;
  background: var(--panel-2); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  touch-action: manipulation; white-space: nowrap;
}
.tb-btn:active, .tb-btn.active { border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo); background: var(--inset); }
.tb-btn.active { color: var(--alert); }
.tb-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: var(--bv-mid); }

.statusbar {
  flex: 0 0 auto;
  display: flex; gap: 12px; align-items: center;
  padding: 3px 8px; font-size: 11px; color: var(--dim);
  border-top: 1px solid var(--bv-hi); background: var(--panel);
  white-space: nowrap; overflow: hidden;
}

/* ============ TASKBAR ============ */
#taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--taskbar-h);
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  background: var(--panel);
  border-top: 2px solid var(--bv-hi);
  z-index: 8000;
}
#start-btn {
  height: 100%; padding: 0 12px 0 8px;
  display: flex; align-items: center; gap: 6px;
  font-weight: bold; font-size: 13px; color: var(--ghost);
  touch-action: manipulation;
}
#start-btn .start-logo { color: var(--alert); font-size: 16px; }
#start-btn:active, #start-btn.open { border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo); background: var(--inset); }

#task-items { flex: 1; display: flex; gap: 4px; overflow-x: auto; height: 100%; scrollbar-width: none; }
#task-items::-webkit-scrollbar { display: none; }
.task-item {
  flex: 0 1 170px; min-width: 90px; height: 100%;
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px; font-size: 12px; color: var(--ghost);
  background: var(--panel-2);
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  overflow: hidden; white-space: nowrap;
  touch-action: manipulation;
}
.task-item .ti-icon { width: 14px; height: 14px; flex: 0 0 14px; }
.task-item .ti-icon svg { width: 100%; height: 100%; display: block; }
.task-item span { overflow: hidden; text-overflow: ellipsis; }
.task-item.active { border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo); background: var(--inset); color: var(--alert); }

#tray { height: 100%; display: flex; align-items: center; gap: 8px; padding: 0 10px; }
#snd-toggle { font-size: 15px; color: var(--ghost); padding: 0 4px; touch-action: manipulation; }
#snd-toggle.muted { color: var(--dim); text-decoration: line-through; }
#clock { font-family: var(--font-mono); font-size: 19px; color: var(--ghost); user-select: none; min-width: 52px; text-align: center; }

/* ============ VIBES MIXER ============ */
#mixer {
  position: fixed; right: 6px; bottom: calc(var(--taskbar-h) + 2px);
  z-index: 8500; width: 240px;
  background: var(--panel);
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  padding: 8px 10px 10px;
}
.mx-title {
  font-size: 12px; color: var(--dim); letter-spacing: 1px;
  border-bottom: 1px solid var(--bv-lo); padding-bottom: 5px; margin-bottom: 8px;
  user-select: none;
}
.mx-row { display: flex; align-items: center; gap: 8px; }
.mx-icon { color: var(--ghost); font-size: 15px; user-select: none; }
#mx-pct { font-family: var(--font-mono); font-size: 15px; color: var(--ghost); min-width: 42px; text-align: right; }
#mx-slider {
  flex: 1; appearance: none; -webkit-appearance: none; height: 4px;
  background: var(--bv-lo); outline: none; touch-action: none;
}
#mx-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 22px; background: var(--ghost); cursor: pointer;
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
}
#mx-slider::-moz-range-thumb {
  width: 14px; height: 22px; background: var(--ghost); cursor: pointer; border-radius: 0;
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
}
.mx-caption { font-size: 12px; color: var(--dim); margin: 7px 0 9px; min-height: 14px; user-select: none; }
#mx-mute { width: 100%; }
#mx-mute.on { background: var(--alert); color: var(--void); }

/* ============ START MENU ============ */
#start-menu {
  position: fixed; left: 6px; bottom: calc(var(--taskbar-h) + 2px);
  display: flex; z-index: 8500;
  background: var(--panel);
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  min-width: 230px;
}
.sm-side {
  width: 30px; background: linear-gradient(180deg, var(--alert), var(--alert-deep));
  display: flex; align-items: flex-end; justify-content: center; padding: 8px 0;
}
.sm-side span {
  writing-mode: vertical-rl; transform: rotate(180deg);
  color: #fff; font-weight: bold; font-size: 16px; letter-spacing: 2px;
  text-shadow: 1px 1px 0 rgba(0,0,0,.4); user-select: none;
}
.sm-items { display: flex; flex-direction: column; padding: 4px; flex: 1; }
.sm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; font-size: 13px; color: var(--ghost);
  text-align: left; touch-action: manipulation;
}
.sm-item .glyph { width: 22px; height: 22px; flex: 0 0 22px; }
.sm-item .glyph svg { width: 100%; height: 100%; display: block; }
.sm-item:hover, .sm-item:active { background: var(--alert); color: var(--void); }
.sm-divider { height: 1px; background: var(--bv-mid); margin: 4px 2px; }

/* ============ APP: NOTEPAD ============ */
.notepad-area {
  flex: 1; min-height: 0; resize: none; outline: none;
  background: var(--inset); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
  margin: 4px;
  padding: 8px; font-family: var(--font-mono); font-size: 18px; line-height: 1.35;
  white-space: pre-wrap;
}

/* ============ APP: PAINT ============ */
.paint-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--inset); margin: 4px; border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo); display: grid; place-items: center; }
.paint-canvas { background: #0f0f0f; cursor: crosshair; touch-action: none; image-rendering: pixelated; }
.paint-palette { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 20px; height: 20px;
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  touch-action: manipulation;
}
.swatch.active { outline: 2px solid var(--alert); outline-offset: 1px; }
.paint-size { width: 80px; accent-color: var(--alert); }

/* ============ APP: TERMINAL ============ */
.term {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--void); padding: 8px 10px;
  font-family: var(--font-mono); font-size: 18px; line-height: 1.3;
  color: var(--ghost); cursor: text;
  overscroll-behavior: contain;
}
.term .t-out { white-space: pre-wrap; word-break: break-word; }
.term .t-out .red { color: var(--alert); }
.term .t-out .dim { color: var(--dim); }
.term .t-line { display: flex; flex-wrap: wrap; }
.term .t-prompt { color: var(--alert); margin-right: 8px; white-space: nowrap; }
.term .t-input {
  flex: 1; min-width: 60px;
  background: transparent; border: none; outline: none;
  color: var(--ghost); font: inherit; caret-color: var(--alert);
}

/* ============ APP: SCRIPTLAB ============ */
.sl-split { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 4px; padding: 4px; }
/* syntax highlight: a <pre> painted behind a transparent <textarea>.
   both MUST share font, padding, line-height and white-space exactly,
   or the caret drifts off the colored text. */
.sl-editwrap {
  flex: 3; min-height: 0; position: relative; overflow: hidden;
  background: var(--inset);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
}
.sl-hl, .sl-editor {
  font-family: var(--font-mono); font-size: 17px; line-height: 1.3;
  white-space: pre; tab-size: 2; padding: 8px; margin: 0;
  border: none; box-sizing: border-box;
}
.sl-hl {
  position: absolute; inset: 0; overflow: hidden;
  color: var(--ghost); pointer-events: none; user-select: none;
}
.sl-editor {
  position: absolute; inset: 0; width: 100%; height: 100%;
  resize: none; outline: none; overflow: auto;
  background: transparent;
  color: transparent; caret-color: var(--alert);
}
.sl-editor::selection { background: var(--alert-glow); color: transparent; }
/* token colors - same palette as the rest of the OS */
.h-kw  { color: var(--alert); }                 /* let fn if while ... */
.h-lit { color: var(--alert); font-style: italic; } /* true false null */
.h-fn  { color: var(--alert-soft); }            /* builtins */
.h-str { color: var(--alert-soft); }            /* "strings" */
.h-num { color: #fff; }                         /* numbers */
.h-com { color: var(--dim); font-style: italic; } /* // comments */
.sl-divider {
  height: 12px; flex: 0 0 12px; cursor: ns-resize; touch-action: none;
  background: var(--panel-2);
  border: 1px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  display: grid; place-items: center; user-select: none;
}
.sl-divider::before {
  content: ""; width: 44px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--dim) 0 4px, transparent 4px 8px);
}
.sl-divider:hover::before { background: repeating-linear-gradient(90deg, var(--alert) 0 4px, transparent 4px 8px); }
.sl-output {
  flex: 2; min-height: 0; overflow-y: auto;
  background: var(--void); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
  padding: 8px; font-family: var(--font-mono); font-size: 17px; line-height: 1.3;
  white-space: pre-wrap; word-break: break-word;
}
.sl-output .err { color: var(--alert); }
.sl-select {
  background: var(--panel-2); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
  font: inherit; font-size: 12px; padding: 3px;
}

/* ============ APP: PASSGEN ============ */
.pg-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.pg-row { display: flex; gap: 8px; align-items: center; }
.pg-out {
  flex: 1; min-width: 60px;
  background: var(--inset); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
  font-family: var(--font-mono); font-size: 17px; padding: 6px 8px;
}
.pg-label { font-size: 12px; color: var(--dim); min-width: 84px; user-select: none; }
.pg-slider {
  flex: 1; appearance: none; -webkit-appearance: none; height: 4px;
  background: var(--bv-lo); outline: none; touch-action: none;
}
.pg-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 22px; background: var(--ghost); cursor: pointer;
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
}
.pg-slider::-moz-range-thumb {
  width: 14px; height: 22px; background: var(--ghost); cursor: pointer; border-radius: 0;
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
}
.pg-opts { display: flex; flex-direction: column; gap: 6px; }
.pg-check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ghost); cursor: pointer; user-select: none; }
.pg-check input { accent-color: var(--alert); width: 15px; height: 15px; }
.pg-meter { height: 8px; background: var(--inset); border: 1px solid var(--bv-lo); }
.pg-meter-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--alert-deep), var(--alert)); transition: width .15s; }
.pg-caption { font-size: 12px; color: var(--dim); min-height: 14px; }
.pg-gen { align-self: flex-start; padding: 6px 18px; }

/* ============ APP: MAZE3D ============ */
.maze-wrap {
  flex: 1; min-height: 0; margin: 4px; overflow: hidden;
  background: var(--void); display: grid; place-items: center;
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
}
.maze-screen {
  margin: 0; font-family: var(--font-mono); line-height: 1;
  color: var(--ghost); text-shadow: 0 0 4px rgba(232, 232, 232, .25);
  user-select: none; white-space: pre;
}
.maze-screen .mz-x { color: var(--alert); text-shadow: 0 0 8px var(--alert-glow); } /* the exit glows */
.maze-screen .mz-f { color: var(--dim); text-shadow: none; }                        /* floor stays humble */
.maze-pad { display: flex; gap: 6px; padding: 0 4px 4px; }
.maze-btn { flex: 1; font-size: 18px; padding: 8px 0; touch-action: none; user-select: none; }
@media (hover: hover) and (pointer: fine) {
  .maze-pad { display: none; } /* desktop has a keyboard, the pad is for thumbs */
}

/* ============ HACK / DEFENDER ============ */
.modal-block {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(10, 10, 10, .55);
  animation: mb-pulse 1.6s ease-in-out infinite alternate;
  cursor: not-allowed;
}
@keyframes mb-pulse { from { background: rgba(10,10,10,.5); } to { background: rgba(40,6,6,.6); } }
.hack-sweep {
  position: fixed; inset: 0; z-index: 8990; pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, var(--alert-glow) 50%, transparent 100%);
  background-size: 100% 30%;
  background-repeat: no-repeat;
  animation: hack-scan .7s linear infinite;
  mix-blend-mode: screen;
}
@keyframes hack-scan { from { background-position: 0 -30%; } to { background-position: 0 130%; } }
.av-window {
  z-index: 9100 !important; /* sibling of .modal-block in #overlays; the wm must not sink it */
  animation: av-breathe 2.4s ease-in-out infinite, av-arrive .45s cubic-bezier(.2, 1.6, .4, 1);
  box-shadow: 0 0 0 2px var(--alert-deep), 0 0 36px var(--alert-glow), 6px 6px 0 rgba(0,0,0,.6) !important;
}
@keyframes av-breathe {
  0%, 100% { transform: scale(1) rotate(0deg); }
  30% { transform: scale(1.012) rotate(.25deg); }
  65% { transform: scale(1.004) rotate(-.3deg); }
}
/* the knock: clicking the blocker rattles the window - deal with it first */
.av-window.av-knock { animation: av-knock .3s ease, av-breathe 2.4s ease-in-out .3s infinite; }
@keyframes av-knock {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px) rotate(-.6deg); }
  55% { transform: translateX(6px) rotate(.5deg); }
  80% { transform: translateX(-3px); }
}
@keyframes av-arrive {
  0% { transform: scale(.4) rotate(-5deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ============ APP: HEARTH ============ */
/* night colors are scene-local on purpose, same exception as the shutdown window */
.hh-scene {
  flex: 1; min-height: 200px; position: relative; overflow: hidden;
  margin: 4px;
  background: linear-gradient(180deg, #04050e 0%, #0a0c1a 60%, #14100c 100%);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
  transition: filter 6s ease;
  touch-action: none; /* the marshmallow follows fingers too */
}
.hh-scene.hh-late { filter: hue-rotate(-25deg) brightness(1.12); }
.hh-stars { position: absolute; inset: 0; }
.hh-stars i {
  position: absolute; width: 2px; height: 2px; background: #dfe6ff;
  animation: hh-twinkle 3s ease-in-out infinite alternate;
}
@keyframes hh-twinkle { from { opacity: .25; } to { opacity: 1; } }
.hh-fire { position: absolute; inset: 0; width: 100%; height: 100%; }

/* the stick: js drives left/top so the mallow sits under the cursor */
.hh-stick {
  position: absolute; width: 86px; height: 3px;
  background: linear-gradient(90deg, #6a4a2e, #4a3220);
  transform: rotate(26deg);
  transform-origin: left center;
  pointer-events: none;
  z-index: 4;
}
.hh-mallow {
  position: absolute; left: -9px; top: -8px; width: 17px; height: 15px;
  background: #f3ecdf; border-radius: 5px;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.12);
}
.hh-mallow.hh-burning { box-shadow: 0 0 8px rgba(255,140,50,.9), inset -2px -2px 0 rgba(0,0,0,.35); }
.hh-mallow.hh-burning::after {
  content: ""; position: absolute; left: 4px; top: -12px; width: 9px; height: 13px;
  background: radial-gradient(ellipse at 50% 90%, #ffd27a 0%, #ff6e28 55%, transparent 75%);
  border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%;
  animation: hh-mfire .14s ease-in-out infinite alternate;
}
@keyframes hh-mfire { from { transform: scaleY(1) rotate(-4deg); } to { transform: scaleY(1.25) rotate(5deg); } }

/* the phantom moon (egg #22): pale, slightly out of focus, easily offended */
.hh-phantom {
  position: absolute; width: 22px; height: 22px;
  border-radius: 50%; background: #cfd4dd;
  opacity: .55; filter: blur(.7px);
  box-shadow: 0 0 12px rgba(207, 212, 221, .5), inset -4px -3px 0 rgba(90, 98, 116, .55);
  cursor: pointer; z-index: 3;
  animation: hh-phantom-in 1.8s ease both;
  transition: opacity .3s, transform .3s;
}
.hh-phantom:hover { opacity: .8; }
.hh-phantom.hh-poof { opacity: 0; transform: scale(.15) rotate(40deg); pointer-events: none; }
@keyframes hh-phantom-in { from { opacity: 0; } to { opacity: .55; } }

.hh-caption {
  position: absolute; left: 0; right: 0; bottom: 8px; text-align: center;
  font-size: 12px; color: var(--dim); text-shadow: 1px 1px 0 #000;
  padding: 0 10px; pointer-events: none;
}

/* after the supernova: black. just black. reopen the app to wake up */
.hh-scene.hh-dead { background: #020203; filter: none; }
.hh-scene.hh-dead .hh-stars, .hh-scene.hh-dead .hh-fire { display: none; }
.hh-dead-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center; color: #2e3140; font-size: 14px; padding: 0 18px;
  animation: hh-deadin 4s ease both;
}
@keyframes hh-deadin { from { opacity: 0; } to { opacity: 1; } }

.hh-controls { display: flex; align-items: center; gap: 10px; padding: 6px; flex-wrap: wrap; }
.hh-scope { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.hh-scope-label { font-size: 12px; color: var(--dim); }
.hh-dial {
  flex: 1; appearance: none; -webkit-appearance: none; height: 4px;
  background: var(--bv-lo); outline: none; touch-action: none; min-width: 80px;
}
.hh-dial::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 22px; background: var(--ghost); cursor: pointer;
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
}
.hh-dial::-moz-range-thumb {
  width: 14px; height: 22px; background: var(--ghost); cursor: pointer; border-radius: 0;
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
}
.hh-signal { font-size: 12px; color: var(--dim); min-width: 120px; }
.hh-signal.tuned { color: var(--alert-soft); }

/* ============ APP: EXPLORER ============ */
.fx-addr { padding: 4px; }
.fx-addr input {
  width: 100%; box-sizing: border-box;
  background: var(--inset); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
  font-family: var(--font-mono); font-size: 16px; padding: 4px 8px;
}
.fx-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 2px; }
.fx-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  text-align: left; font-size: 13px; color: var(--ghost);
  border: 1px dotted transparent; touch-action: manipulation;
}
.fx-item:hover { background: rgba(255, 42, 42, .08); }
.fx-item.selected { border-color: var(--alert); background: rgba(255, 42, 42, .12); }
.fx-item .fx-icon { width: 22px; height: 22px; flex: 0 0 22px; }
.fx-item .fx-icon svg { width: 100%; height: 100%; display: block; }
.fx-item .fx-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-item.fx-hidden { opacity: .5; } /* hidden/system: present, but shy */
.fx-tag { font-size: 10px; color: var(--alert); border: 1px solid var(--alert-deep); padding: 1px 5px; }

/* confirm dialog */
.dlg-confirm { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.dc-text { font-size: 13px; color: var(--ghost); line-height: 1.45; flex: 1; }
.dc-row { display: flex; gap: 8px; justify-content: flex-end; }
.dc-yes { background: var(--alert-deep); color: #fff; }
.dc-yes:hover { background: var(--alert); color: var(--void); }

/* ============ PET SPEECH BUBBLE ============ */
.pet-bubble {
  position: absolute; left: 14px; bottom: 132px; z-index: 55;
  width: 230px; padding: 10px;
  background: var(--panel);
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  animation: bubble-in .25s ease;
}
.pet-bubble::after {
  content: ""; position: absolute; left: 26px; bottom: -10px;
  border: 10px solid transparent; border-top-color: var(--panel);
  border-bottom: none;
}
.pb-text { font-size: 12px; color: var(--ghost); line-height: 1.45; margin-bottom: 9px; }
.pb-row { display: flex; gap: 6px; justify-content: flex-end; }
.pb-stop { color: var(--alert); }
@keyframes bubble-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ THE PET (bottom-left lottie) ============ */
#pet {
  position: absolute; left: 8px; bottom: 8px;
  width: 110px; height: 110px; z-index: 50;
  cursor: pointer; user-select: none;
  filter: drop-shadow(2px 3px 0 rgba(0,0,0,.55));
}
#pet.zoomies { animation: pet-bounce .3s ease-in-out infinite alternate; }
@keyframes pet-bounce { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-10px) rotate(3deg); } }

/* ============ ANTIVIRUS POPUP ============ */
.av-body { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.av-head { display: flex; align-items: center; gap: 10px; color: var(--alert); font-size: 15px; letter-spacing: 1px; }
.av-shield { width: 26px; height: 26px; flex: 0 0 26px; }
.av-shield svg { width: 100%; height: 100%; display: block; }
.av-text { font-size: 13px; color: var(--ghost); line-height: 1.4; }
.av-text.dim { color: var(--dim); }
.av-ok { align-self: flex-end; margin-top: auto; padding: 5px 16px; }

/* ============ MATRIX-IN-A-WINDOW ============ */
.win-body { position: relative; } /* hosts overlays like the terminal matrix */
.matrix-host { position: absolute; inset: 0; z-index: 6; cursor: pointer; }
.matrix-host canvas.matrix { width: 100%; height: 100%; background: rgba(10,10,10,.93); }

/* ============ FIREWORKS ============ */
canvas.fireworks { position: fixed; inset: 0; z-index: 9300; pointer-events: none; }

/* ============ SHUTDOWN ============ */
/* the only place with non-palette colors: this is the world OUTSIDE the os */
#shutdown { position: fixed; inset: 0; z-index: 9800; background: #000; overflow: hidden; }
.sd-crt {
  position: absolute; inset: 0; background: #fff;
  animation: crt-die 1.2s cubic-bezier(.6, 0, .9, .4) forwards;
}
@keyframes crt-die {
  0% { transform: scaleY(1); opacity: 1; }
  55% { transform: scaleY(.006); opacity: 1; }
  72% { transform: scaleY(.006) scaleX(.4); opacity: .9; }
  88% { transform: scaleY(.006) scaleX(.002); opacity: .8; }
  100% { transform: scaleY(.006) scaleX(.002); opacity: 0; }
}
.sd-room { position: absolute; inset: 0; perspective: 900px; animation: sd-fadein 1.6s ease forwards; }
@keyframes sd-fadein { from { opacity: 0; } to { opacity: 1; } }
.sd-pan {
  position: absolute; top: 0; bottom: 0; left: 0; width: 240vw;
  transform: translateX(0) rotateY(0deg);
  transition: transform 4.5s cubic-bezier(.5, 0, .35, 1);
  transform-origin: 50vw center;
}
.sd-pan.turned { transform: translateX(-140vw) rotateY(-7deg); }
/* the desk + dead monitor (what we turn away from) */
.sd-desk { position: absolute; left: 8vw; bottom: 0; width: 84vw; height: 70vh; }
.sd-table { position: absolute; bottom: 0; left: 0; right: 0; height: 16vh; background: #120d0a; border-top: 3px solid #241a12; }
.sd-monitor {
  position: absolute; bottom: 15vh; left: 50%; transform: translateX(-50%);
  width: min(52vw, 560px); height: min(38vh, 380px);
  background: #1a1a1a; border: 10px solid #232323; border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,.8);
}
.sd-screen {
  position: absolute; inset: 8px; background: #050505; border-radius: 2px;
  animation: sd-afterglow 4s ease-out forwards;
}
@keyframes sd-afterglow {
  0% { box-shadow: inset 0 0 60px rgba(120, 130, 150, .25); }
  100% { box-shadow: inset 0 0 0 rgba(120, 130, 150, 0); }
}
.sd-stand {
  position: absolute; bottom: -34px; left: 50%; transform: translateX(-50%);
  width: 90px; height: 24px; background: #1c1c1c;
  border-radius: 3px;
}
.sd-wall { position: absolute; left: 90vw; top: 0; bottom: 0; width: 60vw; background: linear-gradient(180deg, #07070b, #0a0a10 70%, #0c0a10); }
/* the window we end up staring at */
.sd-win {
  position: absolute; left: 160vw; top: 12vh; width: 60vw; height: 64vh;
  border: 14px solid #15110c; box-shadow: 0 0 80px rgba(0,0,0,.9), inset 0 0 40px rgba(0,0,0,.6);
  background: #060912;
}
.sd-sky { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(180deg, #04050e 0%, #070a18 55%, #0b0d1d 100%); }
.sd-stars, .sd-stars.s2 { position: absolute; inset: 0; }
.sd-stars {
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #dfe6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 42%, #cfd8ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 41% 12%, #ffffff 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 33%, #cfd8ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 67% 9%, #dfe6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 27%, #ffffff 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 16%, #cfd8ff 50%, transparent 51%),
    radial-gradient(1px 1px at 18% 55%, #cfd8ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 93% 44%, #dfe6ff 50%, transparent 51%);
  animation: sd-twinkle 3.4s ease-in-out infinite alternate;
}
.sd-stars.s2 {
  background-image:
    radial-gradient(1px 1px at 7% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 25%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 49% 48%, #dfe6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 62% 19%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 73% 40%, #dfe6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 84% 8%, #fff 50%, transparent 51%);
  animation: sd-twinkle 2.6s ease-in-out infinite alternate-reverse;
}
@keyframes sd-twinkle { from { opacity: .45; } to { opacity: 1; } }
.sd-moon {
  position: absolute; top: 12%; right: 16%;
  width: 11vmin; height: 11vmin; border-radius: 50%;
  background: #e9edf5;
  box-shadow: inset -2.6vmin 1.4vmin 0 #0a0d1c, 0 0 50px rgba(220, 228, 255, .35);
}
.sd-city {
  position: absolute; left: 0; right: 0; bottom: 0; height: 32%;
  background:
    linear-gradient(0deg, #02030a 0 38%, transparent 38%),
    repeating-linear-gradient(90deg,
      #03040c 0 6%, transparent 6% 8%,
      #04050e 8% 17%, transparent 17% 19%,
      #02030a 19% 26%, transparent 26% 27%,
      #04050e 27% 38%, transparent 38% 40%,
      #03040c 40% 52%, transparent 52% 53%);
  background-size: 100% 100%, 100% 86%;
  background-repeat: no-repeat;
  background-position: bottom, bottom;
}
.sd-lights { position: absolute; left: 0; right: 0; bottom: 0; height: 32%; }
.sd-lights i {
  position: absolute; width: 3px; height: 3px; background: var(--alert);
  box-shadow: 0 0 6px var(--alert-glow);
  animation: sd-blink 2.2s steps(2) infinite;
}
@keyframes sd-blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .25; } }
.sd-frame { position: absolute; inset: 0; pointer-events: none; }
.sd-frame i { position: absolute; background: #15110c; }
.sd-frame i:first-child { left: 50%; top: 0; bottom: 0; width: 12px; transform: translateX(-50%); }
.sd-frame i:last-child { top: 50%; left: 0; right: 0; height: 12px; transform: translateY(-50%); }
.sd-sill { position: absolute; left: -20px; right: -20px; bottom: -28px; height: 18px; background: #1a140d; box-shadow: 0 6px 20px rgba(0,0,0,.8); }
.sd-hint {
  position: absolute; left: 50%; bottom: 5vh; transform: translateX(-50%);
  color: #3c3f52; font-size: 14px; letter-spacing: 1px;
  opacity: 0; transition: opacity 3s ease;
}
.sd-hint.show { opacity: 1; }

/* ============ OVERLAYS / EGGS ============ */
.overlay-full { position: fixed; inset: 0; z-index: 9500; }

#bsod {
  background: var(--void); color: var(--ghost);
  font-family: var(--font-mono); font-size: 22px; line-height: 1.4;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: left; cursor: pointer;
}
#bsod .bsod-title { background: var(--alert); color: var(--void); padding: 2px 14px; margin-bottom: 22px; }
#bsod .bsod-text { max-width: 640px; white-space: pre-wrap; }
#bsod .blink { animation: blink 1s steps(1) infinite; }

canvas.matrix { display: block; width: 100%; height: 100%; background: rgba(10,10,10,.92); cursor: pointer; }

body.glitch { animation: glitch-hue .12s linear infinite; }
@keyframes glitch-hue {
  0% { filter: none; } 25% { filter: invert(8%) hue-rotate(8deg); }
  50% { filter: contrast(1.6); } 75% { filter: invert(4%); } 100% { filter: none; }
}

.meltdown-noise { pointer-events: none; z-index: 9400; overflow: hidden; }
.melt-block {
  position: absolute;
  animation: melt-flicker .22s steps(2) infinite;
  box-shadow: 0 0 8px rgba(0,0,0,.5);
}
@keyframes melt-flicker {
  0% { opacity: 1; transform: translateX(0); }
  50% { opacity: .35; transform: translateX(-5px); }
  100% { opacity: .9; transform: translateX(3px); }
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--taskbar-h) + 14px);
  transform: translateX(-50%);
  background: var(--panel); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-hi) var(--bv-lo) var(--bv-lo) var(--bv-hi);
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
  padding: 10px 16px; font-size: 13px; z-index: 9700;
  max-width: min(480px, 92vw); text-align: center;
}
.toast b { color: var(--alert); }

/* dialog (file open/save pickers) */
.dlg-list { flex: 1; overflow-y: auto; margin: 4px; }
.dlg-list button {
  display: flex; width: 100%; text-align: left; padding: 7px 10px;
  color: var(--ghost); font-size: 13px; gap: 8px; touch-action: manipulation;
}
.dlg-list button:hover, .dlg-list button:active { background: var(--alert); color: var(--void); }
.dlg-row { display: flex; gap: 6px; padding: 6px; align-items: center; }
.dlg-row input {
  flex: 1; background: var(--inset); color: var(--ghost);
  border: 2px solid; border-color: var(--bv-lo) var(--bv-hi) var(--bv-hi) var(--bv-lo);
  padding: 6px 8px; font: inherit; outline: none; min-width: 0;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}

/* ============ MOBILE ============ */
@media (max-width: 700px), (pointer: coarse) {
  :root { --taskbar-h: 50px; --titlebar-h: 38px; }
  html, body { font-size: 14px; }
  .win-btn { width: 34px; height: 30px; flex-basis: 34px; font-size: 13px; }
  .resize-handle { width: 32px; height: 32px; }
  .rh-n, .rh-s { height: 12px; }
  .rh-e, .rh-w { width: 12px; }
  .rh-ne, .rh-nw, .rh-sw { width: 26px; height: 26px; }
  .rh-se { width: 34px; height: 34px; }
  .tb-btn { padding: 8px 12px; font-size: 13px; }
  .dicon { width: 78px; }
  .swatch { width: 26px; height: 26px; }
  #clock { font-size: 21px; }
  #start-menu { min-width: 260px; }
  .sm-item { padding: 12px 12px; font-size: 14px; }
  .task-item { min-width: 64px; flex-basis: 120px; }
  #watermark { font-size: 16px; bottom: 6px; right: 10px; }
  #pet { width: 76px; height: 76px; left: 4px; bottom: 4px; }
  .pet-bubble { bottom: 92px; width: 200px; }
}
