/* Kineflex API: base styles shared by every page. Mobile first. */
:root {
  --bg: #000000;
  --bg-2: #140d07;
  --card: #1F150C;
  --card-2: #281c10;
  --line: #412D15;
  --line-2: #5c401e;
  --text: #E1DCC9;
  --muted: #b8b29f;
  --dim: #827b6b;
  --accent: #E1DCC9;
  --grad: linear-gradient(135deg, #412D15 0%, #634621 100%);
  --ok: #62b37b;
  --warn: #e5a93b;
  --bad: #e06060;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.2; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: #ffffff; }
code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--card); border: 1px solid var(--line); padding: 0.1em 0.4em; border-radius: 5px; color: var(--text); }
:focus-visible { outline: 2px solid var(--line-2); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 42px; padding: 0 1.1rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--line-2); background: var(--card-2); text-decoration: none; color: #ffffff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--grad); border: 1px solid #634621; color: var(--text); }
.btn.primary:hover { background: linear-gradient(135deg, #4d3619 0%, #755227 100%); color: #ffffff; }
.btn.danger { color: var(--bad); border-color: rgba(224, 96, 96, 0.4); background: transparent; }
.btn.danger:hover { background: rgba(224, 96, 96, 0.12); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card); border-color: var(--line); }
.btn.sm { min-height: 34px; padding: 0 0.75rem; font-size: 0.88rem; border-radius: 8px; }
.btn.block { width: 100%; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 1rem; }
label.field > span { display: block; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.88rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: 0.6rem 0.8rem;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #735227; }
.hint { color: var(--dim); font-size: 0.82rem; margin-top: 0.3rem; }
.form-error { color: var(--bad); font-size: 0.9rem; min-height: 1.2em; margin: 0 0 0.75rem; }
.check { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.7rem 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: #412D15; flex: none; }
.check b { display: block; font-weight: 550; }
.check small { color: var(--muted); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: 0.9rem; }
.grid { display: grid; gap: 0.9rem; }
.stat { display: grid; gap: 0.25rem; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.stat .sub { color: var(--dim); font-size: 0.82rem; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 0.12rem 0.55rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 550; border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(98, 179, 123, 0.4); background: rgba(98, 179, 123, 0.1); }
.badge.warn { color: var(--warn); border-color: rgba(229, 169, 59, 0.4); background: rgba(229, 169, 59, 0.1); }
.badge.bad { color: var(--bad); border-color: rgba(224, 96, 96, 0.4); background: rgba(224, 96, 96, 0.1); }
.badge.accent { color: var(--text); border-color: var(--line-2); background: var(--card-2); }

/* ---------- tables (cards on small screens) ---------- */
.table-wrap { width: 100%; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-weight: 550; font-size: 0.8rem; color: var(--dim);
  text-transform: none; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 0.7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(65, 45, 21, 0.25); }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

@media (max-width: 719px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 10px; margin-bottom: 0.7rem; padding: 0.35rem 0.8rem;
  }
  .tbl td {
    display: flex; justify-content: space-between; gap: 1rem; align-items: center;
    border-bottom: 1px solid var(--line); padding: 0.55rem 0; text-align: right;
  }
  .tbl td:last-child { border-bottom: 0; }
  .tbl td::before {
    content: attr(data-label); color: var(--dim); font-size: 0.8rem; text-align: left; flex: none;
  }
  .tbl td[data-label=""]::before, .tbl td:not([data-label])::before { content: none; }
  .tbl .num { text-align: right; }
}

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; color: var(--muted); font-size: 0.88rem; }

/* ---------- code ---------- */
pre.code {
  margin: 0; padding: 1rem; overflow-x: auto;
  background: #0d0804; border: 1px solid var(--line); border-radius: 10px;
  line-height: 1.6; color: var(--text);
}
.codebox { position: relative; }
.codebox .copy { position: absolute; top: 8px; right: 8px; }
.tok-k { color: #e5b877; }
.tok-s { color: #a2c896; }
.tok-n { color: #d99f6b; }
.tok-c { color: var(--dim); }

/* ---------- dialog & toast ---------- */
dialog {
  width: min(520px, calc(100vw - 2rem)); padding: 1.25rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.75); }
dialog h2 { margin-bottom: 0.4rem; }
dialog .actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.1rem; flex-wrap: wrap; }
.toasts { position: fixed; z-index: 50; left: 1rem; right: 1rem; bottom: 1rem; display: grid; gap: 0.5rem; pointer-events: none; }
.toast {
  pointer-events: auto; margin: 0 auto; max-width: 420px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.9rem; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.65);
}
.toast.bad { border-color: rgba(224, 96, 96, 0.5); }
.toast.ok { border-color: rgba(98, 179, 123, 0.45); }

.banner {
  padding: 0.8rem 1rem; border-radius: 10px; border: 1px solid rgba(229, 169, 59, 0.4);
  background: rgba(65, 45, 21, 0.4); color: #f0cf98;
}
.banner.bad { border-color: rgba(224, 96, 96, 0.4); background: rgba(65, 45, 21, 0.4); color: #f5b0b0; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } * { transition: none !important; } }

/* ---------- public pages (landing, docs, auth) ---------- */
.container { width: min(1120px, 100% - 2rem); margin: 0 auto; }
.site-head { border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, 0.95); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px); }
.site-head .container { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 1rem; }
.logo { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); display: inline-grid; place-items: center; color: var(--text); font-size: 0.8rem; font-weight: 800; border: 1px solid #634621; }
.logo-img { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; display: inline-block; vertical-align: middle; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.site-nav { display: flex; align-items: center; gap: 0.4rem; }
.site-nav a:not(.btn) { color: var(--muted); padding: 0.4rem 0.6rem; border-radius: 8px; }
.site-nav a:not(.btn):hover { color: var(--text); background: rgba(65, 45, 21, 0.25); text-decoration: none; }
.hide-sm { display: none; }

.hero { padding: 2.5rem 0 2rem; display: grid; gap: 2rem; }
.hero h1 { font-size: 2.1rem; max-width: 16ch; }
.hero .lead { color: var(--muted); font-size: 1.05rem; max-width: 46ch; }
.hero .ctas { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.4rem; }
.hero .fine { margin-top: 0.9rem; color: var(--dim); font-size: 0.85rem; }
.section { padding: 2.2rem 0; border-top: 1px solid var(--line); }
.section > .container > h2 { font-size: 1.4rem; margin-bottom: 0.4rem; }
.section .sub { color: var(--muted); margin-bottom: 1.4rem; }
.steps { display: grid; gap: 0.9rem; counter-reset: s; }
.step { position: relative; padding-left: 2.6rem; }
.step::before {
  counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-2);
  display: grid; place-items: center; color: var(--muted); font-size: 0.85rem;
  background: var(--card);
}
.step b { display: block; }
.step span { color: var(--muted); }
.price-grid { display: grid; gap: 0.9rem; }
.price { display: flex; flex-direction: column; gap: 0.35rem; }
.price .name { color: var(--muted); font-weight: 550; }
.price .amount { font-size: 1.8rem; font-weight: 650; letter-spacing: -0.02em; }
.price .pts { font-weight: 550; }
.price.best { border-color: #735227; }
.cost-table { max-width: 420px; }
.site-foot { border-top: 1px solid var(--line); padding: 1.6rem 0 2.4rem; color: var(--dim); font-size: 0.88rem; }
.site-foot .container { display: flex; gap: 1rem 2rem; flex-wrap: wrap; justify-content: space-between; }

.auth-wrap { min-height: 100vh; display: grid; align-content: center; padding: 1.5rem 1rem; }
.auth-card { width: min(420px, 100%); margin: 0 auto; }
.auth-card .logo { margin-bottom: 1.4rem; }
.auth-card h1 { font-size: 1.5rem; }

.docs { display: grid; gap: 1.5rem; padding: 1.5rem 0 3rem; }
.docs-nav { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.docs-nav a { border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.8rem; color: var(--muted); font-size: 0.88rem; }
.docs-nav a:hover { border-color: var(--line-2); color: var(--text); text-decoration: none; }
.docs section { scroll-margin-top: 80px; }
.docs section + section { margin-top: 2.2rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.endpoint { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.7rem; }
.method { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 6px; background: rgba(65, 45, 21, 0.4); border: 1px solid var(--line); color: var(--text); }
.method.post { background: rgba(65, 45, 21, 0.55); border-color: #634621; color: #E1DCC9; }
.docs .tbl td, .docs .tbl th { vertical-align: top; }

@media (min-width: 720px) {
  h1 { font-size: 2rem; }
  .hide-sm { display: inline-flex; }
  .hero { grid-template-columns: 1.05fr 1fr; align-items: center; padding: 4rem 0 3rem; gap: 3rem; }
  .hero h1 { font-size: 3rem; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .price-grid { grid-template-columns: repeat(2, 1fr); }
  .toasts { left: auto; right: 1.25rem; width: 380px; }
}
@media (min-width: 1000px) {
  .price-grid { grid-template-columns: repeat(4, 1fr); }
}
