:root {
  --bg: #0c0e12;
  --surface: #141820;
  --surface-2: #1a1f2b;
  --border: #2a3142;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #6c8cff;
  --accent-dim: rgba(108, 140, 255, 0.15);
  --green: #3dd68c;
  --yellow: #f5c542;
  --gray: #6b7280;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(108, 140, 255, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(61, 214, 140, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.logo-icon {
  font-size: 1.75rem;
  color: var(--accent);
  line-height: 1;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  border-radius: 10px;
  font-weight: 700;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.sync-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.menu-wrap { position: relative; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 2.25rem;
  padding: 0.55rem 0;
  font-size: 1.1rem;
  line-height: 1;
}

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

.btn-primary:hover { background: #5a7aee; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 50;
}

.dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.dropdown button:hover { background: var(--surface-2); }

.notion-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(61, 214, 140, 0.08);
  border: 1px solid rgba(61, 214, 140, 0.25);
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
}

.brain-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.brain-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.brain-panel h2 {
  font-size: 1rem;
  font-weight: 700;
}

.brain-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.brain-actions {
  display: flex;
  gap: 0.5rem;
}

.brain-handoffs {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.brain-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.handoff-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.handoff-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.handoff-from { color: #c084fc; font-weight: 600; }
.handoff-to { color: #fb923c; font-weight: 600; }
.handoff-arrow { color: var(--text-muted); }
.handoff-time { color: var(--text-muted); margin-left: auto; font-family: 'JetBrains Mono', monospace; }

.handoff-msg {
  font-size: 0.9rem;
  line-height: 1.45;
}

.handoff-ctx {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.handoff-done { margin-top: 0.5rem; }

.modal-wide { max-width: 640px; }

.connect-content { padding: 1.5rem; }

.connect-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 1rem 0 0.75rem;
}

.connect-tab {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.connect-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.connect-snippet {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  margin-bottom: 0.75rem;
}

.connect-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.connect-url a { color: var(--accent); }

.notion-banner.disconnected {
  background: rgba(245, 197, 66, 0.08);
  border-color: rgba(245, 197, 66, 0.25);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.stat-card .label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.platform-filter-bar {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
  align-items: flex-end;
}

.filter-group label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.chip-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { border-color: var(--accent); color: var(--text); }

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

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toolbar-right { flex: 1; min-width: 200px; max-width: 320px; }

.toolbar-divider {
  width: 1px;
  height: 1.5rem;
  background: var(--border);
}

.view-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}

.view-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.toolbar-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toolbar-check input { accent-color: var(--accent); }

#searchInput {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent);
}

.bulk-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--accent-dim);
  border: 1px solid rgba(108, 140, 255, 0.35);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.bulk-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bulk-select-all {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.bulk-select-all input { accent-color: var(--accent); }

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bulk-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
}

.projects-panel { margin-top: 0.25rem; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

.project-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.project-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
}

.project-table th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.project-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid rgba(42, 49, 66, 0.6);
  vertical-align: top;
}

.project-row {
  cursor: pointer;
  transition: background 0.12s;
}

.project-row:hover { background: rgba(108, 140, 255, 0.04); }

.project-row.selected { background: rgba(108, 140, 255, 0.1); }

.project-row.is-hidden { opacity: 0.55; }

.group-row td {
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.55rem 0.85rem;
}

.group-count {
  font-weight: 500;
  color: var(--accent);
  margin-left: 0.35rem;
}

.col-check { width: 2.5rem; }
.col-platform { width: 7rem; }
.col-status { width: 6rem; }
.col-time { width: 6.5rem; white-space: nowrap; }
.col-msgs { width: 4rem; text-align: right; font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; }
.col-dir { max-width: 10rem; font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--text-muted); }
.col-actions { width: 5rem; white-space: nowrap; }

.name-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.name-primary {
  font-weight: 600;
  line-height: 1.35;
}

.name-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-badge {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(107, 114, 128, 0.2);
  color: var(--text-muted);
}

.sync-badge {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  white-space: nowrap;
}

.sync-both {
  background: rgba(108, 140, 255, 0.15);
  color: var(--accent);
}

.sync-local {
  background: rgba(61, 214, 140, 0.12);
  color: var(--green);
}

.sync-notion {
  background: rgba(251, 146, 60, 0.12);
  color: #fb923c;
}

.row-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  margin-right: 0.5rem;
}

.row-link:hover { text-decoration: underline; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.project-group { display: contents; }

.group-heading {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.group-cards {
  display: contents;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.1rem 2.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
  cursor: pointer;
}

.card:hover {
  border-color: rgba(108, 140, 255, 0.4);
  box-shadow: var(--shadow);
}

.card.selected {
  border-color: var(--accent);
  background: rgba(108, 140, 255, 0.06);
}

.card.is-hidden { opacity: 0.6; }

.card-select {
  position: absolute;
  top: 1rem;
  left: 1rem;
}

.card-select input { accent-color: var(--accent); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.badges {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.badge {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-platform { background: var(--accent-dim); color: var(--accent); }
.badge-grok { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.badge-claude { background: rgba(251, 146, 60, 0.15); color: #fb923c; }
.badge-codex { background: rgba(61, 214, 140, 0.15); color: var(--green); }
.badge-chatgpt { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }

.badge-status-active { background: rgba(61, 214, 140, 0.12); color: var(--green); }
.badge-status-paused { background: rgba(245, 197, 66, 0.12); color: var(--yellow); }
.badge-status-done { background: rgba(107, 114, 128, 0.2); color: var(--gray); }
.badge-status-archived { background: rgba(107, 114, 128, 0.1); color: var(--text-muted); }

.card-summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.card-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.card-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.card-link:hover { text-decoration: underline; }

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state h2 {
  color: var(--text);
  margin-bottom: 0.5rem;
}

.hidden { display: none !important; }

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal form {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal h2 { font-size: 1.15rem; }

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.modal input,
.modal textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
}

.modal input:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 900px) {
  .col-dir, .col-msgs { display: none; }
  .project-table th:nth-child(6),
  .project-table th:nth-child(7) { display: none; }
}

@media (max-width: 640px) {
  .header { flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { max-width: none; }
  .grid { grid-template-columns: 1fr; }
  .col-platform { display: none; }
  .project-table th:nth-child(3) { display: none; }
}