:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-muted: #eaede8;
  --border: #c4cdc0;
  --border-strong: #9aaa94;
  --text: #1a2e1a;
  --text-muted: #4a6348;
  --accent: #2d6a4f;
  --accent-hover: #1b4332;
  --accent-soft: rgba(45, 106, 79, 0.10);
  --code-bg: #f0f5ee;
  --code-text: #1a2e1a;
  --code-border: rgba(45, 106, 79, 0.22);
  --shadow: 0 1px 3px rgba(26, 46, 26, 0.06);
  --radius: 8px;
  --menu-width: 20rem;
  --toc-width: 16rem;
  --content-width: 52rem;
  --grid-color: rgba(45, 106, 79, 0.06);
  --grid-strong: rgba(45, 106, 79, 0.12);
}


* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px),
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px);
  background-size:
    20px 20px,
    20px 20px,
    100px 100px,
    100px 100px;
  font-family: "IBM Plex Sans", "Avenir Next", Avenir, "Segoe UI", sans-serif;
  line-height: 1.65;
}

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

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

img {
  max-width: 100%;
}

code,
pre,
kbd,
samp {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

pre {
  overflow-x: auto;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  color: var(--code-text);
}

pre code {
  color: inherit;
  background: transparent;
  padding: 0;
}

code {
  padding: 0.15rem 0.4rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface-muted);
  border: 0;
  font-size: 0.88em;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.6rem 1rem;
  border-inline-start: 3px solid var(--accent);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--accent-soft);
}

hr {
  border: 0;
  border-top: 1px dashed var(--border-strong);
  margin: 2rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

th,
td {
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
  font-size: 0.95rem;
}

th {
  background: var(--surface-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.hidden,
input.toggle {
  display: none;
}

.flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.container {
  width: min(100%, 86rem);
  margin: 0 auto;
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
}

.book-menu,
.book-toc {
  align-self: flex-start;
  position: sticky;
  top: 1rem;
}

.book-menu {
  width: min(var(--menu-width), 100%);
}

.book-menu-content,
.book-toc-content {
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.book-page {
  min-width: 0;
  flex: 1;
}

.book-article,
.book-footer {
  max-width: var(--content-width);
  margin: 0 auto;
}

.book-article {
  padding: 2rem 2.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.book-footer {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.book-header {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.book-header h3,
.book-brand {
  margin: 0;
}

.book-brand a {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.book-brand a:hover {
  text-decoration: none;
  color: var(--accent);
}

.book-brand img {
  width: 2rem;
  height: 2rem;
}

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

.book-menu nav li + li {
  margin-top: 0.05rem;
}

.book-menu nav ul ul {
  margin-inline-start: 0.8rem;
  padding-inline-start: 0.8rem;
  border-inline-start: 1px dashed var(--border-strong);
}

.book-menu nav a,
.book-menu nav label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.5rem;
  color: inherit;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.95rem;
}

.book-menu nav a:hover,
.book-menu nav label:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.book-menu nav a.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
}

.book-menu nav label > img:last-child {
  margin-inline-start: auto;
  transition: transform 0.18s ease;
}

.book-menu input.toggle:checked + label > img:last-child {
  transform: rotate(90deg);
}

.book-menu input.toggle + label + ul {
  display: none;
}

.book-menu input.toggle:checked + label + ul {
  display: block;
}

.book-section-flat > a,
.book-section-flat > span,
.book-section-flat > label {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.book-icon {
  width: 1rem;
  height: 1rem;
}

.book-search {
  margin: 1rem 0 1.25rem;
}

.book-search input,
.book-search-results,
input[type="text"],
input[type="search"] {
  width: 100%;
}

.book-search input {
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: inherit;
  font-size: 0.9rem;
}

.book-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.book-search-results {
  margin-top: 0.75rem;
  padding: 0;
  list-style: none;
}

.book-search-results li {
  margin: 0.4rem 0;
}

.book-toc {
  display: none;
}

a.anchor {
  margin-right: 0.4em;
  text-decoration: none;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.markdown h1 {
  font-size: 1.9rem;
  margin-top: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--accent);
}

.markdown h2 {
  font-size: 1.45rem;
  margin-top: 2.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed var(--border-strong);
}

.markdown h3 {
  font-size: 1.15rem;
  margin-top: 1.8rem;
  color: var(--accent);
}

.markdown p,
.markdown ul,
.markdown ol {
  margin: 1rem 0;
}

.markdown li + li {
  margin-top: 0.35rem;
}

.markdown .book-hint,
.markdown .book-card,
.markdown .book-btn,
.markdown .book-badge {
  border-radius: var(--radius);
}

.book-footer,
.book-copyright {
  padding-bottom: 1rem;
}

.book-menu-overlay {
  display: none;
}

/* Prism syntax highlighting */
code[class*="language-"],
pre[class*="language-"] {
  text-shadow: none;
}

.token.comment { color: #7a8a72; font-style: italic; }
.token.string { color: #1a8a2e; }
.token.keyword { color: #0550ae; font-weight: 600; }
.token.builtin { color: #8730b8; }
.token.type { color: #8730b8; }
.token.constant { color: #b35000; }
.token.self { color: #b35000; }
.token.number { color: #b35000; }
.token.operator { color: #24574a; }
.token.punctuation { color: #57705a; }

@media (max-width: 72rem) {
  .book-toc {
    display: none;
  }
}

@media (max-width: 56rem) {
  .container {
    display: block;
    padding: 1rem;
  }

  .book-header.hidden {
    display: block;
  }

  .book-menu {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(22rem, calc(100vw - 3rem));
    max-width: none;
    transform: translateX(-115%);
    transition: transform 0.22s ease;
  }

  .book-menu-content {
    height: calc(100vh - 2rem);
    margin: 1rem;
    overflow: auto;
  }

  #menu-control:checked ~ main .book-menu {
    transform: translateX(0);
  }

  #menu-control:checked ~ main .book-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    background: rgba(13, 17, 23, 0.5);
  }

  .book-article {
    padding: 1.4rem 1.1rem;
  }
}
