/* ── Pico CSS overrides + Web app custom styles ──────────────────────────── */

:root {
  --pico-primary: #1e293b;
  --pico-primary-hover: #0f172a;
  --pico-primary-focus: rgba(30, 41, 59, 0.25);
  --pico-primary-inverse: #ffffff;
  --pico-font-size: 15px;
}

/* ── Site layout ─────────────────────────────────────────────────────────── */
body { display: flex; flex-direction: column; min-height: 100vh; margin: 0; padding: 0; }
body > .site-header { flex-shrink: 0; }
body > .site-main { flex: 1; }
body > .site-footer { flex-shrink: 0; }

/* ── Sticky header ───────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--pico-muted-border-color);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.site-header nav {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  gap: 1rem;
}
.nav-logo {
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
  color: var(--pico-color);
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-links a {
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--pico-muted-color);
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: var(--pico-secondary-background); color: var(--pico-color); }
.nav-links a.active {
  background: var(--pico-secondary-background);
  color: var(--pico-color);
  font-weight: 500;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-actions a, .nav-actions button {
  font-size: 0.875rem;
  white-space: nowrap;
}
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--pico-muted-color);
  width: auto;
  min-width: auto;
}
.nav-hamburger:hover { color: var(--pico-color); }

/* Mobile menu */
.mobile-menu {
  border-top: 1px solid var(--pico-muted-border-color);
  padding: 1rem 1.5rem;
}
.mobile-menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--pico-muted-color);
  margin-bottom: 0.125rem;
}
.mobile-menu a:hover { background: var(--pico-secondary-background); color: var(--pico-color); }
.mobile-menu hr { margin: 0.5rem 0; border-color: var(--pico-muted-border-color); }
.mobile-menu .mobile-user-info { font-size: 0.8125rem; color: var(--pico-muted-color); padding: 0.5rem 0.75rem; }

@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-desktop { display: none; }
  .nav-hamburger { display: flex; }
}
@media (min-width: 769px) {
  .mobile-menu { display: none !important; }
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--pico-muted-border-color);
  padding: 2rem 1.5rem;
}
.footer-inner {
  max-width: 80rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.footer-links a {
  color: var(--pico-muted-color);
  text-decoration: none;
  font-size: 0.875rem;
}
.footer-links a:hover { color: var(--pico-color); }
.footer-copyright { font-size: 0.875rem; color: var(--pico-muted-color); }

/* ── Content wrapper ─────────────────────────────────────────────────────── */
.page-container { max-width: 80rem; margin: 0 auto; padding: 2rem 1.5rem; }
.page-container-sm { max-width: 48rem; margin: 0 auto; padding: 2rem 1.5rem; }
.page-container-xs { max-width: 30rem; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  max-width: 20rem;
  pointer-events: none;
}
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-warning { background: #d97706; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal-overlay > article {
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
  margin: 0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.modal-header h2 { margin: 0; font-size: 1.125rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--pico-muted-color);
  padding: 0;
  line-height: 1;
  width: auto;
  min-width: auto;
}
.modal-close:hover { color: var(--pico-color); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-green   { background: #dcfce7; color: #166534; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-yellow  { background: #fef3c7; color: #92400e; }
.badge-emerald { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

[data-theme="dark"] .badge-green   { background: rgba(22,163,74,0.2);  color: #86efac; }
[data-theme="dark"] .badge-red     { background: rgba(220,38,38,0.2);  color: #fca5a5; }
[data-theme="dark"] .badge-yellow  { background: rgba(234,179,8,0.2);  color: #fde047; }
[data-theme="dark"] .badge-emerald { background: rgba(5,150,105,0.2);  color: #6ee7b7; border-color: rgba(5,150,105,0.3); }

/* ── Hero section ────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 5rem 1.5rem;
  max-width: 56rem;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1.5rem;
}
.hero p {
  font-size: 1.125rem;
  color: var(--pico-muted-color);
  margin: 0 auto 2.5rem;
  max-width: 38rem;
}
.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.hero-note { font-size: 0.875rem; color: var(--pico-muted-color); }

/* ── Centered section wrapper ────────────────────────────────────────────── */
.section { padding: 4rem 1.5rem; }
.section-inner { max-width: 80rem; margin: 0 auto; }
.section-header { text-align: center; margin-bottom: 3rem; }
.section-header h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 0.75rem; }
.section-header p { color: var(--pico-muted-color); max-width: 36rem; margin: 0 auto; }

/* ── Platform grid ───────────────────────────────────────────────────────── */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1rem;
}
.platform-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
}
.platform-card svg { width: 2rem; height: 2rem; }
.platform-card span { font-size: 0.875rem; font-weight: 500; }

/* ── Steps ───────────────────────────────────────────────────────────────── */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 2rem;
}
.step { text-align: center; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--pico-color);
  color: var(--pico-background-color);
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.step h3 { margin-bottom: 0.5rem; }
.step p { color: var(--pico-muted-color); font-size: 0.9375rem; }

/* ── Pricing grid ────────────────────────────────────────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.5rem;
  max-width: 60rem;
  margin: 0 auto;
}
.pricing-card { position: relative; }
.pricing-badge {
  position: absolute;
  top: -0.75rem;
  left: 1rem;
  padding: 0.125rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.price-value { font-size: 2.25rem; font-weight: 700; }
.price-currency { font-size: 0.875rem; color: var(--pico-muted-color); }
.price-credits { color: var(--pico-muted-color); font-size: 0.9375rem; }
.price-per { font-size: 0.75rem; color: var(--pico-muted-color); }

/* ── Stats cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {}
.stat-label { font-size: 0.875rem; color: var(--pico-muted-color); margin-bottom: 0.5rem; }
.stat-value { font-size: 2.5rem; font-weight: 700; margin: 0; }
.stat-sub { font-size: 0.875rem; color: var(--pico-muted-color); margin-top: 0.5rem; }
.stat-action { font-size: 0.875rem; margin-top: 0.75rem; display: inline-flex; align-items: center; gap: 0.25rem; }

/* ── Quick links grid ────────────────────────────────────────────────────── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.quick-card {
  text-align: center;
  text-decoration: none;
  color: var(--pico-color);
  padding: 1rem;
}
.quick-card svg { width: 1.5rem; height: 1.5rem; color: var(--pico-muted-color); margin: 0 auto; display: block; }
.quick-card p { margin: 0.5rem 0 0; font-size: 0.875rem; font-weight: 500; }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 12rem);
  padding: 3rem 1.5rem;
}
.auth-box { width: 100%; max-width: 28rem; }
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header a { font-size: 1.5rem; font-weight: 700; text-decoration: none; color: var(--pico-color); }
.auth-header h1 { margin: 1rem 0 0.25rem; font-size: 1.25rem; }
.auth-header p { color: var(--pico-muted-color); font-size: 0.9375rem; margin: 0; }
.auth-divider { position: relative; text-align: center; margin: 1.5rem 0; }
.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--pico-muted-border-color);
}
.auth-divider span {
  position: relative;
  background: var(--pico-background-color);
  padding: 0 1rem;
  font-size: 0.75rem;
  color: var(--pico-muted-color);
}
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.9375rem; color: var(--pico-muted-color); }
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 1rem;
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-muted-border-color);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--pico-color);
  background: var(--pico-background-color);
  transition: background 0.15s;
  margin-bottom: 0.75rem;
}
.oauth-btn:hover { background: var(--pico-secondary-background); }
.oauth-btn svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }

/* ── Password strength ───────────────────────────────────────────────────── */
.pw-strength { display: flex; gap: 0.25rem; margin-top: 0.5rem; }
.pw-bar {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: var(--pico-muted-border-color);
  transition: background 0.2s;
}
.pw-bar-1 { background: #ef4444; }
.pw-bar-2 { background: #f59e0b; }
.pw-bar-3 { background: #22c55e; }
.pw-bar-4 { background: #16a34a; }

/* ── Table pages ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 { margin: 0 0 0.25rem; }
.page-header p { margin: 0; color: var(--pico-muted-color); font-size: 0.9375rem; }
.page-header-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

/* ── API key code display ────────────────────────────────────────────────── */
.key-display {
  padding: 1rem;
  background: var(--pico-code-background-color);
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-muted-border-color);
}
.key-display code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  word-break: break-all;
  user-select: all;
}
.key-note { font-size: 0.8125rem; color: var(--pico-muted-color); margin-bottom: 0.5rem; }

/* ── Docs layout ─────────────────────────────────────────────────────────── */
.docs-layout { display: flex; gap: 2rem; align-items: flex-start; }
.docs-sidebar {
  width: 14rem;
  flex-shrink: 0;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
.docs-sidebar a {
  display: block;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--pico-muted-color);
  transition: all 0.15s;
}
.docs-sidebar a:hover { color: var(--pico-color); background: var(--pico-secondary-background); }
.docs-sidebar .sidebar-label {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.docs-content { flex: 1; min-width: 0; }
@media (max-width: 768px) {
  .docs-layout { flex-direction: column; }
  .docs-sidebar { display: none; }
}

/* ── Inline utilities ────────────────────────────────────────────────────── */
.flex           { display: flex; }
.inline-flex    { display: inline-flex; }
.flex-1         { flex: 1; }
.items-center   { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.font-mono    { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.text-muted   { color: var(--pico-muted-color); }
.overflow-x-auto { overflow-x: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 20rem; }
.w-full { width: 100%; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.max-w-lg { max-width: 32rem; }

/* ── Spin animation ──────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

/* ── Screenshot result ───────────────────────────────────────────────────── */
.screenshot-result { text-align: center; padding: 1rem; }
.screenshot-result img { max-width: 100%; max-height: 600px; border-radius: 0.5rem; box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
