@import url("visuals.css");
/* COSYmanuals Components UI Styles */

/* Header & Branding */
header.manual-header {
  background: var(--cosy-color-surface, #ffffff);
  border-bottom: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  padding: var(--cosy-space-md, 16px) 0;
  margin-bottom: var(--cosy-space-xl, 32px);
}

.header-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--cosy-space-md, 16px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-badge, .brand-badge, .cosy-badge, .topbar-brand {
  font-weight: var(--cosy-font-weight-extrabold, 800);
  font-size: var(--cosy-font-size-xl, 1.25rem);
  color: var(--cosy-manuals-accent, #6b202b) !important;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--cosy-space-sm, 8px);
}

.private-tag, .badge-cosy, .topbar-badge {
  background: var(--cosy-manuals-accent-light, #f9edf0) !important;
  color: var(--cosy-manuals-accent, #6b202b) !important;
  border: 1px solid var(--cosy-manuals-accent-border, rgba(107, 32, 43, 0.22)) !important;
  font-size: var(--cosy-font-size-xs, 0.75rem);
  font-weight: var(--cosy-font-weight-bold, 700);
  padding: 0.2rem 0.6rem;
  border-radius: var(--cosy-radius-full, 100px);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Sticky Header & Jump Links / Navigation Pills */
.sd-sticky-header, .topbar, .nav-bar, .top-nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--cosy-color-surface, #ffffff);
  border-bottom: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  box-shadow: var(--cosy-shadow-sm, 0 2px 12px rgba(46, 74, 51, 0.07));
}

.sd-header-inner, .topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--cosy-space-sm, 8px) var(--cosy-space-md, 16px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sd-jump-links, .topbar-nav, .nav-pills {
  display: flex;
  gap: var(--cosy-space-sm, 8px);
  overflow-x: auto;
  white-space: nowrap;
  max-width: 1100px;
  margin: 0 auto;
}

.sd-jump-link, .topbar-nav a, .nav-pill, .topbar-pill {
  color: var(--cosy-color-ink-soft, #4a4a4a);
  text-decoration: none;
  font-weight: var(--cosy-font-weight-bold, 700);
  font-size: var(--cosy-font-size-sm, 0.875rem);
  padding: 0.35rem 0.75rem;
  border-radius: var(--cosy-radius-sm, 8px);
  background: var(--cosy-manuals-accent-light, #f9edf0) !important;
  border: 1px solid var(--cosy-manuals-accent-border, rgba(107, 32, 43, 0.22)) !important;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sd-jump-link:hover, .sd-jump-link.active, .topbar-nav a:hover, .topbar-nav a.active, .nav-pill:hover, .nav-pill.active, .topbar-pill:hover, .topbar-pill.active {
  background: var(--cosy-manuals-accent-fill, #6b202b) !important;
  color: #ffffff !important;
  border-color: var(--cosy-manuals-accent-fill, #6b202b) !important;
}

/* Hero Header Contrast Overrides */
.hero h1, .hero .lead, .hero p {
  color: inherit;
}

.hero h1 {
  text-shadow: none;
}

.hero {
  --teal-500: #8fd6c4;
}

/* Page Headings & Titles */
.page-head {
  margin-bottom: var(--cosy-space-lg, 24px);
}

.eyebrow {
  font-size: var(--cosy-font-size-xs, 0.75rem);
  text-transform: uppercase;
  color: var(--cosy-manuals-accent, #6b202b);
  letter-spacing: 0.05em;
  font-weight: var(--cosy-font-weight-extrabold, 800);
}

.subtitle {
  color: var(--cosy-color-ink-faint, #5c5957);
  font-size: var(--cosy-font-size-base, 1rem);
  margin-top: var(--cosy-space-xs, 4px);
}

/* Cards & Section Boxes */
.marathon-card, .section-card, .notice-card, .confusion-card, .phase-box, .stage-box, .part-card, .topic-card {
  background: var(--cosy-color-surface, #ffffff);
  border: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  border-radius: var(--cosy-radius-md, 14px);
  padding: var(--cosy-space-lg, 24px);
  box-shadow: var(--cosy-shadow-sm, 0 2px 12px rgba(46, 74, 51, 0.07));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease;
  position: relative;
  overflow: hidden;
}

.marathon-card:hover, .confusion-card:hover, .phase-box:hover, .part-card:hover, .topic-card:hover {
  transform: translateY(-3px) scale(1.003);
  box-shadow: var(--cosy-shadow-base, 0 6px 28px rgba(46, 74, 51, 0.10));
  border-color: var(--cosy-manuals-accent, #6b202b);
}

.topic-card .ttl {
  margin: 4px 0 8px;
  font-size: var(--cosy-font-size-lg, 1.125rem);
  font-weight: var(--cosy-font-weight-bold, 700);
}

.topic-card .sub {
  font-size: var(--cosy-font-size-sm, 0.875rem);
  color: var(--cosy-color-ink-faint, #5c5957);
  margin: 0;
}

.tnum {
  font-size: var(--cosy-font-size-xs, 0.75rem);
  font-weight: var(--cosy-font-weight-bold, 700);
  text-transform: uppercase;
  color: var(--cosy-manuals-accent, #6b202b);
  letter-spacing: 0.05em;
}

.stripe {
  height: 4px;
  border-radius: var(--cosy-radius-xs, 4px);
  margin-bottom: 12px;
  background: var(--cosy-manuals-accent, #6b202b);
}

/* CELTA Stages & Rule Cards */
.celta-stage {
  background: var(--cosy-color-surface, #ffffff);
  border-radius: var(--cosy-radius-md, 14px);
  border: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  padding: var(--cosy-space-lg, 24px);
  margin-bottom: var(--cosy-space-xl, 32px);
  box-shadow: var(--cosy-shadow-sm, 0 2px 12px rgba(46, 74, 51, 0.07));
}

.stage-badge, .stage-tag {
  background: var(--cosy-manuals-accent-light, #f9edf0);
  color: var(--cosy-manuals-accent, #6b202b);
  border: 1px solid var(--cosy-manuals-accent-border, rgba(107, 32, 43, 0.22));
  font-weight: var(--cosy-font-weight-extrabold, 800);
  font-size: var(--cosy-font-size-xs, 0.75rem);
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: var(--cosy-radius-full, 100px);
  display: inline-block;
  margin-bottom: var(--cosy-space-sm, 8px);
}

.rule-card, .rule-box {
  background: var(--cosy-color-cream, #fdfcf8);
  border-left: 4px solid var(--cosy-manuals-accent, #6b202b);
  border-radius: var(--cosy-radius-sm, 8px);
  padding: var(--cosy-space-md, 16px);
  margin: var(--cosy-space-md, 16px) 0;
}

.hint-box, .hint {
  background: var(--cosy-color-honey-pale, #fff8e7);
  border-left: 4px solid var(--cosy-color-honey, #945e05);
  padding: var(--cosy-space-md, 16px);
  border-radius: var(--cosy-radius-sm, 8px);
  margin: var(--cosy-space-md, 16px) 0;
}

/* Flashcards & Checklists */
.flashcard {
  background: var(--cosy-color-surface, #ffffff);
  border: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  border-radius: var(--cosy-radius-md, 14px);
  padding: var(--cosy-space-md, 16px);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.flashcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--cosy-shadow-sm, 0 2px 12px rgba(46, 74, 51, 0.07));
}

.flashcard .word {
  font-size: var(--cosy-font-size-xl, 1.25rem);
  font-weight: var(--cosy-font-weight-bold, 700);
  color: var(--cosy-manuals-accent, #6b202b);
}

.flashcard .definition {
  display: none;
  margin-top: 8px;
  font-size: var(--cosy-font-size-base, 1rem);
  color: var(--cosy-color-ink, #2a2a2a);
}

.flashcard .example {
  display: none;
  margin-top: 6px;
  font-size: var(--cosy-font-size-sm, 0.875rem);
  color: var(--cosy-color-ink-faint, #5c5957);
  font-style: italic;
}

.flashcard.flipped .definition, .flashcard.flipped .example {
  display: block;
}

.checklist {
  background: var(--cosy-color-surface, #ffffff);
  border: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  border-radius: var(--cosy-radius-sm, 8px);
  padding: var(--cosy-space-md, 16px);
  margin: var(--cosy-space-md, 16px) 0;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  cursor: pointer;
}

/* Quizzes & Practice Panels */
.quiz-panel {
  background: var(--cosy-color-surface, #ffffff);
  border: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  border-radius: var(--cosy-radius-sm, 8px);
  padding: var(--cosy-space-md, 16px);
  margin: var(--cosy-space-md, 16px) 0;
}

.qitem {
  margin: 16px 0;
}

.qopts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cosy-space-sm, 8px);
  margin-top: 8px;
}

.qopt {
  color: inherit;
  background: var(--cosy-color-cream, #fdfcf8);
  border: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  border-radius: var(--cosy-radius-xs, 4px);
  padding: 8px 14px;
  cursor: pointer;
  font-size: var(--cosy-font-size-sm, 0.875rem);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.qopt.correct {
  background: var(--cosy-semantic-success-light, #e5f4ec);
  border-color: var(--cosy-semantic-success, #416b49);
  color: var(--cosy-semantic-success, #416b49);
  font-weight: var(--cosy-font-weight-bold, 700);
}

.qopt.wrong {
  background: var(--cosy-semantic-error-light, #fcebeb);
  border-color: var(--cosy-semantic-error, #a32d2d);
  color: var(--cosy-semantic-error, #a32d2d);
}

.qexplain {
  display: none;
  margin-top: 6px;
  font-size: var(--cosy-font-size-sm, 0.875rem);
  color: var(--cosy-color-ink-faint, #5c5957);
}

.qexplain.show {
  display: block;
}

.pager {
  display: flex;
  justify-content: space-between;
  margin-top: var(--cosy-space-xl, 32px);
  padding-top: var(--cosy-space-md, 16px);
  border-top: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
}

.pager a {
  text-decoration: none;
  color: var(--cosy-manuals-accent, #6b202b);
  font-weight: var(--cosy-font-weight-bold, 700);
}

/* Badges & Buttons */
.badge-cefr {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: var(--cosy-radius-full, 100px);
  font-size: var(--cosy-font-size-xs, 0.75rem);
  font-weight: var(--cosy-font-weight-extrabold, 800);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.level-pill-a0a1 { background: #e0f2fe; color: #0369a1; }
.level-pill-a2 { background: #dcfce7; color: #15803d; }
.level-pill-b1b2 { background: #fef3c7; color: #b45309; }
.level-pill-c1c2 { background: #f3e8ff; color: #6b21a8; }

.badge-lang {
  font-size: var(--cosy-font-size-xs, 0.75rem);
  font-weight: var(--cosy-font-weight-bold, 700);
  color: var(--cosy-color-ink-soft, #4a4a4a);
  background: var(--cosy-color-cream-dark, #f5ede0);
  padding: 0.2rem 0.5rem;
  border-radius: var(--cosy-radius-xs, 4px);
}

.marathon-card-link, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-primary-bg, var(--cosy-manuals-accent, #6b202b));
  color: #ffffff;
  padding: 0.65rem 1.25rem;
  border-radius: var(--cosy-radius-full, 100px);
  text-decoration: none;
  font-weight: var(--cosy-font-weight-extrabold, 800);
  font-size: var(--cosy-font-size-sm, 0.875rem);
  box-shadow: 0 4px 14px rgba(107, 32, 43, 0.18);
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.marathon-card-link:hover, .btn:hover {
  background: var(--btn-primary-hover-bg, var(--cosy-manuals-accent-hover, #521821));
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(107, 32, 43, 0.28);
  color: #ffffff;
  text-decoration: none;
}

/* Practice Footer Links Component */
.practice-links {
  background: var(--cosy-color-sage-deep, #233827);
  color: #ffffff;
  padding: var(--cosy-space-xl, 32px) var(--cosy-space-lg, 24px);
  border-radius: var(--cosy-radius-md, 14px);
  margin-top: var(--cosy-space-xxl, 48px);
  text-align: center;
}

.practice-links h4 {
  font-size: var(--cosy-font-size-xl, 1.25rem);
  margin-bottom: var(--cosy-space-md, 16px);
  color: #ffffff;
}

.practice-links-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--cosy-space-md, 16px);
}

.practice-links a {
  display: inline-flex;
  align-items: center;
  gap: var(--cosy-space-sm, 8px);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: var(--cosy-radius-sm, 8px);
  text-decoration: none;
  font-weight: var(--cosy-font-weight-semibold, 600);
  transition: background 0.2s ease, transform 0.15s ease;
}

.practice-links a:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  color: #ffffff;
  text-decoration: none;
}

footer.main-footer, footer.site {
  text-align: center;
  padding: var(--cosy-space-md, 16px);
  font-size: var(--cosy-font-size-sm, 0.875rem);
  color: inherit;
  border-top: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  margin-top: auto;
}

/* Lesson Teacher Notes Components */
.lesson-code-badge {
  background: var(--cosy-manuals-accent-light, #f9edf0);
  color: var(--cosy-manuals-accent, #6b202b);
  border: 1px solid var(--cosy-manuals-accent-border, rgba(107, 32, 43, 0.22));
  font-size: var(--cosy-font-size-xs, 0.75rem);
  font-weight: var(--cosy-font-weight-extrabold, 800);
  padding: 0.15rem 0.5rem;
  border-radius: var(--cosy-radius-full, 100px);
  margin-left: var(--cosy-space-sm, 8px);
  display: inline-block;
  vertical-align: middle;
}

.lesson-cando {
  background: var(--cosy-semantic-success-light, #e5f4ec);
  border-left: 3px solid var(--cosy-semantic-success, #416b49);
  color: var(--cosy-color-ink, #2a2a2a);
  padding: var(--cosy-space-sm, 8px) var(--cosy-space-md, 12px);
  margin-top: var(--cosy-space-sm, 8px);
  border-radius: var(--cosy-radius-xs, 4px);
  font-size: var(--cosy-font-size-sm, 0.875rem);
}

.lesson-pronunciation {
  background: var(--cosy-color-surface, #ffffff);
  border: 1px solid var(--cosy-color-border, rgba(74, 107, 80, 0.12));
  border-radius: var(--cosy-radius-sm, 8px);
  padding: var(--cosy-space-md, 12px);
  margin-top: var(--cosy-space-sm, 8px);
}

.lesson-pronunciation-item {
  margin-bottom: var(--cosy-space-sm, 8px);
}

.lesson-pronunciation-item:last-child {
  margin-bottom: 0;
}

.lesson-pronunciation-point {
  font-weight: var(--cosy-font-weight-bold, 700);
  color: var(--cosy-color-ink, #2a2a2a);
  font-size: var(--cosy-font-size-sm, 0.875rem);
}

.lesson-pronunciation-explain {
  color: var(--cosy-color-ink-soft, #4a4a4a);
  font-size: var(--cosy-font-size-sm, 0.875rem);
  margin: 2px 0 6px;
}

.lesson-pronunciation-examples {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cosy-space-xs, 6px);
  margin-top: var(--cosy-space-xs, 4px);
}

.lesson-pronunciation-example {
  background: var(--cosy-color-cream-dark, #f5ede0);
  color: var(--cosy-color-ink, #2a2a2a);
  padding: 2px 8px;
  border-radius: var(--cosy-radius-xs, 4px);
  font-size: var(--cosy-font-size-xs, 0.75rem);
  font-family: var(--cosy-font-mono, monospace);
}

.lesson-notes-extra {
  background: var(--cosy-color-cream, #fdfcf8);
  border-left: 3px solid var(--cosy-color-border, rgba(74, 107, 80, 0.25));
  padding: var(--cosy-space-sm, 8px) var(--cosy-space-md, 12px);
  margin-top: var(--cosy-space-sm, 8px);
  font-size: var(--cosy-font-size-sm, 0.875rem);
  color: var(--cosy-color-ink-soft, #4a4a4a);
  border-radius: var(--cosy-radius-xs, 4px);
}

/* ── Contrast fixes: diagram chips ────────────────────────────────────── */
.branch .box2 { color: #ffffff !important; }
.branch .box2[style*="1c9483"],
.branch .box2[style*="c9740a"],
.branch .box2[style*="1c8f56"] { color: #0d1f1a !important; }
/* Practice CTA painted 4.1:1 under white text; deepen the fill */
a[style*="background:#1c8f56"], a[style*="background: #1c8f56"],
.btn-practice-link[style*="1c8f56"] { background: #177a49 !important; }

/* Footer ink follows whatever surface the manual paints behind it */
footer.site a, footer.main-footer a { color: inherit !important; text-decoration: underline; }
/* Green used as text on white needs the darker step */
[style*="color:#1c8f56"], [style*="color: #1c8f56"] { color: #177a49 !important; }
/* ...but an element that paints the green behind itself needs white ink */
:root [style*="background:#1c8f56"], :root [style*="background: #1c8f56"],
:root [style*="background:#177a49"], :root [style*="background: #177a49"] {
  background: #177a49 !important; color: #ffffff !important;
}
:root [style*="background:#1c8f56"] *,
:root [style*="background:#177a49"] * { color: #ffffff !important; }

/* Site footers are the brand navy bar: one surface, one ink */
footer.site, footer.main-footer {
  background: var(--teal-900, #11263d) !important;
  color: rgba(255, 255, 255, 0.86) !important;
}
footer.site a, footer.main-footer a { color: #bcd6ee !important; }
main.container footer { color: #4a5568 !important; }
.mistakes .mflip .hint, .mistakes .mflip .hint * { color: #9c4a4a !important; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {

  /* Content pages carry literal light fills in inline styles and one-off
     rules; under the dark palette those blocks would stay light behind
     light text. Only elements whose author hard-coded a background are
     re-pointed at theme surfaces, so intentional tints keep their hue. */
  table th[style*="background"],
  table td[style*="background"],
  tbody tr[style*="background"] {
    background: color-mix(in srgb, var(--cosy-color-ink) 8%, var(--cosy-color-surface)) !important;
    color: var(--cosy-color-ink) !important;
    border-color: var(--cosy-color-border) !important;
  }
  .mflip[style*="background"],
  .mistakes p[style*="background"] {
    background: color-mix(in srgb, #e53e3e 16%, var(--cosy-color-surface)) !important;
    color: var(--cosy-color-ink) !important;
  }
  .box[style*="background"],
  .callout[style*="background"],
  .note[style*="background"] {
    background: color-mix(in srgb, var(--cosy-color-ink) 6%, var(--cosy-color-surface)) !important;
    color: var(--cosy-color-ink) !important;
  }
  .eyebrow[style*="background"],
  .hint[style*="background"],
  .quiz-head[style*="background"],
  .theme-pill[style*="background"],
  .pnum[style*="background"] {
    background: color-mix(in srgb, var(--cosy-color-ink) 10%, var(--cosy-color-surface)) !important;
    color: var(--cosy-color-ink-soft) !important;
  }
  .notice-card .btn[style*="background"] {
    background: var(--cosy-color-surface) !important;
    color: var(--cosy-color-ink) !important;
  }
  
  }
}
html[data-theme="dark"], body.theme-dark {
/* Content pages carry literal light fills in inline styles and one-off
   rules; under the dark palette those blocks would stay light behind
   light text. Only elements whose author hard-coded a background are
   re-pointed at theme surfaces, so intentional tints keep their hue. */
table th[style*="background"],
table td[style*="background"],
tbody tr[style*="background"] {
  background: color-mix(in srgb, var(--cosy-color-ink) 8%, var(--cosy-color-surface)) !important;
  color: var(--cosy-color-ink) !important;
  border-color: var(--cosy-color-border) !important;
}
.mflip[style*="background"],
.mistakes p[style*="background"] {
  background: color-mix(in srgb, #e53e3e 16%, var(--cosy-color-surface)) !important;
  color: var(--cosy-color-ink) !important;
}
.box[style*="background"],
.callout[style*="background"],
.note[style*="background"] {
  background: color-mix(in srgb, var(--cosy-color-ink) 6%, var(--cosy-color-surface)) !important;
  color: var(--cosy-color-ink) !important;
}
.eyebrow[style*="background"],
.hint[style*="background"],
.quiz-head[style*="background"],
.theme-pill[style*="background"],
.pnum[style*="background"] {
  background: color-mix(in srgb, var(--cosy-color-ink) 10%, var(--cosy-color-surface)) !important;
  color: var(--cosy-color-ink-soft) !important;
}
.notice-card .btn[style*="background"] {
  background: var(--cosy-color-surface) !important;
  color: var(--cosy-color-ink) !important;
}
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {

  [style*="color:#0f172a"], [style*="color: #0f172a"],
  [style*="color:#132321"], [style*="color: #132321"],
  [style*="color:#1e293b"], [style*="color: #1e293b"],
  [style*="color:#1a365d"], [style*="color: #1a365d"] { color: var(--cosy-color-ink) !important; }

  [style*="color:#475569"], [style*="color: #475569"],
  [style*="color:#64748b"], [style*="color: #64748b"],
  [style*="color:#94a3b8"], [style*="color: #94a3b8"] { color: var(--cosy-color-ink-soft) !important; }

  [style*="color:#1c8f56"], [style*="color: #1c8f56"] { color: color-mix(in srgb, #1c8f56 45%, #ffffff) !important; }
  [style*="color:#2563eb"], [style*="color: #2563eb"] { color: color-mix(in srgb, #2563eb 45%, #ffffff) !important; }
  [style*="color:#4f46e5"], [style*="color: #4f46e5"] { color: color-mix(in srgb, #4f46e5 45%, #ffffff) !important; }

  [style*="background:#f1f5f9"], [style*="background: #f1f5f9"],
  [style*="background:#f8fafc"], [style*="background: #f8fafc"],
  [style*="background:#f7fafc"], [style*="background: #f7fafc"],
  [style*="background:#eef0f1"], [style*="background: #eef0f1"] {
    background: color-mix(in srgb, var(--cosy-color-ink) 8%, var(--cosy-color-surface)) !important;
  }

  [style*="background:#ffffff"], [style*="background: #ffffff"],
  [style*="background:#fff"], [style*="background: #fff"],
  [style*="background:white"] { background: var(--cosy-color-surface) !important; }

  [style*="background:#fff3f3"], [style*="background: #fff3f3"] {
    background: color-mix(in srgb, #e53e3e 16%, var(--cosy-color-surface)) !important;
  }
  [style*="background:#fff8e1"], [style*="background: #fff8e1"] {
    background: color-mix(in srgb, #f0b429 16%, var(--cosy-color-surface)) !important;
  }
  [style*="background:#ebf8ff"], [style*="background: #ebf8ff"] {
    background: color-mix(in srgb, #2563eb 16%, var(--cosy-color-surface)) !important;
  }
  [style*="background:#e8f5e9"], [style*="background: #e8f5e9"] {
    background: color-mix(in srgb, #1c8f56 16%, var(--cosy-color-surface)) !important;
  }


  }
}
html[data-theme="dark"], body.theme-dark {

  [style*="color:#0f172a"], [style*="color: #0f172a"],
  [style*="color:#132321"], [style*="color: #132321"],
  [style*="color:#1e293b"], [style*="color: #1e293b"],
  [style*="color:#1a365d"], [style*="color: #1a365d"] { color: var(--cosy-color-ink) !important; }

  [style*="color:#475569"], [style*="color: #475569"],
  [style*="color:#64748b"], [style*="color: #64748b"],
  [style*="color:#94a3b8"], [style*="color: #94a3b8"] { color: var(--cosy-color-ink-soft) !important; }

  [style*="color:#1c8f56"], [style*="color: #1c8f56"] { color: color-mix(in srgb, #1c8f56 45%, #ffffff) !important; }
  [style*="color:#2563eb"], [style*="color: #2563eb"] { color: color-mix(in srgb, #2563eb 45%, #ffffff) !important; }
  [style*="color:#4f46e5"], [style*="color: #4f46e5"] { color: color-mix(in srgb, #4f46e5 45%, #ffffff) !important; }

  [style*="background:#f1f5f9"], [style*="background: #f1f5f9"],
  [style*="background:#f8fafc"], [style*="background: #f8fafc"],
  [style*="background:#f7fafc"], [style*="background: #f7fafc"],
  [style*="background:#eef0f1"], [style*="background: #eef0f1"] {
    background: color-mix(in srgb, var(--cosy-color-ink) 8%, var(--cosy-color-surface)) !important;
  }

  [style*="background:#ffffff"], [style*="background: #ffffff"],
  [style*="background:#fff"], [style*="background: #fff"],
  [style*="background:white"] { background: var(--cosy-color-surface) !important; }

  [style*="background:#fff3f3"], [style*="background: #fff3f3"] {
    background: color-mix(in srgb, #e53e3e 16%, var(--cosy-color-surface)) !important;
  }
  [style*="background:#fff8e1"], [style*="background: #fff8e1"] {
    background: color-mix(in srgb, #f0b429 16%, var(--cosy-color-surface)) !important;
  }
  [style*="background:#ebf8ff"], [style*="background: #ebf8ff"] {
    background: color-mix(in srgb, #2563eb 16%, var(--cosy-color-surface)) !important;
  }
  [style*="background:#e8f5e9"], [style*="background: #e8f5e9"] {
    background: color-mix(in srgb, #1c8f56 16%, var(--cosy-color-surface)) !important;
  }


}

/* Inline colours: lesson pages hard-code a light palette */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  [style*="color:#0f172a" i], [style*="color: #0f172a" i], [style*="color:#132321" i], [style*="color: #132321" i], [style*="color:#1e293b" i], [style*="color: #1e293b" i], [style*="color:#1a365d" i], [style*="color: #1a365d" i], [style*="color:#111827" i], [style*="color: #111827" i], [style*="color:#0b1f17" i], [style*="color: #0b1f17" i] { color: var(--cosy-color-ink) !important; }

  [style*="color:#475569" i], [style*="color: #475569" i], [style*="color:#64748b" i], [style*="color: #64748b" i], [style*="color:#94a3b8" i], [style*="color: #94a3b8" i], [style*="color:#4a5568" i], [style*="color: #4a5568" i], [style*="color:#6b7280" i], [style*="color: #6b7280" i] { color: var(--cosy-color-ink-soft) !important; }

  [style*="color:#1c8f56" i], [style*="color: #1c8f56" i] { color: color-mix(in srgb, #1c8f56 45%, #ffffff) !important; }
  [style*="color:#2563eb" i], [style*="color: #2563eb" i] { color: color-mix(in srgb, #2563eb 45%, #ffffff) !important; }
  [style*="color:#4f46e5" i], [style*="color: #4f46e5" i] { color: color-mix(in srgb, #4f46e5 45%, #ffffff) !important; }
  [style*="color:#2d6a4f" i], [style*="color: #2d6a4f" i] { color: color-mix(in srgb, #2d6a4f 45%, #ffffff) !important; }
  [style*="color:#2b6cb0" i], [style*="color: #2b6cb0" i] { color: color-mix(in srgb, #2b6cb0 45%, #ffffff) !important; }
  [style*="color:#3562e0" i], [style*="color: #3562e0" i] { color: color-mix(in srgb, #3562e0 45%, #ffffff) !important; }
  [style*="color:#c9740a" i], [style*="color: #c9740a" i] { color: color-mix(in srgb, #c9740a 45%, #ffffff) !important; }

  [style*="background:#ffffff" i], [style*="background: #ffffff" i], [style*="background-color:#ffffff" i], [style*="background-color: #ffffff" i] { background: var(--cosy-color-surface) !important; }
  [style*="background:#fff" i], [style*="background: #fff" i], [style*="background-color:#fff" i], [style*="background-color: #fff" i] { background: var(--cosy-color-surface) !important; }

  [style*="background:#f1f5f9" i], [style*="background: #f1f5f9" i], [style*="background-color:#f1f5f9" i], [style*="background-color: #f1f5f9" i] { background: color-mix(in srgb, #f1f5f9 8%, var(--cosy-color-surface)) !important; }
  [style*="background:#f8fafc" i], [style*="background: #f8fafc" i], [style*="background-color:#f8fafc" i], [style*="background-color: #f8fafc" i] { background: color-mix(in srgb, #f8fafc 8%, var(--cosy-color-surface)) !important; }
  [style*="background:#f7fafc" i], [style*="background: #f7fafc" i], [style*="background-color:#f7fafc" i], [style*="background-color: #f7fafc" i] { background: color-mix(in srgb, #f7fafc 8%, var(--cosy-color-surface)) !important; }
  [style*="background:#eef0f1" i], [style*="background: #eef0f1" i], [style*="background-color:#eef0f1" i], [style*="background-color: #eef0f1" i] { background: color-mix(in srgb, #eef0f1 8%, var(--cosy-color-surface)) !important; }
  [style*="background:#f5f6fa" i], [style*="background: #f5f6fa" i], [style*="background-color:#f5f6fa" i], [style*="background-color: #f5f6fa" i] { background: color-mix(in srgb, #f5f6fa 8%, var(--cosy-color-surface)) !important; }
  [style*="background:#e6f0fa" i], [style*="background: #e6f0fa" i], [style*="background-color:#e6f0fa" i], [style*="background-color: #e6f0fa" i] { background: color-mix(in srgb, #e6f0fa 8%, var(--cosy-color-surface)) !important; }
  [style*="background:#fff3f3" i], [style*="background: #fff3f3" i], [style*="background-color:#fff3f3" i], [style*="background-color: #fff3f3" i] { background: color-mix(in srgb, #fff3f3 16%, var(--cosy-color-surface)) !important; }
  [style*="background:#fff8e1" i], [style*="background: #fff8e1" i], [style*="background-color:#fff8e1" i], [style*="background-color: #fff8e1" i] { background: color-mix(in srgb, #fff8e1 16%, var(--cosy-color-surface)) !important; }
  [style*="background:#ebf8ff" i], [style*="background: #ebf8ff" i], [style*="background-color:#ebf8ff" i], [style*="background-color: #ebf8ff" i] { background: color-mix(in srgb, #ebf8ff 16%, var(--cosy-color-surface)) !important; }
  [style*="background:#e8f5e9" i], [style*="background: #e8f5e9" i], [style*="background-color:#e8f5e9" i], [style*="background-color: #e8f5e9" i] { background: color-mix(in srgb, #e8f5e9 16%, var(--cosy-color-surface)) !important; }
  }
}
html[data-theme="dark"], body.theme-dark {
/* Inline colours: lesson pages hard-code a light palette (21k uses of
   #0f172a on #f1f5f9), which turns into dark-on-dark text once the page
   palette flips. Re-point the recurring literals at theme tokens. */
[style*="color:#0f172a" i], [style*="color: #0f172a" i], [style*="color:#132321" i], [style*="color: #132321" i], [style*="color:#1e293b" i], [style*="color: #1e293b" i], [style*="color:#1a365d" i], [style*="color: #1a365d" i], [style*="color:#111827" i], [style*="color: #111827" i], [style*="color:#0b1f17" i], [style*="color: #0b1f17" i] { color: var(--cosy-color-ink) !important; }

[style*="color:#475569" i], [style*="color: #475569" i], [style*="color:#64748b" i], [style*="color: #64748b" i], [style*="color:#94a3b8" i], [style*="color: #94a3b8" i], [style*="color:#4a5568" i], [style*="color: #4a5568" i], [style*="color:#6b7280" i], [style*="color: #6b7280" i] { color: var(--cosy-color-ink-soft) !important; }

[style*="color:#1c8f56" i], [style*="color: #1c8f56" i] { color: color-mix(in srgb, #1c8f56 45%, #ffffff) !important; }
[style*="color:#2563eb" i], [style*="color: #2563eb" i] { color: color-mix(in srgb, #2563eb 45%, #ffffff) !important; }
[style*="color:#4f46e5" i], [style*="color: #4f46e5" i] { color: color-mix(in srgb, #4f46e5 45%, #ffffff) !important; }
[style*="color:#2d6a4f" i], [style*="color: #2d6a4f" i] { color: color-mix(in srgb, #2d6a4f 45%, #ffffff) !important; }
[style*="color:#2b6cb0" i], [style*="color: #2b6cb0" i] { color: color-mix(in srgb, #2b6cb0 45%, #ffffff) !important; }
[style*="color:#3562e0" i], [style*="color: #3562e0" i] { color: color-mix(in srgb, #3562e0 45%, #ffffff) !important; }
[style*="color:#c9740a" i], [style*="color: #c9740a" i] { color: color-mix(in srgb, #c9740a 45%, #ffffff) !important; }

[style*="background:#ffffff" i], [style*="background: #ffffff" i], [style*="background-color:#ffffff" i], [style*="background-color: #ffffff" i] { background: var(--cosy-color-surface) !important; }
[style*="background:#fff" i], [style*="background: #fff" i], [style*="background-color:#fff" i], [style*="background-color: #fff" i] { background: var(--cosy-color-surface) !important; }

[style*="background:#f1f5f9" i], [style*="background: #f1f5f9" i], [style*="background-color:#f1f5f9" i], [style*="background-color: #f1f5f9" i] { background: color-mix(in srgb, #f1f5f9 8%, var(--cosy-color-surface)) !important; }
[style*="background:#f8fafc" i], [style*="background: #f8fafc" i], [style*="background-color:#f8fafc" i], [style*="background-color: #f8fafc" i] { background: color-mix(in srgb, #f8fafc 8%, var(--cosy-color-surface)) !important; }
[style*="background:#f7fafc" i], [style*="background: #f7fafc" i], [style*="background-color:#f7fafc" i], [style*="background-color: #f7fafc" i] { background: color-mix(in srgb, #f7fafc 8%, var(--cosy-color-surface)) !important; }
[style*="background:#eef0f1" i], [style*="background: #eef0f1" i], [style*="background-color:#eef0f1" i], [style*="background-color: #eef0f1" i] { background: color-mix(in srgb, #eef0f1 8%, var(--cosy-color-surface)) !important; }
[style*="background:#f5f6fa" i], [style*="background: #f5f6fa" i], [style*="background-color:#f5f6fa" i], [style*="background-color: #f5f6fa" i] { background: color-mix(in srgb, #f5f6fa 8%, var(--cosy-color-surface)) !important; }
[style*="background:#e6f0fa" i], [style*="background: #e6f0fa" i], [style*="background-color:#e6f0fa" i], [style*="background-color: #e6f0fa" i] { background: color-mix(in srgb, #e6f0fa 8%, var(--cosy-color-surface)) !important; }
[style*="background:#fff3f3" i], [style*="background: #fff3f3" i], [style*="background-color:#fff3f3" i], [style*="background-color: #fff3f3" i] { background: color-mix(in srgb, #fff3f3 16%, var(--cosy-color-surface)) !important; }
[style*="background:#fff8e1" i], [style*="background: #fff8e1" i], [style*="background-color:#fff8e1" i], [style*="background-color: #fff8e1" i] { background: color-mix(in srgb, #fff8e1 16%, var(--cosy-color-surface)) !important; }
[style*="background:#ebf8ff" i], [style*="background: #ebf8ff" i], [style*="background-color:#ebf8ff" i], [style*="background-color: #ebf8ff" i] { background: color-mix(in srgb, #ebf8ff 16%, var(--cosy-color-surface)) !important; }
[style*="background:#e8f5e9" i], [style*="background: #e8f5e9" i], [style*="background-color:#e8f5e9" i], [style*="background-color: #e8f5e9" i] { background: color-mix(in srgb, #e8f5e9 16%, var(--cosy-color-surface)) !important; }
}

/* ── Dark-mode content panels ────────────────────────────────────────────
   The manual pages hard-code pastel panel fills per language level, so the
   shared dark palette never reaches them. Re-point the recurring families at
   theme surfaces; the tint hue is preserved as a faint wash. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(
    .box, .notice-box, .mindset-box, .memory-box, .connect-box, .conversation-map,
    .map-step, .building-blocks, .stage-box, .lesson-cando, .checklist,
    .check-item, .ccq-panel, .quiz-panel, .outcome-banner, .hero-builder,
    .rule-box, .box2, .box.why
  ) {
    background: color-mix(in srgb, var(--accent, #4a6b50) 10%, var(--cosy-color-surface, #222b22)) !important;
    border-color: var(--cosy-color-border, #3a463a) !important;
    color: var(--cosy-color-ink, #e8f0e9) !important;
  }

  :root:not([data-theme="light"]) :is(
    .box, .notice-box, .mindset-box, .memory-box, .connect-box, .conversation-map,
    .map-step, .building-blocks, .stage-box, .lesson-cando, .checklist,
    .ccq-panel, .quiz-panel, .outcome-banner, .hero-builder, .rule-box,
    .box2, .box.why
  ) :is(h1, h2, h3, h4, h5, p, li, span, strong, b, em, a, td, th, div) {
    color: var(--cosy-color-ink, #e8f0e9) !important;
  }

  :root:not([data-theme="light"]) :is(.page-head, .section-head) :is(h1, h2, h3) {
    color: var(--cosy-color-ink, #e8f0e9) !important;
  }

  :root:not([data-theme="light"]) .flash-face.back {
    background: color-mix(in srgb, var(--vocab-noun, #6b7fd0) 28%, #141a15) !important;
    color: #ffffff !important;
  }
  :root:not([data-theme="light"]) .print-btn {
    background: transparent !important;
    color: #e8f0e9 !important;
    border-color: #3a463a !important;
  }

  /* pastel label chips keep their fill in dark mode, so flatten them onto the
     panel surface and let the ink carry the contrast */
  :root:not([data-theme="light"]) :is(
    .chip, .chip-grid > span, .tag, .pill, .word-chip, .task-box,
    .hint-box, .note, table.mp-table > thead > th, table.mp-table thead th
  ) {
    background: color-mix(in srgb, var(--accent, #4a6b50) 16%, #1e241f) !important;
    color: #e8f0e9 !important;
    border-color: #3a463a !important;
  }

  /* print booklets colour corrections inline, so the literal has to be
     matched by attribute rather than by token */
  :root:not([data-theme="light"]) [style*="color:#107050"],
  :root:not([data-theme="light"]) [style*="color: #107050"] { color: #74d6ae !important; }
  :root:not([data-theme="light"]) [style*="color:#dc2626"],
  :root:not([data-theme="light"]) [style*="color: #dc2626"] { color: #f08f8f !important; }
  :root:not([data-theme="light"]) [style*="color:#16a34a"],
  :root:not([data-theme="light"]) [style*="color: #16a34a"] { color: #86d9a2 !important; }
  :root:not([data-theme="light"]) [style*="background:#f0f9f5"],
  :root:not([data-theme="light"]) [style*="background: #f0f9f5"] { background: #1e2a24 !important; }

  :root:not([data-theme="light"]) .mistakes .mflip span:not(.hint) {
    color: #e8a3a3 !important;
  }

  :root:not([data-theme="light"]) .booklet-actions :is(.btn, button, a) {
    background: var(--cosy-color-surface, #222b22) !important;
    color: var(--cosy-color-ink, #e8f0e9) !important;
    border-color: var(--cosy-color-border, #3a463a) !important;
  }
}

/* Light-mode counterpart: the print booklets put the semantic colours inline,
   where a 3.0:1 green and 4.4:1 red sit on the pink mistakes wash. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) [style*="color:#16a34a"],
  :root:not([data-theme="dark"]) [style*="color: #16a34a"] { color: #15803d !important; }
  :root:not([data-theme="dark"]) [style*="color:#dc2626"],
  :root:not([data-theme="dark"]) [style*="color: #dc2626"] { color: #b91c1c !important; }
}

:root[data-theme="light"] [style*="color:#16a34a"],
:root[data-theme="light"] [style*="color: #16a34a"] { color: #15803d !important; }
:root[data-theme="light"] [style*="color:#dc2626"],
:root[data-theme="light"] [style*="color: #dc2626"] { color: #b91c1c !important; }

/* ==========================================================================
   Exercises on paper. Nothing on a printed page can be tapped, so every
   interactive element has a paper form: options in a row (a, b, c), a score
   line, pen tick boxes, both lines of a mistake. The answer key is
   .print-key (language-neutral: letters and numbers only), generated by
   scripts/add_print_key.py.
   ========================================================================== */
.print-key { display: none; }
.celebration-msg { display: none; }
.celebration-msg.is-visible { display: block; }
.booklet-answer-toggle { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--cosy-color-muted, #5b5b5b); }
.booklet-note { font-size: 0.9rem; color: var(--cosy-color-muted, #5b5b5b); }
@media print { .booklet-answer-toggle { display: none !important; } }
@media print {
  /* a single page printed on its own does not load print.css: drop the web chrome here */
  html, body { background: #fff !important; color: #111 !important; }
  #cosy-nav, [data-ecosystem-strip], header.sd-sticky-header, .sd-jump-links, .practice-cta-banner, .btn-practice-link, footer.site { display: none !important; }
  .container { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .mflip .hint { display: none !important; }
  .mflip .wrong-line, .mflip .right-line { display: block !important; break-inside: avoid; }
  .mflip { break-inside: avoid; }

  .quiz-panel, .ccq-panel { display: flex !important; flex-direction: column; gap: 6pt; background: #fff !important;
    border: 1pt solid #000 !important; border-radius: 0 !important; padding: 8pt 10pt !important; margin: 10pt 0 !important; break-inside: avoid; }
  .quiz-score, .quiz-reset, .celebration-msg, .qexplain, .check-progress { display: none !important; }
  .qopts { display: flex !important; flex-wrap: wrap; gap: 2pt 16pt; counter-reset: opt; margin: 2pt 0 6pt; }
  .qopt { display: inline-block !important; counter-increment: opt; background: none !important; border: 0 !important;
    padding: 0 !important; margin: 0 !important; font: inherit !important; color: inherit !important; box-shadow: none !important; }
  .qopt::before { content: counter(opt, lower-alpha) ")\00a0"; font-weight: 700; }

  .checklist { display: block !important; background: #fff !important; border: 1pt solid #000 !important; padding: 8pt 10pt !important; margin: 10pt 0 !important; break-inside: avoid; }
  .checklist .check-item { display: flex !important; align-items: baseline; gap: 6pt; }
  .checklist input[type="checkbox"] { appearance: none; -webkit-appearance: none; flex: none; width: 9pt; height: 9pt; border: 1pt solid #000; background: #fff; margin: 0; }

  /* formula blocks (.gblock) are white text on a colour fill: on paper they become outlined boxes, with the role shown by line style so grey print still reads */
  .gblock { background: #fff !important; color: #000 !important; border: 1.5pt solid #000 !important; box-shadow: none !important; }
  .gblock .k, .gblock .v { color: #000 !important; opacity: 1 !important; }
  .gblock.verb { border-style: dashed !important; }
  .gblock.noun, .gblock.optional, .gblock.adj { border-style: dotted !important; }
  .gblock.ending { border-style: double !important; border-width: 3pt !important; }

  /* decision-tree boxes carry an inline colour fill: outline them, one line style per branch */
  .tree .box2 { background: #fff !important; color: #000 !important; border: 1.5pt solid #000 !important; padding: 2pt 6pt; }
  .tree .branch:nth-child(2) .box2 { border-style: dashed !important; }
  .tree .branch:nth-child(3) .box2 { border-style: dotted !important; }
  .tree .branch:nth-child(4) .box2 { border-style: double !important; border-width: 3pt !important; }
  .tree .branch { break-inside: avoid; margin-bottom: 4pt; }

  .print-key { order: 99; display: none !important; justify-content: space-between; align-items: flex-end; gap: 12pt; margin-top: 4pt; font-size: 9pt; }
  body.teacher-edition .print-key { display: flex !important; }
  .print-key .pk-ans { transform: rotate(180deg); color: #555; letter-spacing: .04em; }
}

/* Static breadcrumb fallback for the nav that used to be empty. */
#cosy-nav[aria-label="Breadcrumb"] {
  max-width: var(--cosy-content-max, 72rem);
  margin: 0 auto;
  padding: 0.55rem 1.25rem;
  font-size: 0.88rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb li {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  min-width: 0;
}

.breadcrumb li + li::before {
  content: "/";
  color: var(--cosy-color-ink-faint, #8a8580);
}

.breadcrumb a {
  color: var(--cosy-manuals-accent, #6b202b);
  text-decoration: none;
}

.breadcrumb a:hover,
.breadcrumb a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.breadcrumb [aria-current="page"] {
  color: var(--cosy-color-ink-soft, #5c5957);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 42ch;
}

@media (max-width: 560px) {
  #cosy-nav[aria-label="Breadcrumb"] {
    padding-inline: 0.9rem;
  }

  .breadcrumb [aria-current="page"] {
    max-width: 22ch;
  }
}
