/*
  Aequs themes. Every colour, face, size and radius the app uses is a token here; app.css and the
  charts read only these tokens.

  Three families, each in light and dark:
    Ledger      warm paper and ink, serif headings, double rules
    Audit       cool and plain, system type, blue accent
    Instrument  graphite and phosphor, monospaced headings, accent rules
  The page carries data-family="ledger|audit|instrument" and data-mode="light|dark" on <html>
  (set by js/theme-boot.js before the page draws, from the user's choice or Auto). The same two
  attributes on any element give it that theme's tokens, which the theme picker uses for previews.

  Contrast: text tokens are at least 4.5:1 and non-text tokens (swatches, ridges, input borders) at
  least 3:1 against the surfaces they sit on. server/tests/test_theme_contrast.py checks every pair.
  Exempt, by design: --bf-rule (decorative dividers), steps of --bf-close-* against each other (the
  value is always printed on the tile), --bf-bridge-* (decorative motif).
*/
:root {
  --bf-size-xs: 11px; --bf-size-s: 12.5px; --bf-size-m: 14px; --bf-size-l: 18px; --bf-size-xl: 28px; --bf-size-hero: 48px;
  --bf-rule-width: 1px; --bf-gap: 16px; --bf-gap-s: 8px; --bf-pad: 16px; --bf-max-width: 1320px;
  --bf-bridge-opacity: .55;
  --bf-ease: cubic-bezier(.2, .7, .2, 1); --bf-dur: 600ms;
}

:root[data-family="ledger"], [data-family="ledger"] {
  --bf-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bf-font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --bf-font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --bf-radius: 2px; --bf-weight-strong: 600;
  --bf-head-track: .06em; --bf-head-case: uppercase; --bf-panel-top: 3px double var(--bf-rule-strong);
}

:root[data-family="audit"], [data-family="audit"] {
  --bf-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bf-font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bf-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --bf-radius: 4px; --bf-weight-strong: 600;
  --bf-head-track: .04em; --bf-head-case: uppercase; --bf-panel-top: var(--bf-rule-width) solid var(--bf-rule);
}

:root[data-family="instrument"], [data-family="instrument"] {
  --bf-font: "Barlow", "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --bf-font-display: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bf-font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bf-radius: 0px; --bf-weight-strong: 600;
  --bf-head-track: .14em; --bf-head-case: uppercase; --bf-panel-top: 2px solid var(--bf-accent);
}

:root {
  color-scheme: light;
  --bf-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bf-font-display: var(--bf-font);
  --bf-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --bf-radius: 4px; --bf-weight-strong: 600; --bf-head-track: .04em; --bf-head-case: uppercase; --bf-panel-top: var(--bf-rule-width) solid var(--bf-rule);
  --bf-bg: #f4f6f9; --bf-surface: #ffffff; --bf-surface-alt: #edf0f4; --bf-rule: #d5dbe3;
  --bf-rule-strong: #7a8594; --bf-ink: #0f1720; --bf-ink-2: #3b4654; --bf-ink-3: #576271; --bf-accent: #1546b3;
  --bf-accent-ink: #ffffff; --bf-code-bg: #f7f9fb; --bf-overlay: rgba(15, 23, 32, .4); --bf-l4: #1546b3;
  --bf-l3: #0d6e62; --bf-l2: #6440bf; --bf-l1: #8f5700; --bf-l0: #b02d2d; --bf-na: #6d7684;
  --bf-original: #8a3ba6; --bf-tier-0: #0d6e62; --bf-tier-1: #6440bf; --bf-tier-2: #a3356b; --bf-tier-3: #3b4654;
  --bf-good: #1b7543; --bf-warn: #8f5700; --bf-crit: #b02d2d; --bf-idle: #576271; --bf-code-kw: #1546b3;
  --bf-code-num: #8f5700; --bf-code-str: #1b7543; --bf-code-com: #576271; --bf-code-reg: #6440bf;
  --bf-code-op: #0f1720; --bf-code-addr: #576271; --bf-close-ink-lo: #0f1720; --bf-close-ink-hi: #ffffff;
  --bf-close-none: #dfe4ea; --bf-on-level: #ffffff; --bf-stage-bg: #0e1319; --bf-stage-bg-2: #151c24;
  --bf-stage-rule: #2a3542; --bf-stage-ink: #e6edf3; --bf-stage-ink-2: #97a6b5; --bf-ridge: #6f8396;
  --bf-ridge-2: #b7c6d4; --bf-ridge-match: #6ee7c8; --bf-stage-warn: #e3b04b; --bf-scan: #6ee7c8;
  --bf-close-0: #e3e9f1; --bf-close-1: #c2cfe0; --bf-close-2: #9eb2cb; --bf-close-3: #7993b3;
  --bf-close-4: #577599; --bf-close-5: #3a587b; --bf-close-6: #1e3959; --bf-bridge-1: #b02d2d;
  --bf-bridge-2: #8f5700; --bf-bridge-3: #1b7543; --bf-bridge-4: #1546b3; --bf-bridge-5: #6440bf;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-mode]) {
    color-scheme: dark;
    --bf-bg: #0c1016; --bf-surface: #11161d; --bf-surface-alt: #19202a; --bf-rule: #2b3442;
    --bf-rule-strong: #7e8998; --bf-ink: #e8edf3; --bf-ink-2: #b9c3cf; --bf-ink-3: #909ba9; --bf-accent: #7ea5ff;
    --bf-accent-ink: #0c1016; --bf-code-bg: #141a22; --bf-overlay: rgba(0, 0, 0, .6); --bf-l4: #7ea5ff;
    --bf-l3: #52c4b3; --bf-l2: #ab91f1; --bf-l1: #e1a742; --bf-l0: #f28683; --bf-na: #8a95a3;
    --bf-original: #d097e9; --bf-tier-0: #52c4b3; --bf-tier-1: #ab91f1; --bf-tier-2: #ef91c0; --bf-tier-3: #b9c3cf;
    --bf-good: #62d091; --bf-warn: #e1a742; --bf-crit: #f28683; --bf-idle: #909ba9; --bf-code-kw: #7ea5ff;
    --bf-code-num: #e1a742; --bf-code-str: #62d091; --bf-code-com: #909ba9; --bf-code-reg: #ab91f1;
    --bf-code-op: #e8edf3; --bf-code-addr: #909ba9; --bf-close-ink-lo: #e8edf3; --bf-close-ink-hi: #0c1016;
    --bf-close-none: #1f2630; --bf-on-level: #0c1016; --bf-stage-bg: #0a0e13; --bf-stage-bg-2: #11171e;
    --bf-stage-rule: #263140; --bf-stage-ink: #e6edf3; --bf-stage-ink-2: #93a2b1; --bf-ridge: #6f8396;
    --bf-ridge-2: #b7c6d4; --bf-ridge-match: #6ee7c8; --bf-stage-warn: #e3b04b; --bf-scan: #6ee7c8;
    --bf-close-0: #1c2633; --bf-close-1: #283648; --bf-close-2: #3a4d66; --bf-close-3: #536b8a;
    --bf-close-4: #7491b1; --bf-close-5: #a0b7d1; --bf-close-6: #d1dfee; --bf-bridge-1: #f28683;
    --bf-bridge-2: #e1a742; --bf-bridge-3: #62d091; --bf-bridge-4: #7ea5ff; --bf-bridge-5: #ab91f1;
  }
}

:root[data-family="ledger"][data-mode="light"], [data-family="ledger"][data-mode="light"] {
  color-scheme: light;
  --bf-bg: #f4eee2; --bf-surface: #fbf8f2; --bf-surface-alt: #efe7d7; --bf-rule: #ddd2bd;
  --bf-rule-strong: #857761; --bf-ink: #1f1a14; --bf-ink-2: #463c30; --bf-ink-3: #62574a; --bf-accent: #8a2a1c;
  --bf-accent-ink: #ffffff; --bf-code-bg: #f6f1e6; --bf-overlay: rgba(31, 26, 20, .45); --bf-l4: #1f4e79;
  --bf-l3: #1a6659; --bf-l2: #5a479b; --bf-l1: #835600; --bf-l0: #a1302a; --bf-na: #776d60;
  --bf-original: #7a3d8e; --bf-tier-0: #1a6659; --bf-tier-1: #5a479b; --bf-tier-2: #8f3762; --bf-tier-3: #463c30;
  --bf-good: #2c6636; --bf-warn: #835600; --bf-crit: #a1302a; --bf-idle: #62574a; --bf-code-kw: #8a2a1c;
  --bf-code-num: #7a5000; --bf-code-str: #2c6636; --bf-code-com: #62574a; --bf-code-reg: #5a479b;
  --bf-code-op: #1f1a14; --bf-code-addr: #6b6052; --bf-close-ink-lo: #1f1a14; --bf-close-ink-hi: #fbf8f2;
  --bf-close-none: #e4dccd; --bf-on-level: #ffffff; --bf-stage-bg: #16130e; --bf-stage-bg-2: #201b14;
  --bf-stage-rule: #3b3327; --bf-stage-ink: #f2eadb; --bf-stage-ink-2: #b8ab93; --bf-ridge: #8d806a;
  --bf-ridge-2: #d9cdb6; --bf-ridge-match: #86d0b0; --bf-stage-warn: #e9aa45; --bf-scan: #86d0b0;
  --bf-close-0: #ebe1cd; --bf-close-1: #d8c8a8; --bf-close-2: #bea67c; --bf-close-3: #9a8158;
  --bf-close-4: #735e3e; --bf-close-5: #53432b; --bf-close-6: #33281a; --bf-bridge-1: #a1302a;
  --bf-bridge-2: #835600; --bf-bridge-3: #2c6636; --bf-bridge-4: #1f4e79; --bf-bridge-5: #5a479b;
}

:root[data-family="ledger"][data-mode="dark"], [data-family="ledger"][data-mode="dark"] {
  color-scheme: dark;
  --bf-bg: #13100c; --bf-surface: #1a1611; --bf-surface-alt: #241f18; --bf-rule: #3a3226;
  --bf-rule-strong: #8a7d67; --bf-ink: #efe7d8; --bf-ink-2: #cbc0ab; --bf-ink-3: #a69a84; --bf-accent: #e58a74;
  --bf-accent-ink: #13100c; --bf-code-bg: #1d1914; --bf-overlay: rgba(0, 0, 0, .6); --bf-l4: #86aedb;
  --bf-l3: #6cc2b1; --bf-l2: #ac9ee3; --bf-l1: #dba84c; --bf-l0: #ea8c80; --bf-na: #998e7c;
  --bf-original: #c99bdb; --bf-tier-0: #6cc2b1; --bf-tier-1: #ac9ee3; --bf-tier-2: #e391b8; --bf-tier-3: #cbc0ab;
  --bf-good: #7ec98c; --bf-warn: #dba84c; --bf-crit: #ea8c80; --bf-idle: #a69a84; --bf-code-kw: #e58a74;
  --bf-code-num: #dba84c; --bf-code-str: #7ec98c; --bf-code-com: #a69a84; --bf-code-reg: #ac9ee3;
  --bf-code-op: #efe7d8; --bf-code-addr: #a69a84; --bf-close-ink-lo: #efe7d8; --bf-close-ink-hi: #13100c;
  --bf-close-none: #2b261f; --bf-on-level: #13100c; --bf-stage-bg: #0d0b08; --bf-stage-bg-2: #17130e;
  --bf-stage-rule: #352d22; --bf-stage-ink: #f2eadb; --bf-stage-ink-2: #b3a68e; --bf-ridge: #8a7d67;
  --bf-ridge-2: #d4c8b1; --bf-ridge-match: #86d0b0; --bf-stage-warn: #e9aa45; --bf-scan: #86d0b0;
  --bf-close-0: #2a241b; --bf-close-1: #3c3427; --bf-close-2: #564a37; --bf-close-3: #76664b;
  --bf-close-4: #998765; --bf-close-5: #bfad88; --bf-close-6: #e8dbbd; --bf-bridge-1: #ea8c80;
  --bf-bridge-2: #dba84c; --bf-bridge-3: #7ec98c; --bf-bridge-4: #86aedb; --bf-bridge-5: #ac9ee3;
}

:root[data-family="audit"][data-mode="light"], [data-family="audit"][data-mode="light"] {
  color-scheme: light;
  --bf-bg: #f4f6f9; --bf-surface: #ffffff; --bf-surface-alt: #edf0f4; --bf-rule: #d5dbe3;
  --bf-rule-strong: #7a8594; --bf-ink: #0f1720; --bf-ink-2: #3b4654; --bf-ink-3: #576271; --bf-accent: #1546b3;
  --bf-accent-ink: #ffffff; --bf-code-bg: #f7f9fb; --bf-overlay: rgba(15, 23, 32, .4); --bf-l4: #1546b3;
  --bf-l3: #0d6e62; --bf-l2: #6440bf; --bf-l1: #8f5700; --bf-l0: #b02d2d; --bf-na: #6d7684;
  --bf-original: #8a3ba6; --bf-tier-0: #0d6e62; --bf-tier-1: #6440bf; --bf-tier-2: #a3356b; --bf-tier-3: #3b4654;
  --bf-good: #1b7543; --bf-warn: #8f5700; --bf-crit: #b02d2d; --bf-idle: #576271; --bf-code-kw: #1546b3;
  --bf-code-num: #8f5700; --bf-code-str: #1b7543; --bf-code-com: #576271; --bf-code-reg: #6440bf;
  --bf-code-op: #0f1720; --bf-code-addr: #576271; --bf-close-ink-lo: #0f1720; --bf-close-ink-hi: #ffffff;
  --bf-close-none: #dfe4ea; --bf-on-level: #ffffff; --bf-stage-bg: #0e1319; --bf-stage-bg-2: #151c24;
  --bf-stage-rule: #2a3542; --bf-stage-ink: #e6edf3; --bf-stage-ink-2: #97a6b5; --bf-ridge: #6f8396;
  --bf-ridge-2: #b7c6d4; --bf-ridge-match: #6ee7c8; --bf-stage-warn: #e3b04b; --bf-scan: #6ee7c8;
  --bf-close-0: #e3e9f1; --bf-close-1: #c2cfe0; --bf-close-2: #9eb2cb; --bf-close-3: #7993b3;
  --bf-close-4: #577599; --bf-close-5: #3a587b; --bf-close-6: #1e3959; --bf-bridge-1: #b02d2d;
  --bf-bridge-2: #8f5700; --bf-bridge-3: #1b7543; --bf-bridge-4: #1546b3; --bf-bridge-5: #6440bf;
}

:root[data-family="audit"][data-mode="dark"], [data-family="audit"][data-mode="dark"] {
  color-scheme: dark;
  --bf-bg: #0c1016; --bf-surface: #11161d; --bf-surface-alt: #19202a; --bf-rule: #2b3442;
  --bf-rule-strong: #7e8998; --bf-ink: #e8edf3; --bf-ink-2: #b9c3cf; --bf-ink-3: #909ba9; --bf-accent: #7ea5ff;
  --bf-accent-ink: #0c1016; --bf-code-bg: #141a22; --bf-overlay: rgba(0, 0, 0, .6); --bf-l4: #7ea5ff;
  --bf-l3: #52c4b3; --bf-l2: #ab91f1; --bf-l1: #e1a742; --bf-l0: #f28683; --bf-na: #8a95a3;
  --bf-original: #d097e9; --bf-tier-0: #52c4b3; --bf-tier-1: #ab91f1; --bf-tier-2: #ef91c0; --bf-tier-3: #b9c3cf;
  --bf-good: #62d091; --bf-warn: #e1a742; --bf-crit: #f28683; --bf-idle: #909ba9; --bf-code-kw: #7ea5ff;
  --bf-code-num: #e1a742; --bf-code-str: #62d091; --bf-code-com: #909ba9; --bf-code-reg: #ab91f1;
  --bf-code-op: #e8edf3; --bf-code-addr: #909ba9; --bf-close-ink-lo: #e8edf3; --bf-close-ink-hi: #0c1016;
  --bf-close-none: #1f2630; --bf-on-level: #0c1016; --bf-stage-bg: #0a0e13; --bf-stage-bg-2: #11171e;
  --bf-stage-rule: #263140; --bf-stage-ink: #e6edf3; --bf-stage-ink-2: #93a2b1; --bf-ridge: #6f8396;
  --bf-ridge-2: #b7c6d4; --bf-ridge-match: #6ee7c8; --bf-stage-warn: #e3b04b; --bf-scan: #6ee7c8;
  --bf-close-0: #1c2633; --bf-close-1: #283648; --bf-close-2: #3a4d66; --bf-close-3: #536b8a;
  --bf-close-4: #7491b1; --bf-close-5: #a0b7d1; --bf-close-6: #d1dfee; --bf-bridge-1: #f28683;
  --bf-bridge-2: #e1a742; --bf-bridge-3: #62d091; --bf-bridge-4: #7ea5ff; --bf-bridge-5: #ab91f1;
}

:root[data-family="instrument"][data-mode="light"], [data-family="instrument"][data-mode="light"] {
  color-scheme: light;
  --bf-bg: #eceeeb; --bf-surface: #f9faf8; --bf-surface-alt: #e5e8e4; --bf-rule: #c8cdc6;
  --bf-rule-strong: #727a71; --bf-ink: #111411; --bf-ink-2: #3a413a; --bf-ink-3: #535b53; --bf-accent: #006557;
  --bf-accent-ink: #ffffff; --bf-code-bg: #f2f4f1; --bf-overlay: rgba(17, 20, 17, .45); --bf-l4: #005677;
  --bf-l3: #006b5a; --bf-l2: #5848ad; --bf-l1: #845700; --bf-l0: #ab372b; --bf-na: #687068;
  --bf-original: #7a4293; --bf-tier-0: #006b5a; --bf-tier-1: #5848ad; --bf-tier-2: #983a68; --bf-tier-3: #3a413a;
  --bf-good: #1d7337; --bf-warn: #845700; --bf-crit: #ab372b; --bf-idle: #535b53; --bf-code-kw: #006557;
  --bf-code-num: #845700; --bf-code-str: #1a6b33; --bf-code-com: #535b53; --bf-code-reg: #5848ad;
  --bf-code-op: #111411; --bf-code-addr: #596159; --bf-close-ink-lo: #111411; --bf-close-ink-hi: #f9faf8;
  --bf-close-none: #dadfda; --bf-on-level: #ffffff; --bf-stage-bg: #080b0a; --bf-stage-bg-2: #0f1412;
  --bf-stage-rule: #24302c; --bf-stage-ink: #d9f4eb; --bf-stage-ink-2: #8fb0a5; --bf-ridge: #5f7d73;
  --bf-ridge-2: #a9cbbf; --bf-ridge-match: #46e6bd; --bf-stage-warn: #ffb547; --bf-scan: #46e6bd;
  --bf-close-0: #dde6e2; --bf-close-1: #b9cdc6; --bf-close-2: #92b0a7; --bf-close-3: #6c9187;
  --bf-close-4: #4a7167; --bf-close-5: #2e5249; --bf-close-6: #15362e; --bf-bridge-1: #ab372b;
  --bf-bridge-2: #845700; --bf-bridge-3: #1d7337; --bf-bridge-4: #005677; --bf-bridge-5: #5848ad;
}

:root[data-family="instrument"][data-mode="dark"], [data-family="instrument"][data-mode="dark"] {
  color-scheme: dark;
  --bf-bg: #090c0b; --bf-surface: #0e1211; --bf-surface-alt: #151b19; --bf-rule: #25302c;
  --bf-rule-strong: #6e7d77; --bf-ink: #d9f4eb; --bf-ink-2: #a8c6bb; --bf-ink-3: #82a095; --bf-accent: #46e6bd;
  --bf-accent-ink: #090c0b; --bf-code-bg: #0b0f0e; --bf-overlay: rgba(0, 0, 0, .65); --bf-l4: #5ec9ff;
  --bf-l3: #46e6bd; --bf-l2: #b4a0ff; --bf-l1: #ffb547; --bf-l0: #ff7d6e; --bf-na: #82a095;
  --bf-original: #e49eff; --bf-tier-0: #46e6bd; --bf-tier-1: #b4a0ff; --bf-tier-2: #ff91c6; --bf-tier-3: #a8c6bb;
  --bf-good: #70e28b; --bf-warn: #ffb547; --bf-crit: #ff7d6e; --bf-idle: #82a095; --bf-code-kw: #46e6bd;
  --bf-code-num: #ffb547; --bf-code-str: #70e28b; --bf-code-com: #82a095; --bf-code-reg: #b4a0ff;
  --bf-code-op: #d9f4eb; --bf-code-addr: #82a095; --bf-close-ink-lo: #d9f4eb; --bf-close-ink-hi: #090c0b;
  --bf-close-none: #18201d; --bf-on-level: #090c0b; --bf-stage-bg: #050807; --bf-stage-bg-2: #0c1110;
  --bf-stage-rule: #1f2a26; --bf-stage-ink: #d9f4eb; --bf-stage-ink-2: #8aab9f; --bf-ridge: #5f7d73;
  --bf-ridge-2: #a9cbbf; --bf-ridge-match: #46e6bd; --bf-stage-warn: #ffb547; --bf-scan: #46e6bd;
  --bf-close-0: #13201c; --bf-close-1: #1c312b; --bf-close-2: #284840; --bf-close-3: #386458;
  --bf-close-4: #4e8777; --bf-close-5: #70b09d; --bf-close-6: #a8dece; --bf-bridge-1: #ff7d6e;
  --bf-bridge-2: #ffb547; --bf-bridge-3: #70e28b; --bf-bridge-4: #5ec9ff; --bf-bridge-5: #b4a0ff;
}
