/* ════════════════════════════════════════════════════════════════════
   OS-2045 Shell additions (Phase 2)
   - Bridges the new shell DOM classes (.os-window, .os-taskbar, .os-ctx,
     .os-desktop-icon, .os-start-menu, .os-window-layer) to the existing
     theme-os2045.css visual language.
   - Adds resize handles, AltTab overlay, sub-menu, empty placeholder.
   - All rules are scoped to body[data-theme-mode="os2045"] to keep the
     Win3.11 / classic themes untouched.
   ════════════════════════════════════════════════════════════════════ */

/* ─── Desktop section host ─────────────────────────────────────────── */
body[data-theme-mode="os2045"] #os2045Desktop {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  background: var(--bg-0, #05070c);
  isolation: isolate;
}
body[data-theme-mode="os2045"] #os2045Desktop[hidden] {
  display: none;
}

body[data-theme-mode="os2045"] .os-wall {
  position: absolute; inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(255,122,66,0.22), transparent 60%),
    radial-gradient(ellipse 60% 60% at 85% 80%, rgba(95,209,255,0.16), transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 110%, rgba(176,139,255,0.14), transparent 60%),
    linear-gradient(180deg, #05070c 0%, #0a0d18 60%, #0e1220 100%);
}
body[data-theme-mode="os2045"] .os-wall-horizon {
  position: absolute; left: 0; right: 0; top: 42%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,184,107,0.5), rgba(95,209,255,0.4), transparent);
  filter: blur(1px);
}
body[data-theme-mode="os2045"] .os-wall-bokeh { position: absolute; inset: 0; pointer-events: none; }
body[data-theme-mode="os2045"] .os-wall-bokeh span {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.6;
}
body[data-theme-mode="os2045"] .os-scan {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
  background: repeating-linear-gradient(0deg,
    transparent 0, transparent 3px,
    rgba(255,255,255,0.012) 3px, rgba(255,255,255,0.012) 4px);
}

/* ─── Icons layer + desktop icons ──────────────────────────────────── */
body[data-theme-mode="os2045"] .os-icons-layer {
  position: absolute;
  inset: 0 0 84px 0;
  z-index: 10;
}
body[data-theme-mode="os2045"] .os-desktop-icon {
  position: absolute;
  width: 82px;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  padding: 6px;
  border-radius: 12px;
  cursor: grab;
  user-select: none;
  transition: background 0.15s, transform 0.2s;
  outline: none;
}
body[data-theme-mode="os2045"] .os-desktop-icon:hover { background: rgba(255,255,255,0.04); }
body[data-theme-mode="os2045"] .os-desktop-icon:focus-visible {
  background: rgba(255,184,107,0.10);
  outline: 1px solid rgba(255,184,107,0.45);
}
body[data-theme-mode="os2045"] .os-desktop-icon.selected {
  background: rgba(255,184,107,0.10);
  outline: 1px solid rgba(255,184,107,0.35);
}
body[data-theme-mode="os2045"] .os-desktop-icon.dragging {
  opacity: 0.78;
  z-index: 20;
  cursor: grabbing;
}
body[data-theme-mode="os2045"] .os-desktop-icon .tile {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  position: relative;
  box-shadow:
    0 10px 24px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -1px 0 rgba(0,0,0,0.25);
  transition: transform 0.2s;
}
body[data-theme-mode="os2045"] .os-desktop-icon:hover .tile { transform: translateY(-3px) scale(1.06); }
body[data-theme-mode="os2045"] .os-desktop-icon.dragging .tile { transform: scale(1.08) rotate(-2deg); }
body[data-theme-mode="os2045"] .os-desktop-icon .tile svg { width: 26px; height: 26px; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
body[data-theme-mode="os2045"] .os-desktop-icon .lbl {
  font-size: 11px; color: var(--ink, #eef2ff);
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
  text-align: center; line-height: 1.2;
  max-width: 80px; letter-spacing: -0.005em;
}
body[data-theme-mode="os2045"] .os-icons-layer.icons-small .os-desktop-icon { width: 64px; }
body[data-theme-mode="os2045"] .os-icons-layer.icons-small .os-desktop-icon .tile { width: 38px; height: 38px; border-radius: 10px; }
body[data-theme-mode="os2045"] .os-icons-layer.icons-small .os-desktop-icon .tile svg { width: 18px; height: 18px; }
body[data-theme-mode="os2045"] .os-icons-layer.icons-small .os-desktop-icon .lbl { font-size: 10px; }

/* ─── Window layer + windows ──────────────────────────────────────── */
/* Bottom inset = taskbar footprint (height 54px + bottom offset 14px = 68px).
   Maximized windows fill the layer, so they end exactly at the taskbar's top
   edge instead of leaving a free strip above it. */
body[data-theme-mode="os2045"] .os-window-layer {
  position: absolute;
  inset: 0 0 68px 0;
  z-index: 30;
  pointer-events: none;
}
body[data-theme-mode="os2045"] .os-window {
  pointer-events: auto;
  position: absolute;
  width: 720px; height: 460px;
  background: var(--glass-2, rgba(14,18,30,0.72));
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  border-radius: 16px;
  box-shadow: var(--glass-shadow, 0 30px 80px rgba(0,0,0,0.55));
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: opacity 0.18s, transform 0.22s cubic-bezier(0.2,0.9,0.2,1);
  z-index: 200;
}
body[data-theme-mode="os2045"] .os-window.dragging,
body[data-theme-mode="os2045"] .os-window.resizing {
  transition: none;
  user-select: none;
}
/* While dragging or resizing a window, lock pointer-events on any
   embedded iframe so the parent receives the move/up events. Without
   this, the SSH ttyd iframe (and similar) eats the pointer the moment
   the cursor crosses its bounds — drag state hangs and the iframe
   reload-loops on next interaction (which kills the SSH session).
   Also force the iframe onto its own compositing layer so the parent
   resize during snap/maximize doesn't trigger a layout reflow inside
   the iframe (which xterm.js / ttyd interprets as "tab visibility lost"
   and reconnects, manifesting as a reload). */
body[data-theme-mode="os2045"] .os-window.dragging iframe,
body[data-theme-mode="os2045"] .os-window.resizing iframe,
body[data-theme-mode="os2045"] .os-window.dragging .os-window-body *,
body[data-theme-mode="os2045"] .os-window.resizing .os-window-body iframe {
  pointer-events: none !important;
}
body[data-theme-mode="os2045"] .os-window iframe {
  /* Pin the iframe onto its own compositor layer at all times. Cheap and
     makes the snap-on-edge / maximize transition glitch-free for ttyd. */
  transform: translateZ(0);
  will-change: transform;
}
body[data-theme-mode="os2045"] .os-window.focused {
  box-shadow:
    0 40px 100px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255,184,107,0.18),
    0 2px 0 rgba(255,255,255,0.06) inset;
}
body[data-theme-mode="os2045"] .os-window.minimized {
  opacity: 0;
  transform: translateY(120px) scale(0.6);
  pointer-events: none;
}
body[data-theme-mode="os2045"] .os-window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  /* The window-layer parent is already `inset: 0 0 68px 0` (taskbar height
     54px + 14px offset). 100% therefore already excludes the taskbar zone —
     the previous `calc(100% - 68px)` subtracted it twice and left a gap. */
  height: 100% !important;
  border-radius: 0;
}
body[data-theme-mode="os2045"] .os-window.closing {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
}
body[data-theme-mode="os2045"] .os-window.always-on-top::after {
  content: '';
  position: absolute; right: 14px; top: 4px;
  width: 6px; height: 6px;
  background: var(--a-amber, #ffb86b);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--a-amber, #ffb86b);
}

body[data-theme-mode="os2045"] .os-window-titlebar {
  height: 40px;
  display: flex; align-items: stretch;
  padding: 0 0 0 14px;
  gap: 0;
  border-bottom: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  position: relative;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
body[data-theme-mode="os2045"] .os-window.dragging .os-window-titlebar { cursor: grabbing; }
/* Windows-style controls (min/max/close) on the right of the titlebar.
   Replaces the old macOS-style .win-lights traffic-light dots. */
body[data-theme-mode="os2045"] .os-window-titlebar .win-controls {
  display: flex;
  margin-left: auto;
  gap: 0;
  align-items: stretch;
  height: 100%;
}
body[data-theme-mode="os2045"] .os-window-titlebar .win-controls > button {
  width: 46px;
  min-height: 32px;
  background: transparent;
  border: 0;
  color: var(--ink-2, #c0c8e0);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  padding: 0;
  font: inherit;
}
body[data-theme-mode="os2045"] .os-window-titlebar .win-controls > button:hover {
  background: rgba(255, 255, 255, 0.08);
}
body[data-theme-mode="os2045"] .os-window-titlebar .win-controls > button:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.4);
  outline-offset: -1px;
}
body[data-theme-mode="os2045"] .os-window-titlebar .win-controls > .win-close:hover {
  background: #e81123;
  color: #fff;
}
body[data-theme-mode="os2045"] .os-window-titlebar .win-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-3, #6d7695);
  letter-spacing: 0.08em;
  flex: 1;
  text-align: left;
  padding-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Backward compatibility: legacy .win-lights markup hidden if any code still
   produces it. Safe no-op for the new chrome. */
body[data-theme-mode="os2045"] .os-window-titlebar .win-lights {
  display: none !important;
}
body[data-theme-mode="os2045"] .os-window-titlebar .win-title b {
  color: var(--ink, #eef2ff);
  font-weight: 500;
}
body[data-theme-mode="os2045"] .os-window-titlebar .win-tools {
  display: flex; gap: 4px;
  min-width: 60px;
  justify-content: flex-end;
}
body[data-theme-mode="os2045"] .os-window-body {
  flex: 1;
  overflow: auto;
  position: relative;
}

/* Resize handles (8 around the window) */
body[data-theme-mode="os2045"] .os-resize {
  position: absolute;
  z-index: 5;
}
body[data-theme-mode="os2045"] .os-resize.n  { top:0; left:8px; right:8px; height:6px; cursor: n-resize; }
body[data-theme-mode="os2045"] .os-resize.s  { bottom:0; left:8px; right:8px; height:6px; cursor: s-resize; }
body[data-theme-mode="os2045"] .os-resize.e  { right:0; top:8px; bottom:8px; width:6px; cursor: e-resize; }
body[data-theme-mode="os2045"] .os-resize.w  { left:0;  top:8px; bottom:8px; width:6px; cursor: w-resize; }
body[data-theme-mode="os2045"] .os-resize.nw { left:0;  top:0;    width:12px; height:12px; cursor: nw-resize; }
body[data-theme-mode="os2045"] .os-resize.ne { right:0; top:0;    width:12px; height:12px; cursor: ne-resize; }
body[data-theme-mode="os2045"] .os-resize.sw { left:0;  bottom:0; width:12px; height:12px; cursor: sw-resize; }
body[data-theme-mode="os2045"] .os-resize.se { right:0; bottom:0; width:12px; height:12px; cursor: se-resize; }
body[data-theme-mode="os2045"] .os-window.maximized .os-resize { display: none; }

/* Empty placeholder (Phase-2 fallback content) */
body[data-theme-mode="os2045"] .os-window-empty {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 30px;
  color: var(--ink-2, #b5bdd1);
}
body[data-theme-mode="os2045"] .os-window-empty-title {
  font-family: 'Instrument Serif', serif; font-style: italic;
  font-size: 28px;
  color: var(--ink, #eef2ff);
}
body[data-theme-mode="os2045"] .os-window-empty-sub {
  font-size: 13px;
  max-width: 420px;
  line-height: 1.5;
  color: var(--ink-3, #6d7695);
}
body[data-theme-mode="os2045"] .os-window-empty-loader {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,184,107,0.3);
  border-top-color: var(--a-amber, #ffb86b);
  animation: os-spin 1s linear infinite;
}
@keyframes os-spin { to { transform: rotate(360deg); } }

/* ─── Taskbar (.os-taskbar — uses existing .taskbar tokens via class) ── */
body[data-theme-mode="os2045"] .os-taskbar {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  height: 54px;
  display: flex; align-items: center;
  padding: 6px 10px; gap: 4px;
  background: var(--glass, rgba(22,28,44,0.58));
  backdrop-filter: blur(40px) saturate(160%);
  -webkit-backdrop-filter: blur(40px) saturate(160%);
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  border-radius: 20px;
  box-shadow: var(--glass-shadow, 0 30px 80px rgba(0,0,0,0.55));
  z-index: 90;
  pointer-events: auto;
}
body[data-theme-mode="os2045"] .os-taskbar .tb-running {
  display: flex; gap: 4px;
}
body[data-theme-mode="os2045"] .os-taskbar .tb-btn {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  transition: all 0.2s;
  color: var(--ink-2, #b5bdd1);
  background: none;
  border: 0;
  cursor: pointer;
}
body[data-theme-mode="os2045"] .os-taskbar .tb-btn:hover {
  background: var(--glass-hi, rgba(255,255,255,0.08));
  color: var(--ink, #eef2ff);
  transform: translateY(-2px);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-btn.running::after {
  content: '';
  position: absolute;
  bottom: -3px; left: 50%;
  transform: translateX(-50%);
  width: 12px; height: 3px;
  background: var(--a-amber, #ffb86b);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--a-amber, #ffb86b);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-btn.active::after {
  width: 20px;
  box-shadow: 0 0 8px var(--a-amber, #ffb86b);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-btn .ti {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.04);
  color: var(--ink, #eef2ff);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-btn .ti svg { width: 18px; height: 18px; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

body[data-theme-mode="os2045"] .os-taskbar .tb-start {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: var(--theme-accent, #5fd1ff);
  display: grid; place-items: center;
  margin-right: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform 0.2s, background 0.15s, border-color 0.15s;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.08);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-start:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.08);
  border-color: color-mix(in srgb, var(--theme-accent, #5fd1ff) 50%, transparent);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-start svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }

body[data-theme-mode="os2045"] .os-taskbar .tb-sep { width: 1px; height: 28px; background: var(--glass-edge, rgba(255,255,255,0.10)); margin: 0 6px; }

body[data-theme-mode="os2045"] .os-taskbar .tb-search {
  display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px;
  background: var(--glass-hi, rgba(255,255,255,0.08));
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  border-radius: 12px;
  color: var(--ink-3, #6d7695);
  font-size: 12px;
  min-width: 180px;
  cursor: text;
}
body[data-theme-mode="os2045"] .os-taskbar .tb-search:hover { color: var(--ink-2, #b5bdd1); }
body[data-theme-mode="os2045"] .os-taskbar .tb-search svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
body[data-theme-mode="os2045"] .os-taskbar .tb-search .kbd {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; padding: 1px 5px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px; color: var(--ink-3, #6d7695);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-nowplaying {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 14px;
  background: rgba(255, 184, 107, 0.12);
  color: var(--a-amber, #ffb86b);
  font-size: 11.5px;
  cursor: pointer;
  border: 1px solid transparent;
  max-width: 200px;
  user-select: none;
  margin-right: 4px;
}
body[data-theme-mode="os2045"] .os-taskbar .tb-nowplaying:hover {
  background: rgba(255, 184, 107, 0.22);
  border-color: rgba(255, 184, 107, 0.4);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-nowplaying.is-playing {
  background: rgba(141, 217, 122, 0.16);
  color: #8dd97a;
}
body[data-theme-mode="os2045"] .os-taskbar .tb-nowplaying.is-playing:hover {
  background: rgba(141, 217, 122, 0.26);
  border-color: rgba(141, 217, 122, 0.5);
}
body[data-theme-mode="os2045"] .os-taskbar .tb-nowplaying .np-icon {
  font-size: 12px;
  line-height: 1;
}
body[data-theme-mode="os2045"] .os-taskbar .tb-nowplaying .np-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  font-weight: 500;
}

body[data-theme-mode="os2045"] .os-taskbar .tray {
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px 0 4px;
  height: 42px;
  border-radius: 12px;
  background: var(--glass-hi, rgba(255,255,255,0.08));
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
}
body[data-theme-mode="os2045"] .os-taskbar .tray .ti {
  padding: 0 6px;
  height: 32px;
  display: grid; place-items: center;
  color: var(--ink-2, #b5bdd1);
  background: none; border: 0; cursor: pointer;
  border-radius: 8px;
}
body[data-theme-mode="os2045"] .os-taskbar .tray .ti:hover { background: rgba(255,255,255,0.08); color: var(--ink, #eef2ff); }
body[data-theme-mode="os2045"] .os-taskbar .tray .ti svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
body[data-theme-mode="os2045"] .os-taskbar .tray .clock {
  padding: 0 10px 0 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--ink, #eef2ff);
  line-height: 1.2; text-align: right;
}
body[data-theme-mode="os2045"] .os-taskbar .tray .clock small {
  display: block; font-size: 9px;
  color: var(--ink-3, #6d7695); letter-spacing: 0.1em;
}
body[data-theme-mode="os2045"] .os-taskbar .tray .tsep { width: 1px; height: 22px; background: var(--glass-edge, rgba(255,255,255,0.10)); }

body[data-theme-mode="os2045"] .os-taskbar .tray-ai {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  position: relative;
  background: radial-gradient(circle at 35% 30%, rgba(255,184,107,0.5), rgba(176,139,255,0.4) 55%, rgba(95,157,255,0.3));
  cursor: pointer;
  margin-left: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 0 14px rgba(255,184,107,0.25);
  border: 0;
}
body[data-theme-mode="os2045"] .os-taskbar .tray-ai::after {
  content: '';
  position: absolute; inset: 6px;
  background: radial-gradient(circle, rgba(255,255,255,0.9), transparent 55%);
  border-radius: 50%;
  animation: os-pulseOrb 3s ease-in-out infinite;
  opacity: 0.7;
}
@keyframes os-pulseOrb {
  0%,100% { opacity: 0.55; transform: scale(0.95); }
  50%     { opacity: 0.9;  transform: scale(1.05); }
}

/* ─── Start menu (.os-start-menu) ──────────────────────────────────── */
body[data-theme-mode="os2045"] .os-start-menu {
  position: fixed;
  bottom: 84px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: 680px;
  max-height: 80vh;
  background: var(--glass-2-strong, rgba(8,12,22,0.92));
  backdrop-filter: blur(50px) saturate(160%);
  -webkit-backdrop-filter: blur(50px) saturate(160%);
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  border-radius: 22px;
  box-shadow: 0 40px 100px rgba(0,0,0,0.6);
  padding: 22px 24px;
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  overflow: auto;
  transition: opacity 0.25s cubic-bezier(0.2, 0.9, 0.2, 1), transform 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
}
body[data-theme-mode="os2045"] .os-start-menu.open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-greet {
  font-family: 'Instrument Serif', serif; font-style: italic;
  font-size: 26px; line-height: 1.1;
  margin-bottom: 12px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-greet b {
  font-style: normal; font-family: 'Inter', sans-serif;
  font-weight: 500; font-size: 16px;
  color: var(--ink-3, #6d7695); letter-spacing: 0.15em;
  text-transform: uppercase; display: block;
  margin-bottom: 6px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-greet-sub {
  font-size: 13px; color: var(--ink-2, #b5bdd1);
  font-family: 'Instrument Serif', serif; font-style: italic;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-search {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  border-radius: 12px;
  margin-bottom: 18px;
  color: var(--ink-3, #6d7695); font-size: 13px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink, #eef2ff);
  font: inherit;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-search input::placeholder {
  color: var(--ink-3, #6d7695);
}
body[data-theme-mode="os2045"] .os-start-menu .sm-search-kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; padding: 1px 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  color: var(--ink-3, #6d7695);
}
body[data-theme-mode="os2045"] .os-start-menu .sm-search svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
body[data-theme-mode="os2045"] .os-start-menu .sm-sec {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.22em;
  color: var(--ink-4, #3d465f); text-transform: uppercase;
  margin: 4px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-sec::after {
  content: ''; flex: 1; height: 1px; background: var(--glass-edge, rgba(255,255,255,0.10));
}
body[data-theme-mode="os2045"] .os-start-menu .sm-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px; margin-bottom: 20px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-tile {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  padding: 12px 6px;
  border-radius: 12px;
  transition: background 0.12s;
  cursor: pointer;
  background: none; border: 0;
  font: inherit;
  color: inherit;
  outline: none;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-tile:hover,
body[data-theme-mode="os2045"] .os-start-menu .sm-tile:focus-visible {
  background: var(--glass-hi, rgba(255,255,255,0.08));
}
body[data-theme-mode="os2045"] .os-start-menu .sm-tile .tile {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
  position: relative;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-tile .sm-badge {
  position: absolute;
  top: -4px; right: -6px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ff5066;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  border: 1.5px solid rgba(8, 12, 22, 0.85);
  letter-spacing: -0.01em;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-tile .tile svg { width: 22px; height: 22px; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
body[data-theme-mode="os2045"] .os-start-menu .sm-tile .lbl {
  font-size: 11px; color: var(--ink-2, #b5bdd1);
  text-align: center; letter-spacing: -0.005em;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-empty {
  grid-column: 1/-1;
  padding: 26px 0;
  text-align: center;
  color: var(--ink-3, #6d7695);
  font-size: 12px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-recent {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-r {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
  background: none; border: 0;
  font: inherit; color: inherit;
  text-align: left;
  width: 100%;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-r:hover { background: var(--glass-hi, rgba(255,255,255,0.08)); }
body[data-theme-mode="os2045"] .os-start-menu .sm-r .dot {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-r .dot svg { width: 13px; height: 13px; stroke-width: 1.8; fill: none; }
body[data-theme-mode="os2045"] .os-start-menu .sm-r .txt { flex: 1; min-width: 0; }
body[data-theme-mode="os2045"] .os-start-menu .sm-r .tl { font-size: 12px; color: var(--ink, #eef2ff); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-theme-mode="os2045"] .os-start-menu .sm-r .ts { font-size: 10px; color: var(--ink-4, #3d465f); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.1em; }
body[data-theme-mode="os2045"] .os-start-menu .sm-foot {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  display: flex; align-items: center; gap: 10px;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-user:hover { background: var(--glass-hi, rgba(255,255,255,0.08)); }
body[data-theme-mode="os2045"] .os-start-menu .sm-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(145deg, var(--a-amber, #ffb86b), var(--a-rose, #ff6b95));
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: #1a0800;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-user .n { font-size: 12px; color: var(--ink, #eef2ff); }
body[data-theme-mode="os2045"] .os-start-menu .sm-user .r { font-size: 10px; color: var(--ink-4, #3d465f); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.1em; }
body[data-theme-mode="os2045"] .os-start-menu .sm-power {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--ink-3, #6d7695);
  background: none; border: 0; cursor: pointer;
  margin-left: 0;
}
body[data-theme-mode="os2045"] .os-start-menu .sm-foot .sm-power:nth-of-type(1) { margin-left: auto; }
body[data-theme-mode="os2045"] .os-start-menu .sm-power:hover { background: var(--glass-hi, rgba(255,255,255,0.08)); color: var(--ink, #eef2ff); }
body[data-theme-mode="os2045"] .os-start-menu .sm-power svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ─── Context menu (.os-ctx) ─────────────────────────────────────── */
body[data-theme-mode="os2045"] .os-ctx {
  position: fixed;
  width: 240px;
  background: var(--glass-2-strong, rgba(8,12,22,0.92));
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  border-radius: 14px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.55);
  padding: 6px;
  z-index: 9000;
  color: var(--ink, #eef2ff);
  font-family: 'Inter', system-ui, sans-serif;
}
body[data-theme-mode="os2045"] .os-ctx-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px; color: var(--ink, #eef2ff);
  cursor: pointer;
  user-select: none;
}
body[data-theme-mode="os2045"] .os-ctx-item:hover { background: rgba(255,184,107,0.15); }
body[data-theme-mode="os2045"] .os-ctx-item.hi    { background: rgba(255,184,107,0.18); }
body[data-theme-mode="os2045"] .os-ctx-item.is-disabled {
  opacity: 0.4;
  cursor: default;
}
body[data-theme-mode="os2045"] .os-ctx-item .os-ctx-ic svg {
  width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6;
}
body[data-theme-mode="os2045"] .os-ctx-item .os-ctx-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-theme-mode="os2045"] .os-ctx-item .os-ctx-kb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--ink-4, #3d465f);
  letter-spacing: 0.05em;
}
body[data-theme-mode="os2045"] .os-ctx-item .os-ctx-arrow {
  font-size: 14px; color: var(--ink-3, #6d7695); margin-left: 4px;
}
body[data-theme-mode="os2045"] .os-ctx-sep {
  height: 1px;
  background: var(--glass-edge, rgba(255,255,255,0.10));
  margin: 4px 6px;
}
body[data-theme-mode="os2045"] .os-ctx-sub { z-index: 9100; }

/* ─── Alt+Tab switcher ─────────────────────────────────────────────── */
body[data-theme-mode="os2045"] .os-alttab {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9500;
  background: var(--glass-2-strong, rgba(8,12,22,0.94));
  backdrop-filter: blur(50px) saturate(160%);
  -webkit-backdrop-filter: blur(50px) saturate(160%);
  border: 1px solid var(--glass-edge, rgba(255,255,255,0.10));
  border-radius: 18px;
  padding: 18px;
  min-width: 320px;
  max-width: 80vw;
  box-shadow: 0 40px 100px rgba(0,0,0,0.65);
}
body[data-theme-mode="os2045"] .os-alttab-inner {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
}
body[data-theme-mode="os2045"] .os-alttab-item {
  width: 120px;
  padding: 10px;
  border-radius: 10px;
  text-align: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
body[data-theme-mode="os2045"] .os-alttab-item.active {
  background: rgba(255,184,107,0.15);
  border-color: rgba(255,184,107,0.5);
  box-shadow: 0 0 0 1px rgba(255,184,107,0.4) inset;
}
body[data-theme-mode="os2045"] .os-alttab-thumb {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--a-amber, #ffb86b), var(--a-amber-2, #ff7a42));
  color: #1a0800;
  display: grid; place-items: center;
  font-family: 'Instrument Serif', serif; font-style: italic;
  font-size: 22px; font-weight: 500;
}
body[data-theme-mode="os2045"] .os-alttab-lbl {
  font-size: 11px;
  color: var(--ink, #eef2ff);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%;
}

/* ─── Reduced motion ──────────────────────────────────────────────── */
body[data-theme-mode="os2045"].os-reduced-motion .os-window,
body[data-theme-mode="os2045"].os-reduced-motion .os-start-menu,
body[data-theme-mode="os2045"].os-reduced-motion .os-taskbar .tb-btn,
body[data-theme-mode="os2045"].os-reduced-motion .os-desktop-icon,
body[data-theme-mode="os2045"].os-reduced-motion .os-desktop-icon .tile,
body[data-theme-mode="os2045"].os-reduced-motion .os-window-empty-loader,
body[data-theme-mode="os2045"].os-reduced-motion .os-taskbar .tray-ai::after {
  transition: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  body[data-theme-mode="os2045"] .os-window,
  body[data-theme-mode="os2045"] .os-start-menu,
  body[data-theme-mode="os2045"] .os-taskbar .tb-btn,
  body[data-theme-mode="os2045"] .os-desktop-icon,
  body[data-theme-mode="os2045"] .os-desktop-icon .tile,
  body[data-theme-mode="os2045"] .os-window-empty-loader,
  body[data-theme-mode="os2045"] .os-taskbar .tray-ai::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ─── Hide legacy desktop UI when OS-2045 shell is active ────────── */
body[data-theme-mode="os2045"].os2045-shell-active.logged-in #desktop > .desktop-icons,
body[data-theme-mode="os2045"].os2045-shell-active.logged-in #taskbar,
body[data-theme-mode="os2045"].os2045-shell-active.logged-in #startMenu,
body[data-theme-mode="os2045"].os2045-shell-active.logged-in #desktopContextMenu {
  display: none !important;
}

/* Mobile fallback — keep usable on narrow viewports */
@media (max-width: 900px) {
  body[data-theme-mode="os2045"] .os-taskbar {
    bottom: 8px;
    left: 8px; right: 8px;
    transform: none;
    width: auto;
    overflow-x: auto;
  }
  body[data-theme-mode="os2045"] .os-start-menu {
    width: calc(100vw - 24px);
    left: 12px;
    transform: translateY(10px);
  }
  body[data-theme-mode="os2045"] .os-start-menu.open {
    transform: translateY(0);
  }
}
