/* Chimely — Help & Guide
   Shares the marketing site's identity: DSEG LED faces for accents,
   neon-green accent, deep near-black surfaces. Light theme included.

   One stylesheet for all sixteen pages (hub + 15 topics). Layout is a
   three-track grid — persistent topic nav | document | on-this-page rail —
   that collapses to a drawer + inline disclosure on narrow screens. */

@font-face {
  font-family: 'DSEG7';
  src: url('../assets/fonts/DSEG7Classic-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'DSEG14';
  src: url('../assets/fonts/DSEG14Classic-Regular.ttf') format('truetype');
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: dark;

  --bg:        #0b0d10;
  --bg-soft:   #0f1317;
  --panel:     #14181d;
  --panel-2:   #171c22;
  --line:      #232a31;
  --line-soft: #1c2228;

  --text:      #e7ecef;
  --text-str:  #ffffff;
  --muted:     #9aa4ac;
  /* Ordinal numerals (01–15, in the nav and on the hub cards). Must clear
     4.5:1 on --panel unaided: never dim these with opacity — that is what
     broke contrast before. */
  --num:       #aab4bc;

  --accent:      #26ff7a;
  --accent-ink:  #001a0a;
  --accent-soft: rgba(38, 255, 122, 0.12);
  --accent-line: rgba(38, 255, 122, 0.34);

  --amber:      #ffb000;
  --amber-soft: rgba(255, 176, 0, 0.11);
  --amber-line: rgba(255, 176, 0, 0.34);

  --cyan:      #29e0e0;
  --cyan-soft: rgba(41, 224, 224, 0.10);
  --cyan-line: rgba(41, 224, 224, 0.30);

  --gold:  #ffc94d;
  --green: #26ff7a;

  --shot-bg:   #000000;
  --shot-line: #262d34;

  /* Scroll-affordance shading for the nav list and wide tables. */
  --fade-shade: rgba(0, 0, 0, 0.55);

  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.62);
  --radius: 14px;

  --sans: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --header-h: 60px;
  --scrim: rgba(4, 6, 8, 0.68);
}

/* Light palette — opt-in ONLY.
   Dark is the default for every reader, matching the marketing site and the
   privacy page, which are hard-committed dark: following prefers-color-scheme
   here meant a reader clicking through from a dark footer landed on a white
   page. The header toggle (and only the toggle) switches to light. */
:root[data-theme='light'] {
  color-scheme: light;

  --bg:        #f5f7f6;
  --bg-soft:   #ffffff;
  --panel:     #ffffff;
  --panel-2:   #f0f3f1;
  --line:      #d8e0dc;
  --line-soft: #e6ebe8;

  --text:      #101619;
  --text-str:  #000000;
  --muted:     #4c5a61;
  --num:       #3d4a51;

  --accent:      #06713a;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(6, 113, 58, 0.09);
  --accent-line: rgba(6, 113, 58, 0.30);

  --amber:      #8a5300;
  --amber-soft: rgba(138, 83, 0, 0.09);
  --amber-line: rgba(138, 83, 0, 0.28);

  --cyan:      #056b76;
  --cyan-soft: rgba(5, 107, 118, 0.09);
  --cyan-line: rgba(5, 107, 118, 0.26);

  --gold:  #8a6100;
  --green: #06713a;

  /* Must be overridden: the dark #000 would flash as a solid black slab
     behind every screenshot that has not decoded yet, on a white page. */
  --shot-bg:   #eef1f0;
  --shot-line: #c9d2ce;

  --fade-shade: rgba(16, 30, 24, 0.26);

  --shadow: 0 14px 34px rgba(16, 30, 24, 0.12);
  --shadow-lg: 0 24px 60px rgba(16, 30, 24, 0.20);
  --scrim: rgba(24, 34, 30, 0.42);
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

strong { color: var(--text-str); font-weight: 700; }

code, .ui {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--text-str);
  white-space: nowrap;
}
/* Long control paths must be allowed to wrap on narrow screens. */
.ui.wrap { white-space: normal; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--panel-2);
  color: var(--muted);
}

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  font-weight: 800;
  z-index: 200;
  border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

.shell {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 18px;
}

/* ---------- Sticky site header ---------- */

.site-head {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-bottom: 1px solid var(--line);
}
.site-head .bar {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.brandmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex: 0 0 auto;
}
.brandmark:hover { text-decoration: none; }
.brandmark img { width: 24px; height: 24px; }
.brandmark span {
  font-family: 'DSEG14', monospace;
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.head-spacer { flex: 1 1 auto; }

.head-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.head-link {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}
.head-link:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
@media (max-width: 900px) { .head-link.optional { display: none; } }

/* "Help & Guide" beside the wordmark says which sub-site you are in. */
.guide-link {
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding-left: 12px;
  margin-left: 2px;
  color: var(--text-str);
}
.guide-link:hover { background: transparent; }
@media (max-width: 480px) { .guide-link { display: none; } }

.theme-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  /* WCAG 2.5.5 target size — the old 36×34 was under the 44px minimum. */
  width: 44px;
  height: 44px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: none; /* revealed by JS — a dead button is worse than none */
  align-items: center;
  justify-content: center;
}
.theme-btn.on { display: inline-flex; }
.theme-btn:hover { color: var(--accent); border-color: var(--accent-line); }

/* ---------- Search launcher ---------- */

.search-btn {
  appearance: none;
  cursor: pointer;
  display: none; /* revealed by JS — see .theme-btn */
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px 0 12px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.search-btn.on { display: inline-flex; }
.search-btn:hover { border-color: var(--accent-line); color: var(--text-str); }
.search-btn .mag { font-size: 17px; line-height: 1; color: var(--accent); }
.search-btn-text { min-width: 96px; text-align: left; }
@media (max-width: 620px) {
  .search-btn { padding: 0; width: 44px; justify-content: center; }
  .search-btn-text, .search-btn kbd { display: none; }
}

/* ---------- Hero (hub) ---------- */

.hero {
  padding: 34px 0 32px;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: -40% 25% auto;
  height: 320px;
  background: radial-gradient(circle at 50% 50%, var(--accent) 0%, transparent 62%);
  opacity: 0.10;
  pointer-events: none;
}
/* The dark accent reads as grey haze rather than a glow on a light page. */
:root[data-theme='light'] .hero::before { opacity: 0.045; }
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.hero h1 {
  font-size: clamp(30px, 6vw, 46px);
  line-height: 1.12;
  font-weight: 900;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
  color: var(--text-str);
  /* No hard <br>: it produced a ragged four-line wrap with orphans at 375px.
     A measure plus balancing lets the browser pick the break points. */
  max-width: 19ch;
  text-wrap: balance;
}
.hero .lede {
  font-size: clamp(15px, 2.1vw, 18px);
  color: var(--muted);
  max-width: 68ch;
  margin: 0;
}
.hero-meta {
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 30px;
}
.pill.accent { border-color: var(--accent-line); color: var(--accent); }
/* The only pill that is actually a control — sized as a real tap target and
   coloured so it does not read as another inert badge. */
a.pill.link {
  padding: 9px 15px;
  gap: 6px;
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}
a.pill.link:hover { background: var(--accent); color: var(--accent-ink); text-decoration: none; }

/* ---------- Topic hero ---------- */

.topic-hero {
  padding: 26px 0 26px;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  background: var(--bg-soft);
}
.topic-hero::before {
  content: '';
  position: absolute;
  inset: auto auto -150px -80px;
  width: 380px;
  height: 300px;
  background: radial-gradient(circle at 50% 50%, var(--accent) 0%, transparent 65%);
  opacity: 0.09;
  pointer-events: none;
}
:root[data-theme='light'] .topic-hero::before { opacity: 0.05; }
.topic-hero h1 {
  font-size: clamp(26px, 4.6vw, 38px);
  line-height: 1.14;
  font-weight: 900;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  color: var(--text-str);
  max-width: 22ch;
  text-wrap: balance;
}
.topic-hero .lede {
  font-size: clamp(15px, 1.9vw, 17.5px);
  color: var(--muted);
  max-width: 68ch;
  margin: 0;
}
.topic-hero .eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}
/* 18px, not 15: seven-segment numerals stop reading as numbers below about
   17px — at 15 the "0" was a rectangle. Full opacity too: at 0.6 these
   measured 2.64:1 in the light theme. */
.eyebrow-n {
  font-family: 'DSEG7', monospace;
  font-size: 18px;
  letter-spacing: 0.1em;
  color: var(--accent);
  line-height: 1;
}
.topic-hero .path { margin: 16px 0 0; }

/* ---------- Breadcrumbs ---------- */

.crumbs { margin: 0 0 16px; }
.crumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 0;
  padding: 0;
  font-size: 12.5px;
}
.crumbs li { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.crumbs li + li::before {
  content: '›';
  color: var(--accent);
  font-weight: 700;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs li[aria-current='page'] { color: var(--text-str); font-weight: 600; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: 'nav' 'rail' 'main';
  gap: 22px;
  padding: 22px 0 70px;
}
.sidenav { grid-area: nav; }
.layout > main { grid-area: main; }
.rail { grid-area: rail; }

@media (min-width: 1000px) {
  .layout {
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-areas: 'nav rail' 'nav main';
    gap: 12px 44px;
    align-items: start;
    padding-top: 30px;
  }
  .layout:not(.has-rail) { grid-template-areas: 'nav main' 'nav main'; }
}
@media (min-width: 1180px) {
  /* Wide enough for the rail to become a true right-hand column. */
  .layout.has-rail {
    grid-template-columns: 250px minmax(0, 1fr) 208px;
    grid-template-areas: 'nav main rail';
    gap: 44px;
  }
}

/* ---------- Persistent topic nav ----------
   A <details> so the mobile drawer opens with no JS at all; JS only adds
   Esc, scrim-dismiss and scroll locking on top. */

.sidenav { position: relative; }
.sidenav summary::-webkit-details-marker { display: none; }

.nav-toggle {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-str);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  position: sticky;
  top: calc(var(--header-h) + 8px);
  z-index: 40;
}
.nav-toggle:hover { border-color: var(--accent-line); }
/* Sans, not DSEG7: at badge size the seven-segment "15" is unreadable. */
.nav-toggle-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 20px;
  padding: 2px 8px;
  letter-spacing: 0.04em;
}
.burger {
  position: relative;
  width: 16px;
  height: 2px;
  background: var(--accent);
  flex: 0 0 auto;
  transition: background 0.15s ease;
}
.burger::before, .burger::after {
  content: '';
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: var(--accent);
  transition: transform 0.18s ease;
}
.burger::before { top: -5px; }
.burger::after { top: 5px; }
.sidenav[open] .burger { background: transparent; }
.sidenav[open] .burger::before { transform: translateY(5px) rotate(45deg); }
.sidenav[open] .burger::after { transform: translateY(-5px) rotate(-45deg); }

/* While the drawer is open the toggle becomes the drawer's own header, sat
   above the scrim — otherwise the ✕ is buried under the overlay and the only
   ways out are Escape or a lucky scrim tap. Pure CSS, so it closes with no
   JS at all. */
@media (max-width: 999.98px) {
  .sidenav[open] .nav-toggle {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 86vw);
    min-height: 54px;
    z-index: 101;
    border-radius: 0;
    border-top: 0;
    border-left: 0;
  }
  .sidenav[open] .burger { order: 2; margin-left: auto; }
  .sidenav[open] .nav-toggle-text { order: 1; }
  .sidenav[open] .nav-toggle-count { display: none; }
  .sidenav[open] .nav-panel { padding-top: 68px; }
}

.nav-scrim { display: none; }
.sidenav[open] .nav-scrim {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.nav-panel {
  position: fixed;
  z-index: 100;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(320px, 86vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 16px 14px 30px;
  animation: nav-in 0.2s ease both;
}
@keyframes nav-in { from { transform: translateX(-14px); opacity: 0; } }

.nav-inner > .nav-home {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 9px;
  margin-bottom: 8px;
  border: 1px solid var(--line-soft);
}
.nav-home:hover { color: var(--accent); border-color: var(--accent-line); text-decoration: none; }
.nav-home[aria-current='page'] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.nav-home-ico { color: var(--accent); font-size: 11px; }

.nav-list, .nav-list ul { list-style: none; margin: 0; padding: 0; }
.nav-list > li { margin: 0; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-group-h {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  /* NOT --muted at opacity — that measured under 4.5:1 in both themes. */
  color: var(--num);
  margin: 0 0 4px;
  padding: 0 10px;
}
.nav-list li { margin: 0; }
.nav-list a {
  display: flex;
  align-items: baseline;
  gap: 9px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 2px solid transparent;
}
/* Numbers are literal markup, not CSS counters, so the reading order can
   never drift out of sync with the pager.
   Deliberately NOT the DSEG7 face: seven-segment numerals are unreadable at
   nav size. The LED identity is carried by the brand mark and the numerals
   in the topic hero instead. */
.nav-list a .n {
  flex: 0 0 auto;
  min-width: 17px;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--num);
}
.nav-list a .l { min-width: 0; }
.nav-list a:hover {
  color: var(--text-str);
  background: var(--accent-soft);
  text-decoration: none;
}
.nav-list a[aria-current='page'] {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-list a[aria-current='page'] .n { color: var(--accent); }

@media (min-width: 1000px) {
  /* Desktop: no drawer. The panel is simply always shown, whatever the
     <details> open state happens to be.
     ::details-content is how current engines hide the closed content, so
     `display` alone is not enough to force it back. */
  .sidenav::details-content {
    content-visibility: visible;
    block-size: auto;
  }
  .nav-toggle, .nav-scrim { display: none; }
  /* Sticky goes on the GRID ITEM, not on .nav-panel. A sticky child can only
     travel inside its parent's box, and .sidenav is exactly as tall as the
     panel — zero room, so it never stuck and rode up over the header. As a
     grid item it travels across its whole grid area instead. */
  .sidenav {
    position: sticky;
    top: calc(var(--header-h) + 16px);
  }
  .nav-panel {
    /* `inset` must come before `top`/`z-index`: it is a shorthand and resets
       whatever the drawer set. */
    inset: auto;
    position: static;
    z-index: auto;
    width: auto;
    max-height: calc(100vh - var(--header-h) - 40px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: none;
    padding: 14px 12px 16px;
    animation: none;
    /* Scroll-shadow: the two `local` gradients ride the content and mask the
       two `scroll` shadows away at each end, so the fade appears only while
       there is genuinely more list to reach. No JS, no false affordance.
       overscroll-behavior stays default — trapping the wheel over the
       sidebar stranded readers on short viewports. */
    overscroll-behavior: auto;
    background:
      linear-gradient(var(--panel) 40%, rgba(0, 0, 0, 0)) top    / 100% 22px no-repeat local,
      linear-gradient(rgba(0, 0, 0, 0), var(--panel) 60%) bottom / 100% 22px no-repeat local,
      linear-gradient(var(--fade-shade), rgba(0, 0, 0, 0)) top    / 100% 14px no-repeat scroll,
      linear-gradient(rgba(0, 0, 0, 0), var(--fade-shade)) bottom / 100% 14px no-repeat scroll,
      var(--panel);
  }
}

/* ---------- On this page (right rail) ---------- */

.rail-box {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 4px 4px;
}
.rail-box > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  border-radius: 9px;
}
.rail-box > summary::-webkit-details-marker { display: none; }
.rail-box > summary::after {
  content: '▾';
  margin-left: auto;
  font-size: 12px;
  color: var(--accent);
  transition: transform 0.16s ease;
}
.rail-box[open] > summary::after { transform: rotate(180deg); }
.rail-box > summary:hover { color: var(--text-str); background: var(--accent-soft); }

.rail-list {
  list-style: none;
  margin: 0;
  padding: 2px 0 6px;
  counter-reset: rail;
}
.rail-list li { margin: 0; }
.rail-list a {
  display: block;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid var(--line-soft);
  margin-left: 10px;
}
.rail-list a:hover { color: var(--text-str); border-left-color: var(--accent-line); text-decoration: none; }
.rail-list a[aria-current='true'] {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

@media (min-width: 1180px) {
  .layout.has-rail .rail {
    position: sticky;
    top: calc(var(--header-h) + 16px);
    max-height: calc(100vh - var(--header-h) - 40px);
    overflow-y: auto;
  }
  /* At full width it is a permanent rail, not a disclosure. */
  .layout.has-rail .rail-box { border: 0; background: transparent; padding: 0; }
  .layout.has-rail .rail-box > summary { pointer-events: none; padding-left: 12px; }
  .layout.has-rail .rail-box > summary::after { display: none; }
  .layout.has-rail .rail-box::details-content {
    content-visibility: visible;
    block-size: auto;
  }
}

/* ---------- Document ---------- */

/* The skip link's target. It carries tabindex="-1" so focus really moves;
   the scroll margin keeps the landing point clear of the sticky header. */
main {
  scroll-margin-top: calc(var(--header-h) + 18px);
  min-width: 0;
}
main:focus { outline: none; }

/* Comfortable measure. Body copy only — figures, tables and the bands grid
   deliberately keep the full column width. */
main p,
main li,
main .note {
  max-width: 72ch;
}

h1 { color: var(--text-str); }

/* Topic pages: the page title is the h1, so the document's own sections sit
   one level up from where they were in the single-page guide. */
.doc > h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 34px 0 8px;
  color: var(--text-str);
  letter-spacing: -0.005em;
  scroll-margin-top: calc(var(--header-h) + 18px);
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}
.doc > h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.doc h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 22px 0 6px;
  color: var(--text-str);
  scroll-margin-top: calc(var(--header-h) + 18px);
}
.doc h2 + p, .doc h3 + p { margin-top: 0; }

p { margin: 0 0 13px; }
.lede { color: var(--muted); font-size: 16.5px; }

ul, ol.steps { padding-left: 22px; margin: 0 0 14px; }
li { margin: 6px 0; }
ol.steps li { padding-left: 3px; }
ol.steps li::marker { color: var(--accent); font-weight: 700; }

.anchor {
  color: var(--line);
  text-decoration: none;
  font-weight: 400;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
h2:hover .anchor, h3:hover .anchor,
.anchor:focus-visible { opacity: 1; color: var(--accent); }
@media (hover: none) { .anchor { display: none; } }

/* ---------- Path breadcrumb (Settings > Chimes > ...) ---------- */

.path {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 6px 11px;
  margin: 0 0 16px;
  line-height: 1.5;
}
/* Inline use (<span class="path"> mid-sentence) must not inherit the
   standalone breadcrumb's bottom margin — it injected a 16px gap into the
   middle of a paragraph. */
span.path { margin: 0; }
.path b { color: var(--text-str); font-weight: 700; }
.path i { color: var(--accent); font-style: normal; opacity: 0.75; }

/* ---------- Screenshots ---------- */

figure.shot {
  margin: 18px 0 22px;
  max-width: 520px;
}
figure.shot img {
  width: 100%;
  border-radius: 10px;
  background: var(--shot-bg);
  border: 1px solid var(--shot-line);
  box-shadow: var(--shadow);
}
figure.shot figcaption {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 9px;
  line-height: 1.5;
}
figure.shot.tall { max-width: 330px; }

/* ---------- Cards, notes, tables ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 18px 0;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card h2, .card h3, .card h4 { margin-top: 0; }
.card h2 { border-top: 0; padding-top: 0; font-size: 17px; }

/* Small print inside a card, and a list that ends flush with the card foot —
   replaces the style="" attributes that used to do this inline. */
.fine { color: var(--muted); font-size: 14.5px; margin-bottom: 0; }
ul.flush { margin-bottom: 0; }
.cta { margin-top: 26px; }

.note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  background: var(--panel);
  border-radius: 10px;
  padding: 13px 16px;
  margin: 18px 0;
  font-size: 15px;
}
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.note .tag {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 5px;
  color: var(--muted);
}
.note.tip { border-left-color: var(--accent); background: var(--accent-soft); }
.note.tip .tag { color: var(--accent); }
.note.warn { border-left-color: var(--amber); background: var(--amber-soft); }
.note.warn .tag { color: var(--amber); }
.note.info { border-left-color: var(--cyan); background: var(--cyan-soft); }
.note.info .tag { color: var(--cyan); }

/* Keyboard-reachable scroll region (WCAG 2.1.1): the markup carries
   tabindex="0" + role="region" + aria-label, so a scrollable table is not
   sealed off from keyboard users. */
.tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 18px 0;
  background: var(--panel);
}
/* Right-edge fade = "there is more table this way". Applied up front to the
   one table that is always scrollable on a phone, so it works without JS;
   help.js widens it to any wrapper that turns out to overflow and clears it
   at the end of the scroll, so a fully visible table is never faded. */
.tablewrap.wide,
.tablewrap.scrollable {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 46px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 46px), transparent 100%);
}
.tablewrap.at-end {
  -webkit-mask-image: none;
  mask-image: none;
}
table {
  width: 100%;
  /* 300px, not 420px: at 375px the content column is 339px, so 420 forced
     every two-column table to clip mid-word with no visible affordance. */
  min-width: 300px;
  border-collapse: collapse;
  font-size: 14.5px;
}
/* The one genuinely three-column table still needs room, so it — and only
   it — keeps a real horizontal scroll. */
.tablewrap.wide table { min-width: 560px; }
caption {
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px 0;
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
thead th {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel-2);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
/* One column rhythm across all fourteen tables rather than a per-table
   width decided by whatever happens to be in the first cell. */
th:first-child, td:first-child { width: 26%; }
td:first-child { color: var(--text-str); font-weight: 600; }
td .df {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 20px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: 1px;
  white-space: nowrap;
}

/* ---------- Qibla alignment bands ---------- */

.bands { display: grid; gap: 12px; margin: 18px 0; }
@media (min-width: 640px) { .bands { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.band {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px 16px;
}
.band .swatch {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 7px;
}
.band .swatch::before {
  content: '';
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex: 0 0 auto;
}
/* DSEG7 is a seven-segment DIGIT face — words rendered in it are unreadable.
   Only the degree figure gets the LED treatment; the qualifier stays in sans. */
.band .deg {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 7px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.band .deg b {
  font-family: 'DSEG7', monospace;
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.03em;
}
.band p { font-size: 14px; color: var(--muted); margin: 0; }
.band.gold  { border-color: color-mix(in srgb, var(--gold) 40%, var(--line)); }
.band.gold .swatch { color: var(--gold); }
.band.gold .swatch::before { background: var(--gold); box-shadow: 0 0 10px color-mix(in srgb, var(--gold) 55%, transparent); }
.band.gold .deg { color: var(--gold); }
.band.green { border-color: color-mix(in srgb, var(--green) 34%, var(--line)); }
.band.green .swatch { color: var(--green); }
.band.green .swatch::before { background: var(--green); box-shadow: 0 0 10px color-mix(in srgb, var(--green) 45%, transparent); }
.band.green .deg { color: var(--green); }
.band.off .swatch { color: var(--muted); }
.band.off .swatch::before { background: var(--muted); }
.band.off .deg { color: var(--muted); }

/* ---------- FAQ ---------- */

.faq {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin: 10px 0;
  overflow: hidden;
  /* Each question is a deep-link target (help.js opens it on hash). */
  scroll-margin-top: calc(var(--header-h) + 18px);
}
.faq:target { border-color: var(--accent-line); }
.faq summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 700;
  color: var(--text-str);
  list-style: none;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: '+';
  color: var(--accent);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.35;
  flex: 0 0 auto;
}
.faq[open] summary::before { content: '\2212'; }
.faq summary:hover { background: var(--accent-soft); }
.faq .body { padding: 0 18px 16px 42px; }
.faq .body > :last-child { margin-bottom: 0; }

/* ---------- Hub ---------- */

.hub-lede {
  color: var(--muted);
  font-size: 16px;
  margin: 0 0 26px;
}
.hub-group { margin: 0 0 34px; }
.hub-group h2 {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--num);
  margin: 0 0 12px;
}
.hub-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
}
.hub-grid li { margin: 0; max-width: none; }
.hub-card a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: 'n t go' 'n d go';
  column-gap: 12px;
  height: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.hub-card a:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  transform: translateY(-2px);
  text-decoration: none;
}
/* Same 17px floor as the topic hero — smaller and the LED face turns the
   digits into blocks. */
.hub-n {
  grid-area: n;
  font-family: 'DSEG7', monospace;
  font-size: 17px;
  line-height: 1.35;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.hub-t {
  grid-area: t;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-str);
  line-height: 1.4;
}
.hub-d {
  grid-area: d;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 3px;
}
.hub-go {
  grid-area: go;
  align-self: center;
  color: var(--accent);
  font-size: 16px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.hub-card a:hover .hub-go, .hub-card a:focus-visible .hub-go {
  opacity: 1;
  transform: translateX(0);
}
@media (hover: none) { .hub-go { opacity: 1; transform: none; } }

/* ---------- Prev / next pager ---------- */

.pager {
  display: grid;
  gap: 12px;
  margin: 44px 0 0;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
@media (min-width: 600px) { .pager { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pager-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.pager-item:hover { border-color: var(--accent-line); background: var(--accent-soft); text-decoration: none; }
.pager-item.next { text-align: right; }
.pager-k {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.pager-t { font-size: 15px; font-weight: 700; color: var(--text-str); line-height: 1.35; }

/* ---------- Search dialog ---------- */

.sdlg {
  width: min(640px, calc(100vw - 24px));
  max-width: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  margin-top: min(9vh, 90px);
  margin-bottom: auto;
}
.sdlg::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sdlg-form { margin: 0; display: flex; flex-direction: column; max-height: min(74vh, 620px); }
.sdlg-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sdlg-bar .mag { font-size: 20px; line-height: 1; color: var(--accent); }
.sdlg-bar input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  padding: 8px 2px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
}
.sdlg-bar input::placeholder { color: var(--muted); }
.sdlg-close {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  flex: 0 0 auto;
}
.sdlg-close:hover { color: var(--accent); border-color: var(--accent-line); }
.sdlg-status {
  margin: 0;
  padding: 9px 16px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}
.sdlg-status:empty { display: none; }
.sdlg-status a { font-weight: 600; }
.sdlg-results {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  flex: 1 1 auto;
}
.sdlg-results:empty { display: none; }
.sres {
  display: block;
  padding: 10px 12px;
  border-radius: 9px;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.sres:hover, .sres.sel {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  text-decoration: none;
}
.sres-p {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--num);
  margin-bottom: 2px;
}
.sres-t { display: block; font-size: 14.5px; font-weight: 700; color: var(--text-str); line-height: 1.35; }
.sres-x { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 3px; }
.sres mark {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: var(--text-str);
  border-radius: 3px;
  padding: 0 1px;
}
.sdlg-hint {
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 11.5px;
  color: var(--muted);
  flex: 0 0 auto;
}
.sdlg-hint span { display: inline-flex; align-items: center; gap: 5px; }
.sdlg-hint kbd { font-size: 10px; }
@media (max-width: 560px) { .sdlg-hint { display: none; } }

/* ---------- Contact / footer ---------- */

.contact-grid { display: grid; gap: 14px; margin: 18px 0; }
@media (min-width: 640px) { .contact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.contact-grid .card { margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 22px;
  border-radius: 40px;
  border: 2px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  background: transparent;
}
.btn:hover { background: var(--accent-soft); text-decoration: none; }
.btn.solid { background: var(--accent); color: var(--accent-ink); }
.btn.solid:hover { background: var(--accent); filter: brightness(1.08); }

.site-foot {
  border-top: 1px solid var(--line);
  padding: 26px 0 40px;
  font-size: 13px;
  color: var(--muted);
}
.site-foot .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: space-between;
}
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

/* ---------- Back to top ---------- */

.totop {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent);
  text-decoration: none;
  font-size: 18px;
  box-shadow: var(--shadow);
}
.totop.on { display: flex; }
.totop:hover { border-color: var(--accent-line); text-decoration: none; }

/* At 375px the text column runs edge to edge, so a permanently parked FAB
   sits on top of body copy. JS reveals it only while the reader is scrolling
   back up (or is at the very bottom) — the moments it is actually wanted —
   and the footer gets clearance so its resting position covers nothing. */
@media (max-width: 700px) {
  .totop { right: 12px; bottom: 12px; }
  .site-foot { padding-bottom: 86px; }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-head, .sidenav, .rail, .totop, .pager, .crumbs, .sdlg { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { display: block; padding: 0; }
  .doc > h2 { page-break-after: avoid; }
  figure.shot, .card, .note, .tablewrap { page-break-inside: avoid; }
  /* A printed FAQ of twelve collapsed questions and no answers is useless.
     help.js opens every <details> on beforeprint — that is the mechanism that
     actually works everywhere. These two rules are the CSS backstop for the
     two ways engines hide the content (old: the slot; new: the pseudo). */
  details.faq > *:not(summary) { display: block !important; }
  details.faq::details-content {
    content-visibility: visible !important;
    block-size: auto !important;
  }
  details.faq summary::before { content: '\2212'; }
  .tablewrap { overflow: visible !important; }
  main p, main li, main .note { max-width: none; }
}
