[data-theme="night"] {
  --bg-base: #050510;
  --text-primary: #e8eaf0;
  --text-secondary: #9499a8;
  --text-muted: #5c6370;
  --glass-bg: rgba(12, 14, 28, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --hover-bg: rgba(255, 255, 255, 0.05);
  --accent: #818cf8;
  --accent-dim: rgba(129, 140, 248, 0.15);
  --accent-glow: rgba(129, 140, 248, 0.35);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --terminal-bg: rgba(4, 6, 14, 0.88);
  --terminal-text: #c8d0e0;
  --terminal-prompt: #818cf8;
  --module-accent: #818cf8;
  --on-accent-text: #06110a;

  /* Ground/horizon — a barely-there silhouette so it reads as depth
     rather than a shape competing with the stars above it. */
  --ground-top: #0c0c1c;
  --ground-bottom: #030308;
  --tree-canopy: #0a1a12;
  --tree-trunk: #0a0a10;
}

[data-theme="day"] {
  /* Third pass. First overhaul fixed contrast; second warmed the palette
     but stayed an abstract wash. This one is a literal blue sky: a real
     gradient from deep sky-blue up top to a pale horizon near the bottom,
     the sun sitting in it, and a ground band (with a small tree) so the
     whole thing reads as an actual scene rather than a tinted background
     behind a dashboard. Cards stay a warm, opaque near-white so they hold
     their own contrast against a much busier background than before. */
  --bg-base: #cfeaff;
  --text-primary: #12203a;
  --text-secondary: #3d5470;
  --text-muted: #6b8098;
  --glass-bg: rgba(255, 253, 246, 0.88);
  --glass-border: rgba(20, 50, 90, 0.16);
  --glass-shadow: 0 4px 6px rgba(20, 50, 90, 0.08), 0 12px 32px rgba(20, 50, 90, 0.14);
  --hover-bg: rgba(217, 119, 6, 0.08);
  --accent: #4f46e5;
  --accent-dim: rgba(79, 70, 229, 0.13);
  --accent-glow: rgba(79, 70, 229, 0.3);
  --success: #047857;
  --warning: #b45309;
  --danger: #be123c;
  --terminal-bg: rgba(16, 20, 34, 0.96);
  --terminal-text: #dde3f0;
  --terminal-prompt: #a5b4fc;
  --module-accent: #4f46e5;
  --on-accent-text: #06110a;

  /* Ground/horizon — soft grass under a blue sky. */
  --ground-top: #8fc76b;
  --ground-bottom: #5a9c4a;
  --tree-canopy: #2f6b3a;
  --tree-trunk: #4a3220;
}

/* Day-theme structure: an actual sky gradient — deep blue at the top,
   fading through a warm sun-glow near .sun, down to a pale horizon blue
   just above where .ground takes over. */
[data-theme="day"] body {
  background-image:
    radial-gradient(ellipse 55% 40% at 88% 6%, rgba(255, 210, 140, 0.55), transparent 60%),
    linear-gradient(180deg, #4a90d9 0%, #7ec4ef 35%, #bfe3f8 68%, #eaf6ff 100%);
  background-attachment: fixed;
}

[data-theme="day"] .module-header {
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.5rem;
}

[data-theme="day"] .module:hover {
  box-shadow: 0 6px 10px rgba(24, 32, 56, 0.08), 0 18px 40px rgba(24, 32, 56, 0.13);
}

[data-theme="day"] .icon-btn,
[data-theme="day"] .nav-btn,
[data-theme="day"] .quick-link {
  border: 1px solid var(--glass-border);
  background: rgba(255, 253, 246, 0.75);
}

[data-theme="day"] .icon-btn:hover,
[data-theme="day"] .nav-btn:hover,
[data-theme="day"] .quick-link:hover {
  background: #fffdf7;
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="day"] .nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

[data-theme="day"] #stars-canvas {
  opacity: 0.15;
}

[data-theme="day"] .sun {
  opacity: 1;
}

[data-theme="day"] .boot-screen {
  background: #e8edf5;
}

[data-theme="day"] .boot-log {
  color: rgba(0, 0, 0, 0.4);
}

/* ==================================================================
   RETRO THEMES — 90s/2000s workstation, two variants
   ------------------------------------------------------------------
   Retro (dark) keeps NightShift's identity (dark base, indigo/cyan
   accent) but reshapes every surface into 90s UI language: beveled
   3D edges instead of soft glass, square corners, solid fills rather
   than translucency, and chunky controls that physically press in.
   Think dark SGI/NeXT workstation rather than literal Win95 grey.

   Retro Light is the same *shapes* — same bevels, same square corners,
   same title-bar-as-chrome idea — recolored as classic Windows 2000:
   silver panel faces, the iconic blue-gradient active title bar
   (grey when "unfocused"), black text.

   Everything structural below is shared via [data-theme^="retro"]
   (matches both "retro" and "retro-light"); only the two variable
   blocks below differ between them. A small set of previously-
   hardcoded colors (title bar gradients, button face, taskbar bg)
   were pulled into variables specifically so this could be shared
   instead of duplicating ~200 lines of identical structural CSS.
   ================================================================== */

[data-theme="retro"] {
  --bg-base: #0a0a14;
  --text-primary: #d8dce8;
  --text-secondary: #9aa0b4;
  --text-muted: #6a7085;

  /* Solid, not translucent — 90s UI had no compositing to blur with. */
  --glass-bg: #141428;
  --glass-border: #3a3a5c;
  --glass-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
  --hover-bg: #1e1e38;

  --accent: #8f9cff;
  --accent-dim: #23234a;
  --accent-glow: rgba(143, 156, 255, 0.4);
  --success: #3ce88a;
  --warning: #ffcc33;
  --danger: #ff5c5c;

  --terminal-bg: #06060f;
  --terminal-text: #b9c4dc;
  --terminal-prompt: #8f9cff;
  --module-accent: #8f9cff;

  /* Bevel palette — the whole look hangs off these two. */
  --bevel-light: #4a4a78;
  --bevel-dark: #05050c;

  /* Surfaces that used to be hardcoded colors, now variables so
     Retro Light can supply its own without duplicating every rule. */
  --header-grad-1: #2a2a55;
  --header-grad-2: #16162e;
  --titlebar-grad-1: #23234a;
  --titlebar-grad-2: #14142c;
  --titlebar-focus-grad-2: #4a4a9c;
  --btn-bg: #1a1a32;
  --on-accent-text: #06060f;
}

[data-theme="retro-light"] {
  /* Windows 2000: silver panel chrome, the unmistakable blue-gradient
     active title bar (grey when a window isn't focused), black text.
     Same bevel *technique* as dark retro, light-side-up instead.
     --bg-base is the classic Windows 2000 desktop blue (matched from a
     reference swatch) — panels/cards stay silver via --glass-bg, so
     silver dialog-style windows sit on a blue desktop exactly like the
     real thing. Text sitting directly on that blue (the dashboard
     greeting, the footer) switches to white further down — the same
     split Windows itself used between white desktop-icon labels and
     black in-dialog text. */
  --bg-base: #3d72a4;
  --text-primary: #000000;
  --text-secondary: #3a3a3a;
  --text-muted: #6d6d6d;

  --glass-bg: #d4d0c8;
  --glass-border: #808080;
  --glass-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
  --hover-bg: #dcdcdc;

  --accent: #0a246a;
  --accent-dim: #d0dcf0;
  --accent-glow: rgba(10, 36, 106, 0.25);
  --success: #008000;
  --warning: #d2691e;
  --danger: #c00000;

  /* The terminal stays a classic black box regardless of desktop
     chrome — a light-background terminal wouldn't read as a terminal. */
  --terminal-bg: #000000;
  --terminal-text: #e0e0e0;
  --terminal-prompt: #16a34a;
  --module-accent: #0a246a;

  --bevel-light: #ffffff;
  --bevel-dark: #4a4a4a;

  /* Module headers always read as "active" (dashboard cards have no
     focus state), so they get the blue gradient outright. Window title
     bars distinguish focused/unfocused the way Windows 2000 actually
     did: grey by default, blue only for the focused window. */
  --header-grad-1: #0a246a;
  --header-grad-2: #a6caf0;
  --titlebar-grad-1: #808080;
  --titlebar-grad-2: #c0c0c0;
  --titlebar-focus-grad-2: #a6caf0;
  --btn-bg: #d4d0c8;
  --on-accent-text: #ffffff;
}

/* Text sitting directly on Retro Light's blue desktop (not inside a
   silver panel) needs the light treatment instead of --text-primary's
   black — otherwise the dashboard greeting and footer both land near-
   illegible on that blue. Real Windows 2000 drew desktop icon labels in
   white for exactly this reason, distinct from black text in dialogs. */
[data-theme="retro-light"] .dashboard-header h1,
[data-theme="retro-light"] .subtitle,
[data-theme="retro-light"] .app-footer {
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

/* ---- Square everything. Neither era had border-radius. ---- */
[data-theme^="retro"] .module,
[data-theme^="retro"] .glass,
[data-theme^="retro"] .icon-btn,
[data-theme^="retro"] .nav-btn,
[data-theme^="retro"] .quick-link,
[data-theme^="retro"] .btn,
[data-theme^="retro"] .toast,
[data-theme^="retro"] .notif-panel,
[data-theme^="retro"] .a11y-panel,
[data-theme^="retro"] .terminal-wrap,
[data-theme^="retro"] .ach-drawer,
[data-theme^="retro"] .nw-window,
[data-theme^="retro"] .progress-track,
[data-theme^="retro"] .progress-fill,
[data-theme^="retro"] .service-status,
[data-theme^="retro"] .nightos-taskbar,
[data-theme^="retro"] .taskbar-app,
[data-theme^="retro"] .nightos-start-menu {
  border-radius: 0 !important;
}

/* ---- Raised bevel: light top/left, dark bottom/right ---- */
[data-theme^="retro"] .module,
[data-theme^="retro"] .notif-panel,
[data-theme^="retro"] .a11y-panel,
[data-theme^="retro"] .ach-drawer,
[data-theme^="retro"] .nw-window,
[data-theme^="retro"] .nightos-start-menu,
[data-theme^="retro"] .toast {
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: var(--glass-bg);
}

/* ---- Buttons: raised until pressed, then genuinely inset ---- */
[data-theme^="retro"] .icon-btn,
[data-theme^="retro"] .nav-btn,
[data-theme^="retro"] .quick-link,
[data-theme^="retro"] .btn,
[data-theme^="retro"] .taskbar-app,
[data-theme^="retro"] .nightos-launcher {
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  background: var(--btn-bg);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

[data-theme^="retro"] .icon-btn:active,
[data-theme^="retro"] .nav-btn:active,
[data-theme^="retro"] .quick-link:active,
[data-theme^="retro"] .btn:active,
[data-theme^="retro"] .taskbar-app:active,
[data-theme^="retro"] .nightos-launcher:active {
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
  /* The classic 1px content shift that makes a button feel physical. */
  padding-top: calc(0.4rem + 1px);
  padding-left: calc(0.5rem + 1px);
}

[data-theme^="retro"] .nav-btn.active {
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
  background: var(--accent-dim);
}

/* ---- Sunken wells: anything that displays rather than invites a click ---- */
[data-theme^="retro"] .progress-track,
[data-theme^="retro"] .terminal-wrap,
[data-theme^="retro"] .terminal-output {
  border: 2px solid;
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
  background: var(--terminal-bg);
}

/* ---- Progress bars: stepped blocks, not smooth gradients ---- */
[data-theme^="retro"] .progress-fill {
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0px,
    var(--accent) 8px,
    var(--bg-base) 8px,
    var(--bg-base) 10px
  ) !important;
}

[data-theme^="retro"] .progress-fill.warn {
  background: repeating-linear-gradient(
    90deg,
    var(--warning) 0px, var(--warning) 8px,
    var(--bg-base) 8px, var(--bg-base) 10px
  ) !important;
}

[data-theme^="retro"] .progress-fill.danger {
  background: repeating-linear-gradient(
    90deg,
    var(--danger) 0px, var(--danger) 8px,
    var(--bg-base) 8px, var(--bg-base) 10px
  ) !important;
}

/* ---- Module headers as title bars ---- */
[data-theme^="retro"] .module-header {
  background: linear-gradient(90deg, var(--header-grad-1), var(--header-grad-2));
  border-bottom: 2px solid var(--bevel-dark);
  padding: 0.4rem 0.6rem;
  margin: -0.1rem -0.1rem 0.6rem;
}

[data-theme^="retro"] .module-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

/* ---- Typography: both eras ran on monospace and bitmap faces ---- */
[data-theme^="retro"] .service-name,
[data-theme^="retro"] .service-status,
[data-theme^="retro"] .stat-label,
[data-theme^="retro"] .stat-value,
[data-theme^="retro"] .quick-link,
[data-theme^="retro"] .nav-btn,
[data-theme^="retro"] .ach-title,
[data-theme^="retro"] .nw-title,
[data-theme^="retro"] .taskbar-app {
  font-family: var(--font-mono);
}

[data-theme^="retro"] .greeting-title {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 2px 2px 0 var(--bevel-dark);
}

/* ---- Status pills become hard-edged tags ---- */
[data-theme^="retro"] .service-status {
  border: 1px solid currentColor;
  background: transparent !important;
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
}

/* ---- Window chrome: proper title bars, either era ---- */
[data-theme^="retro"] .nw-titlebar {
  background: linear-gradient(90deg, var(--titlebar-grad-1), var(--titlebar-grad-2));
  border-bottom: 2px solid var(--bevel-dark);
}

[data-theme^="retro"] .nw-focused .nw-titlebar {
  background: linear-gradient(90deg, var(--accent), var(--titlebar-focus-grad-2));
}

[data-theme^="retro"] .nw-focused .nw-title {
  color: var(--on-accent-text);
  font-weight: 700;
}

[data-theme^="retro"] .nw-btn {
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  background: var(--btn-bg);
  border-radius: 0;
}

/* ---- Taskbar sits on a raised strip, like it always did ---- */
[data-theme^="retro"] .nightos-taskbar {
  background: var(--glass-bg);
  border-top: 2px solid var(--bevel-light);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ---- Starfield dimmed: neither era's desktops were translucent ---- */
[data-theme^="retro"] #stars-canvas {
  opacity: 0.35;
}

[data-theme^="retro"] .sun {
  opacity: 0;
}

/* Retro keeps its own deliberately flat look (scanlined for dark, plain
   chrome for light) — the sky/ground scene belongs to day and night
   specifically, not the 90s/2000s workstation aesthetic layered on top. */
[data-theme^="retro"] .ground,
[data-theme^="retro"] .tree {
  display: none;
}

/* ---- Boot screen leans fully into the terminal look, both variants ---- */
[data-theme^="retro"] .boot-screen {
  background: #06060f;
}

[data-theme^="retro"] .boot-log {
  color: var(--success);
  font-family: var(--font-mono);
}

/* ---- Scanline overlay: dark retro's unmistakable era signature.
       Retro Light skips it — Windows 2000 chrome was crisp, not a CRT
       — so this stays scoped to the exact "retro" value, not ^=.
       pointer-events:none so it can never intercept a click, and it
       respects reduced-motion users by staying perfectly static. ---- */
[data-theme="retro"] body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.13) 0px,
    rgba(0, 0, 0, 0.13) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* High-contrast users have explicitly asked for maximum legibility —
   an overlay that dims every pixel on screen works directly against
   that, so it comes off entirely.
   BUG FIX: both selectors here were wrong — a11y.js toggles the real class
   (`a11y-high-contrast`, not `high-contrast`) on <html> (not <body>), so
   neither ever matched anything and the scanline overlay stayed on
   regardless. `data-theme` lives on that same <html> element too. */
html[data-theme="retro"].a11y-high-contrast body::after {
  display: none;
}
