:root {
  --os-sky: #4072CE;
  --terminal: #123F68;
  --primary: #065279;
  --os-text: #FFFCF0;
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip-link {
  position: fixed;
  z-index: 200;
  left: 16px;
  top: 12px;
  padding: 8px 12px;
  background: var(--cream);
  color: var(--primary);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.os-desktop {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background: var(--os-sky);
  color: var(--os-text);
  transition: opacity 260ms ease;
}

.stars { position: absolute; inset: 0; pointer-events: none; }
.stars i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  background: var(--yellow);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  opacity: var(--o);
  rotate: 12deg;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 10px;
  color: var(--os-text);
  font-size: 11px;
}
.os-brand {
  border-bottom: 2px solid var(--yellow);
  color: var(--os-text);
  font-family: 'Fraunces Local', 'Songti SC', serif;
  font-size: 13px;
  font-style: italic;
  text-decoration: none;
}
.os-brand em { font-weight: 700; }
.topbar nav { display: flex; gap: 16px; margin-left: 16px; }
.topbar button {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--os-text);
  font: inherit;
  cursor: var(--paw-cursor);
}
.topbar button:hover {
  color: var(--os-text);
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-underline-offset: 3px;
}
#os-clock { margin-left: auto; font-family: ui-monospace, monospace; font-size: 10px; }

.icon-grid {
  position: absolute;
  z-index: 4;
  top: 50px;
  right: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px 18px;
  width: min(290px, 26vw);
  max-height: calc(100svh - 190px);
  padding: 4px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--os-text) rgba(255, 252, 240, .15);
}
.icon-grid::-webkit-scrollbar { width: 4px; }
.icon-grid::-webkit-scrollbar-track { background: rgba(255, 252, 240, .15); }
.icon-grid::-webkit-scrollbar-thumb { background: var(--os-text); border-radius: 4px; }
.desktop-icon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--os-text);
  cursor: var(--paw-cursor);
  transform-origin: 50% 70%;
}
.icon-art { display: block; width: 48px; height: 48px; filter: drop-shadow(2px 3px 0 rgba(6, 82, 121, .15)); }
.file-icon .icon-art { width: 43px; }
.file-icon b {
  position: absolute;
  top: 30px;
  left: 50%;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--primary);
  color: var(--cream);
  font-family: ui-monospace, monospace;
  font-size: 8px;
  font-weight: 500;
  translate: -50% -50%;
}
.desktop-icon > span {
  max-width: 90px;
  font-size: 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 2px rgba(6, 82, 121, .4);
}
.desktop-icon:hover, .desktop-icon:focus-visible, .desktop-icon.is-wiggling { animation: icon-wiggle 360ms ease-in-out 1; }
.desktop-icon:focus-visible, .dock-item:focus-visible, .topbar button:focus-visible, .os-brand:focus-visible, .resident:focus-visible {
  outline: 3px dashed var(--os-text);
  outline-offset: 4px;
}

.resident {
  position: absolute;
  z-index: 4;
  right: 3vw;
  bottom: 65px;
  width: clamp(180px, 18vw, 300px);
  transform-origin: 50% 100%;
}
.resident img { display: block; width: 100%; height: auto; }
.resident:hover, .resident:focus-visible { animation: icon-wiggle 420ms ease-in-out 1; }

.dock {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: 16px;
  display: flex;
  align-items: center;
  padding: 4px;
  border: 2px solid var(--primary);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 0 4px 0 rgba(6, 82, 121, .16);
  translate: -50% 0;
}
.dock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
  font-size: 12px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: var(--paw-cursor);
  transform-origin: center;
}
.dock-item > span { font-size: 9px; }
.dock-item.is-current { background: var(--os-sky); color: var(--os-text); cursor: default; }
.dock-item:not(.is-current):hover, .dock-item:not(.is-current):focus-visible, .dock-item.is-wiggling {
  animation: icon-wiggle 360ms ease-in-out 1;
}

@keyframes icon-wiggle {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-3px) rotate(-3deg); }
  70% { transform: translateY(-2px) rotate(3deg); }
}

.boot-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: #F5E7D2;
  opacity: 0;
  visibility: hidden;
  transition: opacity 240ms ease, visibility 240ms;
}
body.is-booting { overflow: hidden; }
body.is-booting .boot-screen { opacity: 1; visibility: visible; }
body.is-booting .os-desktop { opacity: 0; }
body.is-booting .skip-link { display: none; }
.laptop {
  width: min(720px, 88vw);
  filter: drop-shadow(0 20px 18px rgba(6, 82, 121, .17));
}
.terminal {
  overflow: hidden;
  border: 10px solid #202224;
  border-bottom-width: 12px;
  border-radius: 16px 16px 4px 4px;
  background-color: var(--os-sky);
  background-image: repeating-linear-gradient(180deg, rgba(6, 82, 121, .09) 0 1px, transparent 1px 23px);
  color: var(--os-text);
  box-shadow: inset 0 0 0 1px #45484B;
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
}
.terminal-bar {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 42px;
  margin: 0 28px;
  padding: 8px 0 7px;
  border-bottom: 1px solid rgba(255, 252, 240, .12);
}
.window-controls { display: flex; gap: 6px; }
.window-controls span { width: 9px; height: 9px; border-radius: 50%; background: #FF6F61; }
.window-controls span:nth-child(2) { background: #FBC024; }
.window-controls span:nth-child(3) { background: #35B84A; }
.terminal-bar p {
  position: absolute;
  left: 50%;
  margin: 0;
  font-size: 10px;
  opacity: .55;
  white-space: nowrap;
  translate: -50% 0;
}
.terminal-body { min-height: 400px; padding: 24px 32px 28px; }
.boot-line {
  min-height: 1.6em;
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.boot-line[hidden] { display: none; }
.boot-group { margin-top: 20px; }
.prompt, .command-output { color: var(--os-text); }
.about-detail { padding-left: 1.3em; }
.echo-highlight {
  display: block;
  width: fit-content;
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--yellow);
  color: var(--primary);
  font-weight: 700;
}
.boot-progress-row { display: flex; align-items: center; min-height: 1.6em; }
#boot-progress {
  display: block;
  flex: none;
  width: 96px;
  height: 14px;
  margin: 0 2px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--yellow);
}
#boot-progress::-webkit-progress-bar { background: transparent; }
#boot-progress::-webkit-progress-value {
  background: repeating-linear-gradient(90deg, var(--yellow) 0 9px, transparent 9px 11px);
  transition: width 120ms ease-out;
}
#boot-progress::-moz-progress-bar {
  background: repeating-linear-gradient(90deg, var(--yellow) 0 9px, transparent 9px 11px);
  transition: width 120ms ease-out;
}
#boot-percent { margin-left: 8px; color: var(--os-text); font: inherit; font-weight: 700; }
.laptop-base {
  position: relative;
  width: 108%;
  height: 16px;
  margin-left: -4%;
  border-radius: 2px 2px 16px 16px;
  background: linear-gradient(180deg, #E5E3DE 0%, #C8C7C2 58%, #AAA9A4 100%);
  box-shadow: 0 4px 0 #92918D;
}
.laptop-base span {
  display: block;
  width: 14%;
  height: 5px;
  margin: 0 auto;
  border-radius: 0 0 9px 9px;
  background: #AAA9A4;
}

@media (max-width: 900px) {
  .icon-grid { right: 12px; width: 270px; gap: 18px 12px; }
  .resident { right: 2vw; width: 210px; }
}

@media (max-width: 600px) {
  .os-desktop { min-height: 780px; }
  .topbar { padding: 6px 10px; font-size: 10px; }
  .topbar nav { gap: 10px; margin-left: 12px; }
  .os-brand { font-size: 12px; }
  .icon-grid {
    top: 58px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: none;
    gap: 20px 8px;
    overflow: visible;
  }
  .desktop-icon > span { font-size: 10px; }
  .resident { right: 2px; bottom: 75px; width: 170px; }
  .dock { bottom: 12px; }
  .dock-item { gap: 5px; padding: 10px 13px; font-size: 11px; }
  .dock-item > span { font-size: 8px; }
  .terminal { border-width: 8px; border-bottom-width: 10px; border-radius: 12px 12px 4px 4px; }
  .terminal-bar { min-height: 36px; margin: 0 18px; padding: 6px 0; }
  .terminal-bar p { font-size: 8px; }
  .window-controls { gap: 5px; }
  .window-controls span { width: 7px; height: 7px; }
  .terminal-body { min-height: 420px; padding: 20px 16px 24px; }
  .boot-line { font-size: 11px; line-height: 1.55; }
  .boot-group { margin-top: 16px; }
  #boot-progress { width: 80px; height: 12px; }
  .laptop-base { height: 12px; border-radius: 2px 2px 12px 12px; }
}

@media (max-height: 720px) and (min-width: 601px) {
  .icon-grid { top: 42px; gap: 10px 16px; max-height: calc(100svh - 155px); }
  .icon-art { width: 40px; height: 40px; }
  .file-icon b { top: 25px; }
  .resident { width: 180px; }
}

@media (max-height: 600px) {
  .laptop { width: min(620px, 80vw); }
  .terminal-body { min-height: 300px; padding: 16px 28px 18px; }
  .boot-line { font-size: 11px; line-height: 1.45; }
  .boot-group { margin-top: 10px; }
}

@media (max-height: 420px) {
  .boot-screen { padding: 10px 16px; overflow-y: auto; }
  .laptop { width: min(560px, 88vw); }
  .terminal-bar { min-height: 30px; padding: 4px 0; }
  .terminal-body { min-height: 0; padding: 10px 18px 12px; }
  .boot-line { font-size: 10px; line-height: 1.35; }
  .boot-group { margin-top: 8px; }
  .laptop-base { height: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .os-desktop, .boot-screen { transition: none; }
  #boot-progress::-webkit-progress-value, #boot-progress::-moz-progress-bar { transition: none; }
  .desktop-icon, .dock-item, .resident { animation: none !important; }
}
