/**
 * projects.css — Projects System
 *
 * Styles for: Projects sidebar tab/button, project cards + session
 * dropdowns, right-panel project tabs (Canvas/Connectors/Context),
 * project file cards, upload zone, instructions/memory editors,
 * token meter, new-project modal.
 *
 * Only active when body.in-project-session (right panel) or
 * when sidebar tab 'projects' is open (sidebar).
 */

/* ─── Sidebar: Projects tab button ─────────────────────────────── */

#sidebar-tabs-row {
  display: flex;
  padding: 8px 8px 0;
  gap: 6px;
  background: var(--panel-2);
}

/* Separate row just for the Projects wide button */
#sidebar-projects-row {
  padding: 0 8px 8px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

#sidebar-projects-btn {
  /* Layout handled by .sidebar-tab + #sidebar-tabs-row2 in base.css */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
#sidebar-projects-btn:hover { color: var(--text); border-color: var(--line-strong); }
#sidebar-projects-btn.active {
  background: #eaf2ff;
  border-color: #bdd3f6;
  color: #0d4faf;
}
:root[data-theme="dark"] #sidebar-projects-btn { background: var(--panel); }
:root[data-theme="dark"] #sidebar-projects-btn.active {
  background: rgba(76,141,255,0.12);
  color: #7db3ff;
  border-color: #3d4f6e;
}

/* ─── Sidebar: Projects tab content ────────────────────────────── */

#sidebar-projects {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
#sidebar-projects.active { display: flex; }

/* ─── Project card ──────────────────────────────────────────────── */

.project-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--panel-2) 74%, transparent);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.project-card:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: var(--shadow-sm);
}
.project-card.active-project {
  border-color: var(--flame-border);
  background: color-mix(in srgb, var(--flame-glow) 55%, var(--panel) 45%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--t-accent) 8%, transparent);
}

.project-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  cursor: pointer;
  user-select: none;
}
.project-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--flame-glow) 65%, var(--panel-2) 35%);
  border: 1px solid var(--flame-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
  color: var(--text);
}
.project-card-meta { flex: 1; min-width: 0; }
.project-card-name {
  font-size: 12px;
  font-weight: 700;
  color: #e8e6e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-card-sub {
  font-size: 10px;
  color: #9a9890;
  margin-top: 1px;
}
.project-card-add-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: all 0.15s ease;
  font-family: var(--t-font-ui);
}
.project-card-add-btn:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.project-card-delete-btn {
  display: none;
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  flex-shrink: 0;
  font-size: 13px;
  transition: all 0.12s ease;
}
body.projects-edit-mode .project-card-delete-btn { display: flex; }
.project-card-delete-btn:hover { background: #fee2e2; color: var(--err); }

.project-card-chevron {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.18s ease;
  flex-shrink: 0;
  margin-left: 2px;
}
.project-card.open .project-card-chevron { transform: rotate(180deg); }

/* ─── Project sessions dropdown ─────────────────────────────────── */

.project-sessions-list {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.project-card.open .project-sessions-list { display: flex; }

.project-session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 11px;
  color: var(--text);
  transition: background 0.12s ease;
}
.project-session-item:last-child { border-bottom: none; }
.project-session-item:hover { background: color-mix(in srgb, var(--panel) 82%, transparent); }

/* Projects are a compact tree, not a stack of cards. */
#projects-list { padding: 4px 10px 12px 0; }
.project-card {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  box-shadow: none;
}
.project-card:hover,
.project-card.active-project {
  border: 0;
  background: transparent;
  box-shadow: none;
}
.project-card-header {
  min-height: 32px;
  padding: 6px 7px;
  gap: 7px;
  border-radius: 7px;
}
.project-card-header:hover { background: color-mix(in srgb, var(--panel) 84%, transparent); }
.project-card.active-project > .project-card-header { color: var(--text); }
.project-card-icon {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
.project-card-name { flex: 1; font-size: 12px; font-weight: 650; }
.project-card-meta,
.project-card-sub { display: none; }
.project-card-add-btn {
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  opacity: 0;
}
.project-card:hover .project-card-add-btn,
.project-card:focus-within .project-card-add-btn { opacity: 1; }
.project-card-add-btn:hover { background: var(--panel-2); color: var(--text); }
.project-card-chevron { margin-left: 1px; font-size: 9px; }
.project-sessions-list {
  margin: 0 0 3px 24px;
  border: 0;
  background: transparent;
}
.project-session-item {
  min-height: 30px;
  padding: 6px 7px;
  gap: 7px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
}
.project-session-item:hover { background: color-mix(in srgb, var(--panel) 84%, transparent); }
.project-session-item.active-session { background: color-mix(in srgb, var(--brand) 18%, var(--panel) 82%); color: var(--text); }
.project-session-name { font-size: 11px; }
.project-session-time { display: none; }

/* New-project directory scoping flow. */
.project-setup-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .56);
}
.project-setup-modal.open { display: flex; }
.project-setup-dialog {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}
.project-setup-icon {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 15px;
  place-items: center;
  border: 1px solid var(--flame-border);
  border-radius: 12px;
  background: var(--flame-glow);
  color: var(--brand);
}
.project-setup-icon-warning { color: var(--yellow); }
.project-setup-icon img { width: 34px; height: 34px; object-fit: contain; }
.project-setup-dialog h2 { margin: 0 0 9px; font-size: 18px; color: var(--text); }
.project-setup-dialog p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.project-setup-path { display: block; box-sizing: border-box; width: 100%; margin: 14px 0 0; padding: 9px 10px; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); font: 11px var(--t-font-ui); }
.project-setup-path:focus { outline: none; border-color: var(--brand); }
.project-setup-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.project-setup-primary,
.project-setup-secondary,
.project-setup-back { border-radius: 8px; padding: 9px 13px; font: 700 12px var(--t-font-ui); cursor: pointer; }
.project-setup-primary { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.project-setup-secondary { border: 1px solid var(--line); background: transparent; color: var(--text); }
.project-setup-back { margin-top: 12px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.project-setup-back:hover { color: var(--text); text-decoration: underline; }
.project-session-item.active-session {
  background: color-mix(in srgb, var(--flame-glow) 55%, var(--panel) 45%);
  color: var(--text);
  font-weight: 700;
}

/* Project groups live in the Projects rail. The group row uses the same quiet
   session treatment; only the chevron and folder mark signal that it expands. */
.project-sidebar-tree {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
  gap: 2px;
  padding: 4px 10px 2px;
}
.project-sidebar-group {
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.project-sidebar-row {
  display: block;
  min-height: 0;
  box-sizing: border-box;
  padding: 7px 30px 7px 32px;
  margin: 0 0 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}
.project-sidebar-row:hover,
.project-sidebar-group.active-project .project-sidebar-row {
  background: var(--sidebar-item-hover);
  border-color: transparent;
  box-shadow: none;
}
.project-sidebar-row.active { background: var(--sidebar-active-bg); }
.project-sidebar-row .project-card-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 17px;
  height: 17px;
  border: 0;
  background: transparent;
  color: var(--sidebar-muted, var(--muted));
}
.project-sidebar-row .project-card-icon svg { width: 15px; height: 15px; }
.project-row-content {
  display: block;
  min-width: 0;
}
.project-row-meta {
  display: flex;
  margin-top: 0;
}
.project-sidebar-row .project-card-meta {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}
.project-sidebar-row .project-card-name {
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.25;
  color: var(--sidebar-text, var(--text));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-sidebar-row .project-card-sub { display: none; }
.project-row-time {
  flex: 0 0 auto;
  color: var(--sidebar-muted, var(--muted));
  font-size: 10px;
}
.project-sidebar-row .project-card-add-btn {
  position: absolute;
  top: 7px;
  right: 32px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sidebar-muted, var(--muted));
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
}
body:not(.pm-mobile-active) .project-sidebar-row .project-sidebar-top-time {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  max-width: 76px;
  overflow: hidden;
  color: var(--sidebar-muted, var(--muted));
  font-size: 10px;
  line-height: 1.25;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity .12s ease;
}
body:not(.pm-mobile-active) .project-sidebar-row .project-card-pin-btn {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-muted, var(--muted));
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
}
.project-sidebar-row .project-card-pin-btn svg { width: 13px; height: 13px; }
.project-sidebar-row:hover .project-sidebar-top-time,
.project-sidebar-row:focus-within .project-sidebar-top-time { opacity: 0; }
.project-sidebar-row:hover .project-card-add-btn,
.project-sidebar-row:focus-within .project-card-add-btn,
.project-sidebar-row:hover .project-card-pin-btn,
.project-sidebar-row:focus-within .project-card-pin-btn {
  opacity: 1;
  pointer-events: auto;
}
.project-sidebar-row .project-card-add-btn:hover { background: var(--sidebar-active-bg); color: var(--text); }
.project-sidebar-row .project-card-pin-btn:hover,
.project-sidebar-row .project-card-pin-btn.active {
  background: var(--sidebar-active-bg);
  color: var(--brand);
}
.project-sidebar-row .project-card-delete-btn { position: absolute; top: 7px; right: 32px; }
.project-sidebar-group .project-sessions-list {
  display: none;
  gap: 2px;
  margin: 1px 0 3px 16px;
  padding-left: 8px;
  border-left: 1px solid color-mix(in srgb, var(--line-strong) 72%, transparent);
}
.project-sidebar-group.open .project-sessions-list { display: flex; }
#projects-list .project-sessions-list { background: transparent !important; }
#projects-list .project-sidebar-row {
  padding: 7px 30px 7px 32px !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
}
#projects-list .project-sidebar-row:hover {
  background: var(--sidebar-item-hover) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
#projects-list .project-sidebar-group.active-project .project-sidebar-row,
#projects-list .project-sidebar-row.active {
  background: var(--sidebar-active-bg) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
#projects-list .project-sidebar-row::before { display: none !important; }
#projects-list .project-chat-session-card {
  margin-bottom: 2px;
  padding: 7px 30px 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent !important;
  box-shadow: none !important;
}
#projects-list .project-chat-session-card:hover,
#projects-list .project-chat-session-card.active {
  background: var(--sidebar-item-hover) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
#projects-list .project-chat-session-card.is-working,
#projects-list .project-chat-session-card.unread:not(.active) {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
#projects-list .project-chat-session-card.is-working::before,
#projects-list .project-chat-session-card.unread::before { display: none; }
.project-chat-delete-btn {
  display: none;
  right: 32px;
}
body.projects-edit-mode .project-chat-delete-btn { display: inline-flex; }
.project-chat-delete-btn:hover { color: #f87171; background: rgba(248,113,113,0.12); }
.project-empty-session {
  padding: 7px 8px;
  color: var(--sidebar-muted, var(--muted));
  font-size: 10px;
}

.project-session-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.project-session-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-session-time { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.project-session-delete-btn {
  width: 18px;
  height: 18px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
  transition: all 0.12s ease;
}
body.projects-edit-mode .project-session-delete-btn { display: flex; }
.project-session-delete-btn:hover { background: #fee2e2; color: var(--err); }

/* ─── Right panel: inline project section ───────────────────────── */

/* Keep the normal right-rail header and its Canvas button. Project context
   replaces generic connections inline below it instead of becoming a tabbed
   secondary sidebar. */
#project-session-section { display: none; }
body.in-project-session #right-panel-topbar { display: flex !important; order: -1; }
body.in-project-session #project-session-section {
  display: block;
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}
body.in-project-session #rp-project-tab,
body.in-project-session #rp-context-tab { display: block !important; }
body.in-project-session #rp-context-tab { border-top: 1px solid var(--line); }
/* Projects use the right rail itself as the one scroll surface. Keep the
   workspace/editor section and the source tabs at their natural height so a
   long project never creates a nested scrollbar inside the rail. */
body.in-project-session #right-panel.open:not(.canvas-open) {
  overflow-y: auto;
  overflow-x: hidden;
}
body.in-project-session #source-panel-shell {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}
body.in-project-session #source-panel-body {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}
/* Generic chat context stays hidden, but the shared connector catalog remains
   available directly below the project workspace and editors. */
body.in-project-session #mcp-servers-section,
body.in-project-session #agent-context-section,
body.in-project-session #session-approvals-section { display: none !important; }

.rp-tab {
  flex: 1;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--t-font-ui);
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.rp-tab:last-child { border-right: none; }
.rp-tab:hover { color: var(--text); background: rgba(22,104,227,0.05); }
.rp-tab.active {
  color: #0d4faf;
  background: #eaf2ff;
  border-bottom: 2px solid var(--brand);
}
:root[data-theme="dark"] .rp-tab.active {
  color: #7db3ff;
  background: rgba(76,141,255,0.12);
  border-bottom-color: var(--brand);
}

/* Legacy project tab content classes are retained for compatibility. */
.rp-tab-content { display: none; }
.rp-tab-content.active { display: block; }

/* Connectors section — shown via tab when in project, shown directly otherwise */
#connections-section-wrap { display: flex; flex-direction: column; }

/* ─── Project Context tab: file grid ───────────────────────────── */

.project-file-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 12px 12px;
}
.project-file-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  min-height: 70px;
  justify-content: center;
}
.project-file-card:hover {
  border-color: #9fbef1;
  box-shadow: 0 4px 14px rgba(15,60,120,0.09);
  transform: translateY(-1px);
}
:root[data-theme="dark"] .project-file-card { background: var(--panel-2); border-color: var(--line); }
:root[data-theme="dark"] .project-file-card:hover {
  border-color: #3d5a80;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.project-file-icon { font-size: 20px; line-height: 1; }
.project-file-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  text-align: center;
}

.project-context-card {
  width: calc(100% - 24px);
  margin: 8px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  color: var(--text);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-family: var(--t-font-ui);
}
.project-context-card:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--panel-2)); }
.project-context-card-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; color: var(--brand); font-size: 16px; flex: 0 0 auto; }
.project-context-card-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 2px; }
.project-context-card-copy strong { font-size: 12px; letter-spacing: .02em; }
.project-context-card-copy small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.project-context-card-action { color: var(--brand); font-size: 11px; font-weight: 800; }

/* Upload drop zone */
.project-upload-zone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin: 8px 12px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.project-upload-zone:hover,
.project-upload-zone.drag-over {
  border-color: var(--brand);
  background: rgba(22,104,227,0.04);
  color: var(--brand);
}

/* Token meter */
.project-token-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  margin: 4px 12px 8px;
}
.project-token-bar {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.project-token-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.3s ease;
}

/* ─── Agent context: project editors ────────────────────────────── */

.project-editors-wrap {
  display: none;
  flex-direction: column;
  gap: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
body.in-project-session .project-editors-wrap { display: flex; }

.project-editor-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 8px;
}
.project-editor-block:last-child { margin-bottom: 0; }
.project-editor-label {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--panel-2);
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  font-family: var(--t-font-ui);
  text-align: left;
  user-select: none;
}
.project-editor-label:focus,
.project-editor-label:focus-visible {
  outline: none;
  box-shadow: none;
  border-bottom-color: var(--line-strong);
}
.project-editor-chevron { transition: transform 0.18s ease; font-size: 10px; }
.project-editor-block.collapsed .project-editor-chevron { transform: rotate(-90deg); }
.project-editor-block.collapsed .project-editor-body { display: none; }
.project-editor-body { padding: 8px; }
.project-editor-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--t-font-ui);
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 10px;
  resize: vertical;
  min-height: 68px;
  outline: none;
  transition: border-color 0.15s ease;
}
.project-editor-textarea:focus { border-color: #9fc1f7; box-shadow: 0 0 0 3px rgba(22,104,227,0.09); }
.project-editor-textarea:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--panel-2);
}
:root[data-theme="dark"] .project-editor-textarea { background: var(--panel-2); }
.project-editor-save-btn {
  margin-top: 6px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 7px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--t-font-ui);
  transition: background 0.15s ease;
}
.project-editor-save-btn:hover { background: var(--brand-2); }

/* ─── Channels button & panel ───────────────────────────────────── */

#btn-channels {
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

#sidebar-channels {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
}

/* ─── Channel hub cards ─────────────────────────────────────────── */

.channel-hub-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  margin: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  user-select: none;
}
.channel-hub-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  background: var(--panel-2);
}
.channel-hub-card-empty {
  opacity: 0.55;
}
.channel-hub-card-empty:hover {
  opacity: 0.8;
}
:root[data-theme="dark"] .channel-hub-card {
  background: var(--panel-2);
}

.channel-hub-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--panel-2) 82%, transparent);
  color: var(--text);
}

.channel-hub-card-body {
  flex: 1;
  min-width: 0;
}
.channel-hub-card-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.channel-hub-card-desc {
  font-size: 10px;
  color: var(--muted);
}

.channel-hub-card-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.channel-hub-unread {
  background: #e05c5c;
  color: #fff;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

/* ─── Channel drill-down header ─────────────────────────────────── */

.channel-drill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.channel-drill-back {
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-family: var(--t-font-ui);
  transition: color 0.15s ease, background 0.15s ease;
}
.channel-drill-back:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.channel-drill-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* ─── New Project modal ─────────────────────────────────────────── */

#new-project-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,20,40,0.35);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
#new-project-modal.open { display: flex; }

/* Inline project rows use the regular chat footprint; only their children
   receive the tree guide, with no extra project panel. */
.project-inline-section-title { margin-top: 10px; }
.project-chat-group { display: block; }
.project-chat-row { position: relative; cursor: pointer; }
.project-chat-row .project-chat-pin-btn { z-index: 2; }
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row {
  padding-right: 62px;
}
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-top-time {
  position: absolute;
  top: 7px;
  right: 8px;
  z-index: 2;
  max-width: 76px;
  overflow: hidden;
  color: var(--sidebar-muted, var(--muted));
  font-size: 10px;
  line-height: 1.25;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity .12s ease;
}
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-new-btn,
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-pin-btn {
  position: absolute;
  top: 7px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-muted, var(--muted));
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
}
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-new-btn { right: 32px; font-size: 16px; line-height: 1; }
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-pin-btn { right: 8px; }
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-pin-btn svg { width: 13px; height: 13px; }
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row:hover .project-chat-top-time,
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row:focus-within .project-chat-top-time { opacity: 0; }
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row:hover .project-chat-new-btn,
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row:focus-within .project-chat-new-btn,
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row:hover .project-chat-pin-btn,
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row:focus-within .project-chat-pin-btn {
  opacity: 1;
  pointer-events: auto;
}
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-new-btn:hover,
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-pin-btn:hover,
body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-pin-btn.active {
  background: var(--sidebar-active-bg);
  color: var(--brand);
}
.project-chat-icon-line { display: inline-flex; align-items: center; gap: 3px; margin-right: 2px; color: var(--brand, var(--theme-palette-gold)); vertical-align: -2px; }
.project-chat-icon-line .imported-source-logo { display: inline-block; width: 18px; height: 18px; flex: 0 0 18px; vertical-align: -4px; }
.project-chat-icon-line .imported-source-logo-fallback { display: inline-block; width: 18px; height: 18px; flex: 0 0 18px; }
.project-chat-folder { display: inline-flex; width: 18px; height: 18px; }
.project-chat-folder svg { width: 100%; height: 100%; }
.project-chat-children { margin: 1px 0 4px 16px; padding-left: 8px; border-left: 1px solid color-mix(in srgb, var(--line, #596273) 76%, transparent); }
.project-chat-children[hidden] { display: none; }

/* Keep the project tree heading borderless. Its shared sidebar decoration is
   defined with the other desktop section headings; child chat cards keep
   their existing spacing. */
#sidebar-projects-section > .section-title {
  border: 0;
  box-shadow: none;
  background: transparent;
}
#sidebar-projects-section .project-chat-row {
  border: 0;
  box-shadow: none;
}
#sidebar-projects-section .project-chat-project-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}
#sidebar-projects-section .project-chat-row.imported-project .project-chat-project-title {
  gap: 0;
}
#sidebar-projects-section .project-chat-icon-line {
  flex: 0 0 auto;
  gap: 2px;
  margin-right: 0;
  vertical-align: middle;
}
#sidebar-projects-section .project-chat-folder,
#sidebar-projects-section .project-chat-icon-line .imported-source-logo,
#sidebar-projects-section .project-chat-icon-line .imported-source-logo-fallback {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}
#sidebar-projects-section .project-chat-project-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body:not(.pm-mobile-active) #sidebar-projects-section .project-chat-row.imported-project .project-chat-project-name {
  margin-left: 0;
}
