:root {
  --silver: #d4d0c8;
  --white: #fff;
  --title-dark: #0a246a;
  --title-light: #a6caf0;
  --desktop: #3a6ea5;
  --shadow: #808080;
  --dk-shadow: #404040;
  --highlight: #0a246a;
  --highlight-text: #fff;
  --link: #00f;
  --error: #c62828;
  --font: "Trebuchet MS", Tahoma, Geneva, sans-serif;
  --text-muted: #57606a;
  --mono: "Consolas", "Courier New", monospace;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  font-size: 13px;
  color: #000;
  background: var(--desktop);
}

/* Window */
.window {
  background: var(--silver);
  border: 2px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  box-shadow: inset 1px 1px 0 var(--silver), inset -1px -1px 0 var(--shadow);
}

/* Title Bar */
.titlebar {
  background: linear-gradient(to right, var(--title-dark), var(--title-light));
  color: var(--white);
  font-weight: bold;
  font-size: 13px;
  padding: 4px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.titlebar-buttons {
  display: flex;
  gap: 2px;
}

.titlebar-btn {
  width: 18px;
  height: 18px;
  background: var(--silver);
  border: 1px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  cursor: default;
}

/* Window Body */
.window-body { padding: 12px; }

/* Sunken Panel */
.sunken {
  background: var(--white);
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  box-shadow: inset 1px 1px 0 var(--dk-shadow);
  padding: 2px;
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-size: 13px;
  color: #000;
  background: var(--silver);
  border: 2px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  box-shadow: inset -1px -1px 0 var(--shadow), inset 1px 1px 0 var(--silver);
  padding: 4px 16px;
  cursor: default;
  min-width: 75px;
  text-align: center;
  text-decoration: none;
  outline: 1px dotted #000;
  outline-offset: -4px;
}

.btn:active {
  border-color: var(--dk-shadow) var(--white) var(--white) var(--dk-shadow);
  box-shadow: inset 1px 1px 0 var(--shadow);
  padding: 5px 15px 3px 17px;
}

/* Focus-visible styles */
:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -2px;
}

.titlebar-btn:focus-visible {
  outline: 1px dotted #fff;
  outline-offset: -2px;
}

.desktop-icon:focus-visible {
  background: rgba(0,0,0,0.15);
  border-color: rgba(255,255,255,0.3);
  outline: 1px dotted #fff;
  outline-offset: 2px;
}

.start-menu-item:focus-visible {
  background: var(--highlight);
  color: var(--highlight-text);
}

.calc-btn:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -3px;
}

/* Section Title */
.section-title {
  font-size: 13px;
  font-weight: bold;
  margin: 12px 0 6px 0;
}

.section-title:first-child { margin-top: 0; }

/* Separator */
.separator {
  border-top: 1px solid var(--shadow);
  border-bottom: 1px solid var(--white);
  margin: 8px 0;
}

/* Status Bar */
.statusbar {
  background: var(--silver);
  border-top: 2px solid var(--shadow);
  padding: 2px 3px;
  font-size: 12px;
  color: #000;
  display: flex;
  gap: 4px;
}

.statusbar-section {
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  padding: 1px 8px;
  flex: 1;
}

/* Error Dialog Pattern */
.error-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.error-text { font-size: 13px; line-height: 1.5; }
.error-text h1, .error-text strong { font-size: 14px; font-weight: bold; margin-bottom: 6px; }
.error-text strong { display: block; }

.button-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* HUD (mini-window for game overlays) */
.hud-titlebar {
  background: linear-gradient(to right, var(--title-dark), var(--title-light));
  color: var(--white);
  font-weight: bold;
  font-size: 12px;
  padding: 3px 6px;
}

.hud-body { padding: 8px 12px; line-height: 1.6; }

.hud-statusbar {
  border-top: 2px solid var(--shadow);
  padding: 2px 6px;
  font-size: 11px;
  display: flex;
}

.hud-statusbar-section {
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  padding: 1px 6px;
  flex: 1;
}

/* Device-gate overlay (shown/hidden via media query per page) */
.device-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--desktop);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.device-dialog {
  background: var(--silver);
  border: 2px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  box-shadow: inset 1px 1px 0 var(--silver), inset -1px -1px 0 var(--shadow);
  max-width: 95vw;
}

/* ============================================================
   Desktop OS Layout
   ============================================================ */

/* Desktop & Desktop Area */
.desktop {
  display: flex;
  flex-direction: column;
  background: var(--desktop);
  height: 100vh;
  height: var(--vh, 100vh);
  overflow: hidden;
}

.desktop-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 16px 16px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* Desktop Icon */
.desktop-icon {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 80px;
  gap: 4px;
  padding: 4px 8px;
  cursor: default;
  user-select: none;
  border: 1px solid transparent;
  border-radius: 2px;
}

.desktop-icon:hover {
  background: rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.desktop-icon-img {
  width: 48px;
  height: 48px;
}

.desktop-icon-label {
  color: var(--white);
  font-size: 12px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  text-align: center;
  max-width: 72px;
  overflow-wrap: break-word;
}

/* ============================================================
   Taskbar
   ============================================================ */

.taskbar {
  background: var(--silver);
  border-top: 2px solid var(--white);
  padding: 6px 20px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Start Button */
.start-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: bold;
  color: #000;
  background: var(--silver);
  border: 2px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  box-shadow: inset -1px -1px 0 var(--shadow), inset 1px 1px 0 var(--silver);
  padding: 2px 8px;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  user-select: none;
}

.start-btn:active,
.start-btn.pressed {
  border-color: var(--dk-shadow) var(--white) var(--white) var(--dk-shadow);
  box-shadow: inset 1px 1px 0 var(--shadow);
  padding: 3px 7px 1px 9px;
}

/* Start Menu */
.start-menu {
  display: none;
  position: absolute;
  bottom: 34px;
  left: 4px;
  min-width: 180px;
  background: var(--silver);
  border: 2px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  box-shadow: inset 1px 1px 0 var(--silver), inset -1px -1px 0 var(--shadow);
  z-index: 50;
}

.start-menu.open { display: block; }

/* Start Menu Items */
.start-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: default;
  font-size: 13px;
  color: #000;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.start-menu-item:hover {
  background: var(--highlight);
  color: var(--highlight-text);
}

button.start-menu-item {
  background: none;
  border: none;
  font: inherit;
  width: 100%;
  text-align: left;
  cursor: default;
}

.start-menu-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.start-menu-item .arrow { margin-left: auto; font-size: 10px; }

/* Start Menu Separator */
.start-menu-separator {
  border-top: 1px solid var(--shadow);
  border-bottom: 1px solid var(--white);
  margin: 4px 2px;
}

/* Submenus */
.start-menu-item.has-submenu { position: relative; }

.start-submenu {
  display: none;
  position: absolute;
  left: 100%;
  bottom: -2px;
  min-width: 180px;
  background: var(--silver);
  border: 2px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  box-shadow: inset 1px 1px 0 var(--silver), inset -1px -1px 0 var(--shadow);
}

.start-menu-item.has-submenu:hover > .start-submenu { display: block; }

/* Empty submenu placeholder */
.start-menu-empty {
  padding: 6px 12px;
  font-size: 12px;
  font-style: italic;
  color: var(--shadow);
  white-space: nowrap;
}

/* Taskbar Items */
.taskbar-items {
  flex: 1;
  display: flex;
  gap: 2px;
  overflow: hidden;
}

.taskbar-item {
  font-family: var(--font);
  font-size: 12px;
  background: var(--silver);
  border: 1px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  padding: 2px 8px;
  min-width: 120px;
  max-width: 180px;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.taskbar-item.active {
  border-color: var(--dk-shadow) var(--white) var(--white) var(--dk-shadow);
  box-shadow: inset 1px 1px 0 var(--shadow);
  background: #bbb8b0;
}

/* System Tray */
.system-tray {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  padding: 1px 8px;
}

.tray-icon {
  width: 16px;
  height: 16px;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tray-clock {
  font-size: 12px;
  padding-left: 6px;
  white-space: nowrap;
}

/* Volume Popup */
.volume-popup {
  display: none;
  position: absolute;
  bottom: 36px;
  right: 4px;
  background: var(--silver);
  border: 2px solid;
  border-color: var(--white) var(--dk-shadow) var(--dk-shadow) var(--white);
  box-shadow: inset 1px 1px 0 var(--silver), inset -1px -1px 0 var(--shadow);
  padding: 12px;
  z-index: 50;
  text-align: center;
}

.volume-popup.open { display: block; }

.volume-slider {
  writing-mode: vertical-lr;
  direction: rtl;
  height: 100px;
  margin: 8px auto;
  display: block;
}

.volume-popup label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  cursor: default;
}

/* ============================================================
   Window Animations
   ============================================================ */

@keyframes windowFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes windowRestore {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.window.closing,
.window.minimizing {
  animation: windowFadeOut 150ms ease-in forwards;
  will-change: opacity;
}

.window.restoring {
  animation: windowRestore 150ms ease-out forwards;
  will-change: opacity;
}

/* Draggable Window */
.window.draggable {
  position: absolute;
  z-index: 10;
}

.window.draggable .titlebar {
  cursor: move;
}

.window.draggable .titlebar-btn {
  cursor: default;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .window.closing, .window.minimizing, .window.restoring { animation: none; }
}
