/* Synapse Nexus Knowledge Center - design tokens, reset, typography.
   Tokens follow the Internal Portal: primary #02a0fc, navy #102a5b, light background #f3f4f6, near-black sidebar,
   radius 0.625rem, system sans + mono. Both themes are defined on :root[data-theme]. */

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 0.625rem;
  --radius-sm: 0.375rem;
  --radius-lg: 0.875rem;
  --sidebar-w: 15.5rem;
  --topbar-h: 3.5rem;
  --ease: 160ms cubic-bezier(0.2, 0, 0, 1);
  --primary: #02a0fc;
  --navy: #102a5b;
  --on-primary: #03172c;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-hover: #eef1f6;
  --border: #e1e5ec;
  --border-strong: #c6cdd9;
  --text: #0f1b2d;
  --text-2: #35445a;
  --muted: #5b697f;
  --primary-strong: #0386d1;
  --primary-soft: rgba(2, 160, 252, 0.12);
  --link: #0a62a8;
  --focus: #0a7fd1;
  --overlay: rgba(15, 27, 45, 0.45);
  --shadow-sm: 0 1px 2px rgba(16, 42, 91, 0.06);
  --shadow: 0 1px 2px rgba(16, 42, 91, 0.06), 0 6px 20px rgba(16, 42, 91, 0.07);
  --shadow-lg: 0 10px 40px rgba(16, 42, 91, 0.2);

  --ok-fg: #0f7a3b;      --ok-bg: #e7f6ec;      --ok-bd: #b6e0c6;
  --warn-fg: #8a5200;    --warn-bg: #fff4de;    --warn-bd: #f0d59c;
  --bad-fg: #b3261e;     --bad-bg: #fdeceb;     --bad-bd: #f2bdb8;
  --info-fg: #0a62a8;    --info-bg: #e6f3fd;    --info-bd: #b4d9f5;
  --merged-fg: #6b3fb8;  --merged-bg: #f1ebfb;  --merged-bd: #d6c5f1;
  --neutral-fg: #46546a; --neutral-bg: #eef0f4; --neutral-bd: #d6dbe4;

  --diff-add-bg: #e6f6ea;  --diff-add-gutter: #cdeed7;  --diff-add-fg: #0f5f2e;
  --diff-del-bg: #fdecea;  --diff-del-gutter: #f8d3cf;  --diff-del-fg: #8f1d16;
  --diff-hunk-bg: #eaf3fc; --diff-hunk-fg: #0a4f88;

  --cm-bg: #ffffff;      --cm-fg: #1a2433;      --cm-caret: #0a62a8;
  --cm-gutter-bg: #f6f7fa; --cm-gutter-fg: #7b879b; --cm-gutter-border: #e6e9ef;
  --cm-active-line: rgba(2, 160, 252, 0.07);
  --cm-selection: rgba(2, 160, 252, 0.24);
  --cm-match: rgba(2, 160, 252, 0.18);       --cm-match-border: rgba(2, 160, 252, 0.5);
  --cm-search: rgba(255, 196, 0, 0.35);      --cm-search-active: rgba(255, 140, 0, 0.45);
  --cm-panel-bg: #f6f7fa;
  --tok-h: #0b3a7a;   --tok-link: #0a62a8;  --tok-kw: #8a2be2;   --tok-str: #0f7a3b;
  --tok-num: #b45309; --tok-comment: #6b7a90; --tok-type: #0b7285; --tok-fn: #1d4ed8;
  --tok-prop: #a21caf; --tok-tag: #b3261e;  --tok-meta: #7b879b;  --tok-quote: #5b697f;
  --tok-mono-bg: rgba(16, 42, 91, 0.07);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #151f35;
  --surface-hover: #1b2842;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: #e8edf6;
  --text-2: #c3cdde;
  --muted: #94a3bb;
  --primary-strong: #35b4ff;
  --primary-soft: rgba(2, 160, 252, 0.17);
  --link: #5cc4ff;
  --focus: #4cc2ff;
  --overlay: rgba(2, 6, 14, 0.66);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 14px 48px rgba(0, 0, 0, 0.55);

  --ok-fg: #62d78f;      --ok-bg: rgba(46, 204, 113, 0.13);  --ok-bd: rgba(46, 204, 113, 0.32);
  --warn-fg: #f6c35c;    --warn-bg: rgba(245, 166, 35, 0.13); --warn-bd: rgba(245, 166, 35, 0.34);
  --bad-fg: #ff8d84;     --bad-bg: rgba(255, 82, 70, 0.14);  --bad-bd: rgba(255, 82, 70, 0.36);
  --info-fg: #62c5ff;    --info-bg: rgba(2, 160, 252, 0.15); --info-bd: rgba(2, 160, 252, 0.38);
  --merged-fg: #c6a7ff;  --merged-bg: rgba(155, 109, 255, 0.16); --merged-bd: rgba(155, 109, 255, 0.38);
  --neutral-fg: #b6c1d3; --neutral-bg: rgba(255, 255, 255, 0.07); --neutral-bd: rgba(255, 255, 255, 0.16);

  --diff-add-bg: rgba(46, 204, 113, 0.12);  --diff-add-gutter: rgba(46, 204, 113, 0.22);  --diff-add-fg: #8ee6ae;
  --diff-del-bg: rgba(255, 82, 70, 0.12);   --diff-del-gutter: rgba(255, 82, 70, 0.22);   --diff-del-fg: #ffb0a9;
  --diff-hunk-bg: rgba(2, 160, 252, 0.12);  --diff-hunk-fg: #8fd3ff;

  --cm-bg: #0e1626;      --cm-fg: #dbe4f3;      --cm-caret: #5cc4ff;
  --cm-gutter-bg: #0b1220; --cm-gutter-fg: #66758f; --cm-gutter-border: rgba(255, 255, 255, 0.07);
  --cm-active-line: rgba(255, 255, 255, 0.04);
  --cm-selection: rgba(2, 160, 252, 0.35);
  --cm-match: rgba(2, 160, 252, 0.28);       --cm-match-border: rgba(2, 160, 252, 0.6);
  --cm-search: rgba(255, 196, 0, 0.3);       --cm-search-active: rgba(255, 140, 0, 0.45);
  --cm-panel-bg: #0b1220;
  --tok-h: #8fd3ff;   --tok-link: #5cc4ff;  --tok-kw: #c4a4ff;   --tok-str: #8ee6ae;
  --tok-num: #ffc27a; --tok-comment: #7d8aa3; --tok-type: #6fd8e8; --tok-fn: #8cb4ff;
  --tok-prop: #f0a6f5; --tok-tag: #ff9b92;  --tok-meta: #66758f;  --tok-quote: #94a3bb;
  --tok-mono-bg: rgba(255, 255, 255, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
code { background: var(--tok-mono-bg); padding: 0.1em 0.38em; border-radius: 5px; }
kbd {
  display: inline-block; padding: 0.05em 0.45em; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface-2); font-size: 0.8em; color: var(--text-2); line-height: 1.5;
}
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--primary-soft); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  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: 0.75rem; top: -4rem; z-index: 1000; padding: 0.55rem 0.9rem; background: var(--primary);
  color: var(--on-primary); border-radius: var(--radius); font-weight: 600; transition: top var(--ease);
}
.skip-link:focus { top: 0.75rem; text-decoration: none; }

.icon {
  width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.17em;
}
.icon--lg { width: 1.5em; height: 1.5em; }
.icon--xl { width: 2.25em; height: 2.25em; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.right { margin-left: auto; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--gap, 1rem); }
.row { display: flex; align-items: center; gap: var(--gap, 0.5rem); flex-wrap: wrap; }
.row--nowrap { flex-wrap: nowrap; }
.gap-1 { --gap: 0.25rem; } .gap-2 { --gap: 0.5rem; } .gap-3 { --gap: 0.75rem; } .gap-4 { --gap: 1rem; } .gap-6 { --gap: 1.5rem; }

.boot {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1rem; background: var(--bg);
  color: var(--muted); z-index: 900;
}
.boot__spinner {
  width: 2rem; height: 2rem; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--primary);
  animation: kc-spin 0.8s linear infinite;
}
.noscript { padding: 2rem; text-align: center; }

@keyframes kc-spin { to { transform: rotate(360deg); } }
@keyframes kc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kc-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes kc-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
