/* Shared design for every page: plain, paper-like, Charter text and monospace for anything machine-ish. */
:root {
  color-scheme: dark;
  --bg: #15161a;
  --text: #e6e6e6;
  --muted: #9a9a9a;
  --rule: #34353b;
  --surface: #1c1d22;
  --link: #8fb4e8;
  --term: #7fd1a4;
  --dough: #b99466;
  --butter: #e8c95a;
  /* System fonts only, nothing to download: Charter on Apple devices, the closest built-in book serif elsewhere. */
  --body: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --page: 760px;
  --gutter: 20px;

  /* Names the thesis viewer and calculator styles were written against. */
  --text-muted: var(--muted);
  --border: var(--rule);
  --bg-card: var(--bg);
  --bg-secondary: var(--surface);
  --input-bg: var(--bg);
  --accent: var(--link);
  --accent-hover: #b3cdf2;
  --accent-glow: #8fb4e81f;
  --on-accent: #15161a;
  --radius: 3px;
  --radius-lg: 3px;
  --transition: .2s ease;
  --font-sans: var(--body);
  --font-display: var(--body);
  --font-mono: var(--mono);
}
:root.light {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1c1c1c;
  --muted: #666666;
  --rule: #e3e3e3;
  --surface: #f5f5f5;
  --link: #1d4f91;
  --term: #1f7a4d;
  --dough: #dcc19b;
  --butter: #f4d96a;
  --accent-hover: #163d71;
  --accent-glow: #1d4f911a;
  --on-accent: #ffffff;
}
@media (min-width: 1100px) {
  :root { --page: 1040px; --gutter: 32px; }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 400 18px/1.6 var(--body);
}
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
b, strong { font-weight: 600; }
button, input, select { font-family: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }

/* Header, the same on every page */
.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px max(var(--gutter), calc((100% - var(--page)) / 2 + var(--gutter)));
  background: var(--bg); border-bottom: 1px solid var(--rule);
  font: 13px/1 var(--mono);
}
.site-title { color: var(--text); text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 18px; list-style: none; flex-wrap: wrap; justify-content: flex-end; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }
.theme-toggle { display: inline-flex; padding: 2px; border: 0; background: none; cursor: pointer; color: var(--muted); }
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 14px; height: 14px; fill: currentColor; }
.skip-link {
  position: fixed; top: 8px; left: 16px; z-index: 1001; padding: 8px 12px;
  background: var(--bg); color: var(--text); border: 1px solid var(--rule);
  font: 13px var(--mono); transform: translateY(-160%);
}
.skip-link:focus { transform: none; }
.scroll-progress { position: fixed; top: 0; left: 0; z-index: 1000; width: 0; height: 2px; background: var(--link); }

/* Page body */
.site-main { flex: 1; width: 100%; max-width: var(--page); margin: 0 auto; padding: 32px var(--gutter); }
.site-main h1 { font-size: 2rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
.site-footer, .page-footer {
  width: 100%; max-width: var(--page); margin: 64px auto 0; padding: 16px var(--gutter) 40px;
  border-top: 1px solid var(--rule);
  font: 12px/1.6 var(--mono); color: var(--muted);
}
.page-footer a { color: inherit; }
.card { border: 1px solid var(--rule); padding: 1.5rem; }

.back-to-top {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 50;
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  background: var(--bg); border: 1px solid var(--rule); color: var(--text); cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { border-color: var(--text); }
.back-to-top svg { width: 18px; height: 18px; fill: currentColor; }

/* Forms */
label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.3rem; }
input[type="number"], select {
  width: 100%; padding: 0.45rem 0.6rem; font: 14px var(--mono);
  background: var(--bg); color: var(--text); border: 1px solid var(--rule); border-radius: var(--radius);
}
input[type="number"]:focus, select:focus { outline: 2px solid var(--link); outline-offset: 1px; }

.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;
}

@media (max-width: 560px) {
  body { font-size: 17px; }
  .site-nav { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media print {
  .scroll-progress, .back-to-top, .theme-toggle { display: none !important; }
  .site-header { position: static; }
  body { background: white; color: black; }
  a { color: black; }
}
