/* ═══════════════════════════════════════════════════════════════
   tine — 3-panel IDE + notebook hybrid
   Explorer | Canvas (multi-track) | Inspector
   ═══════════════════════════════════════════════════════════════ */

/* ── Theme tokens ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0e0e0e;
  --bg-surface:   #161616;
  --bg-cell:      #1b1b1b;
  --bg-input:     #111111;
  --bg-output:    #141414;
  --bg-hover:     #222222;
  --bg-panel:     #131313;
  --bg-toolbar:   #191919;
  --border:       #282828;
  --border-active:#444444;
  --border-subtle:#1e1e1e;

  --fg:           #d4d4d4;
  --fg-2:         #777777;
  --fg-3:         #4a4a4a;

  --accent:       #6e8ef7;
  --accent-dim:   #4a6ad4;
  --accent-bg:    rgba(110,142,247,0.10);
  --green:        #4ade80;
  --green-bg:     rgba(74,222,128,0.08);
  --red:          #f87171;
  --red-bg:       rgba(248,113,113,0.07);
  --yellow:       #fbbf24;
  --yellow-bg:    rgba(251,191,36,0.08);
  --purple:       #a78bfa;
  --purple-bg:    rgba(167,139,250,0.08);

  /* CodeMirror overrides */
  --cm-bg:        #111111;
  --cm-gutter:    #1a1a1a;
  --cm-cursor:    #d4d4d4;
  --cm-selection: rgba(110,142,247,0.20);
  --cm-line-hl:   rgba(255,255,255,0.03);
}

[data-theme="light"] {
  --bg:           #f8f8f7;
  --bg-surface:   #ffffff;
  --bg-cell:      #ffffff;
  --bg-input:     #f3f3f1;
  --bg-output:    #f6f6f5;
  --bg-hover:     #eeeeec;
  --bg-panel:     #fafaf9;
  --bg-toolbar:   #f0f0ee;
  --border:       #e2e2df;
  --border-active:#c0c0bc;
  --border-subtle:#eaeae8;

  --fg:           #1a1a1a;
  --fg-2:         #6b6b68;
  --fg-3:         #a0a09c;

  --accent:       #4f5fd5;
  --accent-dim:   #3a48a8;
  --accent-bg:    rgba(79,95,213,0.07);
  --green:        #16a34a;
  --green-bg:     rgba(22,163,74,0.06);
  --red:          #dc2626;
  --red-bg:       rgba(220,38,38,0.05);
  --yellow:       #b45309;
  --yellow-bg:    rgba(180,83,9,0.05);
  --purple:       #7c3aed;
  --purple-bg:    rgba(124,58,237,0.05);

  --cm-bg:        #f3f3f1;
  --cm-gutter:    #f8f8f7;
  --cm-cursor:    #1a1a1a;
  --cm-selection: rgba(79,95,213,0.15);
  --cm-line-hl:   rgba(0,0,0,0.02);
}

:root {
  --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --font-mono:  "SF Mono", "Fira Code", "JetBrains Mono", "Cascadia Code", monospace;
  --radius:     6px;
  --radius-lg:  10px;

  /* Panel widths */
  --explorer-w: 220px;
  --inspector-w: 240px;
  --terminal-h: 160px;
}

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

html, body, #root {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: 40px 1fr;
  grid-template-columns: var(--explorer-w) 1fr var(--inspector-w);
  grid-template-areas:
    "titlebar titlebar titlebar"
    "explorer main     inspector";
  height: 100vh;
  overflow: hidden;
}

.app.explorer-collapsed {
  grid-template-columns: 0px 1fr var(--inspector-w);
}
.app.inspector-collapsed {
  grid-template-columns: var(--explorer-w) 1fr 0px;
}
.app.explorer-collapsed.inspector-collapsed {
  grid-template-columns: 0px 1fr 0px;
}

/* ── Title Bar ────────────────────────────────────────────────── */
.titlebar {
  grid-area: titlebar;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;  /* Tauri: make title bar draggable */
  user-select: none;
  z-index: 100;
}

.titlebar-logo {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
  color: var(--fg);
  -webkit-app-region: no-drag;
}

.titlebar-nav {
  display: flex;
  gap: 2px;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}
.titlebar-btn:hover { background: var(--bg-hover); color: var(--fg); }
.titlebar-btn.active { background: var(--accent-bg); color: var(--accent); }

.titlebar-spacer { flex: 1; }

.titlebar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  -webkit-app-region: no-drag;
}

.btn-run-all {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-run-all:hover { opacity: 0.85; }
.btn-run-all:disabled { opacity: 0.4; cursor: default; }

.ws-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-3);
  transition: background 0.3s;
}
.ws-dot.connected { background: var(--green); }

.theme-toggle {
  background: none;
  border: none;
  color: var(--fg-2);
  cursor: pointer;
  font-size: 15px;
  padding: 4px;
  border-radius: var(--radius);
  -webkit-app-region: no-drag;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--fg); }

/* ── Explorer Panel (left) ────────────────────────────────────── */
.explorer {
  grid-area: explorer;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.explorer-collapsed .explorer { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-2);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-header-btn {
  background: none;
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  border-radius: 3px;
  line-height: 1;
}
.panel-header-btn:hover { color: var(--fg); background: var(--bg-hover); }

.explorer-section {
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.explorer-section-title {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.explorer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 20px;
  color: var(--fg-2);
  font-size: 12px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s;
}
.explorer-item:hover { background: var(--bg-hover); color: var(--fg); }
.explorer-item.active { background: var(--accent-bg); color: var(--accent); }

.explorer-icon { font-size: 13px; opacity: 0.7; flex-shrink: 0; }

.explorer-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.explorer-item-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--fg-3);
  flex-shrink: 0;
}

.explorer-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Main Area (center) ───────────────────────────────────────── */
.main-area {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Canvas: holds the multi-track notebook */
.canvas {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

/* ── Pipeline Group (parent + branches) ──────────────────────── */
.pipeline-group {
  width: 100%;
  overflow-x: auto;
}

/* Inside a pipeline-group, the track should not constrain width */
.pipeline-group > .track {
  width: auto;
  min-width: 0;
}

/* ── Cell Row (parent cell + optional branch columns) ────────── */
.cell-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
}

.cell-row-main {
  width: clamp(360px, 42vw, 640px);
  min-width: 360px;
  flex-shrink: 0;
}

/* ── Branch connector ────────────────────────────────────────── */
.branch-connector {
  display: flex;
  align-items: center;
  width: 40px;
  flex-shrink: 0;
  position: relative;
}

.connector-line-h {
  width: 100%;
  height: 2px;
  background: var(--purple);
  opacity: 0.5;
  position: relative;
}
.connector-line-h::after {
  content: "";
  position: absolute;
  right: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--purple);
  opacity: 0.7;
}

/* ── Branch columns (forks branching off at a row) ───────────── */
.branch-columns {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-top: 8px; /* visually center relative to the cell */
}

/* ── Branch Track (divergent cells only) ─────────────────────── */
.branch-track {
  width: clamp(300px, 32vw, 520px);
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.branch-header {
  border-left: 3px solid var(--purple);
}

/* ── Track (one pipeline as a vertical cell strip) ────────────── */
.track {
  flex: 0 0 auto;
  width: clamp(360px, 42vw, 640px);
  min-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.track-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 8px;
  font-weight: 500;
}
.track-badge.fork {
  background: var(--purple-bg);
  color: var(--purple);
}

.track-actions {
  display: flex;
  gap: 4px;
}

.track-btn {
  background: none;
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 6px;
  border-radius: var(--radius);
}
.track-btn:hover { background: var(--bg-hover); color: var(--fg); }

/* ── Cell ─────────────────────────────────────────────────────── */
.cell {
  background: var(--bg-cell);
  border: 1px solid var(--border);
  border-top: none;
  transition: border-color 0.15s;
}

.cell:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.cell.focused {
  border-color: var(--accent);
  z-index: 1;
}

/* Cell input area (gutter + code editor) */
.cell-input {
  display: flex;
  min-height: 40px;
}

.cell-gutter {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 10px 6px 10px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  user-select: none;
  background: var(--bg-input);
  border-right: 1px solid var(--border-subtle);
}

.cell-prompt {
  display: flex;
  align-items: center;
  gap: 3px;
}

.cell-prompt-label { color: var(--accent-dim); font-weight: 600; }
.cell-prompt-num   { color: var(--fg-3); }

/* Status dot in gutter */
.cell-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: 4px;
  flex-shrink: 0;
}
.cell-status.running  { background: var(--yellow); animation: pulse 1s infinite; }
.cell-status.done     { background: var(--green); }
.cell-status.cached   { background: var(--purple); }
.cell-status.failed   { background: var(--red); }
.cell-status.queued   { background: var(--fg-3); }

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

/* Code editor wrapper */
.cell-editor {
  flex: 1;
  padding: 6px 0;
  min-height: 40px;
  overflow: hidden;
}

/* CodeMirror theme overrides */
.cell-editor .cm-editor {
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}
.cell-editor .cm-editor.cm-focused { outline: none; }
.cell-editor .cm-scroller { overflow: hidden; }
.cell-editor .cm-content { padding: 4px 12px; }
.cell-editor .cm-gutters { display: none; } /* we have our own gutter */
.cell-editor .cm-activeLine { background: var(--cm-line-hl); }
.cell-editor .cm-selectionBackground { background: var(--cm-selection) !important; }
.cell-editor .cm-cursor { border-left-color: var(--cm-cursor); }

/* Fallback textarea when CodeMirror hasn't loaded */
.cell-textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  resize: none;
  outline: none;
  overflow: hidden;
}

/* Cell toolbar (appears on hover) */
.cell-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  background: var(--bg-input);
  border-top: 1px solid var(--border-subtle);
  opacity: 0;
  transition: opacity 0.15s;
}
.cell:hover .cell-toolbar,
.cell.focused .cell-toolbar { opacity: 1; }

.cell-tool-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-3);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.1s;
}
.cell-tool-btn:hover { background: var(--bg-hover); color: var(--fg); }
.cell-tool-btn.run { color: var(--green); }
.cell-tool-btn.run:hover { background: var(--green-bg); }
.cell-tool-btn.branch { color: var(--purple); }
.cell-tool-btn.branch:hover { background: var(--purple-bg); }

.cell-tool-spacer { flex: 1; }

/* ── Cell Output ──────────────────────────────────────────────── */
.cell-output {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-output);
}

.cell-output-wrap {
  display: flex;
  min-height: 28px;
}

.cell-output-gutter {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 8px 6px 8px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  user-select: none;
}

.cell-output-body {
  flex: 1;
  padding: 8px 12px;
  overflow-x: auto;
}

/* Output types */
.out-text {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--fg);
}

.out-error {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--red);
  white-space: pre-wrap;
}

.out-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.out-metric {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 10px;
  background: var(--accent-bg);
  border-radius: 12px;
  font-size: 12px;
}
.out-metric-key { color: var(--fg-2); }
.out-metric-val { color: var(--accent); font-weight: 600; font-family: var(--font-mono); }

.out-image img {
  max-width: 100%;
  border-radius: var(--radius);
}

.out-html {
  font-size: 12px;
  overflow-x: auto;
}
.out-html table {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.out-html th, .out-html td {
  padding: 4px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.out-html th {
  background: var(--bg-hover);
  font-weight: 600;
  color: var(--fg-2);
}

.out-status {
  font-size: 11px;
  color: var(--fg-3);
  padding: 4px 0;
}
.out-status.cached { color: var(--purple); }

/* ── Inspector Panel (right) ──────────────────────────────────── */
.inspector {
  grid-area: inspector;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.inspector-collapsed .inspector { display: none; }

.inspector-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.inspector-section {
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px;
}

.inspector-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--fg-3);
  margin-bottom: 8px;
}

.inspector-kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 12px;
}
.inspector-kv dt { color: var(--fg-2); }
.inspector-kv dd { color: var(--fg); font-family: var(--font-mono); font-size: 11.5px; }

/* Comparison table in inspector */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.compare-table th, .compare-table td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.compare-table th {
  color: var(--fg-3);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.compare-table .best { color: var(--green); font-weight: 600; }

/* ── Terminal Panel (bottom, collapsible) ─────────────────────── */
.terminal-area {
  height: var(--terminal-h);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.terminal-area.collapsed { height: 28px; }

.terminal-header {
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
}

.terminal-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
}

.terminal-tab {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--fg-3);
  background: none;
  border: none;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
}
.terminal-tab.active { color: var(--fg); background: var(--bg-hover); }

.terminal-body {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--fg-2);
}
.terminal-area.collapsed .terminal-body { display: none; }

/* ── Connectors (SVG between tracks) ──────────────────────────── */
.connector-line {
  stroke: var(--purple);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  fill: none;
  opacity: 0.5;
}

/* ── Add cell button ──────────────────────────────────────────── */
.add-cell-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  margin-top: 2px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-3);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}
.add-cell-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--fg-3);
}
.empty-state-icon { font-size: 48px; opacity: 0.3; }
.empty-state-text { font-size: 14px; }
.empty-state-hint { font-size: 12px; color: var(--fg-3); }

/* ── 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-active); }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.2s ease; }

/* ── Keyboard shortcut hints ──────────────────────────────────── */
.kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--fg-3);
}

/* ── Fork modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 420px;
  max-width: 90vw;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.modal-input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.modal-btn:hover { background: var(--bg-hover); }
.modal-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.modal-btn.primary:hover { opacity: 0.85; }

/* ═══════════════════════════════════════════════════════════════
   FILE BROWSER — inside Explorer panel
   ═══════════════════════════════════════════════════════════════ */
.file-breadcrumb {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px 12px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.file-crumb {
  background: none; border: none; color: var(--fg-3);
  font-size: 10px; font-family: var(--font-mono);
  cursor: pointer; padding: 1px 2px; border-radius: 3px;
  white-space: nowrap;
}
.file-crumb:hover { color: var(--accent); background: var(--accent-bg); }
.file-crumb-sep { color: var(--fg-3); font-size: 10px; }

.file-viewer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.file-viewer-header {
  border-bottom: 1px solid var(--border-subtle);
}
.file-viewer-code {
  margin: 0;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg);
  white-space: pre;
  tab-size: 4;
  overflow: auto;
  max-height: 400px;
  background: var(--bg-input);
}

/* ═══════════════════════════════════════════════════════════════
   PROJECT DASHBOARD
   ═══════════════════════════════════════════════════════════════ */
.project-dashboard {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.project-dashboard-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 48px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.project-dashboard-body {
  flex: 1;
  overflow-y: auto;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.project-dashboard-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 32px;
  letter-spacing: -0.5px;
  align-self: flex-start;
  max-width: 900px;
  width: 100%;
}

/* ── Project Grid ──────────────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 900px;
}

.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}
.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.project-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.3px;
}

.project-card-desc {
  font-size: 12px;
  color: var(--fg-2);
  line-height: 1.5;
  flex: 1;
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.project-card-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
}

.project-card-date {
  font-size: 11px;
  color: var(--fg-3);
}

/* ── New project card ──────────────────────────────────────────── */
.project-card-new {
  border-style: dashed;
  border-color: var(--border);
  background: transparent;
  align-items: center;
  justify-content: center;
  color: var(--fg-3);
  font: inherit;
  gap: 8px;
  cursor: pointer;
}
.project-card-new:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.project-card-new-icon {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.project-card-new-text {
  font-size: 13px;
  font-weight: 500;
}

/* ── Project form (inline card) ────────────────────────────────── */
.project-card-form {
  cursor: default;
}
.project-card-form:hover {
  border-color: var(--border-active);
  box-shadow: none;
}

.project-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.project-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ── Empty state (dashboard) ───────────────────────────────────── */
.project-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 12px;
  color: var(--fg-3);
  width: 100%;
  max-width: 900px;
}

.project-empty-icon { font-size: 48px; opacity: 0.3; }
.project-empty-text { font-size: 16px; color: var(--fg-2); }
.project-empty-hint { font-size: 13px; }

/* ── Explorer project name ─────────────────────────────────────── */
.explorer-project-label {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--fg-3);
}

.explorer-project-name {
  padding: 2px 12px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Titlebar back button ──────────────────────────────────────── */
.titlebar-back {
  color: var(--fg-2);
  font-size: 12px;
  margin-right: 4px;
}
.titlebar-back:hover {
  color: var(--fg);
}

/* ── Copy path button (file explorer) ──────────────────────────── */
.copy-path-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--fg-3);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}
.copy-path-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.explorer-item:hover .copy-path-btn {
  display: flex;
}

/* ── Toast notification ────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 2000;
  animation: toastIn 0.2s ease;
  pointer-events: none;
}

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