/* [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 .ui-menu .ui-menu-item-wrapper {
    color: var(--app-text);
    background: var(--app-surface);
}
html[data-theme="dark"] .stats_searchable_menu .ui-menu .ui-menu-item-wrapper:is(
    .ui-state-active, .ui-state-focus, .ui-state-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; }
