/* ---------- skin colour tokens (animatable) ---------- */
@property --hi { syntax: '<color>'; inherits: true; initial-value: #bfe6ff; }
@property --base { syntax: '<color>'; inherits: true; initial-value: #1c8cff; }
@property --deep { syntax: '<color>'; inherits: true; initial-value: #0634b8; }
@property --glow { syntax: '<color>'; inherits: true; initial-value: #5fd0ff; }
@property --ink { syntax: '<color>'; inherits: true; initial-value: #e9f7ff; }
@property --lcd { syntax: '<color>'; inherits: true; initial-value: #7fe3ff; }

:root {
  --hi: #bfe6ff;
  --base: #1c8cff;
  --deep: #0634b8;
  --glow: #5fd0ff;
  --ink: #e9f7ff;
  --lcd: #7fe3ff;
  --ui: Tahoma, Verdana, 'Segoe UI', system-ui, sans-serif;
  --pixel: 'Silkscreen', 'VT323', monospace;
  --lcdfont: 'VT323', ui-monospace, monospace;
  --display: 'Unbounded', 'Arial Black', sans-serif;
  --taskbar: 44px;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: --hi 0.9s ease, --base 0.9s ease, --deep 0.9s ease, --glow 0.9s ease, --ink 0.9s ease, --lcd 0.9s ease;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2a6fd6;
  font-family: var(--ui);
  font-size: 12px;
  color: #10131a;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px dashed #fff; outline-offset: 3px; }

.readable {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- wallpaper ---------- */
.wallpaper { position: fixed; inset: 0; }
.wallpaper canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#clouds { animation: drift 140s linear infinite alternate; }
@keyframes drift { from { transform: translateX(-3%); } to { transform: translateX(3%); } }

/* ---------- desktop icons ---------- */
.desk-icons {
  position: fixed;
  top: 14px;
  left: 10px;
  bottom: calc(var(--taskbar) + 10px);
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 92px);
  gap: 4px 6px;
  z-index: 2;
}
.dicon {
  width: 84px;
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 5px 2px;
  border: 1px dotted transparent;
  background: none;
  color: #fff;
  font-size: 11px;
  text-align: center;
  text-shadow: 1px 1px 1px #000, 0 0 4px #0008;
  border-radius: 3px;
}
.dicon__img { width: 46px; height: 46px; filter: drop-shadow(1px 3px 2px #0006); transition: transform 0.25s var(--ease-spring); }
.dicon:hover .dicon__img { transform: translateY(-3px) scale(1.06); }
.dicon__label { padding: 1px 3px; border-radius: 2px; line-height: 1.25; }
.dicon.is-selected .dicon__label { background: #2457d6; text-shadow: none; }
.dicon.is-selected .dicon__img { filter: drop-shadow(1px 3px 2px #0006) sepia(1) hue-rotate(180deg) saturate(3) brightness(0.85); }
.dicon.is-selected { border-color: #fff8; }

/* ---------- taskbar ---------- */
.taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--taskbar);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
  z-index: 50;
  background:
    linear-gradient(180deg, #ffffffb8 0%, #ffffff38 46%, #00000010 50%, #ffffff30 100%),
    linear-gradient(90deg, color-mix(in srgb, var(--deep) 70%, #0b1430), color-mix(in srgb, var(--base) 55%, #1a2448));
  border-top: 1px solid #ffffffc0;
  box-shadow: 0 -1px 0 #0005, 0 -8px 24px #0003;
  backdrop-filter: blur(10px) saturate(1.4);
}
.start {
  height: 100%;
  min-width: 108px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px 0 12px;
  border: 0;
  border-radius: 0 22px 22px 0;
  color: #fff;
  font-family: var(--display);
  font-weight: 900;
  font-style: italic;
  font-size: 19px;
  letter-spacing: -0.02em;
  text-shadow: 1px 1px 1px #0008;
  background:
    radial-gradient(120% 70% at 30% 10%, #ffffffd0, #fff0 60%),
    linear-gradient(180deg, var(--hi), var(--base) 45%, var(--deep));
  box-shadow: inset 0 -3px 6px #0004, inset 0 2px 1px #fffa, 2px 0 6px #0005;
  transition: filter 0.15s;
}
.start i {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--glow) 40%, var(--deep) 100%);
  box-shadow: 0 0 10px var(--glow), inset 0 -2px 3px #0006;
}
.start:hover { filter: brightness(1.12); }
.start[aria-expanded='true'] { filter: brightness(0.9); box-shadow: inset 0 3px 8px #0007; }
.tasks { flex: 1; display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.task {
  height: 32px;
  max-width: 180px;
  min-width: 0;
  flex: 0 1 180px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid #ffffff70;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  text-shadow: 0 1px 1px #0008;
  background: linear-gradient(180deg, #ffffff50, #ffffff10 48%, #0000 52%, #ffffff18);
  box-shadow: inset 0 1px 0 #fff6, 0 1px 2px #0004;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task.is-active { background: linear-gradient(180deg, #00000040, #00000010); box-shadow: inset 0 2px 5px #0007; }
.task i { flex: none; width: 14px; height: 14px; border-radius: 4px; background: var(--c, var(--base)); box-shadow: inset 0 1px 1px #fff8, 0 0 0 1px #0003; }
.tray {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(180deg, #00000030, #00000010);
  box-shadow: inset 0 1px 3px #0006, 0 1px 0 #fff4;
  font-size: 11px;
  text-shadow: 0 1px 1px #0008;
}
.tray__snd { border: 0; background: none; padding: 0; display: grid; }
.tray__snd svg { width: 18px; height: 18px; fill: #fff; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; }
.tray__snd .w { fill: none; opacity: 0.25; }
.tray__snd[aria-pressed='true'] .w { opacity: 1; }
.tray__clock { font-variant-numeric: tabular-nums; }

/* ---------- start menu ---------- */
.start-menu {
  position: fixed;
  left: 0;
  bottom: var(--taskbar);
  width: min(340px, 100vw);
  z-index: 60;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  background: #f4f7fb;
  box-shadow: 4px -4px 30px #0007, 0 0 0 1px #0004;
  transform-origin: bottom left;
  animation: pop 0.28s var(--ease-spring);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.start-menu__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #fff;
  background:
    radial-gradient(100% 120% at 20% 0, #ffffff70, #fff0 60%),
    linear-gradient(180deg, var(--base), var(--deep));
  text-shadow: 0 1px 2px #0008;
}
.start-menu__head b { display: block; font-size: 15px; }
.start-menu__head small { opacity: 0.85; }
.start-menu__list { list-style: none; margin: 0; padding: 6px; display: grid; gap: 2px; }
.start-menu__list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
}
.start-menu__list button:hover,
.start-menu__list button:focus-visible { background: var(--base); color: #fff; outline: 0; }
.start-menu__list .ic { width: 28px; height: 28px; flex: none; }
.start-menu__list b { display: block; font-size: 12px; }
.start-menu__list small { opacity: 0.7; }
.start-menu__foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--base) 30%, #dfe6f1), color-mix(in srgb, var(--deep) 30%, #c5cfdf));
}
.start-menu__foot button {
  padding: 5px 12px;
  border: 1px solid #0003;
  border-radius: 5px;
  background: linear-gradient(#fff, #e3e8f0);
  box-shadow: inset 0 1px 0 #fff;
}

/* ---------- context menu + toast ---------- */
.ctx {
  position: fixed;
  z-index: 80;
  min-width: 190px;
  margin: 0;
  padding: 3px;
  list-style: none;
  background: #fbfcfe;
  border: 1px solid #8994a8;
  box-shadow: 3px 3px 8px #0005;
  border-radius: 4px;
}
.ctx button { width: 100%; padding: 5px 22px; border: 0; background: none; text-align: left; border-radius: 3px; }
.ctx button:hover { background: var(--base); color: #fff; }
.ctx hr { border: 0; border-top: 1px solid #d2d8e2; margin: 3px 2px; }
.toast {
  position: fixed;
  right: 12px;
  bottom: calc(var(--taskbar) + 12px);
  z-index: 70;
  max-width: 300px;
  padding: 10px 14px 10px 36px;
  border: 1px solid #0006;
  border-radius: 8px;
  background: #fffde6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c8cff'/%3E%3Cpath d='M8 4v1M8 7v5' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 11px 11px / 16px no-repeat;
  box-shadow: 2px 3px 10px #0005;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--ease-spring);
}
.toast.in { opacity: 1; transform: none; }

/* ---------- boot + log-in ---------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  color: #c9d1dc;
  display: grid;
}
.boot__post {
  margin: 0;
  padding: 28px;
  font: 18px/1.35 var(--lcdfont);
  white-space: pre-wrap;
}
.boot.gone { animation: bootOut 0.9s ease forwards; }
@keyframes bootOut {
  0% { opacity: 1; filter: none; }
  40% { opacity: 1; filter: brightness(3) saturate(0); }
  100% { opacity: 0; filter: brightness(1); visibility: hidden; }
}
.login {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 78px 1fr 78px;
  color: #fff;
  background:
    radial-gradient(60% 60% at 20% 30%, #46b6ff 0%, #0000 70%),
    linear-gradient(160deg, #0d5bd8, #062a8f 60%, #031650);
  animation: fadeIn 0.6s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.login__band { display: flex; align-items: center; justify-content: space-between; padding: 0 32px; font-size: 12px; }
.login__band--top { background: linear-gradient(180deg, #021044, #0a2f9a); border-bottom: 2px solid; border-image: linear-gradient(90deg, #0000, #ffffffc0, #0000) 1; }
.login__band--bottom { background: linear-gradient(0deg, #021044, #0a2f9a); border-top: 2px solid; border-image: linear-gradient(90deg, #0000, #ff9a3c, #0000) 1; }
.login__mid { display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; gap: 0 40px; padding: 20px 6vw; }
.login__mid::before { content: ''; grid-column: 2; grid-row: 1; height: 60%; background: linear-gradient(#fff0, #fffa, #fff0); }
.login__left { grid-column: 1; grid-row: 1; text-align: right; }
.login__right { grid-column: 3; grid-row: 1; display: grid; gap: 14px; justify-items: start; }
.login__logo b {
  display: block;
  font: italic 900 clamp(56px, 9vw, 120px) / 0.9 var(--display);
  letter-spacing: -0.04em;
  background: linear-gradient(180deg, #fff 0%, #cfe9ff 45%, #5aa9ff 52%, #e8f5ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(2px 4px 0 #021a6a) drop-shadow(0 0 22px #5fd0ff80);
}
.login__logo span { font: 16px var(--pixel); letter-spacing: 0.1em; color: #ffcf6e; }
.login__left p { margin: 18px 0 0; font-size: 16px; opacity: 0.85; }
.user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px 8px 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: #fff;
  text-align: left;
  transition: background 0.2s;
}
.user:hover,
.user:focus-visible { background: linear-gradient(90deg, #ffffff30, #fff0); outline: 0; }
.user b { display: block; font-size: 20px; font-weight: 400; }
.user small { font-size: 12px; opacity: 0.8; }
.user--quiet { opacity: 0.75; }
.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 2px solid #fff;
  background:
    radial-gradient(circle at 50% 38%, #fff 0 17%, #0000 18%),
    radial-gradient(ellipse at 50% 100%, #fff 0 38%, #0000 39%),
    radial-gradient(circle at 30% 20%, #fff8, #0000 50%),
    linear-gradient(135deg, #ff9a3c, #ff2e8a 60%, #7a2cff);
  box-shadow: 0 2px 6px #0006;
}
.avatar--big { width: 64px; height: 64px; border-width: 3px; border-radius: 10px; }
.avatar--grey { filter: grayscale(1) brightness(0.9); }
.user:hover .avatar--big { box-shadow: 0 0 0 3px #ffcf6e, 0 2px 10px #0008; }

@media (max-width: 700px) {
  .login__mid { grid-template-columns: 1fr; grid-template-rows: auto auto; gap: 30px; padding: 20px; }
  .login__mid::before { display: none; }
  .login__left { text-align: center; grid-column: 1; grid-row: 1; }
  .login__right { grid-column: 1; grid-row: 2; justify-items: center; }
  .login__band { padding: 0 16px; font-size: 10px; }
  .desk-icons { display: none; }
  .start { min-width: 0; padding-right: 16px; }
  .tasks { display: none; }
  .tray { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
