/* Tokens copied verbatim from landingpage/styles.css. help.flig.tech is served from another host,
   so it cannot link the landing page stylesheet; tests/parity.test.cjs fails if the two drift.
   --primary-2 is only used inside gradients with white text: on --background it renders 3.39:1. */
:root[data-theme="dark"] {
  --background: hsl(270 60% 8%);
  --foreground: hsl(0 0% 100%);
  --card: hsl(270 50% 12% / 0.86);
  --card-strong: hsl(270 52% 14% / 0.96);
  --muted: hsl(270 20% 72%);
  --muted-strong: hsl(270 18% 84%);
  --border: hsl(270 40% 30% / 0.42);
  --primary: hsl(270 91% 65%);
  --primary-2: hsl(325 75% 43%);
  --glow: 0 0 40px hsl(270 91% 65% / 0.28);
  --shadow: 0 18px 48px hsl(240 40% 4% / 0.45);
  --gradient-primary: linear-gradient(135deg in srgb, hsl(270 91% 45%) 0%, hsl(325 75% 43%) 100%);
  --gradient-card: linear-gradient(135deg, hsl(270 50% 20% / 0.72) 0%, hsl(270 46% 12% / 0.92) 100%);
  --gradient-page: radial-gradient(circle at top, hsl(270 70% 18%) 0%, hsl(270 60% 8%) 42%, hsl(270 62% 6%) 100%);
  --container: 1180px;
  --radius-lg: 28px;
  --radius-md: 20px;
  --site-header: hsl(270 50% 9% / 0.75);
  --site-header-border-bottom: 1px solid hsl(270 30% 25% / 0.35);
  --eyebrow-border: 1px solid hsl(270 60% 45% / 0.42);
  --eyebrow-background: hsl(270 45% 18% / 0.7);
}

:root {
  --background: hsl(0 0% 100%);
  --foreground: hsl(270 60% 5%);
  --card: hsl(0 0% 98%);
  --card-strong: hsl(0 0% 96%);
  --muted: hsl(270, 2%, 38%);
  --muted-strong: hsl(280, 2%, 29%);
  --border: hsl(0 0% 90%);
  --primary: hsl(270 91% 45%);
  --primary-2: hsl(325 75% 43%);
  --glow: 0 0 40px hsla(280, 33%, 98%, 0.28);
  --shadow: 0 4px 20px hsla(270 91% 45% / 0.15);
  --gradient-primary: linear-gradient(135deg in srgb, hsl(270 91% 45%) 0%, hsl(325 75% 43%) 100%);
  --gradient-card: linear-gradient(135deg, hsla(0 0% 100% / 0.9) 0%, hsla(270 20% 98% / 0.8) 100%);
  --gradient-page: linear-gradient(180deg, #fff 0%, #f6f6f8 55%, #fff 100%);
  --container: 1180px;
  --radius-lg: 28px;
  --radius-md: 20px;
  --site-header: hsl(0 0% 98%);
  --site-header-border-bottom: 1px solid hsl(0 0% 90%);
  --eyebrow-border: 1px solid hsla(270, 43%, 65%, 0.42);
  --eyebrow-background: hsl(275 80% 95%);
}

/* Help-only token, declared on html rather than in a third :root block so the two copied theme
   blocks above stay the only :root rules. Reused by scroll-margin-top so an anchored heading never
   lands underneath the sticky header. */
html {
  --header-height: 84px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: var(--foreground);
  background: var(--background);
}

/* ---- Reused from landingpage: layout, header, brand, buttons, cards ---- */

.page-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 20%, hsl(280 90% 55% / 0.04), transparent 24%),
    radial-gradient(circle at 85% 15%, hsl(325 95% 65% / 0.04), transparent 24%),
    var(--gradient-page);
}

.container {
  width: min(calc(100% - 2rem), var(--container));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(18px);
  background: var(--site-header);
  border-bottom: var(--site-header-border-bottom);
}

.nav-wrap {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  color: var(--foreground);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand span:last-child {
  font-size: 0.8rem;
  color: var(--muted);
}

.logo {
  display: flex !important;
  gap: 2px;
  align-items: center;
  color: var(--foreground);
  font-family: Segoe UI, Arial, sans-serif;
}

.dot {
  color: var(--primary);
}

.eyebrow {
  display: inline-flex;
  padding: 0.45rem 0.85rem;
  margin-bottom: 1.2rem;
  border-radius: 999px;
  border: var(--eyebrow-border);
  background: var(--eyebrow-background);
  color: var(--muted-strong);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0.9rem 1.3rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  color: white;
  background: var(--gradient-primary);
  box-shadow: var(--glow);
}

.button-secondary {
  color: var(--foreground);
  border: 1px solid var(--border);
  background: var(--card);
}

.glass-card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.theme-toggle,
.toc-toggle,
.anchor-copy {
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.theme-toggle {
  white-space: nowrap;
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.header-actions .button {
  min-height: 44px;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
}

/* ---- Help-only components ---- */

/* The index is a sticky sidebar on desktop and a collapsible panel at 820px and below. */
.doc-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
  padding: 2.5rem 0 4rem;
}

.toc {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  max-height: calc(100vh - var(--header-height) - 3rem);
  overflow-y: auto;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.toc h2 {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
}

.toc a {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  line-height: 1.3;
}

.toc a::before {
  content: counter(toc) '. ';
  color: var(--primary);
}

.toc a:hover {
  color: var(--foreground);
  background: var(--card-strong);
}

.toc a[aria-current='true'] {
  color: var(--foreground);
  background: var(--card-strong);
  font-weight: 600;
}

.toc-toggle {
  display: none;
  font-size: 0.85rem;
}

.doc-intro {
  padding: 2rem;
  margin-bottom: 2rem;
}

.doc-intro h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.doc-intro p {
  color: var(--muted);
}

.doc-section {
  /* Keeps an anchored heading clear of the sticky header. */
  scroll-margin-top: calc(var(--header-height) + 1rem);
  padding: 1.75rem 0 0.5rem;
  border-top: 1px solid var(--border);
}

.doc-section:first-of-type {
  border-top: 0;
}

.doc-section h2 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.25rem, 3.6vw, 1.6rem);
  letter-spacing: -0.02em;
}

.doc-section h3 {
  margin: 1.6rem 0 0.4rem;
  font-size: 1.02rem;
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.doc-section p,
.doc-section li {
  line-height: 1.6;
  color: var(--muted);
}

.doc-section strong {
  color: var(--foreground);
}

.heading-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.anchor-copy {
  min-height: 32px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.heading-row:hover .anchor-copy,
.anchor-copy:focus-visible {
  opacity: 1;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  border: var(--eyebrow-border);
  background: var(--eyebrow-background);
  color: var(--muted-strong);
  font-size: 0.76rem;
}

.steps {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}

.steps li {
  margin-bottom: 0.5rem;
}

.doc-section ul {
  padding-left: 1.2rem;
}

kbd.ui {
  display: inline-block;
  padding: 0.08em 0.4em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-strong);
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.92em;
  font-weight: 500;
  white-space: nowrap;
}

.note {
  margin: 1rem 0;
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--card);
}

.note p:first-child {
  margin-top: 0;
}

.note p:last-child {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

th {
  color: var(--foreground);
  font-weight: 600;
  white-space: nowrap;
}

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

.faq details {
  margin-bottom: 0.6rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--foreground);
}

.faq details[open] summary {
  margin-bottom: 0.5rem;
}

.doc-section img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
}

.footer-line {
  margin: 0.5rem auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

a {
  color: var(--primary);
}

@media (max-width: 820px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    padding-top: 1.5rem;
  }

  .toc-toggle {
    display: inline-flex;
    align-items: center;
  }

  /* Collapsed by default on small screens; .open is toggled by script.js together with
     aria-expanded on .toc-toggle. Without JS the panel stays open (see the :not fallback below). */
  .toc {
    position: static;
    max-height: none;
    display: none;
  }

  .toc.open {
    display: block;
  }

  html:not(.js) .toc {
    display: block;
  }

  .header-actions .button-primary {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}
