/* Jupyter Notebook 样式 - 适配亮色和暗色模式 */

.jupyter-notebook-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

/* 输入单元格 */
.jupyter-notebook-container .jp-InputArea,
.jupyter-notebook-container .jp-Cell-inputArea,
.jupyter-notebook-container .input_area {
    background-color: #f8f9fa;
    border-left: 3px solid #2563eb;
    padding: 0.5rem;
    border-radius: 0 ;
    margin: 0.25rem 0;
    overflow-x: auto;
}

.dark .jupyter-notebook-container .jp-InputArea,
.dark .jupyter-notebook-container .jp-Cell-inputArea,
.dark .jupyter-notebook-container .input_area {
    background-color: #1f2937;
    border-left-color: #3b82f6;
}

/* 输出单元格：勿在整个 .output_area 加左边框（会与 Out[n]: 提示列错位） */
.jupyter-notebook-container .jp-OutputArea,
.jupyter-notebook-container .jp-Cell-outputArea,
.jupyter-notebook-container .output_area {
    background-color: transparent;
    border-left: none;
    padding: 0.25rem 0;
    border-radius: 0;
    margin: 0.25rem 0;
    overflow-x: auto;
}

.dark .jupyter-notebook-container .jp-OutputArea,
.dark .jupyter-notebook-container .jp-Cell-outputArea,
.dark .jupyter-notebook-container .output_area {
    background-color: transparent;
}

/* 仅在实际输出内容块左侧加标识，与 In/Out 提示列对齐 */
.jupyter-notebook-container .output_area .output_subarea,
.jupyter-notebook-container .jp-OutputArea .jp-OutputArea-child {
    border-left: 3px solid #10b981;
    padding-left: 0.5rem;
    margin-left: 0;
}

.dark .jupyter-notebook-container .output_area .output_subarea,
.dark .jupyter-notebook-container .jp-OutputArea .jp-OutputArea-child {
    border-left-color: #34d399;
}

/* 代码块基础样式 */
.jupyter-notebook-container pre,
.jupyter-notebook-container code {
    background-color: transparent;
    border: none;
    padding: 0 !important;
    margin: 0 !important;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #000000; /* 亮色模式黑色 */
}

.dark .jupyter-notebook-container pre,
.dark .jupyter-notebook-container code {
    color: #e6edf3; /* 暗色模式下的默认浅色 */
}

.jupyter-notebook-container .highlight pre {
    background-color: transparent !important;
    padding: 0.5rem !important;
    margin: 0.5rem !important;
}

/* 去掉 nbconvert 可能添加的额外样式 */
.jupyter-notebook-container div.highlight {
    background-color: transparent !important;
}

.jupyter-notebook-container div.highlight pre {
    background-color: transparent !important;
    padding: 0.5rem !important;
    margin: 0.5rem !important;
}

/* 输出区域的 highlight 容器 */
.jupyter-notebook-container .output_area .highlight,
.jupyter-notebook-container .jp-OutputArea .highlight {
    background-color: transparent !important;
}

/* nbconvert 在 .notebook-html-inner 内自带 Pygments 配色；勿用 !important 覆盖 span 颜色 */

/* 单元格提示符 */
.jupyter-notebook-container .prompt {
    min-width: 8ex;
    padding: 0.2em 0.3em 0.2em 0.1em;
    font-family: monospace;
    text-align: right;
    color: #6b7280;
    font-size: 0.85em;
}

.dark .jupyter-notebook-container .prompt {
    color: #9ca3af;
}

.jupyter-notebook-container .prompt.input_prompt {
    color: #2563eb;
}

.dark .jupyter-notebook-container .prompt.input_prompt {
    color: #3b82f6;
}

.jupyter-notebook-container .prompt.output_prompt {
    color: #10b981;
}

.dark .jupyter-notebook-container .prompt.output_prompt {
    color: #34d399;
}

/* Markdown 单元格 */
.jupyter-notebook-container .text_cell_render {
    color: #374151;
    padding: 0.25rem 0;
}

.dark .jupyter-notebook-container .text_cell_render {
    color: #d1d5db;
}

.jupyter-notebook-container .text_cell_render h1,
.jupyter-notebook-container .text_cell_render h2,
.jupyter-notebook-container .text_cell_render h3,
.jupyter-notebook-container .text_cell_render h4 {
    color: #111827;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.dark .jupyter-notebook-container .text_cell_render h1,
.dark .jupyter-notebook-container .text_cell_render h2,
.dark .jupyter-notebook-container .text_cell_render h3,
.dark .jupyter-notebook-container .text_cell_render h4 {
    color: #f9fafb;
}

/* Markdown 段落 */
.jupyter-notebook-container .text_cell_render p {
    margin: 0.25rem 0;
}

/* 表格（含 DataFrame HTML） */
.jupyter-notebook-container table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.25rem 0;
    font-size: 0.9375rem;
}

.jupyter-notebook-container table th,
.jupyter-notebook-container table td {
    border: 1px solid #d1d5db;
    padding: 0.45rem 0.55rem;
    text-align: left;
    color: #374151;
}

.dark .jupyter-notebook-container table th,
.dark .jupyter-notebook-container table td {
    border-color: #374151;
    color: #d1d5db;
}

.jupyter-notebook-container table th {
    background-color: #f3f4f6;
    font-weight: 600;
    color: #111827;
}

.dark .jupyter-notebook-container table th {
    background-color: #1f2937;
    color: #f3f4f6;
}

/* DataFrame 样式 */
.jupyter-notebook-container .dataframe {
    font-size: 1rem;
}

.jupyter-notebook-container .output_html,
.jupyter-notebook-container .output_area .rendered_html {
    font-size: 1rem;
    line-height: 1.45;
}

.jupyter-notebook-container .dataframe thead th {
    background-color: #eff6ff;
    color: #1e40af;
    font-weight: 600;
}

.dark .jupyter-notebook-container .dataframe thead th {
    background-color: #1e3a8a;
    color: #bfdbfe;
}

/* 图表和图像（output 内嵌图勿被下文半透明规则拖垮） */
.jupyter-notebook-container .notebook-html-inner img,
.jupyter-notebook-container .notebook-html-inner svg,
.jupyter-notebook-container .notebook-html-inner video,
.jupyter-notebook-container .notebook-html-inner canvas {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
    margin: 0.25rem 0;
    vertical-align: middle;
}

/* 图表和图像（容器级 fallback） */
.jupyter-notebook-container img {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
    margin: 0.25rem 0;
}

/* 错误输出 */
.jupyter-notebook-container .output_error,
.jupyter-notebook-container .traceback {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin: 0.25rem 0;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.875rem;
}

.dark .jupyter-notebook-container .output_error,
.dark .jupyter-notebook-container .traceback {
    background-color: #7f1d1d;
    color: #fecaca;
}

/* 标准输出 */
.jupyter-notebook-container .output_stdout {
    background-color: transparent;
    padding: 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
    font-size: 0.9375rem;
    white-space: pre-wrap;
    color: #000000;
}

.dark .jupyter-notebook-container .output_stdout {
    background-color: transparent;
    color: #d1d5db;
}

.jupyter-notebook-container .output_area pre,
.jupyter-notebook-container .jp-OutputArea pre,
.jupyter-notebook-container .output_text pre,
.jupyter-notebook-container .output_stream pre {
    background-color: transparent !important;
    padding: 0.5rem !important;
    margin: 0.25rem 0 !important;
    line-height: 1.5;
}

/* 文本类输出：不作用于 img/svg，避免图表异常 */
.jupyter-notebook-container .output_area pre,
.jupyter-notebook-container .output_area .output_text,
.jupyter-notebook-container .output_area .output_stream,
.jupyter-notebook-container .jp-OutputArea pre,
.jupyter-notebook-container .jp-OutputArea .output_text {
    color: #000000;
}

.dark .jupyter-notebook-container .output_area pre,
.dark .jupyter-notebook-container .output_area .output_text,
.dark .jupyter-notebook-container .output_area .output_stream,
.dark .jupyter-notebook-container .jp-OutputArea pre,
.dark .jupyter-notebook-container .jp-OutputArea .output_text {
    color: #e6edf3;
}

/* 输出区域的文本 */
.jupyter-notebook-container .output_area .output_text,
.jupyter-notebook-container .jp-OutputArea .output_text {
    padding: 0.25rem 0;
    background-color: transparent !important;
}

/* 输出子元素背景：排除图像/矢量图，避免折损 matplotlib 等输出 */
.jupyter-notebook-container .output_area *:not(img):not(svg):not(canvas):not(video),
.jupyter-notebook-container .jp-OutputArea *:not(img):not(svg):not(canvas):not(video) {
    background-color: transparent !important;
}

/* 但保留错误输出的背景色 */
.jupyter-notebook-container .output_error,
.jupyter-notebook-container .traceback {
    background-color: #fee2e2 !important;
}

.dark .jupyter-notebook-container .output_error,
.dark .jupyter-notebook-container .traceback {
    background-color: #7f1d1d !important;
}

/* 单元格容器 */
.jupyter-notebook-container .cell {
    margin-bottom: 0.5rem;
}

/* 输出文本内容（不用通配符，保留 DataFrame/HTML 内联样式） */
.jupyter-notebook-container .output_text,
.jupyter-notebook-container .output_stream {
    color: #000000;
}

.dark .jupyter-notebook-container .output_text,
.dark .jupyter-notebook-container .output_stream {
    color: #d1d5db;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .jupyter-notebook-container {
        font-size: 13px;
    }
    
    .jupyter-notebook-container .jp-InputArea,
    .jupyter-notebook-container .input_area,
    .jupyter-notebook-container .jp-OutputArea,
    .jupyter-notebook-container .output_area {
        padding: 0.4rem;
        margin: 0.2rem 0;
    }
    
    .jupyter-notebook-container .cell {
        margin-bottom: 0.4rem;
    }
    
    .jupyter-notebook-container table th,
    .jupyter-notebook-container table td {
        padding: 0.25rem 0.3rem;
        font-size: 0.8rem;
    }
}

