:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-card: #161b22;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-dim: #9198a1;
  --prose-text: #c9d1d9;
  --nav-bg: rgba(13, 17, 23, 0.85);
  --accent: #3fb950;
  --accent-soft: rgba(63, 185, 80, 0.12);
  --accent-2: #58a6ff;
  --accent-3: #d2a8ff;
  --accent-4: #ff7ac6;
  --grad: linear-gradient(135deg, #3fb950 0%, #58a6ff 55%, #d2a8ff 100%);
  --code-bg: #010409;
  --radius: 12px;
  --max: 1080px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Light theme — applied when the viewer picks it (data-theme="light" is stamped
   on <html> before paint by a tiny inline script). Code blocks stay dark on
   purpose for contrast. */
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-card: #ffffff;
  --border: #d0d7de;
  --border-soft: #eaeef2;
  --text: #1f2328;
  --text-dim: #59636e;
  --prose-text: #2b3138;
  --nav-bg: rgba(255, 255, 255, 0.85);
  --accent: #1a7f37;
  --accent-soft: rgba(26, 127, 55, 0.1);
  --accent-2: #0969da;
}

* { box-sizing: border-box; }

/* Disable the double-tap-to-zoom gesture (and its 300ms delay) on mobile.
   Pinch-to-zoom still works, so accessibility is preserved. */
html { scroll-behavior: smooth; touch-action: manipulation; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ---------- Header / nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.theme-toggle {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-dim); }
.nav .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; color: var(--text); }
.brand span { color: var(--accent); }
.nav .links { margin-left: auto; display: flex; gap: 22px; align-items: center; }
.nav .links a { color: var(--text-dim); font-size: 0.92rem; font-weight: 500; }
.nav .links a:hover { color: var(--text); text-decoration: none; }
.badge-free {
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid rgba(63,185,80,0.35);
  padding: 3px 10px; border-radius: 999px; font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
}

/* ---------- Logo ---------- */
.brand { display: inline-flex; align-items: center; gap: 9px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--grad);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 900; color: #04160a; box-shadow: 0 2px 10px rgba(63,185,80,0.3);
}

/* ---------- Hero ---------- */
.hero { padding: 84px 0 56px; text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(520px 280px at 22% -10%, rgba(63,185,80,0.20), transparent 70%),
    radial-gradient(520px 280px at 80% 0%, rgba(210,168,255,0.16), transparent 70%),
    radial-gradient(420px 240px at 50% 8%, rgba(88,166,255,0.12), transparent 70%);
  pointer-events: none;
}
.hero > .wrap { position: relative; }
.hero h1 { font-size: clamp(2.5rem, 6.5vw, 4.4rem); margin: 0 0 14px; letter-spacing: -0.045em; line-height: 1.03; }
.hero h1 .free {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.pill-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px; }
.pill { font-size: 0.76rem; font-weight: 600; color: var(--text-dim); border: 1px solid var(--border);
  background: var(--bg-soft); padding: 5px 12px; border-radius: 999px; }
.pill b { color: var(--accent); }
.hero .tag { font-size: 1.2rem; color: var(--text-dim); max-width: 640px; margin: 0 auto 8px; }
.hero .sub { color: var(--text-dim); max-width: 620px; margin: 14px auto 0; }
.hero .cta { margin-top: 34px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 8px; font-weight: 600; font-size: 0.95rem;
  border: 1px solid var(--border); cursor: pointer; transition: all 0.15s ease;
}
.btn.primary { background: var(--accent); color: #04160a; border-color: var(--accent); }
.btn.primary:hover { background: #4ac95d; text-decoration: none; }
.btn.ghost { background: var(--bg-soft); color: var(--text); }
.btn.ghost:hover { border-color: var(--text-dim); text-decoration: none; }

/* ---------- Hero "Try it" / Surprise me ---------- */
.try-hero { max-width: 560px; margin: 30px auto 0; }
.surprise-btn {
  font-size: 1.05rem; font-weight: 800; padding: 14px 30px; border: none; cursor: pointer;
  border-radius: 999px; color: #04160a; background: var(--grad); background-size: 200% 200%;
  box-shadow: 0 6px 22px rgba(63,185,80,0.35); transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: floaty 6s ease-in-out infinite;
}
.surprise-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 30px rgba(88,166,255,0.4); }
.surprise-btn:active { transform: translateY(0) scale(0.99); }
@keyframes floaty { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.surprise-hint { color: var(--text-dim); font-size: 0.82rem; margin: 10px 0 0; }
#surprise-out { margin-top: 18px; min-height: 60px; }
.surprise-loading { color: var(--text-dim); font-size: 0.9rem; }
.surprise-card {
  text-align: left; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  animation: pop 0.25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.surprise-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.surprise-emoji { font-size: 2rem; }
.surprise-api { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.surprise-url { font-family: var(--mono); font-size: 0.76rem; color: var(--accent); }
.surprise-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 4px 0 10px; }
.surprise-json { background: var(--code-bg); border-radius: 10px; padding: 12px 14px; overflow: auto; max-height: 200px; font-family: var(--mono); font-size: 0.78rem; margin: 0 0 12px; }
.surprise-json .k { color: #79c0ff; } .surprise-json .s { color: #a5d6ff; } .surprise-json .n { color: #f2cc60; } .surprise-json .b { color: #ff7b72; }
.surprise-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.surprise-actions .btn { padding: 8px 16px; font-size: 0.88rem; }
@keyframes flashpulse { from { opacity: 0.35; } to { opacity: 1; } }
.surprise-json.flash, .tryit-json.flash { animation: flashpulse 0.28s ease; }

/* ---------- Stats strip ---------- */
.stats { display: flex; justify-content: center; gap: 40px; flex-wrap: wrap; margin-top: 44px; }
.stat .num { font-size: 2.1rem; font-weight: 900; letter-spacing: -0.02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.stat .lbl { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- API search ---------- */
.api-search {
  width: 100%; max-width: 420px; padding: 11px 16px; margin: 0 0 22px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--text); font-size: 0.95rem;
}
.api-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Sections ---------- */
section { padding: 56px 0; }
.section-title { font-size: 1.7rem; letter-spacing: -0.02em; margin: 0 0 6px; }
.section-lead { color: var(--text-dim); margin: 0 0 30px; }

/* ---------- API grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; transition: all 0.15s ease; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; text-align: left;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.card .emoji { font-size: 1.8rem; }
.card h3 { margin: 0; font-size: 1.1rem; color: var(--text); }
.card p { margin: 0; color: var(--text-dim); font-size: 0.88rem; flex: 1; }
.card .count { font-size: 0.78rem; color: var(--accent); font-weight: 600; font-family: var(--mono); }

/* ---------- Explorer ---------- */
.explorer { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.explorer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--code-bg); }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.r { background: #ff5f56; } .dot.y { background: #ffbd2e; } .dot.g { background: #27c93f; }
.explorer-url { font-family: var(--mono); font-size: 0.82rem; color: var(--text-dim); margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explorer-body { display: grid; grid-template-columns: 200px 1fr; min-height: 340px; }
.explorer-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 460px; }
.explorer-list button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text-dim); padding: 9px 14px; cursor: pointer; font-size: 0.88rem;
  border-left: 2px solid transparent; font-family: var(--sans);
}
.explorer-list button:hover { background: var(--bg-card); color: var(--text); }
.explorer-list button.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.explorer-code { margin: 0; padding: 16px; overflow: auto; max-height: 460px; font-family: var(--mono); font-size: 0.82rem; color: var(--text); }
.explorer-code .k { color: #79c0ff; } .explorer-code .s { color: #a5d6ff; }
.explorer-code .n { color: #f2cc60; } .explorer-code .b { color: #ff7b72; }

/* ---------- Code blocks ---------- */
.codeblock { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; overflow-x: auto; font-family: var(--mono); font-size: 0.86rem; line-height: 1.7; }
.codeblock .c { color: var(--text-dim); }
.codeblock .p { color: var(--accent); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Feature list ---------- */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.feature h4 { margin: 0 0 6px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.feature p { margin: 0; color: var(--text-dim); font-size: 0.9rem; }
.feature .ico { color: var(--accent); }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--border-soft); padding: 34px 0; color: var(--text-dim); font-size: 0.88rem; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; align-items: center; }

/* ---------- Docs page ---------- */
.docs-header { padding: 20px 0; border-bottom: 1px solid var(--border-soft); }

/* ---------- Prose / long-form pages ---------- */
.page-hero { padding: 64px 0 24px; }
.page-hero h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.03em; margin: 0 0 10px; }
.page-hero .lede { font-size: 1.15rem; color: var(--text-dim); max-width: 720px; }
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; margin-bottom: 12px; }

.prose { max-width: 760px; margin: 0 auto; padding: 8px 0 40px; font-size: 1.05rem; }
.prose h2 { font-size: 1.6rem; letter-spacing: -0.02em; margin: 44px 0 12px; }
.prose h3 { font-size: 1.2rem; margin: 30px 0 8px; color: var(--text); }
.prose p { margin: 0 0 18px; color: var(--prose-text); }
.prose blockquote {
  margin: 24px 0; padding: 4px 20px; border-left: 3px solid var(--accent);
  color: var(--text); font-style: italic; background: var(--accent-soft); border-radius: 0 8px 8px 0;
}
.prose blockquote cite { display: block; font-style: normal; color: var(--text-dim); font-size: 0.9rem; margin-top: 8px; }
.prose ul { margin: 0 0 18px; padding-left: 22px; color: var(--prose-text); }
.prose li { margin: 6px 0; }
.prose strong { color: var(--text); }
.callout {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin: 28px 0; background: var(--bg-soft);
}
.callout h3 { margin: 0 0 8px; }
.table-scroll { overflow-x: auto; margin: 22px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; min-width: 460px; }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.data-table td { color: var(--prose-text); }
.data-table tr:last-child td { border-bottom: none; }
.data-table td.tot { border-top: 2px solid var(--border); border-bottom: none; color: var(--text); background: var(--bg-soft); }
.data-table code { font-size: 0.85em; }

.two-def { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0; }
.def-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; background: var(--bg-card); }
.def-card .tag { font-family: var(--mono); color: var(--accent); font-size: 0.8rem; }
.def-card h3 { margin: 6px 0 8px; }
.def-card p { margin: 0; color: var(--text-dim); font-size: 0.95rem; }

/* ---------- Articles list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 28px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-dim);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 0.85rem; font-weight: 500;
}
.chip:hover { color: var(--text); border-color: var(--text-dim); }
.chip.active { background: var(--accent); color: #04160a; border-color: var(--accent); }
.search-box {
  width: 100%; padding: 12px 16px; margin-bottom: 20px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); font-size: 1rem;
}
.search-box:focus { outline: none; border-color: var(--accent); }
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.article-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 10px; transition: all 0.15s ease;
}
.article-card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.article-card .meta { display: flex; gap: 10px; align-items: center; font-size: 0.75rem; color: var(--text-dim); }
.article-card .cat { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.article-card h3 { margin: 0; font-size: 1.15rem; color: var(--text); line-height: 1.3; }
.article-card p { margin: 0; color: var(--text-dim); font-size: 0.9rem; flex: 1; }
.article-card .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.article-card .tags span { font-size: 0.72rem; color: var(--text-dim); background: var(--bg); border: 1px solid var(--border-soft); padding: 2px 8px; border-radius: 999px; }
.article-meta-line { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 24px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.back-link { color: var(--text-dim); font-size: 0.9rem; display: inline-block; margin-bottom: 20px; }

/* ---------- Article "Try it" panel ---------- */
.tryit {
  margin: 40px 0 8px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg-soft); overflow: hidden;
}
.tryit-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 4px; flex-wrap: wrap; }
.tryit-badge {
  background: var(--grad); color: #04160a; font-weight: 800; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 12px; border-radius: 999px;
}
.tryit-lead { color: var(--text-dim); font-size: 0.9rem; }
.tryit-bar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; }
.tryit-url { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); }
.tryit-json {
  margin: 0 18px; padding: 14px 16px; background: var(--code-bg); border-radius: 10px;
  overflow: auto; max-height: 260px; font-family: var(--mono); font-size: 0.8rem; color: #e6edf3;
}
.tryit-json .k { color: #79c0ff; } .tryit-json .s { color: #a5d6ff; } .tryit-json .n { color: #f2cc60; } .tryit-json .b { color: #ff7b72; }
.tryit-actions { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 18px 18px; }
.tryit-actions .btn { padding: 8px 15px; font-size: 0.85rem; }

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

@media (max-width: 720px) {
  .explorer-body { grid-template-columns: 1fr; }
  .explorer-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 160px; display: flex; overflow-x: auto; }
  .explorer-list button { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .explorer-list button.active { border-left: none; border-bottom-color: var(--accent); }
  .two-col { grid-template-columns: 1fr; }
  .nav .links a:not(.badge-free) { display: none; }
}
