/* ==========================================================================
   Base: reset, typography, focus, layout utilities.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, h5 { margin: 0; line-height: var(--lh-tight); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video { max-width: 100%; display: block; }
img { height: auto; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--brand-100); color: var(--text); }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: var(--s-2); inset-inline-start: var(--s-2); z-index: 200;
  background: var(--text); color: var(--bg); padding: var(--s-2) var(--s-4); border-radius: var(--r-md);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* layout helpers */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--s-4); }
.container-narrow { max-width: var(--container-narrow); }
.stack { display: flex; flex-direction: column; gap: var(--gap, var(--s-4)); }
.row { display: flex; align-items: center; gap: var(--gap, var(--s-3)); }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.row-start { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.grid { display: grid; gap: var(--gap, var(--s-4)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(var(--min, 220px), 1fr)); }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-2.keep, .grid-3.keep { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gap-1 { --gap: var(--s-1); } .gap-2 { --gap: var(--s-2); } .gap-3 { --gap: var(--s-3); }
.gap-4 { --gap: var(--s-4); } .gap-6 { --gap: var(--s-6); } .gap-8 { --gap: var(--s-8); }
.mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); }
.ms-auto { margin-inline-start: auto; }
.w-full { width: 100%; }

.muted { color: var(--text-2); }
.hint { color: var(--text-3); font-size: var(--fs-sm); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.center { text-align: center; }
.end { text-align: end; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.text-ok { color: var(--success); } .text-warn { color: var(--warning); } .text-bad { color: var(--danger); } .text-brand { color: var(--brand-600); }

.only-mobile { display: none !important; }
@media (max-width: 767px) { .only-desktop { display: none !important; } .only-mobile { display: initial !important; } .only-mobile.row, .only-mobile.flex { display: flex !important; } }

/* rich text (markdown output) */
.prose { color: var(--text-2); line-height: 1.7; }
.prose > * + * { margin-top: var(--s-3); }
.prose h2, .prose h3, .prose h4 { color: var(--text); margin-top: var(--s-6); }
.prose ul { list-style: disc; padding-inline-start: var(--s-6); }
.prose ol { list-style: decimal; padding-inline-start: var(--s-6); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote { margin-inline: 0; padding-inline-start: var(--s-4); border-inline-start: 3px solid var(--border-strong); color: var(--text-2); }
.prose code { font-family: var(--font-mono); background: var(--surface-2); padding: 0.1em 0.35em; border-radius: var(--r-sm); font-size: 0.9em; }

@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
}
