/* ==========================================================================
   tiyuvta inference — product theme.

   Deliberately unlike the lab site at tiyuvta.ai (near-black substrate, amber
   lane marker). This is the daylight instrument: warm paper, ink text, one
   ink-teal signal, hairline datasheet rules, tabular figures everywhere.

   Loaded by BOTH the static marketing pages and the server-rendered console
   pages so a signup never crosses a visual seam. One file, one origin.
   ========================================================================== */

/* --- fonts: self-hosted woff2, copied from @fontsource at build time ------ */

@font-face {
  font-family: 'Schibsted Grotesk';
  src: url('/fonts/schibsted-grotesk-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/plex-mono-latin-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/plex-mono-latin-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* --- tokens --------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* warm paper substrate */
  --paper: #f8f6f1;
  --card: #fffefb;
  --sunk: #f1eee6;
  --rule: #e0dbd0;
  --rule-firm: #c6bfb1;

  /* ink */
  --ink: #16181c;
  --ink-2: #4d535c;
  --ink-3: #656c78; /* >=4.5:1 on paper, card and sunk (measured) */

  /* one signal: ink teal */
  --signal: #0c5c50;
  --signal-hot: #0f7a68;
  --signal-wash: #e6efeb;
  --on-signal: #fbfdfb;

  /* semantics, sparing */
  --warn: #8a4b12;
  --stop: #a3301f;
  --live: #0f7a68;

  --sans: 'Schibsted Grotesk', ui-sans-serif, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --step--1: 0.8125rem;
  --step-0: 0.9688rem;
  --step-1: 1.125rem;
  --step-2: 1.375rem;
  --step-3: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem);
  --step-4: clamp(2.1rem, 1.3rem + 3.2vw, 3.4rem);
  --step-5: clamp(2.6rem, 1.2rem + 5.4vw, 4.75rem);

  --gap: 1rem;
  --gap-2: 1.5rem;
  --gap-3: 2.25rem;
  --gap-4: 3.5rem;
  --gap-5: 5.5rem;

  --wrap: 71rem;
  --prose: 40rem;
  --r: 3px;
  --shadow: 0 1px 0 rgba(22, 24, 28, 0.04), 0 12px 28px -22px rgba(22, 24, 28, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12151a;
    --card: #181c22;
    --sunk: #0d1014;
    --rule: #262c34;
    --rule-firm: #3a424e;

    --ink: #e9ecef;
    --ink-2: #a7aeb8;
    --ink-3: #868f9b;

    --signal: #4ecfb4;
    --signal-hot: #6fe0c8;
    --signal-wash: #16241f;
    --on-signal: #06100d;

    --warn: #d9a15f;
    --stop: #e5806f;
    --live: #4ecfb4;

    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 14px 30px -24px rgba(0, 0, 0, 0.9);
  }
}

/* --- reset --------------------------------------------------------------- */

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

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  font-feature-settings: 'kern' 1;
  -webkit-font-smoothing: antialiased;
}

body > * {
  position: relative;
  z-index: 1;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
figure,
pre,
table {
  margin: 0;
}

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

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-firm);
  text-underline-offset: 0.22em;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 1px;
}

::selection {
  background: var(--signal);
  color: var(--on-signal);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 60;
  transform: translateY(-250%);
  background: var(--signal);
  color: var(--on-signal);
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  border-radius: var(--r);
}

.skip:focus {
  transform: none;
}

/* --- type --------------------------------------------------------------- */

h1,
h2,
h3 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.021em;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: var(--step-4);
}

h2 {
  font-size: var(--step-3);
}

h3 {
  font-size: var(--step-1);
  letter-spacing: -0.008em;
  line-height: 1.3;
}

.display {
  font-size: var(--step-5);
  line-height: 1.06;
  letter-spacing: -0.028em;
}

.kicker {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: block;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 36rem;
  text-wrap: pretty;
}

p {
  color: var(--ink-2);
  text-wrap: pretty;
}

.prose {
  max-width: var(--prose);
}

.prose > * + * {
  margin-top: 1rem;
}

.prose h2 {
  margin-top: var(--gap-3);
}

.prose h3 {
  margin-top: var(--gap-2);
}

.prose ul,
.prose ol {
  padding-left: 1.15rem;
  color: var(--ink-2);
}

.prose li + li {
  margin-top: 0.35rem;
}

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

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.tiny {
  font-size: var(--step--1);
  color: var(--ink-3);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.08em 0.32em;
  overflow-wrap: anywhere;
}

/* --- shell -------------------------------------------------------------- */

.wrap {
  width: min(var(--wrap), 100% - 2.5rem);
  margin-inline: auto;
}

.nav {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  min-height: 3.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-right: auto;
}

.brand-mark {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--signal);
  position: relative;
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--signal);
}

.brand small {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-left: 1px solid var(--rule-firm);
  padding-left: 0.5rem;
  margin-left: 0.1rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  list-style: none;
  padding: 0;
  font-size: var(--step--1);
}

/* `:not(.btn)` matters: without it these rules out-specify .btn-primary and
   repaint the button label in body-text grey on the teal fill. */
.nav-links a:not(.btn) {
  text-decoration: none;
  color: var(--ink-2);
  padding-block: 0.3rem;
  border-bottom: 1px solid transparent;
}

.nav-links a:not(.btn):hover,
.nav-links a:not(.btn)[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--signal);
}

.foot {
  border-top: 1px solid var(--rule);
  margin-top: var(--gap-5);
  padding-block: var(--gap-3) var(--gap-3);
  font-size: var(--step--1);
  color: var(--ink-3);
}

.foot-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: var(--gap-2);
}

.foot h4 {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
  margin-bottom: 0.7rem;
}

.foot ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.foot a {
  text-decoration: none;
  color: var(--ink-2);
}

.foot a:hover {
  text-decoration: underline;
  text-decoration-color: var(--signal);
}

.foot-legal {
  margin-top: var(--gap-3);
  padding-top: var(--gap);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

/* --- sections ----------------------------------------------------------- */

.band {
  padding-block: var(--gap-5);
}

.band-tight {
  padding-block: var(--gap-4);
}

.band + .band {
  border-top: 1px solid var(--rule);
}

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: var(--gap-2);
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--rule);
}

/* --- hero --------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: var(--gap-4);
  align-items: start;
  padding-block: clamp(2.75rem, 6vw, 5.5rem) var(--gap-4);
}

.hero-copy > * + * {
  margin-top: var(--gap);
}

.hero .display {
  margin-top: 1.1rem;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  margin-top: var(--gap-2);
}

.hero-side {
  display: grid;
  gap: var(--gap);
}

/* --- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--rule-firm);
  border-radius: var(--r);
  background: var(--card);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  border-color: var(--signal);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--on-signal);
}

.btn-primary:hover {
  background: var(--signal-hot);
  border-color: var(--signal-hot);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
  text-decoration-color: var(--rule-firm);
}

.btn-lg {
  min-height: 3.1rem;
  padding-inline: 1.4rem;
  font-size: var(--step-0);
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: var(--gap-2);
}

/* --- badges, notices ---------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.3rem 0.6rem;
  border-radius: 100px;
  background: var(--signal-wash);
  color: var(--signal);
  border: 1px solid color-mix(in srgb, var(--signal) 28%, transparent);
  width: max-content;
}

.badge-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--live);
  flex: none;
}

.notice {
  display: grid;
  gap: 0.3rem;
  border: 1px solid var(--rule-firm);
  border-left: 2px solid var(--signal);
  background: var(--card);
  border-radius: var(--r);
  padding: 0.85rem 1rem;
  font-size: var(--step--1);
  margin-bottom: var(--gap-2);
}

.notice b {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

.notice span,
.notice p {
  color: var(--ink-2);
}

.notice-warn {
  border-left-color: var(--warn);
}

.notice-stop {
  border-left-color: var(--stop);
}

/* --- cards, panels ------------------------------------------------------ */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: var(--gap-2);
  box-shadow: var(--shadow);
}

.card-flat {
  box-shadow: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

/* --- the meter: the recurring motif ------------------------------------- */

.meter {
  --fill: 62%;
  display: grid;
  gap: 0.5rem;
}

.meter-track {
  position: relative;
  height: 1.55rem;
  border-left: 1px solid var(--rule-firm);
  border-right: 1px solid var(--rule-firm);
}

.meter-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--rule-firm);
}

.meter-track::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  width: var(--fill);
  background: var(--signal);
  transform-origin: left;
}

.meter-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.meter-legend {
  display: flex;
  justify-content: space-between;
  gap: var(--gap);
  font-size: var(--step--1);
  color: var(--ink-2);
}

/* --- code --------------------------------------------------------------- */

.code {
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--rule);
  padding: 0.4rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--card);
}

.code-bar span:last-child {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
}

.code pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  scrollbar-width: thin;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--ink);
  tab-size: 2;
}

/* hero and prose snippets wrap instead of scrolling sideways */
.code-soft pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code .tok-str {
  color: var(--signal);
}

.code .tok-dim {
  color: var(--ink-3);
}

/* --- tables ------------------------------------------------------------- */

.table-frame {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow-x: auto;
  background: var(--card);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--step--1);
}

caption {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

th {
  text-align: left;
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule-firm);
  white-space: nowrap;
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td strong {
  color: var(--ink);
  font-weight: 600;
}

.right {
  text-align: right;
}

td.right,
th.right {
  font-variant-numeric: tabular-nums;
}

tbody tr.is-ours td {
  background: var(--signal-wash);
  color: var(--ink);
}

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ink-3);
}

/* --- key/value spec list ------------------------------------------------ */

.kv {
  display: grid;
  border-top: 1px solid var(--rule);
}

.kv > div {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
  gap: var(--gap);
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}

.kv dt {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-top: 0.15rem;
}

.kv dd {
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink-2);
}

/* --- stat row ----------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--card);
  overflow: hidden;
}

.stat {
  padding: 1.05rem 1.15rem;
  border-right: 1px solid var(--rule);
}

.stat:last-child {
  border-right: 0;
}

.stat span {
  display: block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat strong {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-2);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.stat small {
  display: block;
  margin-top: 0.2rem;
  font-size: var(--step--1);
  color: var(--ink-3);
}

/* --- steps -------------------------------------------------------------- */

.steps {
  list-style: none;
  padding: 0;
  counter-reset: s;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--rule);
}

.steps li {
  counter-increment: s;
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: var(--gap);
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--rule);
}

.steps li::before {
  content: counter(s, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--signal);
  padding-top: 0.2rem;
  grid-row: 1 / span 2;
}

.steps b {
  display: block;
  grid-column: 2;
  color: var(--ink);
}

.steps span {
  grid-column: 2;
  font-size: var(--step--1);
  color: var(--ink-2);
}

/* --- packs -------------------------------------------------------------- */

.packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 0.7rem;
}

.pack {
  position: relative;
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--rule-firm);
  border-radius: var(--r);
  background: var(--card);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.pack:hover {
  border-color: var(--signal);
}

.pack:active {
  transform: translateY(1px);
}

.pack strong {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-2);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.pack span:not(.pack-tag) {
  font-size: var(--step--1);
  color: var(--ink-3);
}

/* Token estimate under each pack: the unit customers plan in. Mono so the
   figures line up column to column, and quiet so the price stays the headline. */
.pack .pack-est {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.pack-tag {
  position: absolute;
  top: -0.6rem;
  right: 0.7rem;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--signal);
  color: var(--on-signal);
  padding: 0.15rem 0.45rem;
  border-radius: 100px;
}

/* --- forms -------------------------------------------------------------- */

.form {
  display: grid;
  gap: 0.8rem;
  max-width: 26rem;
}

.form-wide {
  max-width: none;
}

label {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink);
}

label .hint {
  display: block;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 0.15rem;
}

input[type='email'],
input[type='text'],
input[type='number'],
select,
textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--rule-firm);
  border-radius: var(--r);
  padding: 0.7rem 0.8rem;
  font-size: var(--step-0);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--signal);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 400;
  font-size: var(--step--1);
  color: var(--ink-2);
}

.check input {
  margin-top: 0.25rem;
  accent-color: var(--signal);
  width: 1rem;
  height: 1rem;
  flex: none;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.8rem;
}

.secret {
  display: block;
  width: 100%;
  background: var(--sunk);
  border: 1px solid var(--signal);
  border-radius: var(--r);
  padding: 0.9rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink);
  resize: none;
  word-break: break-all;
}

/* --- console shell ------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: 14.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.app-rail {
  border-right: 1px solid var(--rule);
  padding: 1.1rem 1.1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap-2);
  position: sticky;
  top: 0;
  height: 100vh;
  background: color-mix(in srgb, var(--card) 55%, var(--paper));
}

.app-rail nav ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.1rem;
  font-size: var(--step--1);
}

.app-rail nav a {
  display: block;
  text-decoration: none;
  color: var(--ink-2);
  padding: 0.45rem 0.6rem;
  border-radius: var(--r);
  border-left: 2px solid transparent;
}

.app-rail nav a:hover {
  background: var(--sunk);
  color: var(--ink);
}

.app-rail nav a[aria-current='page'] {
  background: var(--signal-wash);
  border-left-color: var(--signal);
  color: var(--ink);
  font-weight: 600;
}

.app-rail-foot {
  margin-top: auto;
  display: grid;
  gap: 0.5rem;
  font-size: var(--step--1);
  color: var(--ink-3);
  border-top: 1px solid var(--rule);
  padding-top: var(--gap);
}

.app-rail-foot form {
  margin: 0;
}

.app-main {
  min-width: 0;
  padding: clamp(1.5rem, 3vw, 2.5rem) clamp(1.1rem, 3vw, 2.75rem) 5rem;
  width: min(62rem, 100%);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap);
  padding-bottom: var(--gap);
  margin-bottom: var(--gap-2);
  border-bottom: 1px solid var(--rule);
}

.page-head h1 {
  font-size: var(--step-3);
}

.link-plain {
  text-decoration: none;
  color: var(--ink-2);
  font-size: var(--step--1);
}

.link-plain:hover {
  color: var(--signal);
  text-decoration: underline;
}

.text-btn {
  border: 0;
  background: none;
  padding: 0;
  font-size: var(--step--1);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule-firm);
  text-underline-offset: 0.22em;
  color: var(--ink-2);
}

.text-btn:hover {
  color: var(--signal);
}

.text-btn-stop:hover {
  color: var(--stop);
}

/* balance headline */
.balance {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: center;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: var(--gap-2);
  box-shadow: var(--shadow);
}

.balance-fig span {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.balance-fig strong {
  display: block;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.1;
  margin-top: 0.2rem;
}

/* Tokens-left line under the balance. Sentence case on purpose: it is a figure
   to read, not a label, and `.balance-fig span` would otherwise shout it. */
.balance-fig .num {
  display: block;
  margin-top: 0.4rem;
  font-size: var(--step--1);
  letter-spacing: 0.01em;
  text-transform: none;
}

.head-figure .num {
  display: block;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.balance-note {
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule);
  padding-top: 0.85rem;
  font-size: var(--step--1);
  margin: 0;
}

.state {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.state-live {
  color: var(--live);
}

.state-off {
  color: var(--ink-3);
}

.state-stop {
  color: var(--stop);
}

/* --- docs layout -------------------------------------------------------- */

.docs {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: var(--gap-3);
  padding-block: var(--gap-3) var(--gap-4);
  align-items: start;
}

.docs-rail {
  position: sticky;
  top: 5rem;
  font-size: var(--step--1);
}

.docs-rail h4 {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
  margin-bottom: 0.6rem;
}

.docs-rail ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  border-left: 1px solid var(--rule);
}

.docs-rail a {
  display: block;
  padding: 0.1rem 0 0.1rem 0.7rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--ink-2);
}

.docs-rail a:hover {
  color: var(--ink);
  border-left-color: var(--signal);
}

.docs-body > section {
  padding-block: var(--gap-2);
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 5rem;
}

.docs-body > section:last-child {
  border-bottom: 0;
}

.docs-body h2 {
  margin-bottom: 0.6rem;
}

.docs-body > section > * + * {
  margin-top: 0.9rem;
}

/* --- responsive --------------------------------------------------------- */

@media (max-width: 60rem) {
  .hero,
  .docs {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-rail {
    position: static;
  }

  .grid-3,
  .grid-4,
  .foot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    flex-direction: row;
    align-items: center;
    gap: var(--gap);
    overflow-x: auto;
  }

  /* Wrap rather than scroll: six items no longer fit a phone rail, and a link
     hidden behind a horizontal scroll is a link nobody finds. */
  .app-rail nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
  }

  .app-rail nav a {
    white-space: nowrap;
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
  }

  .app-rail nav a[aria-current='page'] {
    border-left: 0;
    border-bottom-color: var(--signal);
  }

  .app-rail-foot {
    margin: 0 0 0 auto;
    border-top: 0;
    padding-top: 0;
  }

  .app-rail-foot a {
    display: none;
  }
}

@media (max-width: 40rem) {
  .grid-2,
  .grid-3,
  .grid-4,
  .foot-grid,
  .balance {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-links {
    gap: 0.95rem;
  }

  .nav-links .nav-hide {
    display: none;
  }

  .sec-head,
  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .kv > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }

  .stat {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .stat:last-child {
    border-bottom: 0;
  }
}

/* --- utilities -----------------------------------------------------------
   Every page here is served under `style-src 'self'` with no inline styles, so
   one-off spacing and width tweaks live as classes rather than style attributes.
   A blocked inline style is an invisible layout break; a class cannot be. */

.mt-xs { margin-top: 0.4rem; }
.mt-sm { margin-top: 0.85rem; }
.mt-md { margin-top: var(--gap); }
.mt-lg { margin-top: var(--gap-2); }
.mt-xl { margin-top: var(--gap-3); }
.mb-md { margin-bottom: var(--gap); }
.mb-lg { margin-bottom: var(--gap-2); }
.m-0 { margin: 0; }

.max-22 { max-width: 22rem; }
.max-34 { max-width: 34rem; }
.max-44 { max-width: 44rem; }
.max-46 { max-width: 46rem; }
.max-none { max-width: none; }

.text-stop { color: var(--stop); }
.text-right { text-align: right; }

.gap-lg { gap: var(--gap-3); }
.items-start { align-items: start; }

/* login: copy beside the sign-in card, stacking on narrow screens */
.login-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 23rem);
  gap: var(--gap-4);
  align-items: start;
}

/* a card that is a call to action */
.card-cta {
  display: grid;
  gap: var(--gap);
  justify-items: start;
}

/* the pricing calculator borrows .stats without its frame */
.stats-bare {
  border: 0;
  background: transparent;
}

.stats-bare .stat:first-child { padding-left: 0; }
.stats-bare .stat:last-child { border-right: 0; }

.rule-h {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--gap) 0;
}

/* balance figure in a page header */
.head-figure { text-align: right; }

.head-figure strong {
  display: block;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-2);
  letter-spacing: -0.03em;
}

/* compact primary action inside the top navigation */
.nav-cta {
  min-height: 2.25rem;
  padding: 0.35rem 0.8rem;
}

.stack-sm { display: grid; gap: 0.55rem; }

.or-rule {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.9rem 0;
  font-size: var(--step--1);
  color: var(--ink-3);
}

.or-rule::before,
.or-rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}

@media (max-width: 60rem) {
  .login-split {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--gap-2);
  }
}

@media (max-width: 40rem) {
  .head-figure { text-align: left; }
}

/* meter fill, quantised to 5% steps so no inline style is needed */
.fill-0 { --fill: 0%; }
.fill-5 { --fill: 5%; }
.fill-10 { --fill: 10%; }
.fill-15 { --fill: 15%; }
.fill-20 { --fill: 20%; }
.fill-25 { --fill: 25%; }
.fill-30 { --fill: 30%; }
.fill-35 { --fill: 35%; }
.fill-40 { --fill: 40%; }
.fill-45 { --fill: 45%; }
.fill-50 { --fill: 50%; }
.fill-55 { --fill: 55%; }
.fill-60 { --fill: 60%; }
.fill-65 { --fill: 65%; }
.fill-70 { --fill: 70%; }
.fill-75 { --fill: 75%; }
.fill-80 { --fill: 80%; }
.fill-85 { --fill: 85%; }
.fill-90 { --fill: 90%; }
.fill-95 { --fill: 95%; }
.fill-100 { --fill: 100%; }

/* --- density and overflow fixes ------------------------------------------
   Found by walking the real pages at 390, 768 and 1440 px. */

/* The console is a working surface, not a landing page: smaller section heads
   and tighter bands so a form is not separated from its table by a screenful. */
.app-main h1 { font-size: var(--step-3); }
.app-main h2 { font-size: var(--step-2); }
.app-main .band-tight { padding-block: var(--gap-2) 0; }
.app-main .sec-head { margin-bottom: var(--gap); }
.app-main .band-tight:first-child { padding-top: 0; }

@media (max-width: 60rem) {
  /* Brand on one line, navigation on the next, rather than a row that runs off
     the side of a phone. */
  .nav-inner {
    flex-wrap: wrap;
    padding-block: 0.6rem;
    gap: 0.5rem var(--gap);
  }

  .app-rail {
    flex-wrap: wrap;
  }

  .app-rail nav {
    width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 40rem) {
  .nav-links {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  /* Wide price tables stay readable instead of clipping mid-number. */
  table { font-size: 0.75rem; }

  th,
  td { padding: 0.6rem 0.65rem; }

  th { white-space: normal; }

  caption { padding: 0.65rem; }

  /* A visible edge shows the table can be scrolled. */
  .table-frame {
    background:
      linear-gradient(to right, var(--card) 30%, transparent),
      linear-gradient(to left, var(--card) 30%, transparent) 100% 0,
      linear-gradient(to right, rgba(22, 24, 28, 0.12), transparent),
      linear-gradient(to left, rgba(22, 24, 28, 0.12), transparent) 100% 0;
    background-repeat: no-repeat;
    background-size: 3rem 100%, 3rem 100%, 0.6rem 100%, 0.6rem 100%;
    background-attachment: local, local, scroll, scroll;
  }
}

@media (max-width: 40rem) {
  /* The navigation takes the whole second line so the primary action is never
     pushed off the edge of the viewport. */
  .nav-inner > nav { width: 100%; }

  /* Least load-bearing table columns step aside rather than being clipped. */
  .hide-sm { display: none; }
}

/* Grid and flex children that contain code blocks must be allowed to shrink:
   a <pre> reports its longest line as min-content, which otherwise widens the
   whole page on a phone. */
.docs-body,
.docs-rail,
.hero-copy,
.hero-side,
.card,
.app-main,
.workbench {
  min-width: 0;
}

@media (max-width: 40rem) {
  /* On a phone, sideways-scrolling code is worse than wrapped code. */
  .code pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.75rem;
  }
}
