﻿/* Theme tokens for Bootstrap and WorldBuilder. Loaded after Bootstrap to override tokens.

   Two attributes on <html> pick the colours (both set before first paint by the inline
   script in each layout, and kept in sync by wwwroot/js/theme.js):
     data-wb-theme = paper (default) | lamp | studio | classic   the palette
     data-bs-theme = light | dark                                the mode (sun/moon button)

   The plain [data-bs-theme="light"] / [data-bs-theme="dark"] blocks below are the
   Classic palette and the baseline. Each other palette overrides every token with a
   [data-wb-theme="…"][data-bs-theme="…"] block, which wins on specificity.
   Guide: docs/UI-Guide.md, "Themes". */

:root {
  /* The one font for manuscript text (editor, chapter titles, shared chapters).
     All are already installed, nothing is downloaded:
     Charter / Iowan Old Style ship with macOS, Sitka Text (made for on-screen
     reading) and Cambria ship with Windows, Georgia is everywhere. */
  --wb-prose-font: Charter, "Bitstream Charter", "Sitka Text", "Iowan Old Style", Cambria, Georgia, serif;
  /* UI text (body, buttons, Studio and Classic headings) */
  --wb-ui-font: system-ui, sans-serif;

  /* The light page the editor shows when "light page" is on in dark mode (site.css).
     Each palette sets its own below. */
  --wb-lightpage-bg: #ffffff;
  --wb-lightpage-color: #111111;
  --wb-lightpage-desk: #2a3343;

  /* --wb-heading-font / --wb-heading-weight are only set by palettes that restyle
     headings (Paper & Ink, Lamplight, Studio). Classic leaves them unset, so every
     heading rule falls back to its old value. */
}

/* =============================================================
   Classic (and baseline): the original WorldBuilder colours
============================================================= */

[data-bs-theme="light"] {
    /* Explicit light mode (same as default) */
    --bs-body-bg: #ffffff;
    --bs-body-color: #212529;
    --bs-border-color: #dee2e6;
    --bs-link-color: #0b5ed7;
    --bs-link-hover-color: #0a58ca;
    /* form controls and panels */
    --bs-secondary-bg: #f8f9fa;
    --bs-secondary-color: #212529;
    --bs-drag-handle: #6c757d;
    --bs-tertiary-bg: #eef0f3; /* was a 35% grey that made every chapter look selected */
    --bs-light-bg-subtle: #f8f9fa;
    /* accents */
    --bs-primary: #0d6efd;
    --bs-primary-bg-subtle: rgba(13, 110, 253, 0.12);
    --bs-status-bar-color: black;
    --wb-app-bg: #f5f7fa; /* page ground behind cards (body) */
    --wb-nav-bg: #ffffff; /* top navbar */
    --wb-muted: #636b73;
    --wb-placeholder: #6f7174;
    --wb-status-done: #146c43;
    --wb-status-revising: #9a6700;
    --wb-status-draft: #636b73;
    --wb-input-border: #8c8e90;
    --wb-surface: #ffffff;
    --wb-surface-2: #f5f7fa;
    --wb-desk: #e3e6ea;
    --wb-sheet: #ffffff;
    /* editor tokens (used by _LexicalEditor.cshtml) */
    --wb-border: #dee2e6;
    --wb-toolbar-bg: #f1f3f5;
    --wb-toolbar-color: #212529;
    --wb-toolbar-hover: #e2e6ea;
    --wb-toolbar-active: #cfd4da;
    --wb-page-bg: #ffffff;
    --wb-page-color: #212529;
    --wb-statusbar-bg: #f8f9fa;
    --wb-statusbar-color: #495057;
    --wb-danger-text: #b02a37;
    --wb-attention: #ffe69c;
    /* shared UI tokens (used by ui.css) */
    --wb-accent: #3f5fe0;
    --wb-accent-hover: #3651c4;
    --wb-accent-active: #2f47ab;
    --wb-accent-subtle: rgba(74, 108, 247, 0.12);
    --wb-on-accent: #ffffff;
    --wb-hover: rgba(0, 0, 0, 0.04);
    --wb-success-text: #146c43;
    --wb-focus-ring: #258cfb;
    --wb-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
    --wb-shadow-md: 0 6px 20px rgba(0, 0, 0, 0.12);
}

[data-bs-theme="dark"] {
    /* Use the Outline palette */
    --bs-body-bg: #0f172a; /* deep navy */
    --bs-body-color: #e5e7eb; /* light text */
    --bs-border-color: #1f2937;
    --bs-link-color: #6ea8fe;
    --bs-link-hover-color: #8bb9fe;
    /* form controls and panels */
    --bs-secondary-bg: #020617;
    --bs-secondary-color: white;
    --bs-drag-handle: red;
    --bs-tertiary-bg: rgba(0, 123, 255, 0.12);
    --bs-light-bg-subtle: #020617;
    /* accents */
    --bs-primary: #3c8dbc;
    --bs-primary-rgb: 60, 141, 188;
    --bs-primary-bg-subtle: rgba(0, 123, 255, 0.12);
    --bs-status-bar-color: black;
    --bs-dropdown-link-color: #e5e7eb;
    --wb-app-bg: #0f172a;
    --wb-nav-bg: #020617;
    --wb-muted: #9ca3af;
    --wb-placeholder: #7f828c;
    --wb-status-done: #75b798;
    --wb-status-revising: #e0a526;
    --wb-status-draft: #9ca3af;
    --wb-input-border: #616470;
    --wb-surface: #020617;
    --wb-surface-2: #111827;
    --wb-desk: #020617;
    --wb-sheet: #0f172a;
    /* editor tokens (used by _LexicalEditor.cshtml) */
    --wb-border: #1f2937;
    --wb-toolbar-bg: #111827;
    --wb-toolbar-color: #d1d5db;
    --wb-toolbar-hover: #1f2937;
    --wb-toolbar-active: #374151;
    --wb-page-bg: #020617;
    --wb-page-color: #e5e7eb;
    --wb-statusbar-bg: #0b1222;
    --wb-statusbar-color: #9ca3af;
    --wb-danger-text: #f1aeb5;
    --wb-attention: #5c4a12;
    /* shared UI tokens (used by ui.css) */
    --wb-accent: #4361e8;
    --wb-accent-hover: #3a57d9;
    --wb-accent-active: #3149c4;
    --wb-accent-subtle: rgba(110, 168, 254, 0.14);
    --wb-on-accent: #ffffff;
    --wb-hover: rgba(255, 255, 255, 0.05);
    --wb-success-text: #75b798;
    --wb-focus-ring: #258cfb;
    --wb-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --wb-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    /* secondary outline buttons: Bootstrap's grey is too dim on navy */
    --wb-btn-outline-color: #d1d5db;
    --wb-btn-outline-border: #374151;
    --wb-btn-outline-hover-color: #ffffff;
    --wb-btn-outline-hover-bg: #1f2937;
    --wb-btn-outline-hover-border: #4b5563;
}

/* =============================================================
   Paper & Ink, Lamplight, Studio
   Generated from the palette table in docs/UI-Guide.md ("Themes"):
   toolbar, hover and outline-button tints are the ground mixed with the
   text colour; hover/active accent is the accent mixed 14% / 24% toward
   black (light) or white (dark). Contrast checked: body, muted, link,
   danger and success text >= 4.5:1 on every ground; placeholder >= 4.5:1 and
   input border / status colours >= 3:1 on every input and page ground (WCAG 1.4.3, 1.4.11).
============================================================= */

[data-wb-theme="paper"][data-bs-theme="light"] {
    --bs-body-bg: #fffdf8;
    --bs-body-bg-rgb: 255,253,248;
    --bs-body-color: #2b2722;
    --bs-body-color-rgb: 43,39,34;
    --bs-emphasis-color: #2b2722;
    --bs-heading-color: #2b2722;
    --bs-secondary-color: #6b6357;
    --bs-border-color: #e0d7c6;
    --bs-link-color: #2c4a78;
    --bs-link-color-rgb: 44,74,120;
    --bs-link-hover-color: #264067;
    --bs-link-hover-color-rgb: 38,64,103;
    --bs-secondary-bg: #f1ebdf;
    --bs-tertiary-bg: #e7e1d6;
    --bs-light-bg-subtle: #f1ebdf;
    --bs-drag-handle: #6b6357;
    --bs-primary: #2c4a78;
    --bs-primary-rgb: 44,74,120;
    --bs-primary-bg-subtle: rgba(44, 74, 120, 0.10);
    --bs-primary-text-emphasis: #2c4a78;
    --bs-dropdown-link-color: #2b2722;
    --wb-app-bg: #ebe4d6;
    --wb-nav-bg: #faf6ee;
    --wb-muted: #6b6357;
    --wb-placeholder: #686560;
    --wb-status-done: #2f6a3a;
    --wb-status-revising: #8a5d00;
    --wb-status-draft: #6b6357;
    --wb-input-border: #84817c;
    --wb-surface: #fbf8f2;
    --wb-surface-2: #f1ebdf;
    --wb-desk: #ebe4d6;
    --wb-sheet: #fffdf8;
    --wb-border: #e0d7c6;
    --wb-toolbar-bg: #f1ebdf;
    --wb-toolbar-color: #2b2722;
    --wb-toolbar-hover: #e1dbd0;
    --wb-toolbar-active: #d3cec3;
    --wb-page-bg: #fffdf8;
    --wb-page-color: #2b2722;
    --wb-statusbar-bg: #faf6ee;
    --wb-statusbar-color: #6b6357;
    --wb-danger-text: #a3372b;
    --wb-success-text: #2f6a3a;
    --wb-attention: #efe0bb;
    --wb-attention-text: #5a4410;
    --wb-accent: #2c4a78;
    --wb-accent-hover: #264067;
    --wb-accent-active: #21385b;
    --wb-accent-subtle: rgba(44, 74, 120, 0.10);
    --wb-on-accent: #ffffff;
    --wb-hover: rgba(43,39,34, 0.05);
    --wb-focus-ring: #2c4a78;
    --wb-shadow-sm: 0 2px 6px rgba(40, 30, 15, 0.08);
    --wb-shadow-md: 0 6px 20px rgba(40, 30, 15, 0.12);
    --wb-btn-outline-color: #2b2722;
    --wb-btn-outline-border: #b3ab9d;
    --wb-btn-outline-hover-color: #2b2722;
    --wb-btn-outline-hover-bg: #e5dfd4;
    --wb-btn-outline-hover-border: #989184;
    --wb-heading-font: var(--wb-prose-font);
    --wb-heading-weight: 700;
}

[data-wb-theme="paper"][data-bs-theme="dark"] {
    --bs-body-bg: #22201b;
    --bs-body-bg-rgb: 34,32,27;
    --bs-body-color: #ece5d8;
    --bs-body-color-rgb: 236,229,216;
    --bs-emphasis-color: #ece5d8;
    --bs-heading-color: #ece5d8;
    --bs-secondary-color: #a59c8c;
    --bs-border-color: #36322a;
    --bs-link-color: #8eaee0;
    --bs-link-color-rgb: 142,174,224;
    --bs-link-hover-color: #9eb9e4;
    --bs-link-hover-color-rgb: 158,185,228;
    --bs-secondary-bg: #29261f;
    --bs-tertiary-bg: #333028;
    --bs-light-bg-subtle: #29261f;
    --bs-drag-handle: #a59c8c;
    --bs-primary: #8eaee0;
    --bs-primary-rgb: 142,174,224;
    --bs-primary-bg-subtle: rgba(142, 174, 224, 0.14);
    --bs-primary-text-emphasis: #8eaee0;
    --bs-dropdown-link-color: #ece5d8;
    --wb-app-bg: #151310;
    --wb-nav-bg: #1c1a16;
    --wb-muted: #a59c8c;
    --wb-placeholder: #928d83;
    --wb-status-done: #93cf9e;
    --wb-status-revising: #e0b04a;
    --wb-status-draft: #a59c8c;
    --wb-input-border: #736f65;
    --wb-surface: #1f1d19;
    --wb-surface-2: #29261f;
    --wb-desk: #151310;
    --wb-sheet: #22201b;
    --wb-border: #36322a;
    --wb-toolbar-bg: #29261f;
    --wb-toolbar-color: #ece5d8;
    --wb-toolbar-hover: #39352e;
    --wb-toolbar-active: #46433b;
    --wb-page-bg: #22201b;
    --wb-page-color: #ece5d8;
    --wb-statusbar-bg: #1c1a16;
    --wb-statusbar-color: #a59c8c;
    --wb-danger-text: #f0a69b;
    --wb-success-text: #93cf9e;
    --wb-attention: #4a3b17;
    --wb-attention-text: #f0dca6;
    --wb-accent: #8eaee0;
    --wb-accent-hover: #9eb9e4;
    --wb-accent-active: #a9c1e7;
    --wb-accent-subtle: rgba(142, 174, 224, 0.14);
    --wb-on-accent: #14171c;
    --wb-hover: rgba(236,229,216, 0.06);
    --wb-focus-ring: #8eaee0;
    --wb-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --wb-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --wb-btn-outline-color: #ece5d8;
    --wb-btn-outline-border: #645f56;
    --wb-btn-outline-hover-color: #ece5d8;
    --wb-btn-outline-hover-bg: #35312a;
    --wb-btn-outline-hover-border: #7f7a70;
    --wb-heading-font: var(--wb-prose-font);
    --wb-heading-weight: 700;
}

[data-wb-theme="lamp"][data-bs-theme="light"] {
    --bs-body-bg: #ffffff;
    --bs-body-bg-rgb: 255,255,255;
    --bs-body-color: #262320;
    --bs-body-color-rgb: 38,35,32;
    --bs-emphasis-color: #262320;
    --bs-heading-color: #262320;
    --bs-secondary-color: #66605a;
    --bs-border-color: #ddd7cd;
    --bs-link-color: #8a5a12;
    --bs-link-color-rgb: 138,90,18;
    --bs-link-hover-color: #774d0f;
    --bs-link-hover-color-rgb: 119,77,15;
    --bs-secondary-bg: #efebe4;
    --bs-tertiary-bg: #e5e1da;
    --bs-light-bg-subtle: #efebe4;
    --bs-drag-handle: #66605a;
    --bs-primary: #8a5a12;
    --bs-primary-rgb: 138,90,18;
    --bs-primary-bg-subtle: rgba(178, 120, 30, 0.13);
    --bs-primary-text-emphasis: #8a5a12;
    --bs-dropdown-link-color: #262320;
    --wb-app-bg: #e7e3dc;
    --wb-nav-bg: #f7f5f1;
    --wb-muted: #66605a;
    --wb-placeholder: #676563;
    --wb-status-done: #3d6a24;
    --wb-status-revising: #8a5d00;
    --wb-status-draft: #66605a;
    --wb-input-border: #838280;
    --wb-surface: #fbfaf8;
    --wb-surface-2: #efebe4;
    --wb-desk: #e7e3dc;
    --wb-sheet: #ffffff;
    --wb-border: #ddd7cd;
    --wb-toolbar-bg: #efebe4;
    --wb-toolbar-color: #262320;
    --wb-toolbar-hover: #dfdbd4;
    --wb-toolbar-active: #d1cdc7;
    --wb-page-bg: #ffffff;
    --wb-page-color: #262320;
    --wb-statusbar-bg: #f7f5f1;
    --wb-statusbar-color: #66605a;
    --wb-danger-text: #a6342a;
    --wb-success-text: #3d6a24;
    --wb-attention: #f3dcc0;
    --wb-attention-text: #6b3f0c;
    --wb-accent: #8a5a12;
    --wb-accent-hover: #774d0f;
    --wb-accent-active: #69440e;
    --wb-accent-subtle: rgba(178, 120, 30, 0.13);
    --wb-on-accent: #ffffff;
    --wb-hover: rgba(38,35,32, 0.05);
    --wb-focus-ring: #8a5a12;
    --wb-shadow-sm: 0 2px 6px rgba(40, 30, 15, 0.08);
    --wb-shadow-md: 0 6px 20px rgba(40, 30, 15, 0.12);
    --wb-btn-outline-color: #262320;
    --wb-btn-outline-border: #afaaa2;
    --wb-btn-outline-hover-color: #262320;
    --wb-btn-outline-hover-bg: #e3dfd8;
    --wb-btn-outline-hover-border: #948f88;
    --wb-heading-font: 'Sitka Heading', var(--wb-prose-font);
    --wb-heading-weight: 700;
}

[data-wb-theme="lamp"][data-bs-theme="dark"] {
    --bs-body-bg: #1d1a14;
    --bs-body-bg-rgb: 29,26,20;
    --bs-body-color: #efe4cf;
    --bs-body-color-rgb: 239,228,207;
    --bs-emphasis-color: #efe4cf;
    --bs-heading-color: #efe4cf;
    --bs-secondary-color: #a89a82;
    --bs-border-color: #332c22;
    --bs-link-color: #e2a447;
    --bs-link-color-rgb: 226,164,71;
    --bs-link-hover-color: #e6b161;
    --bs-link-hover-color-rgb: 230,177,97;
    --bs-secondary-bg: #262119;
    --bs-tertiary-bg: #302b22;
    --bs-light-bg-subtle: #262119;
    --bs-drag-handle: #a89a82;
    --bs-primary: #e2a447;
    --bs-primary-rgb: 226,164,71;
    --bs-primary-bg-subtle: rgba(226, 164, 71, 0.15);
    --bs-primary-text-emphasis: #e2a447;
    --bs-dropdown-link-color: #efe4cf;
    --wb-app-bg: #110f0c;
    --wb-nav-bg: #17140f;
    --wb-muted: #a89a82;
    --wb-placeholder: #918879;
    --wb-status-done: #a3cf8a;
    --wb-status-revising: #e2a447;
    --wb-status-draft: #a89a82;
    --wb-input-border: #726b5e;
    --wb-surface: #1b1813;
    --wb-surface-2: #262119;
    --wb-desk: #110f0c;
    --wb-sheet: #1d1a14;
    --wb-border: #332c22;
    --wb-toolbar-bg: #262119;
    --wb-toolbar-color: #efe4cf;
    --wb-toolbar-hover: #363128;
    --wb-toolbar-active: #443e34;
    --wb-page-bg: #1d1a14;
    --wb-page-color: #efe4cf;
    --wb-statusbar-bg: #17140f;
    --wb-statusbar-color: #a89a82;
    --wb-danger-text: #f2a594;
    --wb-success-text: #a3cf8a;
    --wb-attention: #4a3410;
    --wb-attention-text: #f3cf8e;
    --wb-accent: #e2a447;
    --wb-accent-hover: #e6b161;
    --wb-accent-active: #e9ba73;
    --wb-accent-subtle: rgba(226, 164, 71, 0.15);
    --wb-on-accent: #1a1206;
    --wb-hover: rgba(239,228,207, 0.06);
    --wb-focus-ring: #e2a447;
    --wb-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --wb-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --wb-btn-outline-color: #efe4cf;
    --wb-btn-outline-border: #625a4d;
    --wb-btn-outline-hover-color: #efe4cf;
    --wb-btn-outline-hover-bg: #322d24;
    --wb-btn-outline-hover-border: #7e7667;
    --wb-heading-font: 'Sitka Heading', var(--wb-prose-font);
    --wb-heading-weight: 700;
}

[data-wb-theme="studio"][data-bs-theme="light"] {
    --bs-body-bg: #ffffff;
    --bs-body-bg-rgb: 255,255,255;
    --bs-body-color: #1d2327;
    --bs-body-color-rgb: 29,35,39;
    --bs-emphasis-color: #1d2327;
    --bs-heading-color: #1d2327;
    --bs-secondary-color: #5a666e;
    --bs-border-color: #dde2e5;
    --bs-link-color: #22685c;
    --bs-link-color-rgb: 34,104,92;
    --bs-link-hover-color: #1d594f;
    --bs-link-hover-color-rgb: 29,89,79;
    --bs-secondary-bg: #f1f3f4;
    --bs-tertiary-bg: #e6e9ea;
    --bs-light-bg-subtle: #f1f3f4;
    --bs-drag-handle: #5a666e;
    --bs-primary: #22685c;
    --bs-primary-rgb: 34,104,92;
    --bs-primary-bg-subtle: rgba(34, 104, 92, 0.10);
    --bs-primary-text-emphasis: #22685c;
    --bs-dropdown-link-color: #1d2327;
    --wb-app-bg: #e8ebed;
    --wb-nav-bg: #ffffff;
    --wb-muted: #5a666e;
    --wb-placeholder: #65696c;
    --wb-status-done: #1f6a3e;
    --wb-status-revising: #8a5d00;
    --wb-status-draft: #5a666e;
    --wb-input-border: #838688;
    --wb-surface: #ffffff;
    --wb-surface-2: #f1f3f4;
    --wb-desk: #e8ebed;
    --wb-sheet: #ffffff;
    --wb-border: #dde2e5;
    --wb-toolbar-bg: #f1f3f4;
    --wb-toolbar-color: #1d2327;
    --wb-toolbar-hover: #e0e2e4;
    --wb-toolbar-active: #d1d4d5;
    --wb-page-bg: #ffffff;
    --wb-page-color: #1d2327;
    --wb-statusbar-bg: #ffffff;
    --wb-statusbar-color: #5a666e;
    --wb-danger-text: #b0342c;
    --wb-success-text: #1f6a3e;
    --wb-attention: #dcefe9;
    --wb-attention-text: #174a41;
    --wb-accent: #22685c;
    --wb-accent-hover: #1d594f;
    --wb-accent-active: #1a4f46;
    --wb-accent-subtle: rgba(34, 104, 92, 0.10);
    --wb-on-accent: #ffffff;
    --wb-hover: rgba(29,35,39, 0.05);
    --wb-focus-ring: #22685c;
    --wb-shadow-sm: 0 2px 6px rgba(40, 30, 15, 0.08);
    --wb-shadow-md: 0 6px 20px rgba(40, 30, 15, 0.12);
    --wb-btn-outline-color: #1d2327;
    --wb-btn-outline-border: #adb2b6;
    --wb-btn-outline-hover-color: #1d2327;
    --wb-btn-outline-hover-bg: #e4e7e8;
    --wb-btn-outline-hover-border: #909699;
    --wb-heading-font: var(--wb-ui-font);
    --wb-heading-weight: 650;
}

[data-wb-theme="studio"][data-bs-theme="dark"] {
    --bs-body-bg: #1a1f22;
    --bs-body-bg-rgb: 26,31,34;
    --bs-body-color: #e3e7ea;
    --bs-body-color-rgb: 227,231,234;
    --bs-emphasis-color: #e3e7ea;
    --bs-heading-color: #e3e7ea;
    --bs-secondary-color: #95a1a9;
    --bs-border-color: #2a3237;
    --bs-link-color: #5fb3a1;
    --bs-link-color-rgb: 95,179,161;
    --bs-link-hover-color: #75beae;
    --bs-link-hover-color-rgb: 117,190,174;
    --bs-secondary-bg: #21272b;
    --bs-tertiary-bg: #2b3135;
    --bs-light-bg-subtle: #21272b;
    --bs-drag-handle: #95a1a9;
    --bs-primary: #5fb3a1;
    --bs-primary-rgb: 95,179,161;
    --bs-primary-bg-subtle: rgba(95, 179, 161, 0.14);
    --bs-primary-text-emphasis: #5fb3a1;
    --bs-dropdown-link-color: #e3e7ea;
    --wb-app-bg: #101315;
    --wb-nav-bg: #161a1d;
    --wb-muted: #95a1a9;
    --wb-placeholder: #888d90;
    --wb-status-done: #8fd3a8;
    --wb-status-revising: #e0b04a;
    --wb-status-draft: #95a1a9;
    --wb-input-border: #6b7074;
    --wb-surface: #181c1f;
    --wb-surface-2: #21272b;
    --wb-desk: #101315;
    --wb-sheet: #1a1f22;
    --wb-border: #2a3237;
    --wb-toolbar-bg: #21272b;
    --wb-toolbar-color: #e3e7ea;
    --wb-toolbar-hover: #31363a;
    --wb-toolbar-active: #3e4448;
    --wb-page-bg: #1a1f22;
    --wb-page-color: #e3e7ea;
    --wb-statusbar-bg: #161a1d;
    --wb-statusbar-color: #95a1a9;
    --wb-danger-text: #f2a8a1;
    --wb-success-text: #8fd3a8;
    --wb-attention: #1f3b35;
    --wb-attention-text: #9fdccd;
    --wb-accent: #5fb3a1;
    --wb-accent-hover: #75beae;
    --wb-accent-active: #85c5b8;
    --wb-accent-subtle: rgba(95, 179, 161, 0.14);
    --wb-on-accent: #0d1a17;
    --wb-hover: rgba(227,231,234, 0.06);
    --wb-focus-ring: #5fb3a1;
    --wb-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --wb-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --wb-btn-outline-color: #e3e7ea;
    --wb-btn-outline-border: #585f64;
    --wb-btn-outline-hover-color: #e3e7ea;
    --wb-btn-outline-hover-bg: #2d3336;
    --wb-btn-outline-hover-border: #747a7f;
    --wb-heading-font: var(--wb-ui-font);
    --wb-heading-weight: 650;
}

/* Light editor page inside each palette (dark mode, "light page" toggle) */
[data-wb-theme="paper"] {
    --wb-lightpage-bg: #fffdf8;
    --wb-lightpage-color: #2b2722;
    --wb-lightpage-desk: #3a352c;
}

[data-wb-theme="lamp"] {
    --wb-lightpage-bg: #ffffff;
    --wb-lightpage-color: #262320;
    --wb-lightpage-desk: #3a3227;
}

[data-wb-theme="studio"] {
    --wb-lightpage-bg: #ffffff;
    --wb-lightpage-color: #1d2327;
    --wb-lightpage-desk: #2e3539;
}

/* =============================================================
   Components that read the tokens
============================================================= */

/* Placeholders: always dimmer than typed text */
::placeholder,
input::placeholder,
textarea::placeholder,
.form-control::placeholder {
    color: var(--wb-placeholder);
    opacity: 1;
}

/* Form control edges: --wb-input-border reaches 3:1 against the input and page grounds
   (WCAG 1.4.11). --bs-border-color / --wb-border stay for decorative dividers.
   Focus keeps each control's own focus colour and ring. */
.form-control:not(:focus),
.form-select:not(:focus),
.form-check-input:not(:checked) {
    border-color: var(--wb-input-border);
}

/* Editor find bar (_LexicalEditor.cshtml) */
.wb-editor .editor-find-bar input:not(:focus) {
    border-color: var(--wb-input-border);
}

/* The inline chapter title is a deliberately borderless field: give it a visible underline */
[data-bs-theme] .editor-pane .chapter-title-input:not(:focus):not(:hover) {
    border-bottom-color: var(--wb-input-border);
}

/* Headings: palettes may switch the font and weight. The editor and the shared-chapter
   reader keep their own manuscript headings. Classic falls back to the old values. */
:is(h1, h2, h3):not(:where([contenteditable] *, #chapterView *, .lexical-h1, .lexical-h2, .lexical-h3)) {
    font-family: var(--wb-heading-font, var(--wb-ui-font));
}

.card-title {
    font-family: var(--wb-heading-font, var(--wb-ui-font));
    font-weight: var(--wb-heading-weight, 500);
}

#mainNavbar .navbar-brand {
    font-family: var(--wb-heading-font, var(--wb-ui-font));
    font-weight: var(--wb-heading-weight, 400);
    color: var(--bs-body-color);
}

/* Bootstrap's primary is the palette accent (buttons, switches, active pills) */
.btn.btn-primary {
    --bs-btn-color: var(--wb-on-accent);
    --bs-btn-bg: var(--wb-accent);
    --bs-btn-border-color: var(--wb-accent);
    --bs-btn-hover-color: var(--wb-on-accent);
    --bs-btn-hover-bg: var(--wb-accent-hover);
    --bs-btn-hover-border-color: var(--wb-accent-hover);
    --bs-btn-active-color: var(--wb-on-accent);
    --bs-btn-active-bg: var(--wb-accent-active);
    --bs-btn-active-border-color: var(--wb-accent-active);
    --bs-btn-disabled-color: var(--wb-on-accent);
    --bs-btn-disabled-bg: var(--wb-accent);
    --bs-btn-disabled-border-color: var(--wb-accent);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

/* Secondary outline buttons everywhere (editor header, book list "More" menu, dialogs, forms).
   Fallbacks are Bootstrap's own, so Classic light is unchanged. */
.btn-outline-secondary {
    --bs-btn-color: var(--wb-btn-outline-color, #6c757d);
    --bs-btn-border-color: var(--wb-btn-outline-border, #6c757d);
    --bs-btn-hover-color: var(--wb-btn-outline-hover-color, #ffffff);
    --bs-btn-hover-bg: var(--wb-btn-outline-hover-bg, #6c757d);
    --bs-btn-hover-border-color: var(--wb-btn-outline-hover-border, #6c757d);
    --bs-btn-active-color: var(--wb-btn-outline-hover-color, #ffffff);
    --bs-btn-active-bg: var(--wb-btn-outline-hover-bg, #6c757d);
    --bs-btn-active-border-color: var(--wb-btn-outline-hover-border, #6c757d);
}

/* Top navbar (_Header.cshtml). Page headers have no background of their own. */
#mainNavbar {
    background-color: var(--wb-nav-bg);
    color: var(--bs-body-color);
}

    #mainNavbar .nav-link {
        color: var(--bs-body-color);
    }

    #mainNavbar .dropdown-menu:not(.wb-menu) {
        background-color: var(--wb-nav-bg);
        color: var(--bs-body-color);
    }

/* Classic dark: other navbars keep the old panel colour */
[data-wb-theme="classic"][data-bs-theme="dark"] .navbar {
    background: var(--bs-secondary-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

/* Logout is a button styled as a link; keep it the nav link color in both modes */
#mainNavbar #logout {
    color: var(--bs-body-color);
}

/* -----------------------------------------
   Dark-mode component overrides (all palettes)
----------------------------------------- */

[data-bs-theme="dark"] .list-group-item {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .chapter-item.chapter-selected {
    background-color: var(--wb-surface-2);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] textarea,
[data-bs-theme="dark"] input,
[data-bs-theme="dark"] select {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border-color: var(--wb-input-border);
}

[data-bs-theme="dark"] .note-card {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .modal-body,
[data-bs-theme="dark"] .modal-footer,
[data-bs-theme="dark"] .modal-header {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

/* Cards keep their card look in dark mode */
[data-bs-theme="dark"] .book-table {
    background: var(--wb-surface);
    color: var(--bs-body-color);
    border-color: var(--wb-border);
}

/* Selected chapter: the theme's accent tint in light and dark (Bootstrap's default is a solid blue). */
.wb-chapter-item.active {
    color: var(--bs-body-color);
    border-color: var(--wb-border);
    background: var(--wb-accent-subtle);
}

[data-bs-theme="dark"] .drag-handle {
    color: var(--bs-drag-handle);
}
