:root {
  --bg: #f4f8ff;
  --card: #ffffff;
  --text: #0f1b3d;
  --mute: #51608a;
  --line: #dbe5f7;
  --brand: #1a5fe0;
  --brand-soft: #e7efff;
  --header-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1226;
    --card: #121b36;
    --text: #e8eeff;
    --mute: #9fb0d8;
    --line: #243157;
    --brand: #8db6ff;
    --brand-soft: #1b2a52;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1226;
  --card: #121b36;
  --text: #e8eeff;
  --mute: #9fb0d8;
  --line: #243157;
  --brand: #8db6ff;
  --brand-soft: #1b2a52;
  color-scheme: dark;
}
:root[data-theme='light'] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
a { color: var(--brand); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: text-decoration-thickness 0.12s, color 0.12s; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible, main:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}
main:focus { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Skip link ---------- */
.skip {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  padding: 10px 16px; border-radius: 8px; background: var(--brand); color: var(--bg);
  font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Sticky header ---------- */
header.site {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
header.site .bar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
  max-width: 760px; margin: 0 auto; padding: 10px 16px; min-height: var(--header-h);
}
header.site .brand {
  display: flex; flex-direction: column; justify-content: center; gap: 0; line-height: 1.15;
  color: var(--text); text-decoration: none;
}
header.site .brand .mark {
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 800; font-size: 22px; letter-spacing: 0.14em;
}
header.site .brand .tag { font-size: 12px; color: var(--mute); letter-spacing: 0.01em; }
header.site .brand:hover .mark { color: var(--brand); }

.nav { display: flex; flex-wrap: wrap; gap: 4px 4px; width: 100%; }
.nav a {
  display: inline-block; padding: 8px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px;
  transition: background-color 0.12s, color 0.12s;
}
.nav a:hover { background: var(--brand-soft); color: var(--brand); }
.nav a[aria-current='page'] { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); border-radius: 8px 8px 0 0; }

.menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.menu-btn:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.menu-btn svg { width: 22px; height: 22px; }
.menu-btn .x { display: none; }
.menu-btn[aria-expanded='true'] .bars { display: none; }
.menu-btn[aria-expanded='true'] .x { display: block; }

/* With scripting on, the small-screen menu folds away behind the button. Without it, the links just wrap under the name. */
html.js .menu-btn { display: inline-flex; }
html.js .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; gap: 2px; padding: 8px 12px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
html.js .nav.open { display: flex; }
html.js .nav a { padding: 12px 12px; font-size: 16px; }
@media (min-width: 720px) {
  .nav { width: auto; flex-wrap: nowrap; }
  html.js .menu-btn { display: none; }
  html.js .nav, html.js .nav.open { display: flex; position: static; flex-direction: row; padding: 0; border: 0; background: none; gap: 4px; }
  html.js .nav a { padding: 8px 12px; font-size: 15px; }
}

.progress { height: 3px; background: transparent; overflow: hidden; }
.progress i { display: block; height: 100%; width: 100%; background: var(--brand); transform-origin: left center; transform: scaleX(0); transition: transform 0.08s linear; }
@media (prefers-reduced-motion: reduce) { .progress i { transition: none; } }

/* ---------- Page body ---------- */
main {
  max-width: 760px;
  margin: 24px auto 40px;
  padding: 28px 20px 36px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
@media (max-width: 800px) { main { margin-left: 12px; margin-right: 12px; } }
@media (min-width: 800px) { main { padding: 40px 44px 48px; } }
.print-brand { display: none; }
h1 {
  margin: 0 0 6px;
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h2 {
  margin: 34px 0 8px;
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 22px;
  line-height: 1.25;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
h3 { margin: 20px 0 4px; font-size: 16px; }
[id] { scroll-margin-top: calc(var(--header-h) + 16px); }
p, ul { margin: 0 0 12px; }
ul { padding-left: 22px; }
li { margin: 0 0 6px; }
.meta { color: var(--mute); margin: 0 0 18px; }
.summary {
  margin: 18px 0 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
}
.summary p:last-child, .summary ul:last-child { margin-bottom: 0; }
nav.toc { margin: 18px 0 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; }
nav.toc b { display: block; margin-bottom: 6px; }
nav.toc ol { margin: 0; padding-left: 22px; columns: 2; column-gap: 28px; }
@media (max-width: 560px) { nav.toc ol { columns: 1; } }
nav.toc li { margin: 0 0 4px; break-inside: avoid; }
table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--mute); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
@media (max-width: 600px) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; left: -9999px; }
  tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  td { border: 0; padding: 3px 0; }
  td:first-child { font-weight: 700; }
}

/* ---------- Copy to clipboard ---------- */
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.copy-btn:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.copy-btn svg { width: 16px; height: 16px; flex: none; }
.copied { min-height: 1.4em; font-size: 14px; font-weight: 700; color: var(--brand); }

/* ---------- FAQ ---------- */
.faq-group { margin: 30px 0 10px; }
details.faq { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 8px; background: var(--card); }
details.faq > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; cursor: pointer; list-style: none; font-weight: 700; line-height: 1.4; border-radius: 10px;
  transition: background-color 0.12s, color 0.12s;
}
details.faq > summary::-webkit-details-marker { display: none; }
details.faq > summary::after {
  content: ''; flex: none; width: 10px; height: 10px; margin-right: 4px;
  border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute);
  transform: rotate(45deg); transition: transform 0.18s ease-out, border-color 0.12s;
}
details.faq[open] > summary::after { transform: rotate(-135deg); margin-top: 6px; }
details.faq > summary:hover { background: var(--brand-soft); color: var(--brand); }
details.faq > summary:hover::after { border-color: var(--brand); }
details.faq .answer { padding: 0 16px 6px; }
details.faq .answer > :last-child { margin-bottom: 10px; }
@media (prefers-reduced-motion: reduce) { details.faq > summary::after { transition: none; } }
.help-box { margin: 30px 0 0; padding: 16px 18px; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; }
.help-box h2 { margin-top: 0; }

/* ---------- Back to top ---------- */
.to-top {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40;
  display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text);
  box-shadow: 0 4px 14px rgba(15, 27, 61, 0.14); cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.to-top[hidden] { display: none; }
.to-top:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.to-top svg { width: 22px; height: 22px; }

/* ---------- Footer ---------- */
footer.site { max-width: 760px; margin: 0 auto 40px; padding: 0 20px; color: var(--mute); font-size: 14px; }
footer.site nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 10px; }
footer.site nav a { padding: 6px 0; }
footer.site p { margin: 0; }
@media (max-width: 800px) { footer.site { padding: 0 20px; } }

/* ---------- Print ---------- */
@media print {
  :root:root:root { --bg: #fff; --card: #fff; --text: #000; --mute: #333; --line: #999; --brand: #000; --brand-soft: #fff; color-scheme: light; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  body { background: #fff; color: #000; font-size: 11.5pt; line-height: 1.5; }
  header.site, .skip, .progress, .to-top, .copy-btn, .copied, nav.toc, footer.site nav { display: none !important; }
  main { max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: #fff; }
  .print-brand { display: block; margin: 0 0 14px; padding-bottom: 6px; border-bottom: 1px solid #000; font-weight: 800; letter-spacing: 0.1em; }
  h1, h2, h3, summary { break-after: avoid; }
  .summary, table tr, details.faq, .help-box, li { break-inside: avoid; }
  main a { color: #000; text-decoration: underline; }
  main a[href^='http']::after { content: ' (' attr(href) ')'; font-size: 90%; word-break: break-all; }
  details.faq { border: 0; border-bottom: 1px solid #bbb; border-radius: 0; }
  details.faq > summary { padding: 8px 0 2px; }
  details.faq > summary::after { display: none; }
  details.faq .answer { padding: 0 0 6px; }
  details::details-content { content-visibility: visible; display: block; }
  details:not([open]) > :not(summary) { display: block; }
  footer.site { margin: 16px 0 0; padding: 8px 0 0; border-top: 1px solid #999; color: #000; }
}

/* About page: plain call to action (solid, rounded rectangle, not a pill) */
.cta { margin: 28px 0; }
.open-app {
  display: inline-block; padding: 12px 22px; border-radius: 12px; background: var(--brand); color: var(--bg);
  font-weight: 700; text-decoration: none; transition: filter 0.12s;
}
.open-app:hover { filter: brightness(0.92); color: var(--bg); text-decoration: none; }
.open-app:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
@media print { .cta { display: none !important; } }
