:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f7;
  --bg-soft-2: #fafafa;
  --border: #e5e5e5;
  --border-strong: #d1d1d1;
  --text: #171717;
  --text-dim: #6b6b6b;
  --text-faint: #9a9a9a;
  --amber: #b45309;
  --red: #dc2626;
  --green: #16a34a;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body { height: 100%; }

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

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

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

.mono { font-family: var(--mono); }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.5px;
}
.nav { display: flex; align-items: center; gap: 28px; overflow-x: auto; }
.nav a {
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); font-weight: 500; }
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform .18s ease, opacity .18s ease;
}
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Secondary app tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin: 24px 0 28px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs a {
  font-size: 14px;
  color: var(--text-dim);
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); font-weight: 500; border-bottom-color: var(--text); }

/* ---------- Main ---------- */
main.container { padding-top: 40px; padding-bottom: 90px; }

.page-head { margin-bottom: 28px; }
.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.page-sub { font-size: 14px; color: var(--text-dim); margin-top: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.stat-value {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.stat-note { display: block; font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  text-align: left;
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: top;
}
.table td strong { color: var(--text); font-weight: 500; }
.table tr:last-child td { border-bottom: none; }
.empty { color: var(--text-faint); font-size: 14px; padding: 14px 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .3px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  text-transform: capitalize;
}
.badge-ok { color: var(--green); border-color: #cde8d6; background: #f0faf3; }
.badge-off { color: var(--text-faint); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--text);
  background: var(--text);
  color: #fff;
  cursor: pointer;
  transition: opacity .12s;
}
.btn:hover { opacity: .85; color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); opacity: 1; }
.btn-danger { background: var(--bg); color: var(--red); border-color: var(--border); }
.btn-danger:hover { background: #fef2f2; color: var(--red); opacity: 1; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .12s;
}
.input:focus { border-color: var(--text); }
.input::placeholder { color: var(--text-faint); }
.select {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.inline-form { display: flex; gap: 10px; align-items: center; }

/* ---------- Toolbar (search/filter) ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.toolbar .input { flex: 1; min-width: 200px; }
.toolbar .select { min-width: 140px; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.alert-error { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.alert-success { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }

/* ---------- Code blocks ---------- */
.code {
  background: var(--bg-soft-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: #333;
  overflow-x: auto;
  padding: 18px 20px;
}
.code .cmt { color: var(--text-faint); }

/* ---------- Key reveal ---------- */
.key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-soft-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.key-box .code { border: none; background: transparent; padding: 0; color: var(--text); font-size: 13px; word-break: break-all; }

/* ---------- Model cards ---------- */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.model-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.model-card .name { font-size: 15px; font-weight: 600; color: var(--text); word-break: break-word; }
.model-card .mid { font-family: var(--mono); font-size: 12px; color: var(--text-faint); word-break: break-all; }
.model-card .specs {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}
.model-card .desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; }

/* ---------- Quota / progress ---------- */
.quota { margin-top: 12px; }
.quota-row { margin-bottom: 10px; }
.quota-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.quota-top .used { color: var(--text-faint); }
.progress {
  height: 6px;
  background: #efefef;
  border-radius: 3px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 3px;
  transition: width .3s ease;
}
.progress > span.warn { background: var(--amber); }
.progress > span.over { background: var(--red); }

/* ---------- Features list ---------- */
.features { list-style: none; }
.features li {
  font-size: 15px;
  color: var(--text-dim);
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.features li:last-child { border-bottom: none; }
.features li::before { content: "\2013  "; color: var(--text-faint); }

/* ---------- FAQ ---------- */
.faq-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.faq-item:first-child { padding-top: 0; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-size: 15px; font-weight: 500; color: var(--text); }
.faq-a { font-size: 14px; color: var(--text-dim); margin-top: 6px; line-height: 1.65; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.auth-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 70px 24px 60px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-brand {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.auth-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}
.auth-card .card { padding: 28px; }
.auth-foot {
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-dim);
}
.auth-foot a { color: var(--text); font-weight: 500; }

/* ---------- Landing ---------- */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 96px 24px 64px;
}
.landing-body .term { font-size: 14px; color: var(--text-dim); margin-bottom: 16px; }
.landing-body h1 { font-size: 44px; font-weight: 700; letter-spacing: -1.5px; margin-bottom: 14px; }
.landing-body p { color: var(--text-dim); max-width: 560px; font-size: 16px; margin-bottom: 32px; }
.landing-body .actions { display: flex; gap: 12px; }

.landing-sections { padding: 0 24px; }
.section { margin-top: 72px; }
.section-head { margin-bottom: 24px; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); }
.section-desc { font-size: 14px; color: var(--text-dim); margin-top: 4px; }
.view-all { margin-top: 20px; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}
.landing .footer { margin-top: 80px; }

@media (max-width: 860px) {
  .stats { grid-template-columns: 1fr; }
  .menu-toggle { display: flex; }
  .nav {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    right: 0;
    width: min(280px, calc(100vw - 48px));
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    overflow: visible;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 30px rgba(0,0,0,.1);
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; border-radius: 8px; }
  .nav a:hover { background: var(--bg-soft); }
  .page-title { font-size: 22px; }
  .models-grid { grid-template-columns: 1fr 1fr; }
  .landing-body h1 { font-size: 34px; }
}
@media (max-width: 460px) {
  .models-grid { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
}

/* ---------- Documentation ---------- */
.docs-layout { display: flex; gap: 36px; align-items: flex-start; }
.docs-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding-right: 16px;
}
.docs-sidebar nav a {
  display: block;
  padding: 7px 12px;
  color: var(--text-dim);
  font-size: 14px;
  border-radius: 8px;
}
.docs-sidebar nav a:hover { color: var(--text); background: var(--bg-soft); }
.docs-content { flex: 1; min-width: 0; }

.doc-section { margin-bottom: 56px; }
.doc-section h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 14px; }
.doc-section h3 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; }
.doc-section p { color: var(--text-dim); font-size: 15px; margin-bottom: 14px; }

code.inline {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--text);
  white-space: nowrap;
}

.code-block { margin: 14px 0 20px; }
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}
.code-block .code { border-radius: 0 0 10px 10px; margin: 0; }
.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }

.docs-toggle { display: none; }

@media (max-width: 860px) {
  .docs-toggle { display: inline-flex; }
  .docs-layout { flex-direction: column; gap: 0; }
  .docs-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 86vw);
    background: #fff;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .2s ease;
    padding: 24px 16px;
    border-right: 1px solid var(--border);
    box-shadow: 10px 0 30px rgba(0,0,0,.08);
    max-height: none;
  }
  .docs-sidebar.open { transform: translateX(0); }
  .docs-sidebar nav a { padding: 10px 12px; }
  .docs-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(23,23,23,.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .docs-backdrop.open { opacity: 1; pointer-events: auto; }
  body.docs-menu-open { overflow: hidden; }
}

@media (max-width: 600px) {
  .container { padding-left: 16px; padding-right: 16px; }
  main.container { padding-top: 28px; padding-bottom: 64px; }
  .page-head { margin-bottom: 20px; }
  .page-title { font-size: 24px; }
  .doc-section { margin-bottom: 40px; }
  .doc-section h2 { font-size: 20px; }
  .doc-section h3 { font-size: 16px; }
  .doc-section p { font-size: 14px; }
  code.inline { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
  .code-block { max-width: 100%; overflow: hidden; }
  .code-block .code { max-width: 100%; padding: 14px; font-size: 12px; line-height: 1.6; }
  .code-head { padding: 8px 10px; }
}
