/* ─── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --sidebar-bg: #1a2d4a;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(255, 255, 255, 0.11);
  --sidebar-text: rgba(255, 255, 255, 0.6);
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-width: 220px;
  --bg: #edf1f8;
  --panel: #f5f8ff;
  --panel-soft: #eef3fb;
  --surface: #e8eef7;
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.13);
  --text: #111827;
  --muted: #6b7280;
  --subtle: #9ca3af;
  --accent: #1a2d4a;
  --accent-hover: #243d62;
  --accent-soft: rgba(26, 45, 74, 0.07);
  --active-bg: #e8f0fe;
  --active-border: #bfdbfe;
  --top-bar-bg: #f5f8ff;
  --top-bar-border: rgba(0, 0, 0, 0.07);
  --status-bar-bg: #f5f8ff;
  --status-bar-border: rgba(0, 0, 0, 0.07);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.06);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --top-bar-height: 60px;
  --status-bar-height: 40px;
  --control-height: 36px;
  --font: "Inter", system-ui, sans-serif;
  --text-xs: 0.7rem;
  --text-sm: 0.75rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1rem;
  --text-xl: 1.125rem;
  --text-2xl: 1.5rem;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; -webkit-tap-highlight-color: transparent; }

/* ─── App shell ─────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns 200ms ease;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(0,0,0,0.2);
}
.sidebar-top {
  flex: 0 0 auto;
  padding: 16px 12px 12px;
}
.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sidebar-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}
.sidebar-brand h1 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--sidebar-text-active);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 26px;
  margin-top: 1px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -1px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); border-color: rgba(255,255,255,0.45); }
.toggle-expand { display: none; }
.sidebar.is-collapsed .toggle-collapse { display: none; }
.sidebar.is-collapsed .toggle-expand { display: inline; }
.workflow-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.workflow-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.workflow-tab:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.workflow-tab.is-active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.workflow-tab .icon { flex-shrink: 0; opacity: 0.7; }
.workflow-tab.is-active .icon { opacity: 1; }

/* Quick capture */
.sidebar-capture {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--sidebar-border);
  margin-top: 8px;
}
.sidebar-capture-label {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}
.sidebar-capture-field { flex: 1; min-height: 0; }
.sidebar-capture-textarea {
  width: 100%;
  height: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.85);
  font-size: var(--text-sm);
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease;
}
.sidebar-capture-textarea::placeholder { color: rgba(255,255,255,0.25); }
.sidebar-capture-textarea:focus { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); }
.sidebar-capture-kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--sidebar-border);
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.3);
  font-size: var(--text-xs);
  font-family: inherit;
  align-self: flex-start;
}

/* Sidebar footer */
.sidebar-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  border-top: 1px solid var(--sidebar-border);
}
.user-pill { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 4px; }
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  font-size: var(--text-xs);
  font-weight: 700;
}
.user-name { font-size: var(--text-sm); font-weight: 500; color: rgba(255,255,255,0.75); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chevron { flex-shrink: 0; color: rgba(255,255,255,0.35); }

/* Sidebar drive actions */
.sidebar-drive-actions {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 4px 0;
}

.drive-disclaimer {
  margin: 8px 4px 2px;
  padding: 8px 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}

.drive-disclaimer p {
  margin: 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.67rem;
  line-height: 1.45;
}

.drive-disclaimer strong {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
}

.drive-disclaimer-links {
  margin-top: 6px !important;
  display: flex;
  align-items: center;
  gap: 6px;
}

.drive-disclaimer a {
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  font-size: 0.67rem;
  font-weight: 600;
}

.drive-disclaimer a:hover {
  text-decoration: underline;
}
.sidebar-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background 140ms ease, color 140ms ease;
}
.sidebar-action-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.sidebar-action-btn .icon { flex-shrink: 0; }

/* Collapsed: icon-only for action buttons */
.sidebar.is-collapsed .sidebar-action-btn { justify-content: center; padding: 0; width: 36px; margin: 0 auto; }


/* Sidebar label — hidden when sidebar is collapsed */
.sidebar.is-collapsed .sidebar-label { display: none; }
.sidebar.is-collapsed .sidebar-header { justify-content: center; margin-bottom: 8px; }
.sidebar.is-collapsed .sidebar-brand { display: none; }
.sidebar.is-collapsed .sidebar-top { padding: 16px 8px 12px; }
.sidebar.is-collapsed .workflow-tab { justify-content: center; padding: 0 8px; }
.sidebar.is-collapsed .user-pill { justify-content: center; padding: 0; }
.sidebar.is-collapsed .sidebar-footer { align-items: center; }
.sidebar.is-collapsed .sidebar-drive-actions { align-items: center; }

/* Collapsed sidebar: app-shell grid responds via :has() */
.app-shell:has(.sidebar.is-collapsed) {
  grid-template-columns: 56px 1fr;
}

/* ─── Main area ─────────────────────────────────────────────────────────── */
.main-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

/* ─── Top bar ───────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  height: var(--top-bar-height);
  padding: 0 20px;
  background: var(--top-bar-bg);
  border-bottom: 1px solid var(--top-bar-border);
}
.top-search-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 400px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: text;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.top-search-label:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.top-search-icon { flex-shrink: 0; color: var(--subtle); }
.top-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: var(--text-sm);
  outline: none;
  cursor: text;
}
.top-search-input::placeholder { color: var(--subtle); }
.top-bar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ─── Icon & shared ─────────────────────────────────────────────────────── */
.icon { display: inline-block; width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.icon-outline { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: var(--control-height); height: var(--control-height); padding: 0; flex-shrink: 0; }
.is-hidden { display: none !important; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, transform 100ms ease;
  white-space: nowrap;
}
.primary-button:hover { background: var(--accent-hover); }
.primary-button:active { transform: scale(0.98); }
.primary-button:disabled { opacity: 0.5; cursor: default; transform: none; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 140ms ease, background 140ms ease;
}
.ghost-button:hover { border-color: var(--border-strong); background: var(--surface); }
.ghost-button:disabled { opacity: 0.5; cursor: default; }

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 14px;
  border: none;
  border-radius: var(--radius);
  background: #dc2626;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease, transform 100ms ease;
}
.danger-button:hover { background: #b91c1c; }
.danger-button:active { transform: scale(0.98); }

/* ─── Confirm dialog ────────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 14, 26, 0.5);
  backdrop-filter: blur(8px);
  animation: overlay-in 140ms ease;
}
.confirm-overlay.is-hidden { display: none; }
.confirm-card {
  width: min(400px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  animation: card-in 160ms cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.confirm-eyebrow { margin: 0 0 8px; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.confirm-message { margin: 0 0 20px; font-size: var(--text-base); line-height: 1.55; color: var(--text); }
.confirm-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

/* ─── Workspace menu ────────────────────────────────────────────────────── */
.workspace-menu-shell { position: relative; }
.workspace-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}
.workspace-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease;
}
.workspace-menu-item:hover { background: var(--surface); }

/* ─── Hidden meta (used by JS) ───────────────────────────────────────────── */
.workspace-meta-hidden { display: none; }

/* ─── Workspace content ─────────────────────────────────────────────────── */
.workspace-content { flex: 1; min-height: 0; overflow: hidden; }

/* ─── Mode shell ────────────────────────────────────────────────────────── */
.mode-shell { display: flex; height: 100%; overflow: hidden; }

/* ─── Collect mode ──────────────────────────────────────────────────────── */
.collect-shell {
  display: grid;
  grid-template-columns: 1fr 300px;
  height: 100%;
}

/* Editor panel */
.editor-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.editor-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  padding: 14px 24px 0;
  min-height: 36px;
}
.editor-note-header-left,
.editor-note-header-right { display: flex; align-items: center; gap: 6px; }
.note-save-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
  background: rgba(0,0,0,0.04);
  color: var(--muted);
}
.note-save-status.is-saved { color: #059669; background: rgba(5,150,105,0.08); }
.note-save-status.is-dirty { color: #d97706; background: rgba(217,119,6,0.08); }

.note-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.note-header-btn:hover { background: var(--surface); color: var(--text); }
.note-header-btn.is-pinned { color: var(--accent); }

.editor-title-wrapper { flex-shrink: 0; padding: 8px 24px 4px; }
.editor-title-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  outline: none;
  line-height: 1.3;
}
.editor-title-input::placeholder { color: var(--subtle); }

.editor-tags-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 0 24px 10px;
}
.editor-tags-prefix { color: var(--subtle); font-size: var(--text-base); font-weight: 500; flex-shrink: 0; user-select: none; }
.editor-tags-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-base);
  outline: none;
}
.editor-tags-input::placeholder { color: var(--subtle); }

/* Formatting toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 6px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.toolbar-btn:hover { background: var(--surface); color: var(--text); }
.toolbar-divider { display: block; width: 1px; height: 18px; margin: 0 4px; background: var(--border); flex-shrink: 0; }
.toolbar-spacer { flex: 1; }
.toolbar-btn-save {
  color: var(--accent);
  font-weight: 600;
  font-size: var(--text-xs);
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.toolbar-btn-save:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* CM6 editor container */
.editor-body-wrapper { flex: 1; min-height: 0; position: relative; padding: 0 24px; overflow: hidden; display: flex; flex-direction: column; }
.editor-body-cm { flex: 1; min-height: 0; overflow: hidden; }

/* Editor footer */
.editor-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 8px 24px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.editor-footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.editor-footer-count { color: var(--subtle); font-size: var(--text-xs); }

/* ─── Notes panel ───────────────────────────────────────────────────────── */
.notes-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--panel-soft);
}
.notes-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.notes-panel-title { display: flex; align-items: center; gap: 8px; }
.notes-panel-title h2 { margin: 0; font-size: var(--text-base); font-weight: 600; color: var(--text); }
.notes-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
}
.notes-panel-sort-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms ease;
}
.notes-panel-sort-btn:hover { border-color: var(--border-strong); color: var(--text); }

.note-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.note-card-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.note-card-item:hover { background: var(--panel); border-color: var(--border); }
.note-card-item.is-active { background: var(--active-bg); border-color: var(--active-border); }
.note-card-title { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-time { display: block; font-size: var(--text-xs); color: var(--subtle); }

/* ─── Connect mode ──────────────────────────────────────────────────────── */
.connect-shell {
  flex-direction: column;
  background: var(--panel);
  overflow-y: auto;
}
.mode-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.connect-tags-panel { margin: 16px 16px 0; }
.connect-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 340px);
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px 16px 16px;
}
.connect-note-list, .project-list, .candidate-list, .stack-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 0;
}
.connect-detail-panel { overflow-y: auto; }

/* ─── Note cards (connect/combine) ─────────────────────────────────────── */
.note-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.note-card:hover { border-color: var(--border-strong); background: var(--surface); }
.note-card.is-active { border-color: var(--active-border); background: var(--active-bg); }

/* ─── Note card row (with checkbox for multi-select) ───────────────────── */
.note-card-row { display: flex; align-items: flex-start; gap: 0; }
.note-card-row .note-card { flex: 1; min-width: 0; }
.note-card-row.is-selected .note-card { border-color: var(--active-border); background: var(--active-bg); }
.note-card-check-label { display: flex; align-items: center; padding: 13px 7px 13px 0; cursor: pointer; flex-shrink: 0; line-height: 1; }
.note-card-check { width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.selection-pill { background: rgba(26,45,74,0.12); color: var(--accent); font-weight: 600; }
.section-heading-actions { display: flex; align-items: center; gap: 6px; }
.text-xs { font-size: var(--text-xs); }
.note-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-card strong { font-size: var(--text-base); font-weight: 600; line-height: 1.3; }
.note-meta { color: var(--muted); font-size: var(--text-xs); }
.note-excerpt { margin: 0; color: var(--muted); font-size: var(--text-xs); line-height: 1.55; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

.pin-badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; background: rgba(26,31,46,0.08); color: var(--accent); font-size: var(--text-xs); font-weight: 600; }
.dirty-badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; background: rgba(217,119,6,0.1); color: #d97706; font-size: var(--text-xs); font-weight: 600; }

/* ─── Tags ──────────────────────────────────────────────────────────────── */
.tag-cloud, .selected-tag-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.tag-chip:hover { background: var(--surface); border-color: var(--border-strong); }
.tag-chip.is-active { background: var(--accent); border-color: transparent; color: #fff; }
.tag-chip span { opacity: 0.65; }
.tag-chip.is-active span { opacity: 0.8; }

/* ─── Section headings ──────────────────────────────────────────────────── */
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0; }
.section-heading h2 { margin: 0; font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.015em; }
.muted-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: var(--text-xs); font-weight: 600; }

/* ─── Inline forms ──────────────────────────────────────────────────────── */
.inline-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.inline-field { flex: 1; }
.project-create-form { flex-wrap: nowrap; }
.editor-field { display: flex; flex-direction: column; gap: 5px; }
.editor-field span { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.search-field { display: flex; flex-direction: column; gap: 5px; }
.search-field span { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.text-input, .search-field input, .search-field select, .editor-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.text-input:focus, .search-field input:focus, .search-field select:focus, .editor-field textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.editor-field textarea { flex: 1; min-height: 80px; resize: none; line-height: 1.55; }

/* ─── Header actions ────────────────────────────────────────────────────── */
.header-actions { display: flex; align-items: center; gap: 6px; }
.mode-control-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-search-field { flex: 1 1 240px; }
.mode-sort-field { flex: 0 0 180px; }

/* ─── Combine mode ──────────────────────────────────────────────────────── */
.combine-shell {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  background: var(--panel);
  overflow: hidden;
}

/* ─── Write mode ────────────────────────────────────────────────────────── */
.write-shell {
  display: grid;
  grid-template-columns: 1fr 300px;
  height: 100%;
}
.editor-panel-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.project-sidebar { border-right: 1px solid var(--border); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.project-workbench { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden; padding: 16px; }
.project-header-panel { flex-shrink: 0; }
.combine-filter-panel { flex-shrink: 0; }
.combine-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.combine-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; flex: 1; min-height: 0; overflow: hidden; }

/* ─── Summary / stack cards ─────────────────────────────────────────────── */
.summary-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.summary-card:hover { border-color: var(--border-strong); background: var(--surface); }
.summary-card.is-active { border-color: var(--active-border); background: var(--active-bg); }
.summary-card strong { display: block; font-weight: 600; font-size: var(--text-sm); }
.summary-card span { display: block; font-size: var(--text-xs); color: var(--muted); }
.stack-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
}
.stack-card.is-stacked { align-items: center; }
.stack-card-main { min-width: 0; }
.stack-card strong { font-weight: 600; font-size: var(--text-sm); }
.stack-card p { margin: 3px 0 0; color: var(--muted); font-size: var(--text-xs); }
.stack-order { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: var(--text-xs); font-weight: 700; flex-shrink: 0; margin-right: 8px; }
.stack-card-actions { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stack-order-controls { display: inline-flex; align-items: center; gap: 6px; }
.stack-grab-handle { height: 30px; padding: 0 9px; font-size: var(--text-xs); cursor: grab; }
.stack-grab-handle:active { cursor: grabbing; }
.stack-card.is-dragging { opacity: 0.58; }
.stack-card.is-drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.stack-card.is-drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.flattened-card { margin-top: 4px; }

/* ─── Empty & helper ────────────────────────────────────────────────────── */
.empty-state { color: var(--muted); font-size: var(--text-sm); margin: 0; padding: 12px 0; }
.mode-helper-copy, .context-copy, .connect-note-copy { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }

/* ─── Status bar ────────────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  height: var(--status-bar-height);
  padding: 0 20px;
  border-top: 1px solid var(--status-bar-border);
  background: var(--status-bar-bg);
  gap: 12px;
}
.status-left { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.status-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.status-icon { flex-shrink: 0; color: #10b981; width: 14px; height: 14px; }
.status-text { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-message { max-width: 220px; }
.status-sep { color: var(--subtle); flex-shrink: 0; }
.note-count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: var(--text-xs); font-weight: 600; }

/* ─── Onboarding overlay ────────────────────────────────────────────────── */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10,14,26,0.55);
  backdrop-filter: blur(10px);
}
.onboarding-card {
  width: min(800px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}
.onboarding-eyebrow { margin: 0 0 10px; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.onboarding-card h2 { margin: 0 0 10px; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.onboarding-copy { margin: 0 0 20px; color: var(--muted); font-size: var(--text-base); line-height: 1.6; }
.onboarding-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.onboarding-step { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.onboarding-step h3 { margin: 0 0 8px; font-size: var(--text-base); font-weight: 600; }
.onboarding-step p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }
.onboarding-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .collect-shell { grid-template-columns: 1fr; }
  .write-shell { grid-template-columns: 1fr; }
  .notes-panel { display: none; }
  .connect-layout, .combine-layout { grid-template-columns: 1fr; }
  .combine-shell { grid-template-columns: 1fr; }
  .combine-filter-grid { grid-template-columns: 1fr; }
  .onboarding-grid { grid-template-columns: 1fr; }
  .inline-form, .header-actions, .onboarding-actions { flex-direction: column; align-items: stretch; }
}
