/* ==========================================================================
   Trainia Legal & Information Surface · Round 2 (Convergent Identity)
   Inherits directly from:
   1. trainiaapp.com (client/index.html):
      - WebGL sky/sage/cream mesh (home-mesh.js) + CSS gradient fallback
      - Floating frosted-glass pill navbar (.pnav) + dark Apple Download button
      - Display headline (SF Pro Display 700, -0.045em) + SF body + footer.foot
   2. connect.trainiaapp.com (tokens.css + ui.css):
      - Swift-verified light/dark tokens (--background, --surface, --elevated, --card-edge)
      - System radii, inset-grouped rows (.glyph), and TintedGlassButtonStyle gold CTA
   ========================================================================== */

:root {
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --display-ink: #101b2d;
  --body-ink: #263a4d; /* AppColors.brandInk */
  --muted-ink: #4d5b6d; /* WCAG AA >= 6.4:1 on #fff & #f2f2f7 */
  --subtle-ink: #556274; /* WCAG AA 5.56:1 on #f2f2f7 & 6.20:1 on #fff */
  --hero-lead: #3e4654; /* exact --ink2 from client/index.html */

  /* Landing floating glass pill (.pnav) */
  --pnav-bg: rgba(255, 255, 255, 0.74);
  --pnav-shadow-scrolled: 0 1px 2px rgba(16, 27, 45, 0.05), 0 8px 28px rgba(16, 27, 45, 0.08);
  --pnav-get-bg: #101b2d;
  --pnav-get-fg: #ffffff;

  /* Quick-answer hero glass card */
  --hero-card-bg: rgba(255, 255, 255, 0.86);
  --hero-card-shadow: 0 1px 2px rgba(16, 27, 45, 0.04), 0 22px 48px -22px rgba(16, 27, 45, 0.14);

  /* Highlight mark & link accents (WCAG AA contrast verified) */
  --link-ink: #845a14;
  --focus-ring: #8a5f17; /* landing --gold-ink: 5.63:1 on #fff, 5.05:1 on #f2f2f7 */
  --accent-ink: var(--link-ink); /* 6.08:1 on #fff, 5.25:1 on .match-pill */
  --eyebrow-ink: #5c3e0b; /* 5.33:1 on light atmospheric mesh */
  --highlight-mark: rgb(228 173 80 / 0.34);

  /* Layout rhythm (aligned with landing --m / --r and connect --radius-*) */
  --m: clamp(18px, 4vw, 64px);
  --container: 1160px;
  --r-sheet: clamp(20px, 2vw, 26px);
  --sticky-offset: 92px;

  /* Motion curves (Emil Kowalski / connect/motion.css) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  /* Adaptive browser scrollbar without transition flicker */
  --scrollbar-thumb: #9aa4b2;
  --scrollbar-track: transparent;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  accent-color: var(--gold-signature);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --display-ink: #ffffff;
    --body-ink: #e2e6ed;
    --muted-ink: #9ba3b0;
    --subtle-ink: #7f8896;
    --hero-lead: #c5ccd8;

    --pnav-bg: rgba(21, 23, 27, 0.76);
    --pnav-shadow-scrolled: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.52);
    /* Dark capsule with crisp edge so "Download" stays dark-toned on dark glass while clearly legible */
    --pnav-get-bg: #0c0d10;
    --pnav-get-fg: #ffffff;

    --hero-card-bg: rgba(21, 23, 27, 0.88);
    --hero-card-shadow: 0 24px 56px -22px rgba(0, 0, 0, 0.72);

    --link-ink: #ebc176;
    --focus-ring: var(--mesh-activity);
    --accent-ink: var(--gold-signature);
    --eyebrow-ink: var(--gold-signature);
    --highlight-mark: rgb(228 173 80 / 0.28);
    --scrollbar-thumb: #464c58;
  }
}

:root[data-theme="dark"] {
  --display-ink: #ffffff;
  --body-ink: #e2e6ed;
  --muted-ink: #9ba3b0;
  --subtle-ink: #7f8896;
  --hero-lead: #c5ccd8;

  --pnav-bg: rgba(21, 23, 27, 0.76);
  --pnav-shadow-scrolled: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.52);
  --pnav-get-bg: #0c0d10;
  --pnav-get-fg: #ffffff;

  --hero-card-bg: rgba(21, 23, 27, 0.88);
  --hero-card-shadow: 0 24px 56px -22px rgba(0, 0, 0, 0.72);

  --link-ink: #ebc176;
  --focus-ring: var(--mesh-activity);
  --accent-ink: var(--gold-signature);
  --eyebrow-ink: var(--gold-signature);
  --highlight-mark: rgb(228 173 80 / 0.28);
  --scrollbar-thumb: #464c58;
}

/* ==========================================================================
   Base Reset & Typography
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  scroll-padding-top: var(--sticky-offset);
}

@media (max-width: 959px) {
  html {
    scroll-padding-top: 138px;
  }
}

body {
  position: relative;
  margin: 0;
  min-height: 100svh;
  background-color: var(--background);
  color: var(--body-ink);
  font: var(--type-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--display-ink);
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--link-ink);
  text-underline-offset: 3px;
  transition: color 160ms ease, background-color 160ms ease, opacity 160ms ease, transform 160ms var(--ease-out);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2.5px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

html.no-js .js-only {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -120px;
  z-index: 80;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--display-ink);
  color: var(--background);
  font: var(--type-subheadline);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
}

.shell {
  position: relative;
  z-index: 2;
  width: min(100%, calc(var(--container) + var(--m) * 2));
  margin-inline: auto;
  padding-inline: var(--m);
}

/* ==========================================================================
   1. Atmospheric Header Mesh (home-mesh.js + CSS Gradient Fallback)
   Fades seamlessly into --background (#F2F2F7 light / #0C0D10 dark)
   ========================================================================== */
.atmo-stage {
  position: absolute;
  inset: 0 0 auto 0;
  height: clamp(580px, 74svh, 760px);
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  /* Pure CSS mesh gradient when JS or WebGL is unavailable (exact THEMES.light anchors) */
  background:
    radial-gradient(62% 76% at 16% 18%, rgb(147 182 208 / 0.76) 0%, transparent 70%),
    radial-gradient(56% 70% at 84% 38%, rgb(155 202 183 / 0.52) 0%, transparent 72%),
    radial-gradient(58% 66% at 50% 26%, rgb(245 242 235 / 0.94) 0%, transparent 74%),
    linear-gradient(180deg, #e5eef5 0%, var(--background) 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 54%, rgb(0 0 0 / 0.42) 79%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 54%, rgb(0 0 0 / 0.42) 79%, transparent 100%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .atmo-stage {
    background:
      radial-gradient(62% 76% at 16% 18%, rgb(119 151 178 / 0.36) 0%, transparent 70%),
      radial-gradient(56% 70% at 84% 38%, rgb(131 183 168 / 0.24) 0%, transparent 72%),
      radial-gradient(60% 68% at 50% 24%, rgb(28 36 48 / 0.78) 0%, transparent 76%),
      linear-gradient(180deg, #101723 0%, var(--background) 100%);
  }
}

:root[data-theme="dark"] .atmo-stage {
  background:
    radial-gradient(62% 76% at 16% 18%, rgb(119 151 178 / 0.36) 0%, transparent 70%),
    radial-gradient(56% 70% at 84% 38%, rgb(131 183 168 / 0.24) 0%, transparent 72%),
    radial-gradient(60% 68% at 50% 24%, rgb(28 36 48 / 0.78) 0%, transparent 76%),
    linear-gradient(180deg, #101723 0%, var(--background) 100%);
}

.atmo-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 280ms ease;
}

.atmo-canvas[data-webgl="ready"] {
  opacity: 1;
}

/* ==========================================================================
   2. Floating Glass Pill Navbar (.pnav from client/index.html)
   ========================================================================== */
.pnav {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 0 14px;
  pointer-events: none;
}

.pnav .bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 52px;
  padding: 6px 6px 6px 20px;
  border-radius: 999px;
  background: var(--pnav-bg);
  outline: var(--card-edge);
  outline-offset: -2px;
  -webkit-backdrop-filter: saturate(1.6) blur(20px);
  backdrop-filter: saturate(1.6) blur(20px);
  transition: box-shadow 240ms ease, background-color 200ms ease;
}

.pnav.scrolled .bar {
  box-shadow: var(--pnav-shadow-scrolled);
}

.pnav .wm-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--display-ink);
  text-decoration: none;
  flex-shrink: 0;
}

.pnav .wm {
  height: 21px;
  width: auto;
  display: block;
}

.pnav .links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 15px;
}

.pnav .links a {
  padding: 8px 0;
  color: var(--hero-lead);
  font-weight: 450;
  text-decoration: none;
}

.pnav .links a[aria-current="page"] {
  color: var(--display-ink);
  font-weight: 600;
}

.pnav-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Compact EN / ES segmented switch inside .pnav (inherits connect/ui.css .lang) */
.pnav-lang {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--display-ink) 7%, transparent);
  font: var(--type-footnote);
}

.pnav-lang a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted-ink);
  font-weight: 500;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.pnav-lang a[aria-current="page"] {
  background: var(--surface);
  color: var(--display-ink);
  font-weight: 600;
  outline: var(--card-edge);
  outline-offset: -2px;
}

/* Dark "Download" capsule with Apple glyph (client/index.html .pnav .get) */
.pnav .get {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--pnav-get-bg);
  color: var(--pnav-get-fg);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
  -webkit-tap-highlight-color: transparent;
}

.pnav .get svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  margin-top: -2px;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .pnav .links {
    display: none;
  }

  .pnav .bar {
    width: 100%;
    max-width: 520px;
    justify-content: space-between;
    gap: 10px;
    padding-left: 18px;
  }

  .pnav .wm {
    height: 19px;
  }

  .pnav .get {
    padding: 0 13px;
    font-size: 14px;
  }
}

/* ==========================================================================
   3. Hero Masthead Over the Mesh (Display Type + System Quick Answers Card)
   ========================================================================== */
.doc-masthead {
  padding-top: clamp(96px, 11vw, 132px);
  padding-bottom: clamp(28px, 3.6vw, 44px);
  display: grid;
  gap: 22px;
}

@media (min-width: 960px) {
  .doc-masthead {
    grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
    column-gap: clamp(32px, 4vw, 56px);
    align-items: center;
  }
}

.masthead-say {
  display: grid;
  gap: 18px;
  align-content: start;
}

/* Mobile sibling tabs (connect.trainiaapp.com .doc-tabs, shown when .pnav .links hides) */
.mobile-doc-tabs {
  display: none;
}

@media (max-width: 860px) {
  .mobile-doc-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    width: max-content;
    max-width: 100%;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 74%, transparent);
    outline: var(--card-edge);
    outline-offset: -2px;
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
  }

  .mobile-doc-tabs a {
    padding: 6px 13px;
    border-radius: 999px;
    font: var(--type-footnote);
    font-weight: 500;
    color: var(--muted-ink);
    text-decoration: none;
    white-space: nowrap;
  }

  .mobile-doc-tabs a[aria-current="page"] {
    background: var(--surface);
    color: var(--display-ink);
    font-weight: 600;
    outline: var(--card-edge);
    outline-offset: -2px;
  }
}

/* Hero display headline: 700, -0.045em tracking, 1.02 line-height (exact landing .lines) */
.doc-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(40px, 5vw, 68px);
  letter-spacing: -0.045em;
  line-height: 1.02;
  color: var(--display-ink);
}

.doc-lead {
  font-size: clamp(17.5px, 0.9vw + 13px, 20.5px);
  line-height: 1.44;
  color: var(--hero-lead);
  max-width: 42ch;
}

.doc-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding-top: 4px;
  font: var(--type-subheadline);
  color: var(--muted-ink);
}

.doc-meta-date strong {
  color: var(--display-ink);
  font-weight: 600;
}

.doc-meta-sep {
  opacity: 0.45;
}

.inline-lang-link {
  font-weight: 600;
  color: var(--display-ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--display-ink) 32%, transparent);
  text-underline-offset: 3px;
}

/* System Quick Answers Card (connect/ui.css .card + .list + .glyph) */
.quick-card {
  background: var(--hero-card-bg);
  border-radius: var(--radius-xxl);
  outline: var(--card-edge);
  outline-offset: -2px;
  box-shadow: var(--hero-card-shadow);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  backdrop-filter: saturate(1.5) blur(18px);
  overflow: hidden;
}

.quick-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 10px;
}

.quick-head h2 {
  font: var(--type-headline);
  letter-spacing: -0.015em;
  color: var(--display-ink);
}

.quick-head span {
  font: var(--type-footnote);
  color: var(--muted-ink);
}

.quick-list {
  list-style: none;
  margin: 0;
  padding: 0 10px;
}

.quick-list li + li {
  border-top: 1px solid var(--border);
}

.quick-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 11px 10px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* Connect system .glyph badges (32x32 rounded-sm with domain accents) */
.q-glyph {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--elevated);
  color: var(--display-ink);
  flex-shrink: 0;
}

.q-glyph svg {
  width: 17px;
  height: 17px;
}

.q-glyph.mint {
  background: color-mix(in srgb, var(--nutrition-accent) 15%, var(--surface));
  color: var(--nutrition-accent);
}

.q-glyph.gold {
  background: color-mix(in srgb, var(--gold) 18%, var(--surface));
  color: var(--gold-signature);
}

.q-glyph.sky {
  background: color-mix(in srgb, var(--mesh-activity) 22%, var(--surface));
  color: var(--activity-accent);
}

.q-glyph.slate {
  background: var(--elevated);
  color: var(--display-ink);
}

.quick-q {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.28;
  color: var(--display-ink);
}

.quick-a {
  display: block;
  margin-top: 2px;
  font: var(--type-footnote);
  line-height: 1.36;
  color: var(--muted-ink);
}

.quick-jump-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--elevated);
  color: var(--muted-ink);
  font-family: var(--font-rounded);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.reviewer-bar {
  padding: 12px 18px 16px;
  background: color-mix(in srgb, var(--elevated) 82%, transparent);
  border-top: 1px solid var(--border);
}

.reviewer-label {
  display: block;
  font: var(--type-caption);
  font-weight: 600;
  color: var(--muted-ink);
  margin-bottom: 8px;
}

.reviewer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reviewer-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  outline: var(--card-edge);
  outline-offset: -2px;
  color: var(--display-ink);
  font: var(--type-footnote);
  font-weight: 500;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.reviewer-chip small {
  font-family: var(--font-rounded);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--subtle-ink);
}

@media (max-width: 600px) {
  .reviewer-chip {
    min-height: 38px;
    padding: 6px 12px;
  }
}

/* ==========================================================================
   4. Verbatim Intro & 4 System Surface Highlights (--card-edge)
   ========================================================================== */
.overview-band {
  margin-bottom: clamp(28px, 4vw, 44px);
  display: grid;
  gap: 20px;
}

.intro-prose {
  display: grid;
  gap: 12px;
  max-width: 72ch;
  font-size: 16.5px;
  line-height: 1.58;
  color: var(--body-ink);
}

@media (min-width: 960px) {
  .intro-prose {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    max-width: none;
  }
}

.highlights-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 620px) {
  .highlights-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .highlights-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.highlight-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  outline: var(--card-edge);
  outline-offset: -2px;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.highlight-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.highlight-tile h2 {
  font: var(--type-headline);
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--display-ink);
}

.highlight-ref {
  font-family: var(--font-rounded);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold-signature);
  flex-shrink: 0;
}

.highlight-tile p {
  font: var(--type-subheadline);
  font-size: 14.5px;
  line-height: 1.48;
  color: var(--muted-ink);
}

/* ==========================================================================
   5. Two-Column Document Layout (Connector-Style Open TOC + System Sheets)
   ========================================================================== */
.doc-layout {
  display: grid;
  gap: 24px;
  padding-bottom: clamp(48px, 6vw, 80px);
  overflow-anchor: none;
}

@media (min-width: 960px) {
  .doc-layout {
    grid-template-columns: 256px minmax(0, 1fr);
    gap: 44px;
    align-items: start;
    overflow-anchor: auto;
  }
}

/* Mobile Sticky Section Pill (<960px: parks cleanly below .pnav only when reading clauses) */
.mobile-nav-shell {
  display: none;
}

@media (max-width: 959px) {
  .mobile-nav-shell {
    display: block;
    position: sticky;
    top: 74px;
    z-index: 30;
    overflow-anchor: none;
  }

  .mobile-toc {
    background: var(--pnav-bg);
    border-radius: var(--radius-lg);
    outline: var(--card-edge);
    outline-offset: -2px;
    box-shadow: 0 8px 24px -12px rgba(16, 27, 45, 0.16);
    -webkit-backdrop-filter: saturate(1.6) blur(20px);
    backdrop-filter: saturate(1.6) blur(20px);
  }

  .mobile-toc > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 46px;
    padding: 8px 16px;
    font: var(--type-subheadline);
    color: var(--display-ink);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-toc > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-toc-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
  }

  .mobile-toc-prefix {
    font-weight: 600;
    color: var(--muted-ink);
    flex-shrink: 0;
  }

  .mobile-toc-current {
    font-weight: 600;
    color: var(--display-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-toc-chevron {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border: solid var(--muted-ink);
    border-width: 0 2px 2px 0;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 180ms var(--ease-out);
  }

  .mobile-toc[open] .mobile-toc-chevron {
    transform: translateY(2px) rotate(-135deg);
  }

  .mobile-toc-panel {
    max-height: min(64svh, 480px);
    overflow-y: auto;
    padding: 6px 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }

  .mobile-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 2px;
  }

  .mobile-toc-list a {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-height: 44px;
    padding: 10px;
    border-radius: var(--radius-sm);
    font: var(--type-subheadline);
    color: var(--body-ink);
    text-decoration: none;
  }

  .mobile-toc-list a .sec-num {
    font-family: var(--font-rounded);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--subtle-ink);
    min-width: 20px;
    font-variant-numeric: tabular-nums;
  }

  .mobile-toc-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding: 10px 10px 2px;
    border-top: 1px solid var(--border);
    font: var(--type-footnote);
  }

  .mobile-toc-foot a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: var(--display-ink);
    text-decoration: none;
  }
}

/* Desktop Sticky Left Rail (mirrors connect.trainiaapp.com/privacy .toc) */
.doc-rail {
  display: none;
}

@media (min-width: 960px) {
  .doc-rail {
    display: grid;
    gap: 16px;
    position: sticky;
    top: 84px;
    max-height: calc(100svh - 104px);
    overflow-y: auto;
    padding-right: 4px;
  }
}

.clause-search {
  display: grid;
  gap: 6px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 13px;
  width: 15px;
  height: 15px;
  color: var(--subtle-ink);
  pointer-events: none;
}

.search-input {
  appearance: none;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px 8px 36px;
  border-radius: 999px;
  border: 0;
  background: var(--surface);
  outline: var(--card-edge);
  outline-offset: -2px;
  color: var(--display-ink);
  font: var(--type-footnote);
  font-size: 13.5px;
}

.search-input:not(:placeholder-shown) {
  padding-right: 34px;
}

.search-input::placeholder {
  color: var(--subtle-ink);
}

.search-input:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: -1px;
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--elevated);
  color: var(--muted-ink);
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
}

.search-clear[hidden],
.search-status[hidden] {
  display: none;
}

.search-status {
  font: var(--type-caption);
  color: var(--muted-ink);
  padding-inline: 10px;
}

/* Open, un-boxed TOC directly on --background (exact connect/ui.css .toc feel) */
.toc-nav {
  padding: 2px 0;
}

.toc-heading {
  font: var(--type-caption);
  font-weight: 600;
  color: var(--subtle-ink);
  padding: 0 12px 8px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  scroll-target-group: auto;
}

.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font: var(--type-subheadline);
  font-size: 14px;
  line-height: 1.34;
  color: var(--muted-ink);
  text-decoration: none;
}

.toc-list a .sec-num {
  font-family: var(--font-rounded);
  font-size: 12px;
  font-weight: 600;
  color: var(--subtle-ink);
  min-width: 18px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.toc-list a .match-pill {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 22%, var(--surface));
  color: var(--accent-ink);
  font-family: var(--font-rounded);
  font-size: 11px;
  font-weight: 700;
}

.toc-list a .match-pill[hidden] {
  display: none;
}

.toc-list a:is(:target-current, .target-current) {
  background: var(--surface);
  color: var(--display-ink);
  font-weight: 600;
  outline: var(--card-edge);
  outline-offset: -2px;
}

.toc-list a:is(:target-current, .target-current) .sec-num {
  color: var(--accent-ink);
}

.toc-list a.is-dimmed {
  opacity: 0.4;
}

/* ==========================================================================
   6. System Clause Cards (--surface + --card-edge) & Verbatim Legal Prose
   ========================================================================== */
.doc-chapters {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.chapter-sheet {
  background: var(--surface);
  border-radius: var(--r-sheet);
  outline: var(--card-edge);
  outline-offset: -2px;
  padding: clamp(22px, 3.2vw, 38px);
}

.chapter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.chapter-title {
  font: var(--type-footnote);
  font-weight: 600;
  color: var(--muted-ink);
}

.chapter-range {
  font-family: var(--font-rounded);
  font: var(--type-caption);
  font-weight: 600;
  color: var(--subtle-ink);
  font-variant-numeric: tabular-nums;
}

.clause {
  padding-block: clamp(20px, 2.6vw, 30px);
  scroll-margin-top: var(--sticky-offset);
}

@media (max-width: 959px) {
  .clause {
    scroll-margin-top: 138px;
  }
}

.clause + .clause {
  border-top: 1px solid var(--border);
}

.clause:first-of-type {
  padding-top: 16px;
}

.clause:last-of-type {
  padding-bottom: 2px;
}

.clause.is-filtered-out,
.chapter-sheet.is-filtered-out {
  display: none;
}

.clause-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.clause-heading-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.clause-num {
  font-family: var(--font-rounded);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.clause-title {
  font-family: var(--font-display);
  font-size: clamp(21px, 2.2vw, 26px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--display-ink);
}

.anchor-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--subtle-ink);
  font: var(--type-footnote);
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.anchor-btn.copied {
  background: color-mix(in srgb, var(--nutrition-accent) 16%, var(--surface));
  color: var(--nutrition-accent);
}

.clause-prose {
  display: grid;
  gap: 14px;
  max-width: 66ch;
}

.clause-prose p {
  font-size: 17px;
  line-height: 1.62;
  color: var(--body-ink);
}

/* Inset-grouped category list (§01) and OAuth disclosure cards (§08) */
.clause-bullets {
  list-style: none;
  margin: 16px 0 0;
  padding: 4px 18px;
  border-radius: var(--radius-lg);
  background: var(--elevated);
  max-width: 68ch;
}

.clause-bullets li {
  padding-block: 12px;
  font-size: 15.5px;
  line-height: 1.56;
  color: var(--body-ink);
}

.clause-bullets li + li {
  border-top: 1px solid var(--border);
}

.clause-bullets strong {
  color: var(--display-ink);
  font-weight: 600;
}

.subclause-stack {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  max-width: 68ch;
}

.subclause-card {
  padding: 15px 18px;
  border-radius: var(--radius-lg);
  background: var(--elevated);
}

.subclause-card p {
  font-size: 15.5px;
  line-height: 1.58;
  color: var(--body-ink);
}

.subclause-lead {
  color: var(--display-ink);
  font-weight: 650;
}

.clause-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ==========================================================================
   7. Connector Buttons (.btn.primary TintedGlassButtonStyle + .btn.secondary)
   Exact CSS from connect/ui.css lines 72-88 & 279-285
   ========================================================================== */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  min-height: 52px;
  padding: 0 var(--space-xxl);
  border-radius: 999px;
  font: var(--type-headline);
  text-decoration: none;
  transition: transform 160ms var(--ease-out), opacity 160ms var(--ease-out), filter 160ms ease, background-color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* TintedGlassButtonStyle gold capsule from connect/ui.css */
.btn.primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold) 52%, var(--gold-light));
  color: var(--on-gold);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.22),
    inset 0 1px 0 rgb(255 255 255 / 0.5),
    0 1px 2px rgb(120 80 20 / 0.18),
    0 8px 20px -10px rgb(180 120 40 / 0.55);
}

.btn.secondary {
  min-height: 42px;
  padding: 0 16px;
  font: var(--type-subheadline);
  font-weight: 600;
  background: color-mix(in srgb, var(--display-ink) 7%, var(--surface));
  color: var(--display-ink);
  outline: var(--card-edge);
  outline-offset: -2px;
}

mark.policy-hit {
  background: var(--highlight-mark);
  color: inherit;
  border-radius: 3px;
  padding-inline: 2px;
}

.filter-empty {
  padding: 32px 24px;
  border-radius: var(--r-sheet);
  background: var(--surface);
  outline: var(--card-edge);
  outline-offset: -2px;
  text-align: center;
}

.filter-empty[hidden] {
  display: none;
}

.filter-empty p {
  color: var(--muted-ink);
  margin-bottom: 14px;
}

/* ==========================================================================
   8. Contact Sheet (Primary Gold Action) & Landing Footer (footer.foot)
   ========================================================================== */
.contact-sheet {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border-radius: var(--r-sheet);
  outline: var(--card-edge);
  outline-offset: -2px;
  padding: clamp(24px, 3.2vw, 36px);
  scroll-margin-top: var(--sticky-offset);
}

.contact-copy {
  display: grid;
  gap: 6px;
  max-width: 50ch;
}

.contact-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.contact-copy p {
  font-size: 16.5px;
  color: var(--muted-ink);
}

/* Exact footer.foot from client/index.html (lines 201-205, 395-403) */
footer.foot {
  position: relative;
  z-index: 2;
  width: min(100%, calc(var(--container) + var(--m) * 2));
  margin-inline: auto;
  padding: 36px var(--m) 96px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted-ink);
  font-size: 14px;
}

footer.foot .foot-brand {
  display: inline-flex;
  align-items: center;
  color: var(--display-ink);
  text-decoration: none;
}

footer.foot .foot-wm {
  height: 18px;
  width: auto;
  display: block;
}

footer.foot .flinks {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

footer.foot .flinks a {
  color: var(--muted-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--muted-ink) 38%, transparent);
  font-size: 14px;
  padding: 8px 0;
}

footer.foot .flinks a[aria-current="page"] {
  color: var(--display-ink);
  font-weight: 600;
}

/* ==========================================================================
   9. Motion, Tactile Press & Reduced-Motion Discipline
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
  }

  .masthead-say,
  .quick-card,
  .overview-band,
  .doc-layout {
    animation: rise 400ms var(--ease-out) both;
  }

  .quick-card {
    animation-delay: 45ms;
  }

  .overview-band {
    animation-delay: 90ms;
  }

  .doc-layout {
    animation-delay: 130ms;
  }

  .btn:active,
  .pnav .get:active,
  .pnav-lang a:active,
  .reviewer-chip:active,
  .anchor-btn:active {
    transform: scale(0.97);
  }

  .quick-row:active,
  .highlight-tile:active {
    transform: scale(0.99);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-toc-chevron {
    transition: none;
  }
}

@media (hover: hover) and (pointer: fine) {
  .pnav .links a:hover,
  footer.foot .flinks a:hover {
    color: var(--display-ink);
  }

  .pnav-lang a:not([aria-current="page"]):hover {
    color: var(--display-ink);
  }

  .pnav .get:hover {
    opacity: 0.9;
  }

  .btn.primary:hover {
    filter: brightness(1.04) saturate(1.05);
  }

  .btn.secondary:hover {
    background: color-mix(in srgb, var(--display-ink) 12%, var(--surface));
  }

  .quick-row:hover {
    background: color-mix(in srgb, var(--display-ink) 4%, transparent);
  }

  .quick-row:hover .quick-jump-tag {
    background: var(--surface);
    color: var(--display-ink);
  }

  .reviewer-chip:hover {
    background: var(--elevated);
  }

  .highlight-tile:hover {
    background: var(--elevated);
  }

  .toc-list a:not(:is(:target-current, .target-current)):hover {
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    color: var(--display-ink);
  }

  .anchor-btn:hover {
    background: var(--elevated);
    color: var(--display-ink);
  }
}

@media (max-width: 480px) {
  .chapter-sheet {
    padding: 20px 18px;
    border-radius: 20px;
  }

  .quick-card {
    border-radius: 20px;
  }

  .quick-head {
    padding: 15px 16px 8px;
  }

  .reviewer-bar {
    padding: 12px 16px 14px;
  }

  .subclause-card {
    padding: 13px 14px;
  }

  .clause-bullets {
    padding: 2px 14px;
  }

  .contact-sheet .btn.primary {
    width: 100%;
  }
}

/* Legacy scrollbar fallback for older WebKit without scrollbar-color */
@supports not (scrollbar-color: auto) {
  .doc-rail::-webkit-scrollbar {
    width: 8px;
  }

  .doc-rail::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
  }
}

/* ==========================================================================
   10. Extensions for Sibling Legal & Support Surfaces (Sources, 404)
   Strictly scoped classes so Privacy layout & visual rhythm stay untouched.
   ========================================================================== */
.doc-title.doc-title-long {
  font-size: clamp(34px, 4.1vw, 56px);
  line-height: 1.05;
}

.doc-eyebrow {
  font-family: var(--font-rounded);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--eyebrow-ink);
}

.masthead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 6px;
}

/* Research reference cards (/sources) · inset-grouped companion to .subclause-card */
.ref-stack {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  max-width: 68ch;
}

.ref-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--elevated);
  outline: var(--card-edge);
  outline-offset: -2px;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.ref-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}

.ref-card-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--display-ink);
}

.ref-card-source {
  font: var(--type-footnote);
  font-weight: 600;
  color: var(--link-ink);
  flex-shrink: 0;
}

.ref-card-body {
  font-size: 15px;
  line-height: 1.54;
  color: var(--muted-ink);
}

@media (hover: hover) and (pointer: fine) {
  .ref-card:hover {
    background: color-mix(in srgb, var(--display-ink) 5%, var(--elevated));
  }

  .ref-card:hover .ref-card-title {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: color-mix(in srgb, var(--display-ink) 36%, transparent);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .ref-card:active {
    transform: scale(0.99);
  }
}

@media (max-width: 480px) {
  .ref-card {
    padding: 14px 15px;
  }
}

/* 404 page vertical balance */
body.page-notfound {
  display: flex;
  flex-direction: column;
}

.notfound-main {
  flex: 1 0 auto;
  display: grid;
  align-content: center;
}

.notfound-main .doc-masthead {
  padding-top: clamp(104px, 12vw, 148px);
  padding-bottom: clamp(40px, 6vw, 72px);
}

/* Print stylesheet for legal archival / PDF export */
@media print {
  .atmo-stage,
  .pnav,
  .mobile-nav-shell,
  .doc-rail,
  .anchor-btn,
  .quick-card,
  .mobile-doc-tabs {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #111111;
  }

  .doc-masthead,
  .doc-layout {
    display: block;
    padding-top: 0;
  }

  .chapter-sheet,
  .contact-sheet {
    break-inside: avoid-page;
    padding: 0;
    outline: none;
    margin-bottom: 24px;
  }
}
