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

:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --bg-3: #1a1a1a;
  --border: #222222;
  --border-2: #2a2a2a;
  --text: #ededed;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --code-bg: #111111;
  --radius: 8px;
  --font: "Inter", system-ui, sans-serif;
  --mono: "Geist Mono", "Fira Code", monospace;
  --nav-h: 56px;
  --mobile-api-nav-h: 52px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 780px; }

/* ── Nav ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  font-size: 13px;
  color: var(--text-2);
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover { color: var(--text); background: var(--bg-3); }

/* GitHub nav link with icon */
.nav-link-icon {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2) !important;
  padding: 6px 10px !important;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link-icon svg {
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s;
}

.nav-link-icon:hover { color: var(--text) !important; background: var(--bg-3); }
.nav-link-icon:hover svg { opacity: 1; }

/* npm button */
.btn-nav {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  background: var(--accent) !important;
  color: #fff !important;
  padding: 6px 14px !important;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-nav svg { flex-shrink: 0; opacity: 0.9; }
.btn-nav:hover { background: var(--accent-hover) !important; }

/* hamburger */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  cursor: pointer;
}

.nav-hamburger span {
  display: block;
  height: 1.5px;
  background: var(--text-2);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* mobile menu */
.nav-mobile-menu {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--border);
  padding: 8px 16px 16px;
}

.nav-mobile-menu.open { display: flex; }

.nav-mobile-menu a {
  font-size: 14px;
  color: var(--text-2);
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s;
}

.nav-mobile-menu a:last-child { border-bottom: none; }
.nav-mobile-menu a:hover { color: var(--text); }

/* mobile icon links (GitHub / npm in mobile menu) */
.mobile-icon-link {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.mobile-icon-link svg { flex-shrink: 0; opacity: 0.7; }
.mobile-icon-link:hover svg { opacity: 1; }

/* ── Hero ── */
.hero {
  padding: 100px 0 80px;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--text);
  margin-bottom: 20px;
}

.hero-sub {
  font-size: 17px;
  color: var(--text-2);
  line-height: 1.65;
  max-width: 520px;
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 52px;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: var(--bg-3);
  color: var(--text-2);
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-2);
  transition: color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--text); }

/* ── Hero Code ── */
.hero-code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 620px;
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-2);
}

.code-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  margin-left: 6px;
}

/* ── Features ── */
.features {
  padding: 72px 0;
  border-bottom: 1px solid var(--border);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.feature {
  background: var(--bg);
  padding: 28px 28px 32px;
  transition: background 0.15s;
}
.feature:hover { background: var(--bg-2); }

/* base feature icon */
.feature-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  margin-bottom: 16px;
  flex-shrink: 0;
}

/* brand logo variant — transparent bg, no extra padding */
.feature-icon--brand {
  background: transparent;
  border-color: var(--border);
  padding: 6px;
  overflow: hidden;
}

.feature-icon--brand img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  /* keep crisp on all screens */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.feature h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.feature p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
}

/* ── Sections ── */
.section {
  padding: 80px 0;
  border-bottom: 1px solid var(--border);
}

.section h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 8px;
}

.section-sub {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 36px;
}

/* ── Code Blocks ── */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.code-block pre {
  padding: 20px 24px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  -webkit-overflow-scrolling: touch;
}

.code-block.compact pre { padding: 14px 18px; }
.code-block.terminal { background: #0d0d0d; }

/* Syntax colors */
.kw  { color: #c792ea; }
.fn  { color: #82aaff; }
.cls { color: #ffcb6b; }
.str { color: #c3e88d; }
.tpl { color: #89ddff; }
.com { color: #546e7a; font-style: italic; }
.num { color: #f78c6c; }

/* ── Tabs ── */
.tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
  margin-bottom: 16px;
}

.tab {
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-3);
  padding: 8px 18px;
  font-size: 13px;
  font-family: var(--mono);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.tab:last-child { border-right: none; }
.tab:hover { color: var(--text-2); background: var(--bg-2); }
.tab.active { color: var(--text); background: var(--bg-2); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Copy button ── */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--mono);
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.copy-btn:hover { color: var(--text); background: var(--bg-2); }
.copy-btn.copied { color: #c3e88d; }

/* ── Example group ── */
.example-label {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

/* ── API ── */
.api-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 40px;
  align-items: start;
}

.api-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
}

.api-nav-group { margin-bottom: 24px; }

.api-nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 6px;
  padding-left: 8px;
}

.api-nav-link {
  display: block;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-3);
  padding: 5px 8px;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}
.api-nav-link:hover { color: var(--text-2); background: var(--bg-2); }
.api-nav-link.active { color: var(--text); background: var(--bg-2); }

.api-content { min-width: 0; }

.api-entry {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}
.api-entry:last-child { border-bottom: none; }

.api-sig {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.6;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.sig-kw  { color: #c792ea; }
.sig-new { color: #c792ea; }
.sig-fn  { color: #82aaff; }
.sig-cls { color: #ffcb6b; }
.sig-param { color: #a1a1aa; }
.sig-ret { color: #c3e88d; }

.api-entry p {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 14px;
  line-height: 1.65;
}

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

.api-entry code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.params-table.full-width { margin-top: 0; }

.params-table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  white-space: nowrap;
}

.params-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
  line-height: 1.6;
}

.params-table td:first-child { white-space: nowrap; }

.params-table td code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
}

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

.params-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Helpers grid ── */
.helpers-grid {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.helper-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: start;
}

.helper-row:last-child { border-bottom: none; }

.helper-row.header {
  background: var(--bg-2);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.helper-row code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.helper-row span { color: var(--text-2); padding-top: 1px; }

/* ── Footer ── */
footer { padding: 32px 0; }

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-name {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-3);
}

.footer-license {
  font-size: 12px;
  color: var(--text-3);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }


/* ═══════════════════════════════════════════════
   RESPONSIVE — TABLET  ≤ 900px
   ═══════════════════════════════════════════════ */

@media (max-width: 900px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .api-grid { grid-template-columns: 180px 1fr; gap: 28px; }
}


/* ═══════════════════════════════════════════════
   RESPONSIVE — MOBILE  ≤ 640px
   ═══════════════════════════════════════════════ */

@media (max-width: 640px) {

  /* ── Nav ── */
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }

  /* ── Hero ── */
  .hero { padding: 48px 0 40px; }
  .hero-sub { font-size: 15px; }
  .hero-actions { margin-bottom: 32px; gap: 10px; }
  .hide-mobile { display: none; }

  .hero-code { max-width: 100%; }
  .hero-code pre {
    font-size: 13px;
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Features ── */
  .features { padding: 48px 0; }
  .features-grid { grid-template-columns: 1fr; }

  /* ── Sections ── */
  .section { padding: 48px 0; }
  .section h2 { font-size: 22px; }

  /* ── Tabs: stretch full width ── */
  .tabs { width: 100%; }
  .tab { flex: 1; text-align: center; padding: 8px 6px; }

  /* ── Code blocks ── */
  .code-block pre {
    font-size: 13px;
    padding: 16px;
  }
  .code-block.compact pre { padding: 12px 14px; }

  .copy-btn { font-size: 10px; padding: 3px 8px; top: 8px; right: 8px; }

  /* ── API Section ── */
  .api-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .api-sidebar { display: none; }

  /* Mobile API bottom navigation bar */
  .mobile-api-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(10,10,10,0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    height: var(--mobile-api-nav-h);
  }

  .mobile-api-nav-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-2);
    padding: 0 8px;
    text-align: center;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-api-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
  }
  .mobile-api-nav-btn:hover { color: var(--text); background: var(--bg-3); }
  .mobile-api-nav-btn:disabled { opacity: 0.25; pointer-events: none; }

  .mobile-api-nav-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 100%;
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text-3);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
  }
  .mobile-api-nav-menu-btn:hover { color: var(--text); background: var(--bg-3); }

  .mobile-api-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    padding: 0 0 env(safe-area-inset-bottom, 0);
    max-height: 72vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    -webkit-overflow-scrolling: touch;
  }

  .mobile-api-drawer.open { transform: translateY(0); }

  .mobile-api-drawer-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 8px;
  }

  .mobile-api-drawer-handle::after {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-2);
    border-radius: 2px;
  }

  .mobile-api-drawer-group { padding: 4px 0 12px; }

  .mobile-api-drawer-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    padding: 10px 20px 6px;
  }

  .mobile-api-drawer a {
    display: block;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-2);
    padding: 11px 20px;
    transition: background 0.12s, color 0.12s;
  }

  .mobile-api-drawer a:hover,
  .mobile-api-drawer a.active { background: var(--bg-3); color: var(--text); }

  .mobile-api-backdrop {
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(0,0,0,0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .mobile-api-backdrop.open { opacity: 1; pointer-events: auto; }

  #api .api-content { padding-bottom: calc(var(--mobile-api-nav-h) + 24px); }

  .api-sig {
    white-space: normal;
    word-break: break-word;
    font-size: 12px;
  }

  /* ── Tables ── */
  .table-scroll {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 8px;
  }

  .table-scroll::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, rgba(10,10,10,0.85));
    pointer-events: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: opacity 0.2s;
  }

  .table-scroll.at-end::after { opacity: 0; }

  .table-scroll-inner {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll .params-table {
    border: none;
    border-radius: 0;
    min-width: 420px;
    margin-top: 0;
  }

  /* ── Helpers grid: stack cleanly ── */
  .helpers-grid { overflow-x: visible; }

  .helper-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 16px;
  }

  .helper-row.header { display: none; }

  .helper-row code {
    font-size: 12px;
    color: var(--accent);
  }

  .helper-row span {
    font-size: 12px;
    color: var(--text-3);
    padding-top: 0;
    padding-left: 2px;
  }

  .helper-row + .helper-row { border-top: 1px solid var(--border); }

  /* ── Footer ── */
  footer { padding-bottom: calc(var(--mobile-api-nav-h) + 16px); }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}

/* ── Safe area for notched phones ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 640px) {
    .mobile-api-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(var(--mobile-api-nav-h) + env(safe-area-inset-bottom));
    }
  }
}
