/* Final color-only theme layer. It never changes layout geometry. */
html[data-theme="dark"]:not(.react-student-embedded) body,
html[data-theme="dark"]:not(.react-student-embedded) body .shell,
html[data-theme="dark"]:not(.react-student-embedded) body .main {
  color: #edf4ff !important;
  background-color: #0b1220 !important;
  background-image:
    radial-gradient(circle at 82% 8%, rgba(37, 99, 235, 0.1), transparent 30%),
    linear-gradient(rgba(82, 112, 148, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 112, 148, 0.035) 1px, transparent 1px) !important;
  background-size: auto, 32px 32px, 32px 32px !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body .topbar {
  color: #edf4ff !important;
  background: rgba(8, 18, 34, 0.96) !important;
  border-color: rgba(132, 155, 186, 0.16) !important;
  box-shadow: 0 12px 36px rgba(2, 8, 23, 0.24) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body .topbar h2,
html[data-theme="dark"]:not(.react-student-embedded) body .topbar strong,
html[data-theme="dark"]:not(.react-student-embedded) body .panel h1,
html[data-theme="dark"]:not(.react-student-embedded) body .panel h2,
html[data-theme="dark"]:not(.react-student-embedded) body .panel h3,
html[data-theme="dark"]:not(.react-student-embedded) body .panel h4,
html[data-theme="dark"]:not(.react-student-embedded) body .panel strong,
html[data-theme="dark"]:not(.react-student-embedded) body .panel b {
  color: #edf4ff !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body .panel p,
html[data-theme="dark"]:not(.react-student-embedded) body .panel em,
html[data-theme="dark"]:not(.react-student-embedded) body .panel small,
html[data-theme="dark"]:not(.react-student-embedded) body .panel label {
  color: #9fb1c7 !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body .panel .section-card,
html[data-theme="dark"]:not(.react-student-embedded) body .landing-home-grid > article,
html[data-theme="dark"]:not(.react-student-embedded) body .landing-home-grid > section,
html[data-theme="dark"]:not(.react-student-embedded) body :is(.dashboard-card,.workspace-card,.settings-card,.report-card,.question-card,.case-card,.lab-card,.profile-card) {
  color: #edf4ff !important;
  background-color: #111827 !important;
  background-image: linear-gradient(145deg, rgba(20, 32, 51, 0.98), rgba(14, 24, 39, 0.98)) !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 18px 48px rgba(2, 8, 23, 0.22) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body :is(.landing-training-status,.landing-v5-command-card,.landing-v5-summary-card,.landing-weekly-growth-item,.landing-hardware-card,.engineering-continue-task,.global-ai-result-card) {
  color: #edf4ff !important;
  background: #0d1a2c !important;
  border-color: rgba(126, 151, 184, 0.16) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body .topbar-search,
html[data-theme="dark"]:not(.react-student-embedded) body input,
html[data-theme="dark"]:not(.react-student-embedded) body textarea,
html[data-theme="dark"]:not(.react-student-embedded) body select {
  color: #e6eef8 !important;
  background-color: #0d1a2c !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body input::placeholder,
html[data-theme="dark"]:not(.react-student-embedded) body textarea::placeholder {
  color: #71859e !important;
  opacity: 1 !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body .global-ai-search-panel,
html[data-theme="dark"]:not(.react-student-embedded) body .companion-panel,
html[data-theme="dark"]:not(.react-student-embedded) body .modal-card,
html[data-theme="dark"]:not(.react-student-embedded) body .drawer {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
}

html:not([data-theme="dark"]):not(.react-student-embedded) body,
html:not([data-theme="dark"]):not(.react-student-embedded) body .shell,
html:not([data-theme="dark"]):not(.react-student-embedded) body .main {
  color: #172033 !important;
  background-color: #f3f6fb !important;
}

html:not([data-theme="dark"]):not(.react-student-embedded) body .topbar {
  color: #172033 !important;
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: rgba(71, 103, 139, 0.14) !important;
}

/* Terminal color authority over historical page-specific locks. */
html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell > .main.main {
  color: #edf4ff !important;
  background:
    radial-gradient(circle at 82% 8%, rgba(37, 99, 235, 0.12), transparent 30%),
    linear-gradient(rgba(82, 112, 148, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 112, 148, 0.04) 1px, transparent 1px),
    #0b1220 !important;
  background-size: auto, 32px 32px, 32px 32px, auto !important;
}

html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell > .main.main > header.topbar.topbar {
  color: #edf4ff !important;
  background: rgba(8, 18, 34, 0.97) !important;
  border-color: rgba(132, 155, 186, 0.17) !important;
}

html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell > .main.main > .panel.active {
  color: #edf4ff !important;
  background-color: transparent !important;
  background-image: none !important;
}

html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell .main .panel.active .landing-home-grid > article.section-card,
html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell .main .panel.active :is(.landing-primary-recommendation,.landing-route-card,.landing-welcome-panel,.landing-weekly-growth,.landing-xiaowen-briefing,.landing-hardware-focus,.landing-hardware-questions,.landing-special-training) {
  color: #edf4ff !important;
  background: linear-gradient(145deg, #142033, #0e1827) !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 18px 48px rgba(2, 8, 23, 0.24) !important;
}

html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell .main .panel.active :is(.landing-training-status,.landing-recommendation-preview,.landing-v5-command-card,.landing-v5-summary-card,.landing-weekly-growth-item,.landing-hardware-card,.engineering-continue-task) {
  color: #edf4ff !important;
  background: #0d1a2c !important;
  border-color: rgba(126, 151, 184, 0.16) !important;
}

html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell .main .panel.active :is(h1,h2,h3,h4,strong,b) {
  color: #edf4ff !important;
}

html[data-theme="dark"][data-theme="dark"]:not(.react-student-embedded) body[data-active-panel][data-theme="dark"] .shell .main .panel.active :is(p,small,em) {
  color: #9fb1c7 !important;
}

/* Interview workspace */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .interview-studio {
  color: #edf4ff !important;
  background: #0b1220 !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main :is(.interview-training-statusbar,.interview-arena-block,.interview-record-item,.active-resume-card,.interview-answer-live-card,.interview-answer-transcript-body,.interview-profile-user,.interview-profile-ability,.interview-profile-block) {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main :is(.interview-profile-gain,.interview-space-mode-option,.section-head,.interview-waveform) {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
}

/* Project / engineering workspace */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.project-detail-section,.project-all-projects,.project-architecture-board,.project-today-panel,.engineering-asset-card) {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.project-home-loop-strip,.project-home-card,.project-loop-step,.project-intro-diagram,.project-coach-answer),
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-case-xiaowen-modes > section,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-case-grid > article,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-debug-layout > aside,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-waveform-layout > aside,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .engineering-asset-card > p {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 12px 28px rgba(2, 8, 23, 0.18) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.engineering-lab-task,.project-route-step,.project-architecture-node,.project-case-template-preview,.engineering-asset-kpi,.project-xiaowen-project-preview),
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-practice-page :is(article,section,aside,button,div):not([class]) {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.16) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-debug-steps > p,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-coach-question-list > button {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
}

/* Engineering lab */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="engineering-lab"] .main :is(.engineering-entry-card,.engineering-lab-task) {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.2) !important;
}

/* Personal workspace */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="my"] .main .engineer-dossier-summary {
  color: #edf4ff !important;
  background: #111827 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.2) !important;
}

/* Complete the dark palette for legacy cards that still carry light-mode
   gradients with !important. Keep this layer color-only: no geometry changes. */
html[data-theme="dark"]:not(.react-student-embedded) {
  color-scheme: dark;
}

/* Landing / workbench */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="landing"] .main :is(#landingV5ReasonPrimary,#landingV5ReasonSecondary),
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="landing"] .main .landing-xiaowen-advice-grid > span {
  color: #dbe7f5 !important;
  background: #162238 !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="landing"] .main .landing-v5-command-card > b {
  color: #86efac !important;
  background: rgba(34, 197, 94, 0.14) !important;
  border-color: rgba(34, 197, 94, 0.24) !important;
}

/* Interview workspace and AI-managed weak-question bank */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .interview-weak-bank-item {
  color: #edf4ff !important;
  background: linear-gradient(145deg, #162238, #101c2f) !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
  box-shadow: 0 14px 32px rgba(2, 8, 23, 0.22) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .interview-weak-bank-item span,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .interview-weak-bank-item strong {
  color: #edf4ff !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .interview-weak-bank-item em {
  color: #9fb1c7 !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main :is(.interview-training-metrics > span,.interview-question-requirements li,.engineering-score-summary > div,.interview-answer-mode-toggle) {
  color: #dbe7f5 !important;
  background: #162238 !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .danger-soft {
  color: #fca5a5 !important;
  background: rgba(127, 29, 29, 0.22) !important;
  border-color: rgba(239, 68, 68, 0.28) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .xiaowen-live-interview-coach {
  color: #edf4ff !important;
  background-color: #162238 !important;
  background-image: linear-gradient(145deg, #162238, #101c2f) !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="interview"] .main .xiaowen-live-interview-coach :is(p,em,small) {
  color: #9fb1c7 !important;
}

/* Engineering space: large legacy white/gradient boards */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(
  .engineering-assets-overview,
  .engineering-lab-hero,
  .project-today-card,
  .project-my-assistant,
  .project-loop-board,
  .project-route-overview,
  .project-case-xiaowen
) {
  color: #edf4ff !important;
  background-color: #111827 !important;
  background-image: linear-gradient(145deg, #142033, #0e1827) !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
  box-shadow: 0 18px 46px rgba(2, 8, 23, 0.24) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.skill-training-group,.engineering-lab-entry) {
  color: #edf4ff !important;
  background-color: #162238 !important;
  background-image: linear-gradient(145deg, #162238, #101c2f) !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
  box-shadow: 0 12px 30px rgba(2, 8, 23, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.skill-training-group,.engineering-lab-entry) strong,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(
  .engineering-assets-overview,
  .engineering-lab-hero,
  .project-today-card,
  .project-my-assistant,
  .project-loop-board,
  .project-route-overview,
  .project-case-xiaowen
) :is(h2,h3,h4,strong,b) {
  color: #edf4ff !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.skill-training-group,.engineering-lab-entry) em,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(
  .engineering-assets-overview,
  .engineering-lab-hero,
  .project-today-card,
  .project-my-assistant,
  .project-loop-board,
  .project-route-overview,
  .project-case-xiaowen
) :is(p,em,small) {
  color: #9fb1c7 !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-route-overview > span,
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-loop-track > span {
  color: #dbe7f5 !important;
  background: #162238 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .skill-training-group > span {
  color: #c4b5fd !important;
  background: rgba(124, 92, 255, 0.16) !important;
  border-color: rgba(124, 92, 255, 0.22) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main .project-case-xiaowen-modes section > div > span {
  color: #b9c9db !important;
  background: #162238 !important;
  border-color: rgba(126, 151, 184, 0.18) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.project-summary-metrics,.project-ability-gain) > span {
  color: #dbe7f5 !important;
  background: #162238 !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.16) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.project-summary-metrics,.project-ability-gain) > span :is(b,strong) {
  color: #c4b5fd !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="project-practice"] .main :is(.project-summary-metrics,.project-ability-gain) > span em {
  color: #9fb1c7 !important;
}

/* Engineering lab */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="engineering-lab"] .main .engineering-lab-hero {
  color: #edf4ff !important;
  background-color: #111827 !important;
  background-image: linear-gradient(145deg, #142033, #0e1827) !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
  box-shadow: 0 18px 46px rgba(2, 8, 23, 0.24) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="engineering-lab"] .main .engineering-lab-hero :is(h2,h3,h4,strong,b) {
  color: #edf4ff !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="engineering-lab"] .main .engineering-lab-hero :is(p,em,small) {
  color: #9fb1c7 !important;
}

/* Personal engineering profile */
html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="my"] .main :is(
  .engineer-dossier-skill-list > span,
  .engineer-growth-proof-timeline > span,
  .engineer-proof-list > span
) {
  color: #dbe7f5 !important;
  background-color: #162238 !important;
  background-image: linear-gradient(145deg, #162238, #101c2f) !important;
  border-color: rgba(126, 151, 184, 0.2) !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="my"] .main :is(
  .engineer-dossier-skill-list > span,
  .engineer-growth-proof-timeline > span,
  .engineer-proof-list > span
) :is(b,strong) {
  color: #edf4ff !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="my"] .main :is(
  .engineer-growth-proof-timeline > span,
  .engineer-proof-list > span
) em {
  color: #9fb1c7 !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body[data-active-panel="my"] .main .engineer-dossier-avatar {
  background: #172554 !important;
  border-color: rgba(126, 151, 184, 0.24) !important;
}
