/* Notebook view — main-canvas takeover, scoped under .nb-workspace and body.notebook-mode. */

/* Layout toggle: hide the flowchart UI when notebook mode is active. */
body.notebook-mode .pipeline-run,
body.notebook-mode #chart_container,
body.notebook-mode .footer,
body.notebook-mode .zoom-controls { display: none !important; }
body.notebook-mode .content { padding: 0; }

/* Notebook list cards inherit .pipeline-list-row + .pipeline-list-item styling.
   Only the per-card icon size needs a small adjustment — same as existing list cards. */
.pipeline-panel--notebooks .activity-icon svg { width: 20px; height: 20px; color: #1f4fd6; }
.pipeline-panel--notebooks .pipeline-options-trigger svg { width: 14px; height: 14px; }

/* Notebook workspace — fills the main canvas area. */
.nb-workspace {
  font-family: "Space Grotesk", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 24px;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
}
.nb-workspace[hidden] { display: none; }

.nb-workspace .nb-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02), 0 4px 14px rgba(15, 23, 42, 0.04);
}

.nb-workspace .nb-toolbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  min-width: 240px;
}

.nb-workspace .nb-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nb-workspace .nb-toolbar-divider {
  width: 1px;
  height: 22px;
  background: rgba(15, 23, 42, 0.1);
  margin: 0 4px;
}

.nb-workspace .nb-name-input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  font-size: 15px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 600;
  color: #0f172a;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.nb-workspace .nb-name-input::placeholder {
  color: rgba(15, 23, 42, 0.4);
  font-weight: 500;
}
.nb-workspace .nb-name-input:hover {
  background: rgba(15, 23, 42, 0.04);
}
.nb-workspace .nb-name-input:focus {
  outline: none;
  background: #ffffff;
  border-color: rgba(31, 79, 214, 0.45);
  box-shadow: 0 0 0 3px rgba(31, 79, 214, 0.12);
}

.nb-workspace .nb-kernel-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.nb-workspace .nb-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}
.nb-workspace .nb-kernel-status.nb-busy {
  color: #1d4ed8;
  background: rgba(219, 234, 254, 0.6);
}
.nb-workspace .nb-kernel-status.nb-busy .nb-status-dot {
  background: #1d4ed8;
  box-shadow: 0 0 0 4px rgba(31, 79, 214, 0.18);
  animation: nb-pulse 1.4s ease-in-out infinite;
}
.nb-workspace .nb-kernel-status.nb-error {
  color: #b91c1c;
  background: rgba(254, 226, 226, 0.6);
}
.nb-workspace .nb-kernel-status.nb-error .nb-status-dot { background: #b91c1c; }

@keyframes nb-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ---- Notebook toolbar buttons ------------------------------------------- */
.nb-workspace .nb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  height: 32px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #0f172a;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.nb-workspace .nb-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.nb-workspace .nb-btn:hover {
  background: rgba(15, 23, 42, 0.06);
}
.nb-workspace .nb-btn:active {
  background: rgba(15, 23, 42, 0.1);
}
.nb-workspace .nb-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 79, 214, 0.18);
}

.nb-workspace .nb-btn-icon {
  width: 32px;
  padding: 0;
  color: #475569;
}
.nb-workspace .nb-btn-icon:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.06);
}

.nb-workspace .nb-btn-primary {
  background: #1f4fd6;
  border-color: #1f4fd6;
  color: #ffffff;
  padding: 6px 14px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}
.nb-workspace .nb-btn-primary:hover {
  background: #1438a8;
  border-color: #1438a8;
  color: #ffffff;
}
.nb-workspace .nb-btn-primary:active {
  background: #102b85;
}
.nb-workspace .nb-btn-primary.nb-save-dirty {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1f2937;
}
.nb-workspace .nb-btn-primary.nb-save-dirty:hover {
  background: #d97706;
  border-color: #d97706;
  color: #ffffff;
}

.nb-workspace .nb-btn-run {
  color: #166534;
  border-color: rgba(22, 101, 52, 0.25);
  background: rgba(220, 252, 231, 0.6);
  padding: 6px 14px;
}
.nb-workspace .nb-btn-run:hover {
  color: #ffffff;
  background: #16a34a;
  border-color: #16a34a;
}
.nb-workspace .nb-btn-run:active { background: #15803d; }

.nb-workspace .nb-btn-stop {
  color: #94a3b8;
}
.nb-workspace .nb-btn-stop:hover {
  color: #b91c1c;
  background: rgba(254, 226, 226, 0.7);
}

.nb-workspace .nb-btn-toggle.is-active {
  color: #1d4ed8;
  background: rgba(31, 79, 214, 0.1);
}
.nb-workspace .nb-btn-toggle.is-active:hover {
  background: rgba(31, 79, 214, 0.15);
}

/* Backwards-compat: the old `.buttons` shim if any code path still emits one */
.nb-workspace .nb-toolbar .buttons {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.nb-workspace .nb-toolbar .buttons:hover {
  background: rgba(15, 23, 42, 0.06);
  transform: none;
}

.nb-workspace .nb-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}
.nb-workspace .nb-body:has(#nb_vars_panel:not([hidden])) {
  grid-template-columns: 1fr 320px;
}

.nb-workspace .nb-cells {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.nb-workspace .nb-cell {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.nb-workspace .nb-cell.nb-queued  { border-color: rgba(107, 124, 147, 0.35); }
.nb-workspace .nb-cell.nb-running { border-color: rgba(31, 79, 214, 0.35); box-shadow: 0 4px 14px rgba(31, 79, 214, 0.12); }
.nb-workspace .nb-cell.nb-error   { border-color: rgba(220, 38, 38, 0.35); }
.nb-workspace .nb-cell.nb-selected {
  border-left: 3px solid #1f4fd6;
  box-shadow: 0 4px 14px rgba(31, 79, 214, 0.08);
}

.nb-workspace .nb-cell-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  font-size: 12px;
}

.nb-workspace .nb-exec-badge {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  color: #1f4fd6;
  min-width: 38px;
  text-align: right;
  letter-spacing: 0.4px;
}

.nb-workspace .nb-cell-type-select {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: white;
  cursor: pointer;
  font-weight: 600;
  color: #475569;
}
.nb-workspace .nb-cell-type-select:hover { border-color: rgba(31, 79, 214, 0.4); }

.nb-workspace .nb-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nb-workspace .nb-cell.nb-idle    .nb-status-pill { background: #e2e8f0; color: #475569; }
.nb-workspace .nb-cell.nb-queued  .nb-status-pill { background: #e2e8f0; color: #475569; }
.nb-workspace .nb-cell.nb-running .nb-status-pill { background: #dbeafe; color: #1d4ed8; }
.nb-workspace .nb-cell.nb-success .nb-status-pill { background: #dcfce7; color: #166534; }
.nb-workspace .nb-cell.nb-error   .nb-status-pill { background: #fee2e2; color: #991b1b; }

.nb-workspace .nb-spinner {
  width: 10px; height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: nb-spin 0.7s linear infinite;
  display: none;
}
.nb-workspace .nb-cell.nb-running .nb-spinner { display: inline-block; }
@keyframes nb-spin { to { transform: rotate(360deg); } }

.nb-workspace .nb-drag-handle {
  cursor: grab;
  color: #94a3b8;
  font-weight: 700;
  user-select: none;
}

.nb-workspace .nb-cell-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.nb-workspace .nb-cell-actions button {
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: #475569;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nb-workspace .nb-cell-actions button:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}
.nb-workspace .nb-cell-actions .nb-run {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.4);
  display: inline-flex;
  align-items: center;
}
.nb-workspace .nb-cell-actions .nb-run svg { display: block; }
.nb-workspace .nb-cell-actions .nb-run:hover {
  background: rgba(16, 185, 129, 0.2);
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.6);
}

.nb-workspace .nb-cell-editor { padding: 4px 0; }
.nb-workspace .nb-cell-editor .CodeMirror {
  height: auto;
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", monospace;
  font-size: 13px;
}

.nb-workspace .nb-cell-output {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  padding: 8px 12px;
  font-size: 13px;
  background: #fafafa;
}
.nb-workspace .nb-cell-output:empty { display: none; }
.nb-workspace .nb-cell-output pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}
.nb-workspace .nb-cell-output pre.nb-stderr { color: #b91c1c; background: #fef2f2; padding: 6px 8px; border-radius: 4px; }
.nb-workspace .nb-cell-output pre.nb-stdout { color: #0f172a; }
.nb-workspace .nb-cell-output pre.nb-result { color: #0f172a; padding: 4px 0 0 0; border-top: 1px dashed rgba(15, 23, 42, 0.1); margin-top: 6px; }
.nb-workspace .nb-cell-output .nb-no-output { color: #94a3b8; font-style: italic; font-size: 12px; }
.nb-workspace .nb-cell-output .nb-duration { color: #94a3b8; font-size: 11px; margin-top: 4px; text-align: right; }

:is(.nb-workspace, .sql-results-panel) .nb-df {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}
:is(.nb-workspace, .sql-results-panel) .nb-df th, :is(.nb-workspace, .sql-results-panel) .nb-df td {
  border: 1px solid rgba(15, 23, 42, 0.1);
  padding: 4px 8px;
  text-align: left;
}
:is(.nb-workspace, .sql-results-panel) .nb-df th {
  background: #f1f5f9;
  position: sticky;
  top: 0;
}
:is(.nb-workspace, .sql-results-panel) .nb-df-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 4px;
}
:is(.nb-workspace, .sql-results-panel) .nb-df-footer {
  font-size: 11px;
  color: #64748b;
  padding-top: 4px;
}

.nb-workspace .nb-add-cell {
  align-self: center;
  background: transparent;
  border: 1px dashed rgba(31, 79, 214, 0.35);
  color: #1f4fd6;
  padding: 8px 22px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: "Space Grotesk", system-ui, sans-serif;
  letter-spacing: 0.2px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.nb-workspace .nb-add-cell:hover {
  background: rgba(31, 79, 214, 0.06);
  border-color: rgba(31, 79, 214, 0.6);
  color: #143b9a;
}

/* ---------- Markdown cells ---------- */

.nb-workspace .nb-cell-type-markdown { background: #fffdf6; border-color: rgba(180, 83, 9, 0.18); }
.nb-workspace .nb-cell-type-markdown .nb-cell-header { background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%); }
.nb-workspace .nb-cell-type-markdown .nb-run { display: none; }

.nb-workspace .nb-md-host { padding: 12px 16px; }
.nb-workspace .nb-md-host .nb-md-editor {
  display: none;
  width: 100%;
  min-height: 80px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 13px;
  resize: vertical;
  box-sizing: border-box;
}
.nb-workspace .nb-md-host.nb-md-editing .nb-md-editor { display: block; }
.nb-workspace .nb-md-host.nb-md-editing .nb-md-view { display: none; }

.nb-workspace .nb-md-view { font-size: 14px; line-height: 1.55; color: #1f2937; cursor: text; min-height: 24px; }
.nb-workspace .nb-md-view h1, .nb-workspace .nb-md-view h2, .nb-workspace .nb-md-view h3 {
  margin: 0.5em 0 0.3em;
  font-family: "Space Grotesk", system-ui, sans-serif;
}
.nb-workspace .nb-md-view h1 { font-size: 1.6em; border-bottom: 1px solid rgba(15, 23, 42, 0.1); padding-bottom: 0.2em; }
.nb-workspace .nb-md-view h2 { font-size: 1.3em; }
.nb-workspace .nb-md-view h3 { font-size: 1.1em; }
.nb-workspace .nb-md-view p { margin: 0.4em 0; }
.nb-workspace .nb-md-view ul, .nb-workspace .nb-md-view ol { margin: 0.4em 0 0.4em 1.2em; }
.nb-workspace .nb-md-view code {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.nb-workspace .nb-md-view pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
}
.nb-workspace .nb-md-view pre code { background: transparent; color: inherit; padding: 0; }
.nb-workspace .nb-md-view blockquote {
  border-left: 3px solid rgba(31, 79, 214, 0.3);
  margin: 0.4em 0;
  padding: 4px 12px;
  color: #475569;
  background: rgba(31, 79, 214, 0.04);
}
.nb-workspace .nb-md-view a { color: #1f4fd6; text-decoration: none; }
.nb-workspace .nb-md-view a:hover { text-decoration: underline; }
.nb-workspace .nb-md-view .nb-md-empty { color: #94a3b8; }

/* ---------- Inline Spark progress bar ---------- */

.nb-workspace .nb-spark-bar {
  position: relative;
  height: 8px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

/* ---------- Inline images (matplotlib) ---------- */

.nb-workspace .nb-image {
  max-width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background: #fff;
  display: block;
}

/* ---------- Modern dataframe table ---------- */

:is(.nb-workspace, .sql-results-panel) .nb-df-card {
  margin-top: 6px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

/* Tabs (Table | Chart) — only shown when chartable */
:is(.nb-workspace, .sql-results-panel) .nb-df-tabs {
  display: flex;
  gap: 0;
  background: #f8fafc;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding: 4px 4px 0;
}
:is(.nb-workspace, .sql-results-panel) .nb-df-tab {
  background: transparent;
  border: 0;
  padding: 8px 16px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  position: relative;
  top: 1px;
  transition: color 0.15s ease, background 0.15s ease;
}
:is(.nb-workspace, .sql-results-panel) .nb-df-tab:hover { color: #1f4fd6; }
:is(.nb-workspace, .sql-results-panel) .nb-df-tab-active {
  background: #ffffff;
  color: #1f4fd6;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom-color: #ffffff;
}

:is(.nb-workspace, .sql-results-panel) .nb-df-table-panel[hidden],
:is(.nb-workspace, .sql-results-panel) .nb-chart-panel[hidden] { display: none !important; }

:is(.nb-workspace, .sql-results-panel) .nb-df-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  font-size: 12px;
}
:is(.nb-workspace, .sql-results-panel) .nb-df-filter {
  flex: 1 1 200px;
  max-width: 320px;
  padding: 6px 10px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 6px;
  background: white;
  font-family: inherit;
  font-size: 12px;
}
:is(.nb-workspace, .sql-results-panel) .nb-df-filter:focus {
  outline: none;
  border-color: rgba(31, 79, 214, 0.45);
  box-shadow: 0 0 0 2px rgba(31, 79, 214, 0.12);
}
:is(.nb-workspace, .sql-results-panel) .nb-df-count { color: #64748b; font-size: 11px; }
:is(.nb-workspace, .sql-results-panel) .nb-df-download {
  margin-left: auto;
  background: rgba(31, 79, 214, 0.1);
  border: 1px solid rgba(31, 79, 214, 0.3);
  color: #1f4fd6;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
:is(.nb-workspace, .sql-results-panel) .nb-df-download:hover {
  background: rgba(31, 79, 214, 0.18);
  border-color: rgba(31, 79, 214, 0.55);
}

:is(.nb-workspace, .sql-results-panel) .nb-df-scroll {
  max-height: 420px;
  overflow: auto;
}
:is(.nb-workspace, .sql-results-panel) .nb-df {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
:is(.nb-workspace, .sql-results-panel) .nb-df th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
:is(.nb-workspace, .sql-results-panel) .nb-df th:hover { background: #e2e8f0; }
:is(.nb-workspace, .sql-results-panel) .nb-df th::after { content: ""; display: inline-block; margin-left: 6px; opacity: 0.5; font-size: 10px; }
:is(.nb-workspace, .sql-results-panel) .nb-df th.nb-sort-asc::after  { content: "▲"; opacity: 1; color: #1f4fd6; }
:is(.nb-workspace, .sql-results-panel) .nb-df th.nb-sort-desc::after { content: "▼"; opacity: 1; color: #1f4fd6; }

:is(.nb-workspace, .sql-results-panel) .nb-df td {
  padding: 5px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
:is(.nb-workspace, .sql-results-panel) .nb-df tbody tr:nth-child(even) { background: rgba(15, 23, 42, 0.02); }
:is(.nb-workspace, .sql-results-panel) .nb-df tbody tr:hover { background: rgba(31, 79, 214, 0.06); }

/* ---------- Variables panel ---------- */

.nb-workspace .nb-vars-panel {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: #ffffff;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}
.nb-workspace .nb-vars-panel[hidden] { display: none; }

.nb-workspace .nb-vars-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
}
.nb-workspace .nb-vars-refresh {
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #475569;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.nb-workspace .nb-vars-refresh:hover { color: #1f4fd6; border-color: rgba(31, 79, 214, 0.45); }

.nb-workspace .nb-vars-list {
  overflow-y: auto;
  padding: 6px 0;
  flex: 1;
}
.nb-workspace .nb-vars-empty {
  padding: 16px;
  color: #94a3b8;
  font-size: 12px;
  font-style: italic;
}
.nb-workspace .nb-vars-row {
  display: grid;
  grid-template-columns: minmax(60px, auto) minmax(50px, auto) 1fr;
  gap: 8px;
  padding: 6px 14px;
  font-size: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.04);
  align-items: baseline;
}
.nb-workspace .nb-vars-row:hover { background: rgba(31, 79, 214, 0.04); }
.nb-workspace .nb-vars-name { font-family: ui-monospace, "JetBrains Mono", monospace; font-weight: 600; color: #0f172a; }
.nb-workspace .nb-vars-type { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: rgba(31, 79, 214, 0.1); color: #1f4fd6; text-align: center; align-self: center; }
.nb-workspace .nb-vars-repr {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  color: #475569;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Chart builder ---------- */

:is(.nb-workspace, .sql-results-panel) .nb-chart-panel {
  padding: 14px 16px 18px;
  background: #ffffff;
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 10px;
  margin-bottom: 14px;
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-select {
  padding: 7px 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: #ffffff;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 13px;
  color: #0f172a;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-select:focus {
  outline: none;
  border-color: rgba(31, 79, 214, 0.5);
  box-shadow: 0 0 0 2px rgba(31, 79, 214, 0.15);
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-refresh {
  background: rgba(31, 79, 214, 0.1);
  border: 1px solid rgba(31, 79, 214, 0.3);
  color: #1f4fd6;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  height: 36px;
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-refresh:hover {
  background: rgba(31, 79, 214, 0.18);
  border-color: rgba(31, 79, 214, 0.55);
}

:is(.nb-workspace, .sql-results-panel) .nb-chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 360px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
  box-sizing: border-box;
}
:is(.nb-workspace, .sql-results-panel) .nb-chart-canvas { width: 100% !important; height: 100% !important; }
:is(.nb-workspace, .sql-results-panel) .nb-chart-message {
  margin-top: 10px;
  color: #b91c1c;
  font-size: 12px;
}

/* ---- Inline lint diagnostics ------------------------------------------- */
.nb-workspace .CodeMirror-lint-marker-error,
.nb-workspace .CodeMirror-lint-marker-warning {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: middle;
  background-image: none;
}
.nb-workspace .CodeMirror-lint-marker-error::before,
.nb-workspace .CodeMirror-lint-marker-warning::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin: 2px;
  border-radius: 50%;
}
.nb-workspace .CodeMirror-lint-marker-error::before {
  background: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}
.nb-workspace .CodeMirror-lint-marker-warning::before {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}
.nb-workspace .CodeMirror-lint-mark-error {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='6' height='3' viewBox='0 0 6 3'><path fill='none' stroke='%23dc2626' stroke-width='1' d='M0 2.5 Q1.5 0 3 1.5 T6 1.5'/></svg>");
  background-repeat: repeat-x;
  background-position: 0 100%;
  padding-bottom: 1px;
}
.nb-workspace .CodeMirror-lint-mark-warning {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='6' height='3' viewBox='0 0 6 3'><path fill='none' stroke='%23f59e0b' stroke-width='1' d='M0 2.5 Q1.5 0 3 1.5 T6 1.5'/></svg>");
  background-repeat: repeat-x;
  background-position: 0 100%;
  padding-bottom: 1px;
}
.CodeMirror-lint-tooltip {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  background: #1f2937;
  color: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.85);
  border-radius: 6px;
  padding: 6px 10px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
  max-width: 360px;
  white-space: pre-wrap;
}
.CodeMirror-lint-message-error::before { color: #fca5a5; }
.CodeMirror-lint-message-warning::before { color: #fcd34d; }

/* ---- Code folding gutter ---------------------------------------------- */
.nb-workspace .CodeMirror-foldgutter {
  width: 14px;
}
.nb-workspace .CodeMirror-foldgutter-open,
.nb-workspace .CodeMirror-foldgutter-folded {
  cursor: pointer;
  color: #94a3b8;
  padding-left: 2px;
  font-size: 11px;
  line-height: 1;
  transition: color 0.1s ease;
}
.nb-workspace .CodeMirror-foldgutter-open:hover,
.nb-workspace .CodeMirror-foldgutter-folded:hover {
  color: #1d4ed8;
}
.nb-workspace .CodeMirror-foldgutter-open::after  { content: "▾"; }
.nb-workspace .CodeMirror-foldgutter-folded::after { content: "▸"; color: #1d4ed8; }
.nb-workspace .CodeMirror-foldmarker {
  display: inline-block;
  background: rgba(31, 79, 214, 0.1);
  color: #1d4ed8;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  margin: 0 4px;
  cursor: pointer;
  vertical-align: middle;
}
.nb-workspace .CodeMirror-foldmarker:hover {
  background: rgba(31, 79, 214, 0.2);
}

.nb-workspace .nb-loading-skeleton {
  padding: 24px;
  text-align: center;
  color: #6b7c93;
  font-size: 13px;
}
.nb-workspace .nb-loading-bar {
  position: relative;
  height: 2px;
  width: 100%;
  background: rgba(31, 79, 214, 0.10);
  overflow: hidden;
  z-index: 5;
}
.nb-workspace .nb-loading-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 30%;
  background: #1f4fd6;
  animation: nb-loading-slide 1s ease-in-out infinite;
}
@keyframes nb-loading-slide {
  0%   { left: -30%; }
  100% { left: 100%; }
}
.nb-workspace .nb-loading-bar[hidden] { display: none; }

/* ---- Toast notifications ----------------------------------------------- */
.nb-toast-layer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.nb-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #1f2937;
  color: #f8fafc;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
  opacity: 0;
  transform: translateY(8px);
  animation: nb-toast-in 180ms ease forwards;
}
@keyframes nb-toast-in {
  to { opacity: 1; transform: translateY(0); }
}
.nb-toast-leaving {
  animation: nb-toast-out 200ms ease forwards;
}
@keyframes nb-toast-out {
  to { opacity: 0; transform: translateY(8px); }
}
.nb-toast-error {
  background: #991b1b;
  color: #fff5f5;
  box-shadow: 0 10px 24px rgba(153, 27, 27, 0.32);
}
.nb-toast-info { background: #1f2937; }
.nb-toast-success { background: #166534; }
.nb-toast-message {
  flex: 1;
  word-break: break-word;
}
.nb-toast-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  padding: 0 2px;
}
.nb-toast-close:hover { opacity: 1; }
.nb-toast-clickable { cursor: pointer; }
.nb-toast-clickable:hover { filter: brightness(1.1); }

/* ---- Sidebar Running cells panel -------------------------------------- */
.pipeline-panel--running summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}
.pipeline-panel--running .nb-running-count {
  background: rgba(31, 79, 214, 0.12);
  color: #1d4ed8;
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 700;
}
.nb-running-list {
  max-height: 30vh;
  overflow-y: auto;
  padding: 4px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nb-running-empty {
  color: #94a3b8;
  font-size: 12px;
  padding: 6px 10px;
}
.nb-running-row {
  border: 1px solid rgba(31, 79, 214, 0.18);
  background: rgba(219, 234, 254, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
}
.nb-running-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 2px;
}
.nb-running-meta {
  font-size: 11px;
  color: #475569;
  margin-bottom: 6px;
}
.nb-running-actions {
  display: flex;
  gap: 6px;
}
.nb-running-actions button {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  cursor: pointer;
}
.nb-running-actions .nb-running-stop {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.3);
}
.nb-running-actions .nb-running-stop:hover {
  background: rgba(254, 226, 226, 0.6);
}
.nb-running-actions .nb-running-jump:hover {
  background: rgba(15, 23, 42, 0.06);
}

/* ---- Inline cell-top spark progress bar ------------------------------- */
.nb-cell-output .nb-spark-bar {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #1d4ed8;
  background: rgba(31, 79, 214, 0.08);
  border-radius: 999px;
}

/* ---- Sidebar Spark Settings panel ------------------------------------- */
.pipeline-panel--spark summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}
.nb-spark-panel {
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 35vh;
  overflow-y: auto;
}
.nb-spark-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nb-spark-row label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.nb-spark-row select {
  flex: 1;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 6px;
  background: #fff;
}
.nb-spark-row button {
  font-size: 14px;
  font-weight: 700;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: #fff;
  cursor: pointer;
}
.nb-spark-status {
  font-size: 12px;
  color: #1d4ed8;
  font-weight: 600;
}
.nb-spark-log-header {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.nb-spark-log-header button {
  background: transparent;
  border: none;
  color: #1d4ed8;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}
.nb-spark-log {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 6px;
  padding: 6px 8px;
  margin: 0;
  max-height: 12em;
  overflow-y: auto;
  white-space: pre-wrap;
  color: #334155;
}

/* ---- Notebook list "Running" indicator -------------------------------- */
.nb-list-running { font-weight: 600; }
.nb-list-running-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  margin-left: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
  animation: nb-pulse-green 1.4s ease-in-out infinite;
}
.nb-list-running-label {
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
  margin-left: 6px;
  vertical-align: middle;
}
@keyframes nb-pulse-green {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ── Capped / chunked cell output ───────────────────────────────────────
   Large output is shown a chunk at a time so the page never floods. */
.nb-output-more {
  margin: 4px 0 8px;
}
.nb-output-more-btn {
  cursor: pointer;
  font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 7px;
  border: 1px solid rgba(15,23,42,0.18);
  background: #f1f5f9; color: #1f2937;
}
.nb-output-more-btn:hover { background: #e2e8f0; }
.nb-output-livecap {
  margin: 4px 0 8px; padding: 5px 10px;
  font-size: 11.5px; color: #92400e;
  background: #fef3c7; border-radius: 6px;
  border: 1px solid rgba(217,119,6,0.3);
}

/* ── Ask AI — natural-language Python cell generation ───────────── */
.nb-btn-ai {
  background: linear-gradient(135deg, #6d3bf5, #b13bf5);
  color: #fff; border-color: transparent;
}
.nb-btn-ai:hover { filter: brightness(1.08); }
.nb-btn-ai svg { color: #fff; }

.nb-ai-overlay {
  position: fixed; inset: 0; z-index: 7000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 14vh;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
}
.nb-ai-card {
  width: min(540px, 92vw);
  display: flex; flex-direction: column; gap: 12px;
  padding: 22px; background: #fff; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.32);
  font-family: "Space Grotesk", system-ui, sans-serif;
}
.nb-ai-title { font-size: 18px; font-weight: 700; color: #0f172a; }
.nb-ai-sub { font-size: 12.5px; line-height: 1.5; color: #64748b; }
.nb-ai-sub code {
  background: rgba(109, 59, 245, 0.1); color: #6d3bf5;
  padding: 1px 5px; border-radius: 5px; font-size: 11.5px;
}
.nb-ai-input {
  width: 100%; resize: vertical; box-sizing: border-box;
  padding: 11px 13px; font-size: 13.5px; line-height: 1.5;
  border: 1px solid rgba(15, 23, 42, 0.18); border-radius: 10px;
  font-family: "Space Grotesk", system-ui, sans-serif; color: #0f172a;
}
.nb-ai-input:focus {
  outline: none; border-color: #6d3bf5;
  box-shadow: 0 0 0 3px rgba(109, 59, 245, 0.16);
}
.nb-ai-msg {
  font-size: 12.5px; color: #b4232a;
  background: rgba(180, 35, 42, 0.08);
  padding: 8px 11px; border-radius: 8px;
}
.nb-ai-actions {
  display: flex; justify-content: flex-end; gap: 9px;
}
.nb-ai-go:disabled { opacity: 0.65; cursor: progress; }

/* Per-notebook Spark session picker (toolbar) */
.nb-session-pick {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 4px;
}
.nb-session-lbl {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: #94a3b8;
}
.nb-session-pick select {
  padding: 5px 8px; border-radius: 7px; font-size: 12px;
  border: 1px solid rgba(15,23,42,0.18); background: #fff;
  color: #0f172a; font-family: "Space Grotesk", system-ui, sans-serif;
}

/* ===================================================================
   Dark mode — notebook content + the shared dataframe/chart views
   (:is(.nb-workspace, .sql-results-panel)). These hardcode white/light
   surfaces + dark text; remap to dark tokens so it's readable in dark mode.
   =================================================================== */
html[data-theme="dark"] .nb-workspace { background: var(--surface-2, #0c111a); color: var(--ink-900, #e8edf4); }

/* Card-level surfaces */
html[data-theme="dark"] .nb-workspace .nb-toolbar,
html[data-theme="dark"] .nb-workspace .nb-cell,
html[data-theme="dark"] .nb-workspace .nb-image,
html[data-theme="dark"] .nb-workspace .nb-vars-panel,
html[data-theme="dark"] .nb-workspace .nb-cell-type-select,
html[data-theme="dark"] .nb-workspace .nb-name-input:focus,
html[data-theme="dark"] .nb-running-actions button,
html[data-theme="dark"] .nb-spark-row select,
html[data-theme="dark"] .nb-spark-row button,
html[data-theme="dark"] .nb-session-pick select,
html[data-theme="dark"] .nb-ai-card,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df-card,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df-tab-active,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df-filter,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-chart-panel,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-chart-select,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-chart-canvas-wrap {
  background: var(--surface, #121821);
  border-color: var(--line, #283243);
  color: var(--ink-900, #e8edf4);
}
/* Recessed / header surfaces */
html[data-theme="dark"] .nb-workspace .nb-cell-header,
html[data-theme="dark"] .nb-workspace .nb-cell-output,
html[data-theme="dark"] .nb-workspace .nb-vars-header,
html[data-theme="dark"] .nb-spark-log,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df-tabs,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df-toolbar,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-chart-controls {
  background: var(--surface-2, #0c111a);
  color: var(--ink-900, #e8edf4);
}
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df th,
html[data-theme="dark"] .nb-output-more-btn {
  background: var(--surface-3, #1a212c);
  color: var(--ink-900, #e8edf4);
}
/* Markdown cell keeps a subtle amber tint */
html[data-theme="dark"] .nb-workspace .nb-cell-type-markdown { background: rgba(180, 83, 9, 0.12); }

/* Dark hardcoded text → light */
html[data-theme="dark"] .nb-workspace .nb-name-input,
html[data-theme="dark"] .nb-workspace .nb-md-view,
html[data-theme="dark"] .nb-workspace .nb-vars-name,
html[data-theme="dark"] .nb-workspace .nb-btn,
html[data-theme="dark"] .nb-running-title,
html[data-theme="dark"] .nb-ai-title,
html[data-theme="dark"] .nb-ai-input,
html[data-theme="dark"] .nb-workspace .nb-cell-output pre.nb-result,
html[data-theme="dark"] .nb-workspace .nb-cell-output pre.nb-stdout,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df td,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-chart-select {
  color: var(--ink-900, #e8edf4);
}
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df th,
html[data-theme="dark"] :is(.nb-workspace, .sql-results-panel) .nb-df td {
  border-color: var(--line, #283243);
}
