@import url("https://fonts.googleapis.com/css2?family=Lora:wght@400;600&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;600&display=swap");

:root {
  --bg: #ffffff;
  --ink: #16181d;
  --ink-soft: #6a7280;
  --line: #e5e9f0;
  --line-strong: #d8dee8;
  --accent: #2f3a4a;

  --definition: #2563eb;
  --definition-soft: #f2f7ff;
  --lemma: #16a34a;
  --lemma-soft: #f2fff7;
  --theorem: #d97706;
  --theorem-soft: #fffaf0;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Lora", Georgia, serif;
  color: var(--ink);
  background: var(--bg);
}

body > header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(10, 20, 40, 0.03);
  padding: 0.58rem 0.85rem;
}

#toc-toggle {
  width: 1.2rem;
  height: 1.2rem;
  color: #6e7786;
}

h1#doc_title {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: clamp(0.98rem, 1.35vw, 1.12rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

#doc_title a,
#doc_title a:visited {
  color: var(--ink);
}

div.wrapper {
  gap: 1rem;
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 0.75rem 0.9rem 1rem;
}

nav.toc {
  background: transparent !important;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 0.16rem 0.85rem 0.25rem 0;
}

nav.toc::before {
  content: "CONTENTS";
  display: block;
  margin: 0.12rem 0 0.6rem 0.8rem;
  color: #8a93a3;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.toc ul {
  background: transparent !important;
}

.toc ul li {
  margin: 0.08rem 0;
  background: transparent !important;
}

.toc ul li.current {
  background: transparent !important;
  font-weight: inherit;
}

.toc ul a {
  color: var(--ink-soft);
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.93rem;
  line-height: 1.25rem;
  border-radius: 4px;
  padding-top: 0.28rem;
  padding-bottom: 0.28rem;
}

.toc ul a:hover {
  background: transparent !important;
  color: var(--ink);
}

.toc ul li.current > a {
  background: transparent !important;
  color: #1f2734;
  font-weight: 700;
  box-shadow: inset 2px 0 0 #2f3a4a;
}

span.expand-toc {
  color: #8a93a3;
  font-size: 0.82rem;
}

.toc ul.sub-toc-1,
.toc ul.sub-toc-2,
.toc ul.sub-toc-3,
.toc ul.sub-toc-4 {
  margin-left: 0.45rem;
  border-left: 1px solid #edf1f6;
}

.sub-toc-0 a {
  padding-left: 0.8rem;
}

.sub-toc-1 a {
  padding-left: 1.14rem;
}

.sub-toc-2 a {
  padding-left: 1.42rem;
}

.sub-toc-3 a {
  padding-left: 1.7rem;
}

.sub-toc-4 a {
  padding-left: 1.95rem;
}

div.content {
  padding: 0;
}

div.content-wrapper {
  width: min(100%, 78ch);
  max-width: 78ch;
  margin: 0 auto;
  padding: clamp(0.85rem, 1.7vw, 1.6rem);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.main-text > h1 {
  font-family: "Inter", "Segoe UI", sans-serif;
  color: #171c24;
}

.main-text > h1:first-of-type {
  margin: 0 0 0.95rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.88rem, 2.6vw, 2.42rem);
  line-height: 1.07;
  font-weight: 700;
}

.main-text > h1:not(:first-of-type) {
  margin-top: 1.5rem;
  margin-bottom: 0.62rem;
  padding-top: 0.28rem;
  border-top: 1px solid #eef1f6;
  font-size: clamp(1.16rem, 1.8vw, 1.52rem);
  font-weight: 700;
}

.main-text p,
.main-text li {
  font-family: "Lora", Georgia, serif;
  color: #3f4652;
  font-size: 1.06rem;
  line-height: 1.74;
}

.titlepage {
  text-align: left;
  padding: 0.2rem 0 0.45rem;
}

.titlepage h1 {
  margin: 0;
  padding-bottom: 0.58rem;
  border-bottom: 1px solid var(--line);
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: clamp(1.95rem, 2.85vw, 2.65rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.004em;
  color: #171c24;
}

.titlepage .authors {
  margin-top: 0.42rem;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.83rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #7a8597;
  text-transform: uppercase;
}

nav.local_toc {
  margin-top: 0.8rem;
}

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

nav.local_toc > ul > li {
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 0.72rem 0 0.68rem;
}

nav.local_toc > ul > li:first-child {
  border-top: 0;
  padding-top: 0.12rem;
}

nav.local_toc a {
  text-decoration: none;
}

nav.local_toc > ul > li > a {
  display: inline-flex;
  gap: 0.45rem;
  align-items: baseline;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2734;
}

nav.local_toc > ul > li > a .toc_ref {
  color: #8190a7;
  font-size: 0.9rem;
  font-weight: 700;
}

nav.local_toc > ul > li > a:hover {
  color: #111827;
}

nav.local_toc > ul > li > ul {
  margin-top: 0.42rem;
  margin-left: 0.45rem;
  border-left: 1px solid #e9eef6;
  padding-left: 0.75rem;
}

nav.local_toc > ul > li > ul > li {
  margin: 0;
  padding: 0.22rem 0;
}

nav.local_toc > ul > li > ul > li > a {
  display: inline-flex;
  gap: 0.38rem;
  align-items: baseline;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.93rem;
  color: #556174;
  font-weight: 500;
}

nav.local_toc > ul > li > ul > li > a .toc_ref {
  color: #98a4b6;
  font-size: 0.8rem;
  font-weight: 600;
}

nav.local_toc > ul > li > ul > li > a:hover {
  color: #1f2734;
}

a,
a:visited {
  color: #2f3a4a;
}

a:hover {
  color: #1f2734;
}

.ttfamily,
.texttt,
code,
pre,
code.verb {
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 0.9em;
}

code,
code.verb {
  border: 1px solid #d9e1ee;
  border-radius: 5px;
  background: #f6f9ff;
  padding: 0.05rem 0.34rem;
}

pre.verbatim {
  border: 1px solid #dce4f1;
  border-radius: 8px;
  background: #f8fbff;
  padding: 0.72rem 0.9rem;
}

div.equation,
div.displaymath {
  border: 1px solid #e0e7f2;
  border-radius: 8px;
  background: #fbfdff;
}

div[class$="_thmwrapper"] {
  margin-top: 0.95rem;
  border: 1px solid #dfe6f1;
  border-left: 4px solid #8fa2be;
  border-radius: 8px;
  background: #fbfdff;
  padding: 0.72rem 0.85rem 0.78rem;
}

div.definition_thmwrapper {
  border-left-color: var(--definition);
  background: var(--definition-soft);
}

div.lemma_thmwrapper {
  border-left-color: var(--lemma);
  background: var(--lemma-soft);
}

div.theorem_thmwrapper,
div.proposition_thmwrapper,
div.corollary_thmwrapper {
  border-left-color: var(--theorem);
  background: var(--theorem-soft);
}

div[class$="_thmheading"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.34rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.44rem;
  border-bottom: 1px solid #e2e8f2;
}

span[class$="_thmcaption"] {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  color: #798496;
  font-weight: 700;
}

span[class$="_thmlabel"] {
  margin: 0 0.18rem 0 0;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  border: 1px solid #b8c7dc;
  background: #ecf3ff;
  color: #2a4b75;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.79rem;
  font-weight: 700;
}

div.definition_thmwrapper span[class$="_thmlabel"] {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

div.lemma_thmwrapper span[class$="_thmlabel"] {
  border-color: #86efac;
  background: #dcfce7;
  color: #166534;
}

div.theorem_thmwrapper span[class$="_thmlabel"],
div.proposition_thmwrapper span[class$="_thmlabel"],
div.corollary_thmwrapper span[class$="_thmlabel"] {
  border-color: #fcd34d;
  background: #fef3c7;
  color: #92400e;
}

span[class$="_thmtitle"]::before,
span[class$="_thmtitle"]::after {
  content: "";
}

span[class$="_thmtitle"] {
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.97rem;
  font-weight: 600;
}

div[class$="_thmcontent"] {
  margin-left: 0;
  padding: 0;
}

div.proof_content {
  margin-left: 0.2rem;
  border-left: 3px solid #cbd6e5;
  background: #f7fafe;
  border-radius: 5px;
  padding: 0.48rem 0.72rem;
}

div.thm_header_hidden_extras {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 0.25rem;
}

div[class$="_thmheading"]:hover div.thm_header_hidden_extras {
  display: flex;
}

button.modal,
a.icon {
  border: 1px solid #cad5e5;
  border-radius: 5px;
  background: #f2f6fc;
  color: #304a6a;
  min-height: 1.35rem;
  padding: 0.08rem 0.28rem;
}

button.modal:hover,
a.icon:hover {
  background: #e8eef8;
}

div.modal-container {
  background: rgba(15, 23, 42, 0.34);
}

div.modal-content {
  width: min(94vw, 780px);
  max-height: min(82vh, 700px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fbfdff;
}

div.modal-content header {
  background: #eff4fb;
  border-bottom: 1px solid var(--line);
}

div.modal-content header h1 {
  font-family: "Inter", sans-serif;
  font-size: 1rem;
}

nav.prev_up_next {
  border: 1px solid var(--line);
  border-right: 0;
  border-bottom: 0;
  border-radius: 10px 0 0 0;
  background: #f2f6fc;
}

nav.prev_up_next a {
  color: #36506f;
}

@media (max-width: 1023px) {
  body > header {
    padding: 0.52rem 0.6rem;
  }

  h1#doc_title {
    font-size: 0.93rem;
  }

  div.wrapper {
    width: 100%;
    padding: 0.52rem;
  }

  nav.toc {
    display: flex;
    position: fixed;
    left: -110%;
    top: 3.2rem;
    width: min(90vw, 370px);
    height: calc(100vh - 3.75rem);
    z-index: 48;
    transition: left 0.22s ease;
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
    padding-right: 0.36rem;
  }

  nav.toc.active {
    left: 0.52rem;
  }

  div.content-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 0.92rem;
  }

  .main-text > h1:first-of-type {
    font-size: 1.68rem;
  }
}

@media (min-width: 1024px) {
  nav.toc {
    display: flex;
    width: 22ch;
    max-width: 22ch;
    height: calc(100vh - 2rem);
    position: sticky;
    top: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
