:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #edf2f4;
  --text: #1f2528;
  --muted: #657077;
  --line: #d8e0e4;
  --accent: #486f88;
  --accent-dark: #2f556c;
  --soft: #e7edf1;
  --code: #263238;
  --shadow: 0 16px 44px rgba(34, 45, 52, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 0.18em; }

.container {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 100;
  transform: translateY(-140%);
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  padding: 10px 14px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid transparent;
  background: rgba(246, 247, 244, 0.9);
  backdrop-filter: blur(14px);
}

.site-header.is-scrolled { border-bottom-color: var(--line); }

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 760;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  border-radius: 7px;
  color: var(--muted);
  font-size: 15px;
  padding: 9px 12px;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current="page"] {
  background: var(--soft);
  color: var(--text);
  outline: none;
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.nav-toggle span:not(.sr-only) {
  display: block;
  height: 2px;
  margin: 5px 0;
  background: var(--text);
}

.section { padding: 78px 0; }
.section.compact { padding: 58px 0; }
.muted { background: var(--surface-2); }

.hero {
  border-bottom: 1px solid var(--line);
  padding: 84px 0 90px;
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  align-items: center;
  gap: 56px;
}

.hero-art {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 800px;
  margin-bottom: 20px;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
}

h2 {
  margin-bottom: 18px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.12;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.25;
}

.lead, .hero-text {
  max-width: 690px;
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 21px);
}

.hero-actions,
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 720;
  text-decoration: none;
}

.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { border-color: var(--line); background: var(--surface); color: var(--text); }

.section-heading {
  max-width: 760px;
  margin-bottom: 34px;
}

.section-heading.row {
  max-width: none;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
}

.text-link {
  color: var(--accent-dark);
  font-weight: 720;
}

.topic-grid,
.notes-grid,
.archive-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.topic-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.topic-card,
.note-card,
.info-card,
.archive-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topic-card {
  min-height: 244px;
  padding: 24px;
}

.topic-card img {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
}

.note-card,
.archive-card,
.info-card {
  padding: 24px;
}

.note-card {
  min-height: 292px;
  display: flex;
  flex-direction: column;
}

.note-meta,
.archive-meta,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

.note-meta span,
.archive-meta span,
.article-meta span {
  color: var(--accent-dark);
}

.note-card p,
.topic-card p,
.archive-card p,
.info-card p,
.article-body p,
.article-body li {
  color: var(--muted);
}

.note-card a,
.archive-card a {
  margin-top: auto;
  color: var(--accent-dark);
  font-weight: 720;
}

.material-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 44px;
  align-items: start;
}

.material-list {
  border-top: 1px solid var(--line);
}

.material-list a {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
  text-decoration: none;
}

.material-list span {
  color: var(--muted);
  font-size: 14px;
}

.page-hero {
  padding: 68px 0 44px;
  border-bottom: 1px solid var(--line);
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 42px;
  align-items: start;
}

.article-body {
  max-width: 820px;
}

.article-body h2 {
  margin-top: 42px;
  font-size: 30px;
}

.article-body h3 {
  margin-top: 28px;
}

.article-body table {
  width: 100%;
  margin: 26px 0;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.article-body th,
.article-body td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

.article-body th {
  background: var(--soft);
  color: var(--text);
  font-weight: 760;
}

.article-body tr:last-child td { border-bottom: 0; }

code,
pre {
  border-radius: 8px;
  background: var(--code);
  color: #f4f7f8;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.94em;
}

code { padding: 0.14em 0.35em; }

pre {
  overflow-x: auto;
  padding: 16px;
  line-height: 1.5;
}

pre code { padding: 0; background: transparent; }

.side-note {
  position: sticky;
  top: 96px;
  border-left: 4px solid var(--accent);
  background: var(--surface);
  padding: 18px 20px;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--text);
  color: #fff;
}

.footer-inner {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.footer-inner p { margin: 0; color: rgba(255, 255, 255, 0.75); }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 14px; }
.footer-inner a { color: #fff; }

.to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.error-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.error-card {
  width: min(580px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 46px);
}

@media (max-width: 940px) {
  .hero-inner,
  .material-layout,
  .content-layout {
    grid-template-columns: 1fr;
  }

  .topic-grid,
  .notes-grid,
  .archive-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-note { position: static; }
}

@media (max-width: 700px) {
  .container { width: min(100% - 28px, 1120px); }
  .header-inner { min-height: 64px; }
  .nav-toggle { display: block; }

  .site-nav {
    position: absolute;
    left: 14px;
    right: 14px;
    top: 70px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 8px;
  }

  .site-nav.is-open { display: flex; }
  .site-nav a { padding: 12px 14px; }
  .hero { padding: 58px 0 66px; }
  .section { padding: 58px 0; }
  h1 { font-size: clamp(36px, 12vw, 52px); }

  .topic-grid,
  .notes-grid,
  .archive-grid {
    grid-template-columns: 1fr;
  }

  .material-list a {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .footer-inner {
    min-height: 118px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}

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