/* Appearance is a device preference. All dark overrides are explicitly scoped. */
#themeToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line, #dce1d5);
  border-radius: 12px;
  background: var(--white, #fffefa);
  color: var(--ink, #20392f);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
#themeToggle:hover { border-color: #9180b9; }
#themeToggle svg { display: block; width: 21px; height: 21px; flex: 0 0 21px; }
#themeToggle:focus-visible, #themePreference:focus-visible {
  outline: 3px solid #8c72be;
  outline-offset: 3px;
}
#themePreference {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line, #cbd3c3);
  border-radius: 12px;
  background: var(--white, #fffefa);
  color: var(--ink, #20392f);
  font: inherit;
  font-size: 16px;
}
.brand-status {
  display: inline-block;
  width: max-content;
  padding: 3px 7px;
  border: 1px solid #d2c8e4;
  border-radius: 6px;
  background: #f0ebf7;
  color: #65507f;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: 0;
  white-space: nowrap;
}
.study-club > aside > .brand { position: relative; padding-bottom: 25px; }
.study-club > aside > .brand > .brand-status { position: absolute; left: 48px; bottom: 0; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111b19;
  --white: #182824;
  --ink: #e8eee4;
  --muted: #b3beb5;
  --line: #40544a;
  --lilac: #c5b5f2;
  --lime: #d9ef80;
  --coral: #ffb89c;
  --blue: #b3c7f0;
  --shadow: 4px 5px 0 #080f0c;
  --theme-raised: #21332d;
  --theme-tint-purple: #302b3e;
  --theme-tint-green: #27372b;
  --theme-tint-coral: #3c2c27;
  --theme-accent-ink: #18251b;
  --ab: #111b19;
  --aw: #182824;
  --ai: #e8eee4;
  --am: #b3beb5;
  --al: #40544a;
  --ag: #c6dda6;
  --ag-dark: #d9ef80;
  --ap: #d8c1ef;
  --ap-soft: #302b3e;
  --danger: #ffb89c;
  background: #111b19;
  color: #e8eee4;
  scrollbar-color: #647b6b #111b19;
}
:root[data-theme="dark"] body { background: var(--paper); color: var(--ink); }
:root[data-theme="dark"] ::selection { background: #6b568c; color: #fff8ff; }
:root[data-theme="dark"] :is(button, a, input, select, textarea, summary):focus-visible {
  outline-color: #c5b5f2;
}
:root[data-theme="dark"] :is(input, select, textarea) { accent-color: #c5b5f2; }
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #99aaa0; opacity: 1; }

/* Navigation, device controls and the compact home. */
:root[data-theme="dark"] .study-club > aside {
  background: #182824;
  border-color: var(--line);
}
:root[data-theme="dark"] .app > header {
  background: #111b19f2;
  border-bottom-color: #30483b;
}
:root[data-theme="dark"] :is(.brand, .mobile-brand, .breadcrumbs b) { color: var(--ink); }
:root[data-theme="dark"] :is(.brand-dot, .mobile-brand > span) { color: #c5b5f2; }
:root[data-theme="dark"] .logo { color: #18251b; border-color: #9cab77; box-shadow: 2px 2px 0 #080f0c; }
:root[data-theme="dark"] :is(.navlabel, .breadcrumbs, .today, .app > footer) { color: var(--muted); }
:root[data-theme="dark"] nav > a:hover { background: #24382f; }
:root[data-theme="dark"] nav > a.active {
  background: #38304b;
  color: #efe4ff;
  border-color: #8e7dac;
  box-shadow: 2px 3px 0 #080f0c;
}
:root[data-theme="dark"] nav b { background: #21332d; color: #d9ef80; }
:root[data-theme="dark"] :is(.sidebar-bottom, .academy-path-summary) {
  background: var(--theme-tint-green);
  border-color: #58734b;
}
:root[data-theme="dark"] .sidebar-bottom p { color: #c0ccb8; }
:root[data-theme="dark"] :is(.small-outline, .auth-link, .header-right select) { border-color: #526b5c; }
:root[data-theme="dark"] .avatar { color: #34231c; border-color: #a7826b; }
:root[data-theme="dark"] #cloudStatus {
  color: var(--ink) !important;
  border-color: var(--line) !important;
  background: var(--white) !important;
}
:root[data-theme="dark"] .header-right select { color: var(--ink); background: var(--white); }
:root[data-theme="dark"] .auth-link { background: #182824; color: #e8eee4; }
:root[data-theme="dark"] #themeToggle { border-color: #526b5c; background: #21332d; color: #f3dd9a; }
:root[data-theme="dark"] #themeToggle:hover { border-color: #c5b5f2; background: #2a3e35; }
:root[data-theme="dark"] .brand-status { border-color: #76628e; background: #302b3e; color: #e3d5f6; }
:root[data-theme="dark"] .calm-welcome .eyebrow { color: #c5b5f2; }
:root[data-theme="dark"] .calm-course { background: #302b3e; border-color: #70617f; }
:root[data-theme="dark"] .calm-course .pill { background: #473a58; color: #eee3ff; }
:root[data-theme="dark"] .calm-course-copy > p { color: #cbc3d6; }
:root[data-theme="dark"] .calm-course-art img { opacity: .88; }
:root[data-theme="dark"] .calm-category { background: var(--white); border-color: var(--line); }
:root[data-theme="dark"] .calm-category[href]:hover { background: #22372e; border-color: #849d7a; }
:root[data-theme="dark"] .calm-category-icon { background: #2b3d2f; color: #d2e6a0; }
:root[data-theme="dark"] .calm-category:nth-child(2) .calm-category-icon { background: #393047; color: #dfc9fc; }
:root[data-theme="dark"] .calm-category:nth-child(3) .calm-category-icon { background: #423628; color: #efd09d; }
:root[data-theme="dark"] .calm-category > b { color: #bfd0b8; }
:root[data-theme="dark"] .calm-progress-line > span + span::before { color: #a5b59c; }
:root[data-theme="dark"] .club-hero { background: #302b3e; color: #e8eee4; border-color: #80708e; }
:root[data-theme="dark"] .hero-tag { border-color: #a68bc7; }
:root[data-theme="dark"] .club-hero h2 em { background: #d9ef80; color: #18251b; }
:root[data-theme="dark"] .hero-footnote { color: #cbbbdc; }
:root[data-theme="dark"] .hero-start { background: #21332d; color: #e8eee4; border-color: #829a76; box-shadow: 2px 3px 0 #080f0c; }
:root[data-theme="dark"] .hero-start:hover { background: #d9ef80; color: #18251b; }
:root[data-theme="dark"] .club-greeting h1 > span { color: #c5b5f2; }
:root[data-theme="dark"] .club-greeting .eyebrow { color: #b3beb5; }
:root[data-theme="dark"] .streak-chip > span { color: #ffb89c; }
:root[data-theme="dark"] .header-avatar { color: #18251b; border-color: #9cab77; }

/* Buttons, form fields and status colors remain distinct in every activity. */
:root[data-theme="dark"] .primary {
  background: #d9ef80;
  color: #18251b;
  border-color: #b3c46f;
}
:root[data-theme="dark"] .primary:hover:not(:disabled) { background: #e4f69b; border-color: #d9ef80; }
:root[data-theme="dark"] .outline { background: #21332d; color: #e8eee4; border-color: #607562; }
:root[data-theme="dark"] .outline:hover:not(:disabled) { background: #2a4135; border-color: #a0b790; }
:root[data-theme="dark"] .pill { background: #2c3d30; color: #d6e7c1; }
:root[data-theme="dark"] .pill.purple { background: #3a304a; color: #e4d3fa; }
:root[data-theme="dark"] .audio { background: #293b2f; color: #d9ef80; border-color: #617453; }
:root[data-theme="dark"] .audio:hover { background: #d9ef80; color: #18251b; border-color: #d9ef80; }
:root[data-theme="dark"] :is(.toolbar input, .toolbar select, .fill-input,
  .academy-filterbar select, .academy-profile-form select, .academy-text-input,
  .academy-writing, .beta-dialog input, .beta-dialog select, .beta-dialog textarea,
  #themePreference) {
  background: #14221e;
  color: #e8eee4;
  border-color: #607562;
}
:root[data-theme="dark"] :is(.toolbar select, .academy-profile-form select, #themePreference) option {
  background: #182824;
  color: #e8eee4;
}
:root[data-theme="dark"] :is(.notice, .active-collection, .flash-insights) {
  background: #302b3e;
  border-color: #746082;
  color: #e2d5ee;
}
:root[data-theme="dark"] :is(.empty, .academy-empty) { background: #182824; border-color: #748066; }
:root[data-theme="dark"] :is(.notice a, .source-link, .save.saved, .flash-insights summary) { color: #d8bff5; }
:root[data-theme="dark"] :is(.ipa, .example, .speech-note, .roadmap-note, .club-note, .lesson-time,
  .topic-count, .topic-open p, .band-meta, .word-relations p, .sense-note) { color: var(--muted); }

/* Level and skill catalogue: calm surfaces, clear selection. */
:root[data-theme="dark"] :is(.academy-level-card, .academy-category-card,
  .academy-lesson-row, .academy-unit-card, .academy-profile-form, .academy-area-progress article,
  .academy-progress-summary > div) {
  background: #182824;
  color: #e8eee4;
  border-color: #40544a;
}
:root[data-theme="dark"] :is(.academy-level-card, .academy-category-card, .academy-unit-card):hover {
  background: #22372e;
  border-color: #839d78;
}
:root[data-theme="dark"] .academy-level-card.selected {
  background: #263d30;
  border-color: #aac389;
}
:root[data-theme="dark"] .academy-category-card .academy-category-icon {
  background: #3a3048;
  color: #e0cbfb;
}
:root[data-theme="dark"] .academy-category-card:nth-child(2n) .academy-category-icon {
  background: #2c3f2f;
  color: #d9e9b5;
}
:root[data-theme="dark"] :is(.academy-catalog-toolbar, .academy-catalog-breadcrumb,
  .academy-level-meta, .academy-category-card .academy-category-count,
  .academy-category-card p, .academy-category-copy small, .academy-unit-meta,
  .academy-unit-card > p, .academy-unit-top > span:last-child, .academy-area-progress p,
  .academy-form-help, .academy-unit-label, .academy-production-note, .academy-writing-meta,
  .academy-lesson-row .academy-lesson-number, .academy-lesson-row .academy-lesson-meta,
  .academy-lesson-row .academy-lesson-progress, .academy-lesson-row p, .academy-lesson-category) {
  color: #b3beb5;
}
:root[data-theme="dark"] .academy-catalog-breadcrumb strong { color: #e8eee4; }
:root[data-theme="dark"] .academy-level-link { color: #d9ef80; }
:root[data-theme="dark"] :is(.academy-framework, .academy-progress-details) {
  background: #182824;
  border-color: #40544a;
}
:root[data-theme="dark"] :is(.academy-framework > summary, .academy-progress-details > summary,
  .academy-framework th) { color: #d4dfcd; }
:root[data-theme="dark"] :is(.academy-framework > p, .academy-progress-details > p) { color: #b3beb5; }
:root[data-theme="dark"] :is(.academy-framework th, .academy-framework td) { border-color: #40544a; }
:root[data-theme="dark"] :is(.academy-unit-progress, .academy-lesson-track, .progress-track,
  .band-progress, .quest-track) { background: #354a3d; }
:root[data-theme="dark"] :is(.academy-unit-progress > span, .academy-lesson-track > span,
  .progress-track > span, .band-progress > span, .quest-track > span) { background: #bda8e5; }
:root[data-theme="dark"] :is(.academy-home, .academy-progress-summary > div:first-child) {
  background: #302b3e;
  border-color: #746082;
}
:root[data-theme="dark"] .academy-placement-intro { background: #293e2e; border-color: #6c8559; }
:root[data-theme="dark"] :is(.academy-summary-star, .academy-big-mark) {
  background: #c5b5f2;
  color: #271d36;
  border-color: #8976ad;
  box-shadow: 3px 4px 0 #080f0c;
}
:root[data-theme="dark"] :is(.academy-skill-tab, .academy-skill-orbit-item) {
  background: #21332d;
  color: #e8eee4;
  border-color: #607562;
}
:root[data-theme="dark"] .academy-skill-tab.selected { background: #c5b5f2; color: #271d36; border-color: #c5b5f2; }
:root[data-theme="dark"] .academy-skill-tags > span { background: #2b3e30; color: #d4dfc6; }

/* The lesson player and its feedback surfaces. */
:root[data-theme="dark"] :is(dialog, dialog.academy-dialog) {
  background: #182824;
  color: #e8eee4;
  border-color: #607562;
  box-shadow: 0 24px 90px #0009;
}
:root[data-theme="dark"] dialog::backdrop { background: #030806c9; }
:root[data-theme="dark"] dialog .close { background: #2b3d31; color: #e8eee4; border-color: #6a7e62; }
:root[data-theme="dark"] :is(.lesson-controls, .academy-checklist) { background: #182824; border-color: #526b5c; }
:root[data-theme="dark"] :is(.academy-rule, .academy-context, .academy-order-output,
  .academy-speech-panel, .academy-writing-facts, .academy-review-guidance) {
  background: #21332d;
  color: #e8eee4;
  border-color: #526b5c;
}
:root[data-theme="dark"] .academy-reading-passage { background: #1d2c27; border-left-color: #c5b5f2; }
:root[data-theme="dark"] :is(.academy-answer, .answer) {
  background: #21332d;
  color: #e8eee4;
  border-color: #607562;
}
:root[data-theme="dark"] .academy-answer > span { background: #34463a; color: #dbe6d6; }
:root[data-theme="dark"] :is(.academy-answer:hover:not(:disabled), .answer:hover:not(:disabled)) {
  background: #3b304d;
  border-color: #bca3df;
}
:root[data-theme="dark"] :is(.academy-token, .sentence-prompt) {
  background: #3a304b;
  color: #eee0ff;
  border-color: #9781b6;
}
:root[data-theme="dark"] :is(.academy-listen, .academy-transcript, .academy-speech-text:not(:empty)) {
  background: #302b3e;
  color: #eee4f8;
  border-color: #8e76ab;
}
:root[data-theme="dark"] :is(.academy-listen > small, .academy-speech-text small) { color: #c8bad8; }
:root[data-theme="dark"] :is(.academy-model, .academy-review-guidance .academy-model,
  .academy-review-guidance .academy-checklist) { background: #182824; color: #e8eee4; border-color: #526b5c; }
:root[data-theme="dark"] :is(.academy-review-message, .academy-assessment-note,
  .academy-feedback small, .academy-writing-facts small) { color: #d1c5ad; }
:root[data-theme="dark"] .academy-assessment-note { border-left-color: #bda97b; }
:root[data-theme="dark"] .academy-session-footer { border-top-color: #40544a; }
:root[data-theme="dark"] :is(.academy-feedback, .feedback) {
  background: #302b3e;
  color: #e5d8f1;
  border-color: #8b739f;
}
:root[data-theme="dark"] :is(.academy-feedback.good, .feedback.good, .answer.correct) {
  background: #263e2b;
  color: #d9edc6;
  border-color: #829e66;
}
:root[data-theme="dark"] :is(.academy-feedback.again, .answer.wrong) {
  background: #462d28;
  color: #ffd6c3;
  border-color: #b88368;
}
:root[data-theme="dark"] .mic { background: #ffb89c; color: #2d231e; border-color: #c78e71; box-shadow: 0 0 0 9px #3d2e27; }
:root[data-theme="dark"] .mic.listening { background: #d9ef80; color: #18251b; box-shadow: 0 0 0 9px #34472d; }
:root[data-theme="dark"] .result-icon { color: #18251b; border-color: #9cab77; box-shadow: 3px 4px 0 #080f0c; }
:root[data-theme="dark"] .session-result > .meaning { color: #d4bdf1; }
:root[data-theme="dark"] #toast { background: #e8eee4; color: #18251b; border-color: #c6d1bc; }

/* Vocabulary, optional practice activities and achievements. */
:root[data-theme="dark"] :is(.vocab-card, .today-word, .quick-card, .quests, .band, .mode) {
  background: #182824;
  color: #e8eee4;
  border-color: #40544a;
}
:root[data-theme="dark"] :is(.vocab-card:hover, .quick-card:hover, .band:hover) {
  border-color: #829a76;
  box-shadow: 3px 4px 0 #080f0c;
}
:root[data-theme="dark"] :is(.word-explore, .sense-tab.selected) {
  background: #3a304b;
  color: #e6d4fa;
  border-color: #9b83b9;
}
:root[data-theme="dark"] .sense-tab { background: #21332d; color: #e8eee4; border-color: #607562; }
:root[data-theme="dark"] .word-relations strong { color: #d4dfc6; }
:root[data-theme="dark"] .relation-chip { background: #2c422f; border-color: #758961; color: #deedc9; }
:root[data-theme="dark"] .relation-chip.opposite { background: #452f28; border-color: #ac7c5f; color: #ffd0b0; }
:root[data-theme="dark"] .sense-note { border-top-color: #40544a; }
:root[data-theme="dark"] :is(.quick-icon, .band-top, .mode:nth-child(2), .topic-card) {
  background: #302b3e;
  color: #e8eee4;
  border-color: #70617f;
}
:root[data-theme="dark"] :is(.quick-lime .quick-icon, .band:nth-child(3n+2) .band-top,
  .mode:nth-child(3), .topic-lime, .practice-strip, .club-rhythm) { background: #2b3d2d; color: #dce9ce; border-color: #6a8057; }
:root[data-theme="dark"] :is(.quick-coral .quick-icon, .band:nth-child(3n+3) .band-top,
  .mode:nth-child(4), .topic-coral, .chapter-ticket, .streak-chip) { background: #402e27; color: #f3ddcd; border-color: #8e6b55; }
:root[data-theme="dark"] .topic-blue { background: #273342; border-color: #7185a1; }
:root[data-theme="dark"] :is(.mode > .emoji, .ticket-icon) { background: #21332d; border-color: #607562; }
:root[data-theme="dark"] .topic-art { color: #c7acee; }
:root[data-theme="dark"] .topic-lime .topic-art { color: #c4da88; }
:root[data-theme="dark"] .topic-coral .topic-art { color: #ecb491; }
:root[data-theme="dark"] .topic-blue .topic-art { color: #b3c7f0; }
:root[data-theme="dark"] :is(.practice-strip p, .club-rhythm > p, .week-day) { color: #c0d2aa; }
:root[data-theme="dark"] .week-day > b { background: #344b31; border-color: #7c935f; }
:root[data-theme="dark"] .week-day.studied > b { background: #d9ef80; color: #18251b; border-color: #d9ef80; }
:root[data-theme="dark"] .mastery-track { background: #50653b; }
:root[data-theme="dark"] .mastery-track > span { background: #d9ef80; }
:root[data-theme="dark"] .quest-card { background: #21332d; border-color: #526b5c; }
:root[data-theme="dark"] .quest-card:hover { background: #373047; border-color: #a68bc7; }
:root[data-theme="dark"] :is(.quest-card.complete, .release-item.live) { background: #293e2b; border-color: #829a66; }
:root[data-theme="dark"] .quest-card.complete .quest-track > span { background: #c2d88a; }
:root[data-theme="dark"] .release-item { background: #182824; border-color: #40544a; }
:root[data-theme="dark"] .live .release-dot { background: #c2d88a; }
:root[data-theme="dark"] .badge-card { background: #21332d; color: #b3beb5; border-color: #40544a; }
:root[data-theme="dark"] .badge-card.unlocked { background: #3a304b; color: #efe2ff; border-color: #9b83b9; box-shadow: 2px 3px 0 #080f0c; }

/* Privacy, feedback and data settings share the same readable palette. */
:root[data-theme="dark"] :is(.beta-consent, .beta-settings-card) {
  background: #182824;
  color: #e8eee4;
  border-color: #526b5c;
}
:root[data-theme="dark"] :is(.beta-consent p, .beta-settings-card p, .beta-intro) { color: #b3beb5; }
:root[data-theme="dark"] .beta-small { color: #b3beb5 !important; }
:root[data-theme="dark"] .beta-choice-status { color: #e8eee4 !important; }
:root[data-theme="dark"] .beta-card-icon { background: #3a304b; color: #e5d2fc; }
:root[data-theme="dark"] .beta-settings-card.beta-danger { background: #342621; border-color: #9a6a52; }
:root[data-theme="dark"] .beta-danger .beta-card-icon { background: #58392e; color: #ffd2b6; }
:root[data-theme="dark"] .beta-delete-button { background: #342621; color: #ffc7ad; border-color: #b6856b; }
:root[data-theme="dark"] .beta-form-status { color: #c6e29a; }
:root[data-theme="dark"] .beta-form-status.is-error { color: #ffb89c; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) :is(.card, .hero) {
  background: #182824;
  color: #e8eee4;
  border-color: #526b5c;
  box-shadow: none;
}
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .hero { background: #302b3e; border-color: #80708e; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) :is(.card.wide, .card.lime) { background: #293e2b; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) :is(.card p, .small, .fine, .intro) { color: #b3beb5; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) p { color: #b3beb5; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .sources p { color: #b3beb5; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) a { color: #d5c1f1; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .brand { color: #e8eee4; }
:root[data-theme="dark"] .switch button { background: #21332d; color: #e8eee4; border-color: #607562; }
:root[data-theme="dark"] .switch button[aria-pressed="true"] { background: #c5b5f2; color: #271d36; border-color: #c5b5f2; }

/* Owner pages use their own variables, with a few explicit legacy surfaces. */
:root[data-theme="dark"] :is(.admin-gate, .admin-sense, .admin-word-item) {
  background: #1d2e27;
  color: #e8eee4;
  border-color: #40544a;
}
:root[data-theme="dark"] .admin-word-item:hover { border-color: #8a9f7b; }
:root[data-theme="dark"] .admin-word-item.is-selected { background: #293e2b; border-color: #9ebc80; }
:root[data-theme="dark"] .admin-word-item > span:last-child { color: #b3beb5; }
:root[data-theme="dark"] :is(.admin-input, .admin-body label input, .admin-body label select, .admin-body label textarea) {
  background: #14221e;
  color: #e8eee4;
  border-color: #607562;
}
:root[data-theme="dark"] .admin-input:focus,
:root[data-theme="dark"] .admin-body label :is(input, select, textarea):focus {
  border-color: #c5b5f2;
  box-shadow: 0 0 0 3px #c5b5f22b;
}
:root[data-theme="dark"] .admin-button { background: #c6dda6; color: #18251b; border-color: #a9bf8c; }
:root[data-theme="dark"] .admin-button:hover:not(:disabled) { background: #d9ef80; }
:root[data-theme="dark"] .admin-button.admin-secondary { background: #21332d; color: #e8eee4; border-color: #607562; }
:root[data-theme="dark"] .admin-button.admin-secondary:hover:not(:disabled) { background: #2a4135; }
:root[data-theme="dark"] .admin-button.admin-quiet { background: transparent; color: #b3beb5; border-color: transparent; }
:root[data-theme="dark"] .admin-button.admin-quiet:hover:not(:disabled) { background: #21332d; }
:root[data-theme="dark"] .admin-tabs button.is-active { background: #c6dda6; color: #18251b; }
:root[data-theme="dark"] .admin-workflow { color: #d7c7e9; }
:root[data-theme="dark"] .admin-workflow b { background: #4a3b5b; color: #eadcf6; }
:root[data-theme="dark"] .admin-workflow i { color: #bba5cf; }
:root[data-theme="dark"] .admin-status { background: #263e2b; color: #d9edc6; border-color: #829e66; }
:root[data-theme="dark"] :is(.admin-status.is-error, .admin-import-error) { background: #462d28; color: #ffd6c3 !important; border-color: #b88368; }
:root[data-theme="dark"] :is(.admin-conflict, .admin-import-warning) { background: #403221; color: #f4dcad !important; border-color: #a58a54; }
:root[data-theme="dark"] .admin-publish-bar { background: #182824f5; border-color: #40544a; box-shadow: 0 -8px 25px #0005; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .metric { background: #182824; color: #e8eee4; border-color: #526b5c; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) :is(.metric span, .time, .context, .event-list, .note) { color: #b3beb5; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .message { color: #e8eee4; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .category { background: #473a58; color: #eee3ff; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .status { background: #263e2b; color: #d9edc6; border-color: #829e66; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .status.error { background: #462d28; color: #ffd6c3; border-color: #b88368; }
:root[data-theme="dark"] body:not(.study-club):not(.admin-body) .toolbar button { background: #d9ef80; color: #18251b; border-color: #b3c46f; }

@media (max-width: 760px) {
  :root[data-theme="dark"] .study-club > aside { background: #182824f5; border-top-color: #526b5c; }
  :root[data-theme="dark"] nav > a.active { box-shadow: none; background: #38304b; border-color: #8e7dac; }
  #themeToggle { padding: 10px; }
}
@media (max-width: 650px) {
  .app > header { padding-left: 14px; padding-right: 14px; gap: 8px; }
  .header-right { flex: 0 1 auto; margin-left: auto; max-width: calc(100% - 76px); gap: 5px; }
  .mobile-brand { position: relative; display: inline-block; flex: 0 0 72px; width: 72px; padding-bottom: 17px; line-height: 1; }
  .mobile-brand .brand-status { position: absolute; left: 0; bottom: 0; padding: 1px 4px; font-size: 9px; line-height: 1.25; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #themeToggle { transition: none; }
}

/* Keep the language, account and appearance controls reachable on 320px screens. */
@media (max-width: 350px) {
  .header-right #cloudStatus { display: none !important; }
}
