:root { --zd-explanation-font-size: 18px; --zd-appearance-surface: #fff; --zd-appearance-text: #21382c; --zd-appearance-muted: #64776c; --zd-appearance-line: #d8e3dc; --zd-appearance-soft: #f1f6f1; --zd-appearance-accent: #19694d; }

/* Explanation and translation sizes are independent of exercise text size. */
:root :is(.zd-word-value, .zd-word-examples, .zd-phrase-value, .zd-word-tooltip) { font-size: var(--zd-explanation-font-size); line-height: 1.65; }
/* Module paragraph styles must not override the user's translation size. */
:root .zd-reading-translation-body { font-size: var(--zd-explanation-font-size) !important; line-height: 1.65; }
:root :is(.zd-word-dialog, .zd-phrase-popup, .zd-word-tooltip) { box-sizing: border-box; }
:root .zd-word-dialog { width: min(42rem, 100%); max-height: calc(100dvh - 2rem); }
:root .zd-phrase-popup { width: min(32rem, calc(100vw - 1.25rem)); max-height: calc(100dvh - 1.25rem); }
:root .zd-word-tooltip { max-width: min(26rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); overflow: hidden; padding: .6rem .85rem; }
:root :is(.zd-word-label, .zd-word-kicker, .zd-phrase-label, .zd-phrase-kicker) { font-size: calc(var(--zd-explanation-font-size) * .7); line-height: 1.5; }
:root :is(.zd-word-lemma, .zd-word-tag, .zd-word-head-action, .zd-word-save, .zd-word-remove, .zd-phrase-explain, .zd-phrase-save, .zd-phrase-saved) { font-size: calc(var(--zd-explanation-font-size) * .8); line-height: 1.5; }
:root .zd-phrase-title { font-size: var(--zd-explanation-font-size); }
:root .zd-word-title { font-size: calc(var(--zd-explanation-font-size) * 1.6); overflow-wrap: anywhere; }
:root :is(.zd-word-loading, .zd-word-modal-status, .zd-word-modal-error, .zd-phrase-loading, .zd-phrase-error) { font-size: var(--zd-explanation-font-size); }

.zd-appearance-controls { font: 14px/1.6 "Space Grotesk", system-ui, sans-serif; color: var(--zd-appearance-text); min-width: 0; }
.zd-appearance-controls[lang="ar"], .zd-appearance-dialog[lang="ar"] { font-family: "Tajawal", "Noto Sans Arabic", Tahoma, sans-serif; }
#settings-panel { width: min(22rem, calc(100vw - 1.5rem)) !important; max-width: none !important; max-height: calc(100dvh - 10rem); overflow-y: auto; }
#settings-panel .zd-appearance-controls { border-top: 1px solid var(--zd-appearance-line); padding-top: 18px; margin-top: 18px; }
.zd-appearance-size label { display: flex; align-items: start; justify-content: space-between; gap: 14px; font-weight: 600; }
.zd-appearance-size output { white-space: nowrap; color: var(--zd-appearance-accent); font-variant-numeric: tabular-nums; }
.zd-appearance-size input { display: block; width: 100%; margin: 14px 0 8px; min-height: 24px; accent-color: var(--zd-appearance-accent); cursor: pointer; }
.zd-appearance-size p, .zd-appearance-saved { margin: 0; color: var(--zd-appearance-muted); font-size: 12px; line-height: 1.7; }
.zd-appearance-preview { background: var(--zd-appearance-soft); border: 1px solid var(--zd-appearance-line); border-radius: 10px; padding: 12px 14px; margin: 14px 0 18px; font-size: var(--zd-explanation-font-size); line-height: 1.65; overflow-wrap: anywhere; }
.zd-appearance-theme { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; min-height: 44px; }
.zd-appearance-theme > span { display: flex; align-items: center; gap: 9px; }
.zd-appearance-theme svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.zd-appearance-theme strong { font-weight: 500; }
.zd-appearance-theme input { position: absolute; opacity: 0; width: 44px; height: 28px; inset-inline-end: 0; margin: 0; cursor: pointer; }
.zd-appearance-theme i { position: relative; width: 44px; height: 26px; border: 1px solid var(--zd-appearance-line); border-radius: 20px; background: var(--zd-appearance-soft); flex: none; pointer-events: none; }
.zd-appearance-theme i::before { content: ""; display: block; width: 18px; height: 18px; position: absolute; top: 3px; left: 3px; border-radius: 50%; background: var(--zd-appearance-muted); transition: transform 120ms ease; }
.zd-appearance-theme input:checked + i { background: #19694d; border-color: #19694d; }
.zd-appearance-theme input:checked + i::before { background: #fff; transform: translateX(18px); }
.zd-appearance-theme input:focus-visible + i { outline: 3px solid #d9b33b; outline-offset: 3px; }
.zd-appearance-reset { display: block; border: 0; background: transparent; color: var(--zd-appearance-muted); padding: 7px 0; margin-top: 10px; font: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.zd-appearance-button { display: inline-flex; justify-content: center; align-items: center; flex: none; width: 40px; height: 40px; border: 1px solid var(--zd-appearance-line); border-radius: 10px; background: var(--zd-appearance-surface); color: var(--zd-appearance-accent); cursor: pointer; padding: 9px; }
.zd-appearance-button svg { width: 20px; height: 20px; }
.zd-appearance-dialog { position: fixed; inset: 0; margin: auto; width: min(390px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-sizing: border-box; overflow-y: auto; padding: 24px; border: 1px solid var(--zd-appearance-line); border-radius: 18px; background: var(--zd-appearance-surface); color: var(--zd-appearance-text); box-shadow: 0 24px 80px #0b281f40; font: 14px/1.6 "Space Grotesk", system-ui, sans-serif; }
.zd-appearance-dialog::backdrop { background: #132b236b; backdrop-filter: blur(3px); }
.zd-appearance-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.zd-appearance-dialog h2 { display: flex; align-items: center; gap: 9px; margin: 0; font-family: inherit; font-size: 20px; font-weight: 600; line-height: 1.4; }
.zd-appearance-dialog h2 svg { width: 21px; height: 21px; }
.zd-appearance-dialog .zd-appearance-saved { margin-top: 18px; }
.zd-mobile-appearance { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--zd-appearance-text); }
.sim-appearance { border: 1px solid var(--sim-line); border-radius: 18px; padding: 24px; background: var(--zd-appearance-surface); }
.sim-appearance h2 { font-size: 1rem; margin-bottom: 18px; }

/* Neutral dark palette shared by catalogues, learning workspaces and dashboard.
   Dark-mode overrides stay scoped to the user's preference; light mode is unchanged. */
:root[data-zd-theme="dark"] {
  color-scheme: dark;
  --zd-dark-bg: #101010; --zd-dark-surface: #1b1b1b; --zd-dark-soft: #262626;
  --zd-dark-text: #f5f5f5; --zd-dark-muted: #b8b8b8; --zd-dark-line: #444;
  --zd-appearance-surface: var(--zd-dark-surface); --zd-appearance-text: var(--zd-dark-text);
  --zd-appearance-muted: var(--zd-dark-muted); --zd-appearance-line: var(--zd-dark-line);
  --zd-appearance-soft: var(--zd-dark-soft); --zd-appearance-accent: var(--zd-dark-text);
  --flag-black: var(--zd-dark-text); --flag-stone-50: #181818; --flag-stone-100: #222;
  --flag-stone-200: #383838; --flag-stone-300: #505050; --flag-border: var(--zd-dark-line);
  --flag-muted: var(--zd-dark-muted); --flag-gold: #f5f5f5; --flag-gold-dark: #ddd; --flag-gold-soft: #303030;
  --flag-green: #f5f5f5; --flag-green-soft: #303030; --flag-red: #ffb4b4; --flag-red-soft: #382020;
  --ux-ink: var(--zd-dark-text); --ux-ink-soft: #ddd; --ux-paper: var(--zd-dark-bg);
  --ux-paper-deep: var(--zd-dark-surface); --ux-line: var(--zd-dark-line); --ux-muted: var(--zd-dark-muted);
  --ux-green: var(--zd-dark-text); --ux-focus: #ccc; --ux-gold: #f5f5f5; --ux-gold-strong: #ddd;
  --ux-shadow: 0 16px 40px #0004;
  --zd-ui-bg: var(--zd-dark-bg); --zd-ui-surface: var(--zd-dark-surface); --zd-ui-soft: var(--zd-dark-soft);
  --zd-ui-line: var(--zd-dark-line); --zd-ui-text: var(--zd-dark-text); --zd-ui-muted: var(--zd-dark-muted);
  --zd-ui-green: var(--zd-dark-text); --zd-ui-green-soft: #303030;
  --sim-ink: var(--zd-dark-text); --sim-green: var(--zd-dark-text); --sim-muted: var(--zd-dark-muted);
  --sim-line: var(--zd-dark-line); --sim-paper: var(--zd-dark-bg); --sim-gold: #f5f5f5;
  --oral-ink: var(--zd-dark-text); --oral-forest: #ddd; --oral-forest-deep: #111; --oral-leaf: #eee;
  --oral-gold: #f5f5f5; --oral-gold-pale: #303030; --oral-paper: var(--zd-dark-bg);
  --oral-paper-deep: var(--zd-dark-surface); --oral-line: var(--zd-dark-line); --oral-muted: var(--zd-dark-muted);
  --oral-shadow: 0 16px 40px #0004;
  background: var(--zd-dark-bg);
}
html[data-zd-theme="dark"] body { background: var(--zd-dark-bg) !important; color: var(--zd-dark-text) !important; }
html[data-zd-theme="dark"] .zd-dash-shell {
  --dash-bg: var(--zd-dark-bg); --dash-ink: var(--zd-dark-text); --dash-muted: var(--zd-dark-muted);
  --dash-line: var(--zd-dark-line); --dash-green: var(--zd-dark-text); --dash-soft: var(--zd-dark-soft);
}

/* Utility classes in the legacy modules include hard-coded light-mode colours. */
html[data-zd-theme="dark"] :is(.bg-white, .bg-white\/80, .bg-white\/90, .bg-white\/95, .bg-white\/60, .bg-white\/70) { background-color: var(--zd-dark-surface) !important; }
html[data-zd-theme="dark"] :is(.text-ink, .text-slate, .text-black, .text-gray-700, .text-gray-800, .text-gray-900, .text-slate-600, .text-slate-700, .text-slate-800, .text-slate-900, .text-stone-700, .text-stone-800, .text-stone-900) { color: var(--zd-dark-text) !important; }
html[data-zd-theme="dark"] :is(.text-stone-400, .text-stone-500, .text-stone-600, .text-slate-400, .text-slate-500, .text-gray-400, .text-gray-500, .text-gray-600) { color: var(--zd-dark-muted) !important; }
html[data-zd-theme="dark"] :is(.text-mint, .text-emerald-700, .text-green-700, .text-azure, .text-amber) { color: #eee !important; }
html[data-zd-theme="dark"] :is(.text-rose, .text-red-700) { color: #ffb4b4 !important; }
html[data-zd-theme="dark"] :is(.bg-azure\/10, .bg-azure\/5, .bg-amber\/10, .bg-mint\/10, .bg-mint\/15, .bg-mint\/20, .bg-emerald\/5) { background-color: #303030 !important; }
html[data-zd-theme="dark"] :is(.border-black\/10, .border-black\/20) { border-color: var(--zd-dark-line) !important; }
html[data-zd-theme="dark"] :is(.bg-azure, .bg-azure\/90) { background: #f5f5f5 !important; color: #111 !important; }
html[data-zd-theme="dark"] :is(.bg-azure, .bg-azure\/90) .text-white { color: #111 !important; }

/* All card/search wrappers need their own surface, not just the inner input. */
html[data-zd-theme="dark"] :is(
  .zd-exam-header, .zd-exam-footer, .zd-dash-sidebar, .zd-dash-topbar, .zd-mobile-menu,
  .exam-panel, .zd-dash-panel, .zd-module-card, .zd-theme-card, .zd-catalog-card, .zd-exercise-card,
  .zd-profile-card, .zd-profile-password, .zd-saved-words, .zd-plan-card, .zd-dashboard-exams,
  .zd-reading-translation, .zd-reading-audio-controls, .zd-word-dialog, .zd-phrase-popup,
  .zd-text-camera, .zd-text-import-options, .zd-text-list-item, .zd-version-dialog, .zd-version-choice,
  .zd-version-picker__dialog, .zd-version-picker__list > button, .zd-exercise-card__link,
  .zd-payment-method, .zd-account-secondary, .zd-match-settings, .zd-match-result, .zd-flashcard-face,
  .zd-activity-card, .zd-course-invite, .zd-practice-modal > section, .zd-catalog-search,
  .zd-catalog-part-tabs button, .zd-pwa-help__card, .zd-account-required__dialog,
  .horen-topic, .horen-result-card, .horen-audio-player, .horen-volume-control__popover,
  .shreiben-workspace-heading, .shreiben-task-heading, .shreiben-writing-block, .shreiben-info-block,
  .writing-correction-dialog__shell, .writing-answer-history__item, .writing-submitted-answer,
  .oral-workspace, .oral-topic-reading, .oral-position-card, .oral-plan-card, .oral-checklist-card, .oral-language-bank,
  .oral-recorder, .oral-ai-result, .oral-room-card, .oral-room-setup, .oral-room-participants,
  .zd-admin-stats > span, .zd-admin-table-wrap, .zd-admin-table, .zd-admin-toolbar > label,
  .zd-admin-plan-card, .zd-admin-user-workspace, .zd-admin-user-panel, .zd-admin-control-card,
  .zd-admin-email-composer, .zd-admin-email-history, .zd-admin-email-list details, .zd-request-list > article,
  .sim-header, .sim-footer, .sim-config-main, .sim-part-selection, .sim-options, .sim-score, .sim-dialog,
  .sim-review-answer, .sim-join-group, .sim-score-card, .sim-score-banner, .sim-assessment-loading
) { background: var(--zd-dark-surface) !important; border-color: var(--zd-dark-line) !important; color: var(--zd-dark-text); }
html[data-zd-theme="dark"] :is(
  .zd-exam-context, .zd-exam-subheader, .zd-global-levels, .zd-session-user, .zd-dash-avatar,
  .zd-dash-mobile-nav select, .zd-text-image-queue, .zd-text-image-preview, .zd-text-written-result,
  .zd-text-ai-format, .zd-word-grid article, .zd-reading-subscription-copy, .zd-listening-source-tabs,
  .zd-text-tabs, .zd-exam-history-table th, .zd-admin-table th, .zd-admin-balance label,
  .shreiben-writing-header, .shreiben-answer-meta, .shreiben-answer-actions, .shreiben-answer-toolbar,
  .writing-correction-dialog__header, .writing-answer-history, .oral-library, .oral-hero-score,
  .sim-setting-icon, .sim-emblem, .sim-secondary, .sim-small, .sim-group-card, .sim-group-option,
  .sim-audio-check, .sim-global-audio, .sim-levels input:checked + span, .sim-horen-types input:checked + span,
  .sim-mode-options input:checked + span
) { background: var(--zd-dark-soft) !important; border-color: var(--zd-dark-line) !important; color: var(--zd-dark-text); }
html[data-zd-theme="dark"] :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), textarea, select) { background-color: #171717 !important; color: var(--zd-dark-text) !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.zd-catalog-search, .zd-text-search, .zd-admin-toolbar > label) input { background: transparent !important; }
html[data-zd-theme="dark"] :is(input, textarea)::placeholder { color: #aaa !important; opacity: 1; }
html[data-zd-theme="dark"] :is(input[type="checkbox"], input[type="radio"], input[type="range"]) { accent-color: #ddd !important; }

/* Reading content must inherit readable ink, including unclassed grammar paragraphs. */
html[data-zd-theme="dark"] :is(
  [data-zd-reading-content], .zd-sprach-text, .zd-reading-choice-text, .shreiben-markdown,
  .shreiben-markdown p, .shreiben-markdown li, .shreiben-editor, .oral-position-opinion, .oral-plan-prompt,
  .horen-statement-reading, .zd-reading-translation-body, .zd-word-title, .zd-word-value, .zd-phrase-title, .zd-phrase-value,
  .zd-word-examples, .zd-module-card h2, .zd-text-card h2, .zd-text-reader p, .zd-text-question strong,
  .zd-profile-details dd, .zd-saved-words h2, .zd-exercise-card h2, .zd-version-choice strong,
  .zd-reading-exercise-name, .writing-german-text, .writing-submitted-answer__text
) { color: var(--zd-dark-text) !important; }
html[data-zd-theme="dark"] :is(.zd-dash-shell, .zd-my-texts, .zd-admin-main, .oral-main) :is(h1, h2, h3) { color: var(--zd-dark-text) !important; }
html[data-zd-theme="dark"] :is(
  .zd-word-lemma, .zd-word-label, .zd-phrase-label, .zd-text-reader-hint, .zd-text-counter, .zd-text-meta,
  .zd-text-small-note, .zd-text-question-label, .zd-text-ai-format small, .zd-text-import-hint,
  .zd-text-import-status, .zd-profile-details dt, .zd-plan-description, .zd-version-dialog p,
  .zd-text-list-item p, .zd-text-list-item small, .zd-course-invite p, .zd-reading-exercise-parent,
  .zd-exam-exercise-parent, .zd-exam-history-table time, .zd-exam-history-message,
  .oral-instruction, .oral-recorder > p, .oral-ai-transcripts p, .oral-ai-criteria p, .oral-ai-next-step p,
  .writing-correction-loading__copy, .writing-correction-empty__copy, .writing-answer-history__item-copy small,
  .horen-audio-player__heading div > span, #horen-audio-time
) { color: var(--zd-dark-muted) !important; }
html[data-zd-theme="dark"] :is(
  .zd-word-kicker, .zd-phrase-kicker, .zd-phrase-saved, .zd-word-modal-status, .zd-text-back, .zd-reading-translation-head,
  .zd-text-explanation, .zd-exercise-card__footer, .zd-exercise-card__progress strong,
  .zd-exam-history-actions a, .zd-exam-history-level, .zd-exam-history-score.is-passed,
  .zd-admin-account-status.is-enabled, .oral-eyebrow, .oral-focused-back strong, .oral-part-progress,
  .oral-hero-score strong, .oral-analysis-progress, .oral-ai-result > header span
) { color: #eee !important; }

/* Monochrome controls have explicit foreground/background pairs. */
html[data-zd-theme="dark"] :is(
  .zd-reading-action, .zd-reading-translation-close, .zd-word-head-action, .zd-word-close, .zd-phrase-close, .zd-reading-audio-btn,
  .zd-image-icon, .zd-dash-button:not(.is-primary), .zd-text-import-options button,
  .zd-global-levels a.is-active, .zd-pwa-install, .zd-mobile-menu-toggle, .zd-appearance-button,
  .zd-simulation-fullscreen, .shreiben-fullscreen-toggle, .oral-focused-back, .oral-secondary-button,
  .zd-preview-notice__actions a, .zd-admin-actions button, .zd-admin-plan-card__actions button
) { background: var(--zd-dark-surface) !important; color: #eee !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.zd-exam-header #settings-btn, .zd-speaking-timer, .zd-speaking-reset) { background: #262626 !important; color: #eee !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(
  .zd-word-save, .zd-phrase-save, .zd-phrase-explain, .zd-reading-subscription-link,
  .zd-dash-button.is-primary, .zd-account-primary, .zd-plan-card button, .zd-account-loading button,
  .zd-course-invite__button, .zd-simulation-submit, .sim-primary, .community-floating-btn, .topic-check-btn,
  .oral-analyze-button, .oral-primary-button, .zd-pwa-help__card > button:last-child,
  .zd-admin-toolbar > button, .zd-admin-balance button
) { background: #f5f5f5 !important; color: #111 !important; border-color: #f5f5f5 !important; }
html[data-zd-theme="dark"] :is(.zd-catalog-part-tabs button.is-active, .zd-listening-source-tabs button.is-active) { background: #eee !important; color: #111 !important; border-color: #eee !important; }
html[data-zd-theme="dark"] .zd-catalog-part-tabs button strong { background: #303030 !important; color: #ddd !important; }
html[data-zd-theme="dark"] .zd-catalog-part-tabs button.is-active strong { background: #111 !important; color: #fff !important; }
html[data-zd-theme="dark"] :is(.zd-dash-nav a[aria-current], .zd-text-tabs a[aria-current], .zd-admin-tabs .is-active, .oral-part-tab.is-active) { background: #303030 !important; color: #fff !important; border-color: #888 !important; }
html[data-zd-theme="dark"] :is(.zd-global-modules a:hover, .zd-pwa-install:hover, .zd-version-choice:hover, .zd-admin-table tr:hover td) { background-color: #303030 !important; color: #fff !important; }
html[data-zd-theme="dark"] :is(.zd-global-modules a.is-active, .zd-text-tabs a, .zd-pwa-install svg) { color: #eee !important; }
html[data-zd-theme="dark"] .zd-appearance-theme input:checked + i { background: #eee; border-color: #eee; }
html[data-zd-theme="dark"] .zd-appearance-theme input:checked + i::before { background: #111; }
html[data-zd-theme="dark"] .zd-appearance-dialog::backdrop { background: #0009; }
html[data-zd-theme="dark"] :focus-visible { outline-color: #bbb !important; }
html[data-zd-theme="dark"] :is(.zd-catalog-search, .zd-text-search):focus-within { border-color: #bbb !important; box-shadow: 0 0 0 3px #ffffff18; }

/* Answer states retain labels and a red error signal; positive states use neutral ink. */
html[data-zd-theme="dark"] :is(.zd-answer-select, .zd-sb2-gap)[data-result="correct"] { background: #353535 !important; color: #fff !important; border-color: #bbb !important; }
html[data-zd-theme="dark"] :is(.zd-answer-select, .zd-sb2-gap)[data-result="incorrect"] { background: #382020 !important; color: #ffb4b4 !important; border-color: #d78b8b !important; }
html[data-zd-theme="dark"] :is(.zd-word-remove, .zd-text-delete, .zd-text-notice[role="alert"], .zd-phrase-error, .zd-word-modal-error, .zd-text-choices .is-wrong, .sim-error, .oral-recorder-error) { background: #382020 !important; color: #ffb4b4 !important; border-color: #925757 !important; }
html[data-zd-theme="dark"] .zd-exam-workspace .zd-simulation-quit { background: #382020 !important; color: #ffb4b4 !important; border-color: #925757 !important; }
html[data-zd-theme="dark"] :is(.zd-reading-error.is-subscription, .zd-phrase-error.is-subscription, .zd-word-modal-error.is-subscription, .zd-word-modal-status.is-subscription, .zd-text-notice.is-plan, .zd-text-choices .is-correct, .zd-text-choices .is-selected, .zd-status-banner, .zd-preview-notice) { background: #303030 !important; color: #eee !important; border-color: #666 !important; }
html[data-zd-theme="dark"] :is(.zd-exam-history-status, .zd-admin-status, .zd-subscription-status, .oral-recorder-state) { background: #303030 !important; color: #eee !important; }
html[data-zd-theme="dark"] :is(.zd-exam-history-score.is-below-threshold, .zd-admin-account-status.is-paused) { color: #ffb4b4 !important; }
html[data-zd-theme="dark"] :is(.zd-gap-feedback, .zd-reading-answer-label) { color: #eee !important; }
html[data-zd-theme="dark"] .zd-reading-choice.is-assigned[data-reviewed="false"] { background: #303030 !important; color: #ddd !important; }
html[data-zd-theme="dark"] .zd-reading-choice.is-assigned[data-reviewed="false"] .zd-reading-choice-text { color: #ccc !important; }
html[data-zd-theme="dark"] .zd-reading-choice-assignment { background: #3b3b3b !important; color: #fff !important; border-color: #777 !important; }
html[data-zd-theme="dark"] .zd-reading-subscription-copy p { color: #ccc; }
html[data-zd-theme="dark"] .zd-word-token.is-saved { background: #fff !important; color: #000 !important; box-shadow: none; text-decoration-color: #000; }
html[data-zd-theme="dark"] .zd-word-token.is-saved-phrase { text-decoration-color: #bbb; }
html[data-zd-theme="dark"] .zd-word-token:hover { background: #fff !important; color: #000 !important; box-shadow: 0 0 0 2px #fff; text-decoration-color: #000; }
html[data-zd-theme="dark"] .zd-word-token.is-saved.is-saved-phrase { text-decoration-color: #000; }
html[data-zd-theme="dark"] :is(.zd-word-tooltip, .zd-appearance-preview, .zd-word-tag) { background: #303030; color: #f5f5f5; border-color: #666; }
html[data-zd-theme="dark"] .exam-action-bar { background: linear-gradient(180deg, #1b1b1b00, #1b1b1b 40%) !important; }
html[data-zd-theme="dark"] :is(.zd-global-brand, .zd-dash-brand, .zd-dash-mobile-brand, .sim-brand, .zd-exam-footer, .zd-catalog-footer) img[src*="logo"] { background: #fafafa; border-radius: 8px; padding: 4px; box-sizing: border-box; filter: grayscale(1); }
html[data-zd-theme="dark"] :is(.flag-glow-top, .flag-glow-bottom, .grid-overlay) { opacity: 0; }
html[data-zd-theme="dark"] :is(.zd-exercise-card__icon, .zd-exercise-card__badge, .zd-module-card__icon, .zd-exercise-card__track) { background: #303030 !important; color: #eee !important; }
html[data-zd-theme="dark"] :is(.zd-exercise-card__fill, .zd-exercise-card__track i, .zd-exercise-card__progress i, .zd-admin-usage__track i) { background: #ddd !important; }
html[data-zd-theme="dark"] .zd-exercise-card__stack > span { background: #303030 !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.zd-exam-history-table td, .zd-admin-table td, .zd-admin-table th, .horen-table td, .horen-table th) { border-color: #444 !important; }
html[data-zd-theme="dark"] .horen-table th { background: #303030 !important; color: #f5f5f5 !important; }
html[data-zd-theme="dark"] :is(.horen-audio-player__heading div > strong, .horen-topic-meta) { color: #eee !important; }
html[data-zd-theme="dark"] :is(.horen-audio-player__art, .horen-audio-player__part, .horen-audio-player__toggle, .horen-volume-control__toggle, .horen-callout) { background: #303030 !important; color: #eee !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.horen-audio-player__progress, #horen-audio-progress) { --audio-progress: #ddd; }
html[data-zd-theme="dark"] .oral-focused-mode .oral-workspace { background: transparent !important; }
html[data-zd-theme="dark"] :is(.oral-ai-next-step, .oral-ai-disclaimer, .oral-room-intro) { background: #303030 !important; color: #eee !important; }
html[data-zd-theme="dark"] :is(.zd-text-search, .zd-text-image-preview, .zd-text-tabs) { background: #262626 !important; border-color: #444 !important; }
html[data-zd-theme="dark"] :is(.zd-admin-stats strong, .zd-admin-table, .zd-admin-user-link, .zd-admin-balance label > span) { color: #eee !important; }
html[data-zd-theme="dark"] :is(.zd-admin-table td > span, .zd-admin-table td > small, .zd-admin-table time, .zd-admin-usage small) { color: #b8b8b8 !important; }
@media(max-width:640px) { .zd-appearance-dialog { padding: 20px; } :root .zd-word-dialog-head-main { flex-direction: column; gap: .8rem; } .zd-global-header__end > .zd-appearance-button { display: none; } }
@media(prefers-reduced-motion:reduce) { .zd-appearance-theme i::before { transition: none; } }

html[data-zd-theme="dark"] :is(#horen-audio-part, #horen-audio-mute, .oral-time-chip, .oral-practice-label) { background: #303030 !important; color: #eee !important; }
html[data-zd-theme="dark"] #horen-audio-toggle { background: #eee !important; color: #111 !important; }
html[data-zd-theme="dark"] #horen-audio-seek::-webkit-slider-runnable-track { background: linear-gradient(to right, #eee 0 var(--audio-played), #888 var(--audio-played) var(--audio-buffered), #444 var(--audio-buffered) 100%); }
html[data-zd-theme="dark"] #horen-audio-seek::-moz-range-track { background: linear-gradient(to right, #eee 0 var(--audio-played), #888 var(--audio-played) var(--audio-buffered), #444 var(--audio-buffered) 100%); }
html[data-zd-theme="dark"] #horen-audio-seek::-webkit-slider-thumb { background: #eee; border-color: #111; }
html[data-zd-theme="dark"] #horen-audio-seek::-moz-range-thumb { background: #eee; border-color: #111; }

html[data-zd-theme="dark"] .topic-check-btn { box-shadow: none !important; animation: none; }
html[data-zd-theme="dark"] .zd-session-avatar { background: #3a3a3a !important; color: #f5f5f5 !important; }

/* Catalogue accents are local variables, so override them on each card too. */
html[data-zd-theme="dark"] .zd-exercise-card { --card-accent: #eee !important; --card-soft: #303030 !important; }
html[data-zd-theme="dark"] :is(#settings-panel, .zd-catalog-footer, .topic-comment, .zd-dashboard-edit-profile, .zd-live-room-entry) { background: #1b1b1b !important; color: #eee !important; border-color: #444 !important; }
html[data-zd-theme="dark"] :is(.zd-exercise-card__action, .zd-plan-features li, .zd-plan-features li span) { color: #eee !important; }
html[data-zd-theme="dark"] :is(.zd-session-logout, .zd-session-logout-label) { color: #ffb4b4 !important; }
html[data-zd-theme="dark"] .zd-subscription-status > a { background: #f5f5f5 !important; color: #111 !important; }
html[data-zd-theme="dark"] .zd-heatmap i, html[data-zd-theme="dark"] .zd-heatmap-legend i { background: #363636; }
html[data-zd-theme="dark"] :is(.zd-heatmap, .zd-heatmap-legend) i[data-count="1"] { background: #666; }
html[data-zd-theme="dark"] :is(.zd-heatmap, .zd-heatmap-legend) i[data-count="2"] { background: #999; }
html[data-zd-theme="dark"] :is(.zd-heatmap, .zd-heatmap-legend) i[data-count="3"] { background: #ccc; }
html[data-zd-theme="dark"] :is(.zd-heatmap, .zd-heatmap-legend) i[data-count="4"] { background: #f5f5f5; }
html[data-zd-theme="dark"] :is(.zd-heatmap, .zd-heatmap-legend) i.is-exam-day { background: #ffb4b4; box-shadow: inset 0 0 0 1px #925757; }
html[data-zd-theme="dark"] .oral-practice-label { background: transparent !important; }

/* Fixed chrome and detailed correction panels have stronger module selectors. */
html[data-zd-theme="dark"] body.theme-body :is(.zd-exam-header, .zd-exam-footer),
html[data-zd-theme="dark"] #footer { background: #1b1b1b !important; color: #f5f5f5 !important; border-color: #444 !important; }
html[data-zd-theme="dark"] :is(.telc-score-calculation, .writing-submitted-answer__text, .writing-answer-history__item-icon, .writing-answer-history__score, .writing-correction-dialog__heading-icon, .writing-answer-history__count) { background: #262626 !important; color: #eee !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.writing-correction-dialog__eyebrow, .writing-correction-dialog__title, .writing-submitted-answer__summary, .writing-answer-history__label, .telc-score-calculation__title, .telc-score-calculation__formula) { color: #eee !important; }
html[data-zd-theme="dark"] :is(.writing-submitted-answer__words, .telc-score-calculation__scale, .telc-score-calculation__meta) { color: #b8b8b8 !important; }
html[data-zd-theme="dark"] :is(.sim-rule-grid article, .sim-part-choice, .sim-result-certificate, .sim-score-table, .sim-group-lobby, .sim-group-tools, .sim-group-panel, .sim-group-members li, .sim-group-preferences) { background: #1b1b1b !important; color: #f5f5f5 !important; border-color: #444 !important; }
html[data-zd-theme="dark"] :is(.sim-language [aria-current], .sim-options-upgrade, .sim-result-mark, .sim-certificate-mark, .sim-group-avatar, .sim-group-invitation, .sim-group-answers dt, .sim-group-icon, .sim-group-close, .sim-group-mic.is-on, #sim-group-mic.is-on) { background: #303030 !important; color: #eee !important; border-color: #666 !important; }
html[data-zd-theme="dark"] .sim-options input { background: #444 !important; border-color: #777 !important; }
html[data-zd-theme="dark"] .sim-options input:checked { background: #eee !important; border-color: #eee !important; }
html[data-zd-theme="dark"] .sim-options input:checked::before { background: #111; }
html[data-zd-theme="dark"] .sim-score-table td, html[data-zd-theme="dark"] .sim-score-table th { border-color: #444; }
html[data-zd-theme="dark"] :is(.sim-levels > label > span, .sim-horen-types > label > span, .sim-mode-options > label > span, .sim-daily-limit) { background: #1b1b1b !important; color: #f5f5f5 !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.sim-levels, .sim-horen-types, .sim-mode-options) input:checked + span { background: #303030 !important; border-color: #aaa !important; }
html[data-zd-theme="dark"] :is(.answer-keyword-highlight, .answer-insight-keyword) { background: #fff !important; color: #000 !important; border-color: #fff !important; }
html[data-zd-theme="dark"] :is(.answer-keyword-highlight, .answer-insight-keyword) .zd-word-token { color: #000 !important; }

html[data-zd-theme="dark"] :is(.zd-catalog-search, .zd-text-search, .zd-admin-toolbar > label) input:not([type="range"]):not([type="checkbox"]):not([type="radio"]) { background: transparent !important; }

html[data-zd-theme="dark"] :is(.answer-insight-card, .zd-data-loader__label) { background: #262626 !important; border-color: #555 !important; color: #eee !important; }
html[data-zd-theme="dark"] :is(.answer-insight-title, .answer-insight-reason, .zd-data-loader__label strong) { color: #eee !important; }
html[data-zd-theme="dark"] .zd-data-loader__track { background: #333; }
html[data-zd-theme="dark"] .zd-data-loader__bar { background: #ddd; box-shadow: none; }

/* Secondary learning states: corrections, vocabulary practice and matching. */
html[data-zd-theme="dark"] .lesen-page .answer-insight-card { background: #262626 !important; color: #eee !important; border-color: #555 !important; }
html[data-zd-theme="dark"] .lesen-page :is(.answer-insight-title, .answer-insight-reason) { color: #eee !important; }
html[data-zd-theme="dark"] :is(.zd-practice-modal, .zd-admin-user-modal, .writing-correction-dialog__backdrop) { background: #0009 !important; }
html[data-zd-theme="dark"] :is(.zd-practice-card, .zd-match-live-stats, .zd-match-empty) { background: #262626 !important; color: #f5f5f5 !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.zd-practice-modal header button, .zd-practice-modal nav button, .zd-word-pagination button, .writing-correction-dialog__close, .zd-match-card-actions button, .zd-match-translation, .zd-match-grid button, .zd-match-result > div button:last-child) { background: #262626 !important; color: #eee !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.zd-practice-card > button, .zd-practice-card footer .is-correct, .zd-match-settings > button, .zd-match-result > div button, .zd-match-empty a, .writing-correction-error__action) { background: #f5f5f5 !important; color: #111 !important; border-color: #f5f5f5 !important; }
html[data-zd-theme="dark"] .zd-practice-card footer .is-wrong { background: #382020 !important; color: #ffb4b4 !important; border-color: #925757 !important; }
html[data-zd-theme="dark"] .zd-match-column article { background: #1b1b1b !important; color: #f5f5f5 !important; border-color: #555 !important; }
html[data-zd-theme="dark"] :is(.zd-match-column article.is-selected, .zd-match-grid button.is-selected) { background: #333 !important; color: #fff !important; border-color: #ddd !important; box-shadow: 0 0 0 2px #ffffff20 !important; }
html[data-zd-theme="dark"] :is(.zd-match-column article.is-matched, .zd-match-grid button.is-matched) { background: #303030 !important; color: #eee !important; border-color: #999 !important; }
html[data-zd-theme="dark"] .zd-match-column article.is-wrong { background: #382020 !important; color: #ffb4b4 !important; border-color: #d78b8b !important; }
html[data-zd-theme="dark"] .zd-match-column article.is-revealed { border-color: #bbb !important; box-shadow: inset 4px 0 #bbb !important; }
html[data-zd-theme="dark"] .zd-match-column article:hover { border-color: #aaa !important; }
html[data-zd-theme="dark"] :is(.zd-match-summary svg, .zd-match-result > svg, .zd-practice-card h3, .zd-practice-card strong, .zd-match-live-stats strong) { color: #eee !important; }
html[data-zd-theme="dark"] :is(.writing-correction-loading__title, .writing-correction-empty__title, .writing-correction-error__title) { color: #f5f5f5 !important; }
html[data-zd-theme="dark"] :is(.writing-correction-loading__copy, .writing-correction-empty__copy, .writing-correction-error__copy) { color: #b8b8b8 !important; }
html[data-zd-theme="dark"] :is(.writing-correction-loading__icon, .writing-correction-empty__icon) { background: #303030 !important; color: #eee !important; }
html[data-zd-theme="dark"] .writing-correction-error__icon { background: #382020 !important; color: #ffb4b4 !important; }
.writing-correction-dialog__shell.is-access { width: min(34rem, 100%); }
.writing-correction-access { display: grid; gap: 18px; padding: 12px 4px; font-family: "Manrope", "Noto Sans Arabic", sans-serif; }
.writing-correction-access__title { margin: 0; color: #17231f; font: 700 clamp(21px, 4vw, 26px)/1.4 "Manrope", "Noto Sans Arabic", sans-serif; }
.writing-correction-access__copy { margin: 0; color: #64716c; font-size: 16px; line-height: 1.75; }
.writing-correction-access__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 4px; }
.writing-correction-access__actions a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border: 1px solid #d8e3dc; border-radius: 12px; padding: 9px 16px; font-size: 14px; line-height: 1.5; font-weight: 700; text-decoration: none; }
.writing-correction-access__primary { background: #19694d; color: #fff; }
.writing-correction-access__secondary { background: #fff; color: #21382c; }
html[data-zd-theme="dark"] .writing-correction-access__title { color: #f5f5f5; }
html[data-zd-theme="dark"] .writing-correction-access__copy { color: #b8b8b8; }
html[data-zd-theme="dark"] .writing-correction-access__primary { background: #fff; color: #000; border-color: #fff; }
html[data-zd-theme="dark"] .writing-correction-access__secondary { background: #262626; color: #fff; border-color: #555; }
@media (max-width: 640px) { .writing-correction-access__actions a { width: 100%; box-sizing: border-box; } }

/* Admin overlays and dashboard badges have light surfaces of their own. */
html[data-zd-theme="dark"] :is(
  .zd-admin-requests, .zd-admin-user-workspace__header, .zd-admin-user-tabs,
  .zd-admin-user-workspace__content, .zd-admin-account-summary > article,
  .zd-admin-workspace-message, .zd-admin-pending-action
) { background: var(--zd-dark-surface) !important; color: var(--zd-dark-text) !important; border-color: var(--zd-dark-line) !important; }
html[data-zd-theme="dark"] :is(.zd-admin-modal-close, .zd-admin-email-history .zd-admin-user-panel__heading > button) {
  background: var(--zd-dark-soft) !important; color: var(--zd-dark-text) !important; border-color: var(--zd-dark-line) !important;
}
html[data-zd-theme="dark"] :is(
  .zd-request-list article footer > button:first-child, .zd-admin-control-card > button,
  .zd-admin-pending-action button, .zd-admin-user-identity > strong, .zd-module-card__level,
  .is-resume .zd-dash-icon
) { background: #f5f5f5 !important; color: #111 !important; border-color: #f5f5f5 !important; }
html[data-zd-theme="dark"] :is(
  .zd-request-list article footer > button:first-child, .zd-admin-control-card > button,
  .zd-admin-pending-action button, .is-resume .zd-dash-icon
) :is(span, svg, small) { color: #111 !important; }
html[data-zd-theme="dark"] .zd-request-list button.is-reject { background: #3a2222 !important; color: #ffb4b4 !important; border-color: #b86e6e !important; }
html[data-zd-theme="dark"] .zd-admin-account-summary :is(span, small) { color: var(--zd-dark-muted) !important; }

html[data-zd-theme="dark"] .zd-admin-phone a { background: #eee !important; color: #111 !important; border-color: #eee !important; }
