:root {
  --ink: #1a1a17;
  --muted: #63635c;
  --soft: #f6f5f2;
  --line: #e6e4de;
  --paper: #fff;
  --danger: #b42318;
  --focus: #0068d6;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --success: #1d6a31;
  --success-bg: #e9f5ec;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px -8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.04), 0 20px 40px -12px rgba(0,0,0,0.12);
}

[data-theme="dark"] {
  --ink: #e8e8e0;
  --muted: #9a9a8e;
  --soft: #1c1c19;
  --line: #2a2a25;
  --paper: #131311;
  --accent: #818cf8;
  --accent-dark: #6366f1;
  --success-bg: #142920;
  --warn-bg: #2a2410;
}

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body { line-height: 1.6; min-height: 100vh; }

a { color: inherit; text-underline-offset: 4px; }

/* ─── Layout ─── */
header, footer, main, .container {
  width: min(1180px, 100% - 40px);
  margin: 0 auto;
}

header {
  border-bottom: 1px solid var(--line);
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 100;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* "Aegon" — italic + gradient, the star of the brand */
.brand-aegon {
  font-style: italic;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  display: inline-block;
  transform: skewX(-7deg);
  text-shadow: 0 1px 0 rgba(99,102,241,0.08);
}
.brand span { color: var(--muted); font-weight: 400; }
.brand small {
  font-size: 0.625rem;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ─── Copy icon button ─── */
.copy-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.copy-icon-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(99,102,241,0.06); }
.copy-icon-btn.copied { color: var(--success); border-color: var(--success); background: var(--success-bg); }
.copy-icon-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.copy-icon-btn.icon-only { padding: 6px; }
.copy-icon-btn.icon-only svg { width: 15px; height: 15px; }

nav { display: flex; align-items: center; gap: 28px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}
nav a:hover, nav a.active { color: var(--ink); }

.nav-cta {
  background: var(--ink);
  color: var(--paper) !important;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

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

.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 60px;
  align-items: end;
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 0.95;
  margin-bottom: 24px;
}

.hero h1 span { color: var(--muted); font-weight: 400; display: block; }

.hero .lead {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--muted);
  max-width: 560px;
  line-height: 1.55;
  margin-bottom: 32px;
}

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

.hero-aside {
  border-top: 2px solid var(--ink);
  padding-top: 20px;
}
.hero-aside p { color: var(--muted); font-size: 0.9rem; }
.hero-aside strong { display: block; font-size: 1.1rem; margin-bottom: 4px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 8px 20px -8px rgba(0,0,0,0.2);
}
.btn-primary:hover { background: #2a2420; transform: translateY(-1px); }

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}
.btn-secondary:hover { background: var(--soft); }

.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--soft); }

.btn-danger { color: #fff; background: var(--danger); }
.btn-sm { min-height: 36px; padding: 7px 14px; font-size: 0.8rem; }
.btn-lg { min-height: 50px; padding: 14px 24px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 550;
  margin-bottom: 12px;
}

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 16px;
}

/* ─── Model Cards ─── */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 32px;
}

.model-card {
  background: var(--paper);
  padding: 24px;
  transition: background 0.15s;
}
.model-card:hover { background: var(--soft); }

.model-card code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.model-card h3 {
  font-size: 1.1rem;
  margin: 8px 0 4px;
}

.model-card p { font-size: 0.85rem; color: var(--muted); }

.model-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--success-bg);
  color: var(--success);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* ─── Features ─── */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 32px;
}

.feature {
  background: var(--paper);
  padding: 32px;
}

.feature-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.feature h3 {
  font-size: 1.15rem;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.feature p { color: var(--muted); font-size: 0.9rem; }

/* ─── Code Block ─── */
.code-block {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  position: relative;
}

.code-block pre { margin: 0; }

.code-block .copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.code-block .copy-btn:hover { color: var(--ink); border-color: var(--ink); }

/* ─── OTP input ─── */
.otp-inputs { display: flex; gap: 10px; justify-content: center; margin: 8px 0 4px; }
.otp-inputs input {
  width: 48px; height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-family: var(--font-mono);
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.otp-inputs input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.otp-inputs input.filled { border-color: var(--accent); background: rgba(99,102,241,0.04); }
.otp-resend { text-align: center; margin-top: 14px; }
.otp-resend a { color: var(--accent); font-weight: 600; cursor: pointer; }
.otp-resend a.disabled { color: var(--muted); pointer-events: none; }
.otp-timer { color: var(--muted); font-size: 0.8rem; }

/* ─── Key display with copy ─── */
.key-display { position: relative; }
.key-display .copy-icon-btn {
  position: absolute; top: 10px; right: 10px;
}
.key-card .copy-icon-btn { font-size: 0.68rem; padding: 4px 7px; }

/* ─── Auth Pages ─── */
.auth-page {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 80px;
  align-items: start;
  padding: 60px 0;
  min-height: 70vh;
}

.auth-story h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 1;
  margin-bottom: 20px;
}
.auth-story h1 span { color: var(--muted); display: block; font-weight: 400; }

.auth-story .lead {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 480px;
  margin-bottom: 32px;
}

.auth-points { display: grid; gap: 20px; max-width: 480px; }
.auth-points > div { border-top: 1px solid var(--line); padding-top: 16px; }
.auth-points b { display: block; margin-bottom: 4px; }
.auth-points p { color: var(--muted); font-size: 0.88rem; }

.auth-panel {
  background: var(--soft);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
}

.auth-panel h2 { font-size: 1.5rem; margin-bottom: 8px; letter-spacing: -0.03em; }
.auth-panel .subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 28px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-group .hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.form-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.form-success {
  background: var(--success-bg);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ─── Dashboard ─── */
.dashboard {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 48px;
  padding: 40px 0;
  align-items: start;
}

.side-nav {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.side-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}
.side-nav a:hover, .side-nav a.active { color: var(--ink); }

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

.dashboard-section {
  border-top: 1px solid var(--line);
  padding: 32px 0;
}
.dashboard-section:first-of-type { border-top: 2px solid var(--ink); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}

.stat-card { background: var(--paper); padding: 20px; }
.stat-card .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.04em; margin-top: 4px; }

/* ─── API Key Cards ─── */
.key-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }

.key-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--paper);
  transition: box-shadow 0.15s;
}
.key-card:hover { box-shadow: var(--shadow); }

.key-info { flex: 1; min-width: 0; }
.key-info code { font-family: var(--font-mono); font-size: 0.85rem; color: var(--ink); word-break: break-all; }
.key-info .meta { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.key-actions { display: flex; gap: 8px; }

/* ─── Status Badge ─── */
.badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: #f3f4f6; color: var(--muted); }
.badge-fallback { background: var(--warn-bg); color: var(--warn); }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; margin-top: 20px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h2 { font-size: 1.5rem; margin-bottom: 8px; }
.modal p { color: var(--muted); margin-bottom: 24px; }

.key-display {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
  margin-bottom: 20px;
  position: relative;
}

/* ─── Footer ─── */
footer {
  border-top: 1px solid var(--line);
  padding: 40px 0;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}

.footer-brand p { margin-top: 12px; max-width: 320px; }

.footer-links h3 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 12px;
}

.footer-links a { display: block; color: var(--ink); text-decoration: none; padding: 4px 0; }
.footer-links a:hover { color: var(--accent); }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Loading ─── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .hero-grid, .auth-page, .dashboard, .footer-grid { grid-template-columns: 1fr; }
  .hero-grid { gap: 32px; }
  .features, .stat-grid { grid-template-columns: 1fr; }
  .side-nav { position: static; flex-direction: row; overflow-x: auto; }
  .side-nav a { white-space: nowrap; padding: 8px 12px; border-bottom: none; }
  nav { display: none; }
  .mobile-menu-btn { display: block; }
}

@media (max-width: 600px) {
  .model-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 8px; }
}

/* ─── Utility ─── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.font-mono { font-family: var(--font-mono); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
