:root {
  --text: #222;
  --muted: #666;
  --rule: #ccc;
  --accent: #0055a4;
  --bg: #f9f9f9;
  --mark-red: #c62828;
  --mark-blue: #1565c0;
  --mark-default: #2e7d32;
}

* { box-sizing: border-box; }

body {
  font-family: Arial, sans-serif;
  max-width: 800px;
  margin: 40px auto;
  padding: 0 20px 60px;
  line-height: 1.6;
  background-color: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

header img.logo {
  height: 60px;
  margin-right: 20px;
}

header h1 {
  margin: 0;
  font-size: 1.8em;
  line-height: 1.2;
  font-weight: bold;
}

.subtitle {
  margin: 0 0 28px;
  font-size: 1.1em;
  color: var(--text);
  font-weight: normal;
}

.subtitle .meta {
  color: var(--muted);
  font-size: 0.95em;
}

h2 {
  font-size: 1.4em;
  margin: 2em 0 10px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 4px;
}

h3 {
  font-size: 1.15em;
  margin: 1.6em 0 0.5em;
}

h4 {
  font-size: 1.05em;
  margin: 1.35em 0 0.45em;
}

p { margin: 0 0 0.9rem; }

ul, ol {
  margin: 0 0 0.9rem;
  padding-left: 1.4rem;
}

li { margin-bottom: 0.25rem; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

pre {
  background: #f0f0f0;
  border: 1px solid var(--rule);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  line-height: 1.45;
}

figure {
  margin: 1.25rem 0;
  text-align: center;
}

figure img,
img.fig {
  max-width: 100%;
  height: auto;
}

figcaption {
  margin-top: 0.5rem;
  font-size: 0.9em;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
}

th, td {
  border: 1px solid var(--rule);
  padding: 8px;
  text-align: left;
}

th { background-color: #f0f0f0; }

.eq-block {
  overflow-x: auto;
  margin: 0.9rem 0 1rem;
}

.eq-note {
  font-size: 0.9em;
  color: var(--muted);
  margin: -0.35rem 0 1rem 1.25rem;
  line-height: 1.45;
}

.eq-note .swatch {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  border-radius: 2px;
  margin-right: 0.3em;
  vertical-align: -0.05em;
}

.swatch.red { background: var(--mark-red); }
.swatch.blue { background: var(--mark-blue); }
.swatch.green { background: var(--mark-default); }

.footnote {
  font-size: 0.9em;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem;
  padding-top: 0.85rem;
}

.footnote ol {
  margin: 0.4rem 0 0;
  padding-left: 1.25rem;
}

.footnote li { margin-bottom: 0.4rem; }

sup.fn a { font-size: 0.75em; }

.lec-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95em;
}

.lec-nav .lec-nav-mid {
  text-align: center;
}

.lec-nav .prev,
.lec-nav .next {
  white-space: nowrap;
}

@media (max-width: 640px) {
  body { margin: 20px auto; }
  header { align-items: flex-start; }
  header img.logo { height: 48px; margin-right: 14px; }
  header h1 { font-size: 1.35em; }

  .lec-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .lec-nav .lec-nav-mid {
    order: -1;
  }
}
