/* Toknx
   Same system as parahuman.net: black, off-white, Mars red. Syne for display,
   Inter for reading, JetBrains Mono for data. Fonts are served from /ui/fonts
   (SIL Open Font License) so the page needs nothing outside its own origin. */

@font-face { font-family: "Syne"; src: url("fonts/syne.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Inter"; src: url("fonts/inter.woff2") format("woff2"); font-weight: 300 600; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-2: #111113;
  --bg-3: #18181b;
  --plate: #000;
  --line: #222226;
  --line-2: #2f2f35;
  --ink: #ece9e2;
  --ink-2: #b4b1a9;
  --ink-3: #78766f;
  --red: #d2451f;
  --red-2: #ff5a2e;
  --red-glow: rgba(210, 69, 31, 0.16);
  --ok: #7fb069;
  --bad: #ff6b4a;
  --on-red: #fff;
  --warn: #e0a526;
  /* names older inline styles and app.js still use */
  --mut: var(--ink-3); --fg: var(--ink); --acc: var(--red);

  --display: "Syne", "Space Grotesk", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --max: 1120px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f2ec;
  --bg-2: #ece9e1;
  --bg-3: #e2dfd6;
  --plate: #faf9f5;
  --line: #d9d5ca;
  --line-2: #c4bfb2;
  --ink: #141413;
  --ink-2: #45433e;
  --ink-3: #75726a;
  --red: #c23a15;
  --red-2: #a8300f;
  --red-glow: rgba(194, 58, 21, 0.10);
  --ok: #3f7a2a;
  --bad: #b3261e;
  --warn: #8a5d00;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); scroll-padding-top: 72px; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 400 15.5px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
::selection { background: var(--red); color: #fff; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 0.2em; text-decoration-thickness: 1px; transition: text-decoration-color .2s, color .2s; }
a:hover { text-decoration-color: var(--red-2); }
code, pre, kbd { font-family: var(--mono); font-size: 13px; }
code { background: var(--bg-3); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
header.top .in { max-width: var(--max); margin: 0 auto; padding: 0 16px; min-height: 56px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font: 500 13px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand::before { content: ""; width: 8px; height: 8px; background: var(--red); }
.brand .tag { font-size: 10.5px; letter-spacing: 0.14em; color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 55%, transparent); border-radius: 3px; padding: 2px 6px; }
header.top nav { display: flex; gap: 2px; align-items: center; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
header.top nav::-webkit-scrollbar { display: none; }
header.top nav button, header.top nav a {
  background: none; border: 0; border-radius: 4px; padding: 7px 10px; cursor: pointer; white-space: nowrap;
  font: 400 12px var(--mono); letter-spacing: 0.04em; color: var(--ink-3); text-decoration: none; transition: color .2s, background .2s;
}
header.top nav button:hover, header.top nav a:hover { color: var(--ink); background: var(--bg-3); }
header.top nav button.on { color: var(--ink); background: var(--bg-3); box-shadow: inset 0 -2px 0 var(--red); }
#theme { font-size: 13px; min-width: 34px; }
body.signed-out header.top nav button[data-v] { display: none; }

/* ---------- layout ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 0 16px 24px; display: grid; gap: 20px; }
main > *, .hero > *, .grid2 > *, .row > * { min-width: 0; }
main > section { background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 26px; }
main > section:first-of-type { margin-top: 8px; }

h1 { font-family: var(--display); font-weight: 700; font-size: clamp(44px, 7.2vw, 96px); line-height: 0.96; letter-spacing: -0.035em; margin: 0 0 44px; }
h1 .dot { color: var(--red); }
h1 .soft { color: var(--ink-3); }
h2 { font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 14px; }
h3 { font-family: var(--display); font-weight: 600; font-size: 21px; letter-spacing: -0.015em; line-height: 1.2; margin: 0; }
.kicker { font: 500 12px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--red); margin: 0 0 22px; }
.kicker::before { content: ""; display: inline-block; width: 28px; height: 1px; background: var(--red); margin-right: 14px; vertical-align: 4px; }
.lead { color: var(--ink-2); font-size: 18px; line-height: 1.6; max-width: 54ch; margin: 0 0 30px; }
.mut { color: var(--ink-3); font-size: 13.5px; }
.bad { color: var(--bad); } .ok { color: var(--ok); }

/* ---------- controls ---------- */
label { display: block; font: 400 12px var(--mono); letter-spacing: 0.03em; color: var(--ink-3); margin: 14px 0 6px; }
label .mut { font-size: 12px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font: 400 14px/1.5 var(--sans); letter-spacing: 0; color: var(--ink-2); }
label.check input { width: auto; margin-top: 4px; accent-color: var(--red); }
input, select, textarea {
  width: 100%; max-width: 100%; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--bg); color: var(--ink); font: 15px var(--sans); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
::placeholder { color: var(--ink-3); opacity: .8; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }

button.go, .btn {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; padding: 11px 18px; cursor: pointer;
  background: var(--red); color: var(--on-red); border: 1px solid var(--red); border-radius: 4px;
  font: 500 13px var(--mono); letter-spacing: 0.04em; text-decoration: none; transition: background .2s, border-color .2s, transform .2s var(--ease);
}
button.go:hover, .btn:hover { background: var(--red-2); border-color: var(--red-2); transform: translateY(-1px); }
button.go:active { transform: translateY(0); }
button.go.ghost, .btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
button.go.ghost:hover, .btn.ghost:hover { border-color: var(--red); background: var(--bg-2); }
button.sm {
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); padding: 6px 11px; border-radius: 4px; cursor: pointer;
  font: 400 12px var(--mono); letter-spacing: 0.03em; transition: border-color .2s, color .2s;
}
button.sm:hover { border-color: var(--red); color: var(--ink); }
button:disabled { opacity: .5; cursor: progress; transform: none !important; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 0.2em; }
button.link:hover { color: var(--ink); text-decoration-color: var(--red-2); }

/* ---------- tables, notes, output ---------- */
.wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; margin-top: 12px; background: var(--bg); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { font: 400 11px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); background: var(--bg-2); }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
td { color: var(--ink-2); }
tr:last-child td { border-bottom: 0; }
.need { border: 1px solid var(--line-2); border-left: 2px solid var(--red); background: var(--bg); padding: 16px 18px; margin: 16px 0; border-radius: 4px; }
.need b.hd { display: block; font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; color: var(--ink); }
.need details { margin-top: 8px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--plate); border: 1px solid var(--line); padding: 14px 16px; border-radius: 4px; max-height: 340px; overflow: auto; margin: 12px 0 0; line-height: 1.6; color: var(--ink-2); }
details summary { cursor: pointer; font: 400 12.5px var(--mono); color: var(--ink-3); }
details summary:hover { color: var(--ink); }
#msg { font-size: 14px; border-radius: 4px; }
#msg:not(:empty) { padding: 12px 16px; border: 1px solid var(--line-2); border-left: 2px solid var(--ink-3); background: var(--bg-2); margin-top: 12px; }
#msg.ok:not(:empty) { border-left-color: var(--ok); }
#msg.bad:not(:empty) { border-left-color: var(--bad); }

/* ---------- landing ---------- */
main > section#intro { background: none; border: 0; border-radius: 0; padding: 0; position: relative; }
#intro::before { content: ""; position: absolute; inset: -80px -30% auto -30%; height: 620px; background: radial-gradient(50% 55% at 20% 30%, var(--red-glow), transparent 70%); pointer-events: none; z-index: -1; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 0 64px; align-items: start; padding: 96px 0 80px; border-bottom: 1px solid var(--line); }
.hero .h-top { grid-column: 1 / -1; }
.hero .lead { margin-top: 4px; }
.hero .code-col { margin-top: 6px; min-width: 0; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; }
.cta button.go { margin-top: 0; }
.live { display: inline-flex; align-items: flex-start; gap: 10px; margin-top: 26px; font: 400 12.5px var(--mono); color: var(--ink-3); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex: none; margin-top: 6px; box-shadow: 0 0 0 4px var(--red-glow); animation: pulse 2.4s ease-in-out infinite; }
.live:empty { display: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }

.code-wrap { position: relative; }
.code-wrap::before, .code-wrap::after { content: ""; position: absolute; width: 22px; height: 22px; border: 2px solid var(--red); pointer-events: none; }
.code-wrap::before { left: -8px; top: -8px; border-right: 0; border-bottom: 0; }
.code-wrap::after { right: -8px; bottom: -8px; border-left: 0; border-top: 0; }
.code { border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; background: var(--plate); }
.code .tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.code .tabs button { background: none; border: 0; border-right: 1px solid var(--line); color: var(--ink-3); padding: 10px 16px; cursor: pointer; font: 400 12px var(--mono); letter-spacing: 0.04em; transition: color .2s, background .2s; }
.code .tabs button:hover { color: var(--ink); }
.code .tabs button.on { color: var(--ink); background: var(--bg-2); box-shadow: inset 0 -2px 0 var(--red); }
.code pre { border: 0; border-radius: 0; margin: 0; background: transparent; max-height: none; font-size: 12.5px; line-height: 1.7; white-space: pre; overflow-x: auto; padding: 20px; color: var(--ink); }
.code .k { color: var(--red-2); } .code .s { color: var(--ink-2); } .code .c { color: var(--ink-3); font-style: italic; }

ol.flow { list-style: none; margin: 0; padding: 0; }
ol.flow li { display: grid; grid-template-columns: 56px minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: baseline; padding: 26px 8px; border-bottom: 1px solid var(--line); transition: background .2s, padding-left .3s var(--ease); }
ol.flow li:hover { background: var(--bg-2); padding-left: 16px; }
ol.flow .n { font: 400 13px var(--mono); color: var(--red); }
ol.flow h3 { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; }
ol.flow p { margin: 0; color: var(--ink-2); font-size: 15.5px; }
.sec-h { font: 500 12px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--red); margin: 56px 0 10px; }

dl.specs { margin: 0 0 64px; border-top: 2px solid var(--red); display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; }
dl.specs div { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
dl.specs dt { font: 400 12px var(--mono); color: var(--ink-3); padding-top: 3px; }
dl.specs dd { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
dl.specs dd strong { font: 500 13.5px var(--mono); color: var(--ink); }

/* ---------- auth ---------- */
.auth { max-width: 540px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.seg button { background: none; border: 0; color: var(--ink-3); padding: 9px 16px; cursor: pointer; font: 400 12.5px var(--mono); letter-spacing: 0.04em; transition: color .2s, background .2s; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--bg-3); color: var(--ink); box-shadow: inset 0 -2px 0 var(--red); }
.pwbox { position: relative; }
.pwbox input { padding-right: 64px; }
.pwbox .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--ink-3); font: 400 11.5px var(--mono); cursor: pointer; padding: 6px; }
.pwbox .eye:hover { color: var(--ink); }
ul.rules { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 3px; font: 400 12.5px var(--mono); }
ul.rules li { color: var(--ink-3); } ul.rules li::before { content: "○  "; }
ul.rules li.pass { color: var(--ok); } ul.rules li.pass::before { content: "✓  "; }
ul.rules li.fail { color: var(--bad); } ul.rules li.fail::before { content: "✕  "; }
.meter { height: 3px; border-radius: 0; background: var(--line); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s, background .2s; }

/* ---------- signed in ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel { border: 1px solid var(--line); border-top: 2px solid var(--red); background: var(--bg); border-radius: 0 0 4px 4px; padding: 18px 20px; }
.panel h2 { font-size: 20px; }
.stat { display: flex; flex-wrap: wrap; gap: 14px; }
.stat div { min-width: 120px; }
.stat b { display: block; font: 700 26px/1.2 var(--display); letter-spacing: -0.02em; }
body.signed-out .only-in, body.signed-in .only-out { display: none !important; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.bar h2 { margin: 0; }

footer.bottom { max-width: var(--max); margin: 40px auto 0; padding: 28px 16px 64px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; font: 400 12px/1.6 var(--mono); color: var(--ink-3); }
footer.bottom nav { display: flex; gap: 18px; }
footer.bottom a { color: var(--ink-2); }

/* ---------- getting started ---------- */
header.top nav button.nav-cta { color: var(--ink); border: 1px solid var(--line-2); margin-left: 6px; }
header.top nav button.nav-cta:hover { border-color: var(--red); }
.assure { font: 400 12.5px var(--mono); color: var(--ink-3); margin: 16px 0 0; letter-spacing: 0.02em; }
.api-ref { display: inline-block; margin-top: 16px; font: 400 12.5px var(--mono); color: var(--ink-3); text-decoration: none; }
.api-ref:hover { color: var(--ink); }
.compat { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 44px; padding: 34px 0 30px; border-bottom: 1px solid var(--line); }
.compat .lbl { font: 400 12px var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); flex-basis: 100%; }
.compat .mark { font: 700 clamp(28px, 4.2vw, 44px)/1 var(--display); letter-spacing: -0.03em; color: var(--ink); }
.compat .mark + .mark::before { content: "/"; color: var(--red); font-weight: 500; margin-right: 44px; }

ol.wiz { list-style: none; margin: 14px 0 0; padding: 0; }
ol.wiz > li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
ol.wiz > li:last-child { padding-bottom: 0; }
ol.wiz .n { font: 500 13px var(--mono); color: var(--red); padding-top: 2px; }
ol.wiz > li > div > b { font: 600 17px var(--display); letter-spacing: -0.01em; color: var(--ink); }
ol.wiz p b { color: var(--ink); font-weight: 600; }
ol.wiz p { margin: 6px 0 0; }
ol.wiz .btn { margin-top: 12px; }
.pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.pick button { text-align: left; background: var(--bg); border: 1px solid var(--line-2); border-radius: 4px; padding: 12px 14px; cursor: pointer; color: var(--ink); transition: border-color .2s, background .2s; }
.pick button b { display: block; font: 600 18px var(--display); letter-spacing: -0.01em; }
.pick button span { display: block; margin-top: 2px; font: 400 11.5px var(--mono); color: var(--ink-3); }
.pick button:hover { border-color: var(--ink-3); }
.pick button[aria-checked="true"] { border-color: var(--red); background: var(--bg-3); box-shadow: inset 0 -2px 0 var(--red); }
.fate { margin: 12px 0 4px; padding: 12px 14px; border: 1px solid var(--line); border-left: 2px solid var(--ok); border-radius: 4px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); background: var(--bg); }
.fate:empty { display: none; }
.fate b { color: var(--ink); font-weight: 600; }
#ob-extra { margin: 12px 0 2px; }
.welcome { border: 1px solid var(--line-2); border-left: 2px solid var(--red); background: var(--bg); border-radius: 4px; padding: 18px 20px; margin-bottom: 22px; }
.welcome h3 { font-size: 24px; margin-bottom: 8px; }
.welcome p { margin: 6px 0 0; color: var(--ink-2); font-size: 14.5px; }
.welcome details { margin-top: 12px; }
@media (max-width: 560px) {
  .pick { grid-template-columns: 1fr; }
  .compat { gap: 8px 22px; }
  .compat .mark + .mark::before { margin-right: 22px; }
}

/* ---------- entrance (no script needed) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero > * { animation: rise .9s var(--ease) both; }
  .hero > :nth-child(2) { animation-delay: .12s; }
  .hero > :nth-child(3) { animation-delay: .22s; }
  @keyframes rise { from { opacity: 0; transform: translateY(24px); } }
}
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 36px; padding: 56px 0 52px; }
  h1 { margin-bottom: 8px; }
  dl.specs { grid-template-columns: 1fr; }
  ol.flow li { grid-template-columns: 44px minmax(0, 1fr); }
  ol.flow li p { grid-column: 2; }
}
@media (max-width: 560px) {
  main > section { padding: 18px; }
  h1 { font-size: clamp(44px, 14vw, 64px); }
  ol.flow h3 { font-size: 22px; }
  ol.flow li { padding: 20px 4px; }
  dl.specs div { grid-template-columns: 92px 1fr; }
  .code .tabs button { padding: 10px 12px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- legal pages ---------- */
body.doc main { max-width: 760px; display: block; padding-top: 40px; }
body.doc h1 { font-size: clamp(40px, 7vw, 64px); margin-bottom: 18px; }
body.doc h2 { font-size: 22px; margin: 40px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
body.doc p, body.doc li { color: var(--ink-2); font-size: 15.5px; line-height: 1.7; }
body.doc b { color: var(--ink); font-weight: 600; }
body.doc .box { border: 1px solid var(--line-2); border-left: 2px solid var(--red); background: var(--bg-2); padding: 14px 18px; border-radius: 4px; }
