@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter-latin-600-normal.woff2') format('woff2');
}

:root {
  --bg: #ffffff;
  --bg-soft: #f7f6f2;
  --bg-sidebar: #f7f6f2;
  --surface: #ffffff;
  --border: #e4e2dd;
  --border-strong: #d4d1ca;
  --text: #1c1c1e;
  --text-secondary: #52525b;
  --text-muted: #77767a;
  --primary: #253d2c;
  --primary-soft: #e6eee8;
  --link: #2f6b45;
  --accent: #c86d51;
  --code-bg: #f4f3ef;
  --code-text: #24292f;
  --inline-code-bg: #efede7;
  --shadow: 0 12px 32px rgba(20, 20, 19, 0.12);
  --note: #2f6fb3;
  --note-bg: #eef5fc;
  --tip: #2e6f40;
  --tip-bg: #edf6ef;
  --important: #6d4bb3;
  --important-bg: #f3effb;
  --warning: #a45a08;
  --warning-bg: #fdf5e8;
  --caution: #b42318;
  --caution-bg: #fdeeec;
  --hl-keyword: #a3360f;
  --hl-string: #1f6f3f;
  --hl-number: #8a4b00;
  --hl-comment: #77767a;
  --hl-title: #2759a6;
  --hl-attr: #7a3e9d;
  --topbar-h: 60px;
  --sidebar-w: 292px;
  --toc-w: 232px;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #141413;
  --bg-soft: #1b1b1a;
  --bg-sidebar: #181817;
  --surface: #1e1e1c;
  --border: #2e2e2b;
  --border-strong: #3c3c38;
  --text: #f1f0ec;
  --text-secondary: #b3b2ac;
  --text-muted: #8c8b85;
  --primary: #7fb08e;
  --primary-soft: #1f2d23;
  --link: #8fc39e;
  --accent: #e08a6d;
  --code-bg: #1c1c1b;
  --code-text: #e6e5e0;
  --inline-code-bg: #262624;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --note: #79aee6;
  --note-bg: #17222e;
  --tip: #7fb08e;
  --tip-bg: #18241b;
  --important: #b39ae6;
  --important-bg: #221c2e;
  --warning: #e3a356;
  --warning-bg: #2b2114;
  --caution: #f08a80;
  --caution-bg: #2e1a18;
  --hl-keyword: #f08f6e;
  --hl-string: #8fd1a2;
  --hl-number: #e6b673;
  --hl-comment: #8c8b85;
  --hl-title: #8ab4f0;
  --hl-attr: #c9a0e8;
  color-scheme: dark;
}

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

html {
  scroll-padding-top: calc(var(--topbar-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

a {
  color: var(--link);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}
.skip-link:focus {
  top: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand img {
  border-radius: 7px;
}
.brand-name {
  font-weight: 600;
}
.brand-tag {
  color: var(--text-muted);
  font-size: 14px;
}

.search {
  position: relative;
  flex: 1;
  max-width: 460px;
  margin-left: auto;
}
.search input {
  width: 100%;
  height: 38px;
  padding: 0 72px 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.search input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  background: var(--surface);
}
.search-key {
  position: absolute;
  right: 10px;
  top: 8px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
}
.search input:not(:placeholder-shown) + .search-key {
  display: none;
}
.search-results {
  position: absolute;
  top: 46px;
  left: 0;
  right: 0;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.search-result[aria-selected='true'],
.search-result:hover {
  background: var(--primary-soft);
}
.search-result-path {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}
.search-result-title {
  display: block;
  font-weight: 600;
  font-size: 15px;
}
.search-result-excerpt {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.search-result mark {
  background: transparent;
  color: var(--link);
  font-weight: 600;
}
.search-empty {
  padding: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.theme-toggle,
.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.theme-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
.repo-link {
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
}
.repo-link:hover {
  color: var(--text);
}
.menu-button {
  display: none;
}
.menu-button span,
.menu-button span::before,
.menu-button span::after {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
}
.menu-button span::before,
.menu-button span::after {
  content: '';
  position: absolute;
}
.menu-button span::before {
  top: -5px;
}
.menu-button span::after {
  top: 5px;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 20px 14px 40px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  font-size: 14.5px;
  line-height: 1.45;
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar ul ul {
  display: none;
  margin: 2px 0 4px 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.sidebar li.open > ul {
  display: block;
}
.nav-group + .nav-group {
  margin-top: 18px;
}
.nav-group-title {
  margin: 0 0 6px;
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav-row {
  display: flex;
  align-items: center;
}
.nav-row a {
  flex: 1;
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
}
.nav-row a:hover {
  background: var(--border);
  color: var(--text);
}
.nav-row a[aria-current='page'] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-toggle {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.nav-toggle::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 10px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
li.open > .nav-row .nav-toggle::before {
  transform: rotate(45deg);
}
.nav-toggle:hover {
  background: var(--border);
}

.content {
  min-width: 0;
  padding: 32px 56px 64px;
  outline: none;
}
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 13px;
}
.breadcrumb span + span::before {
  content: '/';
  margin-right: 6px;
}

.markdown {
  max-width: 820px;
}
.markdown h1 {
  margin: 0 0 20px;
  font-size: 34px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.markdown h2 {
  margin: 44px 0 14px;
  padding-top: 8px;
  font-size: 24px;
  line-height: 1.3;
  border-top: 1px solid var(--border);
  padding-top: 28px;
}
.markdown h3 {
  margin: 32px 0 10px;
  font-size: 19px;
}
.markdown h4 {
  margin: 24px 0 8px;
  font-size: 16px;
}
.markdown h2,
.markdown h3,
.markdown h4 {
  position: relative;
}
.anchor {
  position: absolute;
  left: -22px;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
}
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor {
  opacity: 1;
}
.markdown p,
.markdown ul,
.markdown ol {
  margin: 0 0 16px;
}
.markdown ul,
.markdown ol {
  padding-left: 24px;
}
.markdown li + li {
  margin-top: 4px;
}
.markdown li > ul,
.markdown li > ol {
  margin: 6px 0 0;
}
.markdown strong {
  font-weight: 600;
}
.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}
.markdown img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.markdown a.external::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: translateY(-3px);
}
.markdown code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--inline-code-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.86em;
  overflow-wrap: anywhere;
}
.markdown blockquote {
  margin: 0 0 16px;
  padding: 2px 16px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
}

.code-block {
  margin: 0 0 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}
.copy-button {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.copy-button:hover {
  color: var(--text);
}
.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
}
.code-block code {
  padding: 0;
  background: none;
  color: var(--code-text);
  font-size: 13.5px;
  line-height: 1.6;
  overflow-wrap: normal;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-literal,
.hljs-meta {
  color: var(--hl-keyword);
}
.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-template-tag {
  color: var(--hl-string);
}
.hljs-number,
.hljs-symbol,
.hljs-bullet {
  color: var(--hl-number);
}
.hljs-comment,
.hljs-quote,
.hljs-deletion {
  color: var(--hl-comment);
}
.hljs-title,
.hljs-section,
.hljs-function .hljs-title,
.hljs-title.class_,
.hljs-title.function_ {
  color: var(--hl-title);
}
.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-property,
.hljs-type,
.hljs-params {
  color: var(--hl-attr);
}

.table-wrap {
  margin: 0 0 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}
.markdown th,
.markdown td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.markdown th {
  background: var(--bg-soft);
  font-weight: 600;
  white-space: nowrap;
}
.markdown tr:last-child td {
  border-bottom: 0;
}
.markdown td code {
  white-space: nowrap;
}

.hint {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-left-width: 4px;
  border-radius: 10px;
}
.hint > :last-child {
  margin-bottom: 0;
}
.hint-title {
  margin: 0 0 4px !important;
  font-weight: 600;
  font-size: 14px;
}
.hint-note {
  background: var(--note-bg);
  border-color: var(--note);
}
.hint-note .hint-title {
  color: var(--note);
}
.hint-tip {
  background: var(--tip-bg);
  border-color: var(--tip);
}
.hint-tip .hint-title {
  color: var(--tip);
}
.hint-important {
  background: var(--important-bg);
  border-color: var(--important);
}
.hint-important .hint-title {
  color: var(--important);
}
.hint-warning {
  background: var(--warning-bg);
  border-color: var(--warning);
}
.hint-warning .hint-title {
  color: var(--warning);
}
.hint-caution {
  background: var(--caution-bg);
  border-color: var(--caution);
}
.hint-caution .hint-title {
  color: var(--caution);
}

.diagram {
  margin: 0 0 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow-x: auto;
  text-align: center;
}
.diagram pre.mermaid {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  white-space: pre-wrap;
  text-align: left;
}
.diagram pre.mermaid[data-processed='true'] {
  text-align: center;
}
.diagram svg {
  max-width: 100%;
  height: auto;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 820px;
  margin-top: 48px;
}
.pager a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}
.pager a:hover {
  border-color: var(--primary);
}
.pager span {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}
.pager-next {
  text-align: right;
}

.page-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  max-width: 820px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.page-footer a {
  color: var(--text-secondary);
}

.toc {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 32px 20px 40px 8px;
  font-size: 13.5px;
  line-height: 1.45;
}
.toc-title {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}
.toc li a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
}
.toc li.toc-h3 a {
  padding-left: 24px;
  font-size: 13px;
}
.toc li a:hover {
  color: var(--text);
}
.toc li a.active {
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}

.backdrop {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  z-index: 15;
  background: rgba(0, 0, 0, 0.35);
}

.not-found {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}
.not-found-box {
  max-width: 460px;
  text-align: center;
}
.not-found-box img {
  border-radius: 12px;
}
.button {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}

@media (max-width: 1240px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .menu-button {
    display: inline-flex;
  }
  .brand-tag,
  .repo-link,
  .search-key {
    display: none;
  }
  .topbar {
    gap: 10px;
    padding: 0 16px;
  }
  .search input {
    padding-right: 12px;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    z-index: 20;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar {
    transform: none;
  }
  .content {
    padding: 24px 16px 48px;
  }
  .markdown h1 {
    font-size: 28px;
  }
  .anchor {
    display: none;
  }
  .pager {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand-name {
    display: none;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toc,
  .pager,
  .page-footer {
    display: none;
  }
  .layout {
    display: block;
  }
}
