/* ═══════════════════════════════════════════════════════════════
   DS WALLAH Python Lab — Original Notebook Theme
   Inspired by cloud IDEs, NOT a copy of any product.
   Original colors, fonts, and layout by DSWallah.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* DS Wallah Original Palette */
  --bg-deep: #0c0e1a;
  --bg-primary: #111328;
  --bg-secondary: #161836;
  --bg-surface: #1c1f42;
  --bg-elevated: #232650;
  --bg-hover: #2a2e5c;
  --bg-active: #333770;
  --border: #2a2e5c;
  --border-light: #363a70;
  --border-focus: #f59e0b;
  --text-primary: #eef0ff;
  --text-secondary: #a3a7cc;
  --text-muted: #6b6fa0;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-dim: rgba(245,158,11,0.1);
  --accent-border: rgba(245,158,11,0.25);
  --green: #34d399;
  --green-dim: rgba(52,211,153,0.1);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.1);
  --orange: #fb923c;
  --orange-dim: rgba(251,146,60,0.1);
  --purple: #a78bfa;
  --purple-dim: rgba(167,139,250,0.1);
  --cyan: #22d3ee;
  --cyan-dim: rgba(34,211,238,0.1);
  --blue: #60a5fa;
  --blue-dim: rgba(96,165,250,0.1);
  --cell-bg: #1c1f42;
  --cell-active-border: #f59e0b;
  --cell-running-border: #34d399;
  --cell-error-border: #f87171;
  --sidebar-width: 240px;
  --topbar-height: 48px;
  --bottom-panel-height: 200px;
  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ═══════════════ TOP MENU BAR ═══════════════ */
#topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 100;
  flex-shrink: 0;
  position: relative;
}

#topbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.3;
}

.topbar-left { display: flex; align-items: center; gap: 18px; }

.topbar-brand { display: flex; align-items: center; gap: 8px; }

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: -0.03em;
  box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.topbar-menus { display: flex; gap: 2px; }

.menu-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.menu-btn.active { background: var(--bg-active); color: var(--accent); }

.topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.runtime-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse-dot 2s ease infinite;
}

.status-dot.connected { background: var(--green); animation: none; }
.status-dot.error { background: var(--red); animation: none; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-action {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.topbar-action:hover { background: var(--bg-hover); color: var(--text-primary); }

.topbar-action.btn-run {
  background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(239,68,68,0.1));
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(245,158,11,0.1);
}

.topbar-action.btn-run:hover {
  background: linear-gradient(135deg, rgba(245,158,11,0.25), rgba(239,68,68,0.15));
  box-shadow: 0 0 20px rgba(245,158,11,0.2);
}

.topbar-action.btn-stop {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(248,113,113,0.25);
}

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.topbar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.topbar-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.save-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 8px;
}

.profile-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  transition: all 0.15s;
}

.profile-btn:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ═══════════════ MAIN LAYOUT ═══════════════ */
#mainLayout {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}

/* ═══════════════ LEFT SIDEBAR ═══════════════ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.25s ease, opacity 0.25s ease;
}

.sidebar.collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar-actions {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  justify-content: center;
}

.sidebar-btn:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--accent-border); }

.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.tree-section { margin-bottom: 4px; }

.tree-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.tree-section-header:hover { color: var(--text-secondary); }

.tree-items { padding-left: 8px; }

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 20px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  margin: 1px 6px;
  transition: all 0.1s;
}

.tree-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.tree-item.active { background: var(--accent-dim); color: var(--accent); }

.tree-item-icon { font-size: 14px; flex-shrink: 0; }
.tree-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item-size { font-size: 10px; color: var(--text-muted); }

.sidebar-bottom {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.runtime-info, .packages-info {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}

.runtime-label, .packages-label { font-weight: 600; }

/* ═══════════════ NOTEBOOK AREA ═══════════════ */
.notebook-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.notebook-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.notebook-title-input {
  background: none;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  outline: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  min-width: 200px;
  transition: all 0.15s;
}

.notebook-title-input:hover { background: var(--bg-hover); }
.notebook-title-input:focus { background: var(--bg-surface); border-color: var(--border-light); }

.notebook-meta { display: flex; gap: 8px; margin-left: auto; }

.notebook-badge {
  font-size: 10px;
  color: var(--text-muted);
  padding: 3px 10px;
  background: var(--bg-surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.cells-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 80px;
  background: var(--bg-deep);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(245,158,11,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139,92,246,0.03) 0%, transparent 50%);
}

.cells-container {
  max-width: 860px;
  margin: 0 auto;
}

.cells-footer {
  max-width: 860px;
  margin: 20px auto 0;
  text-align: center;
}

.add-cell-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px dashed var(--border-light);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.add-cell-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ═══════════════ CELLS ═══════════════ */
.cell {
  position: relative;
  margin-bottom: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--cell-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.cell::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  transition: background 0.2s;
}

.cell:hover { border-color: var(--border-light); }
.cell:hover::before { background: var(--text-muted); }

.cell.cell-active {
  border-color: var(--cell-active-border);
  box-shadow: 0 0 0 2px rgba(245,158,11,0.12);
}
.cell.cell-active::before { background: var(--accent); }

.cell.cell-running {
  border-color: var(--cell-running-border);
  box-shadow: 0 0 0 2px rgba(52,211,153,0.12);
}
.cell.cell-running::before { background: var(--green); }

.cell.cell-error {
  border-color: var(--cell-error-border);
  box-shadow: 0 0 0 2px rgba(248,113,113,0.12);
}
.cell.cell-error::before { background: var(--red); }

/* Cell Toolbar */
.cell-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px 0;
}

.cell-toolbar button,
.cell-toolbar select {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.12s;
}

.cell-toolbar button:hover { color: var(--text-primary); background: var(--bg-hover); }

.cell-type-sel, .cell-size-sel {
  height: 22px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 0 4px;
  cursor: pointer;
  outline: 0;
}

.cell-type-sel:focus, .cell-size-sel:focus { border-color: var(--accent); }
.cell-type-sel option, .cell-size-sel option { background: var(--bg-surface); color: var(--text-secondary); }
.cell-size-sel { width: 44px; margin-left: 2px; }

.cell-tb-run { color: var(--accent) !important; font-weight: 600; }
.cell-tb-run:hover { background: var(--accent-dim) !important; }
.cell-tb-dl { color: var(--green) !important; }
.cell-tb-dl:hover { background: var(--green-dim) !important; }
.cell-tb-del:hover { color: var(--red) !important; background: var(--red-dim) !important; }

/* Cell Row — no left gutter, input fills width */
.cell-row {
  display: flex;
  align-items: stretch;
}

/* Cell Input */
.cell-input {
  flex: 1;
  min-width: 0;
  padding: 8px 14px;
}

.cell-input textarea,
.cell-input .CodeMirror {
  min-height: 42px;
  max-height: 500px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: transparent !important;
  color: var(--text-primary) !important;
}

.cell-input .CodeMirror {
  border: none !important;
  height: auto !important;
}

.cell-input .CodeMirror-gutters {
  background: transparent !important;
  border-right: 1px solid var(--border) !important;
}

.cell-input .CodeMirror-linenumber { color: var(--text-muted) !important; }
.cell-input .CodeMirror-cursor { border-left: 2px solid var(--accent) !important; }
.cell-input .CodeMirror-selected { background: rgba(245,158,11,0.12) !important; }

/* Cell Run Button — top-right floating, NOT left gutter */
.cell-runbtn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  opacity: 0;
  z-index: 5;
}

.cell:hover .cell-runbtn,
.cell.cell-active .cell-runbtn { opacity: 1; }
.cell-runbtn:hover { background: var(--accent-dim); border-color: var(--accent); transform: scale(1.1); }
.cell.cell-running .cell-runbtn {
  opacity: 1;
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
  cursor: not-allowed;
  animation: pulse-run 1s ease infinite;
}

@keyframes pulse-run {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
}

.cell-spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Cell Markdown Preview */
.cell-md-preview {
  padding: 8px 0;
  color: var(--text-primary);
  line-height: 1.6;
  cursor: pointer;
  min-height: 40px;
}

.cell-md-preview:hover { opacity: 0.85; }
.cell-md-preview h1, .cell-md-preview h2, .cell-md-preview h3 { margin: 8px 0 4px; font-weight: 700; }
.cell-md-preview p { margin: 4px 0; }
.cell-md-preview code {
  background: var(--bg-surface);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.cell-md-preview pre {
  background: var(--bg-surface);
  padding: 10px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.cell-md-preview pre code { background: none; padding: 0; }
.cell-md-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-secondary);
}

/* Cell Output */
.cell-output {
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.1);
}

.cell-output[hidden] { display: none; }

.cell-out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(0,0,0,0.15);
  border-bottom: 1px solid var(--border);
}

.cell-out-head button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-weight: 500;
}

.cell-out-head button:hover { background: var(--bg-hover); color: var(--text-primary); }

.cell-out-body {
  padding: 10px 12px 10px 76px;
  max-height: 400px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.cell-out-line { white-space: pre-wrap; word-break: break-word; color: var(--text-primary); }
.cell-out-line.stderr { color: var(--red); }

/* DataFrame Table */
.cell-df { margin: 6px 0; }
.cell-df-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-family: var(--font-sans);
}

.cell-df-note { color: var(--text-muted); font-size: 10px; font-weight: 400; }

.cell-df-box {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.cell-df-table {
  border-collapse: collapse;
  font-size: 12px;
  width: auto;
  max-width: 100%;
}

.cell-df-table th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 11px;
  padding: 7px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
  font-family: var(--font-sans);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.cell-df-table th:hover { color: var(--accent); }

.cell-df-table td {
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

.cell-df-table tr:hover td { background: var(--bg-hover); }
.cell-df-num { text-align: right; font-family: var(--font-mono); color: var(--orange); font-weight: 500; }
.cell-df-idx { color: var(--text-muted); font-size: 10px; width: 36px; }

/* Cell Gap (Add Cell) */
.cell-gap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.cell:hover .cell-gap,
.cells-footer .cell-gap { opacity: 1; }

.cell-gap button {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.cell-gap button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.cell-gap-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Cell Size Variants */
.cell-s .cell-input textarea,
.cell-s .cell-input .CodeMirror { min-height: 40px; max-height: 120px; }
.cell-m .cell-input textarea,
.cell-m .cell-input .CodeMirror { min-height: 42px; max-height: 300px; }
.cell-l .cell-input textarea,
.cell-l .cell-input .CodeMirror { min-height: 120px; max-height: 500px; }
.cell-xl .cell-input textarea,
.cell-xl .cell-input .CodeMirror { min-height: 240px; max-height: 80vh; }

/* ═══════════════ BOTTOM PANEL ═══════════════ */
.bottom-panel {
  height: var(--bottom-panel-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: height 0.2s;
}

.bottom-panel.minimized {
  height: 32px;
}

.bottom-panel.minimized .panel-body { display: none; }

.panel-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  height: 32px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.panel-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.panel-tab:hover { color: var(--text-secondary); }
.panel-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel-tab-spacer { flex: 1; }

.panel-tab-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.panel-tab-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.panel-body {
  flex: 1;
  overflow: hidden;
}

.panel-content {
  display: none;
  height: 100%;
  overflow: auto;
}

.panel-content.active { display: flex; flex-direction: column; }

/* ═══════════════ BUGBUSTER AI CHAT (Bottom Panel) ═══════════════ */
#aiChat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 8px;
}

.ai-welcome-icon { font-size: 32px; }
.ai-welcome h3 { font-size: 15px; font-weight: 700; color: var(--accent); margin: 0; }
.ai-welcome p { font-size: 12px; color: var(--text-muted); margin: 0; max-width: 280px; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-input-wrap {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}

.ai-input-wrap textarea {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  resize: none;
  min-height: 30px;
  max-height: 100px;
  line-height: 1.4;
}

.ai-input-wrap textarea:focus { border-color: var(--accent); }

.ai-send {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.ai-send:hover { background: rgba(245,158,11,0.2); }

.bugbuster-msg {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  max-width: 92%;
  word-wrap: break-word;
}

.bugbuster-msg.user {
  background: var(--accent-dim);
  color: var(--text-primary);
  align-self: flex-end;
  border: 1px solid var(--accent-border);
}

.bugbuster-msg.bot {
  background: var(--bg-surface);
  color: var(--text-secondary);
  align-self: flex-start;
  border: 1px solid var(--border);
}

.bugbuster-msg code {
  background: var(--bg-primary);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

.bugbuster-model-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 8px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bugbuster-typing {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  align-items: center;
}

.bugbuster-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bbTyping 1.2s infinite;
}

.bugbuster-typing span:nth-child(2) { animation-delay: 0.2s; }
.bugbuster-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bbTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.output-pre {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-empty { color: var(--text-muted); font-style: italic; }

/* ---- CELL INPUT LINE ---- */
.cell-input-line {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  margin-top: 4px;
}
.cell-input-field {
  flex: 1;
  height: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 0 8px;
  outline: none;
}
.cell-input-field:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(245,158,11,0.2); }
.cell-input-ok, .cell-input-cancel {
  height: 28px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.cell-input-ok { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.cell-input-ok:hover { background: #d97706; }
.cell-input-cancel:hover { border-color: #ef4444; color: #ef4444; }

.cell-out-img {
  margin: 4px 0;
}

.cell-out-img img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}

.cell-out-img img:hover {
  border-color: var(--accent);
}

.input-line {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.input-prompt { color: var(--green); font-family: var(--font-mono); font-weight: 700; }

.input-line input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  outline: none;
}

.input-line input:focus { border-color: var(--accent); }

.input-ok {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.input-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
}

/* Variables Panel */
.variables-list { padding: 8px 12px; font-size: 12px; }
.variables-empty { color: var(--text-muted); padding: 20px; text-align: center; }

.variable-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
}

.variable-row:hover { background: var(--bg-hover); }
.variable-name { font-family: var(--font-mono); color: var(--accent); font-weight: 600; min-width: 100px; }
.variable-type { color: var(--text-muted); font-size: 11px; min-width: 80px; }
.variable-value { color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Packages Panel */
.packages-grid { padding: 8px 12px; }

.package-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
}

.package-row:hover { background: var(--bg-hover); }
.package-name { font-family: var(--font-mono); color: var(--text-primary); min-width: 120px; font-size: 12px; font-weight: 500; }
.package-ver { color: var(--text-muted); font-size: 11px; }
.package-status { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.package-status.available { background: var(--green-dim); color: var(--green); }

/* ═══════════════ COMMAND PALETTE ═══════════════ */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 1000;
}

.palette-overlay[hidden] { display: none; }

.palette-box {
  width: 480px;
  max-height: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}

.palette-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.palette-search svg { color: var(--text-muted); flex-shrink: 0; }

.palette-search input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
}

.palette-search input::placeholder { color: var(--text-muted); }

.palette-search kbd {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.palette-list {
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.1s;
}

.palette-item:hover, .palette-item.selected {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.palette-item-kbd {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.palette-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ═══════════════ DROPDOWN MENU ═══════════════ */
.dropdown-menu {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 500;
  min-width: 200px;
  padding: 4px;
}

.dropdown-menu[hidden] { display: none; }

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.1s;
}

.dropdown-item:hover { background: var(--accent-dim); color: var(--text-primary); }

.dropdown-item-shortcut {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: 20px;
}

.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ═══════════════ LOADING ═══════════════ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(12,14,26,0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.loading-overlay.show { display: flex; }

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}

.loading-text { color: var(--text-secondary); font-size: 13px; font-weight: 500; }

.loading-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
  max-width: 400px;
}

.loading-retry {
  margin-top: 14px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.loading-retry:hover { background: rgba(245,158,11,0.18); }

/* ═══════════════ TOAST ═══════════════ */
.toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ═══════════════ BUGBUSTER PANEL ═══════════════ */
.bugbuster-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 380px;
  height: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.3);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bugbuster-panel.open {
  transform: translateY(0);
}

.bugbuster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.bugbuster-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bugbuster-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}

.bugbuster-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.bugbuster-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bugbuster-msg {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  max-width: 90%;
}

.bugbuster-msg.user {
  background: var(--accent-dim);
  color: var(--text-primary);
  align-self: flex-end;
  border: 1px solid var(--accent-border);
}

.bugbuster-msg.bot {
  background: var(--bg-surface);
  color: var(--text-secondary);
  align-self: flex-start;
  border: 1px solid var(--border);
}

.bugbuster-msg code {
  background: var(--bg-primary);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

.bugbuster-msg pre {
  background: var(--bg-primary);
  padding: 8px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 6px 0;
  border: 1px solid var(--border);
}

.bugbuster-input-row {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.bugbuster-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  outline: none;
}

.bugbuster-input:focus { border-color: var(--accent); }

.bugbuster-send-btn {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.bugbuster-send-btn:hover { background: rgba(245,158,11,0.18); }

.bugbuster-chips {
  display: flex;
  gap: 4px;
  padding: 6px 14px 10px;
}

.bugbuster-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.bugbuster-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.bugbuster-typing {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
}

.bugbuster-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite;
}

.bugbuster-typing span:nth-child(2) { animation-delay: 0.2s; }
.bugbuster-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* BugBuster FAB */
.bugbuster-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #d97706);
  border: none;
  color: #0c0e1a;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(245,158,11,0.4);
  z-index: 199;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.bugbuster-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(245,158,11,0.5);
}

/* BugBuster Code Box */
.bugbuster-code-box {
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.bugbuster-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.bugbuster-code-lang {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.bugbuster-copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-sans);
}

.bugbuster-copy-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.bugbuster-code-pre {
  margin: 0;
  padding: 8px 10px;
  background: var(--bg-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-primary);
  overflow-x: auto;
}

/* ═══════════════ PROFILE POPOVER ═══════════════ */
.profile-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.profile-btn:hover { border-color: var(--accent); }

.profile-btn img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

#plab-profile-wrap {
  position: fixed;
  top: var(--topbar-height);
  right: 12px;
  z-index: 300;
}

#plab-profile-pop {
  position: absolute;
  top: 8px;
  right: 0;
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 12px;
}

#plab-profile-pop.show { display: flex; }

.plab-profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin: 0 auto;
  overflow: hidden;
}

.plab-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#plab-profile-pop h3 {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

#plab-profile-pop > p {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
}

.plab-profile-sep {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

#plab-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s;
}

#plab-google:hover { border-color: #4285f4; }

#plab-google::before {
  content: "";
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E") no-repeat center;
  flex-shrink: 0;
}

#plab-signout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s;
}

#plab-signout:hover { border-color: var(--red); color: var(--red); }

#plab-profile-name {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  width: 100%;
}

#plab-profile-name:focus { border-color: var(--accent); }

#plab-profile-save {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

#plab-profile-save:hover { background: rgba(245,158,11,0.2); }

.plab-local-note {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

.plab-or-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted);
}

.plab-or-row::before,
.plab-or-row::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ═══════════════ SCROLLBAR ═══════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ═══════════════ MOBILE FLOATING RUN BAR ═══════════════ */
.mobile-run-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 150;
  gap: 8px;
  align-items: center;
}
.mobile-run-bar button {
  flex: 1;
  min-height: 48px;
  border-radius: 10px;
  border: none;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}
.mobile-run-bar .mob-run-btn {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #0c0e1a;
  box-shadow: 0 2px 12px rgba(52,211,153,0.3);
}
.mobile-run-bar .mob-run-btn:active { transform: scale(0.97); }
.mobile-run-bar .mob-stop-btn {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.3);
  flex: 0 0 auto;
  width: 48px;
}
.mobile-run-bar .mob-add-btn {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  flex: 0 0 auto;
  width: 48px;
}

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 768px) {
  .sidebar { width: 0; opacity: 0; pointer-events: none; }
  .topbar-menus { display: none; }
  .topbar-center { display: none; }
  .topbar-left { gap: 6px; }
  .topbar-right { gap: 2px; }
  .topbar-brand .brand-name { display: none; }
  .topbar-action { padding: 5px 6px; font-size: 11px; gap: 3px; min-height: 36px; }
  .topbar-action svg { width: 14px; height: 14px; }
  .topbar-sep { width: 1px; height: 24px; margin: 0 2px; }
  .save-status { display: none; }
  .topbar-action.btn-run {
    background: var(--green);
    color: #0c0e1a;
    font-weight: 700;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    display: none; /* hidden, mobile run bar is used instead */
  }
  .topbar-action.btn-stop { display: none; }
  .topbar-action#btnRunAll { display: none; }
  .topbar-icon { display: none; }

  /* Layout — notebook on top, panel at bottom */
  #mainLayout {
    flex-direction: column;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
  }
  .sidebar { display: none !important; }
  .notebook-area {
    flex: 1 1 0%;
    min-height: 0;
    order: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .notebook-header {
    padding: 4px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .notebook-title-input { font-size: 14px; padding: 4px 8px; min-width: 80px; flex: 1; }
  .notebook-badge { font-size: 9px; padding: 2px 6px; flex-shrink: 0; }
  .notebook-meta { margin-left: auto; }
  .cells-scroll {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 8px 80px;
    -webkit-overflow-scrolling: touch;
  }
  .cells-container { max-width: 100%; padding: 0; }
  .cell { border-radius: 10px; margin-bottom: 8px; }
  .cell-toolbar { gap: 2px; }
  .cell-toolbar button, .cell-toolbar select { padding: 6px 8px; font-size: 12px; min-height: 36px; }
  .cell-runbtn { width: 40px; height: 40px; font-size: 16px; }
  .add-cell-btn { padding: 16px; font-size: 14px; min-height: 52px; width: 100%; gap: 8px; touch-action: manipulation; }

  /* Show mobile run bar */
  .mobile-run-bar { display: flex; }

  /* Bottom panel — collapse by default, below cells */
  .bottom-panel { height: auto; max-height: 40vh; order: 2; flex-shrink: 0; border-top: 1px solid var(--border); }
  .bottom-panel.minimized { height: 36px; max-height: 36px; }
  .panel-tabs { height: 36px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-shrink: 0; }
  .panel-tab { white-space: nowrap; font-size: 12px; padding: 6px 12px; min-height: 36px; }
  .output-pre { font-size: 14px; line-height: 1.5; padding: 10px 12px; }
  .ai-input-wrap { padding: 10px 12px; gap: 8px; }
  .ai-input-wrap textarea { min-height: 44px; font-size: 16px; padding: 10px; border-radius: 10px; }
  .ai-send { width: 48px; height: 48px; border-radius: 10px; }
  .input-line { padding: 10px 12px; gap: 8px; }
  .input-line input { font-size: 16px; padding: 10px 12px; min-height: 44px; border-radius: 8px; }
  .input-ok { min-height: 44px; padding: 10px 16px; font-size: 14px; border-radius: 8px; }

  /* BugBuster */
  .bugbuster-fab { width: 52px; height: 52px; font-size: 22px; bottom: 70px; right: 14px; }
  .bugbuster-panel { width: 100%; height: 100%; border-radius: 0; top: 0; bottom: 0; left: 0; right: 0; transform: translateY(100%); }
  .bugbuster-panel.open { transform: translateY(0); }
  .bugbuster-input-row { padding: 10px 12px; }
  .bugbuster-input { font-size: 16px; padding: 12px; min-height: 44px; border-radius: 10px; }
  .bugbuster-send-btn { padding: 12px 18px; font-size: 14px; min-height: 44px; border-radius: 10px; }

  /* Profile */
  #plab-profile-wrap { right: 8px; top: var(--topbar-height); }
  #plab-profile-pop { width: calc(100vw - 16px); right: 0; padding: 16px; }
  .profile-btn { width: 34px; height: 34px; }

  /* Palette */
  .palette-overlay { padding-top: 8vh; }
  .palette-box { width: calc(100vw - 24px); max-height: 60vh; }
  .palette-search input { font-size: 16px; }
  .palette-item { padding: 12px 14px; font-size: 14px; min-height: 44px; }
}

@media (max-width: 400px) {
  .topbar-action { padding: 4px 6px; font-size: 10px; min-height: 34px; }
  .cell-toolbar button, .cell-toolbar select { padding: 5px 6px; font-size: 11px; min-height: 34px; }
  .cell-runbtn { width: 36px; height: 36px; font-size: 14px; }
  .add-cell-btn { padding: 14px; font-size: 13px; min-height: 48px; }
  .output-pre { font-size: 13px; }
  .bugbuster-fab { width: 46px; height: 46px; font-size: 20px; bottom: 66px; right: 10px; }
  .bugbuster-msg { font-size: 13px; max-width: 95%; }
  .bugbuster-chip { font-size: 11px; padding: 5px 10px; }
  #plab-profile-pop { padding: 14px; }
  .plab-profile-avatar { width: 50px; height: 50px; }
  .mobile-run-bar { padding: 6px 10px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .mobile-run-bar button { min-height: 44px; font-size: 14px; border-radius: 8px; }
}

/* ═══════════════ TAB TOAST ═══════════════ */
.dsw-tab-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0c0e1a;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 30px;
  box-shadow: 0 4px 20px rgba(245,158,11,0.4);
  z-index: 9999;
  animation: dswToastIn 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.dsw-tab-toast b {
  background: #0c0e1a;
  color: #f59e0b;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  margin: 0 2px;
}

@keyframes dswToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══════════════ AI AUTOCOMPLETE GHOST TEXT ═══════════════ */
.dsw-ghost-inline {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  animation: dswGhostFadeIn 0.1s ease;
  max-width: 500px;
  display: inline-block;
}
.dsw-ghost-inline .dsw-ghost-btns {
  pointer-events: auto;
}

@keyframes dswGhostFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dsw-ghost-lines {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: rgba(160, 170, 220, 0.4);
  white-space: pre;
  padding: 0;
}

.dsw-ghost-line {
  min-height: 1.4em;
}

.dsw-ghost-more {
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-sans);
  padding-top: 2px;
  opacity: 0.6;
}

.dsw-ghost-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  padding: 0 0 2px;
  opacity: 0.7;
}

.dsw-ghost-hint {
  position: absolute;
  top: -2px;
  right: -40px;
  pointer-events: none;
}

/* Accept / Decline buttons */
.dsw-ghost-btns {
  display: flex;
  gap: 6px;
  padding: 0;
  margin-bottom: 4px;
}

.dsw-ghost-btns-top {
  position: absolute;
  top: -32px;
  left: 0;
  z-index: 25;
}

.dsw-ghost-accept,
.dsw-ghost-decline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 10px;
  transition: all 0.15s;
  pointer-events: auto;
  touch-action: manipulation;
  line-height: 1;
}

.dsw-ghost-accept {
  background: rgba(52,211,153,0.2);
  color: #34d399;
  border: 1px solid rgba(52,211,153,0.3);
}
.dsw-ghost-accept:hover {
  background: rgba(52,211,153,0.35);
  transform: scale(1.05);
}

.dsw-ghost-decline {
  background: rgba(248,113,113,0.15);
  color: #f87171;
  border: 1px solid rgba(248,113,113,0.25);
}
.dsw-ghost-decline:hover {
  background: rgba(248,113,113,0.3);
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .dsw-ghost-btns {
    padding: 8px 0 4px;
    gap: 8px;
  }
  .dsw-ghost-accept,
  .dsw-ghost-decline {
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 8px;
    min-height: 36px;
  }
  .dsw-ghost-hint { display: none; }
}

.dsw-ghost-key {
  display: inline-block;
  background: var(--accent);
  color: #0c0e1a;
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(245,158,11,0.3);
  animation: dswKeyPulse 2s ease infinite;
}

@keyframes dswKeyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Cell active line highlight when ghost is shown */
.dsw-ghost-active {
  background: rgba(245,158,11,0.03) !important;
}

/* ═══════════════ CODEMIRROR MOBILE ═══════════════ */
@media (max-width: 768px) {
  .CodeMirror {
    font-size: 16px !important;
    line-height: 1.6 !important;
    height: auto !important;
    min-height: 100px;
    padding: 8px 0;
  }
  .CodeMirror-scroll { min-height: 100px; }
  .CodeMirror-gutters { min-width: 36px; }
  .CodeMirror-linenumber { font-size: 11px !important; }
  .cell-input { padding: 8px 10px; }
  .cell-input textarea { font-size: 16px !important; min-height: 100px; padding: 8px; }
  .cell { border-radius: 8px; margin-bottom: 8px; border-width: 1.5px; }
  .cell-toolbar { padding: 6px 8px 2px; gap: 4px; }
  .cell-toolbar button, .cell-toolbar select {
    min-height: 36px;
    min-width: 36px;
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 6px;
    touch-action: manipulation;
  }
  .cell-runbtn {
    width: 40px !important;
    height: 40px !important;
    font-size: 18px !important;
    opacity: 1 !important;
    top: 6px;
    right: 6px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  .cell-runbtn:active { transform: scale(0.95); }
  .cell-tb-run { font-size: 13px !important; font-weight: 700 !important; }
  .cell-gap button {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 13px;
    touch-action: manipulation;
  }
  .cell-out-body {
    padding: 10px 12px 10px 12px;
    font-size: 13px;
    max-height: 300px;
  }
  .cell-df-table { font-size: 11px; }
  .cell-df-table th { padding: 8px 10px; font-size: 11px; }
  .cell-df-table td { padding: 7px 10px; font-size: 11px; }
}

/* ═══════════════ LIVE MEMORY VISUALIZER ═══════════════ */

/* ---- TOGGLE BUTTON ---- */
.viz-toggle-btn.viz-active {
  background: rgba(245,158,11,0.15) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

/* ---- RIGHT PANEL ---- */
.viz-panel {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.2s ease;
}
.viz-panel.viz-hidden {
  width: 0;
  border-left: none;
  overflow: hidden;
}
.viz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.viz-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.viz-controls {
  display: flex;
  gap: 4px;
}
.viz-ctrl-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.viz-ctrl-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent);
}
.viz-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
}
.viz-body::-webkit-scrollbar { width: 4px; }
.viz-body::-webkit-scrollbar-track { background: transparent; }
.viz-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- EMPTY STATE ---- */
.viz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 20px;
}
.viz-empty-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.4; }
.viz-empty-text { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ---- VARIABLE SECTION ---- */
.viz-section {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.viz-section:last-child { border-bottom: none; margin-bottom: 0; }
.viz-var-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.viz-var-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.viz-var-type {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.viz-var-len {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ---- INDEX ROW ---- */
.viz-index-row {
  display: flex;
  gap: 1px;
  margin-bottom: 2px;
}
.viz-sticky-top {
  background: var(--bg-primary);
  padding-top: 2px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.viz-sticky-bottom {
  background: var(--bg-primary);
  padding-top: 2px;
  border-top: 1px solid var(--border);
}
.viz-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.viz-scroll-wrap::-webkit-scrollbar { height: 3px; }
.viz-scroll-wrap::-webkit-scrollbar-track { background: transparent; }
.viz-scroll-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.viz-scroll-inner {
}
.viz-idx {
  width: 22px;
  min-width: 22px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
}
.viz-neg-index .viz-idx { color: #ef4444; opacity: 0.7; }

/* ---- ARROW ROW ---- */
.viz-arrow-row {
  display: flex;
  gap: 1px;
  margin-bottom: 2px;
}
.viz-arrow {
  width: 22px;
  min-width: 22px;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}

/* ---- BOX ROW ---- */
.viz-box-row {
  display: flex;
  gap: 1px;
  margin-bottom: 4px;
  flex-wrap: nowrap;
}
.viz-box {
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 2px;
  transition: all 0.2s;
}
.viz-box-tuple {
  border-style: dashed;
}
.viz-box-str {
  background: rgba(139,92,246,0.1);
  border-color: rgba(139,92,246,0.3);
}
.viz-box-set {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.3);
}
.viz-box-highlight {
  background: rgba(245,158,11,0.2) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 8px rgba(245,158,11,0.3);
  transform: scale(1.05);
}
.viz-box-loop {
  background: rgba(59,130,246,0.15) !important;
  border-color: rgba(59,130,246,0.4) !important;
}
.viz-box-more {
  background: transparent;
  border-style: dashed;
  color: var(--text-muted);
}
.viz-box-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 20px;
}

/* ---- DICT ---- */
.viz-dict {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.viz-dict-header {
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
}
.viz-dict-key-h, .viz-dict-val-h {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.viz-dict-key-h { flex: 1; }
.viz-dict-val-h { flex: 1; text-align: right; }
.viz-dict-row {
  display: flex;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.viz-dict-row:last-child { border-bottom: none; }
.viz-dict-row-hl {
  background: rgba(245,158,11,0.15) !important;
}
.viz-dict-key {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viz-dict-val {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- SCALAR ---- */
.viz-scalar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.viz-scalar-eq { color: var(--text-muted); font-size: 12px; }
.viz-scalar-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
}

/* ---- DETAIL BOX ---- */
.viz-detail {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.viz-detail-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.viz-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}
.viz-detail-row span:first-child { color: var(--text-muted); }
.viz-detail-row span:last-child {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
}
.viz-detail-result {
  color: var(--accent) !important;
  font-weight: 600;
}

/* ---- LOOP TIMELINE ---- */
.viz-loop-timeline {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.viz-loop-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--bg-primary);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.viz-loop-num {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  min-width: 30px;
}
.viz-loop-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
}

/* ---- EXPLANATIONS ---- */
.viz-explain {
  border-bottom: none;
}
.viz-explain-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 4px 0;
  line-height: 1.4;
}
.viz-explain-icon { font-size: 12px; flex-shrink: 0; }
.viz-explain-error { color: #ef4444; }

/* ---- NDARRAY INFO ---- */
.viz-ndarray-info {
  font-size: 10px;
  color: var(--text-muted);
  padding: 4px 0;
  font-style: italic;
}

/* ---- SLICE DETAIL ---- */
.viz-slice-detail { border-left: 3px solid #8b5cf6; }
.viz-index-detail { border-left: 3px solid var(--accent); }
.viz-mutation-detail { border-left: 3px solid #22c55e; }

/* ═══════════════ LAYOUT INTEGRATION ═══════════════ */
#mainLayout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#notebookArea {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 1024px) {
  .viz-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 200;
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
    width: 300px;
  }
  .viz-panel.viz-hidden {
    width: 0;
    box-shadow: none;
  }
}
@media (max-width: 768px) {
  .viz-panel {
    width: 100% !important;
    top: auto;
    bottom: 0;
    height: 50vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
  }
  .viz-panel.viz-hidden {
    height: 0;
    width: 100% !important;
  }
  .viz-box { min-width: 20px; height: 20px; }
  .viz-box-val { font-size: 9px; max-width: 16px; }
  .viz-idx, .viz-arrow { width: 20px; min-width: 20px; }
}
