/* NetTrace documentation. Colours follow the application; light is the default
   for reading, dark follows the system or the toggle. */
:root {
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --bg-code: #f0f3f7;
  --border: #dde2ea;
  --border-strong: #c5ccd8;
  --text: #1d2430;
  --text-strong: #0c1118;
  --text-muted: #5a6577;
  --accent: #1f6fd6;
  --accent-soft: #e6f0fd;
  --note: #1f6fd6;
  --note-bg: #eef5ff;
  --warn: #9a6200;
  --warn-bg: #fff6e3;
  --mark: #ffe58a;
  --shadow: 0 8px 28px rgba(16, 24, 40, 0.16);
  --font-ui: "Segoe UI", system-ui, -apple-system, "Inter", "Roboto", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "Consolas", "SF Mono", "Menlo", monospace;
  --top-h: 52px;
  --side-w: 268px;
  --toc-w: 220px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181d;
    --bg-soft: #1a1e25;
    --bg-code: #1f242d;
    --border: #2b313c;
    --border-strong: #3a4250;
    --text: #d5dae2;
    --text-strong: #eef1f5;
    --text-muted: #8a93a2;
    --accent: #5aa2ff;
    --accent-soft: #1d3352;
    --note: #7ab4ff;
    --note-bg: #182536;
    --warn: #e8a33d;
    --warn-bg: #33271a;
    --mark: #6b5a16;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181d;
  --bg-soft: #1a1e25;
  --bg-code: #1f242d;
  --border: #2b313c;
  --border-strong: #3a4250;
  --text: #d5dae2;
  --text-strong: #eef1f5;
  --text-muted: #8a93a2;
  --accent: #5aa2ff;
  --accent-soft: #1d3352;
  --note: #7ab4ff;
  --note-bg: #182536;
  --warn: #e8a33d;
  --warn-bg: #33271a;
  --mark: #6b5a16;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font-ui); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text-strong); font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { color: var(--accent); }
.brand-sub { font-weight: 400; font-size: 13px; color: var(--text-muted); margin-left: 2px; }
.top-links { display: flex; align-items: center; gap: 16px; margin-left: auto; font-size: 14px; white-space: nowrap; }
.top-links a { color: var(--text); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--bg-soft); border-color: var(--border); }
.menu-btn { display: none; }

/* Search */
.search { position: relative; flex: 0 1 420px; margin-left: 24px; }
.search input { width: 100%; height: 34px; padding: 0 34px 0 12px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--bg-soft); color: var(--text); font: 14px var(--font-ui); }
.search input::placeholder { color: var(--text-muted); }
.search kbd { position: absolute; right: 8px; top: 7px; font: 11px var(--font-mono); color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; line-height: 18px; pointer-events: none; }
.search input:focus + kbd { display: none; }
.search-results { position: absolute; left: 0; right: 0; top: 40px; max-height: min(70vh, 560px); overflow: auto; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 6px; min-width: 340px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.search-results a:hover, .search-results a.is-active { background: var(--accent-soft); text-decoration: none; }
.search-results .sr-title { font-weight: 600; color: var(--text-strong); font-size: 14px; }
.search-results .sr-page { color: var(--text-muted); font-weight: 400; }
.search-results .sr-text { font-size: 13px; color: var(--text-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-results .sr-empty { padding: 10px; color: var(--text-muted); font-size: 14px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* Layout */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w); max-width: 1480px; margin: 0 auto; }
.side { position: sticky; top: var(--top-h); align-self: start; height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 20px 12px 40px 20px; border-right: 1px solid var(--border); }
.nav-group + .nav-group { margin-top: 18px; }
.nav-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding: 0 10px 6px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--text); font-size: 14.5px; line-height: 1.35; }
.side a:hover { background: var(--bg-soft); text-decoration: none; }
.side a.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { min-width: 0; padding: 32px 48px 48px; }
.toc { position: sticky; top: var(--top-h); align-self: start; max-height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 36px 20px 40px 0; font-size: 13.5px; }
.toc-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.toc a { display: block; padding: 3px 0 3px 10px; border-left: 2px solid var(--border); color: var(--text-muted); line-height: 1.35; }
.toc a.h3 { padding-left: 22px; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); }

/* Article */
.doc { max-width: 860px; }
.doc h1 { font-size: 32px; line-height: 1.2; margin: 0 0 12px; color: var(--text-strong); letter-spacing: -0.01em; }
.doc h2 { font-size: 23px; line-height: 1.3; margin: 40px 0 12px; padding-top: 8px; color: var(--text-strong); border-top: 1px solid var(--border); }
.doc h1 + h2, .doc .lead + h2 { border-top: 0; margin-top: 24px; }
.doc h3 { font-size: 18px; margin: 28px 0 8px; color: var(--text-strong); }
.doc h4 { font-size: 16px; margin: 20px 0 6px; color: var(--text-strong); }
.doc p, .doc ul, .doc ol, .doc table, .doc pre, .doc blockquote { margin: 0 0 16px; }
.doc ul, .doc ol { padding-left: 24px; }
.doc li { margin: 4px 0; }
.doc li > ul, .doc li > ol { margin: 4px 0 4px; }
.lead { font-size: 18px; color: var(--text-muted); margin-bottom: 24px; }
.doc strong { color: var(--text-strong); }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.anchor { margin-left: 8px; color: var(--text-muted); opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

code, kbd, pre { font-family: var(--font-mono); }
.doc code { font-size: 0.875em; background: var(--bg-code); padding: 2px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.doc pre { position: relative; background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; line-height: 1.5; }
.doc pre code { background: none; padding: 0; font-size: 13.5px; overflow-wrap: normal; }
.copy-btn { position: absolute; top: 6px; right: 6px; padding: 2px 8px; font: 12px var(--font-ui); color: var(--text-muted); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 5px; cursor: pointer; opacity: 0; }
pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.doc kbd { font-size: 0.82em; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--bg-soft); white-space: nowrap; }

/* Tables scroll inside their own box on narrow screens. */
.table-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 8px; }
.table-wrap table { margin: 0; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.doc th, .doc td { padding: 7px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.doc th { background: var(--bg-soft); color: var(--text-strong); font-weight: 600; white-space: nowrap; }
.doc tr:last-child td { border-bottom: 0; }
.doc td code { white-space: nowrap; }
.doc td:last-child code { white-space: normal; }

/* Notes: a blockquote that starts with a bold word. */
.doc blockquote { border-left: 3px solid var(--note); background: var(--note-bg); padding: 10px 14px; border-radius: 0 8px 8px 0; }
.doc blockquote.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.doc blockquote > :last-child { margin-bottom: 0; }

/* Screenshots */
.doc img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border-strong); border-radius: 8px; background: #15181d; }
.shot { display: block; margin: 0 0 6px; cursor: zoom-in; }
.shot + em, .doc p > img + em { display: block; }
.doc p:has(> .shot) { margin-bottom: 20px; }
.doc p:has(> .shot) em { display: block; font-style: normal; font-size: 13.5px; color: var(--text-muted); }
.lightbox { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(8, 10, 14, 0.88); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border: 1px solid #3a4250; border-radius: 8px; }

/* Home page cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 0 0 20px; padding: 0; list-style: none; }
.cards li { margin: 0; }
.cards a { display: block; height: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.cards a:hover { border-color: var(--accent); text-decoration: none; background: var(--bg-soft); }
.cards strong { display: block; margin-bottom: 4px; }
.cards span { font-size: 14px; color: var(--text-muted); line-height: 1.45; display: block; }

.pager { display: flex; justify-content: space-between; gap: 16px; max-width: 860px; margin-top: 48px; }
.pager a { flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a.next { text-align: right; }
.pager small { display: block; color: var(--text-muted); font-size: 12.5px; }
.pager b { color: var(--accent); font-weight: 600; }
.foot { display: flex; flex-wrap: wrap; gap: 6px 20px; max-width: 860px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text-muted); }

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .brand-sub { display: none; }
  .top { gap: 8px; padding: 0 12px; }
  .search { margin-left: 4px; }
  .search kbd { display: none; }
  .top-links a { display: none; }
  .side { position: fixed; z-index: 25; top: var(--top-h); left: 0; bottom: 0; width: min(86vw, 320px); background: var(--bg); transform: translateX(-100%); transition: transform 0.18s ease; box-shadow: var(--shadow); }
  body.nav-open .side { transform: none; }
  main { padding: 24px 16px 40px; }
  .doc h1 { font-size: 27px; }
  .search-results { position: fixed; left: 8px; right: 8px; top: calc(var(--top-h) + 4px); min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}
@media print {
  .top, .side, .toc, .pager, .foot, .copy-btn { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
}
