/* Graphite and lime: trainer and material editor color overrides.
   Keep this sheet after their component styles. Layout and light mode stay intact. */
[data-theme="dark"] .trainer-app {
  --paper: inherit;
  --white: inherit;
  --ink: inherit;
  --muted: inherit;
  --line: inherit;
  --lime: inherit;
  --soft: var(--lime-soft);
  --error: #f0ad99;
  --trainer-good-bg: #293c22;
  --trainer-good-line: #59794a;
  --trainer-error-bg: #412b24;
  --trainer-error-line: #865b49;
  color-scheme: dark;
}

[data-theme="dark"] .trainer-app a,
[data-theme="dark"] .trainer-app .wordmark span,
[data-theme="dark"] .trainer-app .text-button,
[data-theme="dark"] .trainer-app .back-button,
[data-theme="dark"] .trainer-app .search-result button {
  color: var(--lime);
}
[data-theme="dark"] .trainer-app .text-button:hover { color: #d7ff85; }
[data-theme="dark"] .trainer-app :focus-visible { outline-color: var(--lime); }
[data-theme="dark"] .trainer-app input:is([type="checkbox"], [type="radio"]),
[data-theme="dark"] .trainer-app progress { accent-color: var(--lime); }
[data-theme="dark"] .trainer-app .top-section { border-color: var(--line); }
[data-theme="dark"] .trainer-app .tabs button[aria-selected="true"] { border-color: var(--lime); }

/* Builder, history and session surfaces. */
[data-theme="dark"] .trainer-entry,
[data-theme="dark"] .trainer-app :is(.skip, .topic-card, .setup-panel, .question, .task-nav, .result-panel, .history-row),
[data-theme="dark"] .trainer-app .numbers button {
  background: var(--white);
  color: var(--ink);
}
[data-theme="dark"] .trainer-app .setup-panel { box-shadow: 0 7px 24px #00000018; }
[data-theme="dark"] .trainer-app :is(.tabs span, .topic-chevron:hover) { background: var(--theme-raised); }
[data-theme="dark"] .trainer-app .tabs button[aria-selected="true"] span,
[data-theme="dark"] .trainer-app .button.lime {
  background: var(--lime);
  color: var(--theme-on-accent);
}
[data-theme="dark"] .trainer-app .button.lime:hover:not(:disabled) {
  background: #d0fa71;
  border-color: #d0fa71;
}
[data-theme="dark"] .trainer-app .button.outline { border-color: var(--line); }
[data-theme="dark"] .trainer-app .button.outline:hover:not(:disabled) { background: var(--theme-raised); }
[data-theme="dark"] .trainer-app :is(.subtopic-list, .mode-rule, .task-example, .run-output, .launch-expected) {
  background: var(--paper);
  color: var(--ink);
}
[data-theme="dark"] .trainer-app .presets button[aria-pressed="true"],
[data-theme="dark"] .trainer-app .resume-banner {
  border-color: #647e38;
  background: var(--soft);
}
[data-theme="dark"] .trainer-app :is(.custom-count input, .matching-row select, textarea.output-answer, .custom-form textarea, .custom-form select),
[data-theme="dark"] .trainer-app dialog input {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
}
[data-theme="dark"] .trainer-app ::placeholder { color: var(--muted); opacity: 1; }
[data-theme="dark"] .trainer-app .error {
  color: var(--error) !important;
  background: var(--trainer-error-bg);
}

/* Answer selection and feedback remain distinguishable without bright panels. */
[data-theme="dark"] .trainer-app .answer-option:has(input:checked) {
  background: var(--soft);
  border-color: #8da956;
}
[data-theme="dark"] .trainer-app .answer-option.right,
[data-theme="dark"] .trainer-app .feedback,
[data-theme="dark"] .trainer-app .numbers button.correct {
  background: var(--trainer-good-bg);
  border-color: var(--trainer-good-line);
}
[data-theme="dark"] .trainer-app .answer-option.wrong,
[data-theme="dark"] .trainer-app .feedback.incorrect,
[data-theme="dark"] .trainer-app .numbers button.incorrect {
  background: var(--trainer-error-bg);
  border-color: var(--trainer-error-line);
}
[data-theme="dark"] .trainer-app .numbers button.drafted {
  background: #24343f;
  border-color: #546f82;
}
[data-theme="dark"] .trainer-app .numbers button.current { outline-color: var(--lime); }
[data-theme="dark"] .trainer-app .progress-track { background: var(--line); }
[data-theme="dark"] .trainer-app .progress-track span { background: var(--lime); }
[data-theme="dark"] .trainer-app .hint-box {
  background: var(--soft);
  border-color: #8da956;
}
[data-theme="dark"] .trainer-app .practice-note {
  background: #24343f;
  color: #c1d5e2;
  border-color: #465e6e;
}

/* Database tables and execution results. */
[data-theme="dark"] .trainer-app .database-panel,
[data-theme="dark"] .trainer-app .data-table :is(th, td) { border-color: var(--line); }
[data-theme="dark"] .trainer-app :is(.database-heading, .data-table th) { background: var(--theme-raised); }
[data-theme="dark"] .trainer-app .data-table tbody tr:nth-child(even) { background: var(--paper); }
[data-theme="dark"] .trainer-app .database-tabs button[aria-selected="true"] {
  background: var(--soft);
  border-color: #8da956;
}
[data-theme="dark"] .trainer-app .null-value { color: var(--muted); }
[data-theme="dark"] .trainer-app .relation span,
[data-theme="dark"] .trainer-app .console-heading,
[data-theme="dark"] .trainer-app .check-case > summary > strong { color: var(--theme-good); }
[data-theme="dark"] .trainer-app .console-text,
[data-theme="dark"] .trainer-app .check-body pre { color: var(--ink); }
[data-theme="dark"] .trainer-app .console-error,
[data-theme="dark"] .trainer-app .check-failed > summary > strong { color: var(--error); }
[data-theme="dark"] .trainer-app .check-case {
  background: var(--white);
  border-color: var(--trainer-good-line);
}
[data-theme="dark"] .trainer-app .check-case.check-failed { border-color: var(--trainer-error-line); }
[data-theme="dark"] .trainer-app .check-comparison > div { background: var(--trainer-good-bg); }
[data-theme="dark"] .trainer-app .check-failed .check-comparison > div:last-child { background: var(--trainer-error-bg); }

/* Live code overlays, rendered code, and Pygments token families. */
[data-theme="dark"] .trainer-app :is(.code-editor, .code-panel, .launch-editor) {
  background: var(--theme-code);
  border-color: var(--line);
}
[data-theme="dark"] .trainer-app .highlight {
  background: var(--theme-code) !important;
  border-color: var(--line);
  color: var(--ink);
}
[data-theme="dark"] .trainer-app :is(.highlight pre, .code-editor pre, .launch-editor) { color: var(--ink); }
[data-theme="dark"] .trainer-app .code-editor textarea { caret-color: var(--lime); }
[data-theme="dark"] .trainer-app .code-toolbar { background: var(--paper); border-color: var(--line); }
[data-theme="dark"] .trainer-app .copy-code {
  color: var(--ink);
  background: var(--theme-raised);
  border-color: #56634b;
}
[data-theme="dark"] .trainer-app .copy-code:hover { background: #35422e; border-color: #8da956; }
[data-theme="dark"] .trainer-app .copy-code:focus-visible { outline-color: var(--lime); }
[data-theme="dark"] .trainer-app .copy-status { color: var(--theme-good); }
[data-theme="dark"] .trainer-app .code-editor textarea::selection,
[data-theme="dark"] .trainer-app .highlight pre::selection,
[data-theme="dark"] .trainer-app .highlight pre *::selection {
  background: #405326;
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
}
[data-theme="dark"] .trainer-app .highlight :is(.g, .ge, .ges, .gh, .go, .gp, .gs, .gu, .gt, .l, .ld, .n, .nb, .nc, .ni, .ne, .nl, .nn, .nx, .py, .nt, .nv, .o, .ow, .p, .pm, .w, .bp, .vc, .vg, .vi, .vm) { color: var(--ink); }
[data-theme="dark"] .trainer-app :is(.highlight, .code-editor) :is(.kw, .k, .kc, .kd, .kn, .kp, .kr, .kt, .se) { color: var(--orange); }
[data-theme="dark"] .trainer-app :is(.highlight, .code-editor) :is(.str, .s, .sa, .sb, .sc, .dl, .sd, .s2, .sh, .si, .sx, .sr, .s1, .ss) { color: var(--theme-good); }
[data-theme="dark"] .trainer-app :is(.highlight, .code-editor) :is(.num, .m, .mb, .mf, .mh, .mi, .mo, .il) { color: var(--theme-blue); }
[data-theme="dark"] .trainer-app :is(.highlight, .code-editor) :is(.comment, .c, .ch, .cm, .cpf, .c1, .cs) { color: var(--muted); }
[data-theme="dark"] .trainer-app .highlight :is(.na, .no) { color: var(--theme-pink); }
[data-theme="dark"] .trainer-app .highlight :is(.cp, .nd, .nf, .fm) { color: #dce58d; }
[data-theme="dark"] .trainer-app .highlight :is(.err, .gr, .gd) { color: var(--error); }
[data-theme="dark"] .trainer-app .highlight .gi { color: var(--theme-good); }
[data-theme="dark"] .trainer-app .highlight .hll,
[data-theme="dark"] .trainer-app :is(td.linenos, span.linenos) .special,
[data-theme="dark"] .trainer-app span.linenos.special { background: #384328; color: var(--ink); }

/* Trainer dialogs, transient warnings and custom question forms. */
[data-theme="dark"] .trainer-app dialog {
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 20px 60px #00000066;
}
[data-theme="dark"] .trainer-app dialog::backdrop { background: #080c08b3; }
[data-theme="dark"] .trainer-app .storage-warning {
  background: #3d3420;
  color: #eddbb1;
  border-color: #806c3c;
}

/* Material editing and revision history. */
[data-theme="dark"] .editor-context,
[data-theme="dark"] .editor-field-heading > span,
[data-theme="dark"] .material-editor .help,
[data-theme="dark"] .editor-save-status,
[data-theme="dark"] .editor-history li .editor-history-author { color: var(--muted); }
[data-theme="dark"] .material-editor label,
[data-theme="dark"] .editor-aside p,
[data-theme="dark"] .editor-aside dd,
[data-theme="dark"] .editor-help summary { color: var(--ink); }
[data-theme="dark"] .editor-toolbar {
  background: var(--theme-raised);
  border-color: #56634b;
}
[data-theme="dark"] .editor-toolbar button {
  color: var(--ink);
  background: var(--white);
  border-color: #56634b;
}
[data-theme="dark"] .editor-toolbar button:hover { background: var(--soft, var(--lime-soft)); border-color: #8da956; }
[data-theme="dark"] .editor-toolbar button:focus-visible { outline-color: var(--lime); }
[data-theme="dark"] .material-editor textarea[name="content"] {
  color: var(--ink);
  background: var(--theme-code);
  border-color: #667558;
  caret-color: var(--lime);
}
[data-theme="dark"] .material-editor textarea:focus { outline-color: var(--lime); }
[data-theme="dark"] .editor-save-bar,
[data-theme="dark"] .editor-history li + li { border-color: var(--line); }
[data-theme="dark"] .editor-save-status.is-dirty { color: var(--orange); }
[data-theme="dark"] .editor-note { background: var(--lime-soft); border-color: #506535; }
[data-theme="dark"] .editor-help code { color: var(--theme-good); background: var(--theme-code); }
[data-theme="dark"] .editor-history li a { color: var(--ink); }
[data-theme="dark"] .editor-history li a:hover strong { color: var(--lime); }
[data-theme="dark"] .editor-history-notice,
[data-theme="dark"] .editor-conflict {
  background: #3d3420;
  border-color: #806c3c;
  color: #eddbb1;
}
[data-theme="dark"] .editor-conflict a { color: var(--orange); }
