/* System-preference theme for all non-exam pages. Manual theme remains only in mock-test.php. */
:root{color-scheme:light dark}
@media(prefers-color-scheme:dark){
 html:not(.test-dark-mode),html:not(.test-dark-mode) body{background:#0f172a!important;color:#e5e7eb!important;color-scheme:dark}
 html:not(.test-dark-mode) header,html:not(.test-dark-mode) .top,html:not(.test-dark-mode) .header,html:not(.test-dark-mode) nav{background:#111827!important;color:#f8fafc!important;border-color:#334155!important}
 html:not(.test-dark-mode) main,html:not(.test-dark-mode) .dash,html:not(.test-dark-mode) .tracker,html:not(.test-dark-mode) .result-page{color:#e5e7eb!important}
 html:not(.test-dark-mode) .card,html:not(.test-dark-mode) .panel,html:not(.test-dark-mode) .tracker-head,html:not(.test-dark-mode) .authbox,html:not(.test-dark-mode) .adminbox,html:not(.test-dark-mode) .test-info,html:not(.test-dark-mode) .tablewrap,html:not(.test-dark-mode) .overall-performance,html:not(.test-dark-mode) .analysis-card,html:not(.test-dark-mode) .summary-card,html:not(.test-dark-mode) .subject,html:not(.test-dark-mode) .subject-box,html:not(.test-dark-mode) .chapter-box,html:not(.test-dark-mode) .empty,html:not(.test-dark-mode) .stat,html:not(.test-dark-mode) .item{background:#1e293b!important;color:#e5e7eb!important;border-color:#475569!important;box-shadow:none!important}
 html:not(.test-dark-mode) h1,html:not(.test-dark-mode) h2,html:not(.test-dark-mode) h3,html:not(.test-dark-mode) h4,html:not(.test-dark-mode) label,html:not(.test-dark-mode) th,html:not(.test-dark-mode) strong{color:#f8fafc!important}
 html:not(.test-dark-mode) p,html:not(.test-dark-mode) small,html:not(.test-dark-mode) .muted,html:not(.test-dark-mode) .empty,html:not(.test-dark-mode) .item small{color:#cbd5e1!important}
 html:not(.test-dark-mode) input,html:not(.test-dark-mode) select,html:not(.test-dark-mode) textarea{background:#172033!important;color:#f8fafc!important;border-color:#475569!important;color-scheme:dark}
 html:not(.test-dark-mode) input::placeholder,html:not(.test-dark-mode) textarea::placeholder{color:#94a3b8!important}
 html:not(.test-dark-mode) table,html:not(.test-dark-mode) td,html:not(.test-dark-mode) th{border-color:#475569!important}
 html:not(.test-dark-mode) th{background:#172033!important}
 html:not(.test-dark-mode) a:not(.btn):not(.button){color:#93c5fd}
 html:not(.test-dark-mode) .btn,html:not(.test-dark-mode) button{border-color:#475569}
 html:not(.test-dark-mode) .success{background:#064e3b!important;color:#bbf7d0!important}
 html:not(.test-dark-mode) .error{background:#7f1d1d!important;color:#fecaca!important}
}


/* System dark palette completion: covers fixed-color controls and nested rows
   on all non-exam pages. mock-test.php intentionally does not load this file. */
@media (prefers-color-scheme: dark) {
  html:not(.test-dark-mode), html:not(.test-dark-mode) body {
    background-color:#0f172a !important; color:#e5e7eb !important;
  }
  html:not(.test-dark-mode) :is(.subject-toggle,.chapter-toggle,.accordion-button,.accordion-header,
    .dropdown-toggle,.tab-button,.filter-button,.pagination a,button:not(.btn):not(.button):not(.action-btn),
    .subject-box button,.chapter-box button) {
    color:#f1f5f9 !important;
  }
  html:not(.test-dark-mode) :is(.subject-box,.chapter-box,.chapter-content,.subject-content,
    .test-group,.chapter-group,.result-row,.result-item,.question-card,.q-review,.q-option,
    .taxonomy-list,.taxonomy-subject-row,.taxonomy-chapter-row,.chapter-empty,
    .published-tests-section,.published-tests-section .tablewrap,.tablewrap table,
    .tablewrap tbody tr,.tablewrap td,.tablewrap th,.result-table,.result-table tbody tr,
    .result-table td,.result-table th,.test-info,.authbox,.adminbox,.card,.panel,.item,
    .stat,.summary-card,.analysis-card,.overall-performance,.tracker-head,.tracker .panel,
    .empty,.notice,.message,.modal-content,.result-modal,.result-modal-content) {
    background-color:#1e293b !important; color:#e5e7eb !important;
    border-color:#475569 !important; box-shadow:none !important;
  }
  html:not(.test-dark-mode) :is(.subject-toggle,.chapter-toggle,.accordion-button,
    .accordion-header,.dropdown-toggle,.tab-button,.filter-button) {
    background-color:transparent !important; color:#f8fafc !important;
  }
  html:not(.test-dark-mode) :is(.chapter-content,.subject-content,.taxonomy-chapter-row,
    .chapter-empty,.tablewrap th,.result-table th) { background-color:#172033 !important; }
  html:not(.test-dark-mode) :is(p,small,label,td,th,li,span,div,summary,legend,.muted,
    .user,.chapter-performance,.rank-total,.result-head p,.test-info p) {
    border-color:#475569;
  }
  html:not(.test-dark-mode) :is(h1,h2,h3,h4,h5,h6,label,th,strong,b,summary,
    .subject-toggle,.chapter-toggle,.chapter-group h4,.test-group h3) {
    color:#f8fafc !important; -webkit-text-fill-color:#f8fafc;
  }
  html:not(.test-dark-mode) :is(p,small,.muted,.empty,.item small,.chapter-performance,
    .performance-heading p,.test-info p,.summary-card span,.analysis-card>p) {
    color:#cbd5e1 !important; -webkit-text-fill-color:#cbd5e1;
  }
  html:not(.test-dark-mode) :is(input,select,textarea) {
    background:#172033 !important; color:#f8fafc !important; border-color:#64748b !important;
    color-scheme:dark;
  }
  html:not(.test-dark-mode) input::placeholder,html:not(.test-dark-mode) textarea::placeholder { color:#94a3b8 !important; }
  html:not(.test-dark-mode) a:not(.btn):not(.button):not(.action-btn) { color:#93c5fd !important; }
  html:not(.test-dark-mode) :is(.btn,.button,.action-btn,.auth-submit,.tracker button[type=submit],
    .addform button,.test-actions button) { color:#fff !important; }
  html:not(.test-dark-mode) :is(.success,.alert-success) { background:#064e3b !important;color:#bbf7d0 !important; }
  html:not(.test-dark-mode) :is(.error,.alert-error) { background:#7f1d1d !important;color:#fecaca !important; }
  html:not(.test-dark-mode) .result-rank,html:not(.test-dark-mode) .attempt-rank { background:#1d4f85 !important;color:#fff !important; }
  html:not(.test-dark-mode) .performance-badge.level-good {background:#14532d!important;color:#bbf7d0!important}
  html:not(.test-dark-mode) .performance-badge.level-moderate {background:#713f12!important;color:#fde68a!important}
  html:not(.test-dark-mode) .performance-badge.level-weak {background:#7f1d1d!important;color:#fecaca!important}
  html:not(.test-dark-mode) .performance-badge.level-nodata {background:#334155!important;color:#cbd5e1!important}
  html:not(.test-dark-mode) .q-option.is-correct {background:#14532d!important;color:#dcfce7!important}
  html:not(.test-dark-mode) .q-option.is-selected-wrong {background:#7f1d1d!important;color:#fee2e2!important}
}

/* Brand visibility and shared mobile header/navbar fixes */
.brand,.top .brand,.header .logo { color:#2563eb !important; -webkit-text-fill-color:#2563eb !important; }
.brand span,.top .brand span { color:#f8fafc !important; -webkit-text-fill-color:#f8fafc !important; }
@media (max-width:700px) {
  .top { height:auto !important; min-height:64px; padding:10px 14px !important; gap:10px 12px !important; flex-wrap:wrap !important; }
  .top .brand { flex:0 1 auto; min-width:0; font-size:clamp(18px,5vw,22px) !important; line-height:1.2; white-space:nowrap; }
  .top .user,.top .admin-header-right { margin-left:auto !important; max-width:100%; display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:6px; font-size:clamp(12px,3.5vw,14px); }
  .top .admin-header-right a { overflow-wrap:anywhere; }
  .top .header-sep { display:inline; }
}
@media (max-width:380px) {
  .top { padding:9px 10px !important; }
  .top .brand { font-size:18px !important; }
  .top .user,.top .admin-header-right { font-size:12px; }
}


/* Focused QA fixes: admin + syllabus tracker logo and system theme surfaces. */
.brand,.top .brand,.header .logo { color:#2563eb !important; -webkit-text-fill-color:#2563eb !important; }
.brand span,.top .brand span { color:#172033 !important; -webkit-text-fill-color:#172033 !important; }
@media (prefers-color-scheme: dark) {
  html:not(.test-dark-mode) .brand span,
  html:not(.test-dark-mode) .top .brand span,
  html:not(.test-dark-mode) .header .logo span {
    color:#f8fafc !important; -webkit-text-fill-color:#f8fafc !important;
  }
  /* Syllabus tracker: its inline light palette needs dark overrides on nested elements. */
  html:not(.test-dark-mode) .tracker .subject h3,
  html:not(.test-dark-mode) .tracker .subject h3 span,
  html:not(.test-dark-mode) .tracker .stat,
  html:not(.test-dark-mode) .tracker .tracker-head,
  html:not(.test-dark-mode) .tracker .panel,
  html:not(.test-dark-mode) .tracker .subject,
  html:not(.test-dark-mode) .tracker .item {
    background:#1e293b !important; color:#f8fafc !important; border-color:#475569 !important;
  }
  html:not(.test-dark-mode) .tracker .subject h3 { background:#172033 !important; }
  html:not(.test-dark-mode) .tracker .back-dashboard {
    background:#1e293b !important; color:#93c5fd !important; border-color:#475569 !important;
  }
  html:not(.test-dark-mode) .tracker .delete {
    background:#7f1d1d !important; color:#fecaca !important; border-color:#991b1b !important;
  }
  html:not(.test-dark-mode) .tracker .bar { background:#334155 !important; }
  html:not(.test-dark-mode) .tracker .addform button { background:#2563eb !important; color:#fff !important; }
  /* Admin: include custom nested taxonomy and upload-management surfaces. */
  html:not(.test-dark-mode) .admin-main-grid,
  html:not(.test-dark-mode) .existing-subjects,
  html:not(.test-dark-mode) .taxonomy-list,
  html:not(.test-dark-mode) .taxonomy-subject-row,
  html:not(.test-dark-mode) .taxonomy-chapter-row,
  html:not(.test-dark-mode) .published-tests-section,
  html:not(.test-dark-mode) .published-tests-section .tablewrap,
  html:not(.test-dark-mode) .adminbox,
  html:not(.test-dark-mode) .adminbox .form-section {
    background:#1e293b !important; color:#e5e7eb !important; border-color:#475569 !important;
  }
  html:not(.test-dark-mode) .taxonomy-subject-row,
  html:not(.test-dark-mode) .taxonomy-chapter-row { border-bottom-color:#475569 !important; }
  html:not(.test-dark-mode) .adminbox input[type=file] { color:#e5e7eb !important; }
  html:not(.test-dark-mode) .adminbox input[type=file]::file-selector-button {
    background:#334155 !important; color:#f8fafc !important; border:1px solid #64748b !important;
  }
  html:not(.test-dark-mode) .admin-header-right a { color:#93c5fd !important; }
}


/* Candidate portal brand visibility: explicit light/dark colors with high specificity. */
html body .top .brand { color:#2563eb !important; -webkit-text-fill-color:#2563eb !important; opacity:1 !important; }
html body .top .brand span { color:#172033 !important; -webkit-text-fill-color:#172033 !important; opacity:1 !important; }
@media (prefers-color-scheme: dark) {
  html:not(.test-dark-mode) body .top .brand span { color:#f8fafc !important; -webkit-text-fill-color:#f8fafc !important; opacity:1 !important; }
}
