:root {
  --bg: #f8f7ff;
  --bg-soft: #fafaff;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --purple: #6d4aff;
  --purple-2: #7c3aed;
  --purple-soft: #eee9ff;
  --border: #e5e7eb;
  --success-bg: #ecfdf5;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --header-height: 64px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #ebe4ff 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, #f3e8ff 0%, transparent 50%),
    var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

code,
pre {
  font-family: var(--mono);
}

.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

section[id] {
  scroll-margin-top: calc(var(--header-height) + 24px);
}

/* Header */
.doc-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.doc-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 0.72rem;
  font-family: var(--mono);
}

.doc-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.doc-nav a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}

.doc-nav a:hover {
  color: var(--text);
}

.doc-nav a.is-active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: 0.15s ease;
  cursor: pointer;
  background: transparent;
  color: var(--text);
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(109, 74, 255, 0.28);
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-secondary,
.btn-outline {
  background: #fff;
  border-color: var(--border);
}

.header-cta.header-profile {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
}

.header-profile-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.btn-secondary:hover,
.btn-outline:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0;
}

.nav-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  margin: 4px auto;
  background: var(--text);
}

/* Full-width content; TOC sits in the right margin and does not shrink cards */
.doc-main {
  padding: 36px 0 80px;
}

.doc-shell {
  position: relative;
  width: 100%;
}

.doc-content {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 22px;
}

/* Hero */
.hero {
  min-width: 0;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 28px;
  align-items: center;
}

.hero-text,
.hero-code {
  min-width: 0;
}

.badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 0.75rem;
  font-weight: 700;
}

.hero h1 {
  margin: 14px 0 10px;
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.hero-sub {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-note {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 0.95rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-code,
.code-block {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #ddd6fe;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.hero-code {
  box-shadow: var(--shadow);
}

.code-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #faf8ff, #fff);
}

.code-lang {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.copy-btn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.copy-btn:hover,
.copy-btn.copied {
  color: var(--purple);
  border-color: #c4b5fd;
  background: var(--purple-soft);
}

.hero-code pre,
.code-block pre {
  margin: 0;
  padding: 16px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: pre;
  font-size: 13px;
  line-height: 1.65;
  background: #fbfaff;
}

.hero-code code,
.code-block code {
  font-family: inherit;
}

.tok-kw { color: #7c3aed; }
.tok-str { color: #0f766e; }
.tok-fn { color: #2563eb; }

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  min-width: 0;
  overflow: hidden;
}

.section-card:hover {
  box-shadow: var(--shadow);
}

.section-title {
  margin: 0 0 14px;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.section-lead {
  margin: 0 0 14px;
  color: var(--muted);
}

.subhead {
  margin: 16px 0 8px;
  font-size: 0.9rem;
}

.steps {
  display: grid;
  gap: 16px;
}

.steps-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  padding: 12px;
  min-width: 0;
  overflow: hidden;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.step h3 {
  margin: 0 0 10px;
  font-size: 0.92rem;
}

.code-block .code-card-head {
  padding: 8px 10px;
}

.code-block pre {
  padding: 12px;
  font-size: 12.5px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.is-active {
  background: var(--purple-soft);
  border-color: #c4b5fd;
  color: var(--purple);
}

.tab-panel {
  display: none;
  min-width: 0;
}

.tab-panel.is-active {
  display: block;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  min-width: 0;
}

.two-col > * {
  min-width: 0;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

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

th {
  background: #faf8ff;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

.method {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--success-bg);
  color: #047857;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.method.post {
  background: var(--purple-soft);
  color: var(--purple);
}

.mono-cell {
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-word;
}

.note-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.note-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--bg-soft);
  min-width: 0;
}

.note-card h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
}

.note-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.cta-card {
  text-align: center;
  padding: 28px 22px;
  background:
    radial-gradient(circle at 20% 0%, #eee9ff, transparent 45%),
    radial-gradient(circle at 80% 100%, #f3e8ff, transparent 40%),
    #fff;
}

.cta-card h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.cta-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

@media (max-width: 1000px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .hero-layout,
  .steps-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .doc-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 16px;
    right: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow);
  }

  .doc-nav.open {
    display: flex;
  }

  .doc-nav a {
    padding: 10px 12px;
    border-bottom: none;
  }

  .doc-nav a.is-active {
    background: var(--purple-soft);
    border-radius: 8px;
  }

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

  .header-cta {
    display: none;
  }

  .header-cta.header-profile {
    display: inline-flex;
  }

  .doc-header-inner {
    position: relative;
  }
}
