/* [CG] SYNGLI-7041 leave metric series colours intact and adapt chart furniture. */
html[data-theme="dark"] :is(.gauge__center, .gauge__cover,
    .stats_searchable_menu, .stats-handwriting-viewport,
    .stats-handwriting-controls, .handwriting-review-summary,
    .handwriting-review-advice, .handwriting-review-disclosure,
    .stats-evaluation-threshold, .stats-evaluation-result,
    .stats-evaluation-table-wrap, .ar_review_question_panel,
    .date_slider, .date_slider_handle, .graph_title > h3) {
    color: var(--app-text);
    background-color: var(--app-surface);
    border-color: var(--app-border);
    text-shadow: none;
}
html[data-theme="dark"] :is(.gauge__background, .gauge__marker,
    .handwriting-review-mark-note) { background-color: var(--app-surface-secondary); }
html[data-theme="dark"] :is(.stats-handwriting-review,
    .handwriting-review-heading, .handwriting-review-disclosure > summary,
    .handwriting-review-metric-value, .handwriting-review-settings dd,
    .stats-evaluation-help, .stats-evaluation-result,
    .gauge__text, .gauge__label, .gauge__value_text) { color: var(--app-text); }
html[data-theme="dark"] :is(.handwriting-review-metric-label,
    .handwriting-review-settings dt, .handwriting-evaluation-key,
    .handwriting-review-note, .stats-handwriting-controls label) {
    color: var(--app-text-secondary);
}
html[data-theme="dark"] :is(.history .settings, .history .settings-panel) {
    color: var(--app-text);
    background-color: var(--app-surface);
    border-color: var(--app-divider);
}
html[data-theme="dark"] :is(.dc-chart .axis text, .dc-chart .chart-label,
    .dc-chart .pie-slice text, .dc-chart text.pie-slice) {
    /* [CG] Existing chart CSS uses important for the axis labels too. */
    fill: var(--app-text-secondary) !important;
}
html[data-theme="dark"] :is(.dc-chart .axis path, .dc-chart .axis line,
    .dc-chart .grid-line line) { stroke: var(--app-border) !important; }
html[data-theme="dark"] .stats_searchable_menu .syngli_menu_select_option {
    color: var(--app-text);
    background: var(--app-surface);
}
html[data-theme="dark"] .stats_searchable_menu .syngli_menu_select_option:is(.is_active, :hover) {
    color: var(--app-text);
    background: var(--app-selection);
    border-color: var(--app-focus);
}
html[data-theme="dark"] :is(.stats_user_network_preview,
    .stats_user_network_overflow, .stats_user_network_badge,
    .stats_other_courses_badge) { color: var(--app-text-secondary); }
html[data-theme="dark"] :is(.stats_tabs > li > a, .stats_button_default,
    .stats_side_menu_header) {
    background: var(--app-surface);
    color: var(--app-text);
    border-color: var(--app-border);
}
html[data-theme="dark"] .stats_tabs > li.active > a {
    background: var(--app-selection);
}
html[data-theme="dark"] :is(.course_name_in_history_tab_text,
    .history_course_close_button, .history h2, .history h3, .history h4,
    .history label, .history .user_name, .history .network_name,
    .gauge__label--average, .gauge__label--low, .gauge__label--high) {
    color: var(--app-text);
}
html[data-theme="dark"] :is(.stats_muted_text, .history .settings_title,
    .history .stats_study_time, .history .stats_setting_label,
    .history_section_title, .section_heading, #minRPS p,
    #sessions_subtitle, #study_time_label) {
    color: var(--app-text-secondary);
}
html[data-theme="dark"] .graph_container .graph_title > h3 {
    color: var(--app-text-secondary);
    box-shadow: none;
}
html[data-theme="dark"] .history {
    --stats-title-border: var(--app-divider);
    --stats-title-background: var(--app-surface-secondary);
}

/* [CG] SVG review colours update live without restarting replay or selection. */
html[data-theme="dark"] .stats-handwriting-review {
    --handwriting-review-guide: #7fa6dd;
    --handwriting-review-ink: #f1f4f8;
    --handwriting-review-line: #3a414b;
    --handwriting-review-missing: #c879ee;
    --handwriting-review-outside: #f5a14e;
}
html[data-theme="dark"] .handwriting-review-swatch.guide { background: #7fa6dd; }
html[data-theme="dark"] .handwriting-review-swatch.writing { background: #f1f4f8; }
html[data-theme="dark"] .handwriting-review-swatch.missing { background: #c879ee; }
html[data-theme="dark"] .handwriting-review-swatch.outside { background: #f5a14e; }

/* [CL] SYNGLI-7037 Included practice pop-up: relation headings and course rows */
html[data-theme="dark"] .stats_history_sources_summary { color: var(--app-text-secondary); }
html[data-theme="dark"] .stats_history_relation { border-color: var(--app-border); }
html[data-theme="dark"] .stats_history_relation h4 {
    background: var(--app-surface-secondary);
    color: var(--app-text);
}
html[data-theme="dark"] .stats_history_courses li { border-top-color: var(--app-divider); }

/* [CL] SYNGLI-7037 Clarity graph: title bar, side panels and the zoom/pan control */
html[data-theme="dark"] .graph_container .graph_title.clarity_header > h3 {
    background: var(--app-surface-secondary);
    border-color: var(--app-divider);
}
html[data-theme="dark"] :is(.graph_stats, .graph_options) { color: var(--app-text-secondary); }
html[data-theme="dark"] #clarity_connection_count { color: var(--app-text-muted); }
html[data-theme="dark"] :is(#confusability_premise, #confusability_target, #confusability_source) {
    background: var(--app-surface);
    border-color: var(--app-border);
}
html[data-theme="dark"] #clarity_evidence_summary {
    background: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text-secondary);
}
html[data-theme="dark"] .confusability_button.btn { border-color: var(--app-border); }
html[data-theme="dark"] :is(.cy-panzoom-zoom-button, .cy-panzoom-slider-background,
    .cy-panzoom-slider-handle, .cy-panzoom-panner) {
    background: var(--app-surface-secondary);
    border-color: var(--app-border);
    color: var(--app-text-secondary);
}
html[data-theme="dark"] :is(.cy-panzoom-zoom-button:active, .cy-panzoom-slider-handle:active,
    .cy-panzoom-slider-handle.active) { background: var(--app-hover-strong); }
html[data-theme="dark"] .cy-panzoom { color: var(--app-text-secondary); }
html[data-theme="dark"] .cy-panzoom-pan-up { border-bottom-color: var(--app-text-secondary); }
html[data-theme="dark"] .cy-panzoom-pan-down { border-top-color: var(--app-text-secondary); }
html[data-theme="dark"] .cy-panzoom-pan-left { border-right-color: var(--app-text-secondary); }
html[data-theme="dark"] .cy-panzoom-pan-right { border-left-color: var(--app-text-secondary); }
html[data-theme="dark"] .cy-panzoom-no-zoom-tick {
    background: var(--app-text-secondary);
    border-color: var(--app-surface-secondary);
}

/* [CL] SYNGLI-3686 All and None network tiles in dark mode */
html[data-theme="dark"] .network_container > .stats_network_placeholder_all {
    background: var(--app-surface-secondary);
    color: var(--app-text-muted);
}
html[data-theme="dark"] .network_container > .stats_network_placeholder_none {
    border-color: var(--app-divider);
    color: var(--app-text-muted);
}
/* [CL] SYNGLI-7037 the Response evaluation pop-up's table (ResponseID, Response, Target, Result, Score, Tolerance,
   dates, Evaluator): its header row, cells and editable scores were still light in dark mode */
html[data-theme="dark"] #response_scores_table :is(th, td) {
    color: var(--app-text);
    border-color: var(--app-border);
}
html[data-theme="dark"] #response_scores_table th { background: var(--app-surface-secondary); }
html[data-theme="dark"] #response_scores_table select.score_span {
    color: var(--app-text);
    background: var(--app-surface);
    border-color: var(--app-border);
}
html[data-theme="dark"] .stats-evaluation-changed { background: var(--app-selection); }
html[data-theme="dark"] .score_span[contenteditable="true"] {
    color: var(--app-text);
    background: var(--app-surface);
    border-color: var(--app-border);
}
html[data-theme="dark"] .score_span[contenteditable="true"]:is(:hover, :focus) {
    background: var(--app-selection);
    border-color: var(--app-focus);
}
html[data-theme="dark"] .syngli-eval_edit_icon { color: var(--app-text-secondary); }
html[data-theme="dark"] .stats-eval-divider { border-top-color: var(--app-divider); }
