/* SonoScope User Guide — clean, readable, chapter-based. Colours are SonoScope's own: the electric cyan of the app
   and the violet it pairs with, on cool near-black neutrals. The violet carries the "The idea" teaching boxes,
   exactly as it carries the second curve in the app. */
:root {
  --accent: #0e7490;          /* cyan, deep enough for links and headings on white */
  --accent-soft: #e4f6fa;
  /* Gradients: --grad is the app's own cyan → violet; --grad-deep is the same hues darkened so white text on it
     and gradient text on white both stay readable. */
  --grad: linear-gradient(100deg, #2fd8ea 0%, #5bb6ef 45%, #a78bfa 100%);
  --grad-deep: linear-gradient(100deg, #0891b2 0%, #3f7fd0 50%, #7c3aed 100%);
  --grad-text: var(--grad-deep);
  --bg: #ffffff;
  --bg-side: #f5f7fa;
  --bar: #07090f;
  --bar-text: #e8edf5;
  --text: #101623;
  --muted: #5b667c;
  --rule: #dde3ee;
  --code-bg: #f1f3f8;
  --tip: #0f7a4f;  --tip-bg: #eaf7f1;
  --note: #1667b3; --note-bg: #eaf4fd;
  --warn: #b42318; --warn-bg: #fdeeec;
  --concept: #6d28d9; --concept-bg: #f4eefe;
  --shadow: 0 1px 2px rgba(7,9,15,.06), 0 4px 18px rgba(7,9,15,.07);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #2fd8ea; --accent-soft: #11242c; --grad-text: var(--grad);
    --bg: #07090f; --bg-side: #10141f; --bar: #05060a; --bar-text: #e8edf5;
    --text: #e8edf5; --muted: #8b96ab; --rule: #232a3b; --code-bg: #161b29;
    --tip: #34d399; --tip-bg: #0d2420; --note: #7cc4ff; --note-bg: #10212f;
    --warn: #fb7185; --warn-bg: #2b1119; --concept: #c4a3ff; --concept-bg: #1c1630;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --accent: #2fd8ea; --accent-soft: #11242c; --grad-text: var(--grad);
  --bg: #07090f; --bg-side: #10141f; --bar: #05060a; --bar-text: #e8edf5;
  --text: #e8edf5; --muted: #8b96ab; --rule: #232a3b; --code-bg: #161b29;
  --tip: #34d399; --tip-bg: #0d2420; --note: #7cc4ff; --note-bg: #10212f;
  --warn: #fb7185; --warn-bg: #2b1119; --concept: #c4a3ff; --concept-bg: #1c1630;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 18px;
  padding: 0 24px; background: var(--bar); color: var(--bar-text);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--bar-text); font-weight: 600; letter-spacing: .2px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 2px rgba(255,255,255,.08); }
.brand small { font-weight: 400; opacity: .7; }
.brand-icon { width: 26px; height: 26px; }
.search { position: relative; margin-left: auto; width: min(360px, 45vw); }
.search input {
  width: 100%; height: 34px; border-radius: 17px; border: 1px solid rgba(255,255,255,.14); padding: 0 14px 0 34px;
  background: rgba(255,255,255,.08); color: var(--bar-text); font: inherit; font-size: 15px; outline: none;
}
.search input::placeholder { color: rgba(242,240,248,.55); }
.search input:focus { border-color: #f1541b; background: rgba(255,255,255,.12); }
.search svg { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; opacity: .6; }
.results {
  position: absolute; top: 42px; right: 0; width: min(520px, 92vw); max-height: 70vh; overflow: auto; display: none;
  background: var(--bg); color: var(--text); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.results.open { display: block; }
.results a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--rule); color: var(--text); }
.results a:hover, .results a.sel { background: var(--accent-soft); text-decoration: none; }
.results .r-title { font-weight: 600; font-size: 15px; }
.results .r-where { font-size: 12px; color: var(--muted); }
.results .r-snip { font-size: 13px; color: var(--muted); margin-top: 2px; }
.results mark { background: none; color: var(--accent); font-weight: 600; }
.results .none { padding: 14px; color: var(--muted); font-size: 14px; }
.theme-btn { background: none; border: 0; color: var(--bar-text); opacity: .7; cursor: pointer; font-size: 18px; padding: 4px; }
.theme-btn:hover { opacity: 1; }
.menu-btn { display: none; background: none; border: 0; color: var(--bar-text); font-size: 22px; cursor: pointer; }

/* Chapter strip under the bar, in the brand gradient */
.band { background: var(--grad-deep); color: #fff; padding: 8px 24px; font-size: 14px; font-weight: 500; }
.band a { color: #fff; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; max-width: 1220px; margin: 0 auto; gap: 48px; padding: 0 24px; }
main { min-width: 0; padding: 34px 0 80px; max-width: 780px; }
nav.toc {
  position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 88px); overflow: auto;
  margin-top: 30px; padding: 16px 16px 20px; background: var(--bg-side); border-radius: 8px; font-size: 14px; line-height: 1.4;
}
.toc h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 0 0 10px; }
.toc .part { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 14px 0 4px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 1px 0; }
.toc a { display: block; padding: 3px 6px; border-radius: 4px; color: var(--text); }
.toc a:hover { background: var(--accent-soft); text-decoration: none; }
.toc a.current { color: var(--accent); font-weight: 600; }
.toc ol.sections { margin: 2px 0 6px 14px; border-left: 2px solid var(--rule); padding-left: 6px; }
.toc ol.sections a { color: var(--muted); font-size: 13px; padding: 2px 6px; }
.toc ol.sections a:hover, .toc ol.sections a.here { color: var(--accent); }

/* Text */
main h1 { font-size: 40px; line-height: 1.15; color: var(--accent); margin: 0 0 22px; letter-spacing: -.4px;
          background: var(--grad-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
          width: fit-content; max-width: 100%; }   /* the gradient spans the words, not the column */
main h1 .num { opacity: .95; }
main h2 { font-size: 27px; line-height: 1.25; margin: 46px 0 12px; padding-top: 6px; border-top: 1px solid var(--rule); padding-top: 26px; }
main h3 { font-size: 20px; margin: 30px 0 8px; }
main h4 { font-size: 16px; margin: 0 0 6px; }
main p, main li, main dd { max-width: 70ch; }
p.lead { font-size: 19px; color: var(--text); }
.anchor { margin-left: 8px; opacity: 0; font-weight: 400; font-size: .7em; color: var(--muted); }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
ul, ol { padding-left: 1.4em; }
li { margin: 4px 0; }
ol.steps { counter-reset: s; list-style: none; padding-left: 0; }
ol.steps > li { counter-increment: s; position: relative; padding-left: 40px; margin: 10px 0; }
ol.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--grad-deep); color: #fff; font-size: 14px; font-weight: 600; text-align: center; line-height: 26px;
}
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 .4em; margin: 0 1px; border: 1px solid var(--rule); border-bottom-width: 2px;
  border-radius: 4px; background: var(--code-bg); font: 600 .82em/1.6 -apple-system, BlinkMacSystemFont, sans-serif; text-align: center; color: var(--text);
}
.menu { font-weight: 600; white-space: nowrap; }
b.ui { font-weight: 600; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; font-size: .9em; }

dl.controls { margin: 16px 0 24px; border-top: 1px solid var(--rule); }
dl.controls dt { font-weight: 650; margin-top: 14px; color: var(--text); }
dl.controls dd { margin: 3px 0 14px 0; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }

aside { margin: 22px 0; padding: 14px 18px 14px 18px; border-radius: 8px; border-left: 4px solid; }
aside p { margin: 6px 0; }
aside::before { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 2px; }
aside.tip { background: var(--tip-bg); border-color: var(--tip); }      aside.tip::before { content: "Tip"; color: var(--tip); }
aside.note { background: var(--note-bg); border-color: var(--note); }   aside.note::before { content: "Note"; color: var(--note); }
aside.warning { background: var(--warn-bg); border-color: var(--warn); } aside.warning::before { content: "Careful"; color: var(--warn); }
aside.concept { background: var(--concept-bg); border-color: var(--concept); } aside.concept::before { content: "The idea"; color: var(--concept); }
aside.concept h4 { color: var(--concept); font-size: 17px; }

figure { margin: 26px 0; }
/* No drop shadow on a screenshot. The shadow exists to lift a LIGHT image off
   a light page; every shot here is the app's dark theme, which already has a
   hard edge, so an 18px halo at 7% just drew a grey frame around it. The
   hairline border stays — it is invisible against a dark shot on white, and
   it is what separates the image from the page in the guide's dark mode. */
figure img { display: block; max-width: 100%; height: auto; margin-inline: auto; border-radius: 6px; border: 1px solid var(--rule); }
/* A shot carries its own max-width from the builder (half its 2x pixel size),
   so a narrow phone card is never stretched up to the column width. Centred,
   because a 360px figure hard against the left margin reads as a mistake. */
figure.shot img { width: auto; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }
figure.missing { display: none; }

table.ref { border-collapse: collapse; width: 100%; margin: 18px 0 26px; font-size: 15px; }
table.ref th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); border-bottom: 2px solid var(--rule); padding: 8px 10px; }
table.ref td { border-bottom: 1px solid var(--rule); padding: 8px 10px; vertical-align: top; }
table.ref tr:hover td { background: var(--bg-side); }

dl.glossary dt { font-weight: 650; margin-top: 18px; scroll-margin-top: 80px; }
dl.glossary dd { margin: 4px 0 0 0; }
dl.glossary dt:target { color: var(--accent); }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 60px; padding-top: 22px; border-top: 1px solid var(--rule); }
.pager a { display: block; max-width: 48%; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 8px; color: var(--text); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager small { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.pager .next { margin-left: auto; text-align: right; }

/* The contents page */
.contents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; margin-top: 24px; }
.contents-grid section { background: var(--bg-side); border-radius: 8px; padding: 16px 18px; }
.contents-grid h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.contents-grid ol { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.contents-grid li { margin: 5px 0; }

footer { color: var(--muted); font-size: 13px; padding: 24px; text-align: center; border-top: 1px solid var(--rule); }
footer .tm { max-width: 820px; margin: 10px auto 0; font-size: 11.5px; line-height: 1.5; opacity: .8; }

/* Narrow screens: the contents become a drawer */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 16px; }
  nav.toc { position: fixed; top: 56px; right: 0; bottom: 0; width: min(330px, 88vw); max-height: none; margin: 0; border-radius: 0;
            transform: translateX(105%); transition: transform .2s; z-index: 15; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
  body.toc-open nav.toc { transform: none; }
  .menu-btn { display: block; }
  .brand small { display: none; }
  main h1 { font-size: 32px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .band { padding: 8px 16px; }
}
@media print {
  .topbar, nav.toc, .pager, .band { display: none; }
  .layout { display: block; }
  main { max-width: none; }
  aside { break-inside: avoid; }
}

/* The single-page version */
.layout.single { grid-template-columns: minmax(0, 1fr); }
.layout.single main { max-width: 820px; margin: 0 auto; }
section.chapter { margin-top: 70px; padding-top: 30px; border-top: 3px solid; border-image: var(--grad) 1; }
@media print { section.chapter { break-before: page; border-top: 0; margin-top: 0; } figure { break-inside: avoid; } a { color: inherit; }
  main h1 { background: none; -webkit-text-fill-color: currentColor; color: #0e7490; } }

.cover-logo { display: block; width: 160px; height: auto; margin: 4px 0 14px; }
.cover-logo + h1 + ol { list-style: none; padding-left: 0; }
@media print { .cover-logo { width: 45mm; margin: 30mm auto 8mm; } main .cover-logo + h1 { margin-left: auto; margin-right: auto; } .cover-logo + h1 + ol { width: max-content; margin: 0 auto; } }

/* The icon has a dark ground of its own, so give it a little rounding rather than letting it sit as a hard square. */
.cover-logo { border-radius: 22px; }
.brand-icon { border-radius: 5px; }
