:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e6e8ec;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #3e67d7;
  --accent-soft: #edf2ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 2px;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 12px 20px;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font-weight: 600;
  padding: 8px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: block;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.top-link {
  color: #676f7e;
  font-size: 14px;
  text-decoration: none;
}

.top-link:hover {
  color: var(--text);
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  width: 220px;
  border: 1px solid var(--border);
  background: #fbfcff;
  border-radius: 12px;
  padding: 9px 52px 9px 12px;
  font-size: 14px;
}

.search-wrap input:focus {
  outline: none;
  border-color: #adc2ff;
  box-shadow: 0 0 0 3px #adc2ff44;
}

.search-kbd-hints {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}
.search-kbd-hints kbd {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: #f0f2f7;
  border: 1px solid #dde1ea;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.6;
}
.search-wrap input:focus + .search-kbd-hints,
.search-wrap input:not(:placeholder-shown) + .search-kbd-hints {
  display: none;
}

.search-results {
  position: fixed;
  z-index: 200;
  max-height: 58vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 40px #1c22301f;
  padding: 8px;
}

.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
}

.search-result:hover {
  background: var(--accent-soft);
}

.search-page {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 2px;
}

.search-result strong {
  color: var(--text);
  display: block;
  font-size: 14px;
}

.search-snippet {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: min(1600px, 100%);
  margin: 0 auto;
}

.site-body.has-toc {
  grid-template-columns: 260px minmax(0, 1fr) 220px;
}

/* ---- Right-side TOC panel ---- */
.toc-panel {
  position: sticky;
  top: 61px;
  height: calc(100vh - 61px);
  overflow: auto;
  padding: 28px 16px 40px 12px;
  border-left: 1px solid var(--border);
}

.page-toc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.page-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border);
}

.page-toc-list li {
  margin: 0;
}

.toc-link {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.5;
  transition: color 120ms;
}

.toc-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc-link.is-active {
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  margin-left: -2px;
}

.toc-link-h3 {
  padding-left: 24px;
  font-size: 12px;
}

.sidebar {
  position: sticky;
  top: 61px;
  height: calc(100vh - 61px);
  overflow: auto;
  border-right: 1px solid var(--border);
  padding: 18px 14px 32px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  margin-bottom: 18px;
}

.sidebar-section-label {
  margin: 10px 10px 6px;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-list.nested {
  margin-left: 12px;
  border-left: 1px solid #d7dce6;
  padding-left: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  color: #374151;
  text-decoration: none;
  font-size: 14px;
}

.sidebar-link:hover {
  background: #f3f4f6;
  color: var(--text);
}

.sidebar-link.is-active {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  border-radius: 0;
  padding-left: 8px;
}

.content {
  padding: 28px 34px 60px;
}

.doc-content {
  width: min(860px, 100%);
}

.page-cover {
  width: min(860px, 100%);
  margin-bottom: 24px;
}

.page-cover img {
  width: 100%;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.doc-content h1 {
  margin: 0 0 18px;
  font-size: 48px;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.doc-content h2 {
  margin-top: 32px;
  margin-bottom: 12px;
  font-size: 30px;
}

.doc-content h3 {
  margin-top: 26px;
  margin-bottom: 10px;
  font-size: 22px;
}

.doc-content p,
.doc-content li {
  font-size: 16px;
  color: #353d49;
}

.doc-content ul,
.doc-content ol {
  padding-left: 24px;
}

.doc-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* GitBook data-size="line" images: inline icon sized to text height */
.doc-content img[data-size="line"] {
  display: inline;
  height: 1.4em;
  width: auto;
  max-width: none;
  vertical-align: middle;
  border-radius: 3px;
  margin-right: 4px;
}

.doc-content figure {
  margin: 24px 0;
}

.doc-content figcaption {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
}

.doc-content blockquote {
  margin: 16px 0;
  border-left: 3px solid #c6d3f7;
  padding-left: 14px;
  color: #566077;
}

.hint {
  margin: 20px 0;
  padding: 14px 16px 14px 20px;
  border-radius: 8px;
  border: 1px solid #bed3ff;
  border-left: 4px solid #5a8ef5;
  background: #f5f8ff;
}

.hint-warning {
  border-color: #f5d56a;
  border-left-color: #e6a817;
  background: #fffdf0;
}

.hint-danger {
  border-color: #f5b8b8;
  border-left-color: #d94f4f;
  background: #fff5f5;
}

.hint-success {
  border-color: #a8e6c4;
  border-left-color: #27a86a;
  background: #f0fff7;
}

.hint p:first-child {
  margin-top: 0;
}

.hint p:last-child {
  margin-bottom: 0;
}

.embed-block,
.embed-link,
.file-card {
  margin: 20px 0;
}

.embed-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b0d13;
}

.embed-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.embed-caption {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
}

.file-card a {
  display: inline-block;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid #cad5f4;
  border-radius: 10px;
  background: #f8faff;
  padding: 10px 14px;
  font-weight: 600;
}

.file-card a:hover {
  background: #eef3ff;
}

.prev-next {
  width: min(860px, 100%);
  margin-top: 42px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.prev-next-link {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  background: var(--surface);
  transition: border-color 120ms, box-shadow 120ms;
}

.prev-next-link:hover {
  border-color: #adc2ff;
  box-shadow: 0 0 0 3px #adc2ff22;
}

.prev-next-link .nav-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.prev-next-link.next .nav-text {
  text-align: right;
}

.prev-next-link span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.prev-next-link strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.prev-next-empty {
  display: block;
}

@media (max-width: 1150px) {
  .brand-row {
    flex-wrap: wrap;
    row-gap: 12px;
  }

  .menu-toggle {
    display: inline-block;
  }

  .header-right {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
    gap: 12px;
  }

  .search-wrap {
    flex: 1;
  }

  .search-wrap input {
    width: 100%;
  }

  .site-body,
  .site-body.has-toc {
    grid-template-columns: 1fr;
  }

  .toc-panel {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 61px;
    left: 0;
    width: min(84vw, 340px);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    z-index: 25;
    background: var(--surface);
    border-right: 1px solid var(--border);
    height: calc(100vh - 61px);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 20px;
  }

  .doc-content h1 {
    font-size: 36px;
  }
}

/* External link icon */
.ext-icon {
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
  stroke-linecap: round;
}

/* Sidebar collapse */
.sidebar-link .chevron {
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.55;
  transition: transform 200ms ease;
}

.sidebar-item.is-open > .sidebar-link > .chevron {
  transform: rotate(90deg);
  opacity: 0.9;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.bc-seg + .bc-seg::before {
  content: "›";
  margin: 0 6px;
  font-weight: 400;
  opacity: 0.5;
  color: var(--accent);
}

/* Page header row + Copy button */
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: min(860px, 100%);
  margin-bottom: 14px;
}
.page-header-row .breadcrumb { margin-bottom: 0; flex: 1; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, color 120ms;
}
.copy-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: #adc2ff; }
.copy-btn.is-copied { color: #27a86a; border-color: #a8e6c4; background: #f0fff7; }


/* Prev/Next arrows + Last updated */
.prev-next-link .nav-arrow { display: block; font-size: 16px; color: var(--muted); }
.last-updated { font-size: 13px; color: var(--muted); margin-top: 16px; }
