/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #0f172a;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: #15803d; text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
}

/* ===== Layout ===== */
.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ===== Top nav ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid #e6e8ee;
  grid-column: 1 / -1;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; color: #0f172a;
}
.topbar .brand-mark {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, #15803d 0%, #14b8a6 100%);
  border-radius: 7px;
  display: inline-grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 12px;
}
.topbar .brand small {
  font-weight: 500; color: #6b7280; margin-left: 6px;
}
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a {
  font-size: 14px; color: #334155; font-weight: 500;
}
.topbar nav a.cta {
  background: #0f172a; color: #fff;
  padding: 7px 14px; border-radius: 8px;
}
.topbar nav a.cta:hover { background: #1e293b; text-decoration: none; }
.lang-switch {
  display: inline-flex; gap: 4px;
  background: #f1f5f9; border-radius: 8px; padding: 3px;
  font-size: 13px;
}
.lang-switch a {
  padding: 5px 10px; border-radius: 6px;
  color: #64748b; font-weight: 600;
}
.lang-switch a.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.lang-switch a:hover { text-decoration: none; }

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 57px;
  align-self: start;
  height: calc(100vh - 57px);
  overflow-y: auto;
  padding: 28px 22px;
  border-right: 1px solid #e6e8ee;
  background: #fafbfc;
}
.sidebar h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  font-weight: 700;
  margin: 22px 0 8px;
}
.sidebar h4:first-child { margin-top: 0; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: block;
  padding: 5px 10px;
  margin: 1px 0;
  font-size: 13.5px;
  color: #475569;
  border-radius: 6px;
  font-weight: 500;
  border-left: 2px solid transparent;
}
.sidebar a:hover {
  color: #0f172a; background: #f1f5f9; text-decoration: none;
}
.sidebar a.active {
  color: #15803d;
  background: #ecfdf5;
  border-left-color: #15803d;
  font-weight: 600;
}

/* ===== Main ===== */
main {
  padding: 48px 56px 80px;
  max-width: 880px;
}
@media (max-width: 900px) {
  main { padding: 32px 22px; }
}

main .lede {
  font-size: 18px;
  color: #475569;
  line-height: 1.6;
  max-width: 660px;
  margin-bottom: 28px;
}

main h1 {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  line-height: 1.1;
}
main h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 56px 0 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}
main h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 28px 0 10px;
}

main p { margin: 0 0 14px; max-width: 720px; }
main ul, main ol { padding-left: 22px; margin: 0 0 16px; max-width: 720px; }
main li { margin: 4px 0; }

/* ===== Inline + block code ===== */
:not(pre) > code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #0f172a;
  border: 1px solid #e2e8f0;
}

pre {
  position: relative;
  margin: 16px 0 22px;
  padding: 16px 18px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}
pre code { color: inherit; background: transparent; padding: 0; }
pre .copy {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(255,255,255,0.08);
  color: #cbd5e1;
  border: none;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
pre .copy:hover { background: rgba(255,255,255,0.16); color: #fff; }
pre .copy.copied { background: #15803d; color: #fff; }

/* simple syntax tokens */
.tok-key { color: #fbbf24; }
.tok-str { color: #86efac; }
.tok-num { color: #f9a8d4; }
.tok-com { color: #64748b; font-style: italic; }

/* ===== Tables ===== */
.tbl-wrap { overflow-x: auto; }
table {
  width: 100%;
  max-width: 720px;
  border-collapse: collapse;
  margin: 12px 0 22px;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e6e8ee;
  vertical-align: top;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 700;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
tr:hover td { background: #fafbfc; }

/* ===== Callouts ===== */
.callout {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 14px 0 18px;
  font-size: 14px;
  max-width: 720px;
  border: 1px solid;
}
.callout .icon {
  flex-shrink: 0;
  font-weight: 700;
  line-height: 1.4;
}
.callout p { margin: 0; }
.callout.note     { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.callout.success  { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.callout.warn     { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.callout.danger   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ===== Step list ===== */
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps li {
  position: relative;
  padding: 0 0 18px 44px;
  counter-increment: step;
  border-left: 2px solid #e2e8f0;
  margin-left: 12px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: -16px; top: -2px;
  width: 28px; height: 28px;
  background: #15803d;
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.steps li:last-child { border-left-color: transparent; }

/* ===== Type badges ===== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.tag.req { background: #fee2e2; color: #991b1b; }
.tag.opt { background: #dbeafe; color: #1e40af; }

/* ===== Footer ===== */
footer {
  margin-top: 80px;
  padding: 24px 0;
  border-top: 1px solid #e6e8ee;
  font-size: 13px;
  color: #6b7280;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  max-width: 720px;
}

/* ===== Anchored sections ===== */
section { scroll-margin-top: 80px; }

/* ===== Mobile TOC (collapsible, replaces sidebar at <=900px) ===== */
.mobile-toc { display: none; }
@media (max-width: 900px) {
  .mobile-toc {
    display: block;
    margin: 0 0 22px;
    border: 1px solid #e6e8ee;
    border-radius: 10px;
    background: #fafbfc;
    overflow: hidden;
  }
  .mobile-toc summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: #0f172a;
    list-style: none;
    user-select: none;
  }
  .mobile-toc summary::-webkit-details-marker { display: none; }
  .mobile-toc summary::after {
    content: '⌄';
    float: right;
    color: #94a3b8;
    transition: transform .15s;
    font-size: 16px;
    line-height: 1;
  }
  .mobile-toc[open] summary::after { transform: rotate(180deg); }
  .mobile-toc nav { padding: 0 14px 14px; }
  .mobile-toc h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 700;
    margin: 14px 0 6px;
  }
  .mobile-toc ul { list-style: none; padding: 0; margin: 0; }
  .mobile-toc a {
    display: block;
    padding: 6px 10px;
    font-size: 13.5px;
    color: #475569;
    border-radius: 6px;
  }
  .mobile-toc a:hover {
    color: #0f172a;
    background: #f1f5f9;
    text-decoration: none;
  }
  .mobile-toc a.active {
    color: #15803d;
    background: #ecfdf5;
    font-weight: 600;
  }
}

/* ===== Mobile typography + topbar tightening ===== */
@media (max-width: 720px) {
  /* Make every long token wrap rather than scroll-and-hide.
     - <pre> blocks: wrap their long curl/JSON lines instead of relying on
       overflow-x: auto (which is invisible on phones with auto-hiding scrollbars
       so users couldn't tell content was clipped).
     - Inline <code> and table cells: break aggressively at any character so
       50-char claves and /v1/... paths don't push the body. */
  html, body { overflow-x: hidden; }
  main { overflow-wrap: anywhere; word-break: break-word; }
  main :not(pre) > code { word-break: break-all; }
  main td, main th {
    overflow-wrap: anywhere;
    word-break: break-all;
  }
  main pre {
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: visible;
  }

  .topbar { padding: 12px 16px; }
  .topbar nav { gap: 10px; flex-shrink: 0; }
  .topbar .brand { font-size: 14px; min-width: 0; }
  .topbar .brand small { display: none; }
  .topbar nav > a:not(.cta) { display: none; }
  .topbar nav .lang-switch { font-size: 12px; padding: 2px; flex-shrink: 0; }
  .topbar nav .lang-switch a { padding: 4px 8px; }
  .topbar nav a.cta { padding: 6px 11px; font-size: 13px; white-space: nowrap; }

  main { padding: 22px 18px 60px; max-width: 100%; }
  main h1 { font-size: 28px; }
  main h2 { font-size: 21px; margin: 36px 0 12px; padding-top: 10px; }
  main h3 { font-size: 16px; margin: 22px 0 8px; }
  main .lede { font-size: 16px; margin-bottom: 22px; }
  main p, main ul, main ol { font-size: 14.5px; max-width: 100%; }

  pre {
    margin: 14px 0 18px;
    padding: 14px;
    border-radius: 8px;
    font-size: 12px;
  }
  table { font-size: 13px; max-width: 100%; }
  th, td { padding: 8px 10px; }
  .callout { font-size: 13px; padding: 10px 14px; max-width: 100%; }

  footer { margin-top: 56px; flex-direction: column; gap: 8px; max-width: 100%; }
}
