:root {
  --primary: #1a56db;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --border: #334155;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.55);
  --radius: 14px;
}

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

html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.08), transparent 45%), var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

a:hover {
  color: #7dd3fc;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
  overflow: hidden;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

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

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  min-height: 44px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(26, 86, 219, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: #1d4ed8;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

/* ── Navigation ── */

nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}

.nav-inner > div:first-child a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 0;
}

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

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
}

/* ── Footer ── */

footer {
  margin-top: 80px;
  padding: 48px 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Code blocks ── */

code,
pre {
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

pre {
  background: #0b1220;
  border: 1px solid var(--border);
  padding: 18px;
  border-radius: 12px;
  overflow-x: auto;
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  -webkit-overflow-scrolling: touch;
}

code {
  background: rgba(148, 163, 184, 0.2);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ── Forms ── */

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
}

input::placeholder {
  color: var(--text-muted);
}

.api-key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #0b1220;
  border: 1px dashed var(--accent);
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

details {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}

details + details {
  margin-top: 12px;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

.tool-list code {
  word-break: break-all;
}

.sidebar {
  position: sticky;
  top: 90px;
  align-self: start;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  background: var(--bg-card);
}

/* ── Responsive: tablet ── */

@media (max-width: 768px) {
  :root {
    --text-muted: #b8c9db;
  }

  body {
    font-size: 16px;
    line-height: 1.6;
  }

  .grid-3 {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Hamburger nav */
  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 4px;
    padding-top: 12px;
  }

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

  .nav-links a,
  .nav-links .btn-primary {
    width: 100%;
    text-align: center;
    padding: 10px 16px;
    min-height: 44px;
    border-radius: 10px;
  }

  .nav-links .btn-primary {
    margin-top: 4px;
  }

  .nav-inner {
    flex-wrap: wrap;
  }

  .sidebar {
    position: static;
    display: none;
  }

  /* Section spacing — breathing room between sections */
  .section {
    padding: 32px 0;
  }

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

  /* Footer */
  footer {
    margin-top: 48px;
    padding: 32px 0;
  }

  footer .container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
  }

  footer .nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 12px;
  }

  footer .nav-links a {
    width: auto;
    min-height: 44px;
    line-height: 44px;
    padding: 0 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
  }

  /* Code blocks on mobile */
  pre {
    font-size: 13px;
    padding: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  pre code {
    font-size: 13px;
  }

  .card pre {
    margin: 8px -8px 0;
  }

  /* Cards */
  .card {
    padding: 20px;
  }

  .card h3 {
    font-size: 1.05rem;
    margin: 0 0 8px;
  }

  .card p {
    font-size: 16px;
    margin: 0;
    line-height: 1.6;
  }

  /* Section titles */
  .section-title {
    margin-bottom: 16px;
  }

  .section-title h2 {
    font-size: 1.4rem;
  }

  /* Badge */
  .badge {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* Tool list */
  .tool-list li {
    padding: 12px 14px;
  }

  .tool-list code {
    font-size: 13px;
    margin-bottom: 4px;
  }

  .tool-list li {
    font-size: 16px;
    line-height: 1.6;
  }

  /* Tool category groups */
  .tool-category {
    margin-bottom: 12px;
  }

  .tool-category summary {
    font-size: 16px;
    padding: 12px 14px;
    color: var(--accent);
  }

  .tool-category .tool-list {
    margin-top: 8px;
    border: none;
    gap: 8px;
  }

  .tool-category .tool-list li {
    border: 1px solid rgba(51, 65, 85, 0.6);
  }

  /* Docs page tables — scrollable */
  .tool-card table {
    font-size: 13px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tool-card th,
  .tool-card td {
    padding: 6px 4px;
    white-space: nowrap;
  }

  .tool-card td:last-child {
    white-space: normal;
  }

  .tool-card h4 {
    font-size: 1rem;
  }

  .tool-card p {
    font-size: 16px;
    line-height: 1.6;
  }

  /* Callout blocks */
  .callout {
    font-size: 16px;
    padding: 14px;
  }

  .callout p {
    margin: 0;
    line-height: 1.6;
  }

  /* Mobile TOC */
  .mobile-toc {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
  }

  .mobile-toc summary {
    padding: 14px 16px;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-toc summary::-webkit-details-marker {
    display: none;
  }

  .mobile-toc summary::after {
    content: "▸";
    color: var(--text-muted);
    transition: transform 200ms;
  }

  .mobile-toc[open] summary::after {
    transform: rotate(90deg);
  }

  .mobile-toc nav {
    padding: 0 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-toc nav a {
    font-size: 15px;
  }
}

/* ── Back to top button ── */

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  z-index: 100;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: opacity 200ms, transform 200ms;
}

.back-to-top.visible {
  display: flex;
}

.back-to-top:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

/* ── Mobile table wrapper ── */

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

/* ── Responsive: small mobile ── */

@media (max-width: 600px) {
  .container {
    padding: 0 16px;
  }

  pre {
    font-size: 13px;
    padding: 12px;
    border-radius: 10px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: break-word;
  }

  pre code {
    font-size: 13px;
    word-break: break-all;
    overflow-wrap: break-word;
  }
}
