/* Dark theme: global overrides for existing Tailwind utility classes (light palette preserved when html has no .dark) */

html.dark {
  color-scheme: dark;
  --mxy-green-50: #0f1f18;
  --mxy-green-100: #143026;
}

html.dark body {
  background-color: #0b1220;
  color: #e2e8f0;
}

@media (min-width: 768px) {
  html.dark body {
    background:
      radial-gradient(at 100% 0%, rgba(47, 158, 115, 0.12) 0px, transparent 50%),
      radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
      radial-gradient(at 80% 50%, rgba(47, 158, 115, 0.06) 0px, transparent 50%),
      radial-gradient(at 0% 100%, rgba(30, 41, 59, 0.5) 0px, transparent 50%),
      #0b1220;
    background-attachment: fixed;
  }
}

html.dark .glass {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(51, 65, 85, 0.65);
}

html.dark .glass-panel {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(51, 65, 85, 0.7);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

html.dark .bg-white.rounded-xl.border,
html.dark .bg-white.rounded-2xl.border,
html.dark .bg-white.border.rounded-xl,
html.dark .bg-white.border.rounded-2xl {
  border-color: #334155;
  box-shadow:
    0 10px 30px -18px rgba(0, 0, 0, 0.45),
    0 2px 8px -6px rgba(47, 158, 115, 0.12);
}

/* Surfaces */
html.dark .bg-white { background-color: #0f172a !important; }
html.dark .bg-slate-50 { background-color: #0b1220 !important; }
html.dark .bg-slate-100 { background-color: #1e293b !important; }
html.dark .bg-slate-200 { background-color: #334155 !important; }

html.dark .bg-white\/60 { background-color: rgb(15 23 42 / 0.6) !important; }
html.dark .bg-white\/70 { background-color: rgb(15 23 42 / 0.7) !important; }
html.dark .bg-white\/80 { background-color: rgb(15 23 42 / 0.8) !important; }
html.dark .bg-white\/85 { background-color: rgb(15 23 42 / 0.85) !important; }
html.dark .bg-white\/40 { background-color: rgb(15 23 42 / 0.4) !important; }
html.dark .bg-white\/90 { background-color: rgb(15 23 42 / 0.9) !important; }
html.dark .bg-white\/95 { background-color: rgb(15 23 42 / 0.95) !important; }
html.dark .hover\:bg-white:hover { background-color: #1e293b !important; }
html.dark .hover\:bg-white\/80:hover { background-color: rgb(30 41 59 / 0.8) !important; }

html.dark .bg-primary\/5 { background-color: rgba(47, 158, 115, 0.12) !important; }
html.dark .bg-primary\/10 { background-color: rgba(47, 158, 115, 0.18) !important; }
html.dark .bg-emerald-50 { background-color: rgba(47, 158, 115, 0.12) !important; }
html.dark .bg-emerald-100 { background-color: rgba(47, 158, 115, 0.18) !important; }
html.dark .bg-red-50 { background-color: rgba(239, 68, 68, 0.12) !important; }
html.dark .bg-amber-50 { background-color: rgba(245, 158, 11, 0.12) !important; }
html.dark .bg-blue-50 { background-color: rgba(59, 130, 246, 0.12) !important; }
html.dark .bg-indigo-50 { background-color: rgba(99, 102, 241, 0.12) !important; }
html.dark .bg-violet-50 { background-color: rgba(139, 92, 246, 0.12) !important; }
html.dark .bg-green-50 { background-color: rgba(34, 197, 94, 0.12) !important; }

/* Text */
html.dark .text-slate-900 { color: #f1f5f9 !important; }
html.dark .text-slate-800 { color: #e2e8f0 !important; }
html.dark .text-slate-700 { color: #cbd5e1 !important; }
html.dark .text-slate-600 { color: #94a3b8 !important; }
html.dark .text-slate-500 { color: #94a3b8 !important; }
html.dark .text-slate-400 { color: #64748b !important; }
html.dark .text-slate-300 { color: #475569 !important; }

/* Borders */
html.dark .border-slate-50 { border-color: #1e293b !important; }
html.dark .border-slate-100 { border-color: #334155 !important; }
html.dark .border-slate-200 { border-color: #334155 !important; }
html.dark .border-slate-300 { border-color: #475569 !important; }
html.dark .border-white\/50 { border-color: rgb(51 65 85 / 0.65) !important; }
html.dark .border-white\/60 { border-color: rgb(51 65 85 / 0.7) !important; }
html.dark .border-t-white\/50 { border-top-color: rgb(51 65 85 / 0.65) !important; }
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: #334155 !important; }
html.dark .divide-slate-200 > :not([hidden]) ~ :not([hidden]) { border-color: #334155 !important; }

/* Hovers */
html.dark .hover\:bg-slate-50:hover { background-color: #1e293b !important; }
html.dark .hover\:bg-slate-100:hover { background-color: #334155 !important; }
html.dark .hover\:bg-emerald-50:hover { background-color: rgba(47, 158, 115, 0.16) !important; }
html.dark .hover\:bg-emerald-100:hover { background-color: rgba(47, 158, 115, 0.22) !important; }
html.dark .hover\:bg-red-50:hover { background-color: rgba(239, 68, 68, 0.16) !important; }
html.dark .hover\:bg-blue-50:hover { background-color: rgba(59, 130, 246, 0.16) !important; }
html.dark .hover\:bg-violet-50:hover { background-color: rgba(139, 92, 246, 0.16) !important; }
html.dark .hover\:bg-green-50:hover { background-color: rgba(34, 197, 94, 0.16) !important; }
html.dark .hover\:bg-primary\/10:hover { background-color: rgba(47, 158, 115, 0.2) !important; }
html.dark .hover\:bg-primary\/20:hover { background-color: rgba(47, 158, 115, 0.28) !important; }
html.dark .hover\:text-slate-600:hover { color: #cbd5e1 !important; }
html.dark .hover\:text-slate-700:hover { color: #e2e8f0 !important; }
html.dark .hover\:border-primary\/20:hover { border-color: rgba(47, 158, 115, 0.35) !important; }
html.dark .hover\:border-primary\/30:hover { border-color: rgba(47, 158, 115, 0.45) !important; }

/* Inputs */
html.dark input,
html.dark textarea,
html.dark select {
  background-color: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #64748b;
}

html.dark input:focus,
html.dark textarea:focus,
html.dark select:focus {
  box-shadow: 0 0 0 3px rgba(47, 158, 115, 0.28);
  border-color: #2f9e73 !important;
}

/* Shadows on elevated panels */
html.dark .shadow-sm,
html.dark .shadow-md,
html.dark .shadow-lg,
html.dark .shadow-xl,
html.dark .shadow-2xl {
  --tw-shadow-color: rgba(0, 0, 0, 0.45);
}

/* Scrollbar (webkit) */
html.dark ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html.dark ::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 999px;
}
html.dark ::-webkit-scrollbar-track {
  background: #0f172a;
}

/* 单词学习卡：深色模式下单词标题为白色（不影响浅色渐变） */
html.dark .word-learning-title {
  color: #ffffff !important;
  background-image: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
}

/* SRS 反馈：深色模式下统一石板灰（不影响浅色彩色按钮） */
html.dark .srs-feedback-panel:not(.theater-srs-panel) .srs-feedback-grade {
  background-color: rgb(30 41 59 / 0.7) !important;
  border-color: rgb(71 85 105 / 0.45) !important;
  border-bottom-color: rgb(51 65 85 / 0.8) !important;
  color: rgb(148 163 184) !important;
  box-shadow: none !important;
}

html.dark .srs-feedback-panel:not(.theater-srs-panel) .srs-feedback-grade:hover {
  background-color: rgb(51 65 85 / 0.85) !important;
  border-color: rgb(100 116 139 / 0.5) !important;
}

html.dark .srs-feedback-panel:not(.theater-srs-panel) .srs-feedback-grade--selected {
  background-color: rgb(71 85 105 / 0.8) !important;
  border-color: rgb(100 116 139 / 0.55) !important;
  border-bottom-color: rgb(148 163 184 / 0.7) !important;
  color: rgb(248 250 252) !important;
}

html.dark .srs-feedback-panel:not(.theater-srs-panel) .srs-feedback-grade--selected:hover {
  background-color: rgb(100 116 139 / 0.8) !important;
}

html.dark .srs-feedback-panel:not(.theater-srs-panel) .srs-unmaster-btn {
  background-color: rgb(30 41 59 / 0.7) !important;
  border: 1px solid rgb(71 85 105 / 0.45) !important;
  color: rgb(148 163 184) !important;
}

html.dark .srs-feedback-panel:not(.theater-srs-panel) .srs-unmaster-btn:hover {
  background-color: rgb(51 65 85 / 0.85) !important;
}

/* 句子课程：深色模式下英文句子提高对比度（仅普通学习卡，剧场模式不变） */
html.dark .glass-panel .theater-title-en {
  color: #7dd3fc !important;
}

/* 显示英文句子：深色按钮 + 亮色文字 */
html.dark .glass-panel .sentence-reveal-en-btn {
  background-color: #0f172a !important;
  color: #e0f2fe !important;
  border-color: #475569 !important;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.35) !important;
}

html.dark .glass-panel .sentence-reveal-en-btn:hover {
  background-color: #1e293b !important;
  color: #f0f9ff !important;
  border-color: #64748b !important;
}

/* 课程列表：筛选菜单标题（筛选 / 类型 / 分类）在浅色卡片上加深字色 */
html.dark .course-filter-panel {
  background-color: rgb(15 23 42 / 0.88) !important;
  border-color: #334155 !important;
}

html.dark .course-filter-panel .course-filter-section-label {
  color: #cbd5e1 !important;
}

/* 登录首页：最近学习 / 已购课程列表深色模式下去掉浅色底 */
html.dark .home-recent-list,
html.dark .home-purchased-list {
  background: transparent !important;
  background-image: none !important;
  border-color: #334155 !important;
  box-shadow: none !important;
}

html.dark .home-recent-list button:hover,
html.dark .home-purchased-list button:hover {
  background-color: rgb(30 41 59 / 0.65) !important;
}

/* 课程卡片：会员免费 / 所有人免费标签 */
html.dark .course-access-badge--free {
  background-color: rgba(47, 158, 115, 0.22) !important;
  border-color: transparent !important;
  color: #a7f3d0 !important;
}

/* 音视频课程：深色模式下字幕去掉圆角底框，提高文字对比度 */
html.dark .theater-subtitle-panel {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

html.dark .theater-subtitle-panel .theater-subtitle-en {
  color: #7dd3fc !important;
  text-shadow: none !important;
}

html.dark .theater-subtitle-panel .theater-subtitle-zh {
  color: #f1f5f9 !important;
  text-shadow: none !important;
}

html.dark .theater-subtitle-panel .theater-subtitle-content {
  color: #cbd5e1 !important;
  border-top-color: #334155 !important;
}

html.dark .theater-subtitle-panel .theater-subtitle-content p,
html.dark .theater-subtitle-panel .theater-subtitle-content li,
html.dark .theater-subtitle-panel .theater-subtitle-content span {
  color: #cbd5e1 !important;
}

/* 视频课：深色模式下字幕区 / 字幕控制条去掉浅色底 */
html.dark .video-subtitle-controls {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

html.dark .video-subtitle-toggle-btn,
html.dark .subtitle-toggle-btn {
  background-color: rgb(30 41 59 / 0.85) !important;
  border-color: rgb(71 85 105 / 0.35) !important;
  color: #e2e8f0 !important;
}

html.dark .video-subtitle-toggle-btn:hover,
html.dark .subtitle-toggle-btn:hover {
  background-color: rgb(51 65 85 / 0.9) !important;
  border-color: rgb(100 116 139 / 0.45) !important;
  color: #f8fafc !important;
}
