/* The site's stylesheet. Desktop.astro imports it and Astro bundles it into one file.
   Order matters: later files override earlier ones, so add rules to the file they belong to
   rather than moving them between files. Values come only from tokens.css (npm run lint). *//* Design tokens: every colour, shadow, text size, corner radius, layer and easing curve
   the site uses. The other files in src/styles/ refer to these by name and never repeat a raw value
   (tools/lint-css.mjs checks this).

   Naming: colours are named by what they are for. Sizes are named by their value
   (--text-15 is 15px), so the name says what you get; pick from the existing steps
   rather than adding new ones. */

:root {
  /* Base palette and roles (unchanged from before tokens.css) */
  --desk: #2f4b6e;
  --desk-dot: rgba(255, 255, 255, 0.12);
  --glow-1: rgba(255, 203, 94, 0.3);
  --glow-2: rgba(255, 126, 160, 0.26);
  --glow-3: rgba(92, 220, 195, 0.24);
  --paper: #fbf8f0;
  --paper-2: #efe9da;
  --ink: #141414;
  --soft: #5b584f;
  --sky: #9fd3f5;
  --butter: #f6d98c;
  --mint: #b5e3c3;
  --apricot: #f4b89c;
  --link: #166d66;
  --play: #e0548c;
  --play-hover: #ec6a9e;
  --pick: var(--butter);
  --pick-text: var(--ink);

  /* Type */
  --mono: "Space Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;

  /* Layout */
  --bar-h: 48px;

  /* Status and accents */
  --brand-accent: #514684;
  --sky-light: #a8d8f8;
  --lilac: #d8d2f2;
  --on-play: #fff;
  --run: #37a354;
  --run-on: #5cd678;
  --run-glow: rgba(92, 214, 120, 0.35);
  --live: #287657;
  --wip-bg: #f6e5b8;
  --wip: #e8a33c;
  --wip-pulse: #f6d27e;
  --rule: #ded7c9;
  --scroll-thumb: #d8cfbc;

  /* Translucent colours (name = base colour + opacity %) */
  --ink-35: rgba(20, 20, 20, 0.35);
  --ink-32: rgba(20, 20, 20, 0.32);
  --ink-30: rgba(20, 20, 20, 0.3);
  --ink-06: rgba(20, 20, 20, 0.06);
  --black-20: rgba(0, 0, 0, 0.2);
  --white-55: rgba(255, 255, 255, 0.55);
  --paper-94: rgba(251, 248, 240, 0.94);
  --paper-86: rgba(251, 248, 240, 0.86);
  --butter-92: rgba(246, 217, 140, 0.92);
  --gold-28: rgba(255, 210, 76, 0.28);

  /* Hard offset shadows (the site's signature): --shadow-N is an N px ink drop */
  --shadow-2: 2px 2px 0 var(--ink);
  --shadow-3: 3px 3px 0 var(--ink);
  --shadow-4: 4px 4px 0 var(--ink);
  --shadow-5: 5px 5px 0 var(--ink);

  /* Other shadows */
  --shadow-soft-4: 4px 4px 0 var(--ink-35);
  --shadow-soft-3: 3px 3px 0 var(--ink-32);
  --shadow-lift: 0 12px 26px var(--ink-30);
  --icon-drop: 2px 2px 0 var(--black-20);

  /* Text sizes (px steps; 16 is body text) */
  --text-12: 12px;
  --text-13: 13px;
  --text-14: 14px;
  --text-15: 15px;
  --text-16: 16px;
  --text-17: 17px;
  --text-19: 19px;
  --text-22: 22px;
  --text-26: 26px;
  --text-display: clamp(28px, 8vw, 34px);

  /* Corner radius (also allowed raw: 0 and 50% for circles) */
  --radius-1: 1px;
  --radius-2: 2px;
  --radius-6: 6px;
  --radius-pill: 999px;

  /* Layers, lowest to highest (local stacking inside a component may use 0-2) */
  --z-snap: 9;
  --z-settling: 25;
  --z-drag: 30;
  --z-menubar: 1000;
  --z-ctxmenu: 1200;
  --z-ghost: 2000;

  /* Easing curves */
  --ease-snap: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-step: steps(1, end); /* jumps between keyframes, no tween (blinks) */

  /* Chart colours, handed out in this order (token usage: projects take the first six, models all twelve) */
  --chart-1: #7953e8;
  --chart-2: #00a88b;
  --chart-3: #f47e36;
  --chart-4: #3292e8;
  --chart-5: #e34c8e;
  --chart-6: #8aae29;
  --chart-7: #b45fe2;
  --chart-8: #e64b57;
  --chart-9: #18adc4;
  --chart-10: #eab52d;
  --chart-11: #526bd5;
  --chart-12: #24aa62;
}

@font-face {
  font-family: "Space Mono";
  src: url("/assets/fonts/SpaceMono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Space Mono";
  src: url("/assets/fonts/SpaceMono-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}


*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 10%, var(--glow-1), transparent 46%),
    radial-gradient(circle at 86% 16%, var(--glow-2), transparent 48%),
    radial-gradient(circle at 55% 96%, var(--glow-3), transparent 52%),
    radial-gradient(var(--desk-dot) 1.15px, transparent 1.35px) 0 0 / 8px 8px,
    var(--desk);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--text-16);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--paper-2);
  border-left: 1px solid var(--ink);
}

::-webkit-scrollbar-track:horizontal {
  border-left: 0;
  border-top: 1px solid var(--ink);
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 1px solid var(--ink);
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--butter);
}

::-webkit-scrollbar-thumb:active {
  background: var(--ink);
}

::-webkit-scrollbar-button {
  display: none;
}

::-webkit-scrollbar-corner {
  background: var(--paper-2);
  border-left: 1px solid var(--ink);
  border-top: 1px solid var(--ink);
}

@supports not selector(::-webkit-scrollbar) {
  html,
  .win > .wb {
    scrollbar-width: thin;
    scrollbar-color: var(--ink) var(--paper-2);
  }
}

::selection {
  background: var(--butter);
  color: var(--ink);
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

svg.px {
  shape-rendering: crispEdges;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hint-desktop {
  display: none;
}

/* ---------- Menu bar & menus ---------- */

.menubar {
  position: sticky;
  top: 0;
  z-index: var(--z-menubar);
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--bar-h);
  padding: 0 10px;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: var(--text-16);
  white-space: nowrap;
}


.bar-spacer {
  flex: 1;
}

/* Phones (and touch screens): the bar wraps, brand on the left and the clock after it. */
@media (max-width: 760px), (hover: none) {
  .menubar {
    flex-wrap: wrap;
    overflow: visible;
    height: auto;
    min-height: var(--bar-h);
    padding: 0 4px 0 8px;
  }

  .menubar > .bar-spacer {
    display: none;
  }

  .menubar .brand {
    order: 0;
    margin: 6px auto 6px 0;
  }

  .menubar .brand-mark {
    width: 16px;
    height: 16px;
  }

  .menubar .clock {
    order: 1;
  }
}

/* A maximized app takes over the bar: its own name and controls replace the other items. */
.menubar.has-app > .bar-spacer {
  display: none;
}

.appbar button,
.appbar a,
.taskbar-tasks button,
.menubar .clock {
  box-sizing: border-box;
  height: 34px;
  align-self: center;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-6);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-2);
  font: inherit;
  font-size: var(--text-16);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 120ms ease, transform 80ms ease, box-shadow 80ms ease;
}

.appbar button:hover,
.appbar a:hover,
.taskbar-tasks button:hover,
.menubar .clock:hover {
  background: var(--pick);
  color: var(--pick-text);
  box-shadow: var(--shadow-3);
  transform: translate(-1px, -1px);
}

.appbar button:active,
.appbar a:active,
.taskbar-tasks button:active,
.menubar .clock:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* The active window's task: inverted, but it stays on the same line as the others. */
.taskbar-tasks button.is-on,
.taskbar-tasks button.is-on:hover {
  background: var(--ink);
  color: var(--paper);
  transform: none;
  box-shadow: var(--shadow-2);
}

.taskbar-tasks button.is-on:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.menubar .brand:focus-visible,
.appbar button:focus-visible,
.appbar a:focus-visible,
.taskbar-tasks button:focus-visible,
.menubar .clock:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

.taskbar-tasks {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
  align-self: stretch;
  margin-left: 10px;
  padding: 0 4px 0 2px;
  overflow: hidden;
}

.taskbar-tasks button {
  max-width: 290px;
  min-width: 0;
  font-size: var(--text-16);
}

.taskbar-tasks button.is-app::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--run);
  animation: run-pulse 2s ease-in-out infinite;
}

.taskbar-tasks button.is-app.is-on::before {
  border-color: transparent;
  background: var(--run-on);
  box-shadow: 0 0 0 1.5px var(--run-glow);
}

.taskbar-tasks button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 761px) and (hover: hover) {
  .wm .taskbar-tasks {
    display: flex;
  }

  .wm .menubar.has-app .taskbar-tasks {
    display: none;
  }
}

/* The logo is a wordmark, not a button: no frame, still clickable. */
.menubar .brand {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 9px;
  padding: 0 6px 0 4px;
  color: var(--ink);
  font-size: var(--text-26);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.menubar .brand:hover .brand-mark {
  transform: rotate(-8deg);
}

.brand-mark {
  transition: transform 160ms ease;
  width: 20px;
  height: 20px;
  flex: none;
  background: var(--play);
  border: 1.5px solid var(--ink);
  box-shadow: var(--shadow-2);
}

.brand-name {
  line-height: 1;
}

.brand-accent {
  color: var(--brand-accent);
}

.ctxmenu {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-4);
  padding: 4px 0;
  min-width: 190px;
  z-index: var(--z-ctxmenu);
  font-family: var(--mono);
  font-size: var(--text-16);
  position: fixed;
  top: 0;
  left: 0;
  opacity: 0;
  scale: 0.96;
  transform-origin: top left;
  transition:
    opacity 110ms ease-out,
    scale 140ms var(--ease-snap);
}

.ctxmenu.is-open {
  opacity: 1;
  scale: 1;
}

.ctxmenu.is-closing {
  opacity: 0;
  scale: 0.98;
}

.ctxmenu:not(.is-open) {
  pointer-events: none;
}

.ctxmenu[hidden] {
  display: none;
}

.ctxmenu button,
.ctxmenu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 12px;
  border: 0;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.ctxmenu button:hover,
.ctxmenu a:hover,
.ctxmenu button:focus-visible,
.ctxmenu a:focus-visible {
  background: var(--pick);
  color: var(--pick-text);
  outline: none;
}

.ctxmenu hr {
  border: 0;
  border-top: 2px solid var(--ink);
  margin: 4px 0;
}

.ext-arrow,
.ctx-arrow {
  display: inline-block;
  margin-left: 6px;
  font-size: 1.55em;
  font-weight: 700;
  line-height: 0.75;
  vertical-align: -0.08em;
}

.ctx-arrow {
  margin-left: 10px;
  font-size: 1.5em;
}

@media (prefers-reduced-motion: reduce) {
  .ctxmenu {
    transition: none;
  }
}

[data-shot] {
  cursor: pointer;
}

.menubar .clock {
  margin-left: 8px;
}

.menubar.has-app .clock {
  margin-left: auto;
}

/* When an app is maximized, its title bar moves into the menu bar (one bar, like a Mac). */
.appbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  padding-left: 10px;
  border-left: 2px solid var(--ink);
}

.appbar[hidden],
.appbar [hidden] {
  display: none;
}

.appbar-name {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-6);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-2);
  font-size: var(--text-17);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.appbar-name::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--run-on);
  box-shadow: 0 0 0 1.5px var(--run-glow);
  animation: run-pulse 2s ease-in-out infinite;
}

@keyframes run-pulse {
  50% {
    opacity: 0.55;
    transform: scale(0.82);
  }
}

@media (max-width: 960px) {
  .menubar {
    font-size: var(--text-14);
  }

  .menubar.has-app .clock {
    display: none;
  }

  .appbar {
    gap: 6px;
    padding-left: 8px;
  }

  .appbar button,
  .appbar a {
    padding: 0 9px;
    font-size: var(--text-14);
  }

  .appbar-name {
    padding: 0 10px;
    font-size: var(--text-15);
  }
}

/* ---------- Desktop icons ---------- */

.menubar,
.icons,
.desktop,
.ctxmenu {
  -webkit-user-select: none;
  user-select: none;
}

.win .wb {
  -webkit-user-select: text;
  user-select: text;
}

.snap-preview {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--z-snap);
  border: 2px dashed var(--butter);
  background: var(--gold-28);
  box-shadow: inset 0 0 0 2px var(--ink-35);
  pointer-events: none;
  transition: transform 0.14s var(--ease-out), width 0.14s var(--ease-out), height 0.14s var(--ease-out);
}

.snap-preview[hidden] {
  display: none;
}

.desktop {
  position: relative;
}

.icons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 16px;
}

/* Each group is a framed "shelf" panel. */
.icon-group {
  min-width: 0;
  border: 2px solid var(--ink);
  background: var(--paper-86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-4);
  overflow: hidden;
}

.icon-group--projects {
  --cat: var(--play);
}

.icon-group--misc {
  --cat: var(--butter);
}

.icon-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 12px;
  border-bottom: 2px solid var(--ink);
  background: var(--ink-06);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--text-16);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.icon-group-title::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: none;
  border: 1.5px solid var(--ink);
  background: var(--cat, var(--butter));
}

.icon-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  min-height: 86px;
  padding: 8px;
}

.icon {
  display: grid;
  grid-template-rows: 48px auto auto;
  align-content: start;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 2px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--ink);
  text-align: center;
  font-family: var(--mono);
  font-size: var(--text-16);
  line-height: 1.25;
}

.icon svg {
  width: 48px;
  height: 48px;
  filter: drop-shadow(var(--icon-drop));
}

.icon span {
  max-width: 100%;
  padding: 1px 4px;
  overflow: hidden;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

a.icon {
  text-decoration: none;
}

.icon .status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: -2px;
  gap: 5px;
  font-size: var(--text-14);
  font-style: normal;
  line-height: 1.2;
}

.icon .status-tag i {
  width: 7px;
  height: 7px;
}

.icon.is-selected span,
.icon:focus-visible span {
  background: var(--pick);
  color: var(--pick-text);
}

@media (hover: hover) {
  .icon:hover span {
    background: var(--pick);
    color: var(--pick-text);
  }
}

.icon.is-selected svg {
  filter: brightness(0.75) drop-shadow(var(--icon-drop));
}

.icon:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
}

.icon-group.is-drop-target {
  outline: 2px dashed var(--ink);
  outline-offset: -4px;
  background: var(--butter-92);
}

.icon.is-drag-source {
  opacity: 0.35;
}

.icon-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-ghost);
  pointer-events: none;
  margin: 0;
  padding: 6px 4px;
  background: var(--paper-94);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-4);
  will-change: transform;
}

/* ---------- Windows (default: stacked flow; desktop mode below) ---------- */

.windows {
  display: grid;
  gap: 20px;
  padding: 0 16px 40px;
}

.win {
  --tb-tint: var(--sky);
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-soft-4);
  min-width: 0;
  transition: box-shadow 160ms ease;
}

.win.is-active:where(:not(.is-max):not(.is-snapped)) {
  box-shadow: 0 0 0 3px var(--tb-tint), 6px 6px 0 3px var(--ink);
}

.win,
.icon-group {
  scroll-margin-top: calc(var(--bar-h) + 14px);
}

#w-info {
  --tb-tint: var(--sky-light);
}

#w-hello {
  --tb-tint: var(--butter);
}

#w-about {
  --tb-tint: var(--mint);
}

#w-analytics {
  --tb-tint: var(--lilac);
}

#w-error {
  --tb-tint: var(--apricot);
}

.win:focus {
  outline: none;
}

.win[hidden] {
  display: none;
}

.tb {
  --tb-fill: var(--tb-tint, var(--paper));
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  height: 46px;
  padding: 0 46px 0 14px;
  border-bottom: 2px solid var(--ink);
  background: var(--tb-fill);
  user-select: none;
  touch-action: none;
  transition: background-color 160ms ease;
}

.tb h2 {
  margin: 0;
  padding: 0;
  background: var(--tb-fill);
  font-family: var(--mono);
  font-size: var(--text-19);
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  transition: color 160ms ease, background-color 160ms ease;
}

.tb .close {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--tb-fill);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--tb-fill);
}

.tb .close::before,
.tb .close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  background: var(--ink);
  pointer-events: none;
}

.tb .close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.tb .close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.tb .close:hover,
.tb .close:focus-visible,
.tb .close:active {
  background: var(--ink);
}

.tb .close:hover::before,
.tb .close:hover::after,
.tb .close:focus-visible::before,
.tb .close:focus-visible::after,
.tb .close:active::before,
.tb .close:active::after {
  background: var(--paper);
}

/* Inactive windows look muted on both desktop and phone so the focused window stands out clearly. */
.win:not(.is-active) .tb {
  --tb-fill: var(--paper);
  background: var(--paper);
}

.win:not(.is-active) .tb h2 {
  color: var(--soft);
}

.win:not(.is-active) .tb .close {
  border-color: var(--soft);
}

.win:not(.is-active) .tb .close::before,
.win:not(.is-active) .tb .close::after {
  background: var(--soft);
}

.win:not(.is-active) .tb .close:hover,
.win:not(.is-active) .tb .close:focus-visible,
.win:not(.is-active) .tb .close:active {
  border-color: var(--ink);
  background: var(--ink);
}

.win:not(.is-active) .tb .close:hover::before,
.win:not(.is-active) .tb .close:hover::after,
.win:not(.is-active) .tb .close:focus-visible::before,
.win:not(.is-active) .tb .close:focus-visible::after,
.win:not(.is-active) .tb .close:active::before,
.win:not(.is-active) .tb .close:active::after {
  background: var(--paper);
}

.wb {
  padding: 14px 16px 16px;
}

.wb p a,
.wb dd a,
.app-loading-slow a {
  color: var(--link);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.wb p a:hover,
.wb dd a:hover,
.app-loading-slow a:hover {
  background: var(--pick);
  color: var(--pick-text);
}

.wb p {
  margin: 0 0 10px;
}

.wb p:last-child {
  margin-bottom: 0;
}

.cat-label {
  margin: 14px 0 4px;
  font-size: var(--text-15);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
}

.cat-list {
  margin: 0 0 10px;
  padding-left: 18px;
}

.cat-list li + li {
  margin-top: 4px;
}

.btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-6);
  background: var(--paper);
  box-shadow: var(--shadow-2);
  font-family: var(--mono);
  font-size: var(--text-16);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, background-color 0.12s ease-out, color 0.12s ease-out;
}

.btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* Play: the one button that matters */

.btn--play {
  position: relative;
  overflow: hidden;
  padding: 4px 16px;
  background: var(--play);
  color: var(--on-play);
  border-color: var(--ink);
  box-shadow: var(--shadow-3);
  font-size: var(--text-17);
  letter-spacing: 0.02em;
  transition: transform 0.16s var(--ease-snap), box-shadow 0.16s var(--ease-snap), background-color 0.16s ease;
}

.btn--play::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent, var(--white-55), transparent);
  transform: translateX(-120%) skewX(-12deg);
  animation: shine 3.6s var(--ease-std) 1.2s infinite;
  pointer-events: none;
}

.btn--play .arrow {
  display: inline-block;
  transition: transform 0.2s var(--ease-snap);
}

.btn--play:hover {
  background: var(--play-hover);
  color: var(--on-play);
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-5);
}

.btn--play:hover .arrow {
  transform: translate(2px, -2px);
}

.btn--play:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
  transition-duration: 0.06s;
}

@keyframes shine {
  0% {
    transform: translateX(-120%) skewX(-12deg);
  }
  45%,
  100% {
    transform: translateX(320%) skewX(-12deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn--play::after {
    animation: none;
    display: none;
  }
}

.btn--default {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.shot {
  margin: 0;
  border-bottom: 2px solid var(--ink);
  background: var(--sky);
}

.shot img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.info-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--soft);
}

.info-head--inline {
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.info-head svg {
  width: 48px;
  height: 48px;
  flex: none;
}

.info-head .btn--play {
  margin-left: auto;
}

.info-head h3 {
  margin: 0;
  font-size: var(--text-22);
}

.info-head p {
  margin: 0;
  color: var(--soft);
  font-size: var(--text-16);
}

.facts {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  gap: 4px 12px;
  margin: 0 0 12px;
  font-size: var(--text-16);
}

.facts dt {
  color: var(--soft);
  text-align: right;
}

.facts dd {
  margin: 0;
}

/* Screenshot thumbnails (info window) */

.thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
}

.thumbs button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: center;
  font-size: var(--text-16);
}

.thumbs button img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 2px solid var(--ink);
  margin-bottom: 4px;
  transition: transform 0.15s ease-out;
}

.thumbs button:hover img {
  transform: translateY(-2px);
}

.thumbs button[aria-pressed="true"] img {
  box-shadow: var(--shadow-3);
}

.thumbs button[aria-pressed="true"] span {
  background: var(--pick);
  color: var(--pick-text);
  padding: 0 3px;
}

/* Status tag */

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--wip-bg);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.status-tag i {
  width: 8px;
  height: 8px;
  flex: none;
  background: var(--wip);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  animation: wip 2.4s ease-in-out infinite;
}

@keyframes wip {
  50% {
    background: var(--wip-pulse);
    transform: scale(0.8);
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-tag i,
  .appbar-name::before,
  .taskbar-tasks button.is-app::before,
  .win--app .tb h2::before {
    animation: none;
  }
}

.dialog {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.dialog svg {
  width: 40px;
  height: 40px;
  flex: none;
}

/* A dialog's buttons, under its message and aligned right. */
.dialog-btns {
  justify-content: flex-end;
  margin-top: 14px;
}

.muted {
  color: var(--soft);
}

/* Analytics window */

#w-analytics .tb {
  justify-content: space-between;
  gap: 12px;
}

#w-analytics .tb h2 {
  font-size: var(--text-17);
}

.tb-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  color: var(--soft);
  font-size: var(--text-12);
  line-height: 1.2;
  white-space: nowrap;
}

.tb-live:not(:empty)::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
}

.tb-live.is-stale::before {
  background: currentColor;
}

#w-analytics .wb {
  padding: 14px 20px 11px;
}

.tok {
  --tok-rule: var(--rule);
  font-size: var(--text-15);
  font-variant-numeric: tabular-nums;
}

.tok-total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  margin-bottom: 10px;
  color: var(--soft);
}

.tok-num {
  color: var(--ink);
  font-size: var(--text-display);
  line-height: 1;
  overflow-wrap: anywhere;
}

.tok-bar {
  display: flex;
  height: 12px;
  overflow: hidden;
  border-radius: var(--radius-2);
  background: var(--paper-2);
}

.tok-bar--overview {
  height: 17px;
}

.tok-seg {
  position: relative;
  flex-basis: 0;
  min-width: 2px;
  transition: opacity 120ms;
}

.tok-bar.is-dim .tok-seg:not(.on) {
  opacity: 0.28;
}

.tok-seg.on {
  z-index: 1;
  box-shadow: -1px 0 var(--ink), 1px 0 var(--ink);
}

.tok-legend {
  display: grid;
  gap: 1px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  line-height: 1.45;
}

.tok-legend li {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) 5ch 6ch;
  align-items: baseline;
  gap: 7px;
  padding: 1px 5px;
  border-radius: var(--radius-2);
}

.tok-legend li.on {
  background: color-mix(in srgb, var(--tok-color) 16%, var(--paper));
  box-shadow: inset 3px 0 var(--tok-color);
}

.tok-legend li.on .tok-name {
  font-weight: 700;
}

.tok-legend--overview .tok-pct,
.tok-legend li.on .tok-val,
.tok-legend li.on .tok-pct {
  color: var(--ink);
}

.tok-name {
  overflow-wrap: anywhere;
}

.tok-val,
.tok-pct {
  color: var(--soft);
  text-align: right;
}

.tok-swatch {
  align-self: center;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-1);
  background: var(--tok-color);
}

.tok-legend .tok-swatch {
  align-self: start;
  margin-top: 0.5em;
}

.tok .tok-foot {
  margin: 9px 0 0;
  color: var(--soft);
  font-size: var(--text-13);
  line-height: 1.4;
}

.tok-foot:empty {
  display: none;
}

.tok-adv {
  margin-top: 10px;
  border-top: 1px solid var(--tok-rule);
}

.tok-adv summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  font-size: var(--text-16);
  font-weight: 700;
  padding: 8px 2px 4px 0;
}

.tok-adv summary::-webkit-details-marker {
  display: none;
}

.tok-adv summary::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
}

.tok-adv[open] > summary::after,
.tok-proj[open] > summary::after {
  transform: translateY(2px) rotate(225deg);
}

.tok-adv summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.tok-adv-body {
  display: grid;
}

.tok-adv-body > :first-child {
  margin-top: 8px;
}

.tok-proj {
  border-top: 1px solid var(--tok-rule);
}

.tok-proj > summary {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) 7px;
  gap: 8px;
  padding: 7px 7px 7px 5px;
}

.tok-proj > summary:hover,
.tok-proj[open] > summary {
  background: color-mix(in srgb, var(--tok-color) 9%, var(--paper));
}

.tok-proj-body {
  display: grid;
  gap: 12px;
  padding-inline: 3px;
}

.tok-proj-body > :first-child {
  margin-top: 9px;
}

.tok-proj-body > :last-child {
  margin-bottom: 12px;
}

.tok-proj h4 {
  margin: 0 0 6px;
  color: var(--soft);
  font-size: var(--text-14);
  font-weight: 400;
}

@media (prefers-reduced-motion: no-preference) {
  .tok-adv summary::after {
    transition: transform 200ms ease;
  }

  @supports selector(details::details-content) {
    :is(.tok-adv, .tok-proj)::details-content {
      display: grid;
      grid-template-rows: 0fr;
      overflow: clip;
      transition: grid-template-rows 220ms ease, content-visibility 220ms allow-discrete;
    }

    :is(.tok-adv, .tok-proj)[open]::details-content {
      grid-template-rows: 1fr;
    }

    .tok-adv-body,
    .tok-proj-body {
      min-block-size: 0;
    }
  }
}

/* App windows (a program running in an iframe) */

.tb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: none;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: none;
  font-family: var(--mono);
  font-size: var(--text-16);
  font-weight: 700;
  line-height: 24px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.tb-btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.tb .zoom {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: none;
  cursor: pointer;
}

.tb .zoom::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
}

.tb .zoom:hover,
.tb .zoom:active {
  background: var(--ink);
}

.tb .zoom:hover::after {
  border-color: var(--paper);
}

.win--app {
  display: flex;
  flex-direction: column;
}

.app-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--sky);
}

.app-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  transition: opacity 0.35s ease-out;
}

.win--app.is-loaded .app-frame iframe {
  opacity: 1;
}

.app-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
}

.win--app.is-loaded .app-loading {
  display: none;
}

.app-loading-text {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--text-16);
  color: var(--ink);
  animation: loading-blink 1.2s ease-in-out infinite;
}

.app-loading-slow {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--text-16);
  color: var(--ink);
}

.app-loading-slow[hidden] {
  display: none;
}

@keyframes loading-blink {
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-loading-text {
    animation: none;
  }
}

.grip {
  display: none;
}

/* While a window is dragged or resized, iframes mustn't swallow the pointer. */
.is-busy iframe {
  pointer-events: none;
}

.is-busy,
.is-busy * {
  user-select: none;
}

/* Phones: apps aren't opened in windows (the launcher goes straight to the game). */
.win--app .app-frame {
  min-height: 60vh;
}

.win--app .tb {
  justify-content: space-between;
}

.win--app .tb h2 {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
}

.win--app .tb h2::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--run);
  animation: run-pulse 2s ease-in-out infinite;
}

/* ---------- Desktop mode (.wm, set by boot.js; wide screens with a mouse) ---------- */

@media (min-width: 761px) and (hover: hover) {
  .wm body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .wm .desktop {
    height: calc(100vh - var(--bar-h));
    height: calc(100dvh - var(--bar-h));
  }

  .wm .hint-desktop {
    display: inline;
  }

  .wm p.hint-desktop {
    display: block;
    font-size: var(--text-15);
  }

  .wm .icons {
    position: absolute;
    inset: 0;
    z-index: 0; /* own stacking layer: icons always sit under the windows */
    display: block;
    padding: 0;
    pointer-events: none;
  }

  .wm .icons .icon-group {
    position: absolute;
    top: 0;
    left: 0;
    width: 148px;
    pointer-events: auto;
    will-change: transform;
  }

  .wm .icons .icon-group-title {
    cursor: default;
  }

  .wm .icons.is-arranging .icon-group {
    transition: transform 0.22s var(--ease-out);
  }

  .wm .icon {
    touch-action: none;
  }

  .wm .windows {
    display: block;
    padding: 0;
  }

  .wm .win {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - var(--bar-h) - 24px);
    max-height: calc(100dvh - var(--bar-h) - 24px);
    will-change: transform;
    transform-origin: 50% 30%;
  }

  .wm .win[hidden] {
    display: none;
  }

  .wm .win--app {
    max-height: none;
  }

  .wm .win--app .app-frame {
    min-height: 0;
  }

  .wm .win.is-max {
    max-width: none;
    max-height: none;
    box-shadow: none;
    border-width: 0;
    transition: none;
  }

  .wm .win.is-snapped {
    max-width: none;
    max-height: none;
    box-shadow: none;
  }

  .wm .win.is-max .tb {
    display: none;
  }

  .wm .grip {
    display: block;
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background:
      linear-gradient(135deg, transparent 0 55%, var(--ink) 55% 62%, transparent 62% 72%, var(--ink) 72% 79%, transparent 79%);
    touch-action: none;
  }

  .wm .win.is-max .grip {
    display: none;
  }

  .wm .win .tb {
    cursor: grab;
  }

  .wm .win > .tb,
  .wm .win > .shot {
    flex: none;
  }

  .wm .win > .wb {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .wm .win > .shot img {
    aspect-ratio: 16 / 8;
  }

  .wm .win.is-dragging .tb {
    cursor: grabbing;
  }

  .wm .win.is-dragging {
    box-shadow: 0 0 0 3px var(--tb-tint), 8px 8px 0 3px var(--ink);
  }

  .wm .win.is-opening {
    animation: win-open 0.2s var(--ease-out) both;
  }

  .wm .win.is-closing {
    animation: win-close 0.14s var(--ease-in) both;
    pointer-events: none;
  }
}

@keyframes win-open {
  from {
    opacity: 0;
    scale: 0.94;
  }
}

@keyframes win-close {
  to {
    opacity: 0;
    scale: 0.96;
  }
}

/* Opening a window that is already open: a small bump, and the title bar blinks twice.
   Maximized and snapped windows only blink (a bump would push them past their edges). */
.win.is-attention {
  animation: win-attention 0.42s var(--ease-out);
}

.win.is-attention:is(.is-max, .is-snapped) {
  animation-name: win-attention-still;
}

/* The blink animates --tb-fill (registered below so it can be animated), which the title,
   the close button and its ring all use, so the whole bar blinks together. */
.win.is-attention > .tb {
  animation: tb-blink 0.42s var(--ease-step);
}

.win.is-attention > .tb h2 {
  transition: none;
}

@property --tb-fill {
  syntax: "<color>";
  inherits: true;
  initial-value: transparent;
}

@keyframes win-attention {
  30% {
    scale: 1.025;
  }
}

@keyframes win-attention-still {
  to {
    opacity: 1;
  }
}

@keyframes tb-blink {
  0%,
  50% {
    --tb-fill: var(--paper);
  }

  25%,
  75% {
    --tb-fill: var(--tb-tint);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wm .win.is-opening,
  .wm .win.is-closing,
  .win.is-attention,
  .win.is-attention > .tb {
    animation: none;
  }

  .win,
  .tb,
  .tb h2,
  .wm .icons.is-arranging .icon-group,
  .snap-preview,
  .win.is-mobile-opening,
  .win.is-mobile-closing,
  .win.is-mobile-settling,
  .icon-group.is-mobile-settling {
    transition: none;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 760px), (hover: none) {
  .desktop {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 12px 16px;
  }

  .windows,
  .icons {
    display: contents;
  }

  body[data-start="hello"] #w-hello,
  body[data-start="info"] #w-info,
  body[data-start="error"] #w-error {
    order: 1;
  }

  .icon-group--projects {
    order: 2;
  }

  .icon-group--misc {
    order: 3;
  }

  .win {
    order: 4;
  }

  .icon-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 4px;
  }

  .icon span {
    padding: 1px 2px;
  }

  .win,
  .icon-group {
    width: 100%;
  }

  .icon-group {
    box-shadow: var(--shadow-4);
  }

  .win {
    box-shadow: var(--shadow-soft-3);
  }

  .win.is-active {
    box-shadow: 0 0 0 3px var(--tb-tint), 4px 4px 0 3px var(--ink);
  }

  .win.is-mobile-opening,
  .win.is-mobile-closing {
    overflow: hidden;
    min-height: 0;
    transform-origin: top center;
    transition:
      height 260ms var(--ease-out-soft),
      margin-top 260ms var(--ease-out-soft),
      margin-bottom 240ms var(--ease-out-soft),
      opacity 200ms ease-out,
      transform 240ms var(--ease-out-soft),
      border-width 240ms ease-out,
      box-shadow 220ms ease-out;
  }

  .win.is-mobile-closing {
    pointer-events: none;
  }

  .desktop.is-mobile-sorting {
    overflow-anchor: none;
  }

  .win .tb,
  .icon-group {
    touch-action: pan-y;
    -webkit-touch-callout: none;
  }

  .win .tb,
  .icon-group-title {
    cursor: grab;
  }

  .win.is-mobile-dragging {
    z-index: var(--z-drag);
    transition: box-shadow 160ms ease;
    box-shadow: 0 0 0 3px var(--tb-tint), var(--shadow-lift), 5px 5px 0 3px var(--ink);
  }

  .icon-group.is-mobile-dragging {
    z-index: var(--z-drag);
    touch-action: none;
    transition: box-shadow 160ms ease;
    box-shadow: 0 0 0 3px var(--cat, var(--butter)), var(--shadow-lift), 5px 5px 0 3px var(--ink);
  }

  .win.is-mobile-dragging .tb {
    touch-action: none;
  }

  .win.is-mobile-dragging .tb,
  .icon-group.is-mobile-dragging .icon-group-title {
    cursor: grabbing;
  }

  .win.is-mobile-settling,
  .icon-group.is-mobile-settling {
    z-index: var(--z-settling);
    transition:
      transform 200ms var(--ease-out-soft),
      box-shadow 160ms ease;
  }

  #w-analytics .tb {
    height: auto;
    min-height: 46px;
    padding: 8px 46px 8px 12px;
    gap: 10px;
  }

  #w-analytics .tb h2 {
    font-size: var(--text-15);
    white-space: normal;
  }

  #w-analytics .wb {
    padding-inline: 14px;
  }
}

@media (max-width: 430px) {
  .menubar .clock {
    display: none;
  }
}

@media (max-width: 360px) {
  .tok-legend li {
    grid-template-columns: 7px minmax(0, 1fr) 5ch 5ch;
  }
}

/* Avoid a layout flash on load: boot.js adds .wm-boot, src/scripts/windows.js removes it once windows are placed.
   visibility (not display) so the scripts can still measure; the animation is a failsafe if they never run. */
.wm-boot .windows,
.wm-boot .icons,
.wm-boot .taskbar-tasks {
  visibility: hidden;
  animation: wm-reveal 0s 1.5s forwards;
}

@keyframes wm-reveal {
  to {
    visibility: visible;
  }
}
