:root {
  --bg: #f8faf9;
  --paper: #ffffff;
  --ink: #151917;
  --muted: #68736e;
  --green: #0f6b4f;
  --line: rgba(21, 25, 23, 0.1);
  --shadow: 0 18px 60px rgba(32, 43, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
  width: min(1060px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 76px;
  display: grid;
  grid-template-columns: 220px minmax(0, 800px);
  column-gap: 36px;
  row-gap: 24px;
  align-items: start;
}

.back {
  grid-column: 2;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  text-decoration: none;
  font-size: 14px;
  font-weight: 750;
  box-shadow: 0 8px 28px rgba(32, 43, 38, 0.05);
}

.toc-panel {
  position: sticky;
  top: 28px;
  grid-column: 1;
  grid-row: 2;
  max-height: calc(100vh - 56px);
  padding: 18px 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  box-shadow: 0 14px 45px rgba(32, 43, 38, 0.06);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.toc-title {
  margin: 0 4px 12px;
  color: #2b3933;
  font-size: 13px;
  font-weight: 850;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 116px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 107, 79, 0.24) transparent;
}

.toc-list::-webkit-scrollbar {
  width: 8px;
}

.toc-list::-webkit-scrollbar-track {
  background: transparent;
}

.toc-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(15, 107, 79, 0.24);
  background-clip: content-box;
}

.toc-link {
  display: block;
  padding: 7px 9px;
  border-radius: 10px;
  color: #65726c;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 650;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.toc-link:hover,
.toc-link.active {
  color: #123f31;
  background: #edf3f0;
}

.toc-link:hover {
  transform: translateX(2px);
}

.toc-level-3 {
  padding-left: 20px;
  font-size: 12px;
  font-weight: 600;
}

.toc-level-4 {
  padding-left: 32px;
  font-size: 12px;
  font-weight: 560;
}

.toc-panel.empty {
  display: none;
}

.note {
  grid-column: 2;
  grid-row: 2;
  margin-top: 0;
  padding: clamp(28px, 6vw, 54px);
  border-radius: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0 0 14px;
  color: var(--green);
  font-size: 13px;
  font-weight: 850;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.04;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.lead {
  margin: 22px 0 34px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.8;
}

.part-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 30px;
  padding: 14px;
  border-radius: 16px;
  background: #f2f6f4;
  border: 1px solid var(--line);
}

.part-nav-title {
  flex: 0 0 100%;
  margin: 0 0 4px;
  color: #2b3933;
  font-size: 13px;
  font-weight: 850;
}

.part-nav a,
.part-nav span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: #51615a;
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
}

.code-block {
  position: relative;
}

.code-copy {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(234, 244, 239, 0.16);
  border-radius: 10px;
  color: #dfece7;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.code-block:hover .code-copy,
.code-copy:focus-visible,
.code-copy.copied {
  opacity: 1;
  transform: translateY(0);
}

.code-copy:hover,
.code-copy.copied {
  background: rgba(255, 255, 255, 0.16);
}

.code-copy svg {
  width: 17px;
  height: 17px;
}

.part-nav a {
  background: #ffffff;
  border: 1px solid rgba(21, 25, 23, 0.08);
}

.part-nav a:hover,
.part-nav .current {
  color: #103f31;
  background: #e2ede8;
}

.note-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 54px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.pager-item {
  min-height: 86px;
  padding: 16px;
  border-radius: 18px;
  background: #f3f7f5;
  border: 1px solid var(--line);
  color: #1f2d28;
  text-decoration: none;
}

.pager-item.next {
  text-align: right;
}

.pager-label {
  display: block;
  margin-bottom: 8px;
  color: #728078;
  font-size: 12px;
  font-weight: 800;
}

.pager-title {
  display: block;
  color: #18221e;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 850;
}

a.pager-item {
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

a.pager-item:hover {
  background: #e7f0eb;
  box-shadow: 0 12px 32px rgba(32, 43, 38, 0.08);
  transform: translateY(-2px);
}

.pager-item.disabled {
  color: #8a9690;
  background: #f7f9f8;
}

.note-content {
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

h2 {
  scroll-margin-top: 22px;
  margin: 52px 0 16px;
  padding-top: 4px;
  font-size: 24px;
}

h3,
h4 {
  scroll-margin-top: 22px;
  margin: 34px 0 12px;
  color: #25302b;
}

p {
  max-width: 72ch;
  color: #303835;
  font-size: 17px;
  line-height: 1.85;
}

ul,
ol {
  margin: 12px 0 18px;
  padding-left: 24px;
  color: #303835;
  font-size: 16px;
  line-height: 1.85;
}

li + li {
  margin-top: 6px;
}

code {
  padding: 2px 6px;
  border-radius: 7px;
  background: #edf1f0;
  color: #0f513d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

pre {
  margin: 24px 0 34px;
  padding: 18px;
  border-radius: 18px;
  background: #17251f;
  color: #eaf4ef;
  overflow: auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
  line-height: 1.7;
}

figure {
  margin: 24px 0;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 14px 42px rgba(32, 43, 38, 0.08);
}

.table-wrap {
  margin: 16px 0 28px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #244238;
  background: #edf3f0;
  font-weight: 850;
}

td {
  color: #34403b;
  overflow-wrap: anywhere;
}

.source-path {
  margin: -2px 0 12px;
  color: #74807a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 26px;
}

.stat-strip span {
  padding: 9px 12px;
  border-radius: 999px;
  color: #173f31;
  background: #e7efeb;
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 1040px) {
  .page {
    width: min(820px, calc(100% - 32px));
    display: block;
  }

  .toc-panel {
    position: sticky;
    top: 12px;
    z-index: 5;
    max-height: none;
    margin: 18px 0 0;
    padding: 12px;
    border-radius: 18px;
  }

  .toc-title {
    margin-bottom: 8px;
  }

  .toc-list {
    flex-direction: row;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0 2px;
  }

  .toc-link,
  .toc-level-3,
  .toc-level-4 {
    flex: 0 0 auto;
    padding: 7px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .toc-link:hover {
    transform: none;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 22px, 820px);
    padding-top: 24px;
  }

  .note {
    border-radius: 22px;
  }

  .note-pager {
    grid-template-columns: 1fr;
  }

  .pager-item.next {
    text-align: left;
  }
}
