/* Fetchflat — one CSS file. §11 visual system.
   Public marketing pages are always dark. The console (/app, /admin) follows
   the reader's choice: light (default), dark, or the operating system.
   Dark is the base palette in :root; the light palette below is applied both
   by an explicit choice and by the system preference, so the two blocks must
   be kept in step. */
:root {
  --bg: #0B0D10; --surface: #14181E; --text: #E8EDF2; --muted: #8B95A3;
  --accent: #F5C542; --danger: #F07178; --border: #232A33; --radius: 6px;
  /* Amber is a light colour in both themes, so its foreground stays dark.
     --accent is the text colour and darkens on light backgrounds for contrast;
     --accent-solid is the brand fill and stays bright in both themes. */
  --on-accent: #0B0D10; --accent-solid: #F5C542; --accent-hover: #FFD35A;
  /* The terminal card is dark on every surface: it is a picture of a shell. */
  --term-bg: #0E1116; --term-text: #E8EDF2;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, Inter, system-ui, sans-serif;
}
body.light {
  --bg: #FFFFFF; --surface: #F6F7F9; --text: #14181E; --muted: #5B6573; --border: #D9DEE5;
  --accent: #B8860B; --accent-hover: #FFD35A; --danger: #C2334D;
  --term-bg: #14181E; --term-text: #E8EDF2;
}
@media (prefers-color-scheme: light) {
  /* Same palette as body.light, for readers who chose "system". */
  body.system {
    --bg: #FFFFFF; --surface: #F6F7F9; --text: #14181E; --muted: #5B6573; --border: #D9DEE5;
    --accent: #B8860B; --accent-hover: #FFD35A; --danger: #C2334D;
    --term-bg: #14181E; --term-text: #E8EDF2;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--mono); font-size: 14px; line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p.prose, .prose p, .prose li { font-family: var(--sans); font-size: 15px; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; }
/* The landing runs on the wide column; prose pages stay at 880px. Header,
   content and footer all read the same width so every row shares one edge. */
body.wide .wrap { max-width: 1100px; }
h1, h2, h3 { font-weight: 600; line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 34px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin-top: 44px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.amber { color: var(--accent); }
.danger { color: var(--danger); }
code, pre { font-family: var(--mono); }
code { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
pre { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.5; margin: 12px 0; }
pre code { background: none; border: 0; padding: 0; }
.term { background: var(--term-bg); color: var(--term-text); border: 1px solid var(--border); border-radius: var(--radius); }
.term .tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.term .tabs label, .term .tabs a { padding: 8px 14px; cursor: pointer; color: var(--muted); border-right: 1px solid var(--border); font-size: 13px; }
.term .tabs label:hover { color: var(--text); }
.term pre { margin: 0; border: 0; background: transparent; padding: 16px; }
.term input[type=radio] { display: none; }
.term .pane { display: none; }
#t-fetch:checked ~ .panes #p-fetch, #t-extract:checked ~ .panes #p-extract, #t-batch:checked ~ .panes #p-batch { display: block; }
#t-fetch:checked ~ .tabs label[for=t-fetch], #t-extract:checked ~ .tabs label[for=t-extract], #t-batch:checked ~ .tabs label[for=t-batch] { color: var(--accent); }
.top { border-bottom: 1px solid var(--border); background: var(--bg); }
.bar { display: flex; align-items: center; gap: 24px; height: 52px; }
/* Logo (LOGO.md): the word in mono with a 3px amber bar under "flat" only. */
.wordmark { font-family: var(--mono); font-weight: 560; letter-spacing: -0.04em; color: var(--text); font-size: 16px; text-decoration: none; white-space: nowrap; }
.wordmark span { border-bottom: 3px solid var(--accent); padding-bottom: 1px; }
.wordmark em { font-style: normal; font-weight: 400; letter-spacing: 0; }
.wordmark.lg { font-size: 24px; }
.wordmark.sm { font-size: 13px; }
.wordmark.sm span { border-bottom-width: 2px; }
.wordmark:hover { text-decoration: none; }
.links { display: flex; gap: 18px; flex: 1; }
.navtoggle { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.navbtn { display: none; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.navbars, .navbars::before, .navbars::after { display: block; width: 15px; height: 2px; background: var(--accent); border-radius: 2px; }
.navbars { position: relative; }
.navbars::before, .navbars::after { content: ""; position: absolute; left: 0; }
.navbars::before { top: -5px; }
.navbars::after { top: 5px; }
.navscrim { display: none; }
.links a { color: var(--muted); font-size: 13px; }
.links a.on, .links a:hover { color: var(--text); text-decoration: none; }
.right { display: flex; gap: 8px; align-items: center; }
.right form { margin: 0; }
.btn { display: inline-block; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border); font-family: var(--mono); font-size: 13px; cursor: pointer; background: transparent; color: var(--text); transition: color 120ms, background-color 120ms, border-color 120ms; line-height: 1.3; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.amber { background: var(--accent-solid); color: var(--on-accent); border-color: var(--accent-solid); font-weight: 600; }
.btn.amber:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }
textarea { line-height: 1.5; resize: vertical; }
input[type=text], input[type=email], input[type=number], select, textarea { font-family: var(--mono); font-size: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%; max-width: 420px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
form.inline { display: inline; }
form.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
form.row label { margin: 0 0 4px; }
.hero { margin: 56px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.hero .eyebrow { color: var(--accent); font-size: 13px; margin-bottom: 14px; }
.hero h1 { font-size: 38px; margin-bottom: 14px; }
.hero .sub { font-family: var(--sans); font-size: 17px; color: var(--muted); margin: 0 0 22px; }
.hero .ctas { display: flex; gap: 10px; }
.hero .tiny { color: var(--muted); font-size: 12px; margin-top: 12px; }
.tariff { margin: 64px 0 0; }
.tariff .row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tariff .cell { padding: 22px 18px; border-right: 1px solid var(--border); }
.tariff .cell:last-child { border-right: 0; }
.tariff .num { font-size: 44px; color: var(--accent); font-weight: 700; line-height: 1; }
.tariff .lbl { color: var(--muted); margin-top: 6px; font-size: 13px; }
.tariff .cap { color: var(--muted); margin-top: 10px; font-size: 13px; }
.tariffline { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: baseline; margin: 18px 0 0; color: var(--muted); font-size: 14px; }
.tariffline b { color: var(--accent); font-size: 18px; font-weight: 700; margin-right: 4px; }
.chip { display: inline-block; border: 1px solid var(--border); border-radius: var(--radius); padding: 1px 8px; margin-left: 6px; color: var(--muted); font-size: 12px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; min-width: 0; }
.card h3 { margin-bottom: 6px; }
.card p { color: var(--muted); font-family: var(--sans); font-size: 14px; margin: 0 0 12px; }
.card pre { margin: auto 0 0; font-size: 12px; background: var(--bg); max-width: 100%; }
.card .price { font-size: 28px; color: var(--accent); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.err td { color: var(--danger); }
.cmp td:first-child { color: var(--muted); }
.ledger { max-width: 660px; }
.ledger td:first-child, .ledger th:first-child { white-space: nowrap; }
.ledger tr.muted-row td { color: var(--muted); }
.section { margin-top: 56px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 700; color: var(--accent); margin-top: 2px; }
.stat .v.danger { color: var(--danger); }
.stat .v .u { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Segmented filters: buttons in a form, so they work without script */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 18px 0 0; }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg button { font-family: var(--mono); font-size: 12px; line-height: 1; padding: 7px 12px; background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--border); cursor: pointer; transition: color 120ms, background-color 120ms; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .seg button { transition: none; } }

.errchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip.err { border-color: var(--danger); color: var(--danger); text-decoration: none; }
.chip.err code { background: none; border: 0; padding: 0; color: inherit; }
.chip.err:hover { background: var(--surface); text-decoration: none; }
.flash { border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--surface); padding: 10px 14px; border-radius: var(--radius); margin: 18px 0; }
.flash.err { border-left-color: var(--danger); }
.lowbar { border: 1px solid var(--accent); background: var(--surface); padding: 10px 14px; border-radius: var(--radius); margin: 16px 0; }
.setup { margin: 40px 0; max-width: 620px; }
.setup-h1 { font-size: 24px; margin-top: 36px; }

/* First-run steps */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 24px 0 0; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 22px 44px; border-left: 1px solid var(--border); margin-left: 13px; }
.steps > li:last-child { border-left-color: transparent; padding-bottom: 8px; }
.steps > li::before { content: counter(step); position: absolute; left: -13px; top: 0; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--accent); font-size: 12px; display: flex; align-items: center; justify-content: center; }
.steps h3 { margin: 3px 0 4px; font-size: 15px; }
.steps p { margin: 0 0 10px; font-family: var(--sans); font-size: 14px; }

/* Compact tariff reminder for the first run */
.tariffmini { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.tariffmini > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); }
.tariffmini .c { font-size: 18px; font-weight: 700; color: var(--accent); }
.tariffmini .l { font-size: 12px; color: var(--muted); }
.tariffmini .f { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; word-break: break-all; }

/* Language samples: CSS-only tabs, no script needed to switch */
.samples { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 12px 0; overflow: hidden; }
.samples > input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.samples .tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.samples .tabs label { padding: 8px 14px; cursor: pointer; color: var(--muted); border-right: 1px solid var(--border); font-size: 13px; transition: color 120ms; }
.samples .tabs label:hover { color: var(--text); }
.samples .pane { display: none; padding: 14px 16px 12px; }
.samples pre { margin: 0 0 10px; border: 0; background: transparent; padding: 0; font-size: 12.5px; }
#s-curl:checked ~ .panes #p-curl,
#s-python:checked ~ .panes #p-python,
#s-js:checked ~ .panes #p-js,
#s-go:checked ~ .panes #p-go,
#s-php:checked ~ .panes #p-php { display: block; }
#s-curl:checked ~ .tabs label[for=s-curl],
#s-python:checked ~ .tabs label[for=s-python],
#s-js:checked ~ .tabs label[for=s-js],
#s-go:checked ~ .tabs label[for=s-go],
#s-php:checked ~ .tabs label[for=s-php] { color: var(--accent); background: var(--bg); }
.samples > input[type=radio]:focus-visible + input + input + input + input ~ .tabs label[for=s-curl] { outline: 2px solid var(--accent); }
@media (prefers-reduced-motion: reduce) { .samples .tabs label { transition: none; } }
.setup ol { padding-left: 20px; }
.setup li { margin: 10px 0; }
.keybox { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0; }
.keybox code { font-size: 14px; word-break: break-all; }
.e404 { max-width: 640px; margin: 88px 0 48px; }
.e404 .code { font-size: 84px; line-height: 1; font-weight: 700; color: var(--accent); letter-spacing: -0.03em; }
.e404 h1 { font-size: 26px; margin: 14px 0 10px; }
.e404 .ctas { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 26px; }
.e404 .note { border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.login { max-width: 380px; margin: 80px auto; }
.login h1 { font-size: 22px; }
.login input { max-width: 100%; }
.login .btn { width: 100%; text-align: center; margin-top: 10px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 18px 0; font-size: 12px; }
.divider:before, .divider:after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.theme { display: flex; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.theme button { font-family: var(--mono); font-size: 11px; line-height: 1; padding: 6px 8px; background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--border); cursor: pointer; transition: color 120ms, background-color 120ms; }
.theme button:last-child { border-right: 0; }
.theme button:hover { color: var(--text); }
.theme button[aria-pressed="true"] { background: var(--surface); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .theme button { transition: none; } }

.foot { border-top: 1px solid var(--border); margin-top: 72px; padding: 22px 0; font-size: 13px; color: var(--muted); }
.sitemap { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; padding-bottom: 20px; }
.sitemap h4 { margin: 0 0 8px; font-size: 12px; font-weight: 500; color: var(--text); letter-spacing: 0.02em; }
.sitemap a { display: block; padding: 3px 0; color: var(--muted); }
.sitemap a:hover { color: var(--accent); text-decoration: none; }
.footbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.foot .sitemap + .footbar { border-top: 1px solid var(--border); padding-top: 16px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.plan { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.plan.on { border-color: var(--accent); }
.plan .name { color: var(--muted); font-size: 13px; }
.plan .price { font-size: 30px; color: var(--accent); font-weight: 700; margin: 4px 0; }
.plan ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.small { font-size: 12px; color: var(--muted); }
details { border-bottom: 1px solid var(--border); padding: 10px 0; }
details summary { cursor: pointer; font-family: var(--mono); font-size: 14px; color: var(--text); }
details summary::marker { color: var(--accent); }
details summary:hover { color: var(--accent); }
details[open] summary { color: var(--accent); }
details p { margin: 8px 0 2px; }
.docs h2 { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.docs h3 { margin-top: 26px; color: var(--accent); }
.copybtn { margin-left: 8px; }
@media (max-width: 800px) {
  /* minmax(0, …), not 1fr: an auto-sized track takes its minimum from the
     widest unbreakable child, so one long line in a <pre> stretches the track
     and the whole page scrolls sideways. This is the same reason the desktop
     tracks are written this way. */
  .hero, .split, .cards, .plans { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sitemap { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .tariffmini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Four numbers read better two-up than stacked down the screen. */
  .tariff .row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tariff .cell { padding: 16px 14px; border-bottom: 1px solid var(--border); }
  .tariff .cell:nth-child(2n) { border-right: 0; }
  .tariff .cell:nth-last-child(-n+2) { border-bottom: 0; }
  .tariff .num { font-size: 34px; }

  /* The header gets a real menu. Dropping .links outright left /app and /admin
     with no way to reach Keys, Usage or Billing at all: the console has no
     other navigation, so the only route was editing the URL. The panel is a
     row of the wrapped header, so it pushes the page down instead of covering
     it, and closes on navigation because the checkbox resets on load. */
  .bar { flex-wrap: wrap; height: auto; gap: 10px 14px; padding: 10px 0; }
  .navbtn { display: inline-flex; position: relative; z-index: 60; }
  .navtoggle { pointer-events: auto; }
  .navtoggle:focus-visible + .navbtn { outline: 2px solid var(--accent); outline-offset: 1px; }
  .navtoggle:checked + .navbtn { border-color: var(--accent); color: var(--accent); }

  /* Drawer: slides in from the right over the page. The scrim is a second
     label for the same checkbox, so tapping outside closes it without script. */
  .navscrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); opacity: 0; visibility: hidden; transition: opacity 180ms; z-index: 40; }
  .navtoggle:checked ~ .navscrim { opacity: 1; visibility: visible; }
  .links { display: flex; position: fixed; top: 0; right: 0; z-index: 50; height: 100%; height: 100dvh; width: min(78vw, 300px); flex-direction: column; gap: 0; padding: 68px 20px 20px; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -18px 0 40px rgba(0, 0, 0, 0.35); overflow-y: auto; transform: translateX(100%); transition: transform 200ms ease; }
  .navtoggle:checked ~ .links { transform: translateX(0); }
  .links a { padding: 13px 2px; border-bottom: 1px solid var(--border); font-size: 15px; color: var(--text); }
  .links a:last-child { border-bottom: 0; }
  .links a.on { color: var(--accent); }
  .wordmark { padding: 8px 0; }
  .right { margin-left: auto; }

  /* Wide content scrolls inside itself rather than widening the document. */
  /* min-width keeps a narrow table filling the column; max-width caps the box
     at the column so a wide one scrolls inside itself instead of the page. */
  table { display: block; width: max-content; min-width: 100%; max-width: 100%; overflow-x: auto; }

  /* Thumb-sized targets. Desktop spacing is unchanged. */
  .btn { padding: 9px 15px; }
  .btn.sm { padding: 6px 11px; }
  .sitemap a { padding: 8px 0; }
  /* The console footer's inline links are the only nav on small screens for
     Terms and Privacy, so they get real height too. */
  .footbar a { display: inline-block; padding: 8px 2px; }
  details summary { padding: 8px 0; }
  .theme button { padding: 13px 11px; }
  .seg button { padding: 11px 14px; }

  .hero { margin-top: 32px; }
  .hero h1 { font-size: 30px; }
  .foot { margin-top: 48px; }
  h2 { margin-top: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .links, .navscrim { transition: none; }
}

@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  h1, .hero h1 { font-size: 26px; }
  .hero .sub { font-size: 16px; }
  .hero .ctas { flex-wrap: wrap; }
  .hero .ctas .btn { flex: 1 1 auto; text-align: center; }
  .plan .price, .card .price { font-size: 24px; }
  .login { margin: 40px auto; }
  .e404 { margin-top: 52px; }
  .e404 .code { font-size: 62px; }
  .e404 .ctas .btn { flex: 1 1 auto; text-align: center; }
  .setup-h1 { font-size: 21px; }
  .steps > li { padding-left: 38px; }
}
