/* Integrity API — "lab bench" theme.
   Cool paper, navy ink, one ultramarine brand colour. Status colours mean status only. */

:root {
  --paper: #eef0f3;
  --surface: #ffffff;
  --sunken: #f5f6f8;
  --ink: #162033;
  --ink-2: #4b5568;
  --ink-3: #5c6577;
  --line: #d8dde5;
  --line-strong: #c3cad5;

  --brand: #2337c6;
  --brand-hover: #1a2a9e;
  --brand-tint: #e6e9fb;

  --ok: #136b42;
  --ok-tint: #e3f3ea;
  --warn: #9a5b06;
  --warn-tint: #fbf0dc;
  --bad: #b42318;
  --bad-tint: #fbe7e5;
  --run: #2337c6;

  --code-bg: #162033;
  --code-ink: #d9e0ec;
  --code-dim: #8591a8;
  --code-key: #a9b7ff;
  --code-str: #b6e3c8;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --maxw: 1120px;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; }

a { color: var(--brand); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
a:focus-visible { border-radius: 4px; }

h1, h2, h3 { margin: 0 0 .5em; line-height: 1.12; letter-spacing: -0.022em; font-weight: 700; color: var(--ink); }
h1 { font-size: clamp(2.1rem, 4.6vw, 3.5rem); font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.1rem; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
code, pre, kbd { font-family: var(--mono); }
:not(pre) > code { font-size: .86em; background: var(--sunken); border: 1px solid var(--line); padding: .08em .38em; border-radius: 5px; color: var(--ink); }

.muted { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.subtle { color: var(--ink-3); }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.section { padding: 88px 0; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 34em; }

/* ---------- Nav ---------- */
.nav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav .container { display: flex; align-items: center; gap: 28px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.05rem; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.brand-api { font-size: .7rem; font-weight: 700; color: var(--brand); border: 1.5px solid var(--brand); border-radius: 5px; padding: 0 5px; line-height: 1.5; letter-spacing: .02em; }
.nav .primary-links { display: flex; gap: 22px; }
.nav .account { display: flex; gap: 14px; align-items: center; margin-left: auto; }
.nav a:not(.btn):not(.brand):not(.balance-chip) { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem; white-space: nowrap; }
.nav a:not(.btn):not(.brand):not(.balance-chip):hover, .nav a[aria-current=page] { color: var(--ink); }
.nav a[aria-current=page] { box-shadow: 0 2px 0 var(--brand); }
.balance-chip { display: inline-flex; align-items: baseline; gap: 5px; padding: 5px 11px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); font-weight: 600; font-size: .88rem; text-decoration: none !important; white-space: nowrap; }
.balance-chip b { font-variant-numeric: tabular-nums; font-weight: 800; }
.inline-form { display: inline; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font: 600 .95rem/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--ink);
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink-2); padding-left: 8px; padding-right: 8px; }
.btn-quiet:hover { color: var(--ink); background: var(--sunken); }
.btn-danger { background: var(--surface); border-color: var(--line-strong); color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-tint); }
.btn-sm { padding: 7px 12px; font-size: .86rem; }
.btn-xs { padding: 3px 8px; font-size: .76rem; border-radius: 5px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-busy=true] { opacity: .55; cursor: progress; }

/* ---------- Hero ---------- */
.hero { padding: 80px 0 72px; border-bottom: 1px solid var(--line); background: var(--surface); }
.hero .container { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 56px; align-items: center; }
.hero h1 { max-width: 11em; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero .facts { margin: 24px 0 0; color: var(--ink-2); font-size: .95rem; }

/* The API exchange — the one loud element on the page. */
.exchange { margin: 0; background: var(--code-bg); color: var(--code-ink); border-radius: var(--r-lg); padding: 8px; box-shadow: 0 30px 60px -30px rgba(22, 32, 51, .55); }
.ex-call { padding: 16px 18px; }
.ex-call + .ex-call { border-top: 1px dashed rgba(217, 224, 236, .16); }
.ex-line { display: flex; align-items: center; gap: 10px; font: 500 .84rem/1.4 var(--mono); margin-bottom: 10px; }
.ex-verb { font-weight: 700; font-size: .72rem; padding: 2px 7px; border-radius: 4px; background: rgba(169, 183, 255, .16); color: var(--code-key); }
.ex-path { color: #fff; }
.exchange pre.ex-code { margin: 0; padding: 0; background: none; border-radius: 0; font: 400 .82rem/1.65 var(--mono); white-space: pre; overflow-x: auto; scrollbar-width: none; color: var(--code-ink); }
.exchange pre.ex-code::-webkit-scrollbar { display: none; }
.ex-code .k { color: var(--code-key); }
.ex-code .s { color: var(--code-str); }
.ex-code .d { color: var(--code-dim); }
.ex-status { transition: color .2s; }
.ex-status[data-state=queued] { color: #f3c77a; }
.ex-status[data-state=running] { color: var(--code-key); }
.ex-status[data-state=done] { color: var(--code-str); }
.ex-token { transition: opacity .35s; }
.exchange[data-state=queued] .ex-token, .exchange[data-state=running] .ex-token { opacity: .18; }
.ex-meter { display: flex; gap: 6px; padding: 0 18px 14px; }
.ex-meter span { flex: 1; height: 3px; border-radius: 2px; background: rgba(217, 224, 236, .14); transition: background-color .25s; }
.exchange[data-state=running] .ex-meter span:nth-child(-n+2),
.exchange[data-state=done] .ex-meter span { background: var(--code-str); }
.exchange[data-state=queued] .ex-meter span:nth-child(-n+1) { background: #f3c77a; }
.exchange[data-state=running] .ex-meter span:nth-child(-n+2) { background: var(--code-key); }

/* ---------- Steps ---------- */
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 40px 0 0; padding: 0; list-style: none; counter-reset: step; border-top: 2px solid var(--ink); }
.steps li { padding: 22px 28px 0 0; counter-increment: step; }
.steps li + li { padding-left: 28px; border-left: 1px solid var(--line); }
.steps li::before { content: "Step " counter(step); display: block; font-weight: 600; font-size: .9rem; color: var(--ink-3); margin-bottom: 8px; }
.steps h3 { margin-bottom: .35em; }
.steps p { color: var(--ink-2); margin: 0; }

.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; }
.section-head p { margin: 0; color: var(--ink-2); max-width: 32em; }

/* ---------- Rate sheet (pricing) ---------- */
.rates { margin-top: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.rate { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 170px; gap: 16px; align-items: center; padding: 22px 28px; }
.rate + .rate { border-top: 1px solid var(--line); }
.rate-head { padding-top: 14px; padding-bottom: 14px; background: var(--sunken); color: var(--ink-3); font-size: .85rem; font-weight: 600; }
.rate.is-featured { box-shadow: inset 3px 0 0 var(--brand); }
.rate-name h3 { margin: 0; font-size: 1.2rem; }
.rate-name .pill { margin-top: 6px; }
.rate-tokens b { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.rate-per b { font-size: 1.05rem; font-weight: 700; }
.rate-price { font-size: 1.05rem; font-weight: 600; }
.rate .unit { color: var(--ink-3); font-size: .86rem; font-weight: 500; }
.rate-cell-label { display: none; }
.rate-empty { padding: 28px; color: var(--ink-2); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--brand); color: #fff; }

.terms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; margin-top: 36px; }
.terms h3 { font-size: 1rem; margin-bottom: .3em; }
.terms p { color: var(--ink-2); font-size: .95rem; margin: 0; }

/* ---------- Panels (cards) ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; }
.card-gap { margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.card-head a { font-size: .9rem; font-weight: 500; }
.card > .table-wrap { margin: 0 -24px -24px; border-radius: 0 0 var(--r) var(--r); }
.card > .table-wrap:first-child { margin-top: -24px; border-radius: var(--r); }
.card > .table-wrap table { min-width: 100%; }
.card > .table-wrap th:first-child, .card > .table-wrap td:first-child { padding-left: 24px; }
.card > .table-wrap th:last-child, .card > .table-wrap td:last-child { padding-right: 24px; }
.notice { margin: 20px 0 0; padding: 16px 18px; border-radius: var(--r-sm); background: var(--sunken); }
.notice h3 { font-size: 1rem; margin-bottom: .3em; }
.notice p { margin: 0; }
.notice.pos { background: var(--ok-tint); color: var(--ok); font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-3); font-weight: 600; font-size: .84rem; background: var(--sunken); }
tr:last-child > td { border-bottom: 0; }
td code { font-size: .84rem; background: none; border: 0; padding: 0; }
table.kv th { width: 34%; background: none; font-size: .9rem; }
table.kv { margin: -8px 0; }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--sunken); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.queued, .badge.pending { background: var(--warn-tint); color: var(--warn); }
.badge.running { background: var(--brand-tint); color: var(--run); }
.badge.done, .badge.paid { background: var(--ok-tint); color: var(--ok); }
.badge.failed, .badge.cancelled { background: var(--bad-tint); color: var(--bad); }
.badge.expired, .badge.refunded { background: var(--sunken); color: var(--ink-3); }

/* ---------- Forms ---------- */
.auth { min-height: calc(100vh - 64px - 90px); display: grid; place-items: center; padding: 56px 24px; }
.form { width: 100%; max-width: 410px; }
.form h1 { font-size: 1.9rem; margin-bottom: .3em; }
.form .switch { margin: 22px 0 0; color: var(--ink-2); font-size: .95rem; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: .9rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 11px 13px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); color: var(--ink); font: 400 1rem/1.3 var(--font);
}
input::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.help, .errorlist { font-size: .85rem; color: var(--ink-3); margin: 6px 0 0; padding: 0; list-style: none; }
.help ul { margin: 4px 0 0; padding-left: 18px; }
.errorlist { color: var(--bad); }
.form > .errorlist { margin: 0 0 16px; padding: 10px 12px; background: var(--bad-tint); border-radius: var(--r-sm); }
.inline-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields .field { margin: 0; flex: 1; min-width: 200px; }

/* ---------- Dashboard ---------- */
.dash { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; padding: 36px 0 64px; }
.dash > * { min-width: 0; }
.dash-title { margin-bottom: 20px; }
.dash-title h1 { font-size: 1.75rem; letter-spacing: -.025em; margin: 0; }
.dash-title p { margin: 6px 0 0; color: var(--ink-2); }
.narrow { max-width: 680px; }
.side { position: sticky; top: 96px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.side a { display: block; padding: 8px 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; font-size: .95rem; text-decoration: none; }
.side a:hover { color: var(--ink); background: rgba(22, 32, 51, .05); }
.side a.active { color: var(--ink); background: var(--surface); box-shadow: inset 3px 0 0 var(--brand), 0 0 0 1px var(--line); }
.side-logout { display: none; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 10px 12px; }

/* Balance strip: one wide panel instead of three equal cards. */
.overview { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 20px; }
.overview > div { padding: 22px 24px; }
.overview > div + div { border-left: 1px solid var(--line); }
.overview .label { color: var(--ink-2); font-size: .9rem; font-weight: 500; }
.overview .value { font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 6px 0 12px; }
.overview .primary .value { font-size: 2.8rem; color: var(--brand); }
.overview .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.key-cell { display: flex; gap: 8px; align-items: flex-start; }
.key-reveal summary { cursor: pointer; list-style: none; white-space: nowrap; }
.key-reveal summary::-webkit-details-marker { display: none; }
.key-reveal summary .subtle { font-size: .82rem; margin-left: 4px; }
.key-reveal[open] summary .subtle { display: none; }
.key-value { display: block; margin-top: 8px; font: 400 .8rem/1.5 var(--mono); background: var(--sunken); padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--line); word-break: break-all; min-width: 240px; }

/* ---------- Messages ---------- */
.messages { margin: 20px 0 0; padding: 0; list-style: none; }
.messages li { padding: 11px 15px; border-radius: var(--r-sm); margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--ink-3); }
.messages li.success { border-left-color: var(--ok); }
.messages li.error { border-left-color: var(--bad); }
.messages li.warning { border-left-color: var(--warn); }

/* ---------- Docs ---------- */
.docs { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; padding: 56px 0 88px; }
.docs-toc { position: sticky; top: 96px; align-self: start; display: flex; flex-direction: column; gap: 2px; font-size: .93rem; }
.docs-toc a { color: var(--ink-2); text-decoration: none; padding: 5px 0; }
.docs-toc a:hover { color: var(--ink); }
.docs-body { max-width: 720px; }
.docs-body > section { padding-top: 12px; margin-top: 40px; border-top: 1px solid var(--line); }
.docs-body h1 { font-size: 2.25rem; }
.docs-body h2 { font-size: 1.5rem; margin-top: 8px; }
.docs-body p { color: var(--ink-2); }
.endpoint { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font: 500 .9rem/1.4 var(--mono); margin: 0 0 12px; }
.method { font: 700 .72rem/1 var(--mono); padding: 5px 7px; border-radius: 4px; background: var(--brand-tint); color: var(--brand); }
pre { background: var(--code-bg); color: var(--code-ink); border-radius: var(--r); padding: 18px 20px; overflow-x: auto; margin: 0 0 18px; font: 400 .84rem/1.65 var(--mono); }
pre code { font: inherit; color: inherit; }
pre .k { color: var(--code-key); }
pre .s { color: var(--code-str); }
pre .d { color: var(--code-dim); }
.section-tight { padding-top: 0; }
.status-flow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.status-flow .sep { color: var(--ink-3); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 28px 0 36px; color: var(--ink-3); font-size: .9rem; }
.footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; }
.footer nav { display: flex; gap: 20px; }
.footer a { color: var(--ink-2); text-decoration: none; }
.footer a:hover { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero .container { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .rate-head { display: none; }
  .rate { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; padding: 22px; }
  .rate-name, .rate-action { grid-column: 1 / -1; }
  .rate-name { display: flex; align-items: center; gap: 10px; }
  .rate-name .pill { margin: 0; }
  .rate-cell-label { display: block; color: var(--ink-3); font-size: .8rem; font-weight: 500; margin-bottom: 2px; }
  .docs { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .docs-toc { display: none; }
}
@media (max-width: 760px) {
  .container { padding: 0 18px; }
  .section { padding: 56px 0; }
  .hero { padding: 48px 0 52px; }
  .nav .container { gap: 14px; }
  .nav .primary-links a[href*=pricing] { display: none; }
  .nav .primary-links { gap: 14px; }
  .hide-sm { display: none !important; }
  .steps { grid-template-columns: minmax(0, 1fr); border-top: 0; }
  .steps li, .steps li + li { padding: 20px 0; border-left: 0; border-top: 1px solid var(--line); }
  .steps li:first-child { border-top: 2px solid var(--ink); }
  .terms { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .dash { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; }
  .side { position: static; flex-direction: row; overflow-x: auto; margin: 0 -18px; padding: 0 18px 4px; gap: 4px; }
  .side a { white-space: nowrap; flex: none; }
  .side { scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .exchange pre.ex-code { font-size: .74rem; }
  .ex-call { padding: 14px; }
  .side-logout { display: none; }
.side hr { display: none; }
  .side { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .side a.active { background: none; box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }
  .hide-mobile-col { display: none; }
  .side-logout { display: inline; }
  .side-logout .btn { padding: 8px 12px; font-size: .95rem; font-weight: 500; }
  .overview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .overview .primary { grid-column: 1 / -1; border-bottom: 1px solid var(--line); }
  .overview > div + div { border-left: 0; }
  .overview > div:last-child { border-left: 1px solid var(--line); }
  .overview .value { font-size: 1.7rem; }
  .card { padding: 18px; }
  .card > .table-wrap { margin: 0 -18px -18px; }
  .card > .table-wrap:first-child { margin-top: -18px; }
  .card > .table-wrap th:first-child, .card > .table-wrap td:first-child { padding-left: 18px; }
  .card > .table-wrap th:last-child, .card > .table-wrap td:last-child { padding-right: 18px; }
}

@media (max-width: 420px) {
  .brand-api { display: none; }
  .nav .account { gap: 10px; }
}

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