/*
 * Site themes: light (default), parchment and dark, set on <html> as
 * data-appearance by study-appearance.js. Colours come from the brand
 * (bnei-baruch-brand skill): dark is built from Deep Blue with Cream text,
 * parchment is Cream paper with Ink text and Deep Blue links.
 *
 * Each text colour is chosen for 4.5:1 on the surfaces it is meant for (large
 * text 3:1). Brand Teal is 3.9:1 on the raised surface, so raised containers
 * switch links to a lighter Teal; brand Orange is text only on the page.
 */

/* ---- The three-way switch ---- */
.study-appearance-switch {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
  margin-inline: .125rem;
  border: 1px solid var(--study-control, #71818c);
  border-radius: 999px;
}
/* In the student headers the next item (language, avatar) has no spacing of its own. */
.study-header-actions .study-appearance-switch { margin-inline-end: .75rem; }
.study-appearance-switch[hidden] { display: none; }
.study-appearance-switch button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--study-muted, #3f5363);
  cursor: pointer;
}
.study-appearance-switch button[aria-pressed="true"] {
  background: var(--study-switch-on, #003b65);
  color: var(--study-switch-on-ink, #fbfbfb);
}
@media (hover: hover) {
  .study-appearance-switch button[aria-pressed="false"]:hover { color: var(--study-link, #003b65); }
}
.study-appearance-switch button:focus-visible {
  outline: 2px solid var(--study-focus, #00608f);
  outline-offset: 1px;
}
@media (forced-colors: active) {
  .study-appearance-switch button[aria-pressed="true"] { outline: 2px solid Highlight; }
}
/* Narrow phones: keep the header on one line; 28px still clears the 24px target minimum. */
@media (max-width: 380px) {
  .study-appearance-switch { gap: 0; }
  .study-header-actions .study-appearance-switch { margin-inline-end: .5rem; }
  .study-appearance-switch button { width: 28px; height: 28px; }
}
.study-appearance-standalone {
  display: flex;
  width: fit-content;
  margin-inline: auto clamp(1rem, 3vw, 3.75rem);
}

/* ---- Logo proportions (unchanged by theme) ---- */
.study-mobile-logo,
[data-study-scope="student"] nav:has(.study-header-actions) img[src*="on_white"] {
  aspect-ratio: 900 / 245;
  object-fit: contain;
}
/* The Hebrew wordmark is narrower (857 x 245). */
.study-mobile-logo[src$="_he.png"],
[data-study-scope="student"] nav:has(.study-header-actions) img[src$="on_white_he.png"] {
  aspect-ratio: 857 / 245;
}
[data-study-scope="staff"] header img[src$="/images/logo.png"] {
  aspect-ratio: 1036 / 224;
  object-fit: contain;
}
@media (max-width: 639px) {
  .study-mobile-logo { width: 100%; }
}
@media (max-width: 440px) {
  .study-header-actions .study-header-menu {
    width: auto;
    margin-inline: 2px;
    padding-inline: 8px;
  }
  [data-study-scope="student"] nav:has(.study-header-actions) img[src*="on_white"] {
    width: clamp(86px, 29vw, 116px);
    height: auto;
  }
}

/* ---- Palettes ---- */
[data-appearance="dark"] {
  color-scheme: dark;
  --study-page: #022d4c;        /* custom-blue-250 */
  --study-surface: #003b65;     /* brand Deep Blue */
  --study-raised: #0d4c7a;
  --study-line: #6f9cbf;        /* control border, 3.1:1 or more on every surface */
  --study-control: #6f9cbf;
  --study-ink: #f6f0eb;         /* brand Cream */
  --study-muted: #c9beb1;       /* sand */
  --study-link: #33bbbd;        /* brand Teal, on page and surface */
  --study-link-raised: #6fd0d1; /* Teal lifted for raised surfaces and tints */
  --study-accent: #ff9a62;      /* Orange lifted for text on surfaces */
  --study-focus: #33bbbd;
  --study-switch-on: #33bbbd;
  --study-switch-on-ink: #022d4c;
}
[data-appearance="parchment"] {
  --study-page: #f6f0eb;        /* brand Cream */
  --study-surface: #fbfbfb;     /* brand Paper */
  --study-raised: #ebe1d6;
  --study-line: #ddd1c4;        /* hairlines */
  --study-control: #8c7b6a;     /* control borders, 3.1:1 or more */
  --study-ink: #202020;         /* brand Ink */
  --study-muted: #4a4f53;       /* brand Slate */
  --study-link: #003b65;        /* brand Deep Blue (no Teal type on Cream) */
  --study-link-raised: #003b65;
  --study-accent: #a3470e;      /* Orange darkened for text on Cream */
  --study-focus: #003b65;
  --study-switch-on: #003b65;
  --study-switch-on-ink: #f6f0eb;
}

/*
 * Rules shared by parchment and dark: map the site's Tailwind surfaces, text
 * and borders onto the palette. Light keeps the classes' own colours.
 */
/* Parchment leaves text colours alone where they are already dark: BB Admin and black text. */
:is([data-appearance="dark"], [data-appearance="parchment"]),
:is([data-appearance="dark"], [data-appearance="parchment"]) body { background: var(--study-page); }
:is([data-appearance="dark"], [data-study-scope="student"][data-appearance="parchment"]),
:is([data-appearance="dark"], [data-study-scope="student"][data-appearance="parchment"]) body { color: var(--study-ink); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .study-nav {
  --nav-ink: var(--study-muted);
  --nav-border: var(--study-line);
  --nav-focus: var(--study-focus);
}
[data-appearance="dark"] .study-nav { --nav-bg: var(--study-surface); --nav-active: var(--study-ink); }
[data-appearance="parchment"] .study-nav { --nav-bg: var(--study-page); --nav-active: var(--study-link); }
:is([data-appearance="dark"], [data-appearance="parchment"]) :focus-visible { outline: 2px solid var(--study-focus); outline-offset: 2px; }

[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) {
  --tw-prose-body: var(--study-ink);
  --tw-prose-headings: var(--study-ink);
  --tw-prose-links: var(--study-link);
}
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.bg-custom-gray-151, .bg-custom-gray-200, .bg-gray-100) { background-color: var(--study-raised); }
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.text-gray-400, .text-gray-500, .text-gray-600, .text-gray-700, .text-custom-gray-150) { color: var(--study-muted); }
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.text-custom-blue-135, .text-custom-blue-200, .text-custom-blue-800) { color: var(--study-link); }
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.bg-white, .bg-custom-gray-50, .bg-gray-50, .bg-custom-blue-100) { background-color: var(--study-surface); }
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.bg-custom-gray-100, .bg-gray-200, .bg-custom-gray-90) { background-color: var(--study-raised); }
[data-appearance="dark"] :is(.text-black, .text-gray-900, .text-custom-blue-250, .text-\[\#003B65\]) { color: var(--study-ink); }
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.text-custom-blue-150, .text-custom-blue-50) { color: var(--study-link); }
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.border-custom-gray-100, .border-gray-200) { border-color: var(--study-line); }
/* custom-blue-270 is a 10% hairline (the site header's bottom edge): keep it that faint. */
[data-appearance="parchment"] .border-custom-blue-270 { border-color: var(--study-line); }
[data-appearance="dark"] .border-custom-blue-270 { border-color: rgb(246 240 235 / .12); }
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.hover\:bg-custom-gray-50, .hover\:bg-gray-50):hover { background-color: var(--study-raised); }
/*
 * Inline icons drawn in Deep Blue (feed likes and comments, event and playlist
 * badges) vanish on Deep Blue: draw them in the text colour. Two-tone icons,
 * a Deep Blue tile behind a white glyph, keep their tile. The feed's
 * "Load more" icon has no fill at all, so it would be black.
 */
[data-study-scope="student"][data-appearance="dark"] :is(svg:not(:has([fill="white" i], [fill="#fff" i], [fill="#ffffff" i], [stroke="white" i], [stroke="#fff" i], [stroke="#ffffff" i]))[fill="#003b65" i], svg:not(:has([fill="white" i], [fill="#fff" i], [fill="#ffffff" i], [stroke="white" i], [stroke="#fff" i], [stroke="#ffffff" i])) [fill="#003b65" i]) { fill: var(--study-ink); }
[data-study-scope="student"][data-appearance="dark"] :is(svg:not(:has([fill="white" i], [fill="#fff" i], [fill="#ffffff" i], [stroke="white" i], [stroke="#fff" i], [stroke="#ffffff" i]))[stroke="#003b65" i], svg:not(:has([fill="white" i], [fill="#fff" i], [fill="#ffffff" i], [stroke="white" i], [stroke="#fff" i], [stroke="#ffffff" i])) [stroke="#003b65" i]) { stroke: var(--study-ink); }
[data-study-scope="student"][data-appearance="dark"] #load-more-button svg { fill: currentColor; }
/*
 * The Alpine pickers (common/form/countries-select.html, the bookshop's sort
 * menu) are a box around a borderless input: give the box the field look of
 * the other inputs, and light icons in dark. Same for the phone field's
 * country arrow and the bookshop's view buttons.
 */
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) .select-box {
  background-color: var(--study-surface);
  border-color: var(--study-control);
}
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.select-box, .select-box-menu) input {
  background-color: transparent;
  border-color: transparent;
}
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.select-box-menu, .select-box-menu .border-custom-blue-150) {
  border-color: var(--study-control);
}
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) .select-box-menu .hover\:bg-custom-blue-130:hover {
  background-color: var(--study-raised);
}
[data-study-scope="student"][data-appearance="dark"] :is(.select-box, .select-box-menu) img { filter: brightness(0) invert(1); }
/* The ring belongs on the box, not on the read-only text inside it. */
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) .select-box input:focus-visible { outline: none; }
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) .select-box:has(input:focus-visible) {
  outline: 2px solid var(--study-focus);
  outline-offset: 2px;
}
[data-study-scope="student"][data-appearance="dark"] :is(img[src$="/cardsViewIcon.svg"], img[src$="/listViewIcon.svg"]) { filter: brightness(0) invert(1); }
[data-study-scope="student"][data-appearance="dark"] .iti__arrow { border-top-color: var(--study-muted); }
[data-study-scope="student"][data-appearance="dark"] .iti__arrow--up { border-top-color: transparent; border-bottom-color: var(--study-muted); }
[data-study-scope="student"][data-appearance="dark"] .iti__country-list { background-color: var(--study-surface); border-color: var(--study-line); }
[data-study-scope="student"][data-appearance="dark"] .iti__country.iti__highlight { background-color: var(--study-raised); }
[data-study-scope="student"][data-appearance="dark"] .iti__dial-code { color: var(--study-muted); }
/* The site headers (fixed or sticky at top-0); in-page navs such as breadcrumbs stay transparent. */
[data-study-scope="student"][data-appearance="dark"] nav.top-0:not(.study-nav) { background-color: var(--study-surface); }
/*
 * In light the page and its plain white bands are the same white; only cards
 * (rounded, bordered or shadowed boxes) and overlays stand apart. Keep it that
 * way: an unboxed white band (a landing row, the site footer, a list wrapper)
 * takes the page colour, so the themes add no stripes or slabs light doesn't
 * have. The off-white and faint gray bands (custom-gray-50, gray-90) that
 * alternate with white ones get a tint about as faint as theirs in light.
 */
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.bg-white, .bg-custom-white):not([class*="rounded"], [class*="shadow"], [class*="border"], .fixed, .absolute, .sticky, input, select, textarea, button) {
  background-color: var(--study-page);
}
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.bg-custom-gray-50, .bg-gray-50, .bg-custom-gray-90):not([class*="rounded"], [class*="shadow"], [class*="border"], .fixed, .absolute, .sticky, input, select, textarea, button) {
  background-color: color-mix(in srgb, var(--study-surface) 45%, var(--study-page));
}
@media (min-width: 1024px) {
  [data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.lg\:bg-white, .lg\:bg-custom-white):not([class*="rounded"], [class*="shadow"], [class*="border"], .fixed, .absolute, .sticky) {
    background-color: var(--study-page);
  }
  [data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) .lg\:bg-custom-gray-50:not([class*="rounded"], [class*="shadow"], [class*="border"], .fixed, .absolute, .sticky) {
    background-color: color-mix(in srgb, var(--study-surface) 45%, var(--study-page));
  }
}
/*
 * Parchment only recolours the light site header. Landing pages style their
 * own footers (light text on navy), which a Cream background would erase.
 */
[data-study-scope="student"][data-appearance="parchment"] nav:is(.bg-custom-gray-50, :has(.study-header-actions)) { background-color: var(--study-page); }
/*
 * The white wrapper beside the study sidebar is the page itself in light (it
 * stops where the content stops). Let it show the page colour, so the boxes
 * inside it keep their contrast and there is no seam below the content.
 */
:is([data-appearance="dark"], [data-appearance="parchment"]) .bg-white.lg\:ms-profile-sidebar { background-color: transparent; }
/* Brand Teal is 3.9:1 on the raised surface: lift links inside raised containers. */
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.bg-custom-gray-151, .bg-custom-gray-200, .bg-gray-100, .bg-custom-gray-100, .bg-gray-200, .bg-custom-gray-90) {
  --study-link: var(--study-link-raised);
}
/* Teal pills (article tags, donation amounts) fill with Teal on hover. */
[data-appearance="dark"] .hover\:bg-custom-blue-50:hover { color: var(--study-page); }
[data-appearance="parchment"] .hover\:bg-custom-blue-50:hover { color: var(--study-link); }
/* Faded labels ("2 Lessons", "* Required fields"): full opacity, muted colour. */
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(a, span, p, li, .text-xs, .text-sm):is(.opacity-40, .opacity-50, .opacity-\[0\.55\], .opacity-60, .opacity-65):not(.text-white) {
  opacity: 1;
  color: var(--study-muted);
}
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.prose, .prose p, .prose strong, .prose li, .prose h2, .prose h3) { color: var(--study-ink); }
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) .prose a { color: var(--study-link); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .bb-reader {
  --reader-ink: var(--study-ink);
  --reader-muted: var(--study-muted);
  --reader-rule: var(--study-line);
  --reader-accent: var(--study-link);
  --reader-warm: var(--study-accent);
  --reader-soft: var(--study-raised);
}
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.bb-reader-switch, .bb-to-top) { background: var(--study-surface); }
/* The sticky sidebar title covers the list as it scrolls: it is the page behind it, not a card. */
:is([data-appearance="dark"], [data-appearance="parchment"]) .bb-sidebar-head { background: var(--study-page); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .bb-article-body :is(strong, b, blockquote),
:is([data-appearance="dark"], [data-appearance="parchment"]) .error-page { color: var(--study-ink); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .crm-app { background: var(--study-page); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .blog-prose {
  --tw-prose-headings: var(--study-ink);
  --tw-prose-quotes: var(--study-ink);
  --tw-prose-bold: var(--study-ink);
  --tw-prose-bullets: var(--study-muted);
}
:is([data-appearance="dark"], [data-appearance="parchment"]) .blog-prose blockquote { color: var(--study-ink); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .blog-card a.bg-custom-blue-10:hover,
:is([data-appearance="dark"], [data-appearance="parchment"]) #blog-load-more a:hover {
  background: var(--study-raised);
  color: var(--study-link-raised);
}
:is([data-appearance="dark"], [data-appearance="parchment"]) .blog-author-intro .text-sky-900 { color: var(--study-ink); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .blog-author-intro .opacity-40 { color: var(--study-muted); opacity: 1; }

/* ---- Dark only ---- */
[data-appearance="dark"] img:is([src*="on_white"], [src$="/images/logo.png"]) {
  content: var(--study-dark-logo);
}
[data-appearance="dark"] .bb-tool-primary:hover { color: var(--study-page); }
[data-study-scope="student"][data-appearance="dark"] .study-feed-filters > li:is(.opacity-40, .opacity-50, .opacity-65) { opacity: 1; }
[data-study-scope="student"][data-appearance="dark"] :is(.text-white.bg-custom-blue-150, .text-white.bg-custom-blue-250):not(a, button) { color: #fff; }
/*
 * Deep Blue pill buttons (cookie banner, Join, Apply) would vanish into Deep
 * Blue cards: fill them with Teal and dark text, as in the approved mockup.
 */
[data-study-scope="student"][data-appearance="dark"] :is(a, button).bg-custom-blue-150 {
  background-color: var(--study-link);
  color: var(--study-page);
}
[data-study-scope="student"][data-appearance="dark"] :is(a, button, li, .lesson-tabs > *).border-custom-blue-150,
[data-study-scope="student"][data-appearance="dark"] li.hover\:border-custom-blue-150:hover { border-color: var(--study-link); }
/* The study-day strip marks today with a white tile on its Deep Blue band. */
[data-study-scope="student"][data-appearance="dark"] [aria-current="date"].bg-white {
  background-color: var(--study-link);
  color: var(--study-page);
}
[data-appearance="dark"] nav path[fill="#00447C"] { fill: var(--study-link); }
[data-appearance="dark"] #label-pills .border-white { border-color: transparent; }
/*
 * Small Orange text on a card or raised surface. The page and the large lesson
 * heading (3.7:1 on Deep Blue, over the 3:1 large text needs) keep brand Orange.
 */
[data-study-scope="student"][data-appearance="dark"] :is(.bg-white, .bg-custom-gray-50, .bg-gray-50, .bg-custom-gray-100, .bg-gray-100) .text-custom-orange:not(.lesson-heading-label) { color: var(--study-accent); }

/*
 * A white pill with a white edge is the button that sits on a photo (the
 * landing hero's Join). The photo looks the same in every theme, so the
 * pill keeps its Light look: white with a Deep Blue label.
 */
[data-study-scope="student"]:is([data-appearance="dark"], [data-appearance="parchment"]) :is(a, button).bg-white.border-white {
  background-color: #fff;
  color: #003b65;
}

/* Glossary (static/css/glossary.css sets these on :root). */
:root[data-appearance="dark"] {
  --glossary-surface: var(--study-surface);
  --glossary-text: var(--study-ink);
  --glossary-muted: var(--study-muted);
  --glossary-border: #1f5c87;
  --glossary-accent: var(--study-link);
  --glossary-accent-soft: rgba(51, 187, 189, .16);
  --glossary-underline: #6fd0d1;
  /* Text on Teal buttons and the active chip: 6.06:1. Through the variable, so
     it only applies where glossary.css styled the button Teal in the first place. */
  --glossary-on-accent: var(--study-page);
}
:root[data-appearance="parchment"] {
  --glossary-surface: var(--study-surface);
  --glossary-text: var(--study-ink);
  --glossary-muted: var(--study-muted);
  --glossary-border: var(--study-line);
  --glossary-accent-soft: var(--study-raised);
}

/* Form controls */
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="image"]), select, textarea) {
  background-color: var(--study-surface);
  color: var(--study-ink);
  border-color: var(--study-control);
}
:is([data-appearance="dark"], [data-appearance="parchment"]) ::placeholder { color: var(--study-muted); opacity: 1; }

/* Staff cards, tables and HTMX forms use Frankenstyle palette variables. */
:is([data-study-scope="staff"], [data-appearance-palette="frankenstyle"])[data-appearance="dark"] {
  --color-white: var(--study-surface);
  --color-gray-50: var(--study-page);
  --color-gray-100: var(--study-raised);
  --color-gray-200: #1f5c87;
  --color-gray-300: var(--study-line);
  --color-gray-400: #c2b8ac;  /* used for small text: 4.6:1 on raised */
  --color-custom-blue-150: var(--study-link);  /* brand-blue button fills */
  --color-custom-blue-200: #6fd0d1;
  --color-gray-500: var(--study-muted);
  --color-gray-600: #d8cfc5;
  --color-gray-700: #e6ded6;
  --color-gray-800: var(--study-ink);
  --color-gray-900: #fbf8f5;
  --color-blue-50: #0b4a73;
  --color-blue-100: #125684;
  --color-blue-300: #4a8db5;
  --color-blue-400: var(--study-link);   /* chart bars, as in the mockup */
  --color-blue-500: var(--study-link);
  --color-blue-600: #7fd5d6;  /* text on blue-100 badges: 4.6:1 */
  --color-blue-700: #a6e1e2;
  --color-blue-800: #c4ecec;
  --color-green-50: #14473f;
  --color-green-100: #1c5446;
  --color-green-200: #3f7a55;
  --color-green-700: #b4e36a;
  --color-green-800: #c9ec8e;
  --color-red-50: #3a3550;
  --color-red-100: #4a3550;
  --color-red-200: #7a4a5c;
  --color-red-600: #ffa49a;
  --color-red-700: #ffb3aa;
  --color-red-800: #ffc4bc;
  --color-amber-50: #2f4048;
  --color-amber-100: #3c4a44;
  --color-amber-200: #7a6a3e;
  --color-amber-300: #a38a4a;
  --color-amber-500: #fbc531;
  --color-amber-700: #fcd468;
  --color-amber-800: #fde095;
  --color-violet-50: #253a6a;
  --color-violet-100: #2e4377;
  --color-violet-200: #55609a;
  --color-violet-700: #cdbdf5;
  --color-violet-900: #e6dbff;
  /* Other hues BB Admin uses: tints over Deep Blue for 50–300, lighter steps for text, each 4.5:1 or more on every dark surface. */
  --color-amber-400: #ffd230;
  --color-amber-600: #ffd230;
  --color-amber-900: #fffbeb;
  --color-blue-200: #2469aa;
  --color-blue-900: #eff6ff;
  --color-emerald-50: #005069;
  --color-emerald-100: #005d6b;
  --color-emerald-200: #008079;
  --color-emerald-300: #42b59d;
  --color-emerald-500: #5ee9b5;
  --color-emerald-600: #5ee9b5;
  --color-emerald-700: #a4f4cf;
  --color-emerald-800: #d0fae5;
  --color-emerald-900: #ecfdf5;
  --color-green-300: #56ba94;
  --color-green-400: #7bf1a8;
  --color-green-500: #7bf1a8;
  --color-green-600: #7bf1a8;
  --color-green-900: #f0fdf4;
  --color-indigo-50: #10417e;
  --color-indigo-600: #a8b7ff;
  --color-orange-50: #294255;
  --color-orange-100: #42474b;
  --color-orange-200: #735e39;
  --color-orange-500: #ffb86a;
  --color-orange-600: #ffb86a;
  --color-orange-700: #ffd6a7;
  --color-pink-50: #273a6d;
  --color-pink-700: #fccee8;
  --color-purple-50: #1c3d7e;
  --color-purple-100: #2d3e8d;
  --color-purple-200: #5757aa;
  --color-purple-600: #dab2ff;
  --color-purple-700: #e9d4ff;
  --color-purple-800: #f3e8ff;
  --color-red-300: #b28390;
  --color-red-400: #ffa2a2;
  --color-red-500: #ffa2a2;
  --color-red-900: #fef2f2;
  --color-rose-50: #293763;
  --color-rose-400: #ffa1ad;
  --color-rose-600: #ffa1ad;
  --color-rose-700: #ffccd3;
  --color-rose-800: #ffe4e6;
  --color-sky-50: #004c7c;
  --color-sky-700: #b8e6fe;
  --color-sky-800: #dff2fe;
  --color-teal-50: #004f70;
  --color-teal-100: #005c76;
  --color-teal-200: #00808d;
  --color-teal-600: #46ecd5;
  --color-teal-700: #96f7e4;
  --color-teal-800: #cbfbf1;
  --color-violet-600: #c4b4ff;
  --color-violet-800: #ede9fe;
  --color-yellow-50: #264e55;
  --color-yellow-100: #3e5a4b;
  --color-yellow-200: #727a38;
  --color-yellow-400: #ffdf20;
  --color-yellow-500: #ffdf20;
  --color-yellow-600: #ffdf20;
  --color-yellow-700: #fff085;
  --color-yellow-800: #fef9c2;
  --color-yellow-900: #fefce8;
}
/*
 * Many BB Admin templates write white as a literal (style="--bg: white;
 * --color: white") instead of var(--color-white), so the palette above cannot
 * reach them. !important is needed to beat the inline declaration. White text
 * sits on blue/green/red/gray-900 fills, which the dark palette makes light,
 * so it becomes Deep Blue.
 */
:is([data-study-scope="staff"], [data-appearance-palette="frankenstyle"])[data-appearance="dark"] :is(
  [style*="--bg: white"], [style*="--bg:white"],
  [style*="--bg: #fff;"], [style*="--bg:#fff;"], [style$="--bg: #fff"],
  [style*="--bg: #ffffff"], [style*="--bg:#ffffff"]
) { --bg: var(--color-white) !important; }
:is([data-study-scope="staff"], [data-appearance-palette="frankenstyle"])[data-appearance="dark"] :is(
  [style*="--color: white"], [style*="--color:white"],
  [style*="--color: #fff;"], [style*="--color:#fff;"], [style$="--color: #fff"],
  [style*="--color: #ffffff"], [style*="--color:#ffffff"]
) { --color: var(--color-white) !important; }

/* Staff guide (bb_admin/guide/_styles.html) keeps its own light palette. */
[data-appearance="dark"] .staff-guide { --ink: var(--study-ink); --blue: var(--study-link); --line: #1f5c87; }
[data-appearance="dark"] :is(.guide-breadcrumb, .guide-intro, .guide-preview-box dt, .guide-step-body figcaption,
  .guide-path, .guide-role, .guide-topic-search [role=status], .guide-task-neighbors small) { color: var(--study-muted); }
[data-appearance="dark"] :is(.guide-practice, .guide-reference, .guide-launch, .guide-topic-group.guide-launch, .guide-task-menu [aria-current]) {
  background: var(--study-raised);
  --blue: var(--study-link-raised);
}

:is([data-study-scope="staff"], [data-appearance-palette="frankenstyle"])[data-appearance="parchment"] {
  --color-white: var(--study-surface);
  --color-gray-50: var(--study-page);
  --color-gray-100: var(--study-raised);
  --color-gray-200: var(--study-line);
  --color-gray-300: #c9bbab;
  /* Secondary text: 4.5:1 or more on Cream and on the raised sand. */
  --color-gray-400: #56636f;
  --color-gray-500: #4a4f53;  /* brand Slate */
  /* Coloured text that passes on white but not on Cream: one step darker. */
  --color-amber-700: #973c00;  /* amber-800, 5.5:1 */
  --color-emerald-700: #006045;  /* emerald-800, 5.9:1 */
  --color-green-700: #016630;  /* green-800, 5.5:1 */
  --color-orange-700: #9f2d00;  /* orange-800, 5.7:1 */
  --color-purple-600: #8200db;  /* purple-700, 5.5:1 */
  --color-red-600: #c10007;  /* red-700, 5.0:1 */
  --color-rose-600: #c70036;  /* rose-700, 4.7:1 */
  --color-teal-700: #005f5a;  /* teal-800, 5.8:1 */
  --color-yellow-700: #894b00;  /* yellow-800, 5.3:1 */
  /* Buttons, links and charts in brand Deep Blue instead of the default bright blue. */
  --color-blue-400: #4a7fa8;
  --color-blue-500: #1f5c87;
  --color-blue-600: #003b65;
  --color-blue-700: #002a4a;
}

/* Inactive AI models are dimmed to 0.55; on Deep Blue that drops their text under 4.5:1. */
[data-study-scope="staff"][data-appearance="dark"] tr:has(> .aim-td)[style*="opacity: 0.55"] { opacity: .72 !important; }

/* ---- Light and parchment: contrast fixes for small text on pale backgrounds ---- */
[data-study-scope="student"]:is([data-appearance="light"], [data-appearance="parchment"]) :is(a.opacity-50, [role="tab"].opacity-50) {
  opacity: 1;
  color: #536473;
}
[data-study-scope="student"]:is([data-appearance="light"], [data-appearance="parchment"]) :is(a, button, span).text-custom-orange { color: #a3470e; }
[data-study-scope="student"]:is([data-appearance="light"], [data-appearance="parchment"]) .study-feed-filters > .opacity-40 {
  opacity: 1;
  color: #40576a;
}
[data-study-scope="staff"][data-appearance="light"] {
  --color-gray-400: #617182;
}

/* ---- Lesson page ---- */
[data-study-scope="student"] .lesson-heading-label { font-size: 1.1875rem; font-weight: 700; line-height: 1.4; }
/* Brand Orange is 2.8:1 on Cream, under the 3:1 a large heading needs. */
[data-study-scope="student"][data-appearance="parchment"] .lesson-heading-label { color: var(--study-accent); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .lesson-reading-mode { color: var(--study-link); }
:is([data-appearance="dark"], [data-appearance="parchment"]) .lesson-reading-mode:hover { background: var(--study-link); color: var(--study-page); }
.study-header-menu[aria-label] { min-width: 44px; min-height: 44px; }
@media (max-width: 639px) {
  .lesson-tabs > div {
    flex-wrap: wrap;
    align-content: center;
    letter-spacing: .06em;
    overflow-wrap: anywhere;
  }
}

/*
 * Staff editing tools on student pages (study-day, lesson text and library
 * editors) have their own light palette. Keep their drawers, dialogs and menus
 * light: resetting the theme variables makes every remap inside them fall back
 * to its light value, so nothing ends up half-dark.
 */
:is([data-appearance="dark"], [data-appearance="parchment"]) :is(.sde-drawer, .sde-confirm, .lte-drawer, .lte-dialog, .lte-menu, .lie-dock, .lie-dialog, .lie-menu) {
  --study-page: #f9fafb;
  --study-surface: #ffffff;
  --study-raised: #f3f4f6;
  --study-line: #e5e7eb;
  --study-control: #71818c;
  --study-ink: #202020;
  --study-muted: #4a4f53;
  --study-link: #003b65;
  --study-link-raised: #003b65;
  --study-accent: #a3470e;
  --study-focus: #00608f;
  color-scheme: light;
  color: var(--study-ink);
}
/* The editors' "+ Add …" buttons sit on the page itself. */
[data-appearance="dark"] :is(.sde-ghost, .sde-ghost-btn) { color: var(--study-muted); border-color: var(--study-line); }
[data-appearance="dark"] .sde-ghost--lesson { background: transparent; }
[data-appearance="dark"] :is(.sde-ghost, .sde-ghost-btn):is(:hover, :focus-visible) { color: var(--study-link); }
