/* apicraft · shared chrome (header, footer, buttons, forms)
   Dials: English · cool white canvas · ink buttons · accent #335CFF as highlighter only ·
   radius 12 · DM Mono style labels · flat fills, no gradients, no glows, no inline styles (CSP). */
:root {
  --font: "Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #fbfcfd; --surface: #fff; --s2: #f2f4f7; --s3: #e7ebf0;
  --ink: #0d0d12; --ink-2: #2b2d36; --muted: #5a6472; --faint: #8a92a4;
  --line: rgba(13,13,18,.08); --line-2: rgba(13,13,18,.14);
  --accent: #335cff; --accent-h: #2447d9; --accent-soft: #eef2ff;
  --green: #15803d; --green-soft: #eaf7ef; --amber: #a15c00; --amber-soft: #fff4e5; --danger: #c4321c; --danger-soft: #fef2f0;
  --dark: #11141b; --dark-2: #1a1f2a; --on-dark: #eef1f5; --on-dark-2: #a9b3c1; --dark-line: rgba(255,255,255,.12);
  --r-card: 16px; --r-control: 12px; --r-panel: clamp(18px, 2.4vw, 28px);
  --gutter: clamp(1rem, 4vw, 3rem);
  --header-h: 60px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.6; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: clip; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.container { width: min(100% - 2 * var(--gutter), 74rem); margin-inline: auto; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: .5rem; z-index: 100; background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; }
.skip:focus { left: 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- links ---------- */
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: .2em; text-decoration-thickness: 1px; transition: text-decoration-color .2s; }
@media (hover: hover) { .link:hover { text-decoration-color: var(--ink); } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .65rem 1.3rem; border-radius: var(--r-control); font: 600 .95rem/1.2 var(--font); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .25s var(--ease), background .2s, border-color .2s, color .2s; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.97); }
.btn-solid { background: var(--ink); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: rgba(196,50,28,.35); }
@media (hover: hover) {
  .btn-solid:hover { background: var(--ink-2); transform: translateY(-1px); }
  .btn-ghost:hover { background: var(--s2); transform: translateY(-1px); }
  .btn-accent:hover { background: var(--accent-h); transform: translateY(-1px); }
  .btn-danger:hover { background: var(--danger-soft); }
}
.btn-sm { min-height: 40px; padding: .45rem .95rem; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn .arrow { display: inline-block; transition: transform .25s var(--ease); }
@media (hover: hover) { .btn:hover .arrow { transform: translateX(3px); } }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: transparent; border-bottom: 1px solid transparent; transition: background .25s, border-color .25s; }
.site-header.is-scrolled, .site-header.menu-open { background: rgba(251,252,253,.94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom-color: var(--line); }
.header-row { display: flex; align-items: center; gap: .5rem; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: .6rem; margin-right: auto; font-weight: 700; font-size: 1.02rem; letter-spacing: -.02em; color: var(--ink); text-decoration: none; min-height: 44px; }
.brand { font-size: 1.12rem; }
.brand-sub { margin-left: .3rem; font-weight: 500; color: var(--muted); }
@media (max-width: 400px) { .brand-sub { display: none; } }
.header-actions { display: flex; align-items: center; gap: .5rem; }
.menu-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-control); background: var(--surface); color: var(--ink); cursor: pointer; }
.menu-btn svg { width: 20px; height: 20px; }
.menu-btn .i-close { display: none; }
.menu-open .menu-btn .i-open { display: none; }
.menu-open .menu-btn .i-close { display: block; }

.nav { position: absolute; left: 0; right: 0; top: 100%; display: none; flex-direction: column; padding: .25rem var(--gutter) 1rem; background: var(--bg); border-bottom: 1px solid var(--line); max-height: calc(100vh - var(--header-h)); overflow-y: auto; }
.menu-open .nav { display: flex; }
.nav a { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: .5rem .25rem; color: var(--ink-2); font-weight: 500; text-decoration: none; border-bottom: 1px solid var(--line); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 650; }
.nav .nav-ext { color: var(--muted); font-size: .92rem; }
@media (min-width: 880px) {
  .menu-btn { display: none; }
  .nav { position: static; display: flex; flex-direction: row; align-items: center; gap: .15rem; padding: 0; background: none; border: 0; max-height: none; overflow: visible; }
  .nav a { position: relative; min-height: 40px; padding: .4rem .75rem; border: 0; font-size: .93rem; color: var(--muted); }
  .nav a::after { content: ""; position: absolute; left: .75rem; right: .75rem; bottom: .2rem; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
  .nav a[aria-current="page"] { color: var(--ink); }
  .nav a[aria-current="page"]::after { transform: scaleX(1); }
  .nav .nav-ext { font-size: .93rem; }
  .header-actions { margin-left: .5rem; }
}
@media (min-width: 880px) and (hover: hover) {
  .nav a:hover { color: var(--ink); }
  .nav a:hover::after { transform: scaleX(1); }
}
@media (min-width: 880px) and (max-width: 1100px) { .nav .nav-ext { display: none; } }

/* ---------- footer ---------- */
.site-footer { margin-top: clamp(1rem, 3vw, 2rem); padding: clamp(2.5rem, 6vw, 4rem) 0 1.75rem; background: var(--surface); border-top: 1px solid var(--line); }
.footer-grid { display: grid; gap: 2rem 1.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.footer-brand { grid-column: 1 / -1; max-width: 26rem; }
.footer-brand .brand { margin-bottom: .75rem; }
.footer-brand p { margin: 0; font-size: .92rem; color: var(--muted); }
.footer-col h2 { margin: 0 0 .5rem; font: 500 .72rem/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.footer-col a { display: flex; align-items: center; gap: .45rem; min-height: 40px; color: var(--ink-2); font-size: .94rem; text-decoration: none; }
.footer-col a img { width: 16px; height: 16px; }
@media (hover: hover) { .footer-col a:hover { color: var(--accent); } }
.footer-legal { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; justify-content: space-between; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.footer-legal p { margin: 0; }
@media (min-width: 880px) {
  .footer-grid { grid-template-columns: 1.7fr 1fr 1fr 1fr; gap: 2rem 3rem; }
  .footer-brand { grid-column: auto; }
}

/* ---------- type ---------- */
.eyebrow { display: inline-block; margin: 0 0 .9rem; font: 500 .75rem/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lead { margin: 0; font-size: clamp(1rem, 1.5vw, 1.15rem); color: var(--muted); max-width: 40rem; }
.mute { color: var(--faint); }
.acc { color: var(--accent); }
code, pre, kbd { font-family: var(--mono); }
:not(pre) > code { padding: .1em .4em; border-radius: 6px; background: var(--s2); font-size: .88em; }

/* ---------- forms ---------- */
.field { display: grid; gap: .4rem; }
.field > label, .field-label { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.input { width: 100%; min-height: 48px; padding: .75rem 1rem; font: 400 1rem var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-control); transition: border-color .2s, box-shadow .2s; }
.input.mono { font-family: var(--mono); font-size: .95rem; }
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field-hint { margin: 0; font-size: .82rem; color: var(--muted); }
.field-error { min-height: 1.3em; margin: 0; font-size: .88rem; color: var(--danger); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 4.5rem; }
.input-toggle { position: absolute; top: 4px; right: 4px; min-height: 40px; padding: 0 .85rem; border: 0; border-radius: 9px; background: none; font: 600 .82rem var(--font); color: var(--muted); cursor: pointer; }
@media (hover: hover) { .input-toggle:hover { color: var(--ink); background: var(--s2); } }

.check { display: inline-flex; align-items: center; gap: .7rem; min-height: 44px; font-size: .92rem; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 22px; height: 22px; margin: 0; border: 1.5px solid rgba(13,13,18,.35); border-radius: 7px; background: var(--surface) center / 14px no-repeat; cursor: pointer; transition: background-color .15s, border-color .15s; }
.check input:checked { background-color: var(--ink); border-color: var(--ink); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E"); }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .check input:not(:checked):hover { border-color: var(--ink); } }

/* ---------- code blocks ---------- */
pre[data-copy] { position: relative; }
.copy-btn { position: absolute; top: .5rem; right: .5rem; min-height: 32px; padding: 0 .7rem; border: 1px solid var(--dark-line); border-radius: 8px; background: rgba(255,255,255,.08); color: var(--on-dark); font: 500 .72rem var(--mono); cursor: pointer; }
@media (hover: hover) { .copy-btn:hover { background: rgba(255,255,255,.16); } }
pre[data-copy] code { display: block; padding-right: 4.5rem; }

/* ---------- pills, alerts, spinner ---------- */
.pill { display: inline-flex; align-items: center; font: 500 .75rem/1 var(--mono); padding: .35rem .65rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--line-2); color: var(--muted); }
.pill.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill.none { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill.pre { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.err { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.spin { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.link-inline { display: inline; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: .2em; cursor: pointer; }
.link-inline:disabled { color: var(--muted); cursor: default; }
@media (hover: hover) { .link-inline:hover { text-decoration-color: var(--ink); } }

/* ---------- Buy me a coffee pop-up (home and dashboard) ---------- */
.coffee { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: grid; gap: .5rem; width: min(22rem, calc(100vw - 2rem)); padding: 1.15rem 1.15rem 1.1rem; border: 1px solid var(--line-2); border-radius: var(--r-card); background: var(--surface); box-shadow: 0 14px 36px -12px rgba(13,13,18,.28); transform: translateY(calc(100% + 2rem)); visibility: hidden; transition: transform .45s var(--ease), visibility 0s .45s; }
.coffee.is-in { transform: none; visibility: visible; transition: transform .45s var(--ease); }
.coffee-ic { width: 28px; height: 28px; color: var(--ink); }
.coffee-t { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.coffee p { margin: 0; font-size: .9rem; color: var(--muted); }
.coffee-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.coffee-x { position: absolute; top: .35rem; right: .35rem; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.coffee-x svg { width: 18px; height: 18px; }
@media (hover: hover) { .coffee-x:hover { background: var(--s2); color: var(--ink); } }
@media (max-width: 520px) { .coffee { right: 1rem; left: 1rem; width: auto; } }
@media (prefers-reduced-motion: reduce) { .coffee, .coffee.is-in { transition: none; } }

/* ---------- note callout (shared by docs and login) ---------- */
.note { margin: 1.25rem 0; padding: .9rem 1.1rem; border: 1px solid var(--line); border-left: 3px solid var(--ink); border-radius: 0 var(--r-control) var(--r-control) 0; background: var(--surface); font-size: .93rem; }
.note > strong:first-child { display: block; margin-bottom: .15rem; font: 500 .72rem/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.note p { margin: 0 0 .5rem; color: var(--ink-2); }
.note p:last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--amber); }
.note.tip { border-left-color: var(--accent); }

.pill.rate-badge {
  font-size: .78rem;
  padding: .35rem .65rem;
  gap: .35rem;
}
.rl-gauge {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-card);
  padding: 1.25rem;
  margin: 1.25rem 0;
  display: grid;
  gap: .75rem;
}
.rl-gauge-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.rl-meter-track {
  height: 10px;
  border-radius: 99px;
  background: var(--s3);
  overflow: hidden;
}
.rl-meter-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .4s var(--ease);
}
.rl-meter-fill.is-healthy { background: var(--green); }
.rl-meter-fill.is-warn { background: var(--amber); }
.rl-meter-fill.is-crit { background: var(--danger); }
.rl-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  font-size: .85rem;
  color: var(--muted);
  font-family: var(--mono);
}
.track-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1rem;
  background: var(--s2);
  border-radius: var(--r-control);
  margin-bottom: 1rem;
}
.track-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.code-box {
  background: var(--dark);
  color: var(--on-dark);
  border-radius: var(--r-control);
  padding: 1rem 1.25rem;
  font-family: var(--mono);
  font-size: .88rem;
  overflow-x: auto;
  position: relative;
}
.code-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--dark-line);
  padding-bottom: .5rem;
  margin-bottom: .75rem;
}
.code-tab {
  background: none;
  border: none;
  color: var(--on-dark-2);
  font: 600 .8rem var(--mono);
  padding: .3rem .6rem;
  border-radius: 6px;
  cursor: pointer;
}
.code-tab[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

