/* ==========================================================================
   Design tokens
   One stylesheet for the public pages (server-rendered) and the dashboard
   (React). Light by default, dark when the system asks for it.
   ========================================================================== */

:root {
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --surface-3: #e8e8e3;
  --border: #e2e2dc;
  --border-strong: #cfcfc8;
  --text: #0d0d12;
  --text-2: #3a3a44;
  --muted: #6b6b75;
  --faint: #9a9aa3;

  --accent: #4b3cfa;
  --accent-hover: #3a2be6;
  --accent-ink: #ffffff;
  --accent-soft: #eeecff;
  --accent-text: #3a2be6;

  --ok: #0f7a47;
  --ok-soft: #e2f4ea;
  --warn: #9a5a00;
  --warn-soft: #fff1d6;
  --danger: #c02626;
  --danger-soft: #fde7e7;
  --info: #1f5fbf;
  --info-soft: #e5eefc;

  --code-bg: #101017;
  --code-text: #e7e7ee;
  --code-muted: #8b8b99;

  --shadow-sm: 0 1px 2px rgb(13 13 18 / 0.06);
  --shadow: 0 1px 2px rgb(13 13 18 / 0.05), 0 4px 16px rgb(13 13 18 / 0.06);
  --shadow-lg: 0 12px 48px rgb(13 13 18 / 0.18);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --focus: 0 0 0 3px rgb(75 60 250 / 0.28);

  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b10;
    --surface: #131319;
    --surface-2: #1a1a22;
    --surface-3: #22222c;
    --border: #25252f;
    --border-strong: #343441;
    --text: #ededf2;
    --text-2: #c9c9d2;
    --muted: #9696a3;
    --faint: #6c6c78;

    --accent: #8a7fff;
    --accent-hover: #a097ff;
    --accent-ink: #0b0b10;
    --accent-soft: #1f1c45;
    --accent-text: #aaa2ff;

    --ok: #4cc98a;
    --ok-soft: #10281c;
    --warn: #f0b24a;
    --warn-soft: #2c2210;
    --danger: #ff6b6b;
    --danger-soft: #2e1414;
    --info: #6fa6ff;
    --info-soft: #122038;

    --code-bg: #08080c;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 16px 56px rgb(0 0 0 / 0.6);
    --focus: 0 0 0 3px rgb(138 127 255 / 0.35);
    color-scheme: dark;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
}

p {
  margin: 0;
}

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

code,
kbd,
pre {
  font-family: var(--mono);
  font-size: 0.9em;
}

:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.08em 0.36em;
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

img,
video {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.nowrap {
  white-space: nowrap;
}
.mono {
  font-family: var(--mono);
}
.num {
  font-variant-numeric: tabular-nums;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--text);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip:focus {
  top: 12px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 500 14px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  user-select: none;
}
.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-ink);
  --btn-border: var(--accent);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn--ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
}
.btn--ghost:hover {
  background: var(--surface-2);
}
.btn--danger {
  --btn-fg: var(--danger);
  --btn-border: color-mix(in srgb, var(--danger) 35%, var(--border));
}
.btn--danger:hover {
  background: var(--danger-soft);
}
.btn--danger-solid {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  --btn-border: var(--danger);
}
.btn--danger-solid:hover {
  background: color-mix(in srgb, var(--danger) 88%, #000);
}
.btn--sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}
.btn--lg {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
}
.btn--block {
  width: 100%;
}
.btn--icon {
  padding: 0;
  width: 36px;
  min-height: 36px;
}
.btn .spinner {
  width: 14px;
  height: 14px;
}

.link-arrow {
  font-weight: 500;
}
.link-arrow::after {
  content: " →";
}

/* ==========================================================================
   Public site
   ========================================================================== */

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand:hover {
  text-decoration: none;
}
.brand__mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent);
  position: relative;
  flex: none;
}
.brand__mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2.5px solid var(--accent-ink);
  border-radius: 50%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.site-nav a:not(.btn) {
  color: var(--text-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}
.site-nav a:not(.btn):hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.nav-toggle,
.nav-burger {
  display: none;
}

.eyebrow {
  font: 500 12px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-text);
  margin-bottom: 18px;
}
.lead {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 60ch;
}

.hero {
  padding: 72px 0 80px;
  background:
    radial-gradient(60% 70% at 85% 10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    linear-gradient(var(--bg), var(--bg));
}
.hero__grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 56px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(36px, 5vw, 58px);
  letter-spacing: -0.035em;
  line-height: 1.04;
  margin-bottom: 22px;
  text-wrap: balance;
}
.hero .lead {
  margin-bottom: 30px;
}
.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.hero__cta .btn {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
}

.window {
  background: var(--code-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.06);
}
.window__bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 14px;
  border-bottom: 1px solid rgb(255 255 255 / 0.07);
}
.window__bar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a3a46;
}
.window__bar em {
  margin-left: 8px;
  font: 12px var(--mono);
  font-style: normal;
  color: var(--code-muted);
}
.window .code {
  border: 0;
  border-radius: 0;
  margin: 0;
}
.window__result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgb(255 255 255 / 0.07);
  font-size: 12px;
}
.window__result code {
  background: none !important;
  border: 0 !important;
  padding: 0 !important;
  color: var(--code-muted);
  overflow-wrap: anywhere;
}

.code {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  margin: 12px 0 20px;
  tab-size: 2;
}
.code code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.band {
  padding: 72px 0;
  background: var(--surface);
  border-block: 1px solid var(--border);
}
.band--dark {
  background: var(--code-bg);
  color: var(--code-text);
  border: 0;
}
.band--dark a {
  color: #b3abff;
}
.band--dark :not(pre) > code {
  background: rgb(255 255 255 / 0.08);
  border-color: rgb(255 255 255 / 0.1);
  color: var(--code-text);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.section-head h2,
.faq h2,
.cta-strip h2 {
  font-size: clamp(26px, 3vw, 34px);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.model-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  transition: border-color 0.15s, transform 0.15s;
}
.model-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.model-card h3 {
  font-size: 18px;
}
.model-card__kind {
  font: 500 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.model-card__price {
  margin-top: auto;
  padding-top: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.model-card__id {
  align-self: flex-start;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px 48px;
  padding-block: 80px;
}
.feature h3 {
  font-size: 17px;
  margin-bottom: 8px;
}
.feature p {
  color: var(--text-2);
}

.faq {
  max-width: 820px;
}
.faq h2 {
  margin-bottom: 24px;
}
.faq details {
  border-top: 1px solid rgb(255 255 255 / 0.1);
  padding: 18px 0;
}
.faq details:last-child {
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.faq summary::-webkit-details-marker {
  display: none;
}
.faq summary::after {
  content: "+";
  font-weight: 400;
  color: var(--code-muted);
}
.faq details[open] summary::after {
  content: "–";
}
.faq details p {
  margin-top: 10px;
  color: #b9b9c6;
  max-width: 68ch;
}

.cta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 64px;
}

.page-head {
  padding-block: 56px 32px;
}
.page-head h1 {
  font-size: clamp(32px, 4vw, 44px);
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.table-title {
  font-size: 20px;
  margin: 36px 0 14px;
}

.docs {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 56px;
  padding-bottom: 96px;
}
.docs__toc {
  position: sticky;
  top: 88px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 1px solid var(--border);
}
.docs__toc a {
  color: var(--muted);
  padding: 6px 14px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 14px;
}
.docs__toc a:hover {
  color: var(--text);
  border-left-color: var(--accent);
  text-decoration: none;
}

.prose {
  max-width: 780px;
  color: var(--text-2);
}
.prose h2 {
  font-size: 24px;
  color: var(--text);
  margin: 48px 0 14px;
  scroll-margin-top: 88px;
}
.prose h2:first-child {
  margin-top: 0;
}
.prose h3 {
  font-size: 16px;
  color: var(--text);
  margin: 26px 0 8px;
}
.prose p,
.prose ul {
  margin: 0 0 14px;
}
.prose ul {
  padding-left: 20px;
}
.prose li {
  margin-bottom: 6px;
}
.legal {
  padding-bottom: 96px;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-top: 48px;
}
.site-footer__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
}
.site-footer__grid > * {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.site-footer__grid a:not(.brand) {
  color: var(--text-2);
  font-size: 14px;
}
.site-footer__head {
  font: 500 12px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.site-footer__base {
  padding-block: 28px;
  margin-top: 40px;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Shared: tables, pills, cards
   ========================================================================== */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: left;
  font: 500 12px/1.2 var(--font);
  color: var(--muted);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr.is-clickable {
  cursor: pointer;
}
.table tbody tr.is-clickable:hover td {
  background: var(--surface-2);
}
.table .t-right {
  text-align: right;
}
.table code {
  white-space: nowrap;
}
.show-sm {
  display: none;
}
.table td.t-prompt {
  max-width: 360px;
  color: var(--text-2);
}
.table td.t-prompt span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font: 500 12px/1 var(--font);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}
.pill--plain::before {
  display: none;
}
.pill--ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.pill--warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.pill--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.pill--info {
  background: var(--info-soft);
  color: var(--info);
}
.pill--accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.pill--running::before {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* ==========================================================================
   Dashboard shell
   ========================================================================== */

.app-body {
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  align-content: start;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
}
.sidebar__brand {
  padding: 4px 8px 18px;
}
.sidebar__section {
  font: 500 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding: 18px 10px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.nav-item[aria-current="page"] svg {
  color: var(--accent-text);
}

.sidebar__foot {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.balance-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.balance-card__label {
  font-size: 12px;
  color: var(--muted);
}
.balance-card__value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 10px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  min-width: 0;
}
.user-chip__avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
}
.user-chip__email {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.topbar {
  display: none;
}

.main {
  min-width: 0;
  padding: 32px 40px 80px;
}
.main__inner {
  max-width: 1120px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 26px;
  letter-spacing: -0.025em;
}
.page-header p {
  color: var(--muted);
  margin-top: 6px;
}
.stack > .page-header {
  margin-bottom: 8px;
}
.page-header__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.back-link {
  display: inline-flex;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.back-link::before {
  content: "←";
  margin-right: 6px;
}

/* ==========================================================================
   Dashboard components
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card__head h2 {
  font-size: 15px;
  letter-spacing: -0.01em;
}
.card__head p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.card__body {
  padding: 20px;
}
.card > .table-scroll {
  border: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: transparent;
}
.card > .table-scroll:first-child {
  border-radius: var(--radius-lg);
}
.card__foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.grid-main-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.row--between {
  justify-content: space-between;
}
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.stat {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.stat__label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat__value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.stat--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.stat--accent .stat__label,
.stat--accent .stat__hint {
  color: color-mix(in srgb, var(--accent-ink) 75%, transparent);
}
.stat--warn {
  border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
  background: var(--warn-soft);
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  flex-wrap: wrap;
}
.banner__text {
  flex: 1;
  min-width: 200px;
}
.banner--info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 25%, transparent);
}
.banner--ok {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}
.banner--warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.banner--danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.field__hint {
  font-size: 12px;
  color: var(--muted);
}
.field__error {
  font-size: 13px;
  color: var(--danger);
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 15px/1.4 var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--faint);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.input--mono {
  font-family: var(--mono);
  font-size: 13px;
}
.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a95' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group__prefix {
  display: grid;
  place-items: center;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}
.input-group .input {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .span-2 {
  grid-column: 1 / -1;
}
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Segmented choice (aspect ratio, amounts) */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.choice {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font: 500 13px/1 var(--font);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.choice:hover {
  border-color: var(--text-2);
}
.choice[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}
.choice--lg {
  min-height: 52px;
  min-width: 88px;
  font-size: 16px;
  font-weight: 600;
}

/* Code block with copy */
.codeblock {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
}
.codeblock__bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid rgb(255 255 255 / 0.07);
  font: 12px var(--mono);
  color: var(--code-muted);
}
.codeblock__bar span {
  margin-right: auto;
}
.codeblock .code {
  margin: 0;
  border-radius: 0;
}
.codeblock__copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  font: 500 12px var(--font);
  border-radius: 6px;
  border: 1px solid rgb(255 255 255 / 0.14);
  background: rgb(255 255 255 / 0.06);
  color: var(--code-text);
  cursor: pointer;
}
.codeblock__copy:hover {
  background: rgb(255 255 255 / 0.12);
}
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
}
.tab {
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 13px var(--font);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.secret {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font: 13px var(--mono);
  overflow-wrap: anywhere;
}
.secret code {
  flex: 1;
  background: none !important;
  border: 0 !important;
  padding: 0 !important;
  font-size: 13px !important;
  color: var(--text);
}

/* Bar chart */
.chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chart__bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding-top: 8px;
  border-bottom: 1px solid var(--border);
}
.chart__col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1px;
  position: relative;
  min-width: 0;
}
.chart__bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  transition: opacity 0.15s;
}
.chart__bar--b {
  background: var(--surface-3);
  border-radius: 0;
}
.chart__bar--empty {
  background: var(--surface-2);
}
.chart__col:hover .chart__bar {
  opacity: 0.75;
}
.chart__tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.chart__col:hover .chart__tip {
  display: block;
}
.chart__axis {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.chart__legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}
.chart__legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
  background: var(--accent);
}
.chart__legend span.b::before {
  background: var(--surface-3);
}

/* Meter (spend vs limit, upstream balance) */
.meter {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}
.meter__fill--warn {
  background: var(--warn);
}
.meter__fill--danger {
  background: var(--danger);
}

/* Progress */
.progress {
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
  min-height: 14px;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty__icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
}
.empty__icon svg {
  width: 22px;
  height: 22px;
}
.empty h3 {
  color: var(--text);
  font-size: 16px;
  margin-bottom: 6px;
}
.empty p {
  max-width: 42ch;
  margin: 0 auto 16px;
  font-size: 14px;
}

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.thumb--video {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.thumb--video svg {
  width: 16px;
  height: 16px;
}

.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 20px;
  font-size: 14px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(8 8 12 / 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.15s ease;
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise 0.18s ease;
}
.modal--wide {
  max-width: 760px;
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}
.modal__head h2 {
  font-size: 18px;
}
.modal__head p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}
.modal__body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 22px 20px;
  flex-wrap: wrap;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

/* Toasts */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: rise 0.18s ease;
}
.toast--error {
  background: var(--danger);
  color: #fff;
}

/* Playground */
.playground {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.playground__form {
  position: sticky;
  top: 24px;
}
.stage {
  min-height: 460px;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%) 0 0 / 20px 20px,
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%) 10px 10px / 20px 20px,
    var(--surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.stage img,
.stage video {
  max-height: 620px;
  width: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stage__waiting {
  width: min(360px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}
.history {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}
.history button {
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  aspect-ratio: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.history button[aria-current="true"] {
  border-color: var(--accent);
}
.history img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.price-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  color: var(--muted);
}
.price-line strong {
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

/* Auth */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.auth__panel {
  display: flex;
  flex-direction: column;
  padding: 32px 48px;
}
.auth__form {
  width: 100%;
  max-width: 380px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth__form h1 {
  font-size: 28px;
  letter-spacing: -0.03em;
}
.auth__form > p {
  color: var(--muted);
  margin-top: -8px;
}
.auth__aside {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  position: relative;
  overflow: hidden;
}
.auth__aside::before {
  content: "";
  position: absolute;
  inset: -30% -30% auto auto;
  width: 520px;
  height: 520px;
  background: radial-gradient(closest-side, rgb(138 127 255 / 0.35), transparent);
  pointer-events: none;
}
.auth__aside h2 {
  font-size: 30px;
  letter-spacing: -0.03em;
  max-width: 16ch;
  position: relative;
}
.auth__points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.auth__points li {
  display: flex;
  gap: 12px;
  color: #c4c4cf;
}
.auth__points li::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  background: rgb(138 127 255 / 0.2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a79fff' stroke-width='3'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.auth__aside .window {
  position: relative;
}
.auth__switch {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1080px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-main-side,
  .playground {
    grid-template-columns: minmax(0, 1fr);
  }
  .playground__form {
    position: static;
  }
  .model-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .hero__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
  }
  .hero {
    padding: 48px 0 56px;
  }
  .features {
    grid-template-columns: repeat(2, 1fr);
    padding-block: 56px;
  }
  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .docs__toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    border-left: 0;
    gap: 4px;
  }
  .docs__toc a {
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 6px 12px;
    margin: 0;
  }
  .site-footer__grid {
    grid-template-columns: 1fr 1fr;
  }
  .auth {
    grid-template-columns: minmax(0, 1fr);
  }
  .auth__aside {
    display: none;
  }

  /* Dashboard: sidebar becomes a drawer */
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    height: 56px;
    padding: 0 12px 0 16px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .topbar__balance {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 14px;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 45;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .shell.is-open .sidebar {
    transform: none;
  }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgb(8 8 12 / 0.5);
    animation: fade 0.15s;
  }
  .main {
    padding: 24px 16px 64px;
  }
  .nav-item {
    min-height: 44px;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }
  .wrap {
    padding: 0 16px;
  }
  .site-header__row {
    height: 58px;
  }
  .nav-burger {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -8px;
    cursor: pointer;
  }
  .nav-burger span,
  .nav-burger span::before,
  .nav-burger span::after {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    position: relative;
    transition: transform 0.2s;
  }
  .nav-burger span::before,
  .nav-burger span::after {
    content: "";
    position: absolute;
  }
  .nav-burger span::before {
    top: -6px;
  }
  .nav-burger span::after {
    top: 6px;
  }
  .nav-toggle:checked + .nav-burger span {
    background: transparent;
  }
  .nav-toggle:checked + .nav-burger span::before {
    transform: translateY(6px) rotate(45deg);
  }
  .nav-toggle:checked + .nav-burger span::after {
    transform: translateY(-6px) rotate(-45deg);
  }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 12px 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .nav-toggle:checked ~ .site-nav {
    display: flex;
  }
  .site-nav a:not(.btn) {
    padding: 12px;
    font-size: 16px;
  }
  .site-nav .btn {
    min-height: 48px;
    margin-top: 8px;
  }
  .hero h1 {
    font-size: 36px;
  }
  .lead {
    font-size: 16px;
  }
  .hero__cta .btn {
    flex: 1;
  }
  .model-grid,
  .features {
    grid-template-columns: minmax(0, 1fr);
  }
  .features {
    gap: 28px;
  }
  .band {
    padding: 52px 0;
  }
  .section-head {
    flex-direction: column;
    gap: 8px;
  }
  .cta-strip {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .cta-strip .btn {
    min-height: 48px;
  }
  .site-footer__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .site-footer__grid a:not(.brand) {
    padding: 4px 0;
  }

  .page-header h1 {
    font-size: 22px;
  }
  .page-header__actions {
    width: 100%;
  }
  .page-header__actions .btn {
    flex: 1;
    min-height: 44px;
  }
  .stats {
    gap: 10px;
  }
  .stat {
    padding: 14px;
  }
  .stat__value {
    font-size: 21px;
  }
  .grid-2,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .card__head,
  .card__body {
    padding: 14px 16px;
  }
  .input,
  .select,
  .textarea {
    font-size: 16px; /* stops iOS zooming into focused fields */
    min-height: 44px;
  }
  .btn {
    min-height: 44px;
  }
  .btn--sm {
    min-height: 36px;
  }
  .choice {
    min-height: 40px;
  }
  .auth__panel {
    padding: 20px 16px 32px;
  }
  .modal-backdrop {
    align-items: end;
    padding: 0;
  }
  .modal {
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
  }
  .modal__foot .btn {
    flex: 1;
  }
  .stage {
    min-height: 300px;
  }
  .toasts {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
  .table td,
  .table th {
    padding: 10px 12px;
  }
  .hide-sm {
    display: none;
  }
  .show-sm {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
