/* ========================================
   NOTEBOOK MODE STYLES
   ======================================== */

/* Notebook Editor (separate from code editor) */
.notebook-editor {
  flex: 1;
  min-width: 0;
  max-width: 100%;  /* Prevent overflow */
  height: 100%;  /* Full height */
  min-height: 100%;  /* Don't allow shrinking */
  max-height: 100%;  /* Don't allow growing */
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--code-bg);
  color: var(--text-primary);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-right: 5px;
  position: relative;  /* Establish positioning context */
}

.notebook-editor .CodeMirror {
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  font-family: 'JetBrains Mono', monospace !important;
  background: var(--code-bg) !important;
  color: var(--text-primary) !important;
  flex: 1;  /* Take all available space */
}

/* ========================================
   CODE BLOCK HIGHLIGHTING IN EDITOR
   ======================================== */

/* Subtle background for code blocks in notebook editor */
.notebook-editor .cm-code-block-marker {
  /* The fence markers themselves (```python and ```) */
  color: var(--accent);
  font-weight: 600;
  opacity: 0.7;
}

/* Highlight entire lines within code blocks */
.notebook-editor .CodeMirror-linebackground.code-block-line {
  background: var(--code-block-bg) !important;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 0;
}

/* Add a subtle left border to code block lines */
.notebook-editor .CodeMirror-linebackground.code-block-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.3;
}

/* First line of code block (```python) */
.notebook-editor .CodeMirror-linebackground.code-block-start {
  background: var(--code-block-bg) !important;
  border-top: 1px solid var(--border);
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

/* Last line of code block (```) */
.notebook-editor .CodeMirror-linebackground.code-block-end {
  background: var(--code-block-bg) !important;
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

/* ========================================
   THEME-SPECIFIC CODE BLOCK BACKGROUNDS
   ======================================== */

/* Light/Ice Theme */
.light .notebook-editor .CodeMirror-linebackground.code-block-line,
.light .notebook-editor .CodeMirror-linebackground.code-block-start,
.light .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(59, 130, 246, 0.04);
}

/* Dark/Lunar Sea Theme */
.dark .notebook-editor .CodeMirror-linebackground.code-block-line,
.dark .notebook-editor .CodeMirror-linebackground.code-block-start,
.dark .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(96, 165, 250, 0.08);
}

/* Elegant/Mystic Queen Theme */
.elegant .notebook-editor .CodeMirror-linebackground.code-block-line,
.elegant .notebook-editor .CodeMirror-linebackground.code-block-start,
.elegant .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(139, 125, 216, 0.08);
}

/* Contrast/Separation Theme */
.contrast .notebook-editor .CodeMirror-linebackground.code-block-line,
.contrast .notebook-editor .CodeMirror-linebackground.code-block-start,
.contrast .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(0, 255, 0, 0.06);
}

/* Caravan/Camel Theme */
.caravan .notebook-editor .CodeMirror-linebackground.code-block-line,
.caravan .notebook-editor .CodeMirror-linebackground.code-block-start,
.caravan .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(184, 133, 106, 0.08);
}

/* Meadow/Mirage Theme */
.meadow .notebook-editor .CodeMirror-linebackground.code-block-line,
.meadow .notebook-editor .CodeMirror-linebackground.code-block-start,
.meadow .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(136, 176, 143, 0.08);
}


/* Notebook Preview Pane - Replaces right panel in notebook mode */
.notebook-preview-pane {
  display: none;
  flex: 0 0 45%;  /* Match right-panel width */
  flex-direction: column;
  height: 100%;
  min-height: 100%;  /* Don't allow shrinking */
  max-height: 100%;  /* Don't allow growing */
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;  /* Allow shrinking */
  max-width: 100%;  /* Prevent overflow */
}

.notebook-preview-pane.active {
  display: flex;
}

.notebook-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.notebook-preview-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.notebook-preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg-tertiary);
}

/* Mode Toggle */
.mode-toggle-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-tertiary);
  padding: 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.mode-toggle-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  font-family: 'Sora', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-toggle-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.mode-toggle-btn.active {
  background: var(--accent);
  color: white;
}

.mode-toggle-btn .icon {
  width: 16px;
  height: 16px;
}

/* Notebook Preview Pane */
.notebook-preview {
  flex: 1;
  padding: 2rem 3rem;
  overflow-y: auto;
  background: var(--bg-primary);
  font-family: 'Sora', sans-serif;
  display: none;
  line-height: 1.7;
}

.notebook-preview.active {
  display: block;
}

.notebook-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
}

.notebook-preview-placeholder-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.notebook-preview-placeholder h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.notebook-preview-placeholder p {
  font-size: 0.875rem;
  margin-bottom: 1rem;
  max-width: 400px;
}

.notebook-preview-placeholder-example {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  text-align: left;
  margin-top: 1rem;
  color: var(--text-primary);
  max-width: 500px;
}

/* Notebook Cell Container */
.notebook-cell {
  margin-bottom: 2.5rem;
  animation: slideIn 0.3s ease;
  position: relative;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Markdown Cells */
.notebook-cell-markdown {
  color: var(--text-primary);
}

.notebook-cell-markdown h1 {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 700;
  border-bottom: 3px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  margin-top: 2rem;
}

.notebook-cell-markdown h1:first-child {
  margin-top: 0;
}

.notebook-cell-markdown h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--border);
}

.notebook-cell-markdown h3 {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.notebook-cell-markdown h4 {
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.notebook-cell-markdown p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

.notebook-cell-markdown ul,
.notebook-cell-markdown ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.notebook-cell-markdown li {
  margin-bottom: 0.5rem;
}

.notebook-cell-markdown blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.notebook-cell-markdown code {
  background: var(--bg-secondary);
  color: var(--accent);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
}

.notebook-cell-markdown pre code {
  background: none;
  padding: 0;
}

.notebook-cell-markdown a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.notebook-cell-markdown a:hover {
  border-bottom-color: var(--accent);
}

.notebook-cell-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
}

.notebook-cell-markdown th,
.notebook-cell-markdown td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.notebook-cell-markdown th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

.notebook-cell-markdown img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
}

/* Code Cells */
.notebook-cell-code {
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s ease;
}

.notebook-cell-code:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--shadow);
}

.notebook-code-header {
  background: var(--bg-tertiary);
  padding: 0.5rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.notebook-cell-number {
  color: var(--accent);
}

.notebook-cell-status {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-secondary);
}

.notebook-cell-status.running {
  background: #f59e0b;
  color: white;
  animation: pulse 1s ease-in-out infinite;
}

.notebook-cell-status.complete {
  background: #10b981;
  color: white;
}

.notebook-cell-status.error {
  background: #ef4444;
  color: white;
}

.notebook-code-input {
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  background: var(--code-bg);
  color: var(--text-primary);
  margin: 0;
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre;
}

/* Code Output */
.notebook-code-output {
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
}

.notebook-output-header {
  padding: 0.5rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.notebook-code-output pre {
  padding: 1rem;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow-x: auto;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
}

/* Empty output state */
.notebook-code-output.empty {
  display: none;
}

/* Plots in Cells */
.notebook-plots {
  padding: 1rem;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
}

.notebook-plot {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow);
}

.notebook-plot + .notebook-plot {
  margin-top: 1rem;
}

/* Execution Progress */
.notebook-progress {
  position: fixed;
  top: 4rem;
  right: 1rem;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 1000;
  min-width: 250px;
  display: none !important; /* Force hide by default */
  visibility: hidden; /* Double insurance */
}

.notebook-progress.active {
  display: block !important;
  visibility: visible;
  animation: slideIn 0.3s ease;
}

.notebook-progress-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.notebook-progress-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  /* Animation only when parent is active */
}

.notebook-progress.active .notebook-progress-spinner {
  animation: spin 0.8s linear infinite;
}

.notebook-progress-status {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.notebook-progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.notebook-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* Export Button */
.btn-export-html {
  display: none;
}

.notebook-mode .btn-export-html {
  display: flex;
}

/* Hide code mode elements in notebook mode */
.notebook-mode .code-mode-only {
  display: none !important;
}

/* Ensure main-content doesn't overflow in notebook mode */
.notebook-mode .main-content {
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  height: 100%;  /* Explicit height */
}

/* Ensure editor-panel maintains full height in notebook mode */
.notebook-mode .editor-panel {
  height: 100%;
  min-height: 0;
  flex: 0 0 55%;  /* Maintain width flex but force full height */
}

/* Notebook Toolbar */
.notebook-toolbar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.notebook-mode .notebook-toolbar {
  display: flex;
}

.notebook-toolbar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Contrast Theme Adjustments */
.editor-container.contrast .notebook-cell-code {
  border: 2px solid #ffffff;
}

.editor-container.contrast .notebook-code-header {
  border-bottom: 2px solid #ffffff;
}

/* Responsive */
@media (max-width: 768px) {
  .notebook-preview {
    padding: 1rem;
  }
  
  .notebook-cell-markdown h1 {
    font-size: 1.5rem;
  }
  
  .notebook-cell-markdown h2 {
    font-size: 1.25rem;
  }
}

/* Print Styles for Export */
@media print {
  .notebook-preview {
    background: white;
    padding: 1in;
  }
  
  .notebook-cell {
    page-break-inside: avoid;
  }
  
  .notebook-cell-code {
    border: 1px solid #ddd;
  }
}

/* ========================================
   NOTEBOOK CELL VISIBILITY CONTROLS
   For controlling what appears in exports
   ======================================== */

/* Visibility controls container */
.notebook-visibility-controls {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
  align-items: center;
}

/* Individual toggle button */
.notebook-visibility-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'Sora', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.notebook-visibility-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px var(--shadow);
}

.notebook-visibility-toggle:active {
  transform: translateY(0);
}

/* Active state (visible in export) */
.notebook-visibility-toggle.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.notebook-visibility-toggle.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Inactive state (hidden in export) */
.notebook-visibility-toggle.inactive {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--border);
  opacity: 0.7;
}

.notebook-visibility-toggle.inactive:hover {
  opacity: 1;
  background: var(--bg-secondary);
}

/* ========================================
   EXPORT HIDDEN STATE (VISUAL FEEDBACK)
   ======================================== */

/* Gray out elements that won't appear in export */
.export-hidden {
  opacity: 0.4;
  position: relative;
}

.export-hidden::after {
  content: '🚫 Hidden in export';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  z-index: 10;
}

.export-hidden:hover::after {
  opacity: 1;
}

/* Make code input grayed out when hidden */
.notebook-code-input.export-hidden {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  border-left: 3px solid #ef4444;
}

/* Make output sections grayed when hidden */
.notebook-code-output.export-hidden,
.notebook-plots.export-hidden {
  background: var(--bg-tertiary);
  opacity: 0.5;
  border-left: 3px solid #ef4444;
}

.notebook-plots.export-hidden img {
  opacity: 0.3;
  filter: grayscale(80%);
}

/* ========================================
   THEME-SPECIFIC ADJUSTMENTS
   ======================================== */

/* Light theme */
.light .notebook-visibility-toggle {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.light .export-hidden::after {
  background: rgba(0, 0, 0, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Dark theme */
.dark .notebook-visibility-toggle {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dark .export-hidden::after {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Elegant theme */
.elegant .notebook-visibility-toggle {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.elegant .export-hidden::after {
  background: rgba(139, 125, 216, 0.95);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 125, 216, 0.3);
}

/* Contrast theme */
.contrast .notebook-visibility-toggle {
  border-width: 2px;
  font-weight: 700;
}

.contrast .notebook-visibility-toggle.active {
  background: #00ff00;
  color: #000000;
  border-color: #00ff00;
}

.contrast .export-hidden::after {
  background: #ffff00;
  color: #000000;
  border: 2px solid #ffffff;
}

/* Caravan theme */
.caravan .export-hidden::after {
  background: rgba(184, 133, 106, 0.95);
  color: white;
}

/* Meadow theme */
.meadow .export-hidden::after {
  background: rgba(206, 235, 211, 0.95);
  color: #2d3e2f;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .notebook-visibility-controls {
    flex-wrap: wrap;
  }
  
  .notebook-visibility-toggle {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
  }
  
  .export-hidden::after {
    font-size: 0.65rem;
    padding: 0.4rem 0.75rem;
  }
}

/* ========================================
   PRINT STYLES (FOR PDF EXPORT)
   ======================================== */

@media print {
  /* Hide visibility controls in print/PDF export */
  .notebook-visibility-controls {
    display: none !important;
  }
  
  /* Actually hide elements marked as export-hidden */
  .export-hidden {
    display: none !important;
  }
  
  /* Remove graying effect in print preview */
  .notebook-code-input,
  .notebook-code-output,
  .notebook-plots {
    opacity: 1 !important;
    background: white !important;
  }
}

/* ========================================
   EXPORT PREVIEW MODE
   (For future HTML export feature)
   ======================================== */

.export-preview-mode .notebook-visibility-controls {
  display: none;
}

.export-preview-mode .export-hidden {
  display: none;
}

/* ========================================
   TOOLTIPS & HINTS
   ======================================== */

/* Enhanced tooltip for toggle buttons */
.notebook-visibility-toggle[title]:hover::before {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.7rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.notebook-visibility-toggle[title]:hover::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 0.1rem);
  left: 50%;
  transform: translateX(-50%);
  border: 0.35rem solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 1000;
}

/* ========================================
   CODE BLOCK HIGHLIGHTING IN EDITOR - CORRECTED
   ======================================== */

/* IMPORTANT: CodeMirror background classes create .CodeMirror-linebackground elements */

/* Highlight entire lines within code blocks */
.notebook-editor .CodeMirror-linebackground.code-block-line {
  background: var(--code-block-bg) !important;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 0;
}

/* Add a subtle left border to code block lines */
.notebook-editor .CodeMirror-linebackground.code-block-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.3;
  z-index: 1;
}

/* First line of code block (```python) */
.notebook-editor .CodeMirror-linebackground.code-block-start {
  background: var(--code-block-bg) !important;
  border-top: 1px solid var(--border);
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

/* Last line of code block (```) */
.notebook-editor .CodeMirror-linebackground.code-block-end {
  background: var(--code-block-bg) !important;
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

/* Style the fence markers (```python and ```) */
.notebook-editor .cm-code-block-marker {
  color: var(--accent);
  font-weight: 600;
  opacity: 0.7;
}

/* ========================================
   THEME-SPECIFIC CODE BLOCK BACKGROUNDS
   ======================================== */

/* Light/Ice Theme */
.light .notebook-editor .CodeMirror-linebackground.code-block-line,
.light .notebook-editor .CodeMirror-linebackground.code-block-start,
.light .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(59, 130, 246, 0.1);
}

/* Dark/Lunar Sea Theme */
.dark .notebook-editor .CodeMirror-linebackground.code-block-line,
.dark .notebook-editor .CodeMirror-linebackground.code-block-start,
.dark .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(96, 165, 250, 0.1);
}

/* Elegant/Mystic Queen Theme */
.elegant .notebook-editor .CodeMirror-linebackground.code-block-line,
.elegant .notebook-editor .CodeMirror-linebackground.code-block-start,
.elegant .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(139, 125, 216, 0.1);
}

/* Contrast/Separation Theme */
.contrast .notebook-editor .CodeMirror-linebackground.code-block-line,
.contrast .notebook-editor .CodeMirror-linebackground.code-block-start,
.contrast .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(0, 255, 0, 0.1);
}

/* Caravan/Camel Theme */
.caravan .notebook-editor .CodeMirror-linebackground.code-block-line,
.caravan .notebook-editor .CodeMirror-linebackground.code-block-start,
.caravan .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(184, 133, 106, 0.1);
}

/* Meadow/Mirage Theme */
.meadow .notebook-editor .CodeMirror-linebackground.code-block-line,
.meadow .notebook-editor .CodeMirror-linebackground.code-block-start,
.meadow .notebook-editor .CodeMirror-linebackground.code-block-end {
  --code-block-bg: rgba(136, 176, 143, 0.1);
}

/* Fallback if CSS variables aren't working */
.notebook-editor .CodeMirror-linebackground.code-block-line {
  background: rgba(59, 130, 246, 0.04) !important;
}

.dark .notebook-editor .CodeMirror-linebackground.code-block-line {
  background: rgba(96, 165, 250, 0.1) !important;
}