:root {
  color-scheme: light;
  --yellow: #ffcb05;
  --ink: #1c1c1c;
  --muted: #5f5f5f;
  --line: #e7e7e7;
  --sidebar: #f5f5f6;
  --paper: #ffffff;
  --icon: #c4a035;
  --info: #198be3;
  --warning: #e07a00;
  --danger: #fb2c36;
  --success: #00a844;
  --header-h: 60px;
  --sidebar-w: 272px;
  --toc-w: 210px;
  --font: Inter, system-ui, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f3f3;
  --muted: #bdbdbd;
  --line: #2c2c2c;
  --sidebar: #1c1c1c;
  --paper: #111111;
  --icon: #ffcb05;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: clip; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  overscroll-behavior-x: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--yellow);
  color: #1a1a1a;
  min-width: 0;
  max-width: 100%;
}
.brand { display: flex; align-items: center; position: relative; z-index: 1; flex: none; }
.brand img { height: 32px; width: auto; object-fit: contain; }
.brand .logo-light { display: block; }
.brand .logo-dark { display: none; }
html[data-theme="dark"] .brand .logo-light { display: none; }
html[data-theme="dark"] .brand .logo-dark { display: block; }
html[data-theme="dark"] .topbar { background: #1a1a1a; color: #f3f3f3; }
html[data-theme="dark"] .menu-btn { color: #f3f3f3; }
.menu-btn {
  display: none;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #1a1a1a;
  cursor: pointer;
  border-radius: 0;
  width: 40px;
  height: 40px;
  padding: 8px;
  position: relative;
  z-index: 2;
  flex: none;
  -webkit-tap-highlight-color: transparent;
}
.burger {
  width: 18px;
  height: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.burger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
}
body.nav-open .burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.nav-open .burger span:nth-child(2) { opacity: 0; }
body.nav-open .burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.search {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, 42vw);
  min-width: 0;
  max-width: 100%;
}
.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 9px 78px 9px 38px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: #1a1a1a;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease;
}
.search input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.16);
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  color: #6b6b6b;
  display: flex;
}
.search-icon svg, .nav-icon svg, .page-icon svg, .card-icon svg, .hint-icon svg, .crumb svg { width: 100%; height: 100%; }
.search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: #666;
  background: #f3f3f3;
  border-radius: 6px;
  padding: 2px 6px;
  border: 1px solid #e5e5e5;
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  max-height: 360px;
  overflow: auto;
  padding: 6px;
  z-index: 30;
}
.search-results a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.search-results a:hover { background: var(--sidebar); }
.search-results small { display: block; color: var(--muted); }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  align-items: start;
  min-height: calc(100vh - var(--header-h));
}
.sidebar {
  margin: 16px 8px 16px 16px;
  background: var(--sidebar);
  border-radius: 16px;
  padding: 10px 8px 18px;
  position: sticky;
  top: calc(var(--header-h) + 12px);
  max-height: calc(100vh - var(--header-h) - 28px);
  overflow: auto;
}
.nav-row { display: flex; align-items: center; min-width: 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.18s ease, color 0.18s ease;
}
.nav-link:hover { background: rgba(0, 0, 0, 0.04); }
html[data-theme="dark"] .nav-link:hover { background: rgba(255, 255, 255, 0.06); }
.nav-link.active { font-weight: 650; }
.nav-icon { width: 16px; height: 16px; color: var(--icon); flex: none; display: flex; }
.nav-label { min-width: 0; }
.chevron-btn {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  color: inherit;
}
.chevron-btn:hover { background: rgba(0, 0, 0, 0.04); }
.chevron {
  width: 7px;
  height: 7px;
  border-right: 1.6px solid #8a8a8a;
  border-bottom: 1.6px solid #8a8a8a;
  transform: rotate(-45deg);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.nav-item.open > .nav-row .chevron { transform: rotate(45deg) translate(-1px, -1px); }
.nav-children {
  display: block;
  margin-left: 14px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.nav-item.open > .nav-children { max-height: 720px; }

.content { padding: 36px 28px 96px; min-width: 0; max-width: 100%; overflow-wrap: break-word; }
.content article {
  max-width: 760px;
  animation: docs-rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.crumb { margin: 0 0 10px; font-size: 13px; }
.crumb a {
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.crumb .nav-icon { width: 14px; height: 14px; }
.content h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 34px;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}
.page-icon { width: 28px; height: 28px; color: var(--icon); display: flex; flex: none; }
.lede { color: var(--muted); font-size: 16px; margin: 0 0 18px; }
.content h2 { margin: 1.6em 0 0.5em; font-size: 26px; letter-spacing: -0.02em; }
.content h3 { margin: 0.2em 0 0.35em; font-size: 18px; }
.content a { color: inherit; text-underline-offset: 2px; }
.content p, .content li { font-size: 16px; }
.content ul { padding-left: 1.2em; }

.table-wrap {
  overflow: auto;
  max-width: 100%;
  margin: 1.1em 0 1.4em;
  border: 1px solid var(--line);
  border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { background: #f3f3f4; font-weight: 600; }
html[data-theme="dark"] th { background: #222; }

.hint {
  display: flex;
  gap: 10px;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 1.2em 0;
}
.hint-icon { width: 18px; height: 18px; flex: none; margin-top: 3px; display: flex; }
.hint-body { min-width: 0; }
.hint p:first-child { margin-top: 0; }
.hint p:last-child { margin-bottom: 0; }
.hint-info { background: #e7f3fc; }
.hint-info .hint-icon { color: var(--info); }
.hint-warning { background: #fff1df; }
.hint-warning .hint-icon { color: var(--warning); }
.hint-danger { background: #ffecec; }
.hint-danger .hint-icon { color: var(--danger); }
.hint-success { background: #e8f8ee; }
.hint-success .hint-icon { color: var(--success); }
html[data-theme="dark"] .hint-info { background: #163044; }
html[data-theme="dark"] .hint-warning { background: #3a2a14; }
html[data-theme="dark"] .hint-danger { background: #3a181b; }
html[data-theme="dark"] .hint-success { background: #12301c; }

.stepper { list-style: none; margin: 1.2em 0; padding: 0; }
.stepper > li {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  margin: 0 0 8px;
  padding-bottom: 10px;
}
.stepper > li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 34px;
  bottom: 0;
  width: 2px;
  background: #f0e0a8;
}
html[data-theme="dark"] .stepper > li:not(:last-child)::before { background: #5a4a16; }
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--icon);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  position: relative;
  z-index: 1;
}
html[data-theme="dark"] .step-num { color: #1a1a1a; background: var(--yellow); }
.step-body h2, .step-body h3 { margin-top: 4px; }
.step-body > :first-child { margin-top: 0; }

.cards table, .cards thead, .cards tbody { display: block; }
.cards thead { display: none; }
.cards tbody {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 1em 0 1.4em;
}
.cards tr {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--paper);
  min-height: 112px;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease, border-color 0.22s ease;
}
.cards tr:hover {
  border-color: #d0d0d0;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}
.cards td { border: 0; padding: 0; }
.cards h3 { margin: 0; font-size: inherit; font-weight: 500; }
.cards td:last-child a {
  position: absolute;
  inset: 0;
  color: transparent;
  text-decoration: none;
}
.card-icon { display: block; width: 22px; height: 22px; margin-bottom: 8px; color: var(--icon); }

.toc { padding: 48px 16px 24px 0; position: sticky; top: var(--header-h); }
.toc:empty { display: none; }
.toc-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { color: var(--muted); text-decoration: none; font-size: 13px; display: block; padding: 4px 0; }
.toc a:hover { color: var(--ink); }

.pager {
  max-width: 760px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 36px;
}
.pager-link {
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  min-height: 72px;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.pager-link:hover {
  border-color: #ccc;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
}
.pager-link > span { display: block; color: var(--muted); font-size: 13px; }
.pager-link strong { display: block; margin-top: 2px; font-size: 15px; }
.pager-link.next { text-align: right; }
.pager-arrow { color: var(--muted); }

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; background: var(--sidebar); padding: 0.1em 0.35em; border-radius: 4px; }
pre { overflow: auto; background: var(--sidebar); padding: 14px; border-radius: 12px; }
pre code { background: transparent; padding: 0; }

.theme-switch {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
}
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.theme-toggle:hover { transform: translateY(-1px); }
.theme-icon { display: grid; place-items: center; }
.theme-icon svg { width: 18px; height: 18px; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: grid; }

.backdrop {
  display: none;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.28s ease;
}
@keyframes docs-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.search-results:not([hidden]) { animation: docs-rise 0.16s ease; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  .cards tbody { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .menu-btn { display: inline-grid; place-items: center; }
  .topbar { gap: 8px; padding: 0 12px; }
  .brand img { height: 28px; }
  .search { position: relative; left: auto; transform: none; width: auto; flex: 1 1 0; }
  .search kbd { display: none; }
  .search input { font-size: 16px; padding-right: 12px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  body.nav-open { overflow: hidden; }
  .sidebar {
    position: fixed;
    z-index: 30;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    margin: 0;
    border-radius: 0;
    max-height: none;
    transform: translateX(-105%);
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  body.nav-open .sidebar { transform: none; }
  .backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 25;
    pointer-events: none;
  }
  body.nav-open .backdrop { opacity: 1; pointer-events: auto; }
  .content { padding: 24px 18px 88px; }
  .content h1 { font-size: 28px; }
  .cards tbody, .pager { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
