/* [CG] SYNGLI-7040 theme controls and surfaces without recolouring authored media. */
/* [CL] SYNGLI-7037 the question area blends into the page, as it does in light mode (white on white); a
   surface colour showed an empty lighter block until the question loaded */
html[data-theme="dark"] #question {
    background: transparent;
    color: var(--app-text);
}
html[data-theme="dark"] .learn-footer {
    background: var(--app-surface-secondary);
    color: var(--app-text);
    border-top: 1px solid var(--app-border);
}
html[data-theme="dark"] :is(.playback-speed-toggle,
    .svg-tracing-options-button, .svg-tracing-demo,
    .handwriting-letter-tab, .tutor_context_premise_badge,
    .pc-quick-review-passage, .spoken-fib-recorder) {
    background: var(--app-surface-secondary);
    color: var(--app-text-secondary);
    border-color: var(--app-border);
}
html[data-theme="dark"] :is(.handwriting-letter-tab[aria-pressed="true"],
    .handwriting-letter-tab:hover, .svg-tracing-options input:checked + span) {
    background: var(--app-selection);
    color: var(--app-action);
    border-color: var(--app-focus);
}
html[data-theme="dark"] .handwriting-viewport[data-vertical-trim],
html[data-theme="dark"] canvas[data-svg-tracing-mode] {
    background-color: #1e232a;
    box-shadow: inset 0 0 0 1px #505b68;
}
html[data-theme="dark"] .handwriting-viewport[data-vertical-trim] > canvas {
    background-color: transparent;
    box-shadow: none;
}
html[data-theme="dark"] .syngli-modal-body .svg-tracing-option-row {
    color: var(--app-text);
    border-color: var(--app-divider);
}
html[data-theme="dark"] :is(.svg-tracing-progress, .handwriting-sections,
    .question_type, #cue_card_header, #cue_card_footer,
    .instruction_hide_option, .tutor_context_premise_text) {
    color: var(--app-text-secondary);
}
/* [CL] SYNGLI-7037 True/False buttons turn white (!important) on hover and focus, so a clicked button stayed
   white; dark mode uses the hover surface, and the correct-answer colours must beat that rule too */
html[data-theme="dark"] .tf-question-buttons:is(:focus, :active, :hover):not(.button-correct-background,
    .button-incorrect-background) {
    background-color: var(--app-hover) !important;
    color: var(--app-text);
}
html[data-theme="dark"] .button-correct-background {
    background: var(--app-success-surface) !important;
    color: var(--app-success);
}
html[data-theme="dark"] .button-incorrect-background {
    background: var(--app-error-surface) !important;
    color: var(--app-error);
}
/* [CL] SYNGLI-7037 True/False and Multiple Choice option borders: light grey dots and dark grey for the choice */
html[data-theme="dark"] :is(.button-unselected, .mc_option_unselected) {
    border-color: var(--app-border) !important;
}
html[data-theme="dark"] :is(.button-selected, .button-entered, .mc_option_selected, .mc_option_entered) {
    border-color: var(--app-text-secondary) !important;
}
html[data-theme="dark"] :is(.fib.input_response, .pc.input_response) {
    /* [CG] Match the existing important rule for typed-answer underlines. */
    border-bottom-color: var(--app-border) !important;
}
/* [CL] SYNGLI-7078 typed answers were dark grey (#575757) on the dark page, with or without the highlight */
html[data-theme="dark"] #question :is(input.fib, input.pc, #fib_user_correct) {
    color: var(--app-text);
}

/* [CG] An empty question surface must not leave a band below instructions. */
html[data-theme="dark"] body.course-instructions-visible #question {
    background: transparent;
}

/* [CL] SYNGLI-7037 on-screen keyboard: the keyboard library's light keys kept the page's light text */
html[data-theme="dark"] .syngli_simple_keyboard_container {
    background: var(--app-surface-elevated);
    border-color: var(--app-border);
    box-shadow: var(--app-shadow);
}
html[data-theme="dark"] .syngli_simple_keyboard_handle { color: var(--app-text-secondary); }
html[data-theme="dark"] .syngli_simple_keyboard_close { background: transparent; color: var(--app-text-muted); }
html[data-theme="dark"] .syngli_simple_keyboard_close:is(:hover, :focus) { color: var(--app-text); }
html[data-theme="dark"] .syngli_simple_keyboard_container .hg-theme-default {
    background-color: var(--app-surface);
}
html[data-theme="dark"] .syngli_simple_keyboard_container .hg-theme-default .hg-button {
    background: var(--app-surface-secondary);
    border-bottom-color: var(--app-page);
    box-shadow: none;
    color: var(--app-text);
}
html[data-theme="dark"] .syngli_simple_keyboard_container .hg-theme-default .hg-button.hg-activeButton {
    background: var(--app-hover-strong);
}
html[data-theme="dark"] .syngli_simple_keyboard_container .hg-theme-default .hg-button.syngli_simple_keyboard_pressed {
    background: #4f8fd9;
    color: #fff;
}
/* [CL] SYNGLI-7067 the spoken-response record button: theme blue when idle, red while recording, white icon */
html[data-theme="dark"] [id*=audio-recordbtn] {
    background-color: var(--app-primary-button);
    color: #fff !important;
}
html[data-theme="dark"] [id*=audio-recordbtn]:hover {
    background-color: var(--app-primary-button-hover);
}
html[data-theme="dark"] [id*=audio-recordbtn].is-recording {
    background-color: #c9302c;
}

/* [CL] SYNGLI-7037 answer stamps: the same error and success tones as other dark feedback */
html[data-theme="dark"] #incorrect_symbol {
    border-color: var(--app-error);
    color: var(--app-error);
}
html[data-theme="dark"] #correct_symbol {
    border-color: var(--app-success);
    color: var(--app-success);
}
/* [CL] SYNGLI-7037 cue and item text was set to #575757 for light pages */
html[data-theme="dark"] #question .item:not(img) { color: var(--app-text); }
html[data-theme="dark"] #question .underline { border-bottom-color: var(--app-text-secondary); }
/* [CL] SYNGLI-7037 authored text colours (<c=...>) and highlights (<h=...>) keep their hue but are lightened, or
   darkened for highlights, so dark blue or black text stays readable on dark pages */
html[data-theme="dark"] .authored-colour {
    color: color-mix(in oklab, var(--authored-colour) 45%, #fff) !important;
}
html[data-theme="dark"] .authored-highlight {
    background-color: color-mix(in oklab, var(--authored-highlight) 40%, #000) !important;
}
/* [CL] SYNGLI-7037 passive presentation item highlights were bright cyan and lime under light text; keep the hue,
   darkened like authored highlights */
html[data-theme="dark"] .hi-lite-blue {
    background-color: color-mix(in oklab, rgb(13, 213, 252) 40%, #000);
    color: var(--app-text);
}
html[data-theme="dark"] .hi-lite-yellow {
    background-color: color-mix(in oklab, rgb(222, 244, 64) 35%, #000);
    color: var(--app-text);
}
/* [CL] SYNGLI-7037 segment highlights: stronger tints on dark pages, and the alternating text colours were dark grey
   and dark blue */
html[data-theme="dark"] #question.pp-segmentation-boundaries-on.pp-segmentation-style-highlight_amber .pp-segment-item-content,
html[data-theme="dark"] #question.pp-segmentation-boundaries-on.pp-segmentation-style-highlight_alternating
    .pp-segment-item-boundary-odd .pp-segment-item-content {
    background-color: rgba(255, 214, 102, 0.22);
}
html[data-theme="dark"] #question.pp-segmentation-boundaries-on.pp-segmentation-style-highlight_turquoise .pp-segment-item-content,
html[data-theme="dark"] #question.pp-segmentation-boundaries-on.pp-segmentation-style-highlight_alternating
    .pp-segment-item-boundary-even .pp-segment-item-content {
    background-color: rgba(64, 178, 220, 0.25);
}
html[data-theme="dark"] #question.pp-segmentation-boundaries-on.pp-segmentation-style-text_alternating
    .pp-segment-item-boundary-odd :is(.pp-segment-item-content, .pp-segment-item-content .item:not(img)) {
    color: var(--app-text);
}
html[data-theme="dark"] #question.pp-segmentation-boundaries-on.pp-segmentation-style-text_alternating
    .pp-segment-item-boundary-even :is(.pp-segment-item-content, .pp-segment-item-content .item:not(img)) {
    color: #6cc4e6;
}
/* [CL] SYNGLI-7037 handwriting answer buttons: Check uses the dark primary blue, Clean the secondary style */
html[data-theme="dark"] :is(#check_btn, #start-btn) {
    background-color: var(--app-primary-button);
    border-color: var(--app-primary-button);
    color: #fff;
}
html[data-theme="dark"] :is(#check_btn, #start-btn):is(:hover, :focus) {
    background-color: var(--app-primary-button-hover);
    border-color: var(--app-primary-button-hover);
}
html[data-theme="dark"] #cleanbtn {
    background-color: var(--app-surface-secondary);
    border-color: var(--app-border);
    color: var(--app-text);
}
html[data-theme="dark"] #cleanbtn:is(:hover, :focus) { background-color: var(--app-hover); }
/* [CL] SYNGLI-7037 Tutor performance bars: titles and labels were dark grey with a white glow */
html[data-theme="dark"] :is(#progress_bar1, #progress_bar2) {
    color: var(--app-text);
    text-shadow: none;
}
html[data-theme="dark"] :is(#progress_bar1, #progress_bar2) .graph_title h4 { color: var(--app-text); }
html[data-theme="dark"] :is(#progress_bar1, #progress_bar2) .nr-progress-bar-label {
    color: var(--app-text);
    text-shadow: 0 0 4px rgb(0 0 0 / 75%);
}
