/* ============================================================
   Full Stack Jack — Design System v2
   Aesthetic: Refined Dark Tool (Linear/Raycast-inspired)
   Font: Geist Sans · Icons: Lucide SVG
   ============================================================ */

/* Geist Sans — the premium tool font (Vercel) */
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/Geist-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/Geist-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/Geist-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/Geist-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-mono/GeistMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Backgrounds — deep, high-contrast dark */
  --bg:        #08080a;
  --surface:   #111114;
  --surface-2: #1a1a1e;
  --surface-3: #232328;

  /* Borders — slightly more visible for card definition */
  --border:    rgba(255,255,255,0.08);
  --border-2:  rgba(255,255,255,0.12);

  /* Typography — crisp hierarchy */
  --text:      #ededef;
  --text-2:    #a0a0a8;
  --text-3:    #63636e;

  /* Brand — vibrant purple accent */
  --accent:    #8b7bf7;
  --accent-2:  #7c6ce7;
  --accent-dim:rgba(139,123,247,0.10);

  /* Silver highlight */
  --silver:    #c8c8d0;

  /* Semantic */
  --green:      #3dd68c;
  --green-dim:  rgba(61,214,140,0.10);
  --red:        #ef6461;
  --red-dim:    rgba(239,100,97,0.08);
  --blue:       #5b9cf5;
  --blue-dim:   rgba(91,156,245,0.10);
  --amber:      #f59e0b;
  --amber-dim:  rgba(245,158,11,0.10);
  --purple:     #8b7bf7;
  --purple-dim: rgba(139,123,247,0.10);

  /* Shape — tight radii */
  --radius-sm:  4px;
  --radius:     6px;
  --radius-lg:  10px;
  --radius-xl:  14px;
  --radius-full:9999px;

  /* Shadow */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.5);
  --shadow:     0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.7);

  /* Motion */
  --ease:       cubic-bezier(0.23, 1, 0.32, 1);
  --dur-fast:   100ms;
  --dur:        200ms;

  /* Layout */
  --sidebar-w:  220px;
}

/* ── Light Mode Tokens ──────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f5f5f7;
  --surface:   #ffffff;
  --surface-2: #f0f0f2;
  --surface-3: #e6e6ea;

  --border:    rgba(0,0,0,0.08);
  --border-2:  rgba(0,0,0,0.12);

  --text:      #0f0f11;
  --text-2:    #55555f;
  --text-3:    #8e8e98;

  --accent:    #6d5dd3;
  --accent-2:  #5f4fc4;
  --accent-dim: rgba(109,93,211,0.07);

  --green:      #1a9a5c;
  --green-dim:  rgba(26,154,92,0.07);
  --red:        #d93636;
  --red-dim:    rgba(217,54,54,0.06);
  --blue:       #2f6fdb;
  --blue-dim:   rgba(47,111,219,0.06);
  --amber:      #d97706;
  --amber-dim:  rgba(217,119,6,0.07);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 4px 16px rgba(0,0,0,0.07);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.10);
}

/* Light mode sidebar */
[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right-color: var(--border);
}

/* Light mode page title */
[data-theme="light"] .page-title {
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: var(--text);
  background-clip: unset;
}

/* Light mode stat card shimmer */
[data-theme="light"] .stat-card::before {
  background: linear-gradient(90deg, transparent, rgba(109,93,211,0.15), transparent);
}

/* Light mode primary action card */
[data-theme="light"] .action-card.primary {
  border-color: rgba(109,93,211,0.18);
}
[data-theme="light"] .action-card.primary::after {
  background: linear-gradient(90deg, transparent, rgba(109,93,211,0.10), transparent);
}

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

/* ── Base ──────────────────────────────────────────────────── */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
svg { flex-shrink: 0; }

code, pre, .mono {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
}

/* ── App Layout ────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
}

/* Brand / Logo */
.sidebar-logo {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.sidebar-logo-org {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px 6px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-group { margin-bottom: 2px; }

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 10px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 400;
  border-radius: var(--radius);
  transition: color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
  position: relative;
  white-space: nowrap;
}

.sidebar-nav a svg { opacity: 0.5; transition: opacity var(--dur-fast) var(--ease); }

.sidebar-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.sidebar-nav a:hover svg { opacity: 0.8; }

.sidebar-nav a.active {
  color: var(--text);
  background: var(--surface-2);
  font-weight: 500;
}

.sidebar-nav a.active svg { opacity: 1; color: var(--text); }

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: var(--radius-full);
  background: var(--accent);
}

/* Footer */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Theme toggle button (injected by theme.js) */
.theme-toggle {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-2);
  background: var(--surface-2);
}

.sidebar-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-3);
}

/* Sidebar user area — clickable */
.sidebar-user-area {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 4px 6px; margin: -4px -6px;
  border-radius: var(--radius); transition: background 120ms var(--ease);
  flex: 1; min-width: 0;
}
.sidebar-user-area:hover { background: var(--surface-2); }

/* Account popover */
.account-popover {
  position: absolute; bottom: calc(100% + 8px); left: 8px; right: 8px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 200;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}
.account-popover.open {
  opacity: 1; transform: translateY(0); pointer-events: auto;
}
.account-popover-header {
  padding: 10px 10px 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.account-popover-email {
  font-size: 12px; color: var(--text-3); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.account-popover-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius);
  font-size: 13px; color: var(--text-2); cursor: pointer;
  transition: background 80ms var(--ease), color 80ms var(--ease);
  border: none; background: none; width: 100%; text-align: left;
  font-family: inherit; text-decoration: none;
}
.account-popover-item:hover { background: var(--surface-2); color: var(--text); }
.account-popover-item svg { opacity: 0.5; flex-shrink: 0; }
.account-popover-item:hover svg { opacity: 0.8; }
.account-popover-item.danger { color: var(--red); }
.account-popover-item.danger:hover { background: var(--red-dim); }
.account-popover-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Main ──────────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 40px 48px;
  min-height: 100vh;
  max-width: calc(var(--sidebar-w) + 960px);
}

/* Fluid main — for full-screen/overflow-hidden page layouts */
.main-fluid {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-w));
  transition: margin-left 200ms var(--ease), max-width 200ms var(--ease);
}
.sidebar-is-collapsed .main-fluid { margin-left: 56px; max-width: calc(100vw - 56px); }

/* ── Toolbar ────────────────────────────────────────────────── */
.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  gap: 16px;
  flex-shrink: 0;
}
.toolbar-left  { display: flex; align-items: center; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.2px;
}
.toolbar-back {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: 13px;
  text-decoration: none;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease);
}
.toolbar-back:hover { color: var(--text); }
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.toolbar-btn:hover {
  color: var(--text);
  border-color: var(--border-2);
  background: var(--surface-2);
}
.toolbar-btn.active {
  background: var(--accent-dim);
  border-color: rgba(139,123,247,0.2);
  color: var(--accent);
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
  font-weight: 400;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Market sentiment badge */
.market-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.market-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.market-BULLISH, .market-VERY_BULLISH  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(61,214,140,0.12); }
.market-BEARISH, .market-VERY_BEARISH  { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239,100,97,0.12); }
.market-NEUTRAL, .market-neutral       { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(139,123,247,0.12); }

/* ── Stats Row ─────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  transition: border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}

/* Top row: icon + label + trend badge */
.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.stat-icon svg { width: 14px; height: 14px; }

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}
.stat-trend--up   { color: var(--green); background: var(--green-dim); }
.stat-trend--down { color: var(--red); background: var(--red-dim); }
.stat-trend--flat { color: var(--text-3); }

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1.5px;
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

/* ── Dashboard Grid (two-column layout for lower sections) ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ── Action Cards ──────────────────────────────────────────── */
.action-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 32px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: block;
  color: var(--text);
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}

.action-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.action-card.primary {
  border-color: rgba(139,123,247,0.15);
  background: linear-gradient(135deg, rgba(139,123,247,0.04) 0%, transparent 100%);
}

/* top edge on primary card */
.action-card.primary::after {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,123,247,0.4), transparent);
}

.action-card.primary:hover {
  border-color: rgba(139,123,247,0.3);
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text-2);
  transition: color var(--dur) var(--ease);
}

.action-card:hover .card-icon { color: var(--text); }
.action-card.primary .card-icon { background: var(--accent-dim); border-color: rgba(139,123,247,0.15); color: var(--accent); }

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.card-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease), gap var(--dur-fast) var(--ease);
}

.action-card:hover .card-link { color: var(--text-2); gap: 6px; }
.action-card.primary .card-link { color: var(--accent); opacity: 0.7; }
.action-card.primary:hover .card-link { opacity: 1; }

/* ── App Footer ────────────────────────────────────────────── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-top: 32px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}
.app-footer-links {
  display: flex;
  gap: 16px;
}
.app-footer-links a {
  color: var(--text-3);
  transition: color var(--dur-fast) var(--ease);
}
.app-footer-links a:hover { color: var(--text-2); }

/* ── Page entrance animations ──────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up {
  animation: fadeUp 0.35s var(--ease) both;
}
.fade-up-1 { animation-delay: 0.04s; }
.fade-up-2 { animation-delay: 0.08s; }
.fade-up-3 { animation-delay: 0.12s; }
.fade-up-4 { animation-delay: 0.18s; }
.fade-up-5 { animation-delay: 0.24s; }
.fade-up-6 { animation-delay: 0.32s; }

/* ── Section Headers ───────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.1px;
}

.section-title svg { color: var(--text-3); }

/* ── List Cards ────────────────────────────────────────────── */
.recent-section { margin-bottom: 28px; }

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-item {
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast) var(--ease);
  cursor: default;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item[href] { cursor: pointer; }

.list-item-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
}

.list-item-body { flex: 1; min-width: 0; }

.list-item-text {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-meta {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

.list-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 500;
}

.badge-pending  { background: var(--accent-dim);  color: var(--accent);  }
.badge-approved { background: var(--green-dim);   color: var(--green);   }
.badge-edited   { background: var(--blue-dim);    color: var(--blue);    }
.badge-rejected { background: var(--red-dim);     color: var(--red);     }
.badge-draft    { background: var(--surface-3);   color: var(--text-2);  border: 1px solid var(--border-2); }
.badge-tweet    { background: var(--blue-dim);    color: var(--blue);    }
.badge-thread   { background: var(--purple-dim);  color: var(--purple);  }
.badge-blog     { background: var(--accent-dim);  color: var(--accent);  }
.badge-scheduled{ background: var(--green-dim);   color: var(--green);   }

/* ── Pill Link ─────────────────────────────────────────────── */
.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}

.pill-link:hover { color: var(--text-2); border-color: var(--border-2); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-2); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-2);
}
.btn-secondary:hover { background: var(--surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }

/* ── Inputs ────────────────────────────────────────────────── */
input, textarea, select {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  width: 100%;
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* ── Empty States ──────────────────────────────────────────── */
.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-3);
}

.empty-icon {
  color: var(--text-3);
  margin: 0 auto 12px;
  opacity: 0.4;
}

.empty-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 4px;
}

.empty-body {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
}

/* ── Loading ───────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

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

.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 36px;
  color: var(--text-3);
  font-size: 12px;
}

/* ── Skeleton ──────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line { height: 10px; margin-bottom: 8px; }
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.short  { width: 50%; }
.skeleton-line.medium { width: 75%; }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  z-index: 9999;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Login ─────────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.login-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 28px;
}

.login-spinner { width: 24px; height: 24px; border-width: 2px; }

.error-msg {
  margin-top: 14px;
  padding: 9px 12px;
  background: var(--red-dim);
  border: 1px solid rgba(239,100,97,0.12);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 12px;
}

/* ── Reply suggestions ─────────────────────────────────────── */
.replies-wrap {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.replies-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.reply-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  transition: border-color var(--dur-fast) var(--ease);
}

.reply-card:last-child { margin-bottom: 0; }
.reply-card:hover { border-color: var(--border-2); }

.reply-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.reply-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
}

.reply-vibe {
  padding: 2px 7px;
  background: var(--blue-dim);
  color: var(--blue);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.reply-angle { font-size: 11px; color: var(--text-3); font-style: italic; }

.reply-actions { display: flex; gap: 4px; margin-top: 7px; }

.reply-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  font-family: inherit;
}

.reply-btn:hover { color: var(--text-2); background: var(--surface-2); }
.reply-btn.copied { border-color: rgba(61,214,140,0.2); color: var(--green); }

.reply-edit-area {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  padding: 8px 12px;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  outline: none;
}

.reply-edit-area:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.reply-edit-actions { display: flex; gap: 6px; margin-top: 6px; }

/* ── Collect button ────────────────────────────────────────── */
.collect-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--dur-fast) var(--ease);
}

.collect-btn:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }
.collect-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Signal score ──────────────────────────────────────────── */
.score-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

/* ── Empty States (shared) ─────────────────────────────────── */
.empty-state-cta {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 56px 24px; gap: 6px;
}
.empty-state-cta .empty-icon-wrap {
  width: 48px; height: 48px; border-radius: var(--radius-lg);
  background: var(--surface-3); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.empty-state-cta .empty-title {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.empty-state-cta .empty-desc {
  font-size: 13px; color: var(--text-3); max-width: 340px; line-height: 1.5;
}
.empty-state-cta .empty-action {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer;
  transition: background 150ms var(--ease);
  text-decoration: none;
}
.empty-state-cta .empty-action:hover { background: var(--accent-2); }
.empty-state-cta .empty-action svg { flex-shrink: 0; }
.empty-state-cta .empty-secondary {
  margin-top: 4px; font-size: 12px; color: var(--text-3);
}
.empty-state-cta .empty-secondary a { color: var(--accent); text-decoration: none; }
.empty-state-cta .empty-secondary a:hover { text-decoration: underline; }

/* ── Divider ───────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Utilities ─────────────────────────────────────────────── */
.hidden  { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--text-3); }

/* ── Collapsible Sidebar ──────────────────────────────────── */
.sidebar-collapse-btn {
  position: absolute; right: -12px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: var(--radius-full);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-3); display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 10; opacity: 0;
  transition: opacity 150ms var(--ease), color 150ms var(--ease),
              background 150ms var(--ease), border-color 150ms var(--ease);
}
.sidebar:hover .sidebar-collapse-btn,
.sidebar-collapse-btn:focus-visible { opacity: 1; }
.sidebar-collapse-btn:hover {
  color: var(--text); background: var(--surface-3);
  border-color: var(--border-2);
}

/* Arrow icon visibility */
.sidebar-collapse-btn .expand-icon { display: none; }
.sidebar.collapsed .sidebar-collapse-btn .collapse-icon { display: none; }
.sidebar.collapsed .sidebar-collapse-btn .expand-icon { display: block; }

/* Collapsed state */
.sidebar.collapsed {
  width: 56px;
}
.sidebar.collapsed .sidebar-logo > div:not(.sidebar-logo-icon) { display: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 16px 12px 12px; }
.sidebar.collapsed .sidebar-logo-icon { margin: 0; }
.sidebar.collapsed .sidebar-collapse-btn {
  position: static; transform: none; opacity: 1;
  margin-top: 8px; width: 100%;
  border-radius: var(--radius); border: none; background: transparent;
}

.sidebar.collapsed .nav-group-label { display: none; }
.sidebar.collapsed .sidebar-nav { padding: 8px 6px; }
.sidebar.collapsed .sidebar-nav a {
  justify-content: center; padding: 9px 0;
  font-size: 0; gap: 0;
}
.sidebar.collapsed .sidebar-nav a svg { opacity: 0.6; }

.sidebar.collapsed .sidebar-footer {
  flex-direction: column; padding: 8px 6px; gap: 6px;
}
.sidebar.collapsed .sidebar-footer > div { display: none; }
.sidebar.collapsed .sidebar-footer > a { margin-left: 0; }

/* Adjust main content margin */
.sidebar-is-collapsed .main { margin-left: 56px; }

/* Smooth transitions */
.sidebar {
  transition: width 200ms var(--ease);
}
.main {
  transition: margin-left 200ms var(--ease);
}
.sidebar-nav a {
  transition: color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease),
              padding 200ms var(--ease);
}
.sidebar-logo {
  transition: padding 200ms var(--ease);
}

/* ── Sidebar Drag Reorder ──────────────────────────────────── */
.nav-reorderable {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-drag-item {
  display: flex;
  align-items: center;
  position: relative;
  border-radius: var(--radius);
  transition: opacity 150ms, background 150ms;
}

.nav-drag-item a {
  flex: 1;
  min-width: 0;
}

.nav-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  flex-shrink: 0;
  color: transparent;
  cursor: grab;
  padding: 4px 0;
  margin-left: 2px;
  transition: color 200ms;
}

.nav-drag-item:hover .nav-drag-handle {
  color: var(--text-3);
}

.nav-drag-handle:active {
  cursor: grabbing;
}

.nav-drag-item.dragging {
  opacity: 0.3;
}

.nav-drag-placeholder {
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  margin: 1px 10px;
}

.nav-drag-clone {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  opacity: 0.85;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Section dividers between groups */
.nav-section-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 12px;
  opacity: 0.5;
}

/* Pinned item has no handle space */
.nav-drag-item.nav-pinned a {
  padding-left: 10px;
}

/* Hide handles and shrink dividers when sidebar is collapsed */
.sidebar.collapsed .nav-drag-handle { display: none; }
.sidebar.collapsed .nav-drag-item a { padding-left: 0; }
.sidebar.collapsed .nav-section-divider { margin: 4px 6px; }

/* ── Command Palette (Cmd+K) ──────────────────────────────── */
.cmd-palette-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: min(20vh, 160px);
  opacity: 0; pointer-events: none;
  transition: opacity 150ms var(--ease);
}
.cmd-palette-overlay.open {
  opacity: 1; pointer-events: auto;
}

.cmd-palette {
  width: min(520px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.97) translateY(-8px);
  transition: transform 150ms var(--ease);
}
.cmd-palette-overlay.open .cmd-palette {
  transform: scale(1) translateY(0);
}

/* Header / search */
.cmd-palette-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cmd-palette-search-icon { color: var(--text-3); flex-shrink: 0; }
.cmd-palette-input {
  flex: 1; border: none; outline: none;
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 14px;
}
.cmd-palette-input::placeholder { color: var(--text-3); }
.cmd-palette-kbd {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 6px; font-size: 10px; font-weight: 500;
  background: var(--surface-2); color: var(--text-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  line-height: 1.4;
}

/* List */
.cmd-palette-list {
  max-height: 340px; overflow-y: auto;
  padding: 6px 0;
}
.cmd-palette-group {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3);
}
.cmd-palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; cursor: pointer;
  font-size: 13px; color: var(--text-2);
  border-radius: 0;
  transition: background 80ms var(--ease), color 80ms var(--ease);
}
.cmd-palette-item.active {
  background: var(--surface-2);
  color: var(--text);
}
.cmd-palette-item-name mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 2px; padding: 0 1px;
}
.cmd-palette-current {
  margin-left: auto; font-size: 11px;
  color: var(--text-3); font-weight: 500;
}
.cmd-palette-empty {
  padding: 24px 16px; text-align: center;
  color: var(--text-3); font-size: 13px;
}

/* Footer */
.cmd-palette-footer {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3);
}
.cmd-palette-footer kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; padding: 1px 4px;
  font-size: 10px; font-weight: 500;
  background: var(--surface-2); color: var(--text-3);
  border: 1px solid var(--border); border-radius: 3px;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; padding: 2rem; }
.modal.active { display: flex; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 500px; padding: 1.5rem; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-header h2 { color: var(--text); font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.3px; }
.modal-close { background: none; border: none; color: var(--text-3); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }

/* ── Motion preference ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
