/* imagine — design language aligned with himslite.fadafad.com
 * Material Design 3, light theme, deep-teal primary, Roboto. */

:root {
  /* Brand */
  --primary: #0D7377;
  --primary-hover: #0A5D60;
  --primary-pressed: #084E51;
  --primary-tint: rgba(13, 115, 119, 0.08);
  --primary-tint-strong: rgba(13, 115, 119, 0.14);
  --on-primary: #ffffff;

  /* Neutrals */
  --bg: #F3F5F8;
  --surface: #ffffff;
  --surface-alt: #F8FAFC;
  --surface-sunk: #EEF2F6;
  --border: #E3E8EF;
  --border-strong: #CBD5E1;
  --divider: #EDF1F6;

  /* Text */
  --text: #0F172A;
  --text-muted: #475569;
  --text-dim: #64748B;
  --text-faint: #94A3B8;

  /* Semantic */
  --danger: #DC2626;
  --danger-tint: rgba(220, 38, 38, 0.08);
  --warning: #D97706;
  --success: #047857;

  /* Chat bubbles */
  --user-bubble: var(--primary);
  --user-bubble-text: #ffffff;
  --assistant-bubble: #ffffff;

  /* Code */
  --code-bg: #0F172A;
  --code-text: #E2E8F0;
  --inline-code-bg: #EEF2F6;
  --inline-code-text: #0F172A;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);

  /* Geometry */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Sidebar widths */
  --sidebar-w: 300px;
  --folder-panel-w: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html, body { overflow: hidden; }
body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--folder-panel-w);
  height: 100vh;
  height: 100dvh; /* account for mobile browser chrome */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== Sidebar ========== */
#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}
#sidebar header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}
.sidebar-section-label { flex-shrink: 0; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #14B8A6 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.1px;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.sidebar-section-label {
  padding: 14px 18px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* "Test as…" picker — admin-only convenience for QA, hidden by default and revealed
   in JS when role==='admin'. Renders as a popover anchored to the bottom-left. */
.test-as-picker { position: relative; }
.test-as-picker.hidden { display: none; }
.test-as-summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
}
.test-as-summary::-webkit-details-marker { display: none; }
.test-as-summary:hover { color: var(--text); border-color: var(--primary); background: var(--surface-sunk); }
.test-as-picker[open] .test-as-summary { color: var(--primary); border-color: var(--primary); }
.test-as-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
  padding: 4px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.test-as-menu button {
  text-align: left;
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: 5px;
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
}
.test-as-menu button:hover { background: var(--surface-sunk); color: var(--primary); }
.sidebar-user-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
}
.sidebar-user-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.sidebar-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#logoutBtn {
  font-size: 11.5px;
  padding: 5px 9px;
  flex-shrink: 0;
}

#threadList {
  list-style: none;
  padding: 0 8px 12px;
  margin: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Folder group container */
#threadList .folder-group {
  padding: 0;
  background: transparent;
  border: none;
  cursor: default;
  display: block;
  margin: 4px 0 2px;
}
#threadList .folder-group:hover { background: transparent; }

/* Folder header (clickable) */
.folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  user-select: none;
  transition: background-color 120ms;
}
.folder-header:hover { background: var(--surface-sunk); color: var(--text); }
.folder-group.has-active .folder-header { color: var(--text); }

.folder-chevron {
  transition: transform 160ms ease;
  color: var(--text-faint);
  flex-shrink: 0;
}
.folder-group.collapsed .folder-chevron { transform: rotate(0deg); }
.folder-group:not(.collapsed) .folder-chevron { transform: rotate(90deg); }

.folder-icon {
  color: var(--text-faint);
  flex-shrink: 0;
}
.folder-group.has-active .folder-icon { color: var(--primary); }

.folder-path {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  letter-spacing: 0.1px;
}

.folder-count {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-sunk);
  color: var(--text-faint);
  letter-spacing: 0.2px;
}
.folder-live-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--text-faint);
  text-decoration: none;
  flex-shrink: 0;
  transition: background-color 120ms, color 120ms;
}
.folder-live-link:hover {
  background: var(--primary-tint);
  color: var(--primary);
}
.folder-add-thread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background-color 120ms, color 120ms;
}
.folder-add-thread:hover {
  background: var(--primary-tint);
  color: var(--primary);
}
.folder-header:hover .folder-count { background: var(--surface); color: var(--text-dim); }
.folder-group.has-active .folder-count {
  background: var(--primary-tint-strong);
  color: var(--primary);
}

/* Sub-list of threads under each folder */
.folder-threads {
  list-style: none;
  margin: 2px 0 4px;
  padding: 0 0 0 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 2px solid var(--border);
  margin-left: 12px;
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 260ms ease, opacity 180ms ease, margin 180ms ease;
}
.folder-group.has-active .folder-threads { border-left-color: var(--primary-tint-strong); }
.folder-group.collapsed .folder-threads {
  max-height: 0;
  opacity: 0;
  margin: 0 0 0 12px;
  pointer-events: none;
}

.folder-threads li {
  padding: 8px 10px 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 120ms ease, color 120ms ease;
  border: 1px solid transparent;
}
.folder-threads li:hover { background: var(--surface-sunk); color: var(--text); }
.folder-threads li.active {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--primary-tint-strong);
  font-weight: 500;
}
.folder-threads li.active .when { color: var(--primary); opacity: 0.85; }

/* Empty-state li (kept for the "No threads yet" case) */
#threadList > li.empty {
  padding: 10px 12px;
  color: var(--text-faint);
  text-align: center;
  cursor: default;
}
#threadList li .thread-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
#threadList li .title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

/* Blinking green activity indicator */
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16A34A;
  flex-shrink: 0;
  display: inline-block;
  position: relative;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6);
  animation: activityPulse 1.2s ease-in-out infinite;
}
.activity-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid rgba(22, 163, 74, 0.35);
  opacity: 0;
  animation: activityRing 1.2s ease-in-out infinite;
}
@keyframes activityPulse {
  0%, 100% {
    background: #16A34A;
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5);
  }
  50% {
    background: #22C55E;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.0);
  }
}
@keyframes activityRing {
  0%   { opacity: 0.6; transform: scale(0.8); }
  80%  { opacity: 0; transform: scale(1.6); }
  100% { opacity: 0; transform: scale(1.6); }
}
.folder-activity-dot {
  margin: 0 2px 0 4px;
}
.folder-group.has-active-prompts .folder-header { color: var(--text); }
.folder-group.has-active-prompts .folder-icon { color: #16A34A; }

/* "A prompt just ended" indicator — glowing yellow dot for ~30s after a prompt in the
   thread completes (or red, when it errored out). Sits in the same slot as the green
   activity dot but with a slower, calmer breath so it reads as "look at me but I'm
   not urgent". Auto-clears via the JS recent-end ticker. */
.recent-end-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F59E0B;
  flex-shrink: 0;
  display: inline-block;
  position: relative;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  animation: recentEndPulse 1.6s ease-in-out infinite;
}
.recent-end-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid rgba(245, 158, 11, 0.45);
  opacity: 0;
  animation: recentEndRing 1.6s ease-in-out infinite;
}
.recent-end-dot.is-error {
  background: #DC2626;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
  animation-name: recentEndPulseError;
}
.recent-end-dot.is-error::after {
  border-color: rgba(220, 38, 38, 0.5);
  animation-name: recentEndRingError;
}
@keyframes recentEndPulse {
  0%, 100% { background: #F59E0B; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55); }
  50%      { background: #FBBF24; box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
@keyframes recentEndRing {
  0%   { opacity: 0.6; transform: scale(0.8); }
  80%  { opacity: 0; transform: scale(2.0); }
  100% { opacity: 0; transform: scale(2.0); }
}
@keyframes recentEndPulseError {
  0%, 100% { background: #DC2626; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
  50%      { background: #EF4444; box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
@keyframes recentEndRingError {
  0%   { opacity: 0.6; transform: scale(0.8); }
  80%  { opacity: 0; transform: scale(2.0); }
  100% { opacity: 0; transform: scale(2.0); }
}

/* Reduce motion: stop the animation for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .activity-dot,
  .activity-dot::after,
  .recent-end-dot,
  .recent-end-dot::after { animation: none !important; }
}
#threadList li .title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13.5px;
}
#threadList li .thread-folder {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: var(--text-faint);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: 0.1px;
}
#threadList li.active .thread-folder {
  color: var(--primary);
  opacity: 0.75;
}
#threadList li .when {
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}
#threadList .empty {
  color: var(--text-faint);
  text-align: center;
  padding: 28px 16px;
  font-size: 13px;
  cursor: default;
}
#threadList .empty:hover { background: transparent; color: var(--text-faint); }

/* ========== Main container (holds Chat + Dashboard + Project brain) ========== */
#main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ========== Primary sections ========== */
#chat, #dashboard, #project, #wizardSection {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}
#chat.hidden, #dashboard.hidden, #project.hidden, #wizardSection.hidden { display: none !important; }

#chatHeader {
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  min-height: 64px;
  flex-shrink: 0;
  z-index: 1;
}
.chat-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.thread-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.thread-rename-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms, color 120ms, opacity 120ms;
}
.thread-rename-btn:hover:not(:disabled) {
  background: var(--primary-tint);
  color: var(--primary);
}
.thread-rename-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.thread-rename-btn:disabled {
  opacity: 0;
  pointer-events: none;
}
#chatHeader h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 60ch;
}
.chat-subtitle {
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.2px;
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.project-rename-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 120ms, color 120ms;
}
.project-rename-btn:hover {
  background: var(--primary-tint);
  color: var(--primary);
}

.cwd-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.4;
  cursor: pointer;
  max-width: 48ch;
  transition: background-color 120ms, border-color 120ms, color 120ms;
  align-self: flex-start;
}
.cwd-chip svg { opacity: 0.7; flex-shrink: 0; }
.cwd-chip span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cwd-chip:hover:not(:disabled) {
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
  color: var(--primary);
}
.cwd-chip:hover:not(:disabled) svg { opacity: 1; }
.cwd-chip.is-default {
  color: var(--text-faint);
  border-style: dashed;
}
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ========== Messages ========== */
#messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 28px 12px;
  scroll-behavior: smooth;
}
#messages > .empty {
  color: var(--text-faint);
  text-align: center;
  padding: 64px 24px;
  font-size: 14px;
}

.msg {
  margin: 0 auto 20px;
  max-width: 820px;
}
.msg .role {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 500;
}
.msg .status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  letter-spacing: 0.3px;
}
.msg .status.queued { color: var(--text-dim); }
.msg .status.streaming {
  color: var(--primary);
  border-color: var(--primary-tint-strong);
  background: var(--primary-tint);
}
.msg .status.error {
  color: var(--danger);
  background: var(--danger-tint);
  border-color: rgba(220, 38, 38, 0.2);
}
.msg .status.done { color: var(--success); }

.queue-pos-label {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  color: var(--text-dim);
  letter-spacing: 0.25px;
  background: transparent;
  text-transform: none;
  font-weight: 500;
}
.queue-pos-label.running {
  color: var(--primary);
  border: 1px solid var(--primary-tint-strong);
  background: var(--primary-tint);
  border-style: solid;
}
.queue-pos-label.waiting {
  color: var(--warning);
  border-color: rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.07);
}

.msg.user { text-align: right; }
.msg.user .role { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  word-wrap: break-word;
  display: inline-block;
  text-align: left;
  max-width: min(720px, 92%);
  box-shadow: var(--shadow-sm);
}
.msg.user .user-text {
  white-space: pre-wrap;
}
.msg.user .attachment-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg.user .attachment-grid:last-child { margin-bottom: 0; }

.msg.assistant .bubble {
  background: var(--assistant-bubble);
  color: var(--text);
  padding: 16px 20px;
  border-radius: 16px 16px 16px 4px;
  word-wrap: break-word;
  white-space: normal;
  display: block;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.msg.assistant .bubble p { margin: 0 0 10px; }
.msg.assistant .bubble p:last-child { margin: 0; }
.msg.assistant .bubble h1,
.msg.assistant .bubble h2,
.msg.assistant .bubble h3,
.msg.assistant .bubble h4 {
  margin: 18px 0 8px;
  font-weight: 600;
  color: var(--text);
}
.msg.assistant .bubble h1 { font-size: 20px; }
.msg.assistant .bubble h2 { font-size: 17px; }
.msg.assistant .bubble h3 { font-size: 15px; }
.msg.assistant .bubble h4 { font-size: 14px; }
.msg.assistant .bubble ul,
.msg.assistant .bubble ol { margin: 8px 0 10px; padding-left: 22px; }
.msg.assistant .bubble li { margin: 3px 0; }
.msg.assistant .bubble a { color: var(--primary); text-decoration: none; }
.msg.assistant .bubble a:hover { text-decoration: underline; }
.msg.assistant .bubble blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--primary);
  background: var(--surface-sunk);
  color: var(--text-muted);
  border-radius: 0 6px 6px 0;
}
.msg.assistant .bubble pre {
  background: var(--code-bg);
  color: var(--code-text);
  border: none;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 12px 0;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.55;
}
.msg.assistant .bubble code {
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 1.5px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.msg.assistant .bubble pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}
.msg.assistant .bubble em { color: var(--text-dim); font-style: italic; }
.msg.assistant .bubble hr {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 14px 0;
}
.msg.assistant .bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 13px;
}
.msg.assistant .bubble th,
.msg.assistant .bubble td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.msg.assistant .bubble th { background: var(--surface-sunk); font-weight: 500; }

/* Assistant message status footer — explicit state indicator per message */
.msg.assistant .msg-status-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid var(--border);
  background: var(--surface-sunk);
  color: var(--text-muted);
  max-width: 100%;
  flex-wrap: wrap;
}
.msg.assistant .msg-status-footer .status-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.msg.assistant .msg-status-footer .status-label {
  font-weight: 600;
  letter-spacing: 0.1px;
  white-space: nowrap;
}
.msg.assistant .msg-status-footer .status-desc {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-dim);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Accordion-style preview: when the user prompt is longer than the one-line preview,
   the desc becomes a click/Enter target. Collapsed = single line with caret + ellipsis.
   Expanded = breaks onto its own row inside the wrap container, full text wraps with
   pre-wrap. Caret rotates 90deg on expand so the visual state matches the keyboard
   `aria-expanded` value (no modal — design rule: avoid dialog boxes for inline UI). */
.msg.assistant .msg-status-footer .status-desc.status-desc-collapsible {
  cursor: pointer;
  user-select: none;
}
.msg.assistant .msg-status-footer .status-desc.status-desc-collapsible:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 3px;
}
.msg.assistant .msg-status-footer .status-desc-caret {
  display: inline-block;
  font-size: 10px;
  margin-right: 4px;
  transition: transform 0.15s ease;
  transform-origin: center;
}
.msg.assistant .msg-status-footer .status-desc.is-expanded .status-desc-caret {
  transform: rotate(90deg);
}
.msg.assistant .msg-status-footer .status-desc.is-expanded {
  /* Take the entire row in the footer's flex-wrap container so the long text isn't
     squeezed by sibling chips on the same line. */
  flex: 1 1 100%;
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px 0 2px;
}
.msg.assistant .msg-status-footer .status-desc.is-expanded .status-desc-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant .msg-status-footer .status-extra {
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.04);
  white-space: nowrap;
}

/* Queued — subtle amber */
.msg.assistant .msg-status-footer.state-queued {
  background: #FEF7E7;
  border-color: #F5D27A;
  color: #92510E;
}
.msg.assistant .msg-status-footer.state-queued .status-icon { background: #FBE1A0; color: #92510E; }
.msg.assistant .msg-status-footer.state-queued .status-desc { color: #7C4A11; }
.msg.assistant .msg-status-footer.state-queued .status-extra { background: rgba(146, 81, 14, 0.10); color: #92510E; }

/* Running — primary teal */
.msg.assistant .msg-status-footer.state-streaming {
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
  color: var(--primary);
}
.msg.assistant .msg-status-footer.state-streaming .status-icon {
  background: var(--primary);
  color: #fff;
  padding: 0;
}
.msg.assistant .msg-status-footer.state-streaming .status-desc { color: var(--primary); opacity: 0.85; }
.msg.assistant .msg-status-footer.state-streaming .status-extra {
  background: rgba(13, 115, 119, 0.14);
  color: var(--primary);
}

/* Completed — green */
.msg.assistant .msg-status-footer.state-done {
  background: #E7F8EF;
  border-color: #A7E3C3;
  color: #086A44;
}
.msg.assistant .msg-status-footer.state-done .status-icon {
  background: #0B9E60;
  color: #fff;
  font-weight: 700;
}
.msg.assistant .msg-status-footer.state-done .status-desc { color: #0B6F48; }

/* Failed — red */
.msg.assistant .msg-status-footer.state-error {
  background: #FDECEC;
  border-color: #F4B6B6;
  color: #A31A1A;
}
.msg.assistant .msg-status-footer.state-error .status-icon {
  background: var(--danger);
  color: #fff;
}
.msg.assistant .msg-status-footer.state-error .status-desc { color: #902020; }
.msg.assistant .msg-status-footer.state-error .status-extra {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

/* Interrupted — soft amber. Used when the message ended in `status='error'` because of an
   intentional server restart or a manual queue-clear, not a real failure. We surface this
   distinctly so a deploy doesn't read like a crash. */
.msg.assistant .msg-status-footer.state-interrupted {
  background: #FFF4E0;
  border-color: #F2C77E;
  color: #8A4B07;
}
.msg.assistant .msg-status-footer.state-interrupted .status-icon {
  background: #F39C20;
  color: #fff;
}
.msg.assistant .msg-status-footer.state-interrupted .status-desc { color: #7A4407; }
.msg.assistant .msg-status-footer.state-interrupted .status-extra {
  background: rgba(243, 156, 32, 0.15);
  color: #8A4B07;
}

/* Tiny status pill in the role line — match the same amber for "interrupted". */
.msg .role .status.interrupted {
  background: #FFE3B0;
  color: #7A4407;
  border: 1px solid #F2C77E;
}

/* In-bubble informational note for benign interruptions — replaces the red `error: …` text. */
.bubble-interrupted-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  background: #FFF7E6;
  border: 1px solid #F4D391;
  color: #7A4407;
  font-size: 13px;
  line-height: 1.5;
}
.bubble-interrupted-note .bubble-interrupted-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #F39C20;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* Streaming spinner dot inside the icon circle */
.msg.assistant .msg-status-footer .spinner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: spinPulse 1s ease-in-out infinite;
  display: inline-block;
}
@keyframes spinPulse {
  0%, 100% { transform: scale(0.6); opacity: 0.5; }
  50% { transform: scale(1); opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────
   Per-prompt Stop button — the green glowing button sitting at
   the right edge of every queued/streaming message footer.
   Clicking it cancels just THAT prompt (server aborts the SDK
   iteration, message status flips to 'error' = "stopped by user",
   footer re-renders into soft amber "Interrupted" state).
   The pulsing green glow is intentional — it tells the user the
   prompt is still alive AND that this control will halt it.
   ───────────────────────────────────────────────────────────── */
.msg.assistant .msg-status-footer .msg-stop-btn {
  position: relative;
  appearance: none;
  border: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: #16A34A;          /* same green as the sidebar activity-dot */
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;            /* push to the right edge of the footer */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6);
  animation: stopBtnPulse 1.4s ease-in-out infinite;
  transition: transform 0.12s ease, background 0.12s ease;
}
.msg.assistant .msg-status-footer .msg-stop-btn:hover {
  background: #DC2626;          /* red on hover — telegraphs "stop / dangerous" */
  animation: none;               /* hold still while user is hovering to click */
  transform: scale(1.08);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.18);
}
.msg.assistant .msg-status-footer .msg-stop-btn:focus-visible {
  outline: 2px solid #16A34A;
  outline-offset: 2px;
}
.msg.assistant .msg-status-footer .msg-stop-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
}
.msg.assistant .msg-status-footer .msg-stop-btn.is-stopping {
  background: #b45309;          /* amber while the cancel POST is in flight */
}
.msg.assistant .msg-status-footer .msg-stop-btn .msg-stop-square {
  width: 9px;
  height: 9px;
  background: currentColor;
  display: inline-block;
  border-radius: 1.5px;
  /* Subtle scale so the icon visually responds to hover too */
  transition: transform 0.12s ease;
}
.msg.assistant .msg-status-footer .msg-stop-btn:hover .msg-stop-square {
  transform: scale(1.1);
}
/* Outer pulsing ring — same animation as .activity-dot's ::after but tuned
   for a larger element. The .msg-stop-glow span is purely decorative. */
.msg.assistant .msg-status-footer .msg-stop-btn .msg-stop-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(22, 163, 74, 0.4);
  opacity: 0;
  animation: stopBtnRing 1.4s ease-in-out infinite;
  pointer-events: none;
}
.msg.assistant .msg-status-footer .msg-stop-btn:hover .msg-stop-glow {
  animation: none;
  opacity: 0;
}
@keyframes stopBtnPulse {
  0%, 100% {
    background: #16A34A;
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5);
  }
  50% {
    background: #22C55E;
    box-shadow: 0 0 0 6px rgba(22, 163, 74, 0);
  }
}
@keyframes stopBtnRing {
  0% { transform: scale(0.85); opacity: 0.7; }
  70% { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .msg.assistant .msg-status-footer .msg-stop-btn,
  .msg.assistant .msg-status-footer .msg-stop-btn .msg-stop-glow {
    animation: none !important;
  }
}

/* ========== Composer ========== */
#composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 28px 18px;
  position: relative;
  flex-shrink: 0;
  z-index: 1;
}

#attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 10px;
  max-width: 820px;
  margin: 0 auto;
}
#attachments .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 12.5px;
  max-width: 260px;
  color: var(--text);
  transition: border-color 120ms;
}
#attachments .chip:hover { border-color: var(--primary-tint-strong); }
#attachments .chip.is-image { padding-left: 4px; }
#attachments .chip img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  border: 1px solid var(--border);
}
#attachments .chip .chip-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 140px;
}
#attachments .chip .chip-size {
  color: var(--text-faint);
  font-size: 11px;
}
#attachments .chip .chip-remove {
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  font-size: 15px;
  color: var(--text-faint);
  border-radius: 50%;
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#attachments .chip .chip-remove:hover:not(:disabled) {
  background: var(--danger-tint);
  color: var(--danger);
}

.composer-card {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 0;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms, box-shadow 120ms;
}
.composer-card:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

#prompt {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  max-height: 280px;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 14px 16px 4px;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
}
#prompt::placeholder { color: var(--text-faint); }
#prompt:focus { outline: none; }

.composer-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 8px;
}

.queue-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-tint);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}
.queue-pill:hover:not(:disabled) {
  background: var(--primary-tint-strong);
  color: var(--primary);
  border-color: var(--primary-tint-strong);
}
.queue-pill[aria-expanded="true"] {
  background: var(--primary-tint-strong);
  border-color: var(--primary);
}
.queue-pill b { font-weight: 700; }
.queue-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

/* Queue popover */
.queue-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 28px;
  width: min(420px, calc(100% - 48px));
  max-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popoverIn 140ms ease-out;
}
@keyframes popoverIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.queue-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-alt);
}
.queue-popover-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.queue-popover-clear {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  padding: 4px 10px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.queue-popover-clear:hover:not(:disabled) {
  background: var(--danger-tint);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
}
.queue-popover-close {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.queue-popover-close:hover {
  background: var(--surface-sunk);
  color: var(--text);
}
.queue-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.queue-list .queue-empty {
  padding: 24px 16px;
  color: var(--text-faint);
  text-align: center;
  font-size: 13px;
}
.queue-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 120ms, border-color 120ms;
}
.queue-item:hover {
  background: var(--surface-sunk);
  border-color: var(--border);
}
.queue-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.queue-item-pos {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.4px;
}
.queue-item-status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-sunk);
  color: var(--text-dim);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.queue-item-status.streaming {
  color: var(--primary);
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
}
.queue-item-preview {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.queue-item-preview.muted { color: var(--text-faint); font-style: italic; }
.queue-item-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

/* Flash highlight when jumping to a message from the queue popover */
.msg.flash .bubble {
  animation: flashBubble 1.2s ease-out;
}
@keyframes flashBubble {
  0%   { box-shadow: 0 0 0 3px var(--primary-tint-strong); }
  100% { box-shadow: var(--shadow-sm); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

.hidden { display: none !important; }

/* ========== Buttons ========== */
.btn, button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}
.btn svg, button svg { flex-shrink: 0; }
button:disabled, .btn:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.btn-primary, #newThreadBtn, #sendBtn {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled),
#newThreadBtn:hover:not(:disabled),
#sendBtn:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-primary:active:not(:disabled),
#newThreadBtn:active:not(:disabled),
#sendBtn:active:not(:disabled) {
  background: var(--primary-pressed);
  border-color: var(--primary-pressed);
}
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.btn-ghost, #deleteBtn, #attachBtn {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled),
#deleteBtn:hover:not(:disabled),
#attachBtn:hover:not(:disabled) {
  background: var(--surface-sunk);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-danger:hover:not(:disabled),
#deleteBtn:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-tint);
  border-color: rgba(220, 38, 38, 0.3);
}

#attachBtn { margin-right: auto; }

/* Focus ring for accessibility (himslite requires this) */
button:focus-visible, .btn:focus-visible,
#threadList li:focus-visible,
#prompt:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.composer-card:focus-within button:focus-visible {
  outline-offset: 2px;
}

/* ========== Drop overlay ========== */
#dropOverlay {
  position: absolute;
  inset: 8px;
  background: rgba(13, 115, 119, 0.06);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  color: var(--primary);
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  backdrop-filter: blur(1px);
}

/* ========== Attachment cards (in messages) ========== */
.attachment-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  min-width: 150px;
  max-width: 240px;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms, transform 120ms;
}
.attachment-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.attachment-card.is-image {
  padding: 0;
  min-width: 0;
  border-color: rgba(255, 255, 255, 0.2);
}
.attachment-card.is-image img {
  display: block;
  max-width: 240px;
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: cover;
}
.attachment-card .attachment-icon {
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 16px;
  text-align: center;
  letter-spacing: 1px;
}
.attachment-card .attachment-name {
  padding: 8px 12px 0;
  font-size: 12.5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attachment-card .attachment-meta {
  padding: 0 12px 8px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ========== Scrollbars (subtle, himslite-style) ========== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; border: 2px solid transparent; }

/* ========== Folder "Ideas" sidebar link ========== */
.folder-ideas-link {
  padding: 6px 10px 6px 12px !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-size: 12.5px !important;
  color: var(--text-faint) !important;
  cursor: pointer;
  border-radius: var(--radius);
  font-style: italic;
  transition: background-color 120ms, color 120ms;
}
.folder-ideas-link:hover {
  background: var(--surface-sunk);
  color: #D97706 !important;
}
/* "Brain" variant — uses a 💡 emoji icon */
.folder-brain-emoji {
  font-size: 13px;
  line-height: 1;
  display: inline-block;
  width: 14px;
  text-align: center;
}
.folder-brain-link {
  font-style: normal !important;
  color: var(--text-muted) !important;
  font-weight: 500;
}
.folder-brain-link:hover {
  color: var(--primary) !important;
}
.folder-brain-link .folder-ideas-count.has-pending {
  /* Show the ideas-pending count pill in a calmer style than the old amber one. */
  background: rgba(217, 119, 6, 0.12);
  color: #D97706;
}
.folder-ideas-link .folder-ideas-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.folder-ideas-count {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-sunk);
  color: var(--text-faint);
  font-style: normal;
  letter-spacing: 0.2px;
}
.folder-ideas-count.has-pending {
  background: rgba(217, 119, 6, 0.12);
  color: #D97706;
}

/* ========== Ideas board ========== */
#ideasHeader {
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  min-height: 64px;
  flex-shrink: 0;
  z-index: 1;
}
#ideasHeader h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}
.ideas-board {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 24px 28px 32px;
  align-items: start;
}
.ideas-loading, .ideas-error {
  grid-column: 1 / -1;
  padding: 48px;
  text-align: center;
  color: var(--text-faint);
}
.ideas-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px 14px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.ideas-col.phase-current { border-top: 3px solid var(--primary); }
.ideas-col.phase-next    { border-top: 3px solid #0EA5E9; }
.ideas-col.phase-futuristic { border-top: 3px solid #A855F7; }

.ideas-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--divider);
}
.ideas-col-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.2px;
}
.ideas-col-count {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-sunk);
  color: var(--text-faint);
}
.ideas-col-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ideas-col-empty {
  padding: 20px 8px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
}

.idea-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 120ms, background-color 120ms;
}
.idea-card:hover { border-color: var(--border-strong); }
.idea-card.priority-critical { border-left: 4px solid var(--danger); }
.idea-card.priority-normal { border-left: 4px solid var(--primary); }
.idea-card.priority-nice_to_have { border-left: 4px solid var(--border-strong); }

.idea-card.status-done {
  opacity: 0.65;
  background: var(--surface);
}
.idea-card.status-done .idea-text {
  text-decoration: line-through;
  color: var(--text-dim);
}
.idea-card.status-queued {
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
}

.idea-head {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.priority-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.priority-chip.chip-critical {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}
.priority-chip.chip-normal {
  background: var(--primary-tint);
  color: var(--primary);
  border: 1px solid var(--primary-tint-strong);
}
.priority-chip.chip-nice_to_have {
  background: var(--surface-sunk);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.idea-status-chip {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.2px;
  border: 1px solid var(--border);
  background: var(--surface-sunk);
  color: var(--text-dim);
}
.idea-status-chip.status-chip-queued {
  background: rgba(217, 119, 6, 0.12);
  color: #D97706;
  border-color: rgba(217, 119, 6, 0.25);
}
.idea-status-chip.status-chip-done {
  background: #E7F8EF;
  color: #086A44;
  border-color: #A7E3C3;
}
.idea-status-chip.status-chip-error {
  background: var(--danger-tint);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.25);
}

.idea-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.idea-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.idea-actions .btn-sm {
  font-size: 11.5px;
  padding: 4px 9px;
}
.idea-thread-link {
  font-size: 11.5px;
  color: var(--primary);
  text-decoration: none;
  margin-top: 2px;
}
.idea-thread-link:hover { text-decoration: underline; }

/* ========== Modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(2px);
  animation: fadeIn 160ms ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 180ms ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-alt);
}
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
}
.modal-close:hover { background: var(--surface-sunk); color: var(--text); }

.modal-body {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.field-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field textarea, .field input, .field select {
  font: inherit;
  font-size: 13.5px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
}
.field select { background: var(--surface); cursor: pointer; }
.field textarea:focus, .field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
  align-items: center;
}

/* Compact variant used by confirmDialog() */
.modal.modal-sm { max-width: 420px; }
.confirm-body {
  padding: 18px 20px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.confirm-body .confirm-message {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.5;
}
.confirm-body .confirm-detail {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}
.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px 18px;
}
.btn-danger-solid {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger-solid:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}
.btn-danger-solid:active:not(:disabled) {
  background: #991b1b;
  border-color: #991b1b;
}

/* ========== All-Projects sidebar button ========== */
.sidebar-dashboard-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 4px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
.sidebar-dashboard-btn:hover {
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
  color: var(--primary);
}

/* ========== Root dashboard ========== */
#dashboardHeader, #projectHeader {
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  min-height: 64px;
  flex-shrink: 0;
}
#dashboardHeader h2, #projectHeader h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}
.projects-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 24px 28px 32px;
  align-content: start;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms, transform 120ms, box-shadow 120ms;
}
.project-card:hover {
  border-color: var(--primary-tint-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.project-card.has-activity {
  border-left: 3px solid #16A34A;
  padding-left: 16px;
}
.project-card-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.project-card-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.project-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.project-card-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--primary-tint);
  color: var(--primary);
  border: 1px solid var(--primary-tint-strong);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-decoration: none;
  white-space: nowrap;
}
.project-card-live:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.project-card-folder {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-faint);
}
.project-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.stat {
  text-align: center;
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.stat-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}
.stat.stat-active { background: rgba(22, 163, 74, 0.08); border-color: rgba(22, 163, 74, 0.25); }
.stat.stat-active .stat-value { color: #0B9E60; }
.project-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* ========== Project brain tabs ========== */
.brain-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 28px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.brain-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
}
.brain-tab:hover { color: var(--text); background: var(--surface-sunk); }
.brain-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.brain-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
}
.brain-tab-panel {
  padding: 20px 28px 32px;
}
.brain-tab-panel.hidden { display: none; }

/* ========== Project wizard view ========== */
/* Layout properties (flex, height, hidden) come from the shared `#chat, #dashboard,
   #project, #wizardSection` rule above so the wizard occupies the centre column. */
#wizardHeader {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.wizard-title-wrap h2 { margin: 0; font-size: 18px; }
.wizard-subtitle { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.wizard-progress {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 6px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.wizard-step-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-faint);
  border-bottom: 2px solid transparent;
  cursor: default;
  white-space: nowrap;
}
.wizard-step-pill .wizard-step-num {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-sunk);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 700;
}
.wizard-step-pill.is-done {
  color: #086A44;
}
.wizard-step-pill.is-done .wizard-step-num {
  background: #0B9E60;
  color: #fff;
}
.wizard-step-pill.is-current {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.wizard-step-pill.is-current .wizard-step-num {
  background: var(--primary);
  color: #fff;
}
.wizard-chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 28px 100px;
}
.wizard-turn {
  margin-bottom: 18px;
  max-width: 820px;
}
.wizard-turn.assistant .wizard-turn-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px;
  padding: 12px 14px;
}
.wizard-turn.user .wizard-turn-bubble {
  background: var(--primary-tint);
  border: 1px solid var(--primary-tint-strong);
  color: var(--primary);
  border-radius: 12px 12px 2px 12px;
  padding: 10px 14px;
  margin-left: auto;
  max-width: 720px;
}
.wizard-turn-bubble pre, .wizard-turn-bubble code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
  background: var(--surface-sunk);
  padding: 1px 4px;
  border-radius: 3px;
}
.wizard-turn-bubble pre {
  padding: 8px 10px;
  overflow-x: auto;
  border: 1px solid var(--border);
}
.wizard-turn-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.wizard-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-top: 6px;
  max-width: 820px;
}
.wizard-editor h4 { margin: 0 0 10px; font-size: 13px; }
.wizard-editor textarea, .wizard-editor input[type=text], .wizard-editor input[type=number] {
  width: 100%;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
}
.wizard-editor textarea { min-height: 100px; resize: vertical; font-family: ui-monospace, SFMono-Regular, monospace; }
.wizard-editor .field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.wizard-editor .field-row label { min-width: 110px; color: var(--text-muted); font-size: 12px; }
.wizard-editor .field-row input { flex: 1 1 auto; }
.wizard-list-item {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  margin-bottom: 6px;
  align-items: start;
}
.wizard-list-item.with-priority { grid-template-columns: 1fr 2fr 110px auto; }
.wizard-list-item textarea { min-height: 36px; }
.wizard-add-row {
  display: flex; justify-content: flex-start; margin-top: 6px;
}
.wizard-list-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.wizard-phase-block {
  margin-bottom: 14px;
  padding: 10px;
  background: var(--surface-sunk);
  border-radius: 8px;
}
.wizard-phase-block h5 {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* Plan & Execute step: an ordered list of editable prompt cards */
.wizard-plan-row {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.wizard-plan-row-head {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.wizard-plan-row-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.wizard-plan-title {
  flex: 1 1 auto;
  font-weight: 600;
}
.wizard-plan-body {
  width: 100%;
  min-height: 100px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  resize: vertical;
}
.wizard-plan-execute {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--primary-tint);
  border: 1px solid var(--primary-tint-strong);
  border-radius: 8px;
  font-size: 13px;
  color: var(--primary);
}
.wizard-plan-execute label { cursor: pointer; }
.wizard-plan-ran {
  margin-top: 10px;
  padding: 10px 12px;
  background: #FFF7E6;
  border: 1px dashed #F2C77E;
  border-radius: 8px;
  font-size: 12.5px;
  color: #7A4407;
}
.wizard-plan-ran a { color: var(--primary); font-weight: 600; }

/* Per-row accept checkbox + visual de-emphasis when a row is excluded. */
.wizard-plan-accept {
  margin: 0;
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.wizard-plan-row.is-excluded {
  opacity: 0.45;
  background: var(--surface-sunk);
}
.wizard-plan-row.is-excluded .wizard-plan-row-num {
  background: var(--text-faint);
}
.wizard-plan-row.is-excluded .wizard-plan-title,
.wizard-plan-row.is-excluded .wizard-plan-body {
  text-decoration: line-through;
  color: var(--text-faint);
}

/* ========== Auto-build progress strip (chat view) ========== */
.build-progress {
  flex-shrink: 0;
  margin: 0;
  padding: 12px 28px 14px;
  background: linear-gradient(180deg, rgba(13, 115, 119, 0.06), rgba(13, 115, 119, 0.02));
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.build-progress.hidden { display: none; }
.build-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.build-progress-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.2px;
}
.build-progress-icon { font-size: 15px; }
.build-progress-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
#buildProgressResumeBtn { margin-left: 4px; }
#buildProgressResumeBtn.hidden { display: none; }
.build-progress-sep { color: var(--text-faint); }
.build-progress-bar {
  height: 6px;
  background: var(--surface-sunk);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.build-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #14a59a);
  transition: width 240ms ease-out;
  border-radius: 4px;
}
.build-progress.is-running .build-progress-fill {
  /* Soft pulsing band while a step is active so the user can see it's alive even when
     the percentage hasn't moved (Claude turns can take a while). */
  background-image: linear-gradient(90deg, var(--primary), #14a59a, var(--primary));
  background-size: 200% 100%;
  animation: buildPulse 2.4s linear infinite;
}
@keyframes buildPulse {
  from { background-position: 0% 0; }
  to   { background-position: -200% 0; }
}
.build-progress-now {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
  min-height: 22px;
  padding: 6px 10px;
  border-radius: 6px;
  /* Subtle background so the "now" line reads as the active strip even when nothing
     is animating. While running we layer a soft glow on top via the .is-running
     parent class. */
  background: rgba(13, 115, 119, 0.06);
  border: 1px solid rgba(13, 115, 119, 0.16);
  transition: box-shadow 240ms ease-out, border-color 240ms;
}
.build-progress.is-running .build-progress-now {
  border-color: rgba(13, 115, 119, 0.45);
  /* Soft pulsing glow that breathes — gives a clear "live" feel without being noisy. */
  animation: buildNowGlow 2.4s ease-in-out infinite;
}
@keyframes buildNowGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(13, 115, 119, 0.18), 0 0 14px 0 rgba(13, 115, 119, 0.12); }
  50%      { box-shadow: 0 0 0 4px rgba(13, 115, 119, 0.10), 0 0 22px 4px rgba(13, 115, 119, 0.20); }
}
.build-progress-now-label {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  font-size: 13.5px;
  letter-spacing: 0.1px;
}
.build-progress-now-detail {
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.build-progress.is-running .build-progress-now-detail {
  color: var(--primary);
}

/* Heartbeat row: a small dot that pulses on every token arrival + a "Last activity"
   counter so the user can confirm the run isn't stuck even when no prose is streaming. */
.build-progress-heartbeat {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--text-faint);
}
.build-progress-heartbeat.is-stale { color: #8A4B07; }
.build-progress-heartbeat.is-very-stale { color: var(--danger); }
.build-progress-heartbeat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd1dc;
  flex-shrink: 0;
}
.build-progress-heartbeat-dot.is-active {
  background: #0B9E60;
  box-shadow: 0 0 0 0 rgba(11, 158, 96, 0.6);
  animation: heartbeatPulse 1.2s ease-out;
}
.build-progress-heartbeat.is-stale .build-progress-heartbeat-dot { background: #F39C20; }
.build-progress-heartbeat.is-very-stale .build-progress-heartbeat-dot { background: var(--danger); }
@keyframes heartbeatPulse {
  0%   { box-shadow: 0 0 0 0 rgba(11, 158, 96, 0.6); }
  100% { box-shadow: 0 0 0 10px rgba(11, 158, 96, 0); }
}
.build-progress-steps {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.build-step-pip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: default;
}
.build-step-pip.is-done {
  background: #E7F8EF;
  border-color: #A7E3C3;
  color: #086A44;
}
/* Active step: vivid filled pill with a pulsing glow so the user can spot
   "what's running right now" at a glance, distinct from done/error pips. */
.build-step-pip.is-running {
  background: linear-gradient(135deg, #F59E0B 0%, #F97316 100%);
  border-color: #F59E0B;
  color: #FFFFFF;
  font-weight: 700;
  animation: buildPipGlow 1.6s ease-in-out infinite;
  position: relative;
  z-index: 1;
}
@keyframes buildPipGlow {
  0%   { box-shadow: 0 0 0 0   rgba(245, 158, 11, 0.55), 0 0 6px  rgba(249, 115, 22, 0.45); }
  60%  { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.00), 0 0 14px rgba(249, 115, 22, 0.65); }
  100% { box-shadow: 0 0 0 0   rgba(245, 158, 11, 0.00), 0 0 6px  rgba(249, 115, 22, 0.45); }
}
@media (prefers-reduced-motion: reduce) {
  .build-step-pip.is-running { animation: none; }
}
.build-step-pip.is-error {
  background: #FDECEC;
  border-color: #F4B6B6;
  color: #A31A1A;
}
.build-step-pip-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 700;
}
.build-step-pip.is-done .build-step-pip-num { background: #0B9E60; color: #fff; }
.build-step-pip.is-running .build-step-pip-num { background: #FFFFFF; color: #B45309; }
.build-step-pip.is-error .build-step-pip-num { background: var(--danger); color: #fff; }
.build-step-pip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────────────────────────────────
   Live activity panel — opens when the user clicks the glowing (running)
   step pip. Shows a scrolling list of "tool → file" entries fed live by
   `message.tool` SSE events as Claude touches each file.
   ────────────────────────────────────────────────────────────────────────── */
.live-activity-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: liveActivityFadeIn 120ms ease-out;
}
@keyframes liveActivityFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.live-activity-panel {
  width: min(680px, 92vw);
  max-height: 72vh;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
}
.live-activity-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #E2E8F0);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.10) 0%, rgba(249, 115, 22, 0.06) 100%);
}
.live-activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #F59E0B;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);
  animation: liveActivityDotPulse 1.5s ease-in-out infinite;
}
@keyframes liveActivityDotPulse {
  0%   { box-shadow: 0 0 0 0   rgba(245, 158, 11, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);    }
  100% { box-shadow: 0 0 0 0   rgba(245, 158, 11, 0);    }
}
.live-activity-panel.is-finished .live-activity-dot {
  background: var(--text-muted, #64748B);
  animation: none;
}
.live-activity-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: var(--text, #0F172A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-activity-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted, #64748B);
  cursor: pointer;
  padding: 0 6px;
  border-radius: 6px;
}
.live-activity-close:hover { color: var(--text, #0F172A); background: rgba(0,0,0,0.04); }
.live-activity-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.live-activity-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  scroll-behavior: smooth;
}
.live-activity-list:focus-visible { outline: none; }

.live-activity-row {
  display: grid;
  grid-template-columns: 22px 70px 14px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.18);
  color: var(--text, #0F172A);
}
.live-activity-row:last-child { border-bottom: 0; }
.live-activity-row.is-fresh {
  animation: liveActivitySlideIn 600ms ease-out;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.18) 0%, rgba(245, 158, 11, 0) 100%);
}
@keyframes liveActivitySlideIn {
  0%   { transform: translateX(8px); opacity: 0; }
  100% { transform: translateX(0);    opacity: 1; }
}
.live-activity-icon {
  text-align: center;
  color: #B45309;
}
.live-activity-tool {
  font-weight: 700;
  color: #B45309;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-activity-arrow { color: var(--text-muted, #64748B); }
.live-activity-detail {
  color: var(--text, #0F172A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-activity-time {
  color: var(--text-muted, #64748B);
  font-size: 11px;
  white-space: nowrap;
}
.live-activity-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted, #64748B);
  font-style: italic;
  font-size: 12.5px;
}
.live-activity-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--border, #E2E8F0);
  font-size: 11.5px;
  color: var(--text-muted, #64748B);
  background: rgba(248, 250, 252, 0.6);
}
@media (prefers-reduced-motion: reduce) {
  .live-activity-row.is-fresh { animation: none; }
  .live-activity-dot { animation: none; }
  .live-activity-overlay { animation: none; }
}

/* Summary line under the plan list */
.wizard-plan-summary {
  margin: 8px 0 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}
.wizard-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.wizard-start-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.wizard-start-flash {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
}
.wizard-start-flash.is-error { background: #FDECEC; color: #A31A1A; border: 1px solid #F4B6B6; }
.folder-panel-head-actions { display: inline-flex; gap: 6px; }

/* Wizard start modal: resume + mode tabs */
.wizard-resume-block {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--primary-tint-strong);
  background: var(--primary-tint);
  border-radius: 10px;
}
.wizard-resume-head {
  font-weight: 700;
  color: var(--primary);
  font-size: 12.5px;
  margin-bottom: 8px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.wizard-resume-list { display: flex; flex-direction: column; gap: 6px; }
.wizard-resume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.wizard-resume-row .wizard-resume-info { flex: 1 1 auto; min-width: 0; }
.wizard-resume-row .wizard-resume-name { font-weight: 600; color: var(--text); }
.wizard-resume-row .wizard-resume-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.wizard-resume-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
  color: var(--text-faint);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.wizard-resume-divider::before, .wizard-resume-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.wizard-mode-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.wizard-mode-tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.wizard-mode-tab:hover { color: var(--text); }
.wizard-mode-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.wizard-mode-pane.hidden { display: none; }
#wizardExistingPick { width: 100%; }

/* Delete-project confirmation */
.delete-project-warning {
  font-size: 13px;
  color: #A31A1A;
  background: #FDECEC;
  border: 1px solid #F4B6B6;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.delete-project-checklist {
  margin: 0 0 12px 18px;
  padding: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.delete-project-checklist li { margin: 3px 0; }
.btn-danger.btn-primary {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
}
.btn-danger.btn-primary:hover:not(:disabled) {
  background: #b51919 !important;
  border-color: #b51919 !important;
}

/* "+ New" modal — folder picker + action chooser */
.new-modal-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.new-modal-action-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 4px;
  margin: 12px 0;
  background: var(--surface-sunk);
}
.new-modal-action-block legend {
  padding: 0 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.new-modal-action-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 100ms;
}
.new-modal-action-row:hover { background: var(--surface); }
.new-modal-action-row input[type="radio"] { margin-top: 4px; }
.new-modal-action-title { font-size: 13px; font-weight: 600; color: var(--text); }
.new-modal-action-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; line-height: 1.4; }
#newModalFolder { width: 100%; }
#newModalNewFolder, #newModalThreadTitle { width: 100%; }

/* Subdomain + deploy block (shown only when "+ Create new folder") */
.new-modal-deploy-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 12px 0;
  background: var(--surface-sunk);
}
.new-modal-deploy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}
.new-modal-deploy-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.new-modal-deploy-block .field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.new-modal-deploy-block .field-row label {
  flex: 0 0 100px;
  color: var(--text-muted);
  font-size: 12px;
}
.new-modal-deploy-block .field-row input {
  flex: 1 1 auto;
}
.new-modal-suffix {
  color: var(--text-faint);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
}
.new-modal-subdomain-status {
  font-size: 11.5px;
  margin: 0 0 8px 108px;
  min-height: 14px;
  color: var(--text-faint);
}
.new-modal-subdomain-status.is-ok { color: #086A44; }
.new-modal-subdomain-status.is-bad { color: var(--danger); }
.new-modal-subdomain-status.is-warn { color: #8A4B07; }

/* ========== Build tab — live generation progress card ========== */
.buildplan-progress-card {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid rgba(13, 115, 119, 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(13, 115, 119, 0.10), rgba(13, 115, 119, 0.04));
  position: relative;
  overflow: hidden;
}
.buildplan-progress-card.is-active {
  /* Soft pulsing glow that breathes — visible "I'm alive" cue. */
  animation: buildPlanCardGlow 2.4s ease-in-out infinite;
}
@keyframes buildPlanCardGlow {
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(13, 115, 119, 0.18),
      0 0 14px 0 rgba(13, 115, 119, 0.12);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(13, 115, 119, 0.10),
      0 0 28px 6px rgba(13, 115, 119, 0.22);
  }
}
.buildplan-progress-card.is-stale {
  border-color: #F2C77E;
  background: linear-gradient(180deg, rgba(243, 156, 32, 0.10), rgba(243, 156, 32, 0.04));
  animation: none;
  box-shadow: 0 0 0 2px rgba(243, 156, 32, 0.18);
}
.buildplan-progress-card.is-very-stale {
  border-color: var(--danger);
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.10), rgba(220, 38, 38, 0.04));
  animation: none;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}
.buildplan-progress-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.buildplan-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(13, 115, 119, 0.6);
  flex-shrink: 0;
}
.buildplan-progress-dot.is-active {
  animation: buildPlanDotPulse 1.2s ease-out;
}
@keyframes buildPlanDotPulse {
  0%   { box-shadow: 0 0 0 0 rgba(13, 115, 119, 0.6); transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { box-shadow: 0 0 0 14px rgba(13, 115, 119, 0); transform: scale(1); }
}
.buildplan-progress-card.is-stale .buildplan-progress-dot { background: #F39C20; }
.buildplan-progress-card.is-very-stale .buildplan-progress-dot { background: var(--danger); }
.buildplan-progress-title {
  flex: 1 1 auto;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
}
.buildplan-progress-card.is-stale .buildplan-progress-title { color: #8A4B07; }
.buildplan-progress-card.is-very-stale .buildplan-progress-title { color: var(--danger); }
.buildplan-progress-elapsed {
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.buildplan-progress-current {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 6px 0 10px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  word-wrap: break-word;
}
.buildplan-progress-bar {
  height: 6px;
  background: var(--surface-sunk);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.buildplan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #14a59a);
  background-size: 200% 100%;
  animation: buildPlanFillShimmer 2.4s linear infinite;
  border-radius: 4px;
  transition: width 240ms ease-out;
}
@keyframes buildPlanFillShimmer {
  from { background-position: 0% 0; }
  to   { background-position: -200% 0; }
}
.buildplan-progress-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

/* ========== Build tab (project-level AI roadmap, auto-runnable) ========== */
.build-tab-actions { display: inline-flex; gap: 6px; align-items: center; }
.build-tab-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
/* Each build-plan row reuses the wizard plan styling for visual consistency. The
   milestone-group header is a dedicated divider rendered above the first row of
   each milestone bucket. */
.build-tab-milestone-head {
  margin: 14px 0 4px;
  padding: 6px 10px;
  border-left: 3px solid var(--primary);
  background: var(--surface-sunk);
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.2px;
}
.build-tab-running-banner {
  margin: 8px 0 14px;
  padding: 10px 12px;
  border: 1px solid #F2C77E;
  background: #FFF7E6;
  border-radius: 8px;
  font-size: 13px;
  color: #7A4407;
  display: flex;
  align-items: center;
  gap: 10px;
}
.build-tab-running-banner.hidden { display: none; }
.build-tab-running-banner a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.build-tab-running-banner a:hover { text-decoration: underline; }

/* ========== Impersonation banner (admin "Login as" indicator) ========== */
.impersonation-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #FFF4E0, #FFE7BD);
  border-bottom: 1px solid #F39C20;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  font-size: 13px;
  color: #7A4407;
}
.impersonation-banner.hidden { display: none; }
.impersonation-banner .impersonation-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.impersonation-banner .impersonation-text { flex: 1 1 auto; }
.impersonation-banner .impersonation-text b { color: #5A2E04; }
.impersonation-banner .impersonation-sub { color: #8A4B07; opacity: 0.85; margin-left: 6px; }
/* When the banner is visible, push the page content down so it doesn't sit underneath. */
body.has-impersonation-banner { padding-top: 40px; }

/* ========== Help modal + onboarding overlay ========== */
.help-modal { width: min(96vw, 1100px); max-height: 86vh; }
.help-modal-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(86vh - 60px);
  overflow: hidden;
}
.help-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface-sunk);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#helpSearch {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
}
#helpSearch:focus {
  outline: none;
  border-color: var(--primary-tint-strong);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10);
}
.help-article-list { display: flex; flex-direction: column; gap: 2px; }
.help-article-list-group-head {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  margin: 10px 6px 4px;
}
.help-article-item {
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.help-article-item:hover { background: var(--surface); }
.help-article-item.is-active {
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: 600;
}
.help-article-item .help-article-snippet {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
  font-weight: 400;
}
.help-article-item.is-active .help-article-snippet { color: var(--primary); opacity: 0.85; }
.help-article-list-empty {
  font-size: 12.5px;
  color: var(--text-faint);
  font-style: italic;
  padding: 20px 6px;
  text-align: center;
}

.help-content {
  padding: 22px 28px 32px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}
.help-content h1, .help-content h2, .help-content h3 { margin: 18px 0 8px; }
.help-content h1 { font-size: 22px; }
.help-content h2 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.help-content h3 { font-size: 15px; }
.help-content p { margin: 8px 0; }
.help-content ul, .help-content ol { margin: 8px 0 8px 22px; }
.help-content li { margin: 3px 0; }
.help-content code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
  background: var(--surface-sunk);
  padding: 1px 5px;
  border-radius: 3px;
}
.help-content pre {
  background: var(--surface-sunk);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12.5px;
  border: 1px solid var(--border);
}
.help-content kbd {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  background: var(--surface);
}

/* Onboarding overlay (first-login walkthrough) */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(15, 17, 23, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.onboarding-overlay.hidden { display: none; }
.onboarding-card {
  width: min(94vw, 720px);
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.30);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.onboarding-header {
  padding: 22px 28px 12px;
  position: relative;
}
.onboarding-header .modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}
.onboarding-eyebrow {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.onboarding-header h2 { margin: 0; font-size: 22px; color: var(--text); }
.onboarding-body {
  padding: 6px 28px 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  min-height: 240px;
}
.onboarding-body h3 { margin: 12px 0 6px; font-size: 16px; }
.onboarding-body p { margin: 8px 0; }
.onboarding-body ul { margin: 8px 0 8px 20px; }
.onboarding-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px 22px;
  background: var(--surface-sunk);
  border-top: 1px solid var(--border);
}
.onboarding-progress {
  display: inline-flex;
  gap: 6px;
}
.onboarding-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.onboarding-progress-dot.is-active { background: var(--primary); }
.onboarding-progress-dot.is-done { background: var(--primary); opacity: 0.5; }

@media (max-width: 720px) {
  .help-modal-body { grid-template-columns: 1fr; height: auto; max-height: 80vh; }
  .help-sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 30vh; }
}

/* ========== Brain mode switch (Normal / Advanced) ========== */
.brain-mode-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  background: var(--surface-sunk);
  margin-right: 6px;
}
.brain-mode-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.brain-mode-btn:hover { color: var(--text); }
.brain-mode-btn.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* MODE: NORMAL — hide power-user controls (upload / raw markdown / future advanced
   surfaces). The tab-doc-panel is the main hide target today; opt-in via
   `.brain-advanced-only` for any future advanced control. */
#project[data-brain-mode="normal"] .tab-doc-panel,
#project[data-brain-mode="normal"] .brain-advanced-only {
  display: none !important;
}

/* MODE: READ — view-only. Hides the same power-user surfaces as normal mode AND
   suppresses every primary-action button on every tab so the brain renders as a
   clean, presentational view (no Add / Edit / Delete / Generate / Save).
   Implementation note: we hide rather than disable so the layout collapses and the
   read-only pages don't look broken. */
#project[data-brain-mode="read"] .tab-doc-panel,
#project[data-brain-mode="read"] .brain-advanced-only,
#project[data-brain-mode="read"] .brain-panel-head .btn-primary,
#project[data-brain-mode="read"] .brain-panel-head .btn-ghost,
#project[data-brain-mode="read"] .brain-card-actions,
#project[data-brain-mode="read"] .wireframe-actions,
#project[data-brain-mode="read"] .build-tab-actions,
#project[data-brain-mode="read"] .build-tab-running-banner,
#project[data-brain-mode="read"] .srs-actions,
#project[data-brain-mode="read"] #ideasAddBtn,
#project[data-brain-mode="read"] .idea-card-actions,
#project[data-brain-mode="read"] .vision-edit-btn,
#project[data-brain-mode="read"] .deploy-panel button,
#project[data-brain-mode="read"] .goal-card-actions,
#project[data-brain-mode="read"] .milestone-actions,
#project[data-brain-mode="read"] [data-add-note] {
  display: none !important;
}
/* Read mode also locks form-style inputs so accidental edits don't accumulate. */
#project[data-brain-mode="read"] input:not([type=button]):not([type=submit]),
#project[data-brain-mode="read"] textarea,
#project[data-brain-mode="read"] select {
  pointer-events: none;
  background: var(--surface-sunk) !important;
  color: var(--text) !important;
  cursor: default;
}
/* A subtle pill in the brain-tabs row so the user always knows the brain is
   read-only — otherwise the missing edit affordances can be confusing. */
#project[data-brain-mode="read"] .brain-tabs::after {
  content: '👁  Read-only — switch to Normal to edit';
  display: inline-block;
  margin-left: auto;
  align-self: center;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
}

/* ========== Per-tab attached document panel (top of every tab) ========== */
.tab-doc-panel {
  /* Sits at the very top of the tab so the Upload button is the first thing the user
     sees. When `.is-filled` is on (a doc is attached), the body grows to dominate the
     viewport — existing structured content stays below, accessible by scroll. */
  margin: 0 0 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.tab-doc-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface-sunk);
  border-bottom: 1px solid transparent;
  flex-wrap: wrap;
}
.tab-doc-panel.is-open .tab-doc-toolbar { border-bottom-color: var(--border); }
.tab-doc-status {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-left: 4px;
}
.tab-doc-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 38%;
}
.tab-doc-body {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
}
/* When a doc is attached we let the body expand to take the bulk of the brain area —
   ~60% of the visible tab height — so the document is the focus. The user can resize
   the textarea further if they want; the preview sits below. */
.tab-doc-panel.is-filled .tab-doc-body {
  min-height: calc(70vh - 200px);
}
.tab-doc-textarea {
  width: 100%;
  min-height: 240px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  resize: vertical;
}
.tab-doc-panel.is-filled .tab-doc-textarea {
  /* Expand the textarea by default when a doc is loaded — saves the user from having
     to drag the resize grip every time. */
  min-height: 50vh;
}
.tab-doc-textarea:focus {
  outline: none;
  border-color: var(--primary-tint-strong);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10);
}
.tab-doc-preview-head {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tab-doc-preview {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  min-height: 60px;
}
.tab-doc-preview:empty::before {
  content: 'Preview appears here as you type.';
  color: var(--text-faint);
  font-style: italic;
}
.tab-doc-preview h1, .tab-doc-preview h2, .tab-doc-preview h3, .tab-doc-preview h4 {
  margin: 10px 0 6px;
}
.tab-doc-preview h1 { font-size: 17px; }
.tab-doc-preview h2 { font-size: 15px; }
.tab-doc-preview h3 { font-size: 14px; }
.tab-doc-preview pre {
  background: var(--surface);
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 12.5px;
}
.tab-doc-preview code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
}

/* ========== SRS tab (one canonical markdown spec per project) ========== */
.srs-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.srs-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin: 4px 0 8px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.srs-meta .srs-meta-pill {
  display: inline-flex;
  gap: 4px;
}
.srs-body {
  width: 100%;
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  resize: vertical;
}
.srs-body:focus {
  outline: none;
  border-color: var(--primary-tint-strong);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10);
}
.srs-preview-head {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.srs-preview {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  min-height: 80px;
}
.srs-preview:empty::before {
  content: 'Preview appears here as you type.';
  color: var(--text-faint);
  font-style: italic;
}
.srs-preview h1, .srs-preview h2, .srs-preview h3, .srs-preview h4 {
  margin: 12px 0 6px;
}
.srs-preview h1 { font-size: 18px; }
.srs-preview h2 { font-size: 16px; }
.srs-preview h3 { font-size: 14px; }
.srs-preview pre {
  background: var(--surface);
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 12.5px;
}
.srs-preview code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
}

/* ========== Brain-note editor modal (Roles, Tech, Workflow, Wireframes) ========== */
.note-editor-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface-sunk);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  line-height: 1.5;
}
#noteEditorTitleInput,
#noteEditorImageUrl,
#noteEditorBody,
#noteEditorCategory,
#noteEditorVersion {
  width: 100%;
  font: inherit;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
}
#noteEditorBody {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 240px;
}
#noteEditorTitleInput:focus,
#noteEditorImageUrl:focus,
#noteEditorBody:focus,
#noteEditorCategory:focus,
#noteEditorVersion:focus {
  outline: none;
  border-color: var(--primary-tint-strong);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10);
}
.note-editor-tech-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}
.note-editor-image-preview {
  margin: 0 0 12px;
  padding: 6px;
  background: var(--surface-sunk);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.note-editor-image-preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 4px;
}
.note-editor-preview {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  max-height: 220px;
  overflow-y: auto;
}
.note-editor-preview:empty { display: none; }
.note-editor-preview h1,
.note-editor-preview h2,
.note-editor-preview h3 { margin: 6px 0 4px; font-size: 14px; }
.note-editor-preview pre {
  background: var(--surface);
  padding: 8px 10px;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 12.5px;
  border: 1px solid var(--border);
}
.note-editor-preview code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
}
.note-editor-flash {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  background: #FDECEC;
  color: #A31A1A;
  border: 1px solid #F4B6B6;
}
.note-editor-flash.hidden { display: none; }
.note-editor-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.note-editor-upload-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* Wireframe + workflow card body: render markdown nicely so the card UX matches the
   editor's preview. */
.brain-card-desc, .wireframe-desc {
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* ========== Brain mini-composer ========== */
/* A compact, always-visible prompt input at the bottom of the brain page. The active brain tab
   determines which thread the prompt routes to ("Brain · {Tab}" inside the project's cwd). */
.brain-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 28px 12px;
  z-index: 1;
}
.brain-composer.hidden { display: none; }
.brain-composer-card {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px 10px;
  transition: border-color 120ms, box-shadow 120ms;
}
.brain-composer-card:focus-within {
  border-color: var(--primary-tint-strong);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10);
}
.brain-composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 6px;
  font-size: 12px;
  color: var(--text-faint);
}
.brain-composer-target {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.brain-composer-target-label { color: var(--text-faint); }
.brain-composer-tab-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.2px;
  border: 1px solid var(--primary-tint-strong);
}
.brain-composer-status {
  font-size: 11.5px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.brain-composer-status .open-thread-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.brain-composer-status .open-thread-link:hover { text-decoration: underline; }
.brain-composer-status.is-success { color: #086A44; }
.brain-composer-status.is-error { color: var(--danger); }
.brain-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.brain-composer-input {
  flex: 1 1 auto;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 6px 8px;
  min-height: 32px;
  max-height: 140px;
  overflow-y: auto;
}
.brain-composer-input::placeholder { color: var(--text-faint); }

/* Attachment chips — mirror the main composer's chip look but compact. */
.brain-composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 8px;
}
.brain-composer-attachments.hidden { display: none; }
.brain-composer-attachments .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 4px 3px 10px;
  font-size: 11.5px;
  max-width: 220px;
  color: var(--text);
}
.brain-composer-attachments .chip.is-image { padding-left: 3px; }
.brain-composer-attachments .chip img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}
.brain-composer-attachments .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}
.brain-composer-attachments .chip-size {
  color: var(--text-faint);
  font-size: 10.5px;
}
.brain-composer-attachments .chip-remove {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.brain-composer-attachments .chip-remove:hover { color: var(--danger); }

/* Drop highlight for the composer card */
.brain-composer-card.is-drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.18);
}

@media (max-width: 720px) {
  .brain-composer { padding: 8px 14px 10px; }
}
.brain-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.brain-panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.vision-view, .vision-edit {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.deploy-panel {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.deploy-panel.hidden { display: none; }
.deploy-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}
.deploy-panel-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.deploy-panel-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.deploy-info-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.deploy-info-btn:hover,
.deploy-info-btn[aria-expanded="true"] {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--primary-tint-strong);
}

.deploy-info-panel {
  margin: 0 0 14px;
  padding: 14px 16px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.deploy-info-panel.hidden { display: none; }
.deploy-info-panel h5 {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.deploy-info-panel h5:first-child { margin-top: 0; }
.deploy-info-panel p { margin: 0 0 8px; }
.deploy-info-panel ol,
.deploy-info-panel ul {
  margin: 6px 0 10px;
  padding-left: 22px;
}
.deploy-info-panel li { margin: 3px 0; }
.deploy-info-panel code {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text);
}
.deploy-info-panel pre {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0 10px;
}
.deploy-info-panel .deploy-info-footnote {
  margin-top: 14px;
  padding: 8px 10px;
  background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: 6px;
  font-size: 11.5px;
  color: #92510E;
}
.deploy-status {
  font-size: 12px;
  color: var(--text-faint);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.deploy-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.deploy-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.deploy-inline input {
  flex: 1;
}
.deploy-suffix {
  color: var(--text-faint);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.deploy-log {
  margin: 14px 0 0;
  max-height: 360px;
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
.deploy-log.hidden { display: none; }

.vision-live-url {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  background: var(--primary-tint);
  border: 1px solid var(--primary-tint-strong);
  border-radius: 8px;
  font-size: 13px;
}
.vision-live-url a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.vision-live-url a:hover { text-decoration: underline; }
.vision-live-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.4px;
}
.vision-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
.vision-empty {
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  padding: 20px;
}
.vision-edit {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.vision-edit.hidden, .vision-view.hidden { display: none; }

.brain-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brain-empty {
  color: var(--text-faint);
  text-align: center;
  padding: 40px 16px;
  font-style: italic;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.brain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.brain-card.priority-critical { border-left: 4px solid var(--danger); }
.brain-card.priority-normal { border-left: 4px solid var(--primary); }
.brain-card.priority-nice_to_have { border-left: 4px solid var(--border-strong); }
.brain-card.milestone { border-left: 4px solid #0EA5E9; }
.brain-card.status-achieved, .brain-card.status-hit {
  opacity: 0.7;
  background: var(--surface-alt);
}
.brain-card.status-achieved .brain-card-title,
.brain-card.status-hit .brain-card-title {
  text-decoration: line-through;
  color: var(--text-dim);
}
.brain-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.brain-card-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  flex: 1;
}
.brain-card-chips {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.milestone-date {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.1);
  color: #0369A1;
  border: 1px solid rgba(14, 165, 233, 0.25);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.brain-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
}
.brain-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* ========== Brain tabs (overflow scroll for many tabs) ========== */
.brain-tabs { overflow-x: auto; flex-wrap: nowrap; }
.brain-tabs::-webkit-scrollbar { height: 4px; }
.brain-tab { white-space: nowrap; flex-shrink: 0; }

/* ========== Wireframes grid ========== */
.brain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.wireframe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms, transform 120ms;
}
.wireframe-card:hover { border-color: var(--primary-tint-strong); transform: translateY(-1px); }
.wireframe-image-wrap {
  display: block;
  background: var(--surface-sunk);
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
  height: 160px;
  overflow: hidden;
  position: relative;
}
.wireframe-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.wireframe-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
}
.wireframe-head {
  padding: 10px 12px 4px;
}
.wireframe-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.wireframe-desc {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wireframe-actions {
  display: flex;
  gap: 6px;
  padding: 6px 12px 10px;
}

/* ========== Staging tab ========== */
.staging-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.staging-hint code {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
}
.staging-card { border-left: 4px solid #0EA5E9; }
.staging-fqdn {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary);
  border: 1px solid var(--primary-tint-strong);
  text-decoration: none;
}
.staging-fqdn:hover { background: var(--primary); color: #fff; }

/* ========== Files tab ========== */
.brain-tab-files { padding: 0 !important; }
.files-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  min-height: 0;
}
.files-tree-pane {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.files-tree-head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}
.files-tree-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 600;
}
.files-tree-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.files-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-faint);
  cursor: pointer;
}
.files-toggle input { transform: translateY(1px); accent-color: var(--primary); }

.files-tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 4px 0 12px;
  font-size: 12.5px;
}
.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 0;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 4px;
  margin: 0 4px;
  color: var(--text);
}
.tree-row:hover { background: var(--surface-sunk); }
.tree-row.active { background: var(--primary-tint); color: var(--primary); }
.tree-chevron {
  display: inline-block;
  width: 14px;
  text-align: center;
  font-size: 9px;
  color: var(--text-faint);
  transition: transform 120ms;
}
.tree-chevron.open { transform: rotate(90deg); }
.tree-icon { font-size: 12px; }
.tree-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-size {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-left: 8px;
}
.tree-loading, .tree-empty {
  padding: 4px 12px 4px 28px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

.files-editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.files-editor-head {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  flex-shrink: 0;
}
.files-editor-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.files-editor-path {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60ch;
}
.files-editor-dirty {
  color: var(--warning);
  font-size: 14px;
}
.files-editor-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.files-editor-meta {
  font-size: 11px;
  color: var(--text-faint);
}

.files-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
}
.files-editor-empty {
  margin: auto;
  padding: 32px;
  color: var(--text-faint);
  text-align: center;
  max-width: 520px;
  font-size: 13px;
}
.files-editor-empty kbd {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.files-editor-textarea {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
  padding: 14px 16px;
  outline: none;
  tab-size: 2;
  -moz-tab-size: 2;
  white-space: pre;
  overflow: auto;
}

/* Goal/Milestone status chip variants */
.idea-status-chip.status-chip-goal-active {
  background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint-strong);
}
.idea-status-chip.status-chip-goal-paused {
  background: rgba(217, 119, 6, 0.1); color: #B45309; border-color: rgba(217, 119, 6, 0.25);
}
.idea-status-chip.status-chip-goal-achieved {
  background: #E7F8EF; color: #086A44; border-color: #A7E3C3;
}
.idea-status-chip.status-chip-mst-upcoming {
  background: var(--surface-sunk); color: var(--text-muted); border-color: var(--border);
}
.idea-status-chip.status-chip-mst-in_progress {
  background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint-strong);
}
.idea-status-chip.status-chip-mst-hit {
  background: #E7F8EF; color: #086A44; border-color: #A7E3C3;
}
.idea-status-chip.status-chip-mst-missed {
  background: var(--danger-tint); color: var(--danger); border-color: rgba(220, 38, 38, 0.25);
}

/* ========== Admin pending-row editable controls ========== */
.admin-row-pending {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.admin-pending-edit {
  width: 100%;
  font: inherit;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 80px;
}
.admin-pending-edit:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.admin-pending-comment {
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.admin-pending-comment:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.admin-pending-actions {
  justify-content: flex-end;
}

/* ========== Originator badge on the message role line ========== */
.originator-badge {
  font-size: 10.5px;
  letter-spacing: 0.2px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500;
  text-transform: none;
}
.originator-badge.originator-self {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--primary-tint-strong);
}
.originator-badge.originator-other {
  background: rgba(168, 85, 247, 0.12);
  color: #7E22CE;
  border-color: rgba(168, 85, 247, 0.28);
}

/* User-prompt bubbles authored by a different developer get a distinct purple bubble
   so it's instantly clear which interactions came from whom in a shared project. */
.msg-other-dev.user .bubble {
  background: linear-gradient(135deg, #7E22CE 0%, #9333EA 100%);
}
.msg-other-dev.user .bubble .diff-word-added {
  background: rgba(255, 255, 255, 0.92);
  color: #581C87;
}

/* Assistant replies that were prompted by another developer get a soft purple left-stripe
   on the bubble — keeps the markdown readable but tags the ownership. */
.msg-other-dev.assistant .bubble {
  border-left: 3px solid #9333EA;
  padding-left: 17px;
}

/* ========== Team summary cards ========== */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #7E22CE;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.team-card.team-auto-approve { border-left-color: #16A34A; }
.team-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  grid-template-areas: "name id" "sub sub" "chips chips";
  gap: 4px 12px;
  margin-bottom: 10px;
}
.team-card-name { grid-area: name; font-size: 15px; font-weight: 600; color: var(--text); }
.team-card-userid {
  grid-area: id;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-faint);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
  align-self: start;
}
.team-card-sub { grid-area: sub; font-size: 12px; color: var(--text-faint); }
.team-card-chips { grid-area: chips; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.team-card-threads {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.team-thread-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}
.team-thread-chip:hover {
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
  color: var(--primary);
}
.team-thread-chip.team-thread-active { border-color: rgba(22, 163, 74, 0.45); }
.team-thread-title {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-thread-count {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--surface-sunk);
  border-radius: 999px;
  padding: 1px 7px;
}

/* ========== Activity feed ========== */
.activity-card { cursor: pointer; }
.activity-card:hover { border-color: var(--primary-tint-strong); }
.activity-card.activity-user { border-left: 3px solid var(--primary); }
.activity-card.activity-assistant { border-left: 3px solid #0EA5E9; }
.activity-role {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 999px;
}
.activity-role-user { background: var(--primary-tint); color: var(--primary); }
.activity-role-assistant { background: rgba(14, 165, 233, 0.12); color: #0369A1; }
.activity-thread {
  color: var(--text-muted);
  font-size: 12.5px;
}
.activity-content {
  white-space: pre-wrap;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface-alt);
  padding: 8px 10px;
  border-radius: 6px;
  margin-top: 6px;
  max-height: 150px;
  overflow: auto;
}

/* ========== Always-visible admin edit teach-view inside the user bubble ========== */
/* Bubble is teal with white text — diff colors must pop on that background. */
.user-text.inline-diff {
  white-space: pre-wrap;
  line-height: 1.6;
}
.diff-word-context { color: #fff; }
.diff-word-added {
  background: rgba(255, 255, 255, 0.92);
  color: #084E51;
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 600;
}
.diff-word-removed {
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  padding: 1px 3px;
  border-radius: 3px;
  opacity: 0.85;
}
.admin-edit-inline-note {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #084E51;
  border: 1px solid rgba(255, 255, 255, 0.7);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}
.admin-edit-inline-caption {
  margin-top: 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
}

.admin-edit-comment {
  background: var(--primary-tint);
  border: 1px solid var(--primary-tint-strong);
  color: var(--primary);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.5;
}
.admin-edit-comment.hidden { display: none; }
.admin-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.admin-edit-col-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 6px;
}
.admin-edit-pre {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 320px;
  overflow: auto;
}
.admin-edit-pre.approved {
  border: 1px solid #0B9E60;
  box-shadow: 0 0 0 1px rgba(11, 158, 96, 0.15);
}

/* ========== App toast (floating bottom-center) ========== */
#appToastHost {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.app-toast {
  pointer-events: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  max-width: 600px;
}
.app-toast-in { opacity: 1; transform: translateY(0); }
.app-toast-out { opacity: 0; transform: translateY(-8px); }
.app-toast-info { background: var(--surface); }
.app-toast-celebrate {
  background: linear-gradient(135deg, var(--primary) 0%, #14B8A6 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(13, 115, 119, 0.35);
}

/* ========== Admin hint paragraph ========== */
.admin-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}

/* ========== Admin (invitations + users) modal ========== */
.admin-body {
  gap: 18px;
  display: flex;
  flex-direction: column;
}
.admin-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface);
}
.admin-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.admin-section-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text);
}
.admin-count {
  font-size: 11.5px;
  color: var(--text-faint);
}
.admin-invite-form {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 8px;
  align-items: center;
}
.admin-invite-form input,
.admin-invite-form select {
  font: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  height: 38px;
}
.admin-invite-form input:focus,
.admin-invite-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.admin-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  font-size: 12.5px;
}

/* ========== Admin → Assignments panel ========== */
.admin-assign-projects { gap: 10px; }
.assign-project-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.assign-project-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.assign-project-label { flex: 1 1 auto; font-size: 13px; color: var(--text); }
.assign-cwd-mono {
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--text-faint);
  font-size: 11.5px;
  margin-left: 8px;
}
.assign-tabs-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface-sunk);
  border-radius: 8px;
  font-size: 12px;
  transition: opacity 120ms;
}
.assign-tabs-box.is-disabled { opacity: 0.45; pointer-events: none; }
.assign-tab-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.assign-tab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px 10px;
}
.assign-tab-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
}
.assign-tab-chip input:disabled + span { color: var(--text-faint); }
.assign-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.assign-status {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 80px;
  text-align: right;
}
.admin-assign-threads-details {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface-sunk);
  border-radius: 8px;
}
.admin-assign-threads-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  padding: 4px 0;
}
.admin-assign-threads-details .admin-hint-inline {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 12px;
  margin-left: 6px;
}
.admin-assign-threads { gap: 4px; margin-top: 6px; }
.assign-thread-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
}
.assign-thread-label { flex: 1 1 auto; }
.assign-thread-folder {
  color: var(--text-faint);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  margin-left: 8px;
}
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.admin-row-disabled { opacity: 0.55; }
.admin-row-main {
  flex: 1;
  min-width: 0;
}
.admin-row-title {
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-row-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}
.admin-role-chip {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.admin-role-chip.role-admin { background: var(--primary-tint); color: var(--primary); border: 1px solid var(--primary-tint-strong); }
.admin-role-chip.role-developer { background: var(--surface-sunk); color: var(--text-muted); border: 1px solid var(--border); }
.admin-role-chip.role-disabled { background: var(--danger-tint); color: var(--danger); border: 1px solid rgba(220,38,38,.25); }
.admin-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.admin-role-select {
  font: inherit;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

/* ========== Inbox (quick idea capture) modal ========== */
.inbox-subtitle {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 13px;
  margin-left: 4px;
}
.inbox-hint {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.inbox-hint code {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--primary);
}
.inbox-projects {
  color: var(--text-faint);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}
#inboxInput {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 90px;
  tab-size: 2;
}
#inboxInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.inbox-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 12px 0 4px;
}
.inbox-fallback-wrap.hidden { display: none; }
.inbox-flash {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin: 8px 0 0;
}
.inbox-flash.hidden { display: none; }
.inbox-flash.ok {
  background: #E7F8EF;
  border: 1px solid #A7E3C3;
  color: #086A44;
}
.inbox-flash.err {
  background: var(--danger-tint);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--danger);
}
.inbox-recent-wrap {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}
.inbox-recent-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 8px;
}
.inbox-recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.inbox-recent li {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.inbox-recent .project-tag {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary);
  border: 1px solid var(--primary-tint-strong);
  flex-shrink: 0;
}
.inbox-recent .preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ========== Global memory modal ========== */
.modal-lg { max-width: 760px; width: 100%; }
.global-memory-hint {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.global-memory-hint code {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}
#globalMemoryInput {
  font: inherit;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 260px;
  width: 100%;
  tab-size: 2;
  -moz-tab-size: 2;
}
#globalMemoryInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.global-memory-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin: -2px 0 2px;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ========== Message-footer extra button (View changes) ========== */
.msg-footer-btn {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  margin-left: auto;
  cursor: pointer;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.msg-footer-btn:hover {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--primary-tint-strong);
}

/* ========== Diff modal ========== */
.modal-xl { max-width: 1200px; width: 100%; max-height: 92vh; }
.diff-modal-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.diff-file-list {
  border-right: 1px solid var(--border);
  background: var(--surface-alt);
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.diff-loading {
  padding: 16px;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
}
.diff-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
}
.diff-file-item:hover { background: var(--surface-sunk); }
.diff-file-item.active {
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
  color: var(--primary);
}
.diff-file-path {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.diff-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.diff-kind-new { background: #E7F8EF; color: #0B9E60; }
.diff-kind-deleted { background: var(--danger-tint); color: var(--danger); }
.diff-kind-modified { background: var(--primary-tint); color: var(--primary); }

.diff-panes {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}
.diff-empty {
  padding: 32px;
  color: var(--text-faint);
  text-align: center;
  font-size: 13px;
}
.diff-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  min-height: 100%;
}
.diff-col {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.diff-col-title {
  padding: 8px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
.diff-col-body {
  padding: 0;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
}
.diff-line {
  display: flex;
  padding: 0;
  border-left: 3px solid transparent;
}
.diff-line-add {
  background: rgba(11, 158, 96, 0.10);
  border-left-color: #0B9E60;
}
.diff-line-rem {
  background: rgba(220, 38, 38, 0.08);
  border-left-color: var(--danger);
}
.diff-line-pad {
  background: var(--surface-sunk);
  opacity: 0.4;
}
.diff-line-ctx { border-left-color: transparent; }
.diff-num {
  display: inline-block;
  width: 44px;
  padding: 0 8px;
  text-align: right;
  color: var(--text-faint);
  user-select: none;
  flex-shrink: 0;
}
.diff-text {
  flex: 1;
  padding: 0 8px;
  white-space: pre;
  overflow-x: auto;
}

/* ========== Right-side folder panel ========== */
#folderPanel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}
.folder-panel-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}
.folder-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.1px;
}
.folder-panel-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.folder-panel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background-color 120ms, border-color 120ms;
  cursor: pointer;
}
.folder-panel-item:hover {
  background: var(--surface-sunk);
  border-color: var(--border);
}
.folder-panel-item.active {
  background: var(--primary-tint);
  border-color: var(--primary-tint-strong);
}
.folder-panel-item.unclaimed .folder-panel-item-name {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}
.folder-panel-item.unclaimed .folder-panel-item-icon { opacity: 0.6; }
.folder-panel-item-icon {
  color: var(--text-faint);
  flex-shrink: 0;
  display: inline-flex;
}
.folder-panel-item.has-activity .folder-panel-item-icon { color: #16A34A; }
.folder-panel-item-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.folder-panel-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-panel-item-sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-panel-item-count {
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 600;
  background: var(--surface-sunk);
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.folder-panel-item.active .folder-panel-item-count {
  background: var(--primary-tint-strong);
  color: var(--primary);
}
.folder-panel-actions {
  display: inline-flex;
  gap: 2px;
  flex-shrink: 0;
}
.folder-panel-actions a,
.folder-panel-actions button {
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  transition: background-color 120ms, color 120ms;
  text-decoration: none;
}
.folder-panel-actions a:hover,
.folder-panel-actions button:hover {
  background: var(--primary-tint);
  color: var(--primary);
}
.folder-panel-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  font-style: italic;
}
/* Group heading shown above the "Frequent" / "Others" buckets. Subtle so it doesn't
   crowd the panel — just enough to separate the two groups visually. */
.folder-panel-group-head {
  padding: 10px 14px 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.folder-panel-group-head:first-child { padding-top: 4px; }

/* ========== Responsive ========== */
/* Mobile / hamburger button — hidden on wide screens. The wide layout already shows
   the sidebar permanently, so the hamburger would only add noise. Below 980px the
   sidebar is hidden off-canvas and the button is the only way back. */
.mobile-nav-btn {
  display: none;
  flex-shrink: 0;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  margin-right: 6px;
}
.mobile-nav-btn:hover { background: var(--surface-sunk); }
.mobile-nav-btn:active { transform: translateY(1px); }

/* Backdrop for the slide-in sidebar — taps on it close the drawer. Only used on
   narrow screens where the sidebar is off-canvas. */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.45);
  z-index: 9;
}
body.sidebar-open .sidebar-backdrop { display: block; }

@media (max-width: 1200px) {
  :root { --folder-panel-w: 220px; }
}
@media (max-width: 980px) {
  /* Tablet: hide the right folder panel and hide the sidebar off-canvas. Hamburger
     button (in #chatHeader / #projectHeader) brings the sidebar back. The folder
     panel's content is duplicated inside the sidebar drawer for project navigation —
     see #folderPanel placement below. */
  body { grid-template-columns: 1fr; }
  #folderPanel {
    /* Hidden as a wide-layout column, but reused inside the sidebar drawer below. */
    display: none;
  }
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 82%;
    max-width: 320px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 200ms;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
  }
  body.sidebar-open #sidebar { transform: translateX(0); }
  .mobile-nav-btn { display: inline-flex; }

  /* When the sidebar is open on mobile, also reveal the right-folder-panel content
     INSIDE the sidebar so users have one place to navigate from. We append a clone
     of #folderPanel after the thread list in JS — see initMobileFolderPanel(). */
  body.sidebar-open #sidebar .mobile-folders-section {
    display: block;
    border-top: 1px solid var(--border);
    margin-top: 12px;
    padding-top: 8px;
  }
  body.sidebar-open #sidebar .mobile-folders-section .folder-panel-list {
    display: flex; flex-direction: column; gap: 2px;
  }
  body.sidebar-open #sidebar .mobile-folders-section-head {
    padding: 8px 12px 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-faint);
  }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
  #messages, #composer { padding-left: 16px; padding-right: 16px; }
  #chatHeader { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 640px) {
  /* Tighten paddings + stack more aggressively. The sidebar slide-in inherits from
     the 980px rule above. */
  #chatHeader, #projectHeader { padding-left: 12px; padding-right: 12px; }
  .header-actions .btn span:not(.mobile-nav-btn span) { display: none; } /* icon-only buttons */
}

/* ============================================================
   Right-panel folder accordion + IDE-style slide-in editor.
   - Each project row in #folderPanel gains a chevron toggle.
   - Expanded rows lazy-load /api/files/list and render an
     inline tree (recursive, also with chevrons).
   - Clicking a file opens #ideEditor (slide in from right).
   ============================================================ */

/* Wrap each row + its accordion children in a single column. */
.fpa-wrap { display: flex; flex-direction: column; }

/* Chevron button placed at the start of each .folder-panel-item. */
.fpa-chev {
  width: 18px;
  height: 18px;
  margin-right: 2px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 120ms, background-color 120ms, transform 150ms;
}
.fpa-chev:hover { background: var(--surface-sunk); color: var(--text); }
.fpa-chev:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.fpa-chev.open { transform: rotate(90deg); color: var(--primary); }

/* The expanded children container. */
.fpa-children {
  margin: 2px 0 6px 14px;
  padding-left: 6px;
  border-left: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 12.5px;
  max-height: 360px;
  overflow-y: auto;
}
.fpa-loading, .fpa-empty, .fpa-error {
  padding: 4px 6px;
  color: var(--text-faint);
  font-style: italic;
  font-size: 12px;
}
.fpa-error { color: var(--danger, #c62828); font-style: normal; }

.fpa-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 2px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  min-width: 0;
}
.fpa-row:hover { background: var(--surface-sunk); color: var(--text); }
.fpa-row.active { background: var(--primary-tint); color: var(--primary); }
.fpa-row.is-file:hover { background: var(--primary-tint); color: var(--primary); }
.fpa-row .fpa-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fpa-row .fpa-size {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.fpa-row .fpa-icon {
  width: 14px;
  display: inline-flex;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
}
.fpa-row .fpa-spacer { width: 14px; flex-shrink: 0; }
.fpa-subchev {
  width: 14px;
  height: 14px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  transition: transform 150ms;
}
.fpa-subchev.open { transform: rotate(90deg); color: var(--primary); }

/* ============================================================
   IDE-style slide-in editor (#ideEditor).
   ============================================================ */
.ide-editor {
  position: fixed;
  top: 0;
  right: 0;
  width: min(880px, 80vw);
  height: 100vh;
  background: var(--surface, #fff);
  border-left: 1px solid var(--border, #e2e6ed);
  box-shadow: -8px 0 24px rgba(15, 32, 68, 0.10), -2px 0 6px rgba(15, 32, 68, 0.05);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ide-editor:not(.hidden) {
  transform: translateX(0);
}
.ide-editor.hidden { pointer-events: none; }

.ide-editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunk, #f6f9fd);
  flex-shrink: 0;
  min-height: 50px;
}
.ide-editor-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 13.5px;
  color: var(--text-muted);
}
.ide-editor-project { color: var(--text-faint); font-weight: 500; }
.ide-editor-sep { color: var(--text-faint); }
.ide-editor-path {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ide-editor-dirty { color: var(--primary); font-size: 14px; line-height: 1; }
.ide-editor-meta {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.ide-editor-actions { display: inline-flex; gap: 6px; flex-shrink: 0; }

.ide-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.ide-editor-empty {
  margin: auto;
  padding: 40px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}
.ide-editor-textarea {
  flex: 1 1 auto;
  width: 100%;
  border: none;
  resize: none;
  padding: 14px 18px;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
  background: var(--surface);
  color: var(--text);
  outline: none;
  tab-size: 2;
  -moz-tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.ide-editor-textarea:focus { background: var(--surface); }

.ide-editor-foot {
  border-top: 1px solid var(--border);
  background: var(--surface-sunk);
  padding: 6px 14px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-faint);
}
.ide-editor-hint kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10.5px;
  color: var(--text-muted);
  margin: 0 2px;
}

@media (max-width: 720px) {
  .ide-editor { width: 100vw; }
}

/* ============================================================
   My Team page (sidebar → My Team)
   ============================================================ */
#myTeamView, #myAgentsView {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg, var(--surface, #f6f9fd));
  overflow: hidden;
}
#myAgentsView.hidden, #myTeamView.hidden { display: none; }
#myAgentsHeader {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface, #fff);
  flex-shrink: 0;
}
.myagents-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 22px 60px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.myagents-body section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 18px; }
.myagents-body section h3 { margin: 0; padding: 12px 16px; font-size: 14px; font-weight: 700; border-bottom: 1px solid var(--border); }
.myagents-create-grid {
  display: grid;
  grid-template-columns: 2fr 1.5fr;
  gap: 10px 14px;
  padding: 14px 16px;
}
.myagents-create-grid .field { display: block; }
.myagents-create-grid .field-label { display: block; font-size: 11.5px; color: var(--text-muted); margin-bottom: 4px; }
.myagents-create-grid input, .myagents-create-grid select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.myagents-create-grid input:focus, .myagents-create-grid select:focus {
  outline: none; border-color: var(--primary-tint-strong);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10);
}
.myagents-create-teams, .myagents-create-desc { grid-column: 1 / -1; }
.myagents-create-actions {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 4px;
}
.myagents-list-head { display: flex; align-items: center; gap: 12px; padding-right: 16px; border-bottom: 1px solid var(--border); }
.myagents-list-head h3 { border-bottom: none !important; flex: 1 1 auto; }
.myagents-count { color: var(--text-faint); font-size: 12px; }
.myagents-list { display: flex; flex-direction: column; gap: 0; padding: 0; }
.myagents-empty { padding: 28px 16px; text-align: center; color: var(--text-faint); font-style: italic; font-size: 13px; }
.myagents-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.myagents-card:last-child { border-bottom: none; }
.myagents-card-name { font-weight: 600; font-size: 14px; color: var(--text); }
.myagents-card-name code { font-size: 11px; color: var(--text-faint); margin-left: 6px; font-family: ui-monospace, monospace; }
.myagents-card-sub { font-size: 12px; color: var(--text-muted); grid-column: 1 / -1; }
.myagents-card-sub .chip { display: inline-block; background: var(--primary-tint); color: var(--primary); padding: 2px 8px; border-radius: 999px; font-size: 11px; margin-right: 4px; }
.myagents-card-actions { display: inline-flex; gap: 6px; }
.myagents-status-pill {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-sunk); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.myagents-status-pill.is-pending { background: #FFF4E0; border-color: #F2C77E; color: #8A4B07; }
.myagents-status-pill.is-approved { background: #E7F8EF; border-color: #A7E3C3; color: #086A44; }
.myagents-status-pill.is-rejected { background: #FDECEC; border-color: #F4B6B6; color: #A31A1A; }

.myagents-editor { display: flex; flex-direction: column; }
.myagents-editor.hidden { display: none; }
.myagents-editor-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.myagents-editor-head h3 { border-bottom: none !important; padding: 0 !important; }
.myagents-tabs { display: flex; gap: 0; padding: 0 16px; border-bottom: 1px solid var(--border); }
.myagents-tab {
  padding: 10px 14px; border: none; background: transparent; color: var(--text-muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; border-radius: 0;
}
.myagents-tab:hover { color: var(--text); }
.myagents-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.myagents-file-body {
  margin: 12px 16px;
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px; line-height: 1.55;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; color: var(--text); resize: vertical;
}
.myagents-file-body:focus { outline: none; border-color: var(--primary-tint-strong); box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10); }
.myagents-editor-footer { display: flex; align-items: center; gap: 10px; padding: 10px 16px 14px; }
.myagents-flash { font-size: 12px; color: var(--text-faint); min-height: 18px; }
.myagents-flash.is-error { color: var(--danger); }
.myagents-flash.is-ok { color: #086A44; }

/* ========== Task Groups (multi-party chat) ========== */
.taskgroups-list { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 0; }
.taskgroup-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
  transition: background 100ms, border-color 100ms;
}
.taskgroup-card:hover { background: var(--surface-sunk); border-color: var(--primary-tint-strong); }
.taskgroup-card.is-active { border-color: var(--primary); background: var(--primary-tint); }
.taskgroup-card-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.taskgroup-card-sub { grid-column: 1 / -1; font-size: 11.5px; color: var(--text-muted); }
.taskgroup-card-sub .chip {
  display: inline-block; background: var(--surface-sunk); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px; font-size: 11px; margin-right: 4px;
}
.taskgroup-card-sub .chip.is-agent { background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint-strong); }
.taskgroup-card-actions { display: inline-flex; gap: 4px; }

/* ── Chat panel ── */
.taskgroup-chat { padding: 0 !important; overflow: hidden; }
.taskgroup-chat.hidden { display: none; }
.taskgroup-chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-sunk);
}
.taskgroup-chat-head h3 { margin: 0; font-size: 14.5px; }
.taskgroup-chat-sub { display: block; font-size: 11.5px; color: var(--text-faint); }
.taskgroup-chat-titlewrap { flex: 1 1 auto; }
.taskgroup-chat-actions { display: inline-flex; gap: 6px; }

.taskgroup-manage { padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.taskgroup-manage.hidden { display: none; }
.taskgroup-manage-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.taskgroup-manage-label { font-weight: 600; font-size: 12px; color: var(--text-muted); min-width: 70px; }
.taskgroup-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; }
.taskgroup-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 10px; background: var(--surface-sunk); border: 1px solid var(--border);
  border-radius: 999px; font-size: 11.5px;
}
.taskgroup-chip.is-agent { background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint-strong); }
.taskgroup-chip-x {
  border: none; background: transparent; cursor: pointer; color: var(--text-faint);
  width: 16px; height: 16px; border-radius: 50%; padding: 0; line-height: 1; font-size: 14px;
}
.taskgroup-chip-x:hover { color: var(--danger); }
.taskgroup-add-select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: 12px; max-width: 220px;
}

.taskgroup-messages {
  height: 380px; overflow-y: auto;
  padding: 12px 14px; background: var(--surface);
  display: flex; flex-direction: column; gap: 8px;
}
.taskgroup-msg { display: flex; gap: 8px; align-items: flex-start; }
.taskgroup-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-sunk); color: var(--text-muted);
  font-size: 11px; font-weight: 700; border: 1px solid var(--border);
}
.taskgroup-msg.is-agent .taskgroup-msg-avatar {
  background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint-strong);
}
.taskgroup-msg-bubble {
  background: var(--surface-sunk); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; max-width: 85%;
}
.taskgroup-msg.is-agent .taskgroup-msg-bubble {
  background: var(--primary-tint); border-color: var(--primary-tint-strong);
}
.taskgroup-msg-meta { font-size: 11px; color: var(--text-faint); margin-bottom: 2px; }
.taskgroup-msg-meta b { color: var(--text); font-weight: 600; }
.taskgroup-msg-content { font-size: 13.5px; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-wrap: break-word; }
.taskgroup-msg.is-self .taskgroup-msg-bubble { background: #E7F8EF; border-color: #A7E3C3; }

.taskgroup-composer {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border); background: var(--surface-sunk);
}
.taskgroup-composer textarea {
  flex: 1 1 auto; resize: none;
  font: inherit; font-size: 13.5px; line-height: 1.4;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.taskgroup-composer textarea:focus {
  outline: none; border-color: var(--primary-tint-strong);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.10);
}
@media (max-width: 760px) {
  .myagents-create-grid { grid-template-columns: 1fr; }
  .myagents-card { grid-template-columns: 1fr; }
}
#myTeamHeader {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface, #fff);
  flex-shrink: 0;
}
.my-team-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.my-team-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(15,32,68,.04);
}
.my-team-section-title {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--text, var(--heading));
  display: flex;
  align-items: center;
  gap: 8px;
}
.my-team-counts {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted, var(--muted));
}
.info-i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary-tint, #e8f1fb); color: var(--primary, #1878D0);
  font-size: 10px; font-weight: 700; cursor: help; border: none; position: relative;
}
.info-i:hover, .info-i:focus-visible { outline: none; background: var(--primary, #1878D0); color: #fff; }
.info-i[data-tip]:hover::after, .info-i[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); background: var(--text, #000A2D); color: #fff;
  font-size: 12px; font-weight: 500; padding: 8px 10px; border-radius: 6px;
  white-space: normal; width: max-content; max-width: 280px; line-height: 1.4;
  text-align: left; z-index: 50; box-shadow: 0 6px 18px rgba(0,0,0,.15); pointer-events: none;
}
.info-i[data-tip]:hover::before, .info-i[data-tip]:focus-visible::before {
  content: ""; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--text, #000A2D); z-index: 50; pointer-events: none;
}

/* Form */
.my-team-form { display: flex; flex-direction: column; gap: 10px; }
.my-team-form-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr auto;
  gap: 10px;
  align-items: end;
}
@media (max-width: 880px) { .my-team-form-row { grid-template-columns: 1fr; } }
.my-team-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.my-team-field span { font-size: 12px; font-weight: 600; color: var(--text-muted, var(--muted)); }
.my-team-field input, .my-team-field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface, #fff); font: inherit; color: var(--text, #1a1d26);
}
.my-team-field input:focus, .my-team-field select:focus {
  outline: none; border-color: var(--primary, #1878D0); box-shadow: 0 0 0 3px var(--primary-tint, #e8f1fb);
}
.my-team-optional { color: var(--text-faint, #9aa0aa); font-weight: 400; font-size: 11px; }
.my-team-form-hint { font-size: 11.5px; color: var(--text-faint, var(--muted)); margin: 4px 0 0; }
.my-team-form-hint kbd {
  background: var(--surface, #fff); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; font-family: inherit; font-size: 10.5px; color: var(--text-muted);
}

/* Banner (replaces alert/dialog) */
.my-team-banner {
  border-radius: 8px; padding: 9px 12px; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.my-team-banner.ok    { background: #e6f4ea; color: #2E7D32; }
.my-team-banner.err   { background: #fdecea; color: #C62828; }
.my-team-banner.info  { background: var(--primary-tint, #e8f1fb); color: var(--primary-dark, #0D5BA6); }

/* List */
.my-team-list { display: flex; flex-direction: column; gap: 6px; }
.my-team-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
  align-items: center;
}
.my-team-row .who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.my-team-row .who .name { font-weight: 600; color: var(--text, var(--heading)); font-size: 14px; }
.my-team-row .who .email { font-size: 12px; color: var(--text-muted, var(--muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-team-row .when { font-size: 11.5px; color: var(--text-faint, var(--muted)); white-space: nowrap; }

.my-team-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.my-team-pill.role-developer { background: #e8f1fb; color: #1878D0; }
.my-team-pill.role-tester    { background: #f3e5f5; color: #6A1B9A; }
.my-team-pill.role-prompter  { background: #fff3e0; color: #E65100; }
.my-team-pill.role-support   { background: #e0f2f1; color: #00796B; }
.my-team-pill.role-admin     { background: #fce4ec; color: #C62828; }
.my-team-pill.role-sales     { background: #e6f4ea; color: #1B5E20; }
.my-team-pill.role-marketing { background: #fff8e1; color: #B26500; }
.my-team-pill.status-pending   { background: #fff8e1; color: #b26500; }
.my-team-pill.status-approved  { background: #e8f1fb; color: #1878D0; }
.my-team-pill.status-rejected  { background: #fdecea; color: #C62828; }
.my-team-pill.status-joined    { background: #e6f4ea; color: #2E7D32; }
.my-team-pill.status-cancelled { background: #f0f0f0; color: #6b7280; }
.my-team-empty { padding: 14px; text-align: center; font-style: italic; color: var(--text-muted, var(--muted)); }

/* Sidebar dot for "you have a pending request" */
.my-team-pending-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent, #E8578A); margin-left: 6px; flex-shrink: 0;
}

/* ============================================================
   Admin pane: pending invite-requests queue
   ============================================================ */
.admin-req-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.admin-req-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
  align-items: center;
}
.admin-req-row .req-line { font-size: 13px; color: var(--text, var(--heading)); }
.admin-req-row .req-line .who { font-weight: 600; }
.admin-req-row .req-line .arrow { color: var(--text-faint, var(--muted)); margin: 0 6px; }
.admin-req-row .req-line .invitee { font-weight: 600; color: var(--text, var(--heading)); }
.admin-req-row .req-meta { font-size: 11px; color: var(--text-muted, var(--muted)); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-req-actions { display: inline-flex; gap: 6px; align-items: center; }
.admin-req-actions input[type="text"] {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit;
  width: 180px;
}
.admin-req-empty {
  padding: 14px; text-align: center; font-style: italic; color: var(--text-muted, var(--muted));
  border: 1px dashed var(--border); border-radius: 8px; margin-bottom: 14px;
}

/* ============================================================
   Wireframe React-artifact rendering — live iframe inside a card.
   ============================================================ */
.wireframe-live-wrap {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  overflow: hidden;
}
.wireframe-iframe {
  display: block;
  width: 100%;
  border: 0;
  background: #fff;
}
.wireframe-live-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 1;
}
.note-editor-code-preview {
  margin-top: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
  min-height: 200px;
}
.note-editor-code-preview .wireframe-iframe { min-height: 380px; }

/* Code textarea: monospace + Tab-friendly */
#noteEditorCode {
  width: 100%;
  min-height: 200px;
  resize: vertical;
}

/* ===== Wireframes: Render-all status banner + per-card render row ===== */
.wireframes-render-status {
  margin: 8px 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--primary-tint, #e8f1fb);
  color: var(--primary-dark, #0D5BA6);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wireframe-render-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
}
.wireframe-render-row .btn.is-rendering {
  opacity: 0.85;
  cursor: progress;
}

/* ===== Task-group create-time pickers ===== */
.taskgroup-pick-row {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.taskgroup-pick-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
}
.taskgroup-pick-label { font-weight: 500; }
.taskgroup-pick-label strong { color: var(--text, var(--heading)); font-weight: 700; }
.taskgroup-pick-hint { font-size: 11px; color: var(--text-faint, #9aa0aa); margin-left: 4px; }
.taskgroup-pick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--surface-sunk, #f6f9fd);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 44px;
}
.taskgroup-pick-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  color: var(--text-muted, #6b7280);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.taskgroup-pick-chip:hover {
  border-color: var(--primary, #1878D0);
  color: var(--primary, #1878D0);
}
.taskgroup-pick-chip.selected {
  background: var(--primary, #1878D0);
  border-color: var(--primary, #1878D0);
  color: #fff;
}
.taskgroup-pick-chip:focus-visible {
  outline: 2px solid var(--primary, #1878D0);
  outline-offset: 2px;
}
.taskgroup-pick-empty {
  font-style: italic;
  font-size: 12px;
  color: var(--text-faint, #9aa0aa);
  padding: 4px 6px;
}
.taskgroup-create-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.taskgroup-create-hint {
  flex: 1 1 auto;
  font-size: 12px;
  color: var(--text-faint, #9aa0aa);
}

/* ===== My Chats — task-group chat list ===== */
#myChatsView {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg, var(--surface, #f6f9fd)); overflow: hidden;
}
#myChatsHeader {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--border);
  background: var(--surface, #fff); flex-shrink: 0;
}
.my-chats-body { flex: 1 1 auto; overflow: auto; padding: 22px; }
.my-chats-list { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.my-chats-row {
  appearance: none; background: var(--surface, #fff);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px; align-items: center;
  cursor: pointer; text-align: left;
  font: inherit; color: inherit;
  transition: border-color 120ms, background-color 120ms;
}
.my-chats-row:hover {
  border-color: var(--primary, #1878D0);
  background: var(--primary-tint, #e8f1fb);
}
.my-chats-row:focus-visible {
  outline: 2px solid var(--primary, #1878D0); outline-offset: 2px;
}
.my-chats-row-ic {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--primary-tint, #e8f1fb);
  color: var(--primary, #1878D0);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.my-chats-row-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.my-chats-row-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.my-chats-row-name {
  font-weight: 600; font-size: 14.5px; color: var(--text, var(--heading));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.my-chats-row-desc {
  font-size: 12.5px; color: var(--text-muted, var(--muted));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.my-chats-row-meta {
  font-size: 11.5px; color: var(--text-faint, var(--muted));
  font-variant-numeric: tabular-nums;
}
.my-chats-row-arrow {
  font-size: 22px; color: var(--text-faint, #9aa0aa); padding: 0 6px;
}
.my-chats-count-badge {
  margin-left: auto;
  background: var(--primary, #1878D0);
  color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ===== Fullscreen task-group chat (launched from My Chats) =====
   When #myTeamView has .chat-fullscreen, hide every other card in the
   My Team body and let #taskGroupChat fill the available middle column. */
#myTeamView.chat-fullscreen .my-team-body > *:not(#taskGroupChat) { display: none !important; }
#myTeamView.chat-fullscreen .my-team-body { padding: 0; }
#myTeamView.chat-fullscreen #taskGroupChat {
  border: 0;
  border-radius: 0;
  margin: 0;
  height: calc(100vh - 60px); /* leave room for the My Team header */
  display: flex;
  flex-direction: column;
}
#myTeamView.chat-fullscreen #taskGroupChat .taskgroup-messages {
  flex: 1 1 auto;
  min-height: 0;
}
#myTeamView.chat-fullscreen #myTeamHeader { background: var(--surface-sunk, #f6f9fd); }

/* ============================================================
   Admin approvals gate — full-screen blocking modal that
   appears on app load (admin only) when there are pending
   team invites, agents, or developer prompts to review.
   No Esc / no outside-click close. Auto-closes when empty.
   ============================================================ */
body.admin-gate-locked { overflow: hidden; }
.admin-gate-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.72);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.admin-gate-backdrop.hidden { display: none; }
.admin-gate-shell {
  background: var(--surface, #fff);
  color: var(--text, #1a1d26);
  border-radius: 14px;
  width: 100%;
  max-width: 880px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.admin-gate-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 14px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-sunk, #f6f9fd) 100%);
}
.admin-gate-title-wrap { flex: 1 1 auto; min-width: 0; }
.admin-gate-head h2 {
  margin: 0; font-size: 17px; font-weight: 700;
  color: var(--text, var(--heading));
  display: flex; align-items: center; gap: 8px;
}
.admin-gate-head h2::before {
  content: '🔔'; font-size: 16px;
}
.admin-gate-sub {
  margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted, var(--muted));
  display: flex; align-items: center; gap: 6px;
}
.admin-gate-counts {
  background: var(--accent, #E8578A); color: #fff;
  font-size: 12px; font-weight: 700;
  padding: 5px 11px; border-radius: 999px;
  flex-shrink: 0;
}
.admin-gate-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px 22px 14px;
  display: flex; flex-direction: column; gap: 14px;
}
.admin-gate-section { display: flex; flex-direction: column; gap: 6px; }
.admin-gate-section.hidden { display: none; }
.admin-gate-section-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 0 4px;
  border-bottom: 1px dashed var(--border);
}
.admin-gate-section-title {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted, var(--muted));
}
.admin-gate-section-count {
  background: var(--primary-tint, #e8f1fb);
  color: var(--primary-dark, #0D5BA6);
  font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.admin-gate-section-list { display: flex; flex-direction: column; gap: 6px; }
.admin-gate-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
  transition: opacity 200ms, transform 200ms;
}
.admin-gate-row.resolving { opacity: 0; transform: translateX(20px); }
.admin-gate-row-text { min-width: 0; }
.admin-gate-row-main {
  font-size: 13.5px; font-weight: 600; color: var(--text, var(--heading));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-gate-row-sub {
  font-size: 11.5px; color: var(--text-muted, var(--muted));
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-gate-note {
  width: 180px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 12.5px;
}
.admin-gate-note:focus {
  outline: none;
  border-color: var(--primary, #1878D0);
  box-shadow: 0 0 0 2px var(--primary-tint, #e8f1fb);
}
.admin-gate-row-actions {
  display: inline-flex; gap: 6px; flex-shrink: 0;
}
.admin-gate-err {
  grid-column: 1 / -1;
  font-size: 12px; color: var(--danger, #C62828);
  padding-top: 4px;
}
.admin-gate-foot {
  padding: 10px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunk, #f6f9fd);
  text-align: center;
}
.admin-gate-footnote { font-size: 11px; color: var(--text-faint, #9aa0aa); }

@media (max-width: 720px) {
  .admin-gate-row { grid-template-columns: 1fr; }
  .admin-gate-note { width: 100%; }
}

/* ===== Chat notification toast (bottom-right) — distinct from #appToastHost
   which floats bottom-CENTER. Each card shows sender · group + a 140-char
   preview, slides in, auto-dismisses after 6s, click opens the chat. ===== */
#chatNotifHost {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 250;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
  max-width: 360px;
}
.chat-notif {
  pointer-events: auto;
  appearance: none;
  background: var(--surface, #fff);
  color: var(--text, #1a1d26);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary, #1878D0);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 32, 68, 0.18), 0 2px 6px rgba(15, 32, 68, 0.06);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 220ms ease, transform 220ms ease;
  width: 360px; max-width: calc(100vw - 44px);
}
.chat-notif:hover { border-left-color: var(--accent, #E8578A); }
.chat-notif-in  { opacity: 1; transform: translateY(0); }
.chat-notif-out { opacity: 0; transform: translateX(20px); }
.chat-notif-head {
  display: flex; gap: 6px; align-items: baseline;
  font-size: 12.5px; margin-bottom: 4px;
}
.chat-notif-sender {
  font-weight: 700;
  color: var(--text, var(--heading));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%;
}
.chat-notif-group {
  color: var(--text-muted, var(--muted));
  font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-notif-body {
  font-size: 13px;
  color: var(--text-muted, var(--muted));
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== My Chats: per-row unread pill + has-unread highlight ===== */
.my-chats-row.has-unread { border-color: var(--accent, #E8578A); background: var(--surface, #fff); }
.my-chats-row.has-unread .my-chats-row-name { font-weight: 700; }
.my-chats-row-unread {
  background: var(--accent, #E8578A); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ===== Feedback panel (sales / marketing / support replacement for the chat composer) ===== */
.feedback-panel {
  margin: 0 22px 12px;
  padding: 14px 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, #E8578A);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 32, 68, 0.04);
}
.feedback-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.feedback-title {
  font-size: 13.5px; font-weight: 700;
  color: var(--text, var(--heading));
}
.feedback-form { display: flex; flex-direction: column; gap: 8px; }
#feedbackInput {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit; font-size: 13.5px; line-height: 1.5;
  resize: vertical;
  min-height: 52px;
}
#feedbackInput:focus {
  outline: none;
  border-color: var(--primary, #1878D0);
  box-shadow: 0 0 0 3px var(--primary-tint, #e8f1fb);
}
.feedback-actions {
  display: flex; align-items: center; gap: 12px;
}
.feedback-hint { flex: 1 1 auto; font-size: 11.5px; color: var(--text-faint, #9aa0aa); }
.feedback-hint kbd {
  background: var(--surface, #fff);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px;
  font-family: inherit; font-size: 10.5px; color: var(--text-muted);
}
.feedback-flash {
  font-size: 12.5px;
  padding: 6px 10px; border-radius: 6px;
  background: #fdecea; color: #C62828;
}
.feedback-flash.ok { background: #e6f4ea; color: #2E7D32; }

/* ===== Workflow → Role flowchart (Mermaid) ===== */
.flowchart-section {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.flowchart-flash {
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  background: var(--primary-tint, #e8f1fb);
  color: var(--primary-dark, #0D5BA6);
}
.flowchart-flash.ok  { background: #e6f4ea; color: #2E7D32; }
.flowchart-flash.err { background: #fdecea; color: #C62828; }
.flowchart-preview {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 8px;
  overflow: hidden;
  min-height: 80px;
}
.flowchart-empty {
  padding: 24px; text-align: center; color: var(--text-faint, #9aa0aa);
  font-size: 13.5px;
}
.flowchart-iframe { display: block; width: 100%; border: 0; background: #fff; }
.flowchart-edit-wrap {
  margin-top: 12px;
  background: var(--surface-sunk, #f6f9fd);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.flowchart-edit-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted, #6b7280);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
}
.flowchart-code {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  background: var(--surface, #fff);
  tab-size: 2;
}
.flowchart-code:focus {
  outline: none;
  border-color: var(--primary, #1878D0);
  box-shadow: 0 0 0 3px var(--primary-tint, #e8f1fb);
}
.flowchart-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint, #9aa0aa);
}
.flowchart-hint kbd {
  background: var(--surface, #fff);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px;
  font-family: inherit; font-size: 10.5px; color: var(--text-muted);
}

/* ===== Masters — admin reference-data editor ===== */
#mastersView {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg, var(--surface, #f6f9fd)); overflow: hidden;
}
#mastersHeader {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--border);
  background: var(--surface, #fff); flex-shrink: 0;
}
.masters-body {
  flex: 1 1 auto; overflow: auto; padding: 22px;
  display: flex; flex-direction: column; gap: 18px;
  max-width: 1100px;
}
.masters-roles-list { display: flex; flex-direction: column; gap: 6px; }

/* Permissions matrix */
.masters-perms-wrap { overflow: auto; }
.masters-perms-table {
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface, #fff);
  width: 100%;
  min-width: 720px;
}
.masters-perms-table th,
.masters-perms-table td {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.masters-perms-table thead th {
  background: var(--surface-sunk, #f6f9fd);
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  font-size: 12px;
  position: sticky; top: 0;
}
.masters-perms-table th.masters-perms-roleh {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface, #fff);
  z-index: 1;
}
.masters-perms-cell input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--primary, #1878D0);
}
.masters-perms-cell.is-dirty {
  background: var(--primary-tint, #e8f1fb);
}
.masters-perms-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 10px;
}

/* ===== Sidebar menu accordion (frees space for the Threads list) ===== */
.sidebar-menu-toggle {
  display: flex; align-items: center; gap: 6px;
  margin: 6px 12px 4px;
  padding: 5px 9px;
  background: transparent;
  border: 1px solid var(--border, #2a2d3a);
  border-radius: 6px;
  color: var(--text-faint, #6b7280);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.sidebar-menu-toggle:hover {
  background: var(--surface-sunk, rgba(255,255,255,0.05));
  color: var(--text, var(--heading));
  border-color: var(--primary, #1878D0);
}
.sidebar-menu-toggle .sidebar-menu-chev {
  transition: transform 180ms;
  flex-shrink: 0;
}
.sidebar-menu-toggle.is-collapsed .sidebar-menu-chev { transform: rotate(-90deg); }
.sidebar-menu-toggle:focus-visible { outline: 2px solid var(--primary, #1878D0); outline-offset: 1px; }

.sidebar-menu {
  display: flex;
  flex-direction: column;
  /* Never get squeezed by the threadList sibling. The whole menu must always
     render at its natural height when expanded, and shrink to 0 only when the
     .collapsed class is applied. */
  flex-shrink: 0;
  transition: max-height 240ms ease, opacity 180ms ease, margin 180ms ease;
}
.sidebar-menu.collapsed {
  /* Only override flow when collapsed — keeps the base state spacious. */
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

/* Shared "section toggle" style for both Menu and Threads headers. */
.sidebar-section-toggle {
  margin-top: 8px;
}

/* Threads accordion. Mirrors .sidebar-menu — base state takes natural height,
   `.collapsed` shrinks to 0. The list itself keeps its own scroll when open. */
#threadList {
  transition: max-height 240ms ease, opacity 180ms ease, margin 180ms ease;
}
#threadList.collapsed {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

/* ===== My Tasks ===== */
#myTasksView {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg, var(--surface, #f6f9fd)); overflow: hidden;
}
#myTasksHeader {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--border);
  background: var(--surface, #fff); flex-shrink: 0;
}
.my-tasks-body {
  flex: 1 1 auto; overflow: auto; padding: 22px;
  display: flex; flex-direction: column; gap: 18px;
  max-width: 1400px;
}
.my-tasks-shell {
  display: grid; grid-template-columns: 360px 1fr;
  gap: 14px; align-items: stretch;
  min-height: 460px;
}
@media (max-width: 920px) { .my-tasks-shell { grid-template-columns: 1fr; } }

.my-tasks-list-pane {
  background: var(--surface, #fff);
  border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column; min-height: 0;
}
.my-tasks-list-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text-muted, #6b7280);
}
.my-tasks-list-title { letter-spacing: 0.04em; text-transform: uppercase; font-size: 11.5px; }
.my-tasks-list { display: flex; flex-direction: column; padding: 4px; overflow: auto; }
.my-tasks-row {
  appearance: none;
  display: grid; grid-template-columns: auto 1fr; gap: 10px;
  background: transparent; border: 1px solid transparent;
  text-align: left; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font: inherit; color: inherit;
}
.my-tasks-row:hover { background: var(--surface-sunk, #f6f9fd); }
.my-tasks-row.active { background: var(--primary-tint, #e8f1fb); border-color: var(--primary, #1878D0); }
.my-tasks-row.overdue .my-tasks-row-meta { color: var(--danger, #C62828); font-weight: 600; }
.my-tasks-row-status {
  font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: var(--surface-sunk, #f6f9fd);
  color: var(--text-muted, #6b7280);
  text-transform: uppercase; letter-spacing: 0.04em;
  height: max-content; align-self: start;
}
.my-tasks-row.status-in_progress .my-tasks-row-status { background: var(--primary-tint, #e8f1fb); color: var(--primary, #1878D0); }
.my-tasks-row.status-done .my-tasks-row-status { background: #e6f4ea; color: #2E7D32; }
.my-tasks-row.status-cancelled .my-tasks-row-status { background: #f0f0f0; color: #6b7280; }
.my-tasks-row-body { min-width: 0; }
.my-tasks-row-title { font-weight: 600; font-size: 13.5px; color: var(--text, var(--heading)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-tasks-row.status-done .my-tasks-row-title,
.my-tasks-row.status-cancelled .my-tasks-row-title { text-decoration: line-through; color: var(--text-faint, #9aa0aa); }
.my-tasks-row-meta { font-size: 11.5px; color: var(--text-muted, #6b7280); margin-top: 2px; }

.my-tasks-detail-pane {
  background: var(--surface, #fff);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; min-height: 0; overflow: auto;
}
.mtask-detail-head {
  display: flex; flex-direction: column; gap: 10px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.mtask-detail-title input {
  width: 100%; font-size: 18px; font-weight: 700;
  border: 1px solid transparent; border-radius: 6px;
  padding: 6px 8px; background: transparent; color: var(--text, var(--heading));
}
.mtask-detail-title input:focus { outline: none; border-color: var(--primary, #1878D0); background: var(--surface-sunk, #f6f9fd); }
.mtask-detail-meta {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  font-size: 12.5px; color: var(--text-muted, #6b7280);
}
.mtask-detail-meta label { display: inline-flex; align-items: center; gap: 6px; }
.mtask-detail-meta select, .mtask-detail-meta input[type="date"] {
  font: inherit; font-size: 12.5px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface, #fff);
}
#mtaskEditDesc {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; resize: vertical;
}

.mtask-goals { display: flex; flex-direction: column; gap: 10px; }
.mtask-goals-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.mtask-goals-head h4 { margin: 0; font-size: 14px; }
.mtask-add-goal {
  display: flex; gap: 6px;
}
.mtask-add-goal input {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
.mtask-goal {
  background: var(--surface-sunk, #f6f9fd);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px;
}
.mtask-goal.status-done { opacity: 0.85; }
.mtask-goal-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
}
.mtask-goal-head input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary, #1878D0); cursor: pointer; }
.mtask-goal-head .mtask-goal-title { flex: 1; }
.mtask-goal.status-done .mtask-goal-title { text-decoration: line-through; color: var(--text-muted, #6b7280); }
.mtask-goal-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px;
}
@media (max-width: 720px) { .mtask-goal-body { grid-template-columns: 1fr; } }
.mtask-subs-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-faint, #9aa0aa); margin-bottom: 4px;
}
.mtask-subs-list, .mtask-blocks-list {
  list-style: none; padding: 0; margin: 0 0 6px;
  display: flex; flex-direction: column; gap: 4px;
}
.mtask-sub {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 6px; background: var(--surface, #fff); border: 1px solid var(--border);
  font-size: 13px;
}
.mtask-sub input[type="checkbox"] { accent-color: var(--primary, #1878D0); cursor: pointer; }
.mtask-sub.status-done span { text-decoration: line-through; color: var(--text-muted, #6b7280); }
.mtask-sub button { margin-left: auto; padding: 2px 6px; }
.mtask-add-sub, .mtask-add-block { display: flex; gap: 4px; }
.mtask-add-sub input, .mtask-add-block input {
  flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font: inherit; font-size: 12.5px;
}
.mtask-block {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px;
  align-items: center;
  padding: 6px 8px; border-radius: 6px;
  background: #fff8e1; border: 1px solid #f0c87f;
  font-size: 12.5px;
}
.mtask-block.status-cleared { background: #e6f4ea; border-color: #b0d6b8; }
.mtask-block.status-cleared .mtask-block-text { text-decoration: line-through; color: var(--text-muted, #6b7280); }
.mtask-block-meta { font-size: 11px; color: var(--text-muted, #6b7280); }
.mtask-goal-del { padding: 2px 8px; }

/* ============================================================
   My Tasks v2 — card list matching the screenshot design.
   Left-border colour by priority + priority/status pills + metadata row.
   ============================================================ */
.mtask-tabs {
  display: flex; gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.mtask-tab {
  appearance: none; background: transparent; border: 0;
  padding: 8px 14px;
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.mtask-tab:hover { color: var(--text, var(--heading)); }
.mtask-tab.active {
  color: var(--text, var(--heading));
  font-weight: 700;
  border-bottom-color: var(--text, var(--heading));
  background: var(--surface-sunk, #f6f9fd);
  border-radius: 6px 6px 0 0;
}

/* Inline create-task strip */
.mtask-create {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto auto;
  gap: 8px;
  margin-bottom: 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
@media (max-width: 920px) {
  .mtask-create { grid-template-columns: 1fr 1fr; }
  .mtask-create input[type="text"] { grid-column: 1 / -1; }
}
.mtask-create input[type="text"],
.mtask-create input[type="number"],
.mtask-create input[type="date"],
.mtask-create select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit; font-size: 13px;
  background: var(--surface, #fff);
}
.mtask-create input[type="number"] { width: 70px; text-align: right; }

.mtask-list-head { padding: 4px 2px; }
.mtask-list-count {
  font-size: 11.5px; color: var(--text-muted, #6b7280);
  letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700;
}

.mtask-card-list { display: flex; flex-direction: column; gap: 10px; }
.mtask-group-head {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  padding: 12px 0 4px;
  border-bottom: 1px dashed var(--border);
}

/* Card */
.mtask-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.mtask-card.status-done { opacity: 0.78; }
.mtask-card.status-cancelled { opacity: 0.55; }

.mtask-card-head {
  display: flex; align-items: flex-start; gap: 12px; justify-content: space-between;
}
.mtask-card-title {
  font-size: 15px; font-weight: 700;
  color: var(--text, var(--heading));
  line-height: 1.3;
}
.mtask-card.status-done .mtask-card-title,
.mtask-card.status-cancelled .mtask-card-title {
  text-decoration: line-through;
  color: var(--text-muted, #6b7280);
}
.mtask-card-pills { display: inline-flex; gap: 6px; flex-shrink: 0; }
.mtask-pill {
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  letter-spacing: 0.02em;
}
/* Priority pills */
.mtask-pill.prio-critical { background: #fde9e1; color: #993C1D; }
.mtask-pill.prio-high     { background: #fdeece; color: #BA7517; }
.mtask-pill.prio-normal   { background: #e0f1ec; color: #0F6E56; }
.mtask-pill.prio-low      { background: #ececea; color: #555550; }
/* Status pills */
.mtask-pill.status-todo        { background: #ececea; color: #555550; }
.mtask-pill.status-in_progress { background: #e8f1fb; color: #1878D0; }
.mtask-pill.status-blocked     { background: #fff8d0; color: #b26500; }
.mtask-pill.status-in_review   { background: #f3e5f5; color: #6A1B9A; }
.mtask-pill.status-done        { background: #e6f4ea; color: #2E7D32; }
.mtask-pill.status-cancelled   { background: #f0f0f0; color: #6b7280; }

.mtask-card-desc {
  font-size: 13.5px;
  color: var(--text-muted, #6b7280);
  line-height: 1.5;
}

.mtask-card-meta {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 12.5px; color: var(--text-muted, #6b7280);
  align-items: center;
}
.mtask-meta-chip {
  display: inline-flex; align-items: center; gap: 5px;
}
.mtask-meta-chip.overdue { color: var(--danger, #C62828); font-weight: 600; }
.mtask-meta-chip.blocks { color: #b26500; font-weight: 600; }
.mtask-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--primary, #1878D0); color: #fff;
  border-radius: 50%;
  font-size: 10px; font-weight: 700;
  letter-spacing: -0.02em;
}

.mtask-blocked-reason {
  font-size: 12.5px;
  background: #fff8d0; color: #5a3d00;
  padding: 6px 10px; border-radius: 6px;
  border: 1px solid #f0c87f;
}

.mtask-card-actions {
  display: flex; gap: 8px;
  padding-top: 4px;
}

/* ─── Edit modal ─── */
.mtask-edit-modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.mtask-edit-modal.hidden { display: none; }
.mtask-edit-shell {
  background: var(--surface, #fff);
  border-radius: 12px;
  width: 100%; max-width: 620px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  display: flex; flex-direction: column;
}
.mtask-edit-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.mtask-edit-head h3 { margin: 0; font-size: 16px; }
.mtask-edit-body {
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.mtask-edit-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12.5px; color: var(--text-muted, #6b7280);
}
.mtask-edit-field span { font-weight: 600; }
.mtask-edit-field input,
.mtask-edit-field textarea,
.mtask-edit-field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit; font-size: 13.5px;
  background: var(--surface, #fff);
  color: var(--text, var(--heading));
}
.mtask-edit-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
}
@media (max-width: 600px) { .mtask-edit-row { grid-template-columns: 1fr; } }
.mtask-edit-actions {
  display: flex; align-items: center; gap: 8px;
  padding-top: 6px; border-top: 1px solid var(--border); margin-top: 6px;
}

/* ===== Side chat (/btw) — slide-in panel beside the main composer ===== */
.side-chat-panel {
  position: fixed;
  right: 0; top: 64px; bottom: 0;
  width: min(420px, 90vw);
  background: var(--surface, #fff);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(15, 32, 68, 0.10);
  z-index: 90;
  display: flex; flex-direction: column;
  transform: translateX(0);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.side-chat-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}
.side-chat-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunk, #f6f9fd);
  display: flex; align-items: center; gap: 8px;
}
.side-chat-title {
  flex: 1 1 auto;
  font-size: 13.5px; font-weight: 700;
  color: var(--text, var(--heading));
  display: inline-flex; align-items: center; gap: 6px;
}
.side-chat-head-actions { display: inline-flex; gap: 4px; }
.side-chat-messages {
  flex: 1 1 auto;
  overflow: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.side-chat-empty {
  color: var(--text-muted, #6b7280);
  font-size: 12.5px;
  font-style: italic;
  text-align: center;
  padding: 18px 8px;
}
.side-chat-bubble {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.side-chat-user {
  align-self: flex-end;
  background: var(--primary, #1878D0);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.side-chat-assistant {
  align-self: flex-start;
  background: var(--surface-sunk, #f6f9fd);
  color: var(--text, #1a1d26);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.side-chat-assistant.pending { font-style: italic; color: var(--text-faint, #9aa0aa); }
.side-chat-error {
  background: #fdecea !important;
  color: #C62828 !important;
  border-color: #f4d6d6;
}
.side-chat-composer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--surface, #fff);
  display: flex; flex-direction: column; gap: 6px;
}
.side-chat-composer textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit; font-size: 13.5px; line-height: 1.4;
  resize: vertical; min-height: 44px; max-height: 200px;
}
.side-chat-composer textarea:focus {
  outline: none;
  border-color: var(--primary, #1878D0);
  box-shadow: 0 0 0 3px var(--primary-tint, #e8f1fb);
}
.side-chat-actions { display: flex; align-items: center; gap: 8px; }
.side-chat-hint {
  flex: 1 1 auto;
  font-size: 11px;
  color: var(--text-faint, #9aa0aa);
}
.side-chat-hint kbd {
  background: var(--surface-sunk, #f6f9fd);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px;
  font-family: inherit; font-size: 10.5px;
}

@media (max-width: 720px) {
  .side-chat-panel { width: 100vw; top: 56px; }
}

/* ────────────────────────────────────────────────────────────
   Onboarding overlay — pinned full-viewport scrim shown to
   non-admin users until both onboarding steps finish:
     1. Telegram /link <email> via the bot
     2. Mini App opened at least once
   Per imagine design rules this is a proper UI panel (not a
   native dialog) — keyboard-accessible, focus-trapped, Escape
   does NOT dismiss (it's mandatory by design).
   ──────────────────────────────────────────────────────────── */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.onboarding-overlay.hidden { display: none; }
.onboarding-card {
  background: var(--surface, #fff);
  border-radius: 16px;
  border: 1px solid var(--border, #e6e9ee);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
  width: 100%; max-width: 560px;
  padding: 28px 28px 22px 28px;
  position: relative;
}
.onboarding-card::before {
  /* Top accent stripe so the panel reads "imagine-branded". */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, #0D7377 0%, #7C3AED 50%, #E44C9A 100%);
}
.onboarding-card h2 {
  margin: 0 0 8px 0; font-size: 20px; font-weight: 800; letter-spacing: -0.2px;
}
.onboarding-blurb {
  margin: 0 0 20px 0; font-size: 13.5px; line-height: 1.55; color: var(--text-soft, #4b5563);
}
.onboarding-steps {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 14px;
}
.onboarding-step {
  display: flex; gap: 14px;
  background: var(--surface-sunk, #f6f9fd);
  border: 1px solid var(--border, #e6e9ee);
  border-radius: 12px;
  padding: 14px 14px 16px 14px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.onboarding-step.is-done {
  background: rgba(13, 115, 119, 0.08);
  border-color: #0D7377;
}
.onboarding-step-num {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-violet, #7C3AED); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.onboarding-step.is-done .onboarding-step-num {
  background: #0D7377;
}
.onboarding-step-body { flex: 1 1 auto; min-width: 0; }
.onboarding-step-title {
  font-weight: 700; font-size: 14.5px; margin-bottom: 4px;
  display: inline-flex; align-items: center; gap: 6px;
}
.onboarding-step-status { font-size: 14px; }
.onboarding-step-desc {
  font-size: 12.5px; color: var(--text-soft, #4b5563); line-height: 1.55;
  margin-bottom: 10px;
}
.onboarding-step-desc code {
  background: rgba(0, 0, 0, 0.05); padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 11.5px;
}
.onboarding-step-cta {
  display: inline-block;
  text-decoration: none;
  font-size: 13px; font-weight: 700;
  padding: 7px 14px; border-radius: 8px;
}
.onboarding-step.is-done .onboarding-step-cta { display: none; }
.onboarding-foot {
  margin-top: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--text-faint, #9aa0aa);
}
.onboarding-foot .btn { font-size: 12px; padding: 6px 12px; }

@media (max-width: 480px) {
  .onboarding-card { padding: 20px 18px 16px 18px; }
  .onboarding-step { padding: 12px; gap: 10px; }
  .onboarding-step-num { width: 26px; height: 26px; font-size: 12.5px; }
}
