/* 让 CKEditor 内容区域与站点的暗色主题一致 */
body.cke_editable,
body.editor-dark {
  background-color: #111827; /* gray-900 */
  color: #e5e7eb; /* gray-200 */
  font-size: 16px;
  line-height: 1.8;
  padding: 0.75rem 1rem;
}

/* 标题 */
body.cke_editable h1,
body.cke_editable h2,
body.cke_editable h3,
body.cke_editable h4,
body.cke_editable h5,
body.cke_editable h6 {
  color: #ffffff;
  margin: 1.25em 0 0.5em 0;
}

/* 链接 */
body.cke_editable a {
  color: #60a5fa; /* blue-400 */
  text-decoration: underline;
}
body.cke_editable a:hover {
  color: #93c5fd; /* blue-300 */
}

/* 段落与列表 */
body.cke_editable p { margin: 0.5em 0; }
body.cke_editable ul,
body.cke_editable ol { padding-left: 1.25rem; }
body.cke_editable li { margin: 0.25rem 0; }

/* 引用 */
body.cke_editable blockquote {
  background: #0b1220; /* darker bg */
  color: #d1d5db; /* gray-300 */
  border-left: 4px solid #4b5563; /* gray-600 */
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
}

/* 代码块与行内代码 */
body.cke_editable pre,
body.cke_editable code {
  background: #0b1220;
  color: #e5e7eb;
  border: 1px solid #374151; /* gray-700 */
  border-radius: 0.375rem;
}
body.cke_editable pre { padding: 0.75rem 1rem; overflow: auto; }
body.cke_editable code { padding: 0.1rem 0.35rem; }

/* 表格 */
body.cke_editable table {
  width: 100%;
  border-collapse: collapse;
}
body.cke_editable th,
body.cke_editable td {
  border: 1px solid #374151;
  padding: 0.5rem 0.75rem;
}
body.cke_editable thead th {
  background: #1f2937; /* gray-800 */
}

/* 水平线 */
body.cke_editable hr {
  border: none;
  border-top: 1px solid #374151;
  margin: 1rem 0;
}

/* 图片自适应 */
body.cke_editable img {
  max-width: 100%;
  height: auto !important;
  border-radius: 0.375rem;
}

/* --- CKEditor UI（工具栏等）暗色主题与可读性增强 --- */
.ck-container { width: 100%; }
.django-ckeditor-widget, .ck-container .django-ckeditor-widget { width: 100% !important; }
.cke_chrome { width: 100% !important; background: #0b1220 !important; border: 1px solid #374151 !important; border-radius: 0.5rem; }
.cke_top, .cke_bottom { background: #0b1220 !important; border-color: #374151 !important; }
.cke_toolgroup { background: transparent !important; border-color: #374151 !important; }
.cke_button a, .cke_button a:hover, .cke_button a:focus { color: #e5e7eb !important; }
.cke_combo_button, .cke_combo, .cke_combo_button:hover { background: #111827 !important; border-color: #374151 !important; }
.cke_combo_text, .cke_button_label { color: #e5e7eb !important; font-size: 14px; }
.cke_button_on, .cke_button:hover { background-color: #1f2937 !important; }
.cke_panel { background: #0b1220 !important; border-color: #374151 !important; }
.cke_panel_frame, .cke_panel_block, .cke_panel_list { background: #0b1220 !important; }
.cke_panel_listItem a { color: #e5e7eb !important; background: transparent !important; }
.cke_panel_listItem a:hover { background: #1f2937 !important; color: #ffffff !important; }
.cke_path { color: #9ca3af !important; }

/* 编辑区最小高度，避免初始过矮 */
body.cke_editable { min-height: 400px; }

/* --- 让工具栏图标与文字在暗色背景下更清晰（白色） --- */
.cke_button_label, .cke_combo_text { color: #ffffff !important; }
.cke_button a, .cke_button a:hover, .cke_button a:focus { color: #ffffff !important; }
/* 反相与增亮处理 CKEditor4 精灵图标，适配深色背景 */
.cke_button_icon, .cke_combo_arrow { filter: invert(1) brightness(1.6) contrast(1.1) !important; }

/* --- 富文本中的 iframe 更友好的响应式显示（16:9）和编辑器内预览 --- */
body.cke_editable iframe { 
  width: 100% !important; 
  aspect-ratio: 16 / 9; 
  height: auto !important; 
  border-radius: 8px; 
  display: block; 
  margin: 1rem 0; 
  border: 0 !important;
  background: transparent !important;
}

/* B站视频容器在编辑器中的样式（去除边框与背景） */
body.cke_editable .bb-video-wrapper {
  position: relative !important;
  width: 100% !important;
  padding-bottom: 56.25% !important; /* 16:9 aspect ratio */
  height: 0 !important;
  overflow: hidden !important;
  margin: 8px 0 !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
}

body.cke_editable .bb-video-wrapper iframe {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  border-radius: 8px !important;
}

/* 前台渲染：确保 .prose 容器内旧内容（bb-video-wrapper）无边框且自适应 */
.prose .bb-video-wrapper {
  position: relative !important;
  width: 100% !important;
  padding-bottom: 56.25% !important; /* 16:9 */
  height: 0 !important;
  overflow: hidden !important;
  margin: 1.5rem 0 !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
}

.prose .bb-video-wrapper iframe {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  border-radius: 8px !important;
}

/* 专门把"格式/标题1-3"下拉的文字调成白色 */
 .cke_combo.cke_combo__format .cke_combo_text { color: #ffffff !important; }
 .cke_panel .cke_panel_listItem a { color: #ffffff !important; }
 .cke_panel .cke_panel_listItem a:hover { background: #1f2937 !important; }

/* 仅显示 Bilibili 插件按钮的文字，隐藏图标占位 */
.cke_button__bilibili_icon { display: none !important; }
.cke_button__bilibili .cke_button_label { display: inline !important; padding: 0 6px; font-weight: 600; }
.cke_button.cke_button__bilibili { height: 32px !important; }
/* 若按钮仍显示"B站"，可能是缓存或插件未加载最新脚本，强制显示当前label */
.cke_button__bilibili .cke_button_label:before { content: '' !important; }
