:root {
  color-scheme: light dark;
  --page: #f5f3ee;
  --sidebar: #ebe8e0;
  --surface: #fffefa;
  --hover: #f0eee8;
  --text: #24231f;
  --muted: #68655d;
  --heading: #11110f;
  --border: #d7d2c7;
  --border-strong: #bdb6a7;
  --accent: #21485d;
  --active: #dce9ee;
  --focus: #8a4d00;
  --code: #ece9e2;
  --sidebar-width: 19rem;
  --reading-width: 48rem;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #151715;
    --sidebar: #1b1e1b;
    --surface: #1e211e;
    --hover: #252925;
    --text: #e8e6df;
    --muted: #aaa79e;
    --heading: #f7f5ef;
    --border: #343934;
    --border-strong: #4a514a;
    --accent: #b1d8e8;
    --active: #253b43;
    --focus: #f0b45e;
    --code: #282c28;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--page);
  font-family: var(--sans);
  line-height: 1.5;
  text-size-adjust: 100%;
}

body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page);
}

a {
  color: var(--accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .18em;
}

a:hover { text-decoration-thickness: .14em; }

:focus-visible {
  outline: .18rem solid var(--focus);
  outline-offset: .2rem;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: .75rem;
  left: .75rem;
  padding: .65rem .9rem;
  color: var(--surface);
  background: var(--heading);
  border-radius: .25rem;
  transform: translateY(-200%);
}

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

.site-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 1.35rem;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

.proof-nav ul { margin: 0; padding: 0; list-style: none; }

.proof-nav a {
  display: block;
  padding: .52rem .65rem;
  color: var(--text);
  border-radius: .35rem;
  font-size: .91rem;
  line-height: 1.35;
  text-decoration: none;
}

.proof-nav a:hover {
  color: var(--heading);
  background: var(--hover);
}

.proof-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--active);
  font-weight: 700;
}


.author-credit {
  margin-top: auto;
  padding: 1.25rem .65rem .15rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: .8rem;
  line-height: 1.35;
}

.main-content {
  min-width: 0;
  padding: clamp(2.25rem, 5vw, 5.5rem) clamp(1.4rem, 6vw, 6rem);
}

.proof {
  width: min(100%, var(--reading-width));
  margin-inline: auto;
}

.claim {
  padding-bottom: 1.8rem;
  border-bottom: 1px solid var(--border-strong);
  color: var(--heading);
  font-family: var(--serif);
  font-size: clamp(1.28rem, 2.2vw, 1.55rem);
  line-height: 1.6;
}

.claim > :first-child { margin-top: 0; }
.claim > :last-child { margin-bottom: 0; }
.claim p { margin: .8em 0; }

.proof-content {
  padding-top: 1.8rem;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1.03rem, 1.7vw, 1.14rem);
  line-height: 1.78;
}

.proof-content > :first-child { margin-top: 0; }

.proof-content h2,
.proof-content h3,
.proof-content h4 {
  margin: 2.2em 0 .75em;
  color: var(--heading);
  line-height: 1.25;
}

.proof-content p,
.proof-content ul,
.proof-content ol,
.proof-content blockquote,
.proof-content pre,
.proof-content table {
  margin-top: 1.15em;
  margin-bottom: 1.15em;
}

.proof-content li + li { margin-top: .4em; }

.proof-content blockquote {
  margin-inline: 0;
  padding: .3rem 0 .3rem 1.2rem;
  color: var(--muted);
  border-left: .22rem solid var(--border-strong);
}

.proof-content code {
  padding: .12em .3em;
  font-family: var(--mono);
  font-size: .86em;
  background: var(--code);
  border-radius: .22rem;
}

.proof-content pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--code);
  border: 1px solid var(--border);
  border-radius: .45rem;
}

.proof-content pre code { padding: 0; background: transparent; }

.katex-display {
  max-width: 100%;
  margin: 1.45rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.claim .katex-display { margin: 1.1rem 0; }

.qed {
  margin-top: .2rem;
  color: var(--heading);
  font-family: var(--serif);
  font-size: 1.08em;
  line-height: 1;
  text-align: right;
}

.mobile-header { display: none; }

@media (max-width: 52rem) {
  .mobile-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    min-height: 4rem;
    align-items: center;
    justify-content: flex-end;
    padding: .75rem 1rem;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
  }

  .mobile-menu { position: relative; }

  .mobile-menu summary {
    padding: .48rem .7rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .35rem;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 700;
    list-style: none;
  }

  .mobile-menu summary::-webkit-details-marker { display: none; }

  .mobile-menu-panel {
    position: absolute;
    top: calc(100% + .55rem);
    right: 0;
    width: min(21rem, calc(100vw - 2rem));
    max-height: 70vh;
    overflow-y: auto;
    padding: .65rem;
    background: var(--sidebar);
    border: 1px solid var(--border);
    border-radius: .55rem;
  }

  .mobile-menu-panel .author-credit {
    margin-top: .65rem;
    padding: .75rem .65rem .1rem;
  }

  .site-shell { display: block; min-height: auto; }
  .sidebar { display: none; }
  .main-content { padding: clamp(2rem, 8vw, 3.5rem) clamp(1.1rem, 5vw, 2rem) 4rem; }
}

@media (max-width: 34rem) {
  .proof-content { font-size: 1.02rem; line-height: 1.72; }
}

@media print {
  :root {
    --page: #fff;
    --surface: #fff;
    --text: #000;
    --muted: #333;
    --heading: #000;
    --border: #bbb;
  }

  .mobile-header,
  .sidebar,
  .skip-link { display: none; }

  .site-shell { display: block; }
  .main-content { padding: 0; }
  .proof { width: 100%; max-width: none; }
  .proof-content { font-size: 11pt; }
  a { color: inherit; }
}
