/* ==========================================================================
   License Docs — design tokens
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --surface-hover: #eef0f5;
  --border: #e6e8ec;
  --border-strong: #d7dae1;

  --text: #14161f;
  --text-muted: #656b78;
  --text-faint: #9aa0ac;

  --accent: #3457d5;
  --accent-hover: #2c49b8;
  --accent-text: #ffffff;
  --accent-soft: rgba(52, 87, 213, 0.08);
  --accent-soft-strong: rgba(52, 87, 213, 0.16);

  --danger: #c0362c;
  --warn: #9a5b12;
  --warn-bg: #fdf3e2;
  --warn-border: #f0d4a3;

  --code-bg: #f4f5f9;
  --code-text: #383c48;

  --shadow-sm: 0 1px 2px rgba(15, 17, 23, 0.05);
  --shadow-md: 0 2px 10px rgba(15, 17, 23, 0.06), 0 1px 2px rgba(15, 17, 23, 0.04);
  --shadow-lg: 0 20px 48px rgba(15, 17, 23, 0.12);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --topbar-h: 60px;
  --content-max: 760px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #1a1e27;
    --surface-hover: #212632;
    --border: #242a35;
    --border-strong: #333a48;

    --text: #eceef3;
    --text-muted: #9aa1af;
    --text-faint: #6c7280;

    --accent: #7c93f5;
    --accent-hover: #93a6f7;
    --accent-text: #0b0d12;
    --accent-soft: rgba(124, 147, 245, 0.14);
    --accent-soft-strong: rgba(124, 147, 245, 0.24);

    --danger: #f2837a;
    --warn: #e3ac5f;
    --warn-bg: #34290f;
    --warn-border: #4a3a17;

    --code-bg: #171a22;
    --code-text: #d6d9e2;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #1a1e27;
  --surface-hover: #212632;
  --border: #242a35;
  --border-strong: #333a48;

  --text: #eceef3;
  --text-muted: #9aa1af;
  --text-faint: #6c7280;

  --accent: #7c93f5;
  --accent-hover: #93a6f7;
  --accent-text: #0b0d12;
  --accent-soft: rgba(124, 147, 245, 0.14);
  --accent-soft-strong: rgba(124, 147, 245, 0.24);

  --danger: #f2837a;
  --warn: #e3ac5f;
  --warn-bg: #34290f;
  --warn-border: #4a3a17;

  --code-bg: #171a22;
  --code-text: #d6d9e2;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.6);
}

:root[data-theme="light"] {
  color-scheme: light;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

img, svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  font-size: 13px;
  font-weight: 600;
  z-index: 100;
}
.skip-link:focus-visible {
  left: 0;
  outline-offset: -2px;
}

hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar-inner {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin-right: auto;
}
.brand:hover { text-decoration: none; }
.brand-icon { width: 22px; height: 22px; flex-shrink: 0; }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  margin-right: 4px;
}
.nav-toggle:hover { background: var(--surface-hover); }
.nav-toggle svg { width: 18px; height: 18px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.admin-link:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
  text-decoration: none;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.theme-switch button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}
.theme-switch button svg { width: 15px; height: 15px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Page shell: sidenav / content / toc
   ========================================================================== */

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.5);
  z-index: 45;
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 24px 96px;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.sidenav {
  position: sticky;
  top: calc(var(--topbar-h) + 32px);
}
.sidenav-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 10px 12px;
}
.sidenav-list { display: flex; flex-direction: column; gap: 2px; }
.sidenav-list a {
  display: block;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}
.sidenav-list a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.sidenav-list a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.content { min-width: 0; max-width: var(--content-max); }

.toc-rail { display: none; }
.toc-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.toc-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.toc-list a {
  color: var(--text-muted);
  border-left: 2px solid transparent;
  padding-left: 11px;
  line-height: 1.4;
}
.toc-list a.toc-h3 { padding-left: 22px; font-size: 12.5px; }
.toc-list a:hover { color: var(--text); text-decoration: none; }
.toc-list a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

@media (min-width: 1180px) {
  .shell { grid-template-columns: 224px minmax(0, var(--content-max)) 200px; }
  .toc-rail { display: block; position: sticky; top: calc(var(--topbar-h) + 32px); }
}

@media (max-width: 899px) {
  .nav-toggle { display: flex; }
  .shell { grid-template-columns: 1fr; padding: 28px 20px 72px; }
  .sidenav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 46;
    width: min(300px, 84vw);
    padding: 88px 20px 24px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .sidenav.open { transform: translateX(0); }
}

/* ==========================================================================
   Content typography
   ========================================================================== */

h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 12px;
}
h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 52px 0 14px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
h2:first-of-type { border-top: none; padding-top: 0; margin-top: 28px; }
h3 {
  font-size: 16.5px;
  font-weight: 650;
  margin: 28px 0 10px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
p { margin: 0 0 15px; color: var(--text); }
.lede {
  color: var(--text-muted);
  font-size: 17.5px;
  line-height: 1.55;
  margin-bottom: 32px;
  max-width: 62ch;
}
ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin-bottom: 8px; }
li:last-child { margin-bottom: 0; }
strong { font-weight: 650; }

/* ==========================================================================
   Code
   ========================================================================== */

code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.87em;
}

.code-block {
  position: relative;
  margin: 4px 0 22px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0;
  box-shadow: var(--shadow-sm);
}
pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 1em;
}

.copy-btn {
  position: absolute;
  top: 9px;
  right: 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 5px 9px;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.copy-btn svg { width: 13px; height: 13px; }
.code-block:hover .copy-btn,
.copy-btn:focus-visible,
.copy-btn.copied {
  opacity: 1;
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); opacity: 1; }

@media (hover: none) {
  .copy-btn { opacity: 1; }
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-scroll { overflow-x: auto; margin: 4px 0 24px; border-radius: var(--radius); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
}
td code { white-space: nowrap; }

/* ==========================================================================
   Callouts
   ========================================================================== */

.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 22px 0;
  box-shadow: var(--shadow-sm);
}
.callout h3 { margin-top: 0; margin-bottom: 8px; font-size: 15px; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn {
  border-left-color: var(--warn);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}
.callout.warn h3 { color: var(--warn); }

.icon-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ==========================================================================
   Card grid (SDK links)
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text);
  display: block;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.doc-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.doc-card h3 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.doc-card p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   Key box (public key display)
   ========================================================================== */

.key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--code-text);
  word-break: break-all;
  margin: 10px 0 4px;
}
.key-box button {
  flex-shrink: 0;
  font: inherit;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12.5px;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.key-box button:hover { border-color: var(--accent); color: var(--accent); }
.key-box button.copied { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   Numbered step list ("How it works")
   ========================================================================== */

.steps { list-style: none; padding: 0; margin: 0 0 20px; counter-reset: step; }
.steps li {
  position: relative;
  padding-left: 40px;
  margin-bottom: 18px;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 40px 0 12px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--text-muted); }

@media (max-width: 520px) {
  h1 { font-size: 27px; }
  .lede { font-size: 16px; }
  .layout, .shell { padding-left: 16px; padding-right: 16px; }
}
