/* The app's palette, from apps/mobile/src/tokens.ts. scripts/assert-tokens.mjs
   fails the gate on any colour in this file that is not in that table. */
:root {
  color-scheme: light;
  --page: #ffffff;
  --raised: #f4f6f9;
  --sunken: #e7eaee;
  --quiet: #edf1f7;
  --ink: #0f2846;
  --text-2: #5a6572;
  --text-3: #6b7480;
  --action: #123a6b;
  --on-action: #ffffff;
  --accent: #5b8fd4;
  --hairline: #dde2e9;
  --edge: #4e5761;
  --good: #0a5c2e;
  /* Surfaces that stay dark in both themes. The old band used var(--ink), which
     flips to near-white in dark mode, so the one dark band rendered white. */
  --hero: #0f2846;
  --on-hero: #ffffff;
  --on-hero-2: #a8b4c3;
  --on-hero-good: #4cc38a;
  --shadow: color-mix(in srgb, #0f2846 14%, transparent);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --shell: 72rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --block: clamp(4rem, 9vw, 7rem);
  --r: 16px;
  --r-sm: 8px;
}

/* Three states: the device setting until somebody chooses, then the toggle's
   choice either way. theme.js sets data-theme before the first paint. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f1620;
    --raised: #18212e;
    --sunken: #0a1018;
    --quiet: #1e2a3a;
    --ink: #e8edf4;
    --text-2: #a8b4c3;
    --text-3: #93a0b1;
    --action: #5b8fd4;
    --on-action: #0f2846;
    --hairline: #2a3444;
    --edge: #8a97a8;
    --good: #4cc38a;
    --hero: #1e2a3a;
    --shadow: color-mix(in srgb, #000000 45%, transparent);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1620;
  --raised: #18212e;
  --sunken: #0a1018;
  --quiet: #1e2a3a;
  --ink: #e8edf4;
  --text-2: #a8b4c3;
  --text-3: #93a0b1;
  --action: #5b8fd4;
  --on-action: #0f2846;
  --hairline: #2a3444;
  --edge: #8a97a8;
  --good: #4cc38a;
  --hero: #1e2a3a;
  --shadow: color-mix(in srgb, #000000 45%, transparent);
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { color: var(--ink); text-wrap: balance; }
h2 { font-size: clamp(1.9rem, 1.35rem + 2vw, 2.85rem); line-height: 1.06; letter-spacing: -0.03em; font-weight: 800; }
h3 { font-size: 1.2rem; line-height: 1.3; letter-spacing: -0.01em; font-weight: 700; }
a { color: var(--action); text-underline-offset: 0.2em; }
a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { max-width: var(--shell); margin-inline: auto; padding-inline: var(--gutter); }
.block { padding-block: var(--block); }
.eyebrow {
  font: 600 0.75rem/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--action);
}

.skip {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 20;
  padding: 0.6rem 1rem;
  border-radius: var(--r-sm);
  background: var(--action);
  color: var(--on-action);
}
.skip:focus { top: 0.5rem; }

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

/* 44px minimum, the web's floor, for the same reason the app holds 56dp. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.4rem;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font: 600 1rem/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--action); color: var(--on-action); }
.btn-primary:hover { filter: brightness(1.15); }
.btn-ghost { color: var(--ink); border-color: var(--hairline); }
.btn-ghost:hover { border-color: var(--edge); }
.btn-invert { background: var(--on-hero); color: var(--hero); }
.btn-invert:hover { filter: brightness(0.94); }
.btn-sm { min-height: 44px; padding: 0 1rem; font-size: 0.9rem; }

/* ------------------------------------------------------------------- bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--page);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.bar-in { display: flex; align-items: center; gap: 1.75rem; min-height: 4rem; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.bar-end { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.nav { display: flex; gap: 1.75rem; margin-right: 0.75rem; }
.nav a { color: var(--text-2); text-decoration: none; font-size: 0.9375rem; font-weight: 500; }
.nav a:hover { color: var(--ink); }
.crumb { color: var(--text-2); font-size: 0.9375rem; padding-left: 1rem; border-left: 1px solid var(--hairline); }

/* Hidden until theme.js runs, so a page with scripts off never shows a control
   that does nothing. The class would otherwise beat the hidden attribute. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { border-color: var(--edge); }
.theme-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .to-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .to-dark { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .to-light { display: block; }
}
:root[data-theme="dark"] .theme-toggle .to-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .to-light { display: block; }

@media (max-width: 52rem) { .nav { display: none; } }
@media (max-width: 30rem) {
  .crumb, .wide { display: none; }
  .bar-end { gap: 0.6rem; }
}

/* ----------------------------------------------------------------- intro */

.intro {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4rem);
  align-items: center;
  padding-block: clamp(3.5rem, 8vw, 6.5rem) clamp(3rem, 7vw, 5.5rem);
}
@media (min-width: 62rem) {
  .intro { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); }
}
.intro h1 {
  margin-top: 1.25rem;
  font-size: clamp(2.4rem, 1.4rem + 4.2vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 800;
}
.lead {
  margin-top: 1.4rem;
  max-width: 34rem;
  font-size: clamp(1.125rem, 1rem + 0.45vw, 1.3rem);
  color: var(--text-2);
}
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  font: 500 0.8125rem/1.4 var(--mono);
  color: var(--text-2);
}
.facts li::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--good);
  vertical-align: middle;
}

/* The invoice, on top of the two before it: the same stack of numbers the mark
   is the edge of. Real text rather than a picture, so it is crisp at any size. */
.stack {
  --off: 1.25rem;
  position: relative;
  justify-self: center;
  width: min(100%, 25rem);
  padding: calc(var(--off) * 2) calc(var(--off) * 2) 0 0;
}
.sheet { background: var(--page); border: 1px solid var(--hairline); border-radius: var(--r-sm); }
.sheet-back {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(100% - var(--off) * 2);
  height: 88%;
  padding: 0.35rem 0.6rem;
  text-align: right;
  font: 600 0.68rem/1 var(--mono);
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--raised);
}
.sheet-1 { top: var(--off); right: var(--off); background: var(--page); }
.invoice {
  position: relative;
  padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: 0 1px 2px var(--shadow), 0 18px 40px -12px var(--shadow);
}
/* The perforation a receipt book tears along. */
.invoice::before {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  top: 0.55rem;
  height: 4px;
  background: radial-gradient(circle, var(--sunken) 1.6px, transparent 2px) 0 50% / 9px 4px repeat-x;
}
.invoice .eyebrow { color: var(--text-3); }
.inv-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--hairline);
}
.inv-no { margin-top: 0.4rem; font: 700 1.5rem/1.2 var(--mono); letter-spacing: 0.02em; }
.inv-to { text-align: right; font-size: 0.8rem; color: var(--text-2); }
.inv-to b { display: block; margin-top: 0.2rem; font-size: 0.95rem; color: var(--ink); }
.inv-lines { width: 100%; margin: 0.4rem 0; border-collapse: collapse; font-size: 0.875rem; }
.inv-lines td { padding: 0.55rem 0; border-bottom: 1px dashed var(--hairline); }
.inv-lines td + td { padding-left: 1rem; text-align: right; font-family: var(--mono); white-space: nowrap; }
.inv-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 0.6rem; font-weight: 600; }
.inv-total b { font: 700 1.5rem/1 var(--mono); }
.inv-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem 1rem; margin-top: 1.25rem; }
.stamp {
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
  border: 1.5px solid var(--good);
  border-radius: 4px;
  color: var(--good);
  font: 700 0.7rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(-3deg);
}
.inv-from { font-size: 0.8rem; color: var(--text-3); }

@media (max-width: 30rem) {
  .actions .btn { flex: 1 1 100%; }
  .stack { --off: 0.95rem; }
  .sheet-back { font-size: 0.6rem; padding: 0.2rem 0.45rem; }
  .invoice { padding: 1.4rem 1.1rem 1.1rem; }
  .inv-no, .inv-total b { font-size: 1.25rem; }
}

/* --------------------------------------------------------------- problem */

.problem { border-block: 1px solid var(--hairline); }
.statement {
  max-width: 22ch;
  font-size: clamp(1.9rem, 1.2rem + 2.8vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
  text-wrap: balance;
}
.statement span { color: var(--text-3); }
.statement-sub { margin-top: 1.5rem; max-width: 36rem; font-size: 1.15rem; color: var(--text-2); }

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

.section-head { display: grid; gap: 0.9rem; max-width: 42rem; margin-bottom: clamp(2rem, 4vw, 3.25rem); }
.section-head p:not(.eyebrow) { font-size: 1.125rem; color: var(--text-2); }

.band { background: var(--raised); border-block: 1px solid var(--hairline); }

.split { display: grid; gap: 2rem; }
@media (min-width: 56rem) {
  .split { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 5rem; align-items: start; }
  .split .section-head { position: sticky; top: 6rem; margin-bottom: 0; }
}

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

/* Numbered because a sale happens in this order. */
.steps { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; }
@media (min-width: 52rem) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; } }
.step {
  display: grid;
  align-content: start;
  gap: 0.8rem;
  padding: 1.75rem;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  background: var(--raised);
}
.step-n { font: 600 0.75rem/1 var(--mono); letter-spacing: 0.1em; color: var(--text-3); }
.step-art {
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--page);
  font: 600 0.9rem/1.35 var(--mono);
  overflow-wrap: anywhere;
}
.step p:last-child { color: var(--text-2); }

/* --------------------------------------------------------------- offline */

.offline { background: var(--hero); color: var(--on-hero); }
.offline-in { display: grid; gap: clamp(2.5rem, 5vw, 4rem); align-items: center; }
@media (min-width: 56rem) { .offline-in { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.offline h2 { margin-top: 1rem; color: var(--on-hero); }
.offline .eyebrow { color: var(--accent); }
.offline-copy p:not(.eyebrow) { margin-top: 1.25rem; max-width: 30rem; font-size: 1.125rem; color: var(--on-hero-2); }
.timeline {
  display: grid;
  gap: 1.2rem;
  margin: 0;
  padding: 1.75rem;
  list-style: none;
  border: 1px solid color-mix(in srgb, var(--on-hero) 16%, transparent);
  border-radius: var(--r);
  background: color-mix(in srgb, #000000 18%, transparent);
}
.timeline li {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 1rem;
  font: 0.95rem/1.45 var(--mono);
  color: var(--on-hero-2);
}
.timeline time { font-weight: 600; color: var(--on-hero); }
.timeline .done { color: var(--on-hero-good); }
.timeline .done time { color: var(--on-hero-good); }

/* ----------------------------------------------------------------- buyer */

.buyer { display: grid; gap: clamp(2.5rem, 5vw, 4rem); align-items: center; }
@media (min-width: 56rem) {
  .buyer { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .buyer .msg { order: -1; }
}
.buyer-copy h2 { margin-top: 1rem; }
.buyer-copy > p:not(.eyebrow) { margin-top: 1.1rem; font-size: 1.125rem; color: var(--text-2); }

.msg { justify-self: center; width: 100%; max-width: 24rem; margin: 0; }
.msg figcaption {
  margin-bottom: 0.75rem;
  font: 600 0.75rem/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
/* An incoming message, squared at the corner it came from. pre-line keeps the
   lines composeMessage writes and collapses the indentation around them. */
.msg-bubble {
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--hairline);
  border-radius: 4px var(--r) var(--r) var(--r);
  background: var(--raised);
  box-shadow: 0 18px 40px -12px var(--shadow);
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.msg-link { color: var(--action); text-decoration: underline; text-underline-offset: 0.2em; }

/* ----------------------------------------------------------------- money */

.formats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.format { padding: 1.4rem 1.5rem; border: 1px solid var(--hairline); border-radius: var(--r); background: var(--raised); }
.format b { display: block; font: 700 clamp(1.5rem, 1.2rem + 1vw, 2rem)/1.1 var(--mono); letter-spacing: -0.01em; }
.format span { display: block; margin-top: 0.5rem; font-size: 0.9rem; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.chips li {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--text-2);
}
.chips b { font-family: var(--mono); font-weight: 700; color: var(--ink); }
.chips .more { border-style: dashed; }

/* ------------------------------------------------------------------- faq */

.faq { border-top: 1px solid var(--hairline); }
.faq details { border-bottom: 1px solid var(--hairline); }
.faq summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 44px;
  padding: 1.1rem 0;
  list-style: none;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  display: grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  color: var(--action);
}
.faq details[open] summary::after { content: "\2212"; }
.faq details p { max-width: 40rem; padding-bottom: 1.25rem; color: var(--text-2); }

/* ---------------------------------------------------------------- closer */

.closer {
  display: grid;
  justify-items: center;
  gap: 1.1rem;
  padding: clamp(2.75rem, 7vw, 5rem) var(--gutter);
  border-radius: calc(var(--r) * 1.5);
  background: var(--hero);
  text-align: center;
}
.closer img { width: 56px; height: 56px; border-radius: 12px; }
.closer h2 { color: var(--on-hero); }
.closer p { max-width: 32rem; color: var(--on-hero-2); }
.closer .btn { margin-top: 0.5rem; }
.closer .fine { font-size: 0.875rem; }

/* ---------------------------------------------------------------- footer */

.foot { padding-block: 3.5rem 2.5rem; border-top: 1px solid var(--hairline); }
.foot-cols { display: grid; gap: 2.5rem; }
@media (min-width: 48rem) { .foot-cols { grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); } }
.foot-brand p { margin-top: 0.9rem; max-width: 17rem; font-size: 0.9375rem; color: var(--text-2); }
.foot h2 {
  margin-bottom: 1rem;
  font: 600 0.72rem/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.foot ul { display: grid; gap: 0.65rem; margin: 0; padding: 0; list-style: none; }
.foot a { color: var(--text-2); text-decoration: none; font-size: 0.9375rem; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.foot .brand { color: var(--ink); font-size: 1.05rem; }
.foot-note {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.8125rem;
  color: var(--text-3);
}

/* ------------------------------------------------------- reference pages */

/* Privacy, terms and contact are read to answer a question, so they keep a
   reading measure. .hero is shared with the API's "Not published yet" page,
   which has no .doc around it. */
.hero { max-width: 46rem; margin-inline: auto; padding: clamp(3rem, 7vw, 5rem) var(--gutter) 2.5rem; }
.hero h1 { font-size: clamp(2.2rem, 1.5rem + 3vw, 3.4rem); line-height: 1.04; letter-spacing: -0.035em; font-weight: 800; }
.hero > p:not(.lead) { margin-top: 1.25rem; }

.doc > section, .doc > nav { max-width: 46rem; margin-inline: auto; padding-inline: var(--gutter); }
.doc > section { padding-block: 2.5rem; border-bottom: 1px solid var(--hairline); scroll-margin-top: 5rem; }
.doc > .hero { padding-top: clamp(3rem, 7vw, 5rem); }
.doc > section:last-child { padding-bottom: var(--block); border-bottom: 0; }
.doc h2 { margin-bottom: 1rem; font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.015em; font-weight: 700; }
.doc p, .doc li { color: var(--text-2); }
.doc p + p { margin-top: 0.9rem; }
/* The legal pages are lists of terms. Spaced so each item reads as its own
   point, and indented enough for the bullet and no more on a narrow phone. */
.doc ul { display: grid; gap: 0.75rem; margin: 0; padding-left: 1.25rem; }
.doc ul + p, .doc p + ul { margin-top: 0.9rem; }
.doc strong { font-weight: 700; color: var(--ink); }

.answers { margin: 2rem 0 0; border-top: 1px solid var(--hairline); }
.answers dt { padding-top: 1rem; font-weight: 700; color: var(--ink); }
.answers dd { margin: 0.25rem 0 0; padding-bottom: 1rem; border-bottom: 1px solid var(--hairline); color: var(--text-2); }
.answers dd a { white-space: nowrap; }
@media (min-width: 42rem) {
  .answers { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); column-gap: 1.5rem; }
  .answers dt, .answers dd { margin: 0; padding-block: 1rem; border-bottom: 1px solid var(--hairline); }
}

.jump { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-block: 1.5rem; border-bottom: 1px solid var(--hairline); }
.jump a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.9rem;
  text-decoration: none;
}
.jump a:hover { border-color: var(--edge); }

.doc > .raised { margin-block: 1.5rem; border-bottom: 0; border-radius: var(--r); background: var(--raised); }
@media (max-width: 46rem) { .doc > .raised { border-radius: 0; } }

.pending {
  padding: 0.8rem 1rem;
  border: 1px dashed var(--edge);
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  color: var(--text-2);
}
.version { font-size: 0.875rem; color: var(--text-3); }

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