/* Custom modules follow Hydro's explicit theme. Light mode keeps its existing palette. */
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) {
  color-scheme: dark;
  --nf-dark-surface: #323334;
  --nf-dark-hover: #3b4249;
  --nf-dark-soft: #293f53;
  --nf-dark-control: #282c31;
  --nf-dark-text: #e9edf2;
  --nf-dark-muted: #b2bcc8;
  --nf-dark-border: #515a65;
  --nf-dark-action: #216ba3;
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) body.nf-learner {
  --nf-blue: #8fcaff;
  --nf-muted: var(--nf-dark-muted);
  --nf-green: #64d69b;
  color: var(--nf-dark-text);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-growth {
  color-scheme: dark;
  color: var(--nf-dark-text);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(
  .section__title,.nf-home-header .section__title,.nf-training-heading h1,
  .nf-chapter-title a,.nf-medal-name,.nf-medal-wrap,.nf-problem-table .col--display-id
) { color: var(--nf-dark-text); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(
  .nf-surface,.nf-training-panel,.nf-training-tools,.nf-badge,.nf-wall-detail
) {
  background: var(--nf-dark-surface);
  color: var(--nf-dark-text);
  border-color: var(--nf-dark-border);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(
  .nf-home-count,.nf-home-current-progress>span,.nf-home-empty,
  .nf-contest-time,.nf-discussion-time,.nf-discussion-node,.nf-announcement-more,
  .nf-wall-count,.nf-appearance-help,.nf-problem-table .toggle-tag
) { color: var(--nf-dark-muted); }

/* Match all rows, including native even-row and hover rules. Geometry stays shared. */
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner
:is(.nf-problem-table,.nf-contest-table,.nf-discussion-table,.nf-home-course-table).data-table > tbody > tr {
  background: var(--nf-dark-surface);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner
:is(.nf-problem-table,.nf-contest-table,.nf-discussion-table,.nf-home-course-table).data-table > tbody > tr:hover {
  background: var(--nf-dark-hover);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner
:is(.nf-problem-table,.nf-contest-table,.nf-discussion-table,.nf-home-course-table) th {
  color: var(--nf-dark-text);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .data-table > :is(thead,tbody) > tr {
  border-color: var(--nf-dark-border);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .data-table > thead > tr { background: var(--nf-dark-control); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .data-table :is(th,td) { border-color: var(--nf-dark-border); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .data-table th { color: var(--nf-dark-text); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(
  .nf-course-card,.nf-training-entry,.nf-chapter-item,.nf-course-counter,
  .nf-badge-details,.nf-pin-option,.nf-preview-slot,.nf-problem-filters,
  .nf-home-medals .nf-medal-wrap,.nf-timeline li,.nf-discussion-announcement>.section__body
) { border-color: var(--nf-dark-border); }

/* Links and filled actions use separate colors so both remain readable. */
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-button,.button.primary) {
  background: var(--nf-dark-action);
  border-color: var(--nf-dark-action);
  color: #fff;
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-button,.button.primary):hover {
  background: #287bb4;
  border-color: #8fcaff;
  color: #fff;
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-button.secondary {
  background: var(--nf-dark-control);
  border-color: var(--nf-dark-border);
  color: var(--nf-blue);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-button.secondary:hover {
  background: var(--nf-dark-hover);
  border-color: var(--nf-blue);
  color: var(--nf-blue);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-filter {
  background: var(--nf-dark-control);
  color: var(--nf-dark-text);
  border-color: var(--nf-dark-border);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-filter:is([aria-current="page"],[aria-pressed="true"]) {
  background: var(--nf-dark-soft);
  color: var(--nf-blue);
  border-color: var(--nf-blue);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-growth :is(
  .nf-form-slot select,.nf-wall-category select,.nf-appearance-select
) {
  background: var(--nf-dark-control);
  color: var(--nf-dark-text);
  border-color: var(--nf-dark-border);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-pill {
  background: var(--nf-dark-control);
  color: var(--nf-dark-muted);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-pill.current {
  background: var(--nf-dark-soft);
  color: var(--nf-blue);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-pill.complete {
  background: #254439;
  color: var(--nf-green);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-track { background: #515a65; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-track > span { background: #72b9f4; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-track.green > span { background: #55c995; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-chapter-node { background: #414850; color: var(--nf-dark-muted); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-chapter-item.current .nf-chapter-node { background: var(--nf-dark-soft); color: var(--nf-blue); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-chapter-item.done .nf-chapter-node { background: #254439; color: var(--nf-green); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-home-course-status,.nf-contest-status--ready,.nf-discussion-pin) { color: var(--nf-blue); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-home-course-status.done,.nf-contest-status--live,.nf-contest-joined,.nf-save-hint) { color: var(--nf-green); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-contest-status--done { color: var(--nf-dark-muted); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-discussion-hidden { color: #f5bc77; }

/* The search field, badges and favourite button must not keep their white fills. */
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .search.nf-problem-search {
  background: var(--nf-dark-surface);
  border-color: var(--nf-dark-border);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-search :is(input,select) { color: var(--nf-dark-text); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-search :is(.search-sort,[data-fragment-id="problem_stat"]) { border-color: var(--nf-dark-border); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-search [data-fragment-id="problem_stat"] { color: var(--nf-dark-muted); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-table .problem__tag-link {
  background: #236390;
  color: #fff !important;
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-table .problem__tag-link:hover { background: #2c76a6; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-table .star { background: var(--nf-dark-control); color: var(--nf-dark-muted); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-table .star:hover { background: var(--nf-dark-soft); color: var(--nf-blue); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-problem-table .star.activated { color: #f4c560; }

/* Keep the judgement meanings, with brighter icons on the dark surface. */
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-status--accepted { color: #64d69b; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-status--wrong-answer,.nf-status--hacked) { color: #ff8993; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .record-status--text.fail { color: #ff8993 !important; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-status--time-limit,.nf-status--compile-error) { color: #edc86b; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-status--memory-limit { color: #c8a4f5; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-status--output-limit,.nf-status--format-error) { color: #f5bc77; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-status--runtime-error { color: #f798c2; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-status--system-error,.nf-status--unknown,.nf-status--waiting,.nf-status--ignored) { color: var(--nf-dark-muted); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-status--judging,.nf-status--compiling) { color: var(--nf-blue); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner #status .section__title>span[style] { color: var(--nf-dark-text) !important; }

/* The reveal fade must blend into its parent instead of painting a white strip. */
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .collapsible-content::after {
  background: linear-gradient(to bottom,transparent,var(--nf-profile-surface,var(--nf-dark-surface)));
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-wall-detail::backdrop { background: #0009; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-medal { --nf-medal-ink: color-mix(in srgb,var(--nf-medal) 60%,#fff); color: var(--nf-medal-ink); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-badge-art { color: color-mix(in srgb,var(--nf-medal,var(--nf-blue)) 60%,#fff); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-medal .nf-medal-plate {
  background: linear-gradient(145deg,#282c31,color-mix(in srgb,var(--nf-medal) 18%,#282c31));
  border-color: var(--nf-medal-ink);
  box-shadow: 0 3px 0 color-mix(in srgb,var(--nf-medal-ink) 55%,#282c31);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-medal .nf-medal-plate::after {
  border-color: color-mix(in srgb,var(--nf-medal) 55%,#282c31);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-medal::before,
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-medal::after { background: var(--nf-medal-ink); }

html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nav__logo { filter: invert(1); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner
:is(.nf-problem-table,.nf-contest-table,.nf-discussion-table,.nf-home-course-table) > thead > tr { background: var(--nf-dark-control); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(input,textarea)::placeholder { color: var(--nf-dark-muted); opacity: 1; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .section__body label { color: var(--nf-dark-muted); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner :is(.nf-growth label,.section.side dt,.help-text) { color: var(--nf-dark-muted); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .pager__item.current { color: #ffa1bd !important; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .menu__link.active,
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile .menu__link.active { background: #913450; color: #fff; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .record-status--text:is(.pass,.accepted) { color: var(--nf-green) !important; }

/* Retain each profile's accent, custom cover and authored biography. */
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile {
  --nf-profile-surface: #202a38;
  --nf-profile-text: #e6edf5;
  --nf-profile-muted: #acb9c9;
  --nf-profile-border: #354255;
  --nf-accent: #89bdf0;
  --nf-accent-soft: #29384b;
  color: var(--nf-profile-text);
}
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile-theme-forest { --nf-accent: #74cfaf; --nf-accent-soft: #263d39; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile-theme-sunset { --nf-accent: #efb08c; --nf-accent-soft: #42372e; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile-theme-violet { --nf-accent: #c9aaf1; --nf-accent-soft: #38304a; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile-theme-graphite { --nf-accent: #b8c6d5; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile .section__title { color: var(--nf-profile-text); }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile-day.active { color: #18202a; }
html:is(.theme--dark,[data-mantine-color-scheme="dark"]) .nf-learner .nf-profile .nf-profile-bio .section__tab-container .section__tab-header-item.selected {
  background: var(--nf-accent-soft);
  color: var(--nf-accent);
}
