*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; margin: 0 0 var(--s3); }
h1 { font-size: clamp(1.875rem, 1.6rem + 1.2vw, 2.25rem); font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin: 0 0 var(--s3); max-width: 68ch; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--primary); text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
button, summary, label { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus, h1:focus:not(:focus-visible), h2:focus:not(:focus-visible), legend:focus:not(:focus-visible) { outline: none; }
.num { font-variant-numeric: tabular-nums; }
.meta { font-size: 0.875rem; color: var(--muted); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: var(--s4);
  top: -100px;
  z-index: 30;
  background: var(--surface);
  padding: var(--s3) var(--s4);
  border-radius: var(--r1);
}
.skip-link:focus { top: var(--s2); }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: var(--s5) var(--s4); }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--s2) var(--s4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.main-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.main-nav a {
  height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  border-top: 2px solid transparent;
}
.main-nav a[aria-current="page"] { color: var(--primary); border-top-color: var(--primary); font-weight: 600; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

.site-footer { border-top: 1px solid var(--line); font-size: 0.875rem; color: var(--muted); }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }

body.is-exam { padding-bottom: 0; }
body.is-exam .main-nav { display: none; }

@media (min-width: 600px) {
  .container, .header-inner { padding-left: var(--s5); padding-right: var(--s5); }
}

@media (min-width: 960px) {
  body, body.is-exam { padding-bottom: 0; }
  .main-nav, body.is-exam .main-nav {
    position: static;
    display: flex;
    gap: var(--s2);
    border: 0;
    margin-left: auto;
    padding: 0;
  }
  .main-nav a { flex-direction: row; gap: var(--s2); height: 44px; padding: 0 var(--s3); font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
