/* Gesher help: static, offline. Colours follow the app (Theme.xaml): near-black #14161C with a teal accent in dark, the app's own light set in light. */
:root {
  color-scheme: light dark;
  --bg: #F4F5F8; --panel: #FFFFFF; --raised: #EEF0F4; --hover: #E4E7EE; --line: #D5D9E2;
  --text: #1B1F29; --muted: #5B6475; --faint: #7C8497;
  --accent: #0E9F8A; --accent-dim: #0B7A6B; --accent-wash: rgba(14,159,138,.12); --on-accent: #FFFFFF;
  --danger: #D93636; --mark: #FFE27A; --mark-text: #1B1F29; --code-bg: #EEF0F4;
  --shadow: 0 8px 28px rgba(20,22,28,.14);
  --header-h: 60px; --nav-w: 292px; --toc-w: 220px;
  --ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161C; --panel: #181B22; --raised: #20242E; --hover: #262B37; --line: #2A2F3A;
    --text: #E8EAF0; --muted: #8B93A5; --faint: #5C6475;
    --accent: #2DE0C2; --accent-dim: #1F9C88; --accent-wash: rgba(45,224,194,.10); --on-accent: #0B1512;
    --danger: #FF6B6B; --mark: #F5D547; --mark-text: #14161C; --code-bg: #0F1116;
    --shadow: 0 8px 28px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  --bg: #14161C; --panel: #181B22; --raised: #20242E; --hover: #262B37; --line: #2A2F3A;
  --text: #E8EAF0; --muted: #8B93A5; --faint: #5C6475;
  --accent: #2DE0C2; --accent-dim: #1F9C88; --accent-wash: rgba(45,224,194,.10); --on-accent: #0B1512;
  --danger: #FF6B6B; --mark: #F5D547; --mark-text: #14161C; --code-bg: #0F1116;
  --shadow: 0 8px 28px rgba(0,0,0,.55);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 18px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { overflow-wrap: break-word; margin: 0; background: var(--bg); color: var(--text); font: 16px/1.62 var(--ui); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-dim); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-wash); }

.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 10px; }

/* ---------- top bar ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 50; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: .01em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand svg { width: 26px; height: 26px; }
.brand small { font-weight: 500; font-size: 13px; color: var(--muted); }
.icon-btn { appearance: none; border: 1px solid transparent; background: transparent; color: var(--muted); width: 38px; height: 38px; border-radius: 9px; display: inline-grid; place-items: center; cursor: pointer; font: inherit; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
#menu-btn { display: none; }

.search { position: relative; flex: 1; max-width: 640px; margin: 0 auto; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 64px 0 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 15px; }
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input:not(:placeholder-shown) ~ kbd { display: none; }
kbd { font: 600 12px/1 var(--mono); padding: 4px 7px; border-radius: 6px; background: var(--raised); border: 1px solid var(--line); border-bottom-width: 2px; color: var(--muted); white-space: nowrap; }
.results { position: absolute; left: 0; right: 0; top: 46px; max-height: min(70vh, 560px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; }
.results.open { display: block; }
.result { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; }
.result[aria-selected="true"], .result:hover { background: var(--hover); }
.result .t { font-weight: 600; font-size: 15px; }
.result .p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.result .s { font-size: 13.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.results .none { padding: 14px; color: var(--muted); }
.results .count { padding: 6px 12px 8px; font-size: 12px; color: var(--faint); }
mark, mark.hit { background: var(--mark); color: var(--mark-text); border-radius: 3px; padding: 0 1px; }
mark.current { outline: 2px solid var(--accent); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--toc-w); padding-top: var(--header-h); min-height: 100vh; }
nav.tree { position: sticky; top: var(--header-h); align-self: start; height: calc(100vh - var(--header-h)); overflow: auto; padding: 16px 10px 40px 14px; border-right: 1px solid var(--line); background: var(--panel); scrollbar-width: thin; }
nav.tree ul { list-style: none; margin: 0; padding: 0; }
nav.tree > ul > li { margin: 2px 0; }
.grp { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; background: none; border: 0; color: var(--text); font: 600 14.5px/1.3 var(--ui); padding: 8px 8px; border-radius: 8px; cursor: pointer; }
.grp:hover { background: var(--hover); }
.grp .chev { width: 14px; height: 14px; flex: none; color: var(--faint); transition: transform .15s; }
li.open > .grp .chev { transform: rotate(90deg); }
nav.tree a { display: block; color: var(--muted); text-decoration: none; padding: 5px 10px 5px 30px; border-radius: 7px; font-size: 14px; line-height: 1.35; }
nav.tree a:hover { background: var(--hover); color: var(--text); }
nav.tree .sub { display: none; margin: 0 0 6px; }
nav.tree li.open > .sub { display: block; }
nav.tree a.current { color: var(--accent); background: var(--accent-wash); font-weight: 600; }
nav.tree a.hit::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--mark); margin-left: 8px; vertical-align: middle; }
.grp.hit::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mark); margin-left: auto; }
nav.tree a.pick { outline: 2px solid var(--accent); outline-offset: -2px; }
.grp.current-grp { color: var(--accent); }

main { padding: 36px clamp(20px, 4vw, 56px) 120px; min-width: 0; }
.doc { max-width: 800px; margin: 0 auto; }
aside.toc { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow: auto; padding: 36px 16px 24px 4px; font-size: 13.5px; }
aside.toc h2 { font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); margin: 0 0 8px; font-weight: 700; }
aside.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
aside.toc a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.35; }
aside.toc a:hover { color: var(--text); }
aside.toc a.current { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ---------- content ---------- */
.doc h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.12; margin: 6px 0 14px; letter-spacing: -.01em; }
.doc .lead { font-size: 19px; color: var(--muted); margin: 0 0 18px; }
section.group { padding-top: 10px; margin-top: 54px; border-top: 1px solid var(--line); }
section.group:first-of-type { border-top: 0; margin-top: 30px; }
.doc h2 { font-size: 27px; line-height: 1.2; margin: 22px 0 6px; letter-spacing: -.005em; }
.doc h3 { font-size: 20px; line-height: 1.3; margin: 40px 0 8px; }
.doc h4 { font-size: 16px; margin: 24px 0 4px; color: var(--text); }
.doc h2 .anchor, .doc h3 .anchor { opacity: 0; margin-left: 8px; text-decoration: none; font-weight: 400; color: var(--faint); }
.doc h2:hover .anchor, .doc h3:hover .anchor, .anchor:focus { opacity: 1; }
.doc p, .doc li { max-width: 72ch; }
.doc ul, .doc ol { padding-left: 1.4em; }
.doc li { margin: 4px 0; }
.doc li > ul, .doc li > ol { margin-top: 4px; }
code { font: 0.9em var(--mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow: auto; line-height: 1.5; margin: 14px 0; }
pre code { background: none; border: 0; padding: 0; font-size: 13.5px; overflow-wrap: normal; }
.copy-btn { float: right; margin: -6px -8px 0 8px; font: 600 12px var(--ui); padding: 4px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--raised); color: var(--muted); cursor: pointer; }
.copy-btn:hover { color: var(--text); }
.example, .note, .warn { border-radius: 11px; padding: 12px 16px 12px 18px; margin: 16px 0; border: 1px solid var(--line); border-left-width: 4px; background: var(--panel); max-width: 78ch; }
.example { border-left-color: var(--accent); }
.example > :first-child, .note > :first-child, .warn > :first-child { margin-top: 0; }
.example > :last-child, .note > :last-child, .warn > :last-child { margin-bottom: 0; }
.example::before { content: "Example"; display: block; font: 700 11.5px var(--ui); letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.note { border-left-color: var(--faint); }
.note::before { content: "Good to know"; display: block; font: 700 11.5px var(--ui); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.warn { border-left-color: var(--danger); }
.warn::before { content: "Careful"; display: block; font: 700 11.5px var(--ui); letter-spacing: .09em; text-transform: uppercase; color: var(--danger); margin-bottom: 4px; }
figure { margin: 22px 0; }
figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 2px 14px rgba(0,0,0,.18); }
figure.narrow img { max-width: 320px; width: 100%; }
/* phone pictures side by side: two to a row when there is room, one under the other on a narrow screen */
.shots { display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: flex-start; }
.shots figure { flex: 0 1 320px; min-width: 0; }
figure.mid img { max-width: 620px; }
figcaption { font-size: 13.5px; color: var(--muted); margin-top: 8px; max-width: 72ch; }
.tablewrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; vertical-align: top; padding: 9px 14px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--raised); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
td code { white-space: nowrap; }
td.wrap, td.wrap code { white-space: normal; }
dl.gloss dt { font-weight: 700; margin-top: 16px; }
dl.gloss dd { margin: 2px 0 0 0; color: var(--muted); max-width: 72ch; }
details { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); margin: 10px 0; padding: 0 16px; }
details summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style-position: outside; }
details[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
details > :last-child { margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 20px 0; }
.card { display: block; text-decoration: none; color: var(--text); border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 14px 16px; }
.card:hover { border-color: var(--accent); color: var(--text); }
.card b { display: block; margin-bottom: 2px; }
.card span { color: var(--muted); font-size: 14px; }
.steps { counter-reset: s; list-style: none; padding-left: 0; }
.steps > li { counter-increment: s; position: relative; padding-left: 40px; margin: 10px 0; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-wash); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.foot { margin-top: 70px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--faint); font-size: 13.5px; }

#top-btn { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); box-shadow: var(--shadow); cursor: pointer; display: none; place-items: center; }
#top-btn.show { display: grid; }
#top-btn:hover { border-color: var(--accent); color: var(--accent); }
#top-btn svg { width: 20px; height: 20px; }
.scrim { display: none; }

/* ---------- narrower screens ---------- */
@media (max-width: 1280px) { .layout { grid-template-columns: var(--nav-w) minmax(0, 1fr); } aside.toc { display: none; } }
@media (max-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  #menu-btn { display: inline-grid; }
  nav.tree { position: fixed; z-index: 60; top: var(--header-h); left: 0; bottom: 0; width: min(88vw, 340px); height: auto; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open nav.tree { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0,0,0,.45); z-index: 55; }
  .brand small { display: none; }
  .search kbd { display: none; }
  main { padding: 24px 16px 100px; }
  .doc h2 { font-size: 24px; }
}
@media (max-width: 520px) { .topbar { padding: 0 10px; gap: 8px; } .brand span.name { display: none; } }
@media print {
  .topbar, nav.tree, aside.toc, #top-btn, .copy-btn { display: none !important; }
  .layout { display: block; padding-top: 0; }
  body { background: #fff; color: #000; }
  figure img { box-shadow: none; }
}
