:root {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --ink: #111111;
  --ink-secondary: #3d3d3d;
  --muted: #6b6b6b;
  --muted-light: #999999;
  --accent: #0a6b5c;
  --accent-hover: #085548;
  --border: #e5e5e5;
  --border-light: #f0f0f0;
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: ui-serif, Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(10, 107, 92, 0.12); }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
svg { display: block; }
.site-main { flex: 1; }
.muted { font-size: 15px; color: var(--muted); }

.animate-in { animation: fadeIn 0.6s var(--ease-expo) forwards; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s var(--ease-expo);
}
.btn-primary { background: var(--accent); color: #fff; font-size: 0.875rem; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--border-light); color: var(--ink); }
.btn-ghost.active { color: var(--ink); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(250, 250, 250, 0.8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.site-header-inner {
  max-width: 64rem;
  margin: 0 auto;
  height: 3.5rem;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { font-size: 15px; font-weight: 600; letter-spacing: -0.025em; transition: opacity 0.3s var(--ease-expo); }
.logo:hover { opacity: 0.7; }
.site-nav { display: flex; align-items: center; gap: 0.25rem; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; gap: 0.25rem; }
.menu summary::-webkit-details-marker { display: none; }
.chevron { width: 0.875rem; height: 0.875rem; transition: transform 0.3s var(--ease-expo); }
.menu[open] .chevron { transform: rotate(180deg); }

.dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.5rem;
  width: 12rem;
  padding: 0.375rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-elevated);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  animation: dropdownIn 0.25s var(--ease-expo) forwards;
  transform-origin: top;
}
.dropdown[hidden] { display: none; }
@keyframes dropdownIn {
  from { opacity: 0; transform: scaleY(0.96) translateY(-4px); }
  to { opacity: 1; transform: scaleY(1) translateY(0); }
}
.dropdown-item {
  display: block;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.2s var(--ease-expo);
}
.dropdown-item:hover, .dropdown-item.active { background: var(--border-light); color: var(--ink); }
.dropdown-search { width: 18rem; max-height: 18rem; overflow: auto; }
.dropdown-search .dropdown-item { color: var(--ink); }
.dropdown-empty { padding: 0.5rem 0.75rem; font-size: 13px; color: var(--muted); }

.search { position: relative; margin: 0 0 0 0.5rem; }
.search-icon {
  pointer-events: none;
  position: absolute;
  left: 0.75rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--muted-light);
}
.search input {
  height: 2.25rem;
  width: 11rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--bg-elevated);
  padding: 0 0.75rem 0 2.25rem;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: all 0.3s var(--ease-expo);
}
.search input::placeholder { color: var(--muted-light); }
.search input:focus { border-color: var(--muted-light); }
@media (min-width: 640px) { .search input { width: 14rem; } }

.site-footer { border-top: 1px solid var(--border); background: var(--bg); }
.site-footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  font-size: 13px;
  color: var(--muted);
}
.footer-left { display: flex; flex-direction: column; gap: 0.75rem; }
.footer-categories { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 12px; }
.footer-right { display: flex; gap: 1rem; }
.site-footer a { transition: color 0.2s var(--ease-expo); }
.site-footer a:hover { color: var(--ink); }
.site-footer .light { color: var(--muted-light); }
.site-footer .sep { color: var(--border); }
@media (min-width: 1024px) {
  .site-footer-inner { flex-direction: row; align-items: center; justify-content: space-between; }
}

.page { max-width: 56rem; margin: 0 auto; padding: 2.5rem 1.25rem; }
.page-narrow { max-width: 48rem; }
.home { padding-top: 3rem; padding-bottom: 3rem; }

.hero { margin-bottom: 4rem; text-align: center; }
.hero h1, .article-header h1, .page-header h1 {
  font-family: var(--font-serif);
  font-size: 1.875rem;
  line-height: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}
@media (min-width: 640px) {
  .hero h1, .article-header h1 { font-size: 2.25rem; line-height: 2.5rem; }
}
.hero p { max-width: 32rem; margin: 1rem auto 0; font-size: 15px; line-height: 1.625; color: var(--muted); }

.alphabet {
  position: sticky;
  top: 3.5rem;
  z-index: 30;
  margin: 0 -1.25rem 3rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(250, 250, 250, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.alphabet div { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
.alphabet a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.25rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.3s var(--ease-expo);
}
.alphabet a:hover { background: var(--border-light); color: var(--ink); }

.letters { display: flex; flex-direction: column; gap: 4rem; }
.letter { scroll-margin-top: 8rem; }
.letter h2 {
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 600;
}

.terms { columns: 1; column-gap: 2rem; }
.terms li { margin-bottom: 0.625rem; break-inside: avoid; }
@media (min-width: 640px) { .terms { columns: 2; } }
@media (min-width: 1024px) { .terms { columns: 3; } }

.term-link { position: relative; font-size: 15px; color: var(--ink-secondary); transition: color 0.3s var(--ease-expo); }
.term-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 0;
  background: currentColor;
  transition: width 0.4s var(--ease-expo);
}
.term-link:hover { color: var(--accent); }
.term-link:hover::after { width: 100%; }

.breadcrumb { margin-bottom: 2rem; font-size: 13px; color: var(--muted); }
.breadcrumb a { transition: color 0.2s var(--ease-expo); }
.breadcrumb a:hover, .breadcrumb .current { color: var(--ink); }
.breadcrumb .sep { margin: 0 0.5rem; }

.page-header { margin-bottom: 2.5rem; }
.page-header p { margin-top: 0.75rem; font-size: 15px; color: var(--muted); }

.article-grid { display: grid; gap: 3rem; }
.article-grid > article { min-width: 0; }
@media (min-width: 1024px) { .article-grid { grid-template-columns: 1fr 200px; } }
.article-header { margin-bottom: 2.5rem; }
.definition {
  margin-top: 1.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  font-size: 15px;
  line-height: 1.625;
  color: var(--ink-secondary);
}

.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.article-header .pills { margin-top: 1.5rem; }
.pill {
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.3s var(--ease-expo);
}
.pill:hover { border-color: var(--muted-light); color: var(--ink); }
.pill-lg { padding: 0.375rem 0.75rem; font-size: 13px; }

.section-links { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.section-links.tight { margin-top: 2.5rem; }
.section-links.cta { margin-top: 3rem; }
.section-links h2 {
  margin-bottom: 1rem;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.toc { display: none; }
@media (min-width: 1024px) { .toc { display: block; } }
.toc > div { position: sticky; top: 5rem; }
.toc p {
  margin-bottom: 1rem;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.toc ul { display: flex; flex-direction: column; gap: 0.5rem; border-left: 1px solid var(--border); font-size: 13px; }
.toc a {
  display: block;
  margin-left: -1px;
  padding-left: 1rem;
  border-left: 1px solid transparent;
  color: var(--muted);
  transition: all 0.2s var(--ease-expo);
}
.toc a:hover { border-color: var(--accent); color: var(--ink); }
.toc a.depth-3 { padding-left: 1.5rem; font-size: 12px; }

.not-found { display: flex; flex-direction: column; align-items: center; padding-top: 5rem; padding-bottom: 5rem; text-align: center; }
.not-found .code { font-size: 80px; font-weight: 600; line-height: 1; color: var(--border); }
.not-found h1 { margin-top: 1rem; font-family: var(--font-serif); font-size: 1.5rem; line-height: 2rem; font-weight: 600; }
.not-found .muted { margin-top: 0.75rem; max-width: 28rem; }
.not-found div { margin-top: 2rem; }

.prose { font-size: 15px; line-height: 1.8; color: var(--ink-secondary); max-width: none; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 1.25em 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.prose h1, .prose h2.doc-title { margin: 0 0 0.888em; font-size: 1.875rem; line-height: 2.25rem; }
.prose h2 { margin: 3rem 0 1em; font-size: 1.25rem; line-height: 1.75rem; }
.prose h3 { margin: 2rem 0 0.6em; font-size: 1.125rem; line-height: 1.75rem; }
.prose h4 { margin: 1.5em 0 0.5em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0; }
.prose h2.doc-title + * { margin-top: 1.25em; }
.page-narrow .prose h2 { margin-top: 2.5rem; }
.prose a { color: var(--accent); font-weight: 500; }
.prose a:hover { text-decoration: underline; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose ul, .prose ol { margin: 1rem 0; padding-left: 1.625em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin: 0.25rem 0; padding-left: 0.375em; }
.prose li::marker { color: #d1d5db; }
.prose ol > li::marker { color: #6b7280; }
.prose li > p { margin: 0.75em 0; }
.prose blockquote {
  margin: 1.6em 0;
  padding-left: 1em;
  border-left: 0.25rem solid #e5e7eb;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
}
.prose hr { margin: 3em 0; border: 0; border-top: 1px solid var(--border); }
.prose img { max-width: 100%; height: auto; }
.prose code {
  border-radius: 0.25rem;
  background: var(--border-light);
  padding: 0.125rem 0.25rem;
  font-size: 13px;
  color: var(--ink);
}
.prose pre {
  margin: 1.7em 0;
  padding: 0.85em 1.15em;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--bg-elevated);
  font-size: 0.875em;
  line-height: 1.7;
}
.prose pre code { padding: 0; background: none; font-size: inherit; }
.prose table { width: 100%; margin: 2em 0; border-collapse: collapse; font-size: 0.875em; line-height: 1.7; text-align: left; }
.prose thead { border-bottom: 1px solid #d1d5db; }
.prose th { padding: 0 0.57em 0.57em; font-weight: 600; color: var(--ink); vertical-align: bottom; }
.prose td { padding: 0.57em; vertical-align: baseline; }
.prose tbody tr { border-bottom: 1px solid #e5e7eb; }
.prose tbody tr:last-child { border-bottom: 0; }
.prose .math.block, .prose div.math { margin: 1.25em 0; overflow-x: auto; overflow-y: hidden; }
