:root {
  --bg: #0b0e14;
  --bg-elevated: #12161f;
  --border: #232838;
  --text: #e8eaf0;
  --text-muted: #9aa1b2;
  --accent: #7c6ff0;
  --accent-strong: #9686ff;
  --accent-amber: #f5b759;
  --danger: #f2716b;
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

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

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

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

/* Nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 16px 0;
}
.nav__brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav__brand:hover {
  text-decoration: none;
}
.nav__links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  font-size: 0.95rem;
}
/* Below ~390px the full link set (guides, playground, pricing, faq, locale,
   currency, auth actions) no longer fits one row even wrapped loosely —
   tighten spacing and type size rather than build a separate mobile-menu
   component for what's still just a CSS-level fix. */
@media (max-width: 480px) {
  .nav {
    padding: 14px 0;
  }
  .nav__links {
    gap: 8px 14px;
    font-size: 0.85rem;
  }
}
.nav__links a {
  color: var(--text-muted);
}
.nav__links a:hover {
  color: var(--text);
}
.nav__locale,
.nav__currency {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.nav__locale a,
.nav__currency a {
  color: var(--text-muted);
}
.nav__locale a.is-active,
.nav__currency a.is-active {
  color: var(--text);
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-decoration: none;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 rgba(124, 111, 240, 0);
}
.btn--primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 8px 24px rgba(124, 111, 240, 0.35);
}
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover {
  border-color: var(--accent-strong);
}
.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
  padding: 8px 14px;
  font-size: 0.85rem;
}
.btn--danger:hover {
  border-color: var(--danger);
}
.btn--block {
  width: 100%;
}

/* Hero */
.hero {
  position: relative;
  padding: 96px 0 72px;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  top: -200px;
  left: 50%;
  width: 900px;
  height: 500px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(124, 111, 240, 0.35), transparent);
  animation: pulse-glow 6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.hero__grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
  align-items: center;
}
@media (min-width: 900px) {
  .hero__grid {
    grid-template-columns: 1.1fr 1fr;
  }
}
.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-amber);
  margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  line-height: 1.1;
  margin: 0 0 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero p.lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 46ch;
  margin: 0 0 32px;
}
.hero__ctas {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* Code window */
.code-window {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.code-window__bar {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}
.code-window__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--border);
}
.code-window pre {
  margin: 0;
  padding: 20px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #b9c0d4;
  overflow-x: auto;
}
.code-window .tok-key { color: #9686ff; }
.code-window .tok-str { color: #7ee7b8; }
.playground-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
}
@media (min-width: 900px) {
  .playground-grid {
    grid-template-columns: 1fr 1.2fr;
  }
}
.playground-grid .code-window pre {
  max-height: 520px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.code-window .tok-num { color: #f5b759; }

/* Sections */
section {
  padding: 64px 0;
}
.section-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  text-align: center;
}
.section-lead {
  text-align: center;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0 auto 48px;
}

/* Reveal animation */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 111, 240, 0.5);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.card__icon {
  font-size: 1.6rem;
  margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Pricing */
.pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  align-items: stretch;
}
.plan {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.plan:hover {
  transform: translateY(-3px);
}
.plan--featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 20px 50px rgba(124, 111, 240, 0.25);
}
.plan__badge {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.plan__name {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
}
.plan__price {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 8px 0 4px;
}
.plan__price span {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}
.plan__limit {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.plan .btn {
  margin-top: auto;
}

/* FAQ */
.faq {
  max-width: 760px;
  margin: 0 auto;
}
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 22px 0;
}
.faq-item h3 {
  margin: 0 0 8px;
  font-size: 1.02rem;
}
.faq-item p {
  margin: 0;
  color: var(--text-muted);
}

/* CTA banner */
.cta-banner {
  text-align: center;
  background: linear-gradient(135deg, rgba(124, 111, 240, 0.18), rgba(245, 183, 89, 0.12));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 56px 32px;
}
.cta-banner h2 {
  margin: 0 0 12px;
  font-size: 1.8rem;
}
.cta-banner p {
  color: var(--text-muted);
  margin: 0 0 28px;
}

footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer__grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
}
.footer__links a {
  color: var(--text-muted);
}
.footer__links a:hover {
  color: var(--text);
}
.footer__copy {
  color: var(--text-muted);
}

/* Auth forms */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
}
.auth-card h1 {
  font-size: 1.4rem;
  margin: 0 0 6px;
}
.auth-card p.sub {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 0.92rem;
}
.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
}
.field textarea {
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-strong);
}
.field--checkbox label {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.field--checkbox input[type="checkbox"] {
  width: auto;
  margin-top: 3px;
  flex-shrink: 0;
}
.field--checkbox a {
  color: var(--accent-strong);
}
.form-error {
  background: rgba(242, 113, 107, 0.12);
  border: 1px solid rgba(242, 113, 107, 0.4);
  color: #ffb3ae;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.form-success {
  background: rgba(126, 231, 184, 0.12);
  border: 1px solid rgba(126, 231, 184, 0.4);
  color: #7ee7b8;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.auth-card .switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Dashboard */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}
.dash-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
}
.dash-header p {
  margin: 0;
  color: var(--text-muted);
}

.upsell-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 28px;
  margin-bottom: 28px;
}
.upsell-card__copy h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.upsell-card__copy p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.upsell-card__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Usage summary + chart */
.usage-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
}
@media (min-width: 800px) {
  .usage-summary {
    grid-template-columns: 220px 1fr;
  }
}
.usage-summary__total {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.usage-summary__label {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.usage-summary__value {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text);
}
.usage-summary__limit {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-muted);
}
.usage-summary__note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}
.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 130px;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 12px 12px 0;
}
.usage-chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.usage-chart__bar-track {
  flex: 1;
  width: 100%;
  max-width: 40px;
  display: flex;
  align-items: flex-end;
}
.usage-chart__bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
  min-height: 2px;
}
.usage-chart__value {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.usage-chart__label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.table-scroll {
  overflow-x: auto;
}
.key-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.key-table th, .key-table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.key-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.key-table tr:last-child td {
  border-bottom: none;
}
.usage-bar {
  width: 120px;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.usage-bar--account {
  width: 100%;
  max-width: 220px;
  height: 8px;
  margin: 10px 0 8px;
}
.usage-bar__fill {
  height: 100%;
  background: var(--accent);
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge--active {
  background: rgba(126, 231, 184, 0.15);
  color: #7ee7b8;
}
.badge--inactive {
  background: rgba(154, 161, 178, 0.15);
  color: var(--text-muted);
}
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Modal for new key */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-overlay.is-open {
  display: flex;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.modal h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}
.modal p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.key-reveal {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.key-reveal code {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
}
.modal .actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* Rendered markdown documentation pages (docsPages.ts) */
.docs-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 48px;
  align-items: start;
}
.docs-nav {
  position: sticky;
  top: 24px;
  font-size: 0.9rem;
}
.docs-nav h4 {
  margin: 20px 0 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.docs-nav h4:first-child {
  margin-top: 0;
}
.docs-nav ul {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
}
.docs-nav a {
  display: block;
  padding: 4px 0;
  color: var(--text-muted);
}
.docs-nav a:hover,
.docs-nav a.is-active {
  color: var(--accent-strong);
  text-decoration: none;
}
.docs-content h1 {
  font-size: 1.9rem;
  margin: 0 0 16px;
}
.docs-content h2 {
  font-size: 1.4rem;
  margin: 40px 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.docs-content h3 {
  font-size: 1.1rem;
  margin: 28px 0 10px;
}
.docs-content p,
.docs-content li {
  color: var(--text);
}
.docs-content ul,
.docs-content ol {
  padding-left: 22px;
}
.docs-content code {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 0.88em;
}
.docs-content pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
}
.docs-content pre code {
  background: none;
  border: none;
  padding: 0;
}
.docs-content blockquote {
  margin: 16px 0;
  padding: 4px 16px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}
.docs-content th,
.docs-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.docs-content th {
  background: var(--bg-elevated);
}
@media (max-width: 800px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-nav {
    position: static;
  }
}
