:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #eef2f7;
  --card: #ffffff;
  --sidebar-width: 320px;
  --site-header-h: 72px;
  --doc-hero-h: 176px;
  --doc-hero-h-compact: 88px;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  font-size: 16px;
}

/* Tutorial hero: single row, title left + search right, sticky */
.doc-hero {
  position: sticky;
  top: var(--site-header-h);
  z-index: 998;
  margin-top: var(--site-header-h);
  overflow: visible;
}

.doc-hero__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: var(--doc-hero-h);
  padding: 24px 32px;
  background: linear-gradient(135deg, #001529 0%, #002766 45%, #003a8c 100%);
  box-shadow: 0 4px 20px rgba(0, 21, 41, 0.15);
  overflow: visible;
  transition: min-height 0.28s ease, padding 0.28s ease, box-shadow 0.28s ease;
}

.doc-hero__content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  max-width: 1200px;
  width: auto;
  margin: 0 auto;
  transition: width 0.28s ease, gap 0.28s ease, justify-content 0.28s ease;
}

.doc-hero__title {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.3;
  white-space: nowrap;
  transition: font-size 0.28s ease;
}

.doc-hero .header-search {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 320px;
}

.header-search input {
  width: 100%;
  padding: 11px 22px;
  border: 1px solid rgba(24, 144, 255, 0.55);
  border-radius: 999px;
  font-size: 15px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.doc-hero.is-stuck .doc-hero__inner {
  min-height: var(--doc-hero-h-compact);
  padding: 12px 24px;
  box-shadow: 0 6px 24px rgba(0, 21, 41, 0.22);
}

.doc-hero.is-stuck .doc-hero__content {
  width: 100%;
  justify-content: space-between;
  gap: 24px;
}

.doc-hero.is-stuck .doc-hero__title {
  font-size: 22px;
}

.header-search input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.header-search input::placeholder {
  color: #94a3b8;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(420px, 55vh);
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 21, 41, 0.14), 0 2px 8px rgba(0, 21, 41, 0.06);
  border: 1px solid #e8e8e8;
  z-index: 1001;
  padding: 6px;
  scrollbar-width: thin;
}

.search-results[hidden] {
  display: none;
}

.search-results__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.search-results__item:hover,
.search-results__item:focus-visible {
  background: #f1f5f9;
  outline: none;
}

.search-results__title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.4;
}

.search-results__snippet {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

.search-results__snippet mark,
.search-results__title mark {
  background: #fef08a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.search-results__empty,
.search-results__more {
  padding: 12px 14px;
  font-size: 14px;
  color: #64748b;
  text-align: center;
}

.search-results__more {
  border-top: 1px solid #e2e8f0;
  margin-top: 4px;
  font-size: 13px;
}

/* Layout */
.doc-layout {
  display: flex;
  gap: 24px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  align-items: flex-start;
}

/* Sidebar card */
.doc-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--site-header-h) + var(--doc-hero-h) + 12px);
  max-height: calc(100vh - var(--site-header-h) - var(--doc-hero-h) - 24px);
  transition: top 0.25s ease, max-height 0.25s ease;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

/* Mobile nav toggle (tutorial catalog) */
.nav-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

.nav-toggle__icon {
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}

.doc-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.doc-nav::-webkit-scrollbar {
  width: 6px;
}

.doc-nav::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.doc-nav ul {
  list-style: none;
}

.nav-group {
  margin-bottom: 4px;
}

.nav-item--flat {
  margin-bottom: 4px;
}

.nav-item--flat > a {
  font-size: 19px;
  font-weight: 700;
  padding: 10px 12px;
  margin: 0 12px;
}

.nav-group__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 0 12px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 19px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-group__title:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.nav-group__label {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.nav-group__chevron {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-top: -3px;
  opacity: 0.55;
  transition: transform 0.2s ease, margin 0.2s ease;
}

.nav-group.is-open .nav-group__chevron {
  transform: rotate(-135deg);
  margin-top: 2px;
}

.nav-group__list {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.28s ease, opacity 0.2s ease;
  opacity: 1;
}

.nav-group:not(.is-open) .nav-group__list {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.doc-nav a {
  display: block;
  padding: 11px 16px;
  margin: 3px 12px;
  color: #1e293b;
  text-decoration: none;
  font-size: 17px;
  font-weight: 500;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}

.doc-nav a:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.doc-nav a.active {
  background: #3b82f6;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.doc-nav a.active:hover {
  background: #60a5fa;
  color: #fff;
}

/* Main content */
.doc-main {
  flex: 1;
  min-width: 0;
}

.doc-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px 40px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.9);
  scroll-margin-top: calc(var(--site-header-h) + var(--doc-hero-h) + 24px);
}

.doc-disabled-notice {
  margin-bottom: 20px;
  padding: 14px 18px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  border-radius: 8px;
  color: #ad6800;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
}

.doc-disabled-content {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.doc-disabled-content::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(148, 163, 184, 0.42);
  pointer-events: none;
}

.doc-disabled-content > * {
  position: relative;
  z-index: 1;
  opacity: 0.55;
  filter: grayscale(0.25);
  pointer-events: none;
  user-select: none;
}

.section-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #e2e8f0;
  color: #0f172a;
}

.section-body h1 {
  font-size: 24px;
  margin: 24px 0 14px;
  color: #0f172a;
}

.section-body h2 {
  font-size: 20px;
  margin: 22px 0 12px;
  color: #1e40af;
}

.section-body h3,
.section-body h4,
.section-body h5,
.section-body h6 {
  font-size: 17px;
  margin: 18px 0 10px;
  color: #334155;
}

.section-body p {
  margin: 12px 0;
  color: #374151;
}

.section-body ul,
.section-body ol {
  margin: 12px 0 12px 28px;
}

.section-body li {
  margin: 8px 0;
}

.section-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 20px 0;
  display: block;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.section-body code,
.doc-code {
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 14px;
}

.section-body pre {
  background: #1e293b;
  color: #f8fafc;
  padding: 18px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 16px 0;
}

.section-body pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.section-body strong {
  color: #0f172a;
}

.section-body blockquote {
  margin: 16px 0;
  padding: 12px 18px;
  border-left: 4px solid var(--primary);
  background: #f8fafc;
  border-radius: 0 10px 10px 0;
}

/* Tables from original docs */
.doc-table-wrap {
  overflow-x: auto;
  margin: 20px 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.doc-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-size: 14px;
}

.doc-table-wrap td,
.doc-table-wrap th {
  border: 1px solid #cbd5e1;
  padding: 10px 12px;
  vertical-align: middle;
  word-break: break-word;
}

/* Back to top */
.back-top {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  z-index: 300;
}

.back-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-top:hover {
  transform: translateY(-2px);
  background: var(--primary-dark);
}

.nav-overlay {
  display: none;
}

#page-3317 .section-title {
  display: none;
}

.feature-list-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

.feature-list-intro + .feature-list-intro {
  margin-top: 20px;
}

/* Paywall modal */
.paywall-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.paywall-modal[hidden] {
  display: none;
}

.paywall-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.paywall-modal__panel {
  position: relative;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 24px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

.paywall-modal__title {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 12px;
  text-align: center;
}

.paywall-modal__hint {
  font-size: 15px;
  line-height: 1.7;
  color: #475569;
  margin-bottom: 20px;
  text-align: center;
}

.paywall-modal__input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.paywall-modal__input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.paywall-modal__input.is-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.paywall-modal__error {
  margin-top: 10px;
  font-size: 14px;
  color: #ef4444;
  text-align: center;
}

.paywall-modal__submit {
  width: 100%;
  margin-top: 18px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: #3b82f6;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.paywall-modal__submit:hover {
  background: #2563eb;
}

body.paywall-open {
  overflow: hidden;
}

#navList > li.nav-item--locked > .nav-group__title,
#navList > li.nav-item--locked.nav-item--flat > a {
  opacity: 0.72;
}

#navList > li.nav-item--locked .nav-group__label::after,
#navList > li.nav-item--locked.nav-item--flat > a::after {
  content: " 🔒";
  font-size: 0.85em;
}

@media (max-width: 960px) {
  .nav-toggle {
    display: inline-flex;
  }

  .doc-hero__inner {
    position: relative;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    gap: 12px;
    min-height: var(--doc-hero-h);
  }

  .nav-toggle {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
  }

  .doc-hero.is-stuck .doc-hero__inner {
    padding: 10px 16px;
  }

  .doc-hero.is-stuck .doc-hero__content {
    justify-content: space-between;
    gap: 12px;
    padding: 0 72px 0 8px;
  }

  .doc-hero.is-stuck .doc-hero__title {
    font-size: 17px;
  }

  .doc-hero__content {
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 16px;
    justify-content: center;
    margin: 0 auto;
    padding: 0 88px 0 16px;
  }

  .doc-hero__title {
    font-size: 17px;
  }

  .doc-hero .header-search {
    flex: 1;
    width: auto;
    min-width: 0;
    max-width: 280px;
  }

  .header-search input {
    padding: 10px 16px;
    font-size: 16px;
  }

  .search-results {
    max-height: min(360px, 50vh);
  }

  .doc-layout {
    flex-direction: column;
    gap: 0;
    padding: 12px 12px calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  body.nav-is-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.nav-is-open {
    overflow: hidden;
  }

  .doc-sidebar {
    position: fixed;
    top: calc(var(--site-header-h) + var(--doc-hero-h));
    left: 0;
    bottom: 0;
    width: min(88vw, 320px);
    max-height: none;
    z-index: 260;
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    border-radius: 0;
  }

  body.nav-is-open .doc-sidebar {
    transform: translateX(0);
  }

  .doc-nav {
    max-height: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item--flat > a {
    font-size: 19px;
    padding: 10px;
    margin: 0 8px;
  }

  .nav-group__title {
    font-size: 19px;
    width: calc(100% - 16px);
    margin: 0 8px;
    padding: 10px;
  }

  .doc-nav a {
    font-size: 17px;
    padding: 10px 14px;
    margin: 2px 8px;
  }

  .doc-section {
    padding: 18px 14px;
    margin-bottom: 16px;
    border-radius: 12px;
    overflow-x: hidden;
  }

  .section-body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .section-body img,
  .feature-list-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
  }

  .section-body p,
  .feature-list-intro {
    max-width: 100%;
    overflow-x: hidden;
  }

  .section-title {
    font-size: 20px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .section-body h1 {
    font-size: 20px;
  }

  .section-body h2 {
    font-size: 18px;
  }

  .section-body ul,
  .section-body ol {
    margin-left: 20px;
  }

  .section-body pre {
    padding: 14px;
    font-size: 13px;
  }

  .back-top {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

@media (max-width: 768px) {
  :root {
    --site-header-h: 64px;
    --doc-hero-h: 144px;
    --doc-hero-h-compact: 72px;
  }
}

@media (max-width: 480px) {
  .doc-hero__inner {
    padding: 10px 12px;
    gap: 8px;
  }

  .doc-hero__content {
    gap: 10px;
  }

  .doc-hero__title {
    font-size: 14px;
  }

  .doc-hero .header-search {
    max-width: 200px;
  }

  .doc-section {
    padding: 16px 12px;
  }

  .section-title {
    font-size: 18px;
  }
}
