
:root {
  --bg: #ffffff;
  --paper: #ffffff;
  --ink: #171717;
  --muted: #666666;
  --line: rgba(32, 29, 24, 0.12);
  --accent: #111111;
  --measure: 72ch;
  --display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "URW Palladio L", Georgia, serif;
  --body: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "Iosevka", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.68;
}

a {
  color: inherit;
  text-decoration-color: rgba(138, 59, 18, 0.45);
  text-underline-offset: 0.14em;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

main {
  width: min(1120px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 5.5rem 0 4rem;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header-inner {
  width: min(1120px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 0.9rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header a {
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--ink);
}

.site-title {
  display: inline-block;
}

.site-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
}

.site-title-sep {
  color: var(--muted);
}

.site-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-search {
  min-width: 0;
  width: min(20rem, 42vw);
}

.header-search .gcse-search {
  width: 100%;
}

.site-tools .gsc-control-cse,
.site-tools .gsc-control-cse-en {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  font-family: var(--mono) !important;
}

.site-tools table.gsc-search-box,
.site-tools .gsc-search-box,
.site-tools form.gsc-search-box {
  margin: 0 !important;
}

.site-tools .gsib_a {
  padding: 0 !important;
}

.site-tools .gsib_b {
  display: none !important;
}

.site-tools .gsc-input-box {
  border: 1px solid var(--line) !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.9) !important;
  height: 1.9rem !important;
  box-shadow: none !important;
}

.site-tools input.gsc-input,
.site-tools input.gsc-input:focus {
  margin: 0 !important;
  padding: 0.32rem 0.75rem !important;
  height: 1.9rem !important;
  background: transparent !important;
  box-shadow: none !important;
  font-family: var(--mono) !important;
  font-size: 0.82rem !important;
}

.site-tools .gsc-search-button,
.site-tools .gsc-search-button-v2 {
  margin: 0 !important;
  padding: 0 !important;
  min-width: 1.9rem !important;
  width: 1.9rem !important;
  height: 1.9rem !important;
  border: 1px solid var(--line) !important;
  border-radius: 999px !important;
  background: transparent !important;
}

.site-tools .gsc-search-button-v2 svg {
  width: 0.85rem !important;
  height: 0.85rem !important;
}

.gsc-results-wrapper-overlay,
.gsc-results-wrapper-visible {
  position: fixed !important;
  top: 4.4rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: min(1120px, calc(100vw - 2rem)) !important;
  max-width: none !important;
  height: calc(100vh - 5.4rem) !important;
  max-height: calc(100vh - 5.4rem) !important;
  overflow: auto !important;
  z-index: 30 !important;
}

.gsc-overlay {
  z-index: 29 !important;
}

.pdf-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.pdf-link svg {
  width: 0.9rem;
  height: 0.9rem;
}

.front-title {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.front-subtitle {
  margin: -0.7rem 0 0;
  color: black; /*var(--muted)*/
  font-family: var(--body);
  font-size: 1.06rem;
  line-height: 1.45;
  font-style: italic;
}

.social-links {
  margin: 0.7rem 0 1.4rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid #d5d7db;
  border-radius: 0.6rem;
  background: #f8fafc;
  color: #334155;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.social-icon {
  width: 0.88rem;
  height: 0.88rem;
  fill: currentColor;
  flex: 0 0 auto;
}

.social-link-discord:hover {
  border-color: #818cf8;
  background: #eef2ff;
  color: #4338ca;
}

.social-link-x:hover {
  border-color: #64748b;
  background: #e2e8f0;
  color: #0f172a;
}

.social-link-github:hover {
  border-color: #10b981;
  background: #ecfdf5;
  color: #047857;
}

.front-split {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 2rem;
  align-items: stretch;
  margin-bottom: 2.5rem;
}

.front-cover {
  display: flex;
  flex-direction: column;
}

.front-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.front-cover-link {
  display: block;
  flex: 1 1 auto;
}

.front-cover-caption {
  margin-top: 0.55rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: center;
}

.front-excerpt {
  max-width: var(--measure);
}

.front-excerpt .center {
  margin: 0;
}

.content-shell {
  display: block;
}

.content-shell.with-aside {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: 2.4rem;
  align-items: start;
}

.toc-panel,
.content-panel {
  padding: 0;
}

.toc-panel {
  margin-top: 2.2rem;
}

.panel,
.content-panel,
.toc-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.panel {
  padding: 0;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.page-head {
  margin-bottom: 2rem;
}

.page-head.is-minimal {
  display: none;
}

.page-path {
  margin-bottom: 0.45rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--muted);
}

.page-heading-line {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.page-number,
.page-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.3;
}

.chapter-sections {
  margin: 1.1rem 0 2rem;
}

.chapter-sections ul,
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chapter-sections li + li,
.toc-item + .toc-item {
  margin-top: 0.45rem;
}

.toc-panel h2,
.panel h2 {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-size: 1.5rem;
}

.toc-entry {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toc-number {
  min-width: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}

.toc-number-empty {
  min-width: 0;
}

.toc-type-part .toc-number {
  min-width: 0;
}

.toc-type-part .toc-entry {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--display);
  font-size: 1.12rem;
  gap: 0.35rem;
}

.toc-type-part:first-child .toc-entry {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.toc-type-chapter,
.toc-type-appendix {
  margin-top: 0.8rem;
}

.toc-type-section { padding-left: 1.2rem; }
.toc-type-subsection { padding-left: 2.2rem; font-size: 0.95rem; }
.toc-type-subsubsection,
.toc-type-paragraph { padding-left: 3rem; font-size: 0.92rem; }

.toc-entry a,
.toc-entry a:visited {
  color: inherit;
}

.toc-entry > a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.content-panel article {
  max-width: var(--measure);
}

.content-panel p,
.content-panel li {
  font-size: 1.05rem;
}

.content-panel h2,
.content-panel h3,
.content-panel h4,
.content-panel h5 {
  font-family: var(--display);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.content-panel h2 { margin-top: 2.2rem; font-size: 1.95rem; }
.content-panel h3 { margin-top: 1.8rem; font-size: 1.45rem; }
.content-panel h4,
.content-panel h5 { margin-top: 1.4rem; font-size: 1.12rem; }

.heading-number {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--muted);
  margin-right: 0.5rem;
}

.content-panel figure {
  margin: 1.8rem 0;
}

.content-panel figure > figure {
  display: inline-block;
  width: min(49%, 100%);
  vertical-align: top;
  margin: 0 0.5% 0.75rem 0;
}

.content-panel figcaption {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.content-panel .cquote,
.front-excerpt .cquote {
  margin: 1.8rem 0;
  padding-left: 2.2rem;
  font-style: italic;
}

.content-panel .flushright,
.content-panel .quote-author,
.content-panel .cquote .quote-author,
.front-excerpt .flushright,
.front-excerpt .quote-author,
.front-excerpt .cquote .quote-author {
  margin-top: 0.8rem;
  text-align: right;
  font-style: normal;
  color: var(--muted);
}

.content-panel .cquote br,
.front-excerpt .cquote br {
  display: none;
}

.content-panel .cquote p,
.front-excerpt .cquote p {
  margin: 0;
}

.content-panel .cquote p + p,
.front-excerpt .cquote p + p {
  margin-top: 0.7rem;
}

.content-panel .flow-diagram {
  margin: 1.6rem 0 0.45rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.8;
}

.content-panel .flow-diagram em {
  font-style: italic;
}

.content-panel dl {
  margin: 1.4rem 0;
  display: grid;
  gap: 0.6rem 1rem;
}

.content-panel .textnotes {
  margin: 2rem 0;
  display: grid;
  gap: 1.1rem;
}

.content-panel .textnote-item {
  display: grid;
  gap: 0.35rem;
}

.content-panel .textnote-body,
.content-panel .textnote-note {
  max-width: var(--measure);
}

.content-panel .textnote-body p,
.content-panel .textnote-note p {
  margin: 0;
}

.content-panel .textnote-note {
  width: min(90%, var(--measure));
  margin-left: auto;
  color: var(--muted);
  font-size: 0.97rem;
  text-align: right;
}

.content-panel dt {
  font-weight: 700;
}

.content-panel dd {
  margin: 0 0 0.2rem 0;
}

.content-panel .footnotes {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.content-panel sup a {
  text-decoration: none;
}

.content-panel .footnotes hr {
  display: none;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pager a {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
}

.pager small {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
}

.book-index-list {
  columns: 2 18rem;
  column-gap: 2rem;
}

.index-links a,
.index-links span {
  margin-right: 0.15rem;
}

.book-index-list section {
  break-inside: avoid;
  margin-bottom: 1.3rem;
}

.book-index-list h3 {
  margin-bottom: 0.6rem;
}

.index-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-left: 0.55rem;
  font-family: var(--mono);
  font-size: 0.88rem;
}

.section-toc {
  font-size: 0.92rem;
  position: sticky;
  top: 5.4rem;
  align-self: start;
}

.section-toc-inner {
  border-left: 1px solid var(--line);
  padding-left: 1rem;
}

.section-toc h2 {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.section-toc li + li {
  margin-top: 0.5rem;
}

.section-toc a {
  text-decoration: none;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
}

@media (max-width: 920px) {
  .front-split {
    grid-template-columns: 1fr;
  }

  .header-search {
    width: min(14rem, 45vw);
  }

  .gsc-results-wrapper-overlay,
  .gsc-results-wrapper-visible {
    width: calc(100vw - 1.2rem) !important;
    height: calc(100vh - 5rem) !important;
    max-height: calc(100vh - 5rem) !important;
  }

  .book-index-list {
    columns: 1;
  }

  .content-shell.with-aside {
    grid-template-columns: 1fr;
  }

  .section-toc {
    position: static;
    order: -1;
    margin-bottom: 1.5rem;
  }

  .section-toc-inner {
    position: static;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 1rem;
  }

  .site-header-inner {
    gap: 0.7rem;
  }

  .site-title-group {
    min-width: 0;
    overflow: hidden;
  }

  .site-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .site-tools {
    gap: 0.45rem;
  }

  .header-search {
    width: min(10.5rem, 42vw);
  }
}
