:root {
  --textw: 58rem;
  --marginw: 22rem;
  --gutter: 3rem;
  --maxw: calc(var(--textw) + var(--marginw) + var(--gutter));
  --bg: #f7f5f1;
  --ink: #14161a;
  --muted: #5d6068;
  --rule: #e3e4ea;
  --accent: #0f4c81;
  --panel: #ffffff;
  --note: #f2f3f6;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(1200px 800px at 85% -10%, #ffffff 0%, #f7f5f1 45%, #f0efec 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  line-height: 1.7;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 76, 129, 0.25);
}

a:hover { border-bottom-color: rgba(15, 76, 129, 0.65); }

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 245, 241, 0.92);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}

.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
  color: inherit;
}

.links a {
  margin-left: 1rem;
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: inherit;
}

.commentary-global {
  margin-left: 1rem;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.75rem 1.5rem 5rem;
}

.container > *:not(details.commentary) {
  max-width: var(--textw);
  margin-right: auto;
}

h1, h2, h3, h4 {
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(2.4rem, 4vw, 3.4rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.6rem, 2.4vw, 2.2rem); margin-top: 2.4rem; }
h3 { font-size: clamp(1.25rem, 1.6vw, 1.5rem); margin-top: 1.8rem; }

p { margin: 0 0 1.2rem; }

ul, ol {
  padding-left: 1.3rem;
  margin: 0 0 1.2rem;
}

li { margin-bottom: 0.4rem; }

blockquote {
  margin: 1.4rem 0;
  padding: 0.2rem 1.1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

details.commentary {
  float: right;
  clear: right;
  width: var(--marginw);
  margin: 0.2rem 0 1.6rem var(--gutter);
  padding: 0.85rem 0.9rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--note);
  font-size: 0.95rem;
  line-height: 1.55;
  box-shadow: 0 12px 24px rgba(17, 18, 24, 0.08);
}

details.commentary summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.6rem;
}

details.commentary summary::-webkit-details-marker { display: none; }
details.commentary summary::marker { content: ""; }

.commentary-toggle {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  background: #fff;
}

.commentary-toggle::before { content: "+"; }

details.commentary[open] .commentary-toggle {
  background: var(--ink);
  color: #fff;
}

details.commentary[open] .commentary-toggle::before { content: "\2212"; }

.commentary-global .commentary-toggle { box-shadow: none; }
.commentary-global[aria-pressed="true"] .commentary-toggle::before { content: "\2212"; }

.commentary-body > :first-child { margin-top: 0; }
.commentary-body > :last-child { margin-bottom: 0; }

@media (max-width: 960px) {
  :root {
    --textw: 100%;
    --marginw: 100%;
    --gutter: 0;
    --maxw: 100%;
  }

  .nav-inner { padding: 0.75rem 1rem; flex-wrap: wrap; }
  .links { width: 100%; justify-content: space-between; flex-wrap: wrap; display: flex; }
  .links a { margin-left: 0.6rem; }
  .commentary-global { margin-left: 0.6rem; }

  .container { padding: 2rem 1rem 4rem; }

  details.commentary {
    float: none;
    width: auto;
    margin: 0 0 1.4rem 0;
    box-shadow: none;
  }
}
