/* =========================================================================
   UtilityDock design system
   Direction: editorial terminal — warm paper, ink type, a serif display face
   against system sans and mono. One accent, used sparingly. Density over air.
   Light is the default; dark is a real second design, not an inversion.
   ========================================================================= */

/* --- Fonts ---------------------------------------------------------------
   Only the display face is downloaded. Body and mono use the platform stacks,
   which cost zero bytes and render on the first paint with no swap. */

@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-latin-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}

/* --- Tokens -------------------------------------------------------------- */

:root {
  color-scheme: light;

  --paper: #faf8f4;
  --paper-tint: #f4f1e9;
  --surface: #ffffff;
  --surface-2: #f3f0e8;
  --surface-inset: #f7f5ef;

  --ink: #1a1815;
  --ink-2: #56524a;
  --ink-3: #857f72;

  --rule: #e5e0d5;
  --rule-strong: #cec7b7;

  --accent: #ab3d13;
  --accent-hover: #8d3210;
  --accent-soft: rgb(171 61 19 / 9%);
  --accent-line: rgb(171 61 19 / 28%);

  --ok: #14663a;
  --warn: #8a5a0b;
  --bad: #a32017;

  --cat-data: #3f3d9e;
  --cat-security: #14663a;
  --cat-devops: #6b3fa0;
  --cat-utils: #8a5a0b;
  --cat-media: #0e6f7a;
  --cat-arcade: #a32b4e;

  --shadow-1: 0 1px 2px rgb(26 24 21 / 5%);
  --shadow-2: 0 2px 4px rgb(26 24 21 / 6%), 0 8px 20px -8px rgb(26 24 21 / 12%);
  --shadow-3: 0 4px 8px rgb(26 24 21 / 8%), 0 24px 48px -16px rgb(26 24 21 / 22%);

  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono",
    "Roboto Mono", Menlo, Consolas, monospace;

  /* Fluid scale: the display sizes shrink hard on phones, body text barely. */
  --step-display: clamp(2.6rem, 1.6rem + 4.4vw, 5rem);
  --step-h2: clamp(1.5rem, 1.24rem + 1.1vw, 2.1rem);
  --step-h3: clamp(1.15rem, 1.06rem + 0.4vw, 1.35rem);
  --step-body: 1rem;
  --step-sm: 0.875rem;
  --step-xs: 0.78rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 6.5rem;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 14px;

  --measure: 68ch;
  --shell: 76rem;
  --header-h: 60px;

  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* Dark mode is the same design with a different ground: warm near-black rather
   than blue-black, so the cream text reads as ink on slate, not as glow. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --paper: #131211;
    --paper-tint: #171614;
    --surface: #1b1a17;
    --surface-2: #232120;
    --surface-inset: #100f0e;

    --ink: #f4f1e9;
    --ink-2: #a9a295;
    --ink-3: #7b7568;

    --rule: #2e2b27;
    --rule-strong: #443f38;

    --accent: #f5824f;
    --accent-hover: #ff9c70;
    --accent-soft: rgb(245 130 79 / 12%);
    --accent-line: rgb(245 130 79 / 32%);

    --ok: #63c48f;
    --warn: #e0ac55;
    --bad: #f0796d;

    --cat-data: #9a98f0;
    --cat-security: #63c48f;
    --cat-devops: #c09bee;
    --cat-utils: #e0ac55;
    --cat-media: #56c4d0;
    --cat-arcade: #f58ba6;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-2: 0 2px 4px rgb(0 0 0 / 40%), 0 8px 20px -8px rgb(0 0 0 / 60%);
    --shadow-3: 0 4px 8px rgb(0 0 0 / 45%), 0 24px 48px -16px rgb(0 0 0 / 70%);
  }
}

[data-theme="dark"] {
  color-scheme: dark;

  --paper: #131211;
  --paper-tint: #171614;
  --surface: #1b1a17;
  --surface-2: #232120;
  --surface-inset: #100f0e;

  --ink: #f4f1e9;
  --ink-2: #a9a295;
  --ink-3: #7b7568;

  --rule: #2e2b27;
  --rule-strong: #443f38;

  --accent: #f5824f;
  --accent-hover: #ff9c70;
  --accent-soft: rgb(245 130 79 / 12%);
  --accent-line: rgb(245 130 79 / 32%);

  --ok: #63c48f;
  --warn: #e0ac55;
  --bad: #f0796d;

  --cat-data: #9a98f0;
  --cat-security: #63c48f;
  --cat-devops: #c09bee;
  --cat-utils: #e0ac55;
  --cat-media: #56c4d0;
  --cat-arcade: #f58ba6;

  --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-2: 0 2px 4px rgb(0 0 0 / 40%), 0 8px 20px -8px rgb(0 0 0 / 60%);
  --shadow-3: 0 4px 8px rgb(0 0 0 / 45%), 0 24px 48px -16px rgb(0 0 0 / 70%);
}

/* --- Reset --------------------------------------------------------------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-5));
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Primitives ---------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-2);
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  transform: translateY(-200%);
  transition: transform 0.15s var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.kbd {
  font-family: var(--font-mono);
  font-size: 0.75em;
  line-height: 1;
  padding: 0.35em 0.45em;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
}

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

/* --- Header -------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand svg {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--accent);
}

.brand b {
  font-weight: 400;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-left: auto;
}

.nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--step-sm);
  padding-block: var(--space-2);
  border-bottom: 1px solid transparent;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 1.05rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease),
    border-color 0.15s var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--rule);
}

/* The palette trigger reads as a search field on desktop and collapses to a
   plain icon button once there is no room for the hint. */
.palette-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding-inline: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink-3);
  font-size: var(--step-sm);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.palette-trigger:hover {
  border-color: var(--rule-strong);
  color: var(--ink-2);
}

.palette-trigger .kbd {
  margin-left: var(--space-3);
}

.nav-toggle {
  display: none;
}

@media (max-width: 860px) {
  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: var(--space-3) var(--space-5) var(--space-5);
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    box-shadow: var(--shadow-2);
    transform: translateY(-120%);
    visibility: hidden;
    transition: transform 0.25s var(--ease), visibility 0.25s;
  }

  .nav[data-open="true"] {
    transform: translateY(0);
    visibility: visible;
  }

  .nav a {
    padding-block: var(--space-4);
    font-size: 1.05rem;
    border-bottom: 1px solid var(--rule);
  }

  .nav a:last-child {
    border-bottom: 0;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .palette-trigger__hint,
  .palette-trigger .kbd {
    display: none;
  }

  .palette-trigger {
    width: 36px;
    padding-inline: 0;
    justify-content: center;
  }
}

/* --- Hero ---------------------------------------------------------------- */

.hero {
  padding-block: clamp(var(--space-7), 6vw, var(--space-9)) var(--space-7);
  border-bottom: 1px solid var(--rule);
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-display);
  line-height: 0.98;
  letter-spacing: -0.02em;
  max-width: 18ch;
  margin-block: var(--space-4) var(--space-5);
}

.hero__title em {
  font-style: italic;
  color: var(--accent);
}

.hero__lede {
  max-width: 52ch;
  color: var(--ink-2);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.hero__stats b {
  color: var(--ink);
  font-weight: 500;
}

/* --- Search -------------------------------------------------------------- */

.search {
  position: relative;
  max-width: 34rem;
  margin-top: var(--space-6);
}

.search__icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  translate: 0 -50%;
  color: var(--ink-3);
  font-size: 1.05rem;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 52px;
  padding-inline: 2.9rem var(--space-4);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.search input::placeholder {
  color: var(--ink-3);
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__hint {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  translate: 0 -50%;
  pointer-events: none;
}

@media (max-width: 560px) {
  .search__hint {
    display: none;
  }
}

/* --- Category rail ------------------------------------------------------- */

.rail {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  display: flex;
  gap: var(--space-2);
  padding-block: var(--space-3);
  margin-bottom: var(--space-6);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.rail a {
  flex: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--step-sm);
  white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.rail a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.rail a.is-active {
  background: var(--ink);
  color: var(--paper);
}

/* --- Sections ------------------------------------------------------------ */

.section {
  padding-block: var(--space-7);
  scroll-margin-top: calc(var(--header-h) * 2);
}

.section + .section {
  border-top: 1px solid var(--rule);
}

.section__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.section__head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-h2);
  letter-spacing: -0.01em;
}

.section__head p {
  color: var(--ink-3);
  font-size: var(--step-sm);
  margin-left: auto;
  text-align: right;
}

@media (max-width: 640px) {
  .section__head {
    flex-direction: column;
    gap: var(--space-1);
  }

  .section__head p {
    margin-left: 0;
    text-align: left;
  }
}

/* --- Tool cards ----------------------------------------------------------
   Denser than the previous 2.25rem-padded boxes: the icon and title share a
   line, the description gets two lines, and the affordance is a rule that
   fills on hover rather than a lift-and-glow. */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: background 0.18s var(--ease);
}

.card::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--cat, var(--accent));
  scale: 0 1;
  transform-origin: left;
  transition: scale 0.28s var(--ease);
}

.card:hover,
.card:focus-visible {
  background: var(--paper-tint);
}

.card:hover::after,
.card:focus-visible::after {
  scale: 1 1;
}

.card__top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.card__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  color: var(--cat, var(--accent));
  background: color-mix(in srgb, var(--cat, var(--accent)) 10%, transparent);
}

.card__title {
  font-size: var(--step-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.card__desc {
  color: var(--ink-2);
  font-size: var(--step-sm);
  line-height: 1.5;
}

.card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Pin control sits above the card link so it can be clicked independently. */
.card__pin {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s var(--ease), color 0.15s var(--ease),
    background 0.15s var(--ease);
}

.card:hover .card__pin,
.card__pin:focus-visible,
.card__pin[aria-pressed="true"] {
  opacity: 1;
}

.card__pin:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.card__pin[aria-pressed="true"] {
  color: var(--accent);
}

.card__pin[aria-pressed="true"] .icon {
  fill: currentColor;
}

.cat-data {
  --cat: var(--cat-data);
}
.cat-security {
  --cat: var(--cat-security);
}
.cat-devops {
  --cat: var(--cat-devops);
}
.cat-utils {
  --cat: var(--cat-utils);
}
.cat-media {
  --cat: var(--cat-media);
}
.cat-arcade {
  --cat: var(--cat-arcade);
}

.grid--compact .card {
  padding: var(--space-4);
}

.grid--compact .card__desc {
  display: none;
}

/* --- Empty state --------------------------------------------------------- */

.empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--ink-3);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-lg);
}

.empty b {
  color: var(--ink);
  font-weight: 600;
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--step-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease);
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary is solid ink rather than a saturated brand colour — it reads as a
   printed rule on paper and keeps the accent reserved for links and state. */
.btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn--primary:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
  color: var(--paper);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn--sm {
  min-height: 32px;
  padding-inline: var(--space-3);
  font-size: var(--step-xs);
}

.btn.is-done {
  border-color: var(--ok);
  color: var(--ok);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* --- Tool workspace ------------------------------------------------------ */

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: var(--space-7);
  align-items: start;
  padding-block: var(--space-6) var(--space-8);
}

@media (max-width: 1000px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tool-head {
  margin-bottom: var(--space-5);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  color: var(--ink-3);
}

.breadcrumbs a {
  color: var(--ink-3);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.tool-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 1.5rem + 2vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.tool-head p {
  margin-top: var(--space-2);
  max-width: var(--measure);
  color: var(--ink-2);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel + .panel {
  margin-top: var(--space-4);
}

.panel__bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
  min-height: 42px;
}

.panel__label {
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.panel__bar .btn-row {
  margin-left: auto;
}

.panel__body {
  padding: var(--space-4);
}

.panel__body--flush {
  padding: 0;
}

/* --- Fields -------------------------------------------------------------- */

.field {
  display: block;
}

.field + .field {
  margin-top: var(--space-4);
}

.field__label {
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.field__hint {
  margin-top: var(--space-2);
  font-size: var(--step-xs);
  color: var(--ink-3);
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: var(--space-3);
  background: var(--surface-inset);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

textarea {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  resize: vertical;
  min-height: 9rem;
  tab-size: 2;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: var(--space-4);
  min-height: 16rem;
}

.editor:focus {
  box-shadow: none;
}

.editor[readonly] {
  color: var(--ink-2);
}

.checkline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--step-sm);
  color: var(--ink-2);
  cursor: pointer;
}

.checkline input {
  width: auto;
  accent-color: var(--accent);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: end;
}

.control-row > * {
  flex: 1 1 10rem;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-inset);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.segmented button {
  padding: var(--space-1) var(--space-3);
  min-height: 28px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  font-size: var(--step-xs);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* --- Status -------------------------------------------------------------- */

.status {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: var(--step-sm);
  font-family: var(--font-mono);
  line-height: 1.5;
  border: 1px solid transparent;
}

.status:empty {
  display: none;
}

.status[data-kind="ok"] {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 8%, transparent);
  border-color: color-mix(in srgb, var(--ok) 24%, transparent);
}

.status[data-kind="bad"] {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 8%, transparent);
  border-color: color-mix(in srgb, var(--bad) 24%, transparent);
}

.status[data-kind="warn"] {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border-color: color-mix(in srgb, var(--warn) 24%, transparent);
}

/* --- Chain rail ---------------------------------------------------------- */

.chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--rule-strong);
}

.chain__label {
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-right: var(--space-1);
}

/* --- Sidebar ------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + var(--space-4));
  display: grid;
  gap: var(--space-5);
}

@media (max-width: 1000px) {
  .sidebar {
    position: static;
  }
}

.sidebar__group h2 {
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-2);
}

.sidelist {
  display: grid;
  list-style: none;
  padding: 0;
}

.sidelist a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  margin-inline: calc(var(--space-2) * -1);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--step-sm);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.sidelist a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sidelist a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

.sidelist .icon {
  color: var(--cat, var(--ink-3));
}

/* --- Sticky mobile action bar -------------------------------------------- */

.action-bar {
  display: none;
}

@media (max-width: 1000px) {
  .action-bar {
    position: sticky;
    bottom: 0;
    z-index: 80;
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) 0;
    margin-top: var(--space-4);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--rule);
  }

  .action-bar .btn {
    flex: 1;
    min-height: 46px;
  }
}

/* --- Long-form content --------------------------------------------------- */

.prose {
  max-width: var(--measure);
  color: var(--ink-2);
  line-height: 1.75;
}

.prose > * + * {
  margin-top: var(--space-4);
}

.prose h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-h2);
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-top: var(--space-7);
}

.prose h3 {
  font-size: var(--step-h3);
  font-weight: 600;
  color: var(--ink);
  margin-top: var(--space-6);
}

.prose a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.15em 0.35em;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: var(--space-2);
}

.prose blockquote {
  padding-left: var(--space-4);
  border-left: 2px solid var(--accent-line);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-style: italic;
  color: var(--ink);
}

/* --- FAQ ----------------------------------------------------------------- */

.faq {
  border-top: 1px solid var(--rule);
}

.faq details {
  border-bottom: 1px solid var(--rule);
}

.faq summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary .icon {
  margin-left: auto;
  color: var(--ink-3);
  transition: rotate 0.2s var(--ease);
}

.faq details[open] summary .icon {
  rotate: 180deg;
}

.faq details > div {
  padding-bottom: var(--space-4);
  max-width: var(--measure);
  color: var(--ink-2);
}

/* --- Command palette ----------------------------------------------------- */

.palette {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 40rem;
  width: calc(100% - 2rem);
  margin-top: 12vh;
}

.palette::backdrop {
  background: rgb(20 18 16 / 45%);
  backdrop-filter: blur(3px);
}

.palette__box {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}

.palette__input {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--rule);
}

.palette__input .icon {
  color: var(--ink-3);
  font-size: 1.1rem;
}

.palette__input input {
  flex: 1;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 1.05rem;
}

.palette__input input:focus {
  outline: none;
  box-shadow: none;
}

.palette__results {
  max-height: min(24rem, 52vh);
  overflow-y: auto;
  padding: var(--space-2);
}

.palette__group {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.palette__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.palette__item[data-active="true"] {
  background: var(--surface-2);
}

.palette__item .icon:first-child {
  color: var(--cat, var(--accent));
  font-size: 1.05rem;
}

.palette__item small {
  display: block;
  color: var(--ink-3);
  font-size: var(--step-xs);
}

.palette__item .icon:last-child {
  margin-left: auto;
  color: var(--ink-3);
  opacity: 0;
}

.palette__item[data-active="true"] .icon:last-child {
  opacity: 1;
}

.palette__foot {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
  font-size: var(--step-xs);
  color: var(--ink-3);
}

.palette__empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--ink-3);
  font-size: var(--step-sm);
}

/* --- Toasts -------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  translate: -50% 0;
  z-index: 300;
  display: grid;
  gap: var(--space-2);
  justify-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  font-size: var(--step-sm);
  animation: toast-in 0.2s var(--ease);
}

.toast[data-kind="bad"] {
  background: var(--bad);
  color: #fff;
}

@keyframes toast-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

/* --- Ads -----------------------------------------------------------------
   Height is reserved up front so the slot cannot shift content when it fills. */

.ad {
  margin-block: var(--space-7);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
  text-align: center;
}

.ad::before {
  content: "Advertisement";
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ad ins {
  display: block;
  min-height: 280px;
}

@media (min-width: 800px) {
  .ad ins {
    min-height: 90px;
  }
}

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--paper-tint);
  padding-block: var(--space-7);
  margin-top: var(--space-8);
}

.site-footer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--space-6);
}

.site-footer__brand {
  grid-column: 1 / -1;
}

@media (min-width: 1000px) {
  .site-footer__grid {
    grid-template-columns: 1.5fr repeat(6, minmax(0, 1fr));
  }

  .site-footer__brand {
    grid-column: auto;
  }
}

.site-footer h2 {
  font-family: var(--font-mono);
  font-size: var(--step-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--space-3);
}

.site-footer ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.site-footer a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--step-sm);
}

.site-footer a:hover {
  color: var(--accent);
}

.site-footer__note {
  max-width: 32ch;
  color: var(--ink-3);
  font-size: var(--step-sm);
  margin-top: var(--space-3);
}

.site-footer__base {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
  font-size: var(--step-xs);
  color: var(--ink-3);
}

.site-footer__base .visits {
  margin-left: auto;
  font-family: var(--font-mono);
}

.site-footer__base .visits b {
  color: var(--ink-2);
  font-weight: 500;
}

/* --- Game frame ---------------------------------------------------------- */

.game-shell {
  padding-block: var(--space-6) var(--space-8);
}

.game-stage {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-inset);
}

/* --- Legacy aliases ------------------------------------------------------
   The five arcade games are self-contained canvas apps carried over intact,
   and their stylesheets reference the token names from the previous design.
   Mapping them here keeps those files untouched rather than hand-editing
   several thousand lines of game CSS. Nothing new should use these. */

:root {
  --font-heading: var(--font-display);
  --font-body: var(--font-sans);
  --border: var(--rule);
  --text-muted: var(--ink-2);
  --primary: var(--cat-arcade);
  --secondary: var(--cat-data);
  --primary-glow: color-mix(in srgb, var(--cat-arcade) 40%, transparent);
  --radius-full: 999px;
  --radius-md: var(--radius);
}

/* --- Utilities ----------------------------------------------------------- */

[hidden] {
  display: none !important;
}

.stack-6 > * + * {
  margin-top: var(--space-6);
}

.muted {
  color: var(--ink-2);
}

.text-center {
  text-align: center;
}
