body {
  font-family: var(--font-main);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: var(--leading-normal);
}

/* ─── Typography scale ─────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); letter-spacing: -0.025em; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h3 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

p + p {
  margin-top: var(--space-3);
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-blue-hover);
  text-decoration: underline;
}

strong, b {
  font-weight: 600;
  color: var(--text-primary);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-3);
  color: var(--accent-green);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  color: var(--text-primary);
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

blockquote {
  border-left: 3px solid var(--accent-blue);
  padding-left: var(--space-4);
  color: var(--text-secondary);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}

/* ─── Focus ring (WCAG 2.1 AA) ────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Remove outline when not keyboard-navigating */
:focus:not(:focus-visible) {
  outline: none;
}

/* ─── Skip to content ─────────────────────────────────────── */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: var(--z-toast);
  background: var(--accent-blue);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: var(--space-4);
}

/* ─── Main content area ───────────────────────────────────── */
main {
  padding-top: var(--nav-height);
  min-height: calc(100vh - var(--nav-height));
}

/* ─── Container ───────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding-inline: var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container {
    padding-inline: var(--space-8);
  }
}

/* ─── Section ─────────────────────────────────────────────── */
.section {
  padding-block: var(--space-12);
}

/* ─── Selection colour ────────────────────────────────────── */
::selection {
  background: var(--accent-blue-subtle);
  color: var(--text-primary);
}

/* ─── Scrollbar (Webkit) ──────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-2);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Visually hidden (accessibility) ────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Loading skeleton ────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.skeleton {
  background: var(--surface-3);
  border-radius: var(--radius-md);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ─── Truncate text ───────────────────────────────────────── */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Text utilities ──────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary  { color: var(--text-primary); }
.text-success  { color: var(--accent-green); }
.text-danger   { color: var(--accent-red); }
.text-warning  { color: var(--accent-yellow); }
.text-info     { color: var(--accent-blue); }

.text-sm   { font-size: var(--text-sm); }
.text-xs   { font-size: var(--text-xs); }
.text-lg   { font-size: var(--text-lg); }
.font-mono { font-family: var(--font-mono); }

/* ─── Flex / grid utilities ───────────────────────────────── */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
