:root {
  --desktop: #0a6a65;
  --desktop-deep: #07534f;
  --title: #55265f;
  --title-active: #4b2d77;
  --surface: #c9c5b8;
  --surface-light: #eee9dc;
  --surface-dark: #565a58;
  --ink: #171819;
  --mint: #79d5af;
  --coral: #e6756c;
  --focus: #fff4a3;
  --taskbar-height: 44px;
  --font: "IBM Plex Sans", Arial, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  color-scheme: light;
  font-family: var(--font);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 0; min-height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: var(--desktop-deep); font-size: 14px; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { border-radius: 0; }
a { color: #142c85; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10000;
  padding: 9px 12px;
  transform: translateY(-150%);
  border: 2px solid var(--ink);
  background: var(--focus);
  color: var(--ink);
  font-weight: 500;
}
.skip-link:focus { transform: none; }

.desktop {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 360px;
  overflow: hidden;
  padding: max(10px, env(safe-area-inset-top)) 10px calc(var(--taskbar-height) + env(safe-area-inset-bottom) + 10px);
  background-color: var(--desktop);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    radial-gradient(circle at 82% 18%, rgba(121,213,175,.18), transparent 28%);
  background-size: 16px 16px, 16px 16px, auto;
}

[data-wallpaper="night"] .desktop {
  --desktop: #24305e;
  --desktop-deep: #171c3c;
  background-color: var(--desktop);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    radial-gradient(circle at 78% 14%, rgba(230,117,108,.17), transparent 26%);
}

.wallpaper-mark {
  position: absolute;
  right: 34px;
  top: 28px;
  display: grid;
  grid-template-columns: 64px auto;
  align-items: center;
  column-gap: 12px;
  color: rgba(255,255,255,.72);
  text-shadow: 1px 1px rgba(0,0,0,.45);
  user-select: none;
}
.wallpaper-mark img { grid-row: 1 / 3; image-rendering: pixelated; opacity: .7; }
.wallpaper-mark span { align-self: end; font-size: 28px; font-weight: 500; letter-spacing: -.04em; }
.wallpaper-mark small { align-self: start; font-family: var(--mono); font-size: 10px; }

.desktop-icons {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, 96px);
  grid-auto-rows: 102px;
  align-content: start;
  gap: 2px 8px;
  width: min-content;
  max-height: 100%;
}

.desktop-icon {
  position: relative;
  width: 96px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  padding: 4px 5px 3px;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  cursor: default;
  text-shadow: 1px 1px 0 rgba(0,0,0,.8);
}
.desktop-icon img { width: 52px; height: 52px; flex: none; image-rendering: pixelated; }
.desktop-icon span {
  max-width: 88px;
  padding: 1px 3px;
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}
.desktop-icon:hover { background: rgba(255,255,255,.08); }
.desktop-icon.is-selected { border-color: rgba(255,255,255,.65); background: rgba(55,45,118,.55); }
.desktop-icon.is-selected span { outline: 1px dotted #fff; background: var(--title-active); }
.desktop-icon:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; }

.catalogue-message,
.system-message {
  position: absolute;
  left: 18px;
  bottom: calc(var(--taskbar-height) + env(safe-area-inset-bottom) + 14px);
  z-index: 2;
  max-width: 360px;
  margin: 0;
  padding: 8px 10px;
  border: 2px solid;
  border-color: var(--surface-light) var(--surface-dark) var(--surface-dark) var(--surface-light);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 1px 1px #000;
}

.window-layer { position: absolute; inset: 0 0 calc(var(--taskbar-height) + env(safe-area-inset-bottom)) 0; z-index: 10; pointer-events: none; }

.os-window {
  margin: 0;
  padding: 3px;
  border: 2px solid;
  border-color: var(--surface-light) #333 #333 var(--surface-light);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 2px 2px 0 rgba(0,0,0,.7);
}
.os-app-window {
  position: absolute;
  width: min(520px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - var(--taskbar-height) - 24px));
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}
.os-app-window[data-active="false"] .window-titlebar { background: #68666d; }
.os-app-window.is-minimised { display: none; }

.window-titlebar {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 3px 3px 7px;
  background: linear-gradient(90deg, var(--title), var(--title-active) 70%, #775879);
  color: #fff;
  user-select: none;
}
.window-titlebar h1,
.window-titlebar h2 {
  min-width: 0;
  flex: 1;
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.window-control {
  width: 25px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border: 2px solid;
  border-color: var(--surface-light) var(--surface-dark) var(--surface-dark) var(--surface-light);
  background: var(--surface);
  color: var(--ink);
  font-family: Arial, sans-serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: default;
}
.window-control:active { border-color: var(--surface-dark) var(--surface-light) var(--surface-light) var(--surface-dark); padding: 1px 0 1px 1px; }

.window-body {
  min-height: 0;
  padding: 22px;
  overflow: auto;
  border: 1px solid #77746e;
  border-top: 0;
  background: var(--surface);
}
.window-body h2 { margin: 0 0 12px; font-size: 20px; line-height: 1.15; }
.window-body h3 { margin: 18px 0 8px; font-size: 14px; }
.window-body p { margin: 0 0 13px; line-height: 1.55; }
.window-body p:last-child { margin-bottom: 0; }
.window-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px;
}

.os-button {
  min-width: 88px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border: 2px solid;
  border-color: var(--surface-light) var(--surface-dark) var(--surface-dark) var(--surface-light);
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  box-shadow: 1px 1px 0 #222;
  cursor: default;
}
.os-button:active { border-color: var(--surface-dark) var(--surface-light) var(--surface-light) var(--surface-dark); box-shadow: none; transform: translate(1px,1px); }
.default-button { outline: 1px dotted var(--ink); outline-offset: -6px; }
.os-button:focus-visible,
.window-control:focus-visible,
.launcher-button:focus-visible,
.task-button:focus-visible,
.menu-items :is(button,a):focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.project-heading { display: grid; grid-template-columns: 64px minmax(0,1fr); align-items: center; gap: 16px; margin-bottom: 18px; }
.project-heading img { width: 64px; height: 64px; image-rendering: pixelated; }
.project-heading h2 { margin-bottom: 4px; }
.project-heading p { margin: 0; color: #34363a; font-style: italic; }
.project-summary { padding: 14px; border: 2px inset var(--surface-light); background: var(--surface-light); }
.project-status { display: flex; align-items: center; gap: 8px; margin-top: 16px !important; font-family: var(--mono); font-size: 11px; text-transform: uppercase; }
.project-status::before { content: ""; width: 9px; height: 9px; border: 1px solid #164e3f; background: var(--mint); }
.project-status[data-status="building"]::before { border-color: #7c342e; background: var(--coral); }
.project-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.directory-list { margin: 0; padding: 2px; border: 2px inset var(--surface-light); background: #fffdf5; list-style: none; }
.directory-list li + li { border-top: 1px dotted #aaa69d; }
.directory-item { width: 100%; min-height: 52px; display: grid; grid-template-columns: 40px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 6px 9px; border: 0; background: transparent; color: var(--ink); text-align: left; cursor: default; }
.directory-item:hover { background: #d9e5e0; }
.directory-item:focus-visible { outline: 3px solid var(--title-active); outline-offset: -3px; }
.directory-item img { width: 36px; height: 36px; image-rendering: pixelated; }
.directory-item strong { display: block; font-size: 13px; }
.directory-item small { color: #555; font-size: 11px; }
.directory-item > small { font-family: var(--mono); text-transform: uppercase; }

.about-grid { display: grid; grid-template-columns: 80px minmax(0,1fr); gap: 18px; }
.about-grid > img { width: 80px; height: 80px; image-rendering: pixelated; }
.system-table { width: 100%; margin: 16px 0; border-collapse: collapse; font-family: var(--mono); font-size: 11px; }
.system-table th, .system-table td { padding: 6px 8px; border: 1px solid #8a877f; text-align: left; }
.system-table th { width: 36%; font-weight: 500; background: #ded9cb; }
.disclosure { color: #3e3b3f; font-size: 11px; }

.corner-links { display: grid; gap: 8px; }
.corner-links a { min-height: 54px; display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid; border-color: var(--surface-light) var(--surface-dark) var(--surface-dark) var(--surface-light); background: #ddd8ca; color: var(--ink); text-decoration: none; }
.corner-links img { width: 34px; height: 34px; image-rendering: pixelated; }
.corner-links strong { display: block; }
.corner-links small { color: #4e4e4e; }

.control-group { margin: 0 0 16px; padding: 14px; border: 2px groove var(--surface-light); }
.control-group legend { padding: 0 5px; font-weight: 500; }
.control-group label { min-height: 40px; display: flex; align-items: center; gap: 9px; }
.control-group input[type="checkbox"] { width: 20px; height: 20px; }
.control-group select { min-height: 36px; margin-left: 6px; padding: 4px 30px 4px 8px; border-radius: 0; background: #fffdf5; }

.taskbar {
  position: absolute;
  z-index: 5000;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--taskbar-height) + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 4px max(5px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(5px, env(safe-area-inset-left));
  border-top: 2px solid var(--surface-light);
  background: var(--surface);
  box-shadow: 0 -1px #363838;
}
.launcher-button,
.task-button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 5px;
  border: 2px solid;
  border-color: var(--surface-light) var(--surface-dark) var(--surface-dark) var(--surface-light);
  background: var(--surface);
  color: var(--ink);
  cursor: default;
}
.launcher-button { flex: none; font-weight: 700; }
.launcher-button[aria-expanded="true"],
.task-button[aria-pressed="true"] { border-color: var(--surface-dark) var(--surface-light) var(--surface-light) var(--surface-dark); background: #aaa89f; }
.launcher-button img { width: 24px; height: 24px; image-rendering: pixelated; }
.task-buttons { min-width: 0; flex: 1; display: flex; gap: 3px; overflow-x: auto; scrollbar-width: thin; }
.task-button { width: min(178px, 20vw); min-width: 86px; justify-content: flex-start; overflow: hidden; font-size: 12px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.task-button img { width: 22px; height: 22px; flex: none; image-rendering: pixelated; }
.tray { height: 34px; flex: none; display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 2px inset var(--surface-light); font-family: var(--mono); font-size: 11px; }
.tray-light { width: 8px; height: 8px; border: 1px solid #1b513f; background: var(--mint); }

.eunni-menu {
  position: absolute;
  z-index: 6000;
  left: max(5px, env(safe-area-inset-left));
  bottom: calc(var(--taskbar-height) + env(safe-area-inset-bottom) + 2px);
  width: min(320px, calc(100vw - 10px));
  max-height: calc(100dvh - var(--taskbar-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 6px);
  display: grid;
  grid-template-columns: 32px minmax(0,1fr);
  padding: 3px;
  overflow: auto;
  border: 2px solid;
  border-color: var(--surface-light) var(--surface-dark) var(--surface-dark) var(--surface-light);
  background: var(--surface);
  box-shadow: 2px 2px #111;
}
.menu-rail { position: relative; background: linear-gradient(0deg, var(--title), #3e6477); color: #fff; }
.menu-rail span { position: absolute; left: 5px; bottom: 8px; font-size: 16px; font-weight: 500; letter-spacing: -.02em; writing-mode: vertical-rl; transform: rotate(180deg); }
.menu-rail b { font-weight: 400; color: var(--mint); }
.menu-items { display: grid; align-content: start; }
.menu-items :is(button,a) { min-height: 50px; display: grid; grid-template-columns: 38px minmax(0,1fr); align-items: center; gap: 7px; padding: 6px 10px; border: 0; background: transparent; color: var(--ink); text-align: left; text-decoration: none; cursor: default; }
.menu-items :is(button,a):hover,
.menu-items :is(button,a):focus { background: var(--title-active); color: #fff; }
.menu-items img { width: 32px; height: 32px; image-rendering: pixelated; }
.menu-items span { display: flex; justify-content: space-between; gap: 8px; }
.menu-rule { display: block; height: 2px; margin: 3px 5px; border-top: 1px solid #74726d; border-bottom: 1px solid var(--surface-light); }

.welcome-window {
  position: fixed;
  z-index: 4500;
  top: clamp(48px, 16vh, 150px);
  left: 50%;
  width: min(520px, calc(100vw - 28px));
  transform: translateX(-50%);
}
.welcome-window::backdrop,
.shutdown-dialog::backdrop { background: rgba(8, 28, 27, .48); }
.welcome-body { display: grid; grid-template-columns: 74px minmax(0,1fr); gap: 18px; }
.welcome-mark img { width: 64px; height: 64px; image-rendering: pixelated; }
.welcome-body h2 { margin-top: 2px; }
.os-check { min-height: 44px; display: flex; align-items: center; gap: 9px; margin-top: 18px; font-size: 12px; }
.os-check input { width: 20px; height: 20px; }

.shutdown-dialog { position: fixed; z-index: 8000; top: 30%; left: 50%; width: min(430px, calc(100vw - 28px)); transform: translate(-50%,-30%); }
.shutdown-body { display: grid; grid-template-columns: 64px minmax(0,1fr); align-items: center; gap: 18px; }
.shutdown-body img { image-rendering: pixelated; }

.shutdown-screen { position: fixed; inset: 0; z-index: 10000; display: grid; place-content: center; justify-items: center; gap: 22px; padding: 24px; background: #142444; color: #fff6d6; text-align: center; }
.shutdown-screen img { image-rendering: pixelated; }
.shutdown-screen h1 { max-width: 700px; margin: 0; font-family: var(--mono); font-size: clamp(20px, 4vw, 38px); font-weight: 500; }

[data-large-text="true"] { font-size: 118%; }
[data-large-text="true"] .desktop-icon span,
[data-large-text="true"] .task-button { font-size: 13px; }
[data-contrast="high"] {
  --desktop: #00514d;
  --title: #321341;
  --title-active: #281040;
  --surface: #e7e5dc;
  --surface-light: #fff;
  --surface-dark: #161616;
  --ink: #000;
}
[data-contrast="high"] .desktop-icon { text-shadow: 2px 2px #000; }

@media (prefers-contrast: more) {
  :root { --surface: #e7e5dc; --surface-light: #fff; --surface-dark: #111; --ink: #000; }
  .desktop-icon { text-shadow: 2px 2px #000; }
}

@media (max-width: 700px), (max-height: 520px) {
  :root { --taskbar-height: 52px; }
  .desktop { padding-inline: 4px; }
  .wallpaper-mark { display: none; }
  .desktop-icons { width: 100%; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); grid-auto-rows: 98px; overflow-y: auto; padding: 4px 0 10px; }
  .desktop-icon { width: 100%; min-height: 92px; }
  .desktop-icon img { width: 48px; height: 48px; }
  .window-layer { position: fixed; inset: env(safe-area-inset-top) 0 calc(var(--taskbar-height) + env(safe-area-inset-bottom)) 0; }
  .os-app-window { position: fixed !important; inset: env(safe-area-inset-top) 0 calc(var(--taskbar-height) + env(safe-area-inset-bottom)) 0 !important; width: 100%; max-height: none; box-shadow: none; }
  .os-app-window .window-body { flex: 1; }
  .window-control { width: 44px; height: 44px; }
  .window-titlebar { min-height: 50px; }
  .window-titlebar h1, .window-titlebar h2 { font-size: 14px; }
  .window-body { padding: 18px; }
  .os-button { min-height: 44px; }
  .control-group label, .control-group select { min-height: 44px; }
  .launcher-button, .task-button, .tray { height: 44px; }
  .task-button { width: 104px; min-width: 72px; padding-inline: 5px; }
  .tray { padding-inline: 6px; }
  .tray-light { display: none; }
  .welcome-window { top: max(10px, env(safe-area-inset-top)); max-height: calc(100dvh - var(--taskbar-height) - env(safe-area-inset-bottom) - 20px); overflow: auto; }
  .welcome-body { grid-template-columns: 1fr; }
  .welcome-mark { display: none; }
  .catalogue-message { left: 8px; right: 8px; max-width: none; }
  .about-grid { grid-template-columns: 1fr; }
  .about-grid > img { width: 64px; height: 64px; }
}

@media (max-width: 390px) {
  .desktop-icons { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .desktop-icon { padding-inline: 1px; }
  .desktop-icon span { max-width: 100%; font-size: 11px; }
  .launcher-button span { display: none; }
  .launcher-button { padding-right: 5px; }
  .tray { font-size: 10px; }
}

@media (prefers-reduced-motion: no-preference) {
  .os-app-window { animation: window-open 100ms steps(2, end); }
  .tray-light { animation: tray-pulse 4s steps(2, end) infinite; }
  @keyframes window-open { from { opacity: .35; transform: scale(.985); } to { opacity: 1; transform: none; } }
  @keyframes tray-pulse { 50% { background: #d3f4df; } }
}

[data-reduce-motion="true"] *,
[data-reduce-motion="true"] *::before,
[data-reduce-motion="true"] *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
