/* ============================================================
   Dark mode — html[data-theme="dark"]
   独立文件，不经 Tailwind 构建，直接由页面加载。
   ============================================================ */

[data-theme="dark"] {
  color-scheme: dark;
}

/* ---- 主题切换按钮（太阳/月亮图标） ---- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #57606a;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.theme-toggle:hover {
  background-color: rgba(234, 238, 242, 0.7);
  color: #24292f;
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
}
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle { color: #a8aec0; }
[data-theme="dark"] .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #e4e4e7;
}
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---- 页面背景 / 正文 ---- */
[data-theme="dark"] body {
  background-color: #0f1117;
  color: #e4e4e7;
}
[data-theme="dark"] body.bg-white {
  background-color: #0f1117;
}

/* ---- 白色表面 → 暗色卡片 ---- */
[data-theme="dark"] .bg-white { background-color: #1a1a2e; }
[data-theme="dark"] .bg-white\/95 { background-color: rgb(26 26 46 / 0.95); }
[data-theme="dark"] .bg-white\/90 { background-color: rgb(26 26 46 / 0.9); }

/* ---- neutral 背景 ---- */
[data-theme="dark"] .bg-neutral-50 { background-color: #0f1117; }
[data-theme="dark"] .bg-neutral-100 { background-color: #161b2b; }
[data-theme="dark"] .bg-neutral-200 { background-color: #1f2436; }

/* ---- neutral 文字 ---- */
[data-theme="dark"] .text-neutral-950,
[data-theme="dark"] .text-neutral-900 { color: #e4e4e7; }
[data-theme="dark"] .text-neutral-800 { color: #d6dae4; }
[data-theme="dark"] .text-neutral-700 { color: #c3c8d6; }
[data-theme="dark"] .text-neutral-600 { color: #a8aec0; }
[data-theme="dark"] .text-neutral-500 { color: #8b91a5; }
[data-theme="dark"] .text-neutral-400 { color: #6e748a; }
[data-theme="dark"] .text-neutral-300 { color: #5a6074; }

/* ---- neutral 边框 ---- */
[data-theme="dark"] .border-neutral-50 { border-color: #161b2b; }
[data-theme="dark"] .border-neutral-100 { border-color: #1a1a2e; }
[data-theme="dark"] .border-neutral-200 { border-color: #232838; }
[data-theme="dark"] .border-neutral-300 { border-color: #2c3144; }
[data-theme="dark"] .border-neutral-600 { border-color: #3a4056; }

/* ---- neutral hover 状态 ---- */
[data-theme="dark"] .hover\:bg-neutral-50:hover { background-color: #161b2b; }
[data-theme="dark"] .hover\:bg-neutral-100:hover { background-color: #1f2436; }
[data-theme="dark"] .hover\:text-neutral-600:hover { color: #a8aec0; }
[data-theme="dark"] .hover\:text-neutral-700:hover { color: #c3c8d6; }
[data-theme="dark"] .hover\:text-neutral-900:hover { color: #e4e4e7; }
[data-theme="dark"] .hover\:border-neutral-300:hover { border-color: #2c3144; }

/* ---- checkbox 强调色 ---- */
[data-theme="dark"] .accent-neutral-900 { accent-color: #a8aec0; }

/* ---- primary 品牌灰（按钮/链接） ---- */
[data-theme="dark"] .btn-primary { background-color: #30363d; }
[data-theme="dark"] .btn-primary:hover { background-color: #3a414b; }
[data-theme="dark"] .bg-primary-50,
[data-theme="dark"] .bg-primary-100 { background-color: #1c212e; }
[data-theme="dark"] .bg-primary-600 { background-color: #30363d; }
[data-theme="dark"] .bg-primary-700 { background-color: #3a414b; }
[data-theme="dark"] .hover\:bg-primary-50:hover { background-color: #252b3a; }
[data-theme="dark"] .hover\:bg-primary-700:hover { background-color: #3a414b; }
[data-theme="dark"] .text-primary-600,
[data-theme="dark"] .hover\:text-primary-600:hover { color: #c9d1d9; }
[data-theme="dark"] .text-primary-700,
[data-theme="dark"] .hover\:text-primary-700:hover { color: #e6edf3; }
[data-theme="dark"] .border-primary-600 { border-color: #30363d; }

/* ---- accent 蓝（链接/徽章，适度提亮） ---- */
[data-theme="dark"] .text-accent-500 { color: #58a6ff; }
[data-theme="dark"] .text-accent-700 { color: #79c0ff; }
[data-theme="dark"] .bg-accent-100 { background-color: #0d2a4a; }
[data-theme="dark"] .ring-accent-100 { --tw-ring-color: rgba(88, 166, 255, 0.25); }

/* ---- 表单 ---- */
[data-theme="dark"] .form-input {
  background-color: #161b2b;
  border-color: #3a4056;
  color: #e4e4e7;
}
[data-theme="dark"] .form-input::placeholder { color: #6e748a; }

/* ---- Markdown 正文（github-markdown.css 亮色主题的暗色覆盖） ---- */
[data-theme="dark"] .markdown-body { color: #c3c8d6; }
[data-theme="dark"] .markdown-body h1,
[data-theme="dark"] .markdown-body h2,
[data-theme="dark"] .markdown-body h3,
[data-theme="dark"] .markdown-body h4,
[data-theme="dark"] .markdown-body h5,
[data-theme="dark"] .markdown-body h6 { color: #e4e4e7; }
[data-theme="dark"] .markdown-body a { color: #58a6ff; }
[data-theme="dark"] .markdown-body blockquote {
  color: #8b91a5;
  border-left-color: #30363d;
}
[data-theme="dark"] .markdown-body code,
[data-theme="dark"] .markdown-body pre {
  background-color: #161b2b;
  color: #c3c8d6;
}
[data-theme="dark"] .markdown-body pre { border-color: #232838; }
[data-theme="dark"] .markdown-body table th,
[data-theme="dark"] .markdown-body table td { border-color: #30363d; }
[data-theme="dark"] .markdown-body table tr {
  background-color: transparent;
  border-top-color: #30363d;
}
[data-theme="dark"] .markdown-body table tr:nth-child(2n) { background-color: #161b2b; }

/* ---- 代码高亮（highlight.js github.css 的暗色覆盖） ---- */
[data-theme="dark"] .hljs {
  background: #161b2b;
  color: #c3c8d6;
}

/* ---- 图片灯箱 colorbox ---- */
[data-theme="dark"] #cboxContent,
[data-theme="dark"] #cboxLoadedContent,
[data-theme="dark"] #cboxLoadingOverlay {
  background: #0f1117;
}
[data-theme="dark"] .cboxIframe { background: #1a1a2e; }

/* ---- 目录 TOC（card-toc.css 的暗色覆盖） ---- */
[data-theme="dark"] .toc-sidebar { scrollbar-color: #30363d transparent; }
[data-theme="dark"] .toc-sidebar::-webkit-scrollbar-thumb { background: #30363d; }
[data-theme="dark"] .toc-title {
  color: #8b91a5;
  border-bottom-color: #232838;
}
[data-theme="dark"] .toc-link { color: #8b91a5; }
[data-theme="dark"] .toc-link:hover {
  color: #e4e4e7;
  background: #161b2b;
}
[data-theme="dark"] .toc-link.active {
  color: #58a6ff;
  border-left-color: #58a6ff;
}
[data-theme="dark"] .toc-panel { background: #1a1a2e; }
[data-theme="dark"] .toc-panel-handle { background: #30363d; }
[data-theme="dark"] .toc-panel-header { border-bottom-color: #232838; }
[data-theme="dark"] .toc-panel-title { color: #e4e4e7; }
[data-theme="dark"] .toc-panel-close {
  background: #161b2b;
  color: #a8aec0;
}
[data-theme="dark"] .toc-panel-close:hover { background: #1f2436; }
[data-theme="dark"] .toc-overlay { background: rgba(0, 0, 0, 0.6); }

/* ---- 底部操作栏 + 评论面板（card-action-bar.css 的暗色覆盖） ---- */
[data-theme="dark"] .card-action-bar {
  background: rgba(26, 26, 46, 0.94);
  border-top-color: #232838;
}
[data-theme="dark"] .cab-comment {
  background: #161b2b;
  color: #8b91a5;
}
[data-theme="dark"] .cab-comment-icon { color: #6e748a; }
[data-theme="dark"] .cab-comment-placeholder { color: #8b91a5; }
[data-theme="dark"] .cab-comment-count {
  color: #a8aec0;
  background: #232838;
}
[data-theme="dark"] .cab-btn { color: #a8aec0; }
[data-theme="dark"] .cab-btn:active { background: #161b2b; }
[data-theme="dark"] .cab-count { color: #a8aec0; }
[data-theme="dark"] .cab-fav-icon.fa-star { color: #f59e0b; }
[data-theme="dark"] .cab-like-icon.fa-heart { color: #ef4444; }
[data-theme="dark"] .cab-overlay { background: rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .cab-sheet {
  background: #1a1a2e;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .cab-sheet-handle { background: #30363d; }
[data-theme="dark"] .cab-sheet-header { border-bottom-color: #232838; }
[data-theme="dark"] .cab-sheet-title { color: #e4e4e7; }
[data-theme="dark"] .cab-sheet-close {
  background: #161b2b;
  color: #a8aec0;
}
[data-theme="dark"] .cab-textarea {
  background: #161b2b;
  border-color: #3a4056;
  color: #e4e4e7;
}
[data-theme="dark"] .cab-textarea::placeholder { color: #6e748a; }
[data-theme="dark"] .cab-textarea:focus { border-color: #58a6ff; }
[data-theme="dark"] .cab-send { background: #1f6feb; }

/* ---- Like 按钮 ---- */
[data-theme="dark"] .like-btn {
  border-color: #30363d;
  background: #1a1a2e;
  color: #8b91a5;
}
[data-theme="dark"] .like-btn:hover,
[data-theme="dark"] .like-btn.liked {
  border-color: #f87171;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* ---- 确认弹窗（delete-confirmation-modal-style.css） ---- */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-confirm .modal-content {
  background: #1a1a2e;
  color: #e4e4e7;
}
[data-theme="dark"] .modal-custom-header,
[data-theme="dark"] .modal-custom-footer {
  border-color: #232838;
}
[data-theme="dark"] .modal-confirm { color: #a8aec0; }
[data-theme="dark"] .modal-confirm .modal-body,
[data-theme="dark"] .modal-confirm .modal-custom-footer a { color: #8b91a5; }

/* ---- Bootstrap-notify Toast ---- */
[data-theme="dark"] .notifyjs-corner .alert {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.12);
}

/* ---- card-edit.css（EasyMDE 编辑器 + 编辑卡片）变量暗色覆盖 ---- */
html[data-theme="dark"] {
  --bg-page: #0f1117;
  --bg-card: #1a1a2e;
  --bg-card-header: #161b2b;
  --border: #232838;
  --border-hover: #30363d;
  --text-primary: #e4e4e7;
  --text-secondary: #a8aec0;
  --text-muted: #6e748a;
  --brand: #58a6ff;
  --brand-hover: #79c0ff;
  --btn-fill: #30363d;
  --btn-fill-hover: #3a414b;
  --accent-danger: #f85149;
}
[data-theme="dark"] #card-discription,
[data-theme="dark"] input[type="text"].form-control {
  background: #161b2b;
}
[data-theme="dark"] #card-discription:focus,
[data-theme="dark"] input[type="text"].form-control:focus {
  background: #1a1a2e;
}
[data-theme="dark"] .card-thumbnail,
[data-theme="dark"] .upload-zone:hover,
[data-theme="dark"] .btn-upload:hover,
[data-theme="dark"] .btn.btn-outline:hover {
  background: #161b2b;
}
[data-theme="dark"] .thumbnail-placeholder .material-icons { color: #6e748a; }
[data-theme="dark"] .EasyMDEContainer .CodeMirror {
  background: #1a1a2e !important;
  color: #e4e4e7 !important;
}
[data-theme="dark"] .EasyMDEContainer .editor-preview {
  background: #1a1a2e !important;
  color: #e4e4e7 !important;
}
