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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  /* plain --c-bg plus decorative layers (restyle): three soft glows near the top, then a faint grid. Pure CSS
     gradients — no image, no request; they scroll with the page (no fixed or animated background). */
  background-color: var(--c-bg);
  background-image:
    radial-gradient(680px 440px at 4% -80px, var(--c-glow-1), transparent 70%),
    radial-gradient(600px 420px at 98% 40px, var(--c-glow-2), transparent 70%),
    radial-gradient(760px 520px at 52% 820px, var(--c-glow-3), transparent 70%),
    linear-gradient(var(--c-page-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--c-page-grid) 1px, transparent 1px);
  background-size: auto, auto, auto, var(--grid-step) var(--grid-step), var(--grid-step) var(--grid-step);
  background-repeat: no-repeat, no-repeat, no-repeat, repeat, repeat;
  color: var(--c-text);
  font-family: var(--font-en);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  overflow-wrap: break-word;
}

/* Per-language font stacks avoid mixed glyph shapes from Han unification. */
:lang(zh-Hans) body,
body:lang(zh-Hans) {
  font-family: var(--font-zh-hans);
  line-height: var(--lh-cjk);
}
:lang(zh-Hant) body,
body:lang(zh-Hant) {
  font-family: var(--font-zh-hant);
  line-height: var(--lh-cjk);
}
:lang(ja) body,
body:lang(ja) {
  font-family: var(--font-ja);
  line-height: var(--lh-cjk);
  line-break: strict;
}

h1,
h2,
h3 {
  line-height: 1.3;
  margin: 0 0 var(--space-2);
}
h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.15rem;
}
h3 {
  font-size: 1rem;
}
p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--c-link);
  text-underline-offset: 2px;
}
a:hover {
  text-decoration-thickness: 2px;
}

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

:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--c-bg);
  border: 2px solid var(--c-focus);
  border-radius: var(--radius);
}
.skip-link:focus {
  top: var(--space-2);
}

/* Reduced motion: switch transitions and animations off entirely. Do NOT use the common
   "transition-duration: 0.01ms" hack: transition-property defaults to `all`, so a non-zero duration
   would add a (tiny) transition to every property of every element, delaying e.g. hover colours
   by a frame instead of removing motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* High-contrast (forced colours) and print: drop the decorative layers of the restyle; text stays solid. The
   component rules (brand gradient, cards, header glass) have their own fallbacks in components.css / layout.css. */
@media (forced-colors: active) {
  body {
    background-image: none;
  }
}
@media print {
  body {
    background: none;
  }
}

/* MathML token elements must not inherit word-wrapping (otherwise "64" can render as "6"). */
math,
math * {
  overflow-wrap: normal;
  word-break: normal;
  line-break: auto;
}
