/* Shared by the teacher, student and guest home views. Light and print stay unchanged. */
@media screen {
  html[data-bs-theme="dark"] {
    --app-bg: #0c1220;
    --app-surface: #141e30;
    --app-surface-muted: #1b2940;
    --app-text: #edf2fa;
    --app-text-muted: #aab9ce;
    --app-border: #2c3d56;
    --app-accent: #a4c8ff;
    --app-focus: #b5d3ff;
    --home-blue-soft: #203657;
    --bs-secondary-color: #aab9ce;
    --bs-secondary-color-rgb: 170, 185, 206;
    --bs-tertiary-bg: #1b2940;
    --bs-emphasis-color: #edf2fa;
  }
  html[data-bs-theme="dark"] body.page-home {
    background-image: radial-gradient(ellipse 80% 520px at 50% 0, #172641 0%, transparent 100%);
    background-color: var(--app-bg);
    background-repeat: no-repeat;
    color: var(--app-text);
  }
  html[data-bs-theme="dark"] .page-home .app-navbar {
    background: rgb(12 18 32 / 86%) !important;
  }
  html[data-bs-theme="dark"] .page-home .app-navbar .navbar-shell {
    background: rgb(20 30 48 / 90%);
    border-color: #2c3d56;
    box-shadow: 0 8px 28px rgb(0 0 0 / 14%);
  }

  /* First impression: a quiet, illuminated surface rather than a solid color slab. */
  html[data-bs-theme="dark"] :is(.dashboard-hero, .student-hero, .home-welcome) {
    background: radial-gradient(ellipse at 95% 0, rgb(85 130 224 / 18%), transparent 60%),
      linear-gradient(120deg, #192840, #131d31 65%, #1d2542) !important;
    border: 1px solid #344968;
    color: var(--app-text);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 4%), 0 18px 50px rgb(0 0 0 / 20%);
  }
  html[data-bs-theme="dark"] .dashboard-hero {
    background: radial-gradient(ellipse at 95% 0, rgb(96 165 250 / 9%), transparent 60%),
      linear-gradient(120deg, #1c2940, #192c32) !important;
    border-color: #34495a;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 3%), 0 12px 32px rgb(0 0 0 / 16%);
  }
  html[data-bs-theme="dark"] .dashboard-hero::before { background: rgb(96 165 250 / 7%); }
  html[data-bs-theme="dark"] .dashboard-hero::after { background: rgb(45 212 191 / 5%); }
  html[data-bs-theme="dark"] .student-hero::after { background: rgb(164 200 255 / 6%); }
  html[data-bs-theme="dark"] :is(.dashboard-hero__title, .dashboard-action-card__title,
    .lesson-row__title, .unit-detail-panel .unit-detail-title, .feature-title) { color: var(--app-text); }
  html[data-bs-theme="dark"] :is(.dashboard-hero__subtitle, .dashboard-hero__date,
    .dashboard-action-card__text, .dashboard-action-card__eyebrow, .lesson-row__meta,
    .feature-text) { color: var(--app-text-muted); }
  html[data-bs-theme="dark"] .dashboard-hero__branch-badge {
    background: #25394b;
    border-color: #40596c;
    color: #d2e4f3;
  }
  html[data-bs-theme="dark"] .dashboard-hero__btn {
    --bs-btn-bg: #3768cb;
    --bs-btn-border-color: #5886de;
    --bs-btn-hover-bg: #4277df;
    --bs-btn-hover-border-color: #8bb4ff;
    --bs-btn-active-bg: #315db6;
    box-shadow: 0 5px 18px rgb(28 66 145 / 25%);
  }

  /* Each action retains its identity, with restrained tinted surfaces. */
  html[data-bs-theme="dark"] .dashboard-action-card {
    --home-card-accent: #a4c8ff;
    --home-card-tint: #1e3456;
    --home-card-edge: #365988;
    background: radial-gradient(ellipse at 100% 0, var(--home-card-tint), transparent 65%),
      linear-gradient(145deg, #172236, #121c2d);
    border-color: #2a3a52;
    box-shadow: 0 8px 24px rgb(0 0 0 / 16%) !important;
    backdrop-filter: none;
  }
  html[data-bs-theme="dark"] .dashboard-action-card.card-theme-danger {
    --home-card-accent: #ffadbb; --home-card-tint: #392633; --home-card-edge: #754253;
  }
  html[data-bs-theme="dark"] .dashboard-action-card.card-theme-secondary {
    --home-card-accent: #c4b9ff; --home-card-tint: #2d2b49; --home-card-edge: #595180;
  }
  html[data-bs-theme="dark"] .dashboard-action-card.card-theme-success {
    --home-card-accent: #8be0c0; --home-card-tint: #193c38; --home-card-edge: #346e5d;
  }
  html[data-bs-theme="dark"] .dashboard-action-card.card-theme-warning {
    --home-card-accent: #f7ce8b; --home-card-tint: #3b3026; --home-card-edge: #796044;
  }
  html[data-bs-theme="dark"] .dashboard-action-card.card-theme-info {
    --home-card-accent: #91ddef; --home-card-tint: #1b3543; --home-card-edge: #356579;
  }
  html[data-bs-theme="dark"] .dashboard-action-card::before {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--home-card-edge), transparent);
    box-shadow: none;
  }
  html[data-bs-theme="dark"] .dashboard-action-card::after { opacity: .1; }
  html[data-bs-theme="dark"] .dashboard-action-card__icon {
    color: var(--home-card-accent);
    background: var(--home-card-tint);
    border: 1px solid var(--home-card-edge);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 5%), 0 8px 20px rgb(0 0 0 / 15%);
  }
  html[data-bs-theme="dark"] .dashboard-action-card .dashboard-action-card__cta {
    color: var(--home-card-accent) !important; /* Overrides Bootstrap text-dark on amber/cyan actions. */
    background: var(--home-card-tint);
    border-color: var(--home-card-edge);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 3%);
    padding-block: .55rem;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
  }
  html[data-bs-theme="dark"] .dashboard-action-card:is(:hover, :focus-within) {
    border-color: var(--home-card-edge);
    box-shadow: 0 16px 32px rgb(0 0 0 / 28%) !important;
  }
  html[data-bs-theme="dark"] .dashboard-action-card:is(:hover, :focus-within) .dashboard-action-card__cta {
    background: var(--home-card-edge);
    color: #fff !important;
  }
  html[data-bs-theme="dark"] .dashboard-action-card a:focus-visible {
    outline: 3px solid var(--home-card-accent);
    outline-offset: 4px;
  }

  /* Statistics, expanded tables and dynamically populated achievement panels. */
  html[data-bs-theme="dark"] :is(.dashboard-stats-card, .student-card, .feature-card) {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    color: var(--app-text);
    box-shadow: 0 12px 32px rgb(0 0 0 / 18%) !important;
  }
  html[data-bs-theme="dark"] .dashboard-stats-card__header {
    background: linear-gradient(110deg, #1d304c, #172439);
    border-bottom-color: var(--app-border);
  }
  html[data-bs-theme="dark"] .lesson-accordion .accordion-item {
    background: #111c2d;
    border: 1px solid var(--app-border);
    box-shadow: none;
  }
  html[data-bs-theme="dark"] .lesson-row {
    background: #1a2940;
    color: var(--app-text);
  }
  html[data-bs-theme="dark"] .lesson-row:not(.collapsed) {
    background: #223755;
    color: var(--app-text);
    box-shadow: inset 3px 0 0 #8bb4ff;
  }
  html[data-bs-theme="dark"] .lesson-row:focus-visible {
    outline: 2px solid var(--app-focus);
    outline-offset: -3px;
  }
  html[data-bs-theme="dark"] :is(.lesson-row__icon, .student-icon) {
    background: var(--home-blue-soft);
    color: var(--app-accent);
  }
  html[data-bs-theme="dark"] .unit-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--app-text);
    --bs-table-border-color: var(--app-border);
    --bs-table-hover-bg: #223755;
    --bs-table-hover-color: var(--app-text);
  }
  html[data-bs-theme="dark"] .unit-table thead th { color: var(--app-text-muted); border-color: var(--app-border); }
  html[data-bs-theme="dark"] .unit-row:is(:hover, :focus, .is-selected) {
    background: #223755;
    border-left-color: var(--app-accent);
    color: var(--app-text);
  }
  html[data-bs-theme="dark"] .unit-row.is-selected::after { background: #304c73; color: #d6e6ff; }
  html[data-bs-theme="dark"] .total-questions-card {
    background: radial-gradient(ellipse at top right, #3c4277, transparent 80%), #223958;
    border: 1px solid #4a5e89;
    box-shadow: 0 10px 28px rgb(0 0 0 / 18%);
  }
  html[data-bs-theme="dark"] .total-questions-card .text-white-50 { color: #c3cfe4 !important; }
  html[data-bs-theme="dark"] .unit-detail-panel { background: #18263b; border-color: var(--app-border); }
  html[data-bs-theme="dark"] .unit-detail-panel .list-group-item { border-bottom-color: var(--app-border); }
  html[data-bs-theme="dark"] .unit-detail-panel .text-dark { color: var(--app-text) !important; }
  html[data-bs-theme="dark"] :is(.dashboard-shell, .student-card) :is(.text-primary, .bg-primary-subtle) {
    color: var(--app-accent) !important;
  }
  html[data-bs-theme="dark"] :is(.lesson-row__cta, .unit-detail-summary, .publication-stat,
    .unit-detail-panel .bg-white, .student-card .bg-light) {
    background: var(--home-blue-soft) !important;
    color: var(--app-text) !important;
    border-color: #3b5375 !important;
  }
  html[data-bs-theme="dark"] .publication-stat .text-primary { color: #bfdaff !important; }
  html[data-bs-theme="dark"] .progress-thin { background: #2c3e58; }
  html[data-bs-theme="dark"] .unit-pagination { background: #18263b; border-color: var(--app-border); }
  html[data-bs-theme="dark"] :is(.unit-pagination, .student-card) .btn-outline-primary {
    --bs-btn-color: var(--app-accent);
    --bs-btn-border-color: #4d6e9e;
    --bs-btn-disabled-color: #aab9ce;
    --bs-btn-disabled-border-color: #4d6e9e;
  }
  html[data-bs-theme="dark"] .student-card .text-success { color: #8be0c0 !important; }
  html[data-bs-theme="dark"] .student-card .alert-light {
    --bs-alert-bg: #1b2940;
    --bs-alert-color: var(--app-text-muted);
    --bs-alert-border-color: var(--app-border);
  }
  html[data-bs-theme="dark"] .feature-icon i { color: #a4c8ff; }
  html[data-bs-theme="dark"] .home-welcome .btn-light {
    background: #dbe9ff;
    color: #182d4d;
    border-color: #dbe9ff;
    box-shadow: 0 6px 20px rgb(0 0 0 / 18%);
  }
  html[data-bs-theme="dark"] .home-welcome .btn-light:hover { background: #fff; }
  @media (prefers-reduced-motion: reduce) {
    html[data-bs-theme="dark"] :is(.dashboard-hero__btn, .feature-card) { transition: none; transform: none; }
  }
}
