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

:root {
  --bg-primary: #212121;
  --bg-secondary: #171717;
  --bg-tertiary: #2f2f2f;
  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --text-muted: #8e8e8e;
  --border-color: #424242;
  --accent-color: #10a37f;
  --accent-hover: #1a7f64;
  /* The accent as text or an icon (fills, borders and switches keep --accent-color); light darkens it. */
  --accent-text: var(--accent-color);
  /* Links: message links, file links, links to other chats (Control UI --link). */
  --link-color: #58a6ff;
  --mention-color: #58a6ff; /* @mentions in team chats: the link blue */
  --user-bg: #2f2f2f;
  --assistant-bg: transparent;
  --input-bg: #2f2f2f;
  --sidebar-width: 260px;
  /* Foreground ink as an RGB triple for translucent tints, hairlines and text: rgba(var(--ink), a).
     White on the dark theme, black on the light one. */
  --ink: 255, 255, 255;
}

[data-theme="light"] {
  --mention-color: #0757b8; /* darker than the link blue: 4.5:1+ inside a tinted pill on the warm user bubble */
  /* Light surfaces need darker inks for 4.5:1: the plain green reads 2.3-3.0:1 on them, the old link blue
     #0969da 3.8-4.5:1. Both reach 5:1+ on every light surface (page, sidebar, tertiary, user bubble, input). */
  --accent-text: color-mix(in srgb, var(--accent-color) 62%, #000);
  --link-color: #0757b8;
  /* Warm paper (Claude / Control UI light palette): parchment page, darker chrome, near-white composer and cards.
     The accent stays ClawChats green. */
  --bg-primary: #f0eee6;
  --bg-secondary: #e8e5dc;
  --bg-tertiary: #e0dcd1;
  --text-primary: #211e1a;
  --text-secondary: #403c35;
  --text-muted: #6e6960;
  --border-color: #dcd7cc;
  --user-bg: #e6e2d8;
  --input-bg: #faf9f5;
  --ink: 33, 30, 26;
}

[data-theme="light"] .project-rail-item:hover {
  background: rgba(var(--ink), 0.04);
}

[data-theme="light"] .project-rail-item.active {
  background: rgba(var(--ink), 0.06);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height - adjusts when mobile keyboard opens */
  overflow: hidden;
  font-size: 16px;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* Project Rail */
.project-rail {
  width: 52px;
  min-width: 52px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.project-rail::-webkit-scrollbar {
  display: none;
}

.project-rail-items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.project-rail-item {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: 2px solid var(--border-color);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

.project-rail-item:hover {
  transform: scale(1.08);
  background: rgba(var(--ink), 0.04);
}

.project-rail-item.active {
  background: rgba(var(--ink), 0.06);
}

/* A chat row dragged over a project: dropping moves the chat there (chat-list.js moveChatToProject). */
.project-rail-item.chat-drop-target {
  transform: scale(1.12);
  background: rgba(var(--ink), 0.1);
  box-shadow: 0 0 0 2px currentColor;
}

.project-rail-item.active::before {
  content: '';
  position: absolute;
  left: -9px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--rail-accent, var(--accent-color));
}

.project-rail-item .project-icon-emoji {
  font-size: 16px;
  line-height: 1;
}

.project-rail-item .project-icon-letter {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* Tooltip on hover */
.project-rail-item[title] {
  position: relative;
}

/* Unread badge on project rail icons */
.project-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  pointer-events: none;
}

.project-rail-add {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: 1.5px dashed var(--border-color);
  color: var(--text-muted);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  margin-top: 6px;
  flex-shrink: 0;
  opacity: 0.5;
}

.project-rail-add:hover {
  opacity: 1;
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

/* A chat row dragged over +: dropping opens New project with that chat to move into it */
.project-rail-add.chat-drop-target {
  opacity: 1;
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: rgba(var(--ink), 0.1);
  transform: scale(1.12);
}

.project-rail-add svg {
  width: 14px;
  height: 14px;
}

/* Cog menu at bottom of project rail */
.project-rail-cog-wrapper {
  position: relative;
  margin-top: auto;
  flex-shrink: 0;
}

.project-rail-cog-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.project-rail-cog-btn:hover,
.project-rail-cog-btn.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.project-rail-cog-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Mobile menu: show project icon instead of hamburger */
.menu-btn .menu-project-icon {
  display: none;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  /* Only the mobile drawer slides. Collapse snaps (as the Control UI's does): animating width
     re-truncated every chat title on each frame. */
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.hidden {
  transform: translateX(-100%);
  position: absolute;
  z-index: 100;
  height: 100%;
}

/* Sidebar Resize Handle */
.sidebar-resize {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 150ms ease;
  flex-shrink: 0;
  position: relative;
  z-index: 101;
  /* overlay the sidebar's right edge instead of taking a 4px column of bare page background between it and the header */
  margin-left: -4px;
}

.sidebar-resize::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  right: -3px;
}

.sidebar-resize:hover,
.sidebar-resize.active {
  background: var(--accent-color);
}

.sidebar.hidden + .sidebar-resize,
.sidebar.collapsed + .sidebar-resize {
  display: none;
}

.sidebar-header {
  padding: 12px;
}

.new-chat-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.new-chat-btn {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  transition: background 0.2s;
}

.new-chat-btn:hover {
  background: var(--bg-tertiary);
}

.new-chat-btn svg {
  width: 16px;
  height: 16px;
}

#newChatBtn, .new-chat-btn {
  background: rgba(16, 163, 127, 0.08);
  border: 1px solid rgba(16, 163, 127, 0.28);
  color: var(--accent-text);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.01em;
  padding: 10px 16px;
  box-shadow: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

#newChatBtn, .new-chat-btn {
  justify-content: center;
  gap: 8px;
  padding-left: 12px;
  padding-right: 12px;
}

.new-chat-btn .btn-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#newChatBtn svg, .new-chat-btn svg {
  stroke: #10a37f;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

#newChatBtn:hover, .new-chat-btn:hover {
  background: rgba(16, 163, 127, 0.14);
  border-color: rgba(16, 163, 127, 0.5);
  color: #13c49a;
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(16, 163, 127, 0.12);
}

#newChatBtn:active, .new-chat-btn:active {
  transform: scale(0.97);
  background: rgba(16, 163, 127, 0.10);
}

/* Sidebar collapse button: sidebar header, after New chat (Control UI .sidebar-brand__collapse) */
.sidebar-collapse-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.sidebar-collapse-btn:active {
  transform: scale(0.97);
}

.sidebar-collapse-btn__open,
.sidebar.collapsed .sidebar-collapse-btn__close {
  display: none;
}

.sidebar.collapsed .sidebar-collapse-btn__open {
  display: block;
}

/* Incognito notice above the composer (Control UI .new-session-page__incognito-notice) */
.incognito-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  width: calc(100% - 36px);
  max-width: 48rem;
  margin: 0 auto 6px;
  padding-inline: 14px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  user-select: none;
}

.incognito-banner[hidden] {
  display: none;
}

.incognito-banner svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}

body.incognito-chat .agent-chat__input {
  border-style: dashed;
}

.sidebar-search {
  position: relative;
  margin-top: 8px;
}

.sidebar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.sidebar-search input:focus {
  border-color: var(--accent-color);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.section-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 16px 6px;
  letter-spacing: 0.5px;
}

.pinned-section {
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
  padding-bottom: 8px;
}

.chat-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: default;
  margin: 2px 8px;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-item .chat-title,
.chat-item:hover .chat-title {
  max-width: none;
  flex: 1 1 0%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions: always in layout, never display:none — use visibility instead */
.chat-item .chat-item-actions {
  display: flex !important;
  flex-shrink: 0;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.chat-item:hover .chat-item-actions {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.chat-item:hover {
  background: var(--bg-tertiary);
}

.chat-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-left: 2px solid var(--accent-color, #10a37f);
  padding-left: 10px;
}

.chat-item {
  transition: background 0.6s ease-out, border-left-color 0.6s ease-out;
}

/* Last selected chat: a neutral rule only. Accent green belongs to the open chat alone. */
.chat-item.previously-active {
  border-left: 2px solid rgba(var(--ink), 0.18);
  padding-left: 10px;
}

/* Branch chat styling */
.chat-item.branch {
  padding-left: 24px;
  border-left: 2px solid var(--border-color);
  margin-left: 8px;
  background: rgba(99, 102, 241, 0.03);
}

.chat-item.branch:hover {
  background: rgba(99, 102, 241, 0.08);
}

.chat-item.branch.active {
  background: rgba(99, 102, 241, 0.12);
  border-left-color: var(--accent-color);
}

.branch-indicator {
  display: inline-flex;
  margin-right: 6px;
  opacity: 0.6;
}

.branch-icon {
  width: 12px;
  height: 12px;
}

.pin-indicator {
  display: inline-flex;
  margin-right: 4px;
  opacity: 0.6;
}

.pin-indicator .pin-icon {
  width: 10px;
  height: 10px;
}

.pin-icon {
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
}

/* Grey, not accent: green marks the open chat only */
.pin-icon.pinned {
  stroke: var(--text-muted);
  fill: var(--text-muted);
}

.chat-item {
  cursor: grab;
}

.chat-item:active {
  cursor: grabbing;
}

/* Unread dot: the gateway's unread is a flag, not a count. Static (no entry animation), like the
   Control UI's dot; blue is the unread colour everywhere (rail count, collapsed icons, workspace list). */
.chat-unread-dot {
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 6px color-mix(in srgb, #3b82f6 55%, transparent);
  flex-shrink: 0;
}

.chat-item .unread-title {
  font-weight: bold;
}

/* Session attention (pending approval / question), ported from the Control UI's layout.css
   (.sidebar-session-attention__icon*, .sidebar-recent-session--attention-*). Our rows are .chat-item with
   .chat-title as the name; the subtitle keeps the Control UI's class. Colours come from --warn/--danger
   (frontend/styles/composer-tokens.css, which scopes them to .sidebar too). */
.sidebar-session-attention__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: none;
}

.sidebar-session-attention__icon--question,
.sidebar-session-attention__icon--approval,
.sidebar-session-attention__icon--agent {
  color: var(--warn);
}

.sidebar-session-attention__icon--error {
  color: var(--danger);
}

.sidebar-session-attention__icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-item.sidebar-recent-session--attention-amber .chat-title,
.chat-item.sidebar-recent-session--attention-amber .sidebar-recent-session__subtitle {
  color: color-mix(in srgb, var(--warn) 82%, var(--text));
}

.chat-item.sidebar-recent-session--attention-danger .chat-title,
.chat-item.sidebar-recent-session--attention-danger .sidebar-recent-session__subtitle {
  color: color-mix(in srgb, var(--danger) 86%, var(--text));
}

/* Title over subtitle when attention owns the second line. */
.chat-item .chat-item-text {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-width: 0;
  gap: 1px;
}

.chat-item .sidebar-recent-session__subtitle {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collapsed sidebar: the attention icon takes the corner badge slot. */
.chat-icon-item .sidebar-session-attention__icon {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-secondary);
  pointer-events: none;
}

.chat-icon-item .sidebar-session-attention__icon svg {
  width: 11px;
  height: 11px;
}

/* Run spinner in the ⋯ slot (chat-list.js RUN_SPINNER): shown while the row isn't hovered, ⋯ on hover */
.chat-item .chat-item-actions {
  position: relative;
}

.chat-item.streaming:not(:hover) .chat-item-actions {
  visibility: visible;
  opacity: 1;
}

.chat-item.streaming:not(:hover) .chat-action-btn,
.chat-item:hover .chat-item-run {
  visibility: hidden;
}

.chat-item .chat-item-run {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -6px 0 0 -6px;
}

.streaming-dots {
  animation: streamingPulse 1.4s ease-in-out infinite;
}

@keyframes streamingPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Streaming dot for collapsed chat icons */
.chat-icon-streaming-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 2px var(--bg-primary);
  pointer-events: none;
  animation: streamingPulse 1.4s ease-in-out infinite;
}

/* Context menu for chat items */
.chat-context-menu {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  min-width: 160px;
  padding: 4px 0;
  display: none;
}

.chat-context-menu.visible {
  display: block;
}

.chat-context-menu-item {
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s;
}

.chat-context-menu-item:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-context-menu-item:disabled {
  opacity: 0.5;
  cursor: default;
}

.chat-context-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.chat-context-menu-item svg[hidden] {
  display: none;
}

/* Move to project…: the project list, indented under the item like the Add agent… list */
.chat-context-projects { padding-left: 18px; }
.chat-context-projects-scroll { max-height: 240px; overflow-y: auto; }
.chat-context-projects[hidden] { display: none; }
.chat-context-project-icon {
  width: 18px;
  height: 18px;
  border: 1.5px solid;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.chat-context-project-icon img { width: 12px; height: 12px; object-fit: contain; }
.chat-context-project--new .chat-context-project-icon { border: 1.5px dashed var(--border-color); color: var(--text-muted); font-size: 13px; font-weight: 400; }

.chat-context-menu-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--border-color);
}

.chat-context-menu-item.danger {
  color: #ef4444;
}

.chat-context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.completed-section {
  margin-top: 6px;
}

/* Matches .chat-date-group (TODAY / THIS WEEK), but clickable */
.expand-completed-btn,
.expand-pinned-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 8px 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: #444;
}

.expand-completed-btn span,
.expand-pinned-btn span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.expand-completed-btn::after,
.expand-pinned-btn::after {
  content: '';
  flex: 1;
  height: 1px;
  margin-left: 2px;
  background: rgba(var(--ink), 0.06);
}

.expand-completed-btn:hover,
.expand-pinned-btn:hover {
  color: var(--text-secondary);
}

.completed-chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.expand-completed-btn.expanded .completed-chevron,
.expand-pinned-btn.expanded .completed-chevron {
  transform: rotate(90deg);
}

.completed-indicator {
  display: inline-flex;
  vertical-align: -2px;
  margin-right: 6px;
  color: var(--text-muted);
}

.completed-indicator svg {
  width: 13px;
  height: 13px;
}

/* Muted, not faded: full contrast on hover and when open, so it never reads as disabled */
.chat-item.completed .chat-title {
  color: var(--text-muted);
}

.chat-item.completed:hover .chat-title,
.chat-item.completed.active .chat-title {
  color: var(--text-primary);
}

.chat-context-menu-item[hidden] {
  display: none;
}

/* Shortcuts modal */
.shortcuts-body {
  padding: 0 !important;
}

.shortcut-group {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.shortcut-group:last-child {
  border-bottom: none;
}

.shortcut-group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.shortcut-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

.shortcut-keys {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.shortcut-keys kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 11px;
  min-width: 20px;
  text-align: center;
}

/* Mobile Access / QR Code */
.mobile-access {
  text-align: center;
}

.qr-container {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.qr-code {
  padding: 12px;
  background: white;
  border-radius: 8px;
  display: inline-block;
}

.qr-code img {
  display: block;
}

.mobile-url {
  margin-top: 8px;
  font-family: monospace;
  font-size: 12px;
  color: var(--accent-text);
  word-break: break-all;
}

.setting-hint.warning {
  color: #f59e0b;
  display: block;
  margin-top: 8px;
}

/* Main area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  position: relative;
}

.header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 600;
  background: rgba(28, 28, 28, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(var(--ink), 0.06);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(var(--ink), 0.03) inset;
}

/* Open chat's cached render is being revalidated (indeterminate bar on the header's bottom edge) */
.header.syncing::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(var(--ink), 0.45), transparent) no-repeat;
  background-size: 30% 100%;
  animation: header-sync 1.1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes header-sync {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}

.menu-btn:hover {
  background: var(--bg-tertiary);
}

.menu-btn svg {
  width: 20px;
  height: 20px;
}

.title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-project-label {
  opacity: 0.85;
  font-weight: 500;
  max-width: 120px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.header-title-sep {
  opacity: 0.3;
  margin: 0 2px;
}

.header-chat-title {
  font-weight: 600;
}

.status {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  transition: all 0.2s;
}

.status.connected {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent-color, #10a37f);
  box-shadow: 0 0 6px rgba(16, 163, 127, 0.5);
  flex-shrink: 0;
  cursor: default;
}

.status.connected.relay {
  background: #e88a1a;
  box-shadow: 0 0 6px rgba(232, 138, 26, 0.5);
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  transition: opacity 0.2s;
  cursor: default;
}
.sync-status.hidden {
  display: none;
}
.sync-status.pending {
  background: rgba(255, 170, 0, 0.15);
  color: #ffaa00;
}
.sync-status.dead {
  background: rgba(255, 60, 60, 0.15);
  color: #ff3c3c;
  cursor: pointer;
}

/* Messages */
/* The scroll buttons (.scroll-nav: two 40px slots + 8px gap, 16px above the composer; a hidden button keeps
   its slot) float over the bottom-right of the transcript: the newest content ends above them. */
:root { --scroll-nav-clearance: 104px; }

.messages {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 32px 0 calc(var(--scroll-nav-clearance) + var(--attachment-overlay-h, 0px));
  scroll-behavior: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-secondary);
}

.sidebar-region__primary { isolation: isolate; }
.sidebar-region__primary.ascii-bg-on .input-area { background: transparent; }

/* First message sent: the splash fades out (chat-view.js dismissWelcome); ascii-bg.js fades its backdrop with it. */
.welcome.welcome--leaving {
  position: absolute;
  inset: 0 0 auto 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.sidebar-region__primary > .ascii-bg {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  pointer-events: none;
}

.welcome > h2,
.welcome > p {
  position: relative;
  z-index: 1;
  text-shadow: 0 0 12px var(--bg-primary), 0 0 4px var(--bg-primary);
}

.welcome h2 {
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome p {
  font-size: 16px;
}

.message {
  margin: 0 auto;
  width: 100%;
  max-width: 920px;
  padding: 6px 32px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: transparent;
  background-color: transparent;
}

.message.user {
  align-items: flex-end;
  margin-bottom: 8px;
  background: transparent;
  background-color: transparent;
}

.message.assistant {
  align-items: flex-start;
  margin-bottom: 4px;
  background: transparent;
  background-color: transparent;
}

.message.user .message-header {
  display: none;
}

.message.assistant .message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.message-time {
  font-size: 11px;
  color: #555;
  white-space: nowrap;
  font-weight: 400;
}

/* Message timestamps */
.message-hover-time {
  font-size: 10px;
  color: #666;
  margin-bottom: 2px;
  user-select: none;
}

.message.user .message-hover-time {
  text-align: right;
}

.message.assistant .message-hover-time {
  text-align: left;
}

/* Messages loading indicator */
.messages-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #333;
  border-top-color: #888;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Date separators */
.date-separator {
  display: flex;
  align-items: center;
  margin: 16px 0;
  gap: 12px;
}

.date-separator::before,
.date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #333;
}

.date-separator span {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message.user .message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message.assistant .message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message.user:hover .message-actions {
  opacity: 0.45;
}

.message.assistant:hover .message-actions {
  opacity: 0.45;
}

@media (hover: none) {
  /* Same specificity as the hidden-until-hover rules above, or those win and touch never shows the row. */
  .message.user .message-actions,
  .message.assistant .message-actions {
    opacity: 0.45;
  }
}

.msg-action-btn {
  background: transparent;
  border: 1px solid #383838;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.msg-action-btn svg {
  width: 16px;
  height: 16px;
}

.msg-action-btn:hover {
  background: #282828;
  color: #ccc;
  border-color: #555;
}

.msg-action-btn.copy-btn.copied {
  color: var(--accent-text);
}

.msg-action-btn.regen-btn:hover {
  color: var(--accent-text);
}

.msg-action-btn.speak-btn:hover {
  color: #8b5cf6;
}

.msg-action-btn.speak-btn.speaking {
  color: #8b5cf6;
  animation: pulse-speaking 1s ease-in-out infinite;
}

@keyframes pulse-speaking {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.msg-action-btn.edit-btn:hover {
  color: #818cf8;
}

.avatar {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.avatar.user {
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cbf 0%, #9b6fd4 100%);
  color: white;
}

.avatar.assistant {
  border-radius: 7px;
  background: linear-gradient(135deg, #c96442 0%, #d4784d 100%);
  color: white;
}

.message-role {
  font-weight: 600;
  font-size: 13px;
  color: #999;
  letter-spacing: 0.01em;
}

/* Attachment-only user message: just the images/files, no empty bubble (matches Control UI).
   Copy has nothing to copy; hidden but its slot kept so Edit doesn't move. */
.message.user.no-text > .message-content { display: none; }
.message.user.no-text .copy-btn { visibility: hidden; }

.message.user .message-content {
  background-color: #2d2d2d;
  border: 1px solid #3e3e3e;
  border-radius: 20px 20px 5px 20px;
  padding: 12px 18px;
  max-width: 72%;
  color: #ececec;
  font-size: 15px;
  line-height: 1.65;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  word-break: break-word;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.01em;
}

.message.assistant .message-content {
  background-color: transparent;
  border: none;
  padding: 0;
  max-width: 82%;
  color: #e5e5e5;
  font-size: 15px;
  line-height: 1.78;
  word-break: break-word;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.01em;
}

/* Turn-group spacing */
.message.assistant + .message.user {
  margin-top: 20px;
}

.message.user + .message.assistant {
  margin-top: 6px;
}

/* Markdown headers */
.message-content h1 { font-size: 1.5em; font-weight: 600; margin: 16px 0 8px; border-bottom: 1px solid var(--border-color); padding-bottom: 4px; }
.message-content h2 { font-size: 1.3em; font-weight: 600; margin: 14px 0 6px; }
.message-content h3 { font-size: 1.15em; font-weight: 600; margin: 12px 0 4px; }
.message-content h4, .message-content h5, .message-content h6 { font-size: 1em; font-weight: 600; margin: 10px 0 4px; }
.message-content h1:first-child, .message-content h2:first-child, .message-content h3:first-child { margin-top: 0; }

/* Markdown lists */
.message-content ul, .message-content ol { margin: 8px 0; padding-left: 24px; }
.message-content li { margin: 2px 0; }
.message-content li > ul, .message-content li > ol { margin: 2px 0; }

/* Markdown blockquotes */
.message-content blockquote {
  border-left: 3px solid var(--accent-color, #58a6ff);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-secondary);
  background: rgba(var(--ink), 0.03);
  border-radius: 0 4px 4px 0;
}
[data-theme="light"] .message-content blockquote { background: rgba(var(--ink), 0.03); }

/* Markdown tables */
.message-content table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  overflow-x: auto;
  display: block;
}
.message-content th, .message-content td {
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  text-align: left;
  /* The message's word-break: break-word lets auto layout squeeze a column to one letter; break only overlong words */
  word-break: normal;
  overflow-wrap: break-word;
}
/* Row labels keep a readable width, as in the Control UI */
.message-content th:first-child, .message-content td:first-child { min-width: 8rem; }
.message-content th { background: var(--bg-tertiary); font-weight: 600; }
.message-content tr:nth-child(even) { background: rgba(var(--ink), 0.02); }
[data-theme="light"] .message-content tr:nth-child(even) { background: rgba(var(--ink), 0.02); }

/* Markdown horizontal rule */
.message-content hr { border: none; border-top: 1px solid var(--border-color); margin: 16px 0; }

/* Markdown strikethrough */
.message-content del { opacity: 0.6; }

/* Markdown task lists */
.message-content input[type="checkbox"] { margin-right: 6px; vertical-align: middle; }

.message-content p {
  margin-bottom: 10px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  transition: border-color 0.15s;
}

.message-content a:hover {
  border-bottom-color: currentColor;
}

/* File links (frontend/chat/file-links.js), ported from the Control UI (ui/src/styles/chat/text.css):
   link colour, a file-kind glyph painted as a masked ::before (out of copied text and the
   accessibility tree), no underline until hover. A path written in backticks drops its code chip,
   so `README.md` and a bare src/app.ts read as the same affordance. */
.message-content a.markdown-file-link {
  position: relative;
  cursor: pointer;
  border-bottom: none;
  text-decoration: none;
  display: inline-block;
  max-width: 100%;
  padding-inline-start: 1.28em;
  overflow-wrap: anywhere;
}
.message-content a.markdown-file-link:hover {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.message-content a.markdown-file-link::before {
  --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' x2='8' y1='13' y2='13'/%3E%3Cline x1='16' x2='8' y1='17' y2='17'/%3E%3Cline x1='10' x2='8' y1='9' y2='9'/%3E%3C/svg%3E");
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: calc((1lh - 1em) / 2);
  width: 1em;
  height: 1em;
  background: currentColor;
  mask: var(--file-glyph) center / contain no-repeat;
  -webkit-mask: var(--file-glyph) center / contain no-repeat;
}
.message-content a.markdown-file-link[data-file-kind="code"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cpath d='m10 13-2 2 2 2'/%3E%3Cpath d='m14 17 2-2-2-2'/%3E%3C/svg%3E"); }
.message-content a.markdown-file-link[data-file-kind="markdown"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20'/%3E%3C/svg%3E"); }
.message-content a.markdown-file-link[data-file-kind="skill"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3H8'/%3E%3Cpath d='m15.007 5.008 3.987 3.986'/%3E%3Cpath d='M20 15v4'/%3E%3Cpath d='M21.174 6.813a2.82 2.82 0 0 0-3.986-3.987L3.842 16.175a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z'/%3E%3Cpath d='M22 17h-4'/%3E%3Cpath d='M4 5v4'/%3E%3Cpath d='M6 7H2'/%3E%3Cpath d='M9 2v2'/%3E%3C/svg%3E"); }
.message-content a.markdown-file-link[data-file-kind="component"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='7' height='7' x='3' y='3' rx='1'/%3E%3Crect width='7' height='7' x='14' y='3' rx='1'/%3E%3Crect width='7' height='7' x='14' y='14' rx='1'/%3E%3Crect width='7' height='7' x='3' y='14' rx='1'/%3E%3C/svg%3E"); }
.message-content a.markdown-file-link[data-file-kind="package"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/%3E%3Cpolyline points='3.27 6.96 12 12.01 20.73 6.96'/%3E%3Cline x1='12' y1='22.08' x2='12' y2='12'/%3E%3C/svg%3E"); }
.message-content a.markdown-file-link[data-file-kind="data"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1'/%3E%3Cpath d='M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1'/%3E%3C/svg%3E"); }
.message-content a.markdown-file-link[data-file-kind="shell"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 17 10 11 4 5'/%3E%3Cline x1='12' x2='20' y1='19' y2='19'/%3E%3C/svg%3E"); }
.message-content a.markdown-file-link[data-file-kind="image"]::before { --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2' ry='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21'/%3E%3C/svg%3E"); }
/* Out-specifies the per-bubble code chips (.message.assistant .message-content code etc.). */
.message .message-content a.markdown-file-link[data-file-path] > code,
.message-content a.markdown-file-link[data-file-path] > code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
}

/* A backticked URL (format.js codespan): keep the chip, but in the link colour so it reads as a link. */
.message-content a.markdown-code-link { border-bottom: none; }
.message .message-content a.markdown-code-link > code,
.message-content a.markdown-code-link > code { color: inherit; }
.message-content a.markdown-code-link:hover > code { border-color: currentColor; }
/* Click check (specs/file-link-check.md): the glyph becomes a spinning ring in the same 1em box,
   and a link the connector couldn't resolve dims in place. Neither changes the link's width. */
.message-content a.markdown-file-link.is-checking { cursor: progress; }
.message-content a.markdown-file-link.is-checking::before {
  --file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M21 12a9 9 0 1 1-6.22-8.56'/%3E%3C/svg%3E");
  animation: spin 0.8s linear infinite;
}
.message-content a.markdown-file-link.is-missing { opacity: 0.55; cursor: default; }
.message-content a.markdown-file-link.is-missing:hover { text-decoration: none; }

.file-link-popover {
  position: fixed;
  z-index: 10000;
  max-width: min(420px, calc(100vw - 16px));
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  color: var(--text-secondary);
}
.file-link-popover-title { color: var(--text-primary); font-weight: 500; margin-bottom: 4px; }
.file-link-popover-path {
  display: block;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  margin-bottom: 8px;
}
.file-link-popover-copy {
  padding: 4px 10px;
  font-size: 12px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
}
.file-link-popover-copy:hover { color: var(--text-primary); border-color: var(--text-muted); }

.message-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 14px;
}

.message-content pre {
  background: #2d2d2d;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0;
  position: relative;
}

.message-content pre code {
  background: transparent;
  padding: 0;
  font-family: 'SF Mono', Monaco, 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Code blocks inside USER bubbles ── */
.message.user .code-block { margin: 6px 0; }
.message.user .message-content pre {
  background: rgba(0, 0, 0, 0.3);
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0;
}
.message.user .message-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #d4d4d4;
  font-size: 13.5px;
  line-height: 1.6;
}
.message.user .message-content code {
  background: rgba(0, 0, 0, 0.25);
  border: none;
  border-radius: 4px;
  padding: 1px 5px;
  color: #ececec;
}

/* ── Code blocks inside ASSISTANT messages ── */
.message.assistant .message-content pre {
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: 10px;
  padding: 16px 18px;
  margin: 10px 0;
}
.message.assistant .message-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #abb2bf;
  font-size: 13.5px;
  line-height: 1.6;
}
.message.assistant .message-content code {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 13.5px;
  color: #d4956a;
}

/* Prism.js overrides */
.message-content pre[class*="language-"],
.message-content code[class*="language-"] {
  font-family: 'SF Mono', Monaco, 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}

.message-content pre[class*="language-"] {
  background: #2d2d2d;
  margin: 16px 0;
  padding: 16px;
  border-radius: 8px;
}

/* Light theme code blocks */
[data-theme="light"] .message-content pre,
[data-theme="light"] .message-content pre[class*="language-"] {
  background: var(--bg-secondary);
}

[data-theme="light"] .message-content code[class*="language-"],
[data-theme="light"] .message-content pre[class*="language-"] {
  color: var(--text-secondary);
}

/* Code block container */
.code-block {
  position: relative;
  margin: 16px 0;
}

.code-block pre {
  margin: 0;
}

/* Copy button for code blocks */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: #888;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s;
  z-index: 1;
}

.code-block:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.code-copy-btn svg {
  width: 14px;
  height: 14px;
}

.code-copy-btn.copied {
  color: var(--accent-text);
}

/* Language label */
.code-block pre[data-language]::before {
  content: attr(data-language);
  position: absolute;
  top: 8px;
  right: 40px;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light"] .code-copy-btn {
  background: rgba(var(--ink), 0.05);
  color: var(--text-muted);
}

[data-theme="light"] .code-copy-btn:hover {
  background: rgba(var(--ink), 0.1);
  color: var(--text-secondary);
}

/* Earlier-history boundary above the transcript, also the auto-load sentinel (chat-history.js).
   Port of the Control UI's .chat-history-boundary (styles/chat/layout.css); its loading sweep uses
   the brand accent. */
.chat-history-boundary {
  display: flex;
  overflow: hidden;
  height: 44px;
  flex-shrink: 0; /* .messages is a flex column */
  align-items: center;
  gap: 10px;
  padding: 8px 8px 0;
  color: var(--text-muted);
  font-size: 12px;
  user-select: none;
}

.chat-history-boundary__line {
  position: relative;
  flex: 1 1 0;
  height: 1px;
  overflow: hidden;
  background: var(--border-color);
  opacity: 0.9;
}

.chat-history-boundary__line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
  opacity: 0;
  transform: translateX(-100%);
}

.chat-history-boundary--loading .chat-history-boundary__line::after {
  opacity: 1;
  animation: chat-history-comet 1.2s ease-in-out infinite;
}

.chat-history-boundary--loading .chat-history-boundary__line:last-child::after {
  animation-direction: reverse;
}

.chat-history-boundary__action {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.chat-history-boundary__action:disabled {
  cursor: default;
}

.chat-history-boundary__action:not(:disabled):hover {
  color: var(--text-primary);
}

@keyframes chat-history-comet {
  to {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-history-boundary--loading .chat-history-boundary__line::after {
    animation: none;
  }
}

/* A display-capped reply or step: reads the whole row from the gateway on demand */
.activity-expand-full {
  display: block;
  margin-top: 6px;
  padding: 2px 0;
  background: none;
  border: none;
  color: var(--text-secondary, #666);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.activity-expand-full:hover:not(:disabled) {
  color: var(--text-primary);
}

.activity-expand-full:disabled {
  cursor: default;
  opacity: 0.6;
}

.msg-expand-full {
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 0;
  background: none;
  border: none;
  color: var(--text-secondary, #666);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.msg-expand-full:hover:not(:disabled) {
  color: var(--text-primary);
}

.msg-expand-full:disabled {
  cursor: default;
  opacity: 0.6;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

.typing-indicator span.thinking-timer {
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
  animation: none;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 2px;
  line-height: 1;
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Streaming cursor — blinking caret inline with last text */
.streaming-cursor {
  display: inline;
  animation: cursor-blink 0.8s step-end infinite;
  color: var(--text-primary);
  opacity: 0.7;
  margin-left: 1px;
  font-weight: 400;
  user-select: none;
  pointer-events: none;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0; }
}

/* Working dots — the cursor's place while a tool runs: the reply isn't finished, nothing is streaming in */
.working-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 6px;
  vertical-align: middle;
  user-select: none;
  pointer-events: none;
}

.working-dots span {
  width: 5px;
  height: 5px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.working-dots span:nth-child(2) { animation-delay: 0.2s; }
.working-dots span:nth-child(3) { animation-delay: 0.4s; }

/* A running reply has nothing to copy, read out or regenerate yet: keep the row's slot, hide its buttons */
.message.assistant[data-response-active] .message-actions {
  visibility: hidden;
}

/* Input area */
.input-area {
  position: relative;
  padding: 16px 24px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-primary);
  flex-shrink: 0; /* Don't compress input area */
}

.input-area .agent-chat__composer-combobox > textarea[data-ref="messageInput"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  outline: none;
  font-family: inherit;
}

.input-area .agent-chat__composer-combobox > textarea[data-ref="messageInput"]::placeholder {
  color: var(--text-muted);
}

/* Slash command autocomplete popup */
.slash-command-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 24px;
  right: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 4px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 100;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.slash-command-popup.open {
  display: flex;
  flex-direction: column;
}

.slash-command-popup.visible {
  opacity: 1;
  transform: translateY(0);
}

.slash-command-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  min-height: 44px;
  transition: background 0.1s;
  width: 100%;
}

.slash-command-item:hover,
.slash-command-item.active {
  background: var(--bg-tertiary);
}

.slash-command-name {
  font-weight: 600;
  color: var(--accent-text);
  flex-shrink: 0;
}

.slash-command-desc {
  color: var(--text-muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Image preview area */
/* Floats over the bottom of the message list with no backdrop; .messages is padded by its height
   (--attachment-overlay-h, set in syncAttachmentOverlay). Thumbnails stay in the 768px column. */
.image-preview {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  z-index: 1;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px max(24px, calc((100% - 768px) / 2 + 24px));
  pointer-events: none; /* no backdrop: clicks between thumbnails reach the messages behind */
}

.image-preview-item {
  pointer-events: auto;
}

.image-preview.has-images {
  display: flex;
}

.image-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.image-preview-item .remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
}

.image-preview-item:hover .remove-image,
.image-preview-item .remove-image:focus-visible {
  opacity: 1;
}

/* Touch screens have no hover: the × (remove, or cancel a read) stays visible (Control UI .chat-attachment-remove). */
@media (hover: none) {
  .image-preview-item .remove-image {
    opacity: 1;
  }
}

.image-preview-item .remove-image:hover {
  background: rgba(239, 68, 68, 0.8);
}

/* Text file preview items */
.image-preview-item.text-file-item {
  width: auto;
  min-width: 100px;
  max-width: 180px;
  height: auto;
  padding: 8px;
  background: var(--input-bg);
}

.text-file-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.text-file-icon {
  font-size: 24px;
  line-height: 1;
}

.text-file-name {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.text-file-size {
  font-size: 10px;
  color: var(--text-muted, #888);
}

/* A file still reading (attachments.js _appendReadingPreview; Control UI .chat-attachment-loading): a progress
   line where the size goes (a file) or along the bottom of a tinted tile (an image); its content pulses
   until the reader reports progress. --read-progress is 0..1. */
.image-preview-item.attachment-reading:not(.text-file-item) {
  background: color-mix(in srgb, var(--text-primary) 5%, var(--input-bg));
}

.attachment-read-line {
  width: 52px;
  height: 3px;
  margin: 4px 0 3px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.attachment-read-line > span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--text-muted, #888);
  transform: scaleX(var(--read-progress, 0));
  transform-origin: left;
}

.image-preview-item.attachment-reading:not(.text-file-item) .attachment-read-line {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 7px;
  width: auto;
  margin: 0;
}

.attachment-reading[data-indeterminate="true"] > :not(.remove-image) {
  animation: attachment-read-pulse 1.5s ease-in-out infinite;
}

.attachment-reading[data-indeterminate="true"] .attachment-read-line {
  height: 6px;
}

.attachment-reading[data-indeterminate="true"] .attachment-read-line > span {
  display: none;
}

@keyframes attachment-read-pulse {
  50% {
    opacity: 0.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .attachment-reading[data-indeterminate="true"] > :not(.remove-image) {
    animation: none;
  }
}

/* Text files in messages */
.message-text-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.message-text-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--input-bg);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
}

.message-text-file-icon {
  font-size: 14px;
}

/* Message images */
.message-images {
  --img-tile: min(128px, calc((100vw - 48px) / 3));
  display: grid;
  grid-template-columns: repeat(3, var(--img-tile));
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin-top: 12px;
}

.message-images--two-column {
  grid-template-columns: repeat(2, var(--img-tile));
}

.message-images--five > img:nth-child(4) {
  grid-column: 2;
}

.message-images img {
  width: var(--img-tile);
  height: var(--img-tile);
  object-fit: cover;
  border-radius: 14px;
  cursor: pointer;
  background: #1a1a1a;
  transition: transform 0.15s ease-out;
}

.message-images img:hover {
  transform: scale(1.02);
}

.message-images--single {
  grid-template-columns: minmax(0, auto);
}

.message-images--single img {
  width: auto;
  height: auto;
  min-width: 100px;
  min-height: 60px;
  max-width: min(100%, 400px);
  max-height: 360px;
  object-fit: contain;
}

.message-images-placeholder {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* Gap between anything stacked above the text bubble (images, files, comment chips…) and the bubble.
   The timestamp and the tool-activity block keep their own spacing. */
.message > :not(.message-hover-time, .activity-block) + .message-content {
  margin-top: 12px;
}

.message-images-placeholder .image-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--input-bg);
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Drag and drop overlay */
.drag-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(16, 163, 127, 0.1);
  border: 3px dashed var(--accent-color);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drag-overlay.active {
  display: flex;
}

.drag-overlay-text {
  background: var(--bg-secondary);
  padding: 24px 48px;
  border-radius: 12px;
  font-size: 18px;
  color: var(--accent-text);
  font-weight: 500;
}

@keyframes pulse-recording {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes stop-btn-stuck-pulse {
  0%, 100% { background: #ef4444; }
  50% { background: #fbbf24; }
}

.scroll-nav {
  position: fixed;
  bottom: 100px; /* Updated dynamically in JS based on input area height */
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.scroll-to-bottom-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  background: var(--surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.scroll-to-bottom-btn:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.scroll-to-bottom-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-primary);
}

/* While the agent is replying, an arc spins around the border (as in Claude's jump-to-latest
   button), so a reader scrolled up can see work going on below. Toggled in updateStreamingUI. */
.scroll-to-bottom-btn { position: relative; }
.scroll-to-bottom-btn svg.scroll-to-bottom-ring {
  position: absolute;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 22 78;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.scroll-to-bottom-btn.is-working svg.scroll-to-bottom-ring {
  opacity: 0.65;
  animation: scroll-to-bottom-spin 1s linear infinite;
}
@keyframes scroll-to-bottom-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .scroll-to-bottom-btn.is-working svg.scroll-to-bottom-ring {
    stroke-dasharray: none;
    animation: scroll-to-bottom-pulse 1.6s ease-in-out infinite;
  }
}
@keyframes scroll-to-bottom-pulse { 0%, 100% { opacity: 0.15; } 50% { opacity: 0.6; } }

/* Mobile context progress bar (replaces disclaimer) */
.mobile-context-bar {
  height: 4px;
  border-radius: 2px;
  margin: 8px 16px 4px;
  background: var(--bg-tertiary);
  overflow: hidden;
  display: none;
}

.mobile-context-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

@media (max-width: 680px) {
  .mobile-context-bar {
    display: block;
  }

  .sidebar-collapse-btn {
    display: none;
  }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
  border-color: var(--accent-color);
}

.form-group input[type="checkbox"] {
  margin-right: 8px;
}

.settings-actions {
  display: flex;
  gap: 12px;
}

.save-btn,
.connect-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.save-btn {
  background: var(--accent-color);
  color: white;
}

.save-btn:hover {
  background: var(--accent-hover);
}

.connect-btn {
  background: var(--accent-color);
  color: white;
}

.connect-btn:hover {
  background: var(--accent-hover);
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-muted, #888);
  border: 1px solid var(--border-color, #333);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  color: #f87171;
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.cancel-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  background: transparent;
  color: var(--text-secondary);
}

.cancel-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.modal-small {
  max-width: 360px;
}

.delete-warning {
  color: #ff6b6b;
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.delete-confirm-btn {
  padding: 8px 20px;
  background: #dc3545;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s, opacity 0.2s;
}

.delete-confirm-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.delete-confirm-btn:not(:disabled):hover {
  background: #c82333;
}

/* Drag handle for workspace items */
.workspace-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  padding: 0 4px;
  font-size: 14px;
  user-select: none;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.workspace-drag-handle:hover {
  opacity: 1;
}

/* Project drag-reorder (sidebar/projects.js _wireProjectReorder): rail icons and Settings → Projects rows */
.project-dragging {
  opacity: 0.4;
}

.project-drop-before,
.project-drop-after {
  position: relative;
}

/* The insertion bar sits in the gap above/below the target */
.project-drop-before::after,
.project-drop-after::after {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent-color);
  pointer-events: none;
}

.project-drop-before::after { top: -6px; }
.project-drop-after::after { bottom: -6px; }

.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-group select:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* A setting shown, not edited here (e.g. synced from the gateway) */
.form-group .setting-value {
  font-size: 14px;
  color: var(--text-primary);
}

.form-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

.branch-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-style: italic;
}

.connect-btn.secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  flex: 0 0 auto;
  padding: 12px 20px;
}

.connect-btn.secondary:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Search Modal */
.search-container {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.search-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
}

.search-input-wrapper:focus-within {
  border-color: var(--accent-color);
}

.search-icon {
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

#searchInput::placeholder {
  color: var(--text-muted);
}

.search-hint {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  border: 1px solid var(--border-color);
}

.search-filters {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.filter-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 200px;
  max-height: 60vh;
}

.search-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 14px;
}

.search-result {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
}

.search-result:hover {
  background: var(--bg-tertiary);
}

.search-result-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.search-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-result-role {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
}

.search-result-role.user {
  background: rgba(84, 54, 218, 0.2);
  color: #8b7dd8;
}

.search-result-role.assistant {
  background: rgba(16, 163, 127, 0.2);
  color: var(--accent-text);
}

.search-result-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-result-snippet mark {
  background: rgba(16, 163, 127, 0.3);
  color: var(--text-primary);
  padding: 1px 2px;
  border-radius: 2px;
}

/* One group per chat: the chat row, then its best matches indented under it */
.search-chat {
  margin-bottom: 6px;
}

.search-chat .search-result {
  margin-bottom: 0;
}

.search-chat-head {
  display: flex;
  flex-wrap: wrap; /* a chat's summary and tags (tags.css .search-chat-about) take their own line */
  align-items: center;
  justify-content: space-between;
  gap: 2px 12px;
  padding: 10px 12px 6px;
}

.search-chat-head .search-result-title {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-chat-head .search-result-meta {
  flex-shrink: 0;
}

.search-result-title mark {
  background: rgba(16, 163, 127, 0.3);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.search-chat.archived .search-result-title {
  color: var(--text-secondary);
}

.search-chat-archived,
.search-chat-count {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
}

.search-snippet {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px 6px 24px;
}

.search-snippet .search-result-role {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.search-result-role.person {
  background: rgba(251, 146, 60, 0.2);
  color: #fb923c;
}

/* Another chat or an automation wrote it: neutral, like the "↪ N updates from" row it opens. */
.search-result-role.chat {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
  color: var(--text-secondary);
  white-space: nowrap;
}

.search-snippet-icon {
  width: 10px;
  height: 10px;
}

.search-snippet .search-result-snippet {
  min-width: 0;
}

/* Index still building, failures, capped list, basic search on old connectors */
.search-status {
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

/* Settings → General → Search: chats the index couldn't read */
.search-index-failed {
  padding: 8px 16px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.search-index-failed__title {
  margin-bottom: 4px;
}

.search-index-failed__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.search-index-failed__error {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-no-results {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.search-no-results svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-muted);
  margin-bottom: 12px;
  opacity: 0.5;
}

.message-highlight {
  animation: highlightFade 2s ease-out;
}

@keyframes highlightFade {
  0% { background: rgba(16, 163, 127, 0.3); }
  100% { background: transparent; }
}

/* Up-arrow jump: quick flash on the message scrolled to (row for assistant, ring around the user bubble) */
.message.message-jump-flash {
  animation: highlightFade 1.2s ease-out;
  border-radius: 12px;
}

.message-content.message-jump-flash {
  animation: jumpRing 1.2s ease-out;
}

@keyframes jumpRing {
  0% { box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.9), 0 0 0 0 rgba(16, 163, 127, 0.4); }
  100% { box-shadow: 0 0 0 2px rgba(16, 163, 127, 0), 0 0 0 10px rgba(16, 163, 127, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .message-jump-flash { animation-duration: 0.01s; }
}

/* Search result keyboard selection */
.search-result.selected {
  background: var(--bg-tertiary);
  outline: 2px solid var(--accent-color);
  outline-offset: -2px;
}

/* Recent searches */
.recent-searches {
  padding: 8px 0;
}

.recent-searches-header {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recent-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s;
}

.recent-search-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.recent-search-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

/* Settings enhancements */
.settings-divider {
  height: 1px;
  background: var(--border-color);
  margin: 20px 0;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.workspace-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.workspace-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--bg-tertiary, #2a2a2a);
  font-size: 14px;
}

.workspace-item.active {
  border: 1px solid var(--accent, #4caf50);
}

.workspace-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-badge {
  font-size: 11px;
  color: var(--accent-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.workspace-unread-badge {
  background: #3b82f6;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
}

.workspace-actions {
  display: flex;
  gap: 4px;
}

.workspace-item.clickable {
  cursor: pointer;
}

.workspace-item.clickable:hover {
  background: var(--bg-hover, #333);
}

.workspace-rename-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted, #888);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.workspace-item:hover .workspace-rename-btn,
.workspace-item.active .workspace-rename-btn {
  opacity: 1;
}

.workspace-rename-btn:hover {
  color: var(--text-primary, #fff);
  border-color: var(--border-color, #444);
}

.workspace-name-edit {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.workspace-name-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-primary, #1a1a1a);
  border: 1px solid var(--accent, #4caf50);
  border-radius: 4px;
  color: var(--text-primary, #fff);
  font-size: 14px;
  padding: 2px 6px;
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #4caf50) 20%, transparent);
}

.workspace-name-input:disabled {
  opacity: 0.5;
}

.workspace-name-counter {
  font-size: 11px;
  color: var(--text-muted, #888);
  white-space: nowrap;
  flex-shrink: 0;
}

.workspace-delete-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary, #aaa);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  cursor: pointer;
}

.workspace-delete-btn:hover {
  color: #ff4444;
  border-color: #ff4444;
}

.workspace-icon-preview {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid;
  margin-right: 8px;
}

/* Project context menu */
.project-context-menu {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  width: 320px;
}

.project-context-menu .emoji-picker {
  border: none;
  box-shadow: none;
  border-radius: 10px;
  width: 100%;
}

.project-menu-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-top: 8px;
}

.project-menu-label:first-child {
  margin-top: 0;
}

.project-menu-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.project-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}

.project-color-swatch:hover {
  transform: scale(1.15);
}

.project-color-swatch.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--bg-secondary);
}

.project-menu-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.project-icon-option {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  color: var(--text-secondary);
  transition: border-color 0.15s, transform 0.15s;
}

.project-icon-option:hover {
  transform: scale(1.1);
}

.project-icon-option.active {
  border-color: var(--accent-color);
}

/* ─── Emoji Picker ─── */
.emoji-picker {
  width: 320px;
  height: 380px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.emoji-picker-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border-color);
}

.emoji-picker-name-input {
  flex: 1;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 6px;
  outline: none;
  transition: background 0.15s;
}

.emoji-picker-name-input:hover {
  background: var(--bg-tertiary);
}

.emoji-picker-name-input:focus {
  background: var(--bg-tertiary);
  outline: 1px solid var(--accent-color);
}

.emoji-picker-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.emoji-picker-delete-btn:hover {
  color: #ff7070;
  background: rgba(255, 80, 80, 0.1);
}

.emoji-picker-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.emoji-picker-tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.emoji-picker-tab:hover {
  color: var(--text-primary);
}

.emoji-picker-tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent-color);
}

.emoji-picker-search {
  margin: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  flex-shrink: 0;
}

.emoji-picker-search:focus {
  border-color: var(--accent-color);
}

.emoji-picker-search::placeholder {
  color: var(--text-muted);
}

.emoji-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.emoji-picker-category {
  margin-bottom: 8px;
}

.emoji-picker-category-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 2px;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.emoji-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.emoji-picker-item {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  transition: background 0.1s, transform 0.1s;
  border: none;
  background: transparent;
  padding: 0;
}

.emoji-picker-item:hover {
  background: var(--bg-tertiary);
  transform: scale(1.15);
}

.emoji-picker-item.active {
  background: var(--bg-tertiary);
  outline: 2px solid var(--accent-color);
  outline-offset: -1px;
}

.emoji-picker-item img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.emoji-picker-clear-btn {
  display: block;
  width: 100%;
  padding: 5px 2px;
  margin-bottom: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}

.emoji-picker-clear-btn:hover {
  color: var(--text-secondary);
}

.emoji-picker-none {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  margin-bottom: 4px;
}

.emoji-picker-none:hover {
  transform: scale(1.1);
}

.emoji-picker-none.active {
  border-color: var(--accent-color);
}

.emoji-picker-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Add tab styles */
.emoji-picker-add-section {
  padding: 4px 0;
}

.emoji-picker-add-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 2px 6px;
}

.emoji-picker-add-row {
  display: flex;
  gap: 6px;
}

.emoji-picker-add-input {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  min-width: 0;
}

.emoji-picker-add-input:focus {
  border-color: var(--accent-color);
}

.emoji-picker-add-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: var(--accent-color);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.emoji-picker-add-btn:hover {
  opacity: 0.85;
}

.emoji-picker-add-status {
  font-size: 12px;
  padding: 4px 2px;
  min-height: 20px;
}

.emoji-picker-item-addable {
  position: relative;
}

.emoji-picker-item-addable::after {
  content: '+';
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--bg-secondary);
  border-radius: 50%;
  width: 12px;
  height: 12px;
  line-height: 12px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.emoji-picker-item-addable:hover::after {
  opacity: 1;
}

/* Custom emoji in project rail / display */
.project-icon-custom {
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-icon-custom img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.setting-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-left: 24px;
}

.sub-setting {
  margin-top: 12px;
  margin-left: 24px;
  padding-left: 12px;
  border-left: 2px solid var(--border-color);
}

.sub-setting label {
  color: var(--text-secondary);
}

.sub-setting input:disabled + span,
.sub-setting input:disabled {
  opacity: 0.5;
}

.sub-setting .setting-hint {
  margin-left: 24px;
}

/* Token counter */
.token-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 12px;
}

.token-icon {
  font-size: 11px;
}

.token-value {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Responsive - Tablets and Mobile */
@media (max-width: 680px) {
  body {
    font-size: 18px;
  }

  /* Hide sidebar overflow when closed */
  .sidebar {
    overflow: hidden;
  }

  /* App layout - ensure main takes full width when sidebar hidden */
  .app {
    position: relative;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    height: 100%;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .sidebar.open {
    transform: translateX(0);
  }
  
  /* On mobile, never show collapsed state - always full width when open */
  .sidebar.collapsed {
    width: 85%;
    max-width: 320px;
  }
  
  /* Force all collapsed-hidden elements to show on mobile */
  .sidebar.collapsed .sidebar-search,
  .sidebar.collapsed .section-header,
  .sidebar.collapsed .btn-text,
  .sidebar.collapsed .completed-section,
  .sidebar.collapsed .chat-list {
    display: block;
  }

  /* Hide collapsed chat icons when sidebar is expanded on mobile */
  .chat-icons-collapsed {
    display: none;
  }
  
  .sidebar.collapsed .search-btn-collapsed {
    display: none;
  }
  
  .sidebar.collapsed .new-chat-row {
    flex-direction: column;
  }

  .sidebar.collapsed .new-chat-btn {
    padding: 12px 16px;
    justify-content: flex-start;
  }

  .sidebar.collapsed .sidebar-collapse-btn {
    width: 100%;
    height: 36px;
  }
  
  .sidebar.collapsed .cog-menu-wrapper {
    display: none;
  }
  
  .sidebar.collapsed .sidebar-footer {
    flex-direction: row;
    gap: 8px;
  }
  
  .sidebar.collapsed .collapse-btn svg {
    transform: none;
  }
  
  /* Mobile sidebar header: X button inline with New Chat, search on its own row */
  .sidebar .sidebar-header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .sidebar .new-chat-row {
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
    width: auto;
  }

  .sidebar .mobile-close-btn {
    display: flex;
    order: 2;
    flex-shrink: 0;
    align-self: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
  }

  .sidebar .search-btn-collapsed,
  .sidebar .sidebar-search {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }

  .sidebar .mobile-close-btn span {
    display: none;
  }
  
  .sidebar .mobile-close-btn:hover {
    background: var(--bg-tertiary);
  }
  
  .sidebar .mobile-close-btn svg {
    width: 16px;
    height: 16px;
  }
  
  /* Hide footer collapse button on mobile (we use the top one) */
  .sidebar .collapse-btn {
    display: none;
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* Main content takes full width */
  .main {
    width: 100%;
    margin-left: 0 !important;
  }

  .menu-btn {
    display: flex;
  }

  .menu-btn .menu-hamburger {
    display: none;
  }

  /* Hide project label in header on mobile — not enough space */
  .header-project-label,
  .header-title-sep {
    display: none;
  }

  .menu-btn .menu-project-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
  }

  .message {
    padding: 10px 12px;
    max-width: 100%;
  }

  .header {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .title {
    font-size: 18px;
  }


  /* Input area - fixed at bottom */
  .input-area {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
  }

  .input-area .agent-chat__composer-combobox > textarea[data-ref="messageInput"] {
    font-size: 16px !important; /* 16px prevents iOS zoom */
    padding: 12px;
    min-height: 48px;
  }

  /* Messages - leave room for fixed input */
  .messages {
    padding: 12px;
    padding-bottom: calc(var(--scroll-nav-clearance) + var(--attachment-overlay-h, 0px));
  }

  .message {
    padding: 6px 16px;
  }

  .message.user .message-content {
    max-width: 88%;
    font-size: 15px !important;
  }

  .message.assistant .message-content {
    font-size: 15px !important;
    line-height: 1.7 !important;
  }

  .message-role {
    font-size: 13px !important;
  }

  .code-block {
    font-size: 13px;
  }

  .code-block pre {
    padding: 12px;
    overflow-x: auto;
  }

  /* Welcome screen */
  .welcome h2 {
    font-size: 24px;
  }

  .welcome p {
    font-size: 16px;
  }

  /* Modals - full screen on mobile */
  .modal-content {
    width: 95%;
    max-width: none;
    max-height: 90vh;
    margin: 5vh auto;
  }

  .modal-body {
    max-height: 70vh;
    overflow-y: auto;
  }

  .setup-wizard {
    width: 95%;
  }

  .settings-actions {
    flex-direction: column;
  }

  .settings-actions button {
    width: 100%;
  }

  /* Search modal */
  .search-container {
    width: 95%;
    max-height: 80vh;
  }

  /* Chat list items - larger touch targets */
  .chat-item {
    padding: 14px 16px;
    font-size: 16px;
  }

  /* Action buttons on messages - always visible on touch (specificity: see the (hover: none) rule) */
  .message.user .message-actions,
  .message.assistant .message-actions {
    opacity: 1;
  }

  .msg-action-btn {
    min-width: 40px;
    min-height: 36px;
    padding: 8px;
  }

  /* Status indicator */
  .status {
    font-size: 13px;
    padding: 4px 8px;
  }
  
  .chat-item {
    font-size: 16px;
  }
  
  .new-chat-btn {
    font-size: 16px;
  }
}

/* Safe area padding is handled in base .input-area and responsive media queries */
.sidebar {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.toast {
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* Disable text selection on UI elements for cleaner mobile experience */
.sidebar,
.header,
.message-actions,
.settings-actions {
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection in messages and the header's project / chat title */
.header .title,
.message-content {
  -webkit-user-select: text;
  user-select: text;
}

/* Smooth scrolling on iOS */
.messages,
.chat-list,
.modal-body {
  -webkit-overflow-scrolling: touch;
}

/* Medium screens: foldables, small tablets (481-768px) */
@media (min-width: 481px) and (max-width: 680px) {
  /* Keep collapsed sidebar as thin strip instead of hiding offscreen */
  .sidebar.collapsed {
    position: static;
    transform: none;
    width: 60px;
    max-width: 60px;
    box-shadow: none;
  }

  /* Restore desktop collapsed behavior */
  .sidebar.collapsed .sidebar-search,
  .sidebar.collapsed .section-header,
  .sidebar.collapsed .btn-text,
  .sidebar.collapsed .expand-pinned-btn,
  .sidebar.collapsed .completed-section,
  .sidebar.collapsed .chat-list {
    display: none;
  }

  .sidebar.collapsed .chat-icons-collapsed {
    display: flex !important;
  }

  .sidebar.collapsed .search-btn-collapsed {
    display: flex;
  }

  .sidebar.collapsed .new-chat-row {
    flex-direction: column;
  }

  .sidebar.collapsed .new-chat-btn {
    padding: 12px;
    justify-content: center;
  }

  .sidebar.collapsed .sidebar-collapse-btn {
    width: 100%;
    height: 34px;
  }

  .sidebar.collapsed .mobile-close-btn {
    display: none;
  }

  .sidebar.collapsed .sidebar-footer {
    flex-direction: column;
    gap: 4px;
  }

  .sidebar.collapsed .cog-menu-wrapper {
    display: none;
  }

  .sidebar.collapsed .collapse-btn {
    display: flex;
  }

  .sidebar.collapsed .collapse-btn svg {
    transform: rotate(180deg);
  }

  .sidebar.collapsed .sidebar-header {
    padding: 8px;
  }
}

/* Small phones and folded foldables (Samsung Fold outer screen ~280px) */
@media (max-width: 480px) {
  /* On small phones, project rail is fixed alongside sidebar overlay */
  .project-rail {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    border-right: none;
    background: var(--bg-secondary);
    padding-top: env(safe-area-inset-top, 0px);
  }

  .project-rail.open {
    transform: translateX(0);
  }

  /* Shift sidebar right when project rail is open */
  .sidebar.open {
    left: 52px;
    width: calc(85% - 52px);
  }

  /* When sidebar is open on small screens, force expanded view even if collapsed class is set */
  .sidebar.open.collapsed {
    width: calc(85% - 52px);
    max-width: 280px;
  }

  .sidebar.open.collapsed .sidebar-search,
  .sidebar.open.collapsed .section-header,
  .sidebar.open.collapsed .btn-text,
  .sidebar.open.collapsed .chat-list {
    display: block;
  }

  .sidebar.open.collapsed .chat-icons-collapsed {
    display: none;
  }

  .sidebar.open.collapsed .search-btn-collapsed {
    display: none;
  }

  .sidebar.open.collapsed .new-chat-btn {
    padding: 12px 16px;
    justify-content: flex-start;
  }

  body {
    font-size: 17px;
  }

  .message {
    padding: 8px 10px;
  }

  /* Larger, more readable text on small screens */
  .message-content {
    font-size: 16px !important;
    line-height: 1.6 !important;
    word-break: break-word;
  }

  .input-area {
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }

  .input-area .agent-chat__composer-combobox > textarea[data-ref="messageInput"] {
    font-size: 16px !important;
    min-height: 44px;
    padding: 10px 8px;
  }

  .modal-content {
    width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
  }

  .modal-body {
    max-height: calc(100vh - 60px);
    padding: 16px;
  }

  /* Code blocks */
  .code-block pre {
    padding: 10px;
    font-size: 12px;
  }

  /* Compact header */
  .header {
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  .title {
    font-size: 16px;
  }

  /* Stack setup steps */
  .setup-step-content {
    padding-left: 0;
    margin-top: 12px;
  }

  .ask-openclaw-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .ask-phrase {
    width: 100%;
    text-align: center;
  }

  /* Sidebar narrower on small screens */
  .sidebar {
    width: 90%;
    max-width: 280px;
  }
  
  /* Welcome */
  .welcome h2 {
    font-size: 22px;
  }
  
  .welcome p {
    font-size: 14px;
    padding: 0 16px;
  }
}

/* Very narrow screens (folded foldables, small phones) */
@media (max-width: 320px) {
  .message-content {
    font-size: 15px !important;
    line-height: 1.5 !important;
  }

  .header {
    padding: 8px 10px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }

  .title {
    font-size: 15px;
  }

  .menu-btn {
    padding: 6px;
  }

  .status {
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Data import/export buttons */
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.data-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.data-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.data-btn svg {
  width: 16px;
  height: 16px;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success {
  background: var(--accent-color);
  color: white;
}

.toast-error {
  background: #ef4444;
  color: white;
}

/* Collapsed sidebar state */
/* Collapsed chat icons — hidden by default, shown when sidebar collapsed */
.chat-icons-collapsed {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  scrollbar-width: none;
}

.chat-icons-collapsed::-webkit-scrollbar {
  display: none;
}

.chat-icon-item {
  width: 36px;
  height: 32px;
  min-height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  position: relative;
}

.chat-icon-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-icon-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-icon-item.active::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--accent-color);
  border-radius: 0 3px 3px 0;
}

.chat-icon-item.pinned {
  color: var(--text-secondary);
}

.chat-icon-item.pinned:hover {
  color: var(--text-primary);
}

.chat-icon-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: uppercase;
}

/* Unread dot on collapsed chat icons */
.chat-icon-unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 0 2px var(--bg-primary);
  pointer-events: none;
}

.sidebar.collapsed {
  width: 60px;
}

/* Search button - only visible when collapsed */
.search-btn-collapsed {
  display: none;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.search-btn-collapsed:hover {
  background: var(--bg-tertiary);
}

.search-btn-collapsed svg {
  width: 16px;
  height: 16px;
}

.sidebar.collapsed .search-btn-collapsed {
  display: flex;
}

.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .section-header,
.sidebar.collapsed .btn-text,
.sidebar.collapsed .expand-pinned-btn,
.sidebar.collapsed .completed-section,
.sidebar.collapsed .chat-list {
  display: none;
}

.sidebar.collapsed .chat-icons-collapsed {
  display: flex;
}

.sidebar.collapsed .new-chat-row {
  flex-direction: column;
}

.sidebar.collapsed .new-chat-btn {
  padding: 12px;
  justify-content: center;
}

/* Collapsed strip: expand, new chat and search are one stack of equal squares, evenly spaced */
.sidebar.collapsed .sidebar-collapse-btn {
  order: -1;
  width: 100%;
  height: 36px;
}

.sidebar.collapsed #newChatBtn,
.sidebar.collapsed .search-btn-collapsed {
  flex: none;
  height: 36px;
  padding: 0;
}

.sidebar.collapsed .search-btn-collapsed {
  margin-top: 6px;
}

.sidebar.collapsed .cog-menu-wrapper {
  display: none;
}

.sidebar.collapsed .collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-footer {
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}

.sidebar.collapsed .sidebar-header {
  padding: 8px;
}

/* Mobile close button - hidden on desktop */
.mobile-close-btn {
  display: none;
}

/* Smooth width transition */
.main {
  transition: margin-left 0.2s ease;
}

/* Setup Wizard */
.setup-wizard {
  max-width: 480px;
}

.setup-wizard .modal-header h2 {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-intro {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.setup-step {
  margin-top: 24px;
}

.setup-actions {
  display: flex;
  justify-content: center;
}

.setup-save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 15px;
}

.setup-success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.setup-success-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-color, #10a37f);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.setup-success-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--accent-text);
}

.setup-path {
  background: var(--input-bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

.setup-fallback {
  margin-top: 24px;
}

.setup-fallback-instructions {
  background: var(--input-bg);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.setup-fallback-instructions p {
  margin: 0 0 8px 0;
}

.setup-fallback-instructions code {
  display: block;
  background: var(--bg-color);
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  word-break: break-all;
  margin: 12px 0;
}

.setup-hint {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-top: 8px;
}

.setup-config-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(16, 163, 127, 0.1);
  border-radius: 8px;
  color: var(--accent-text);
  margin-bottom: 16px;
}

.setup-config-status svg {
  width: 20px;
  height: 20px;
}

.setup-folder-info {
  background: var(--input-bg);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}

.setup-folder-info p {
  margin: 0 0 10px 0;
  font-size: 14px;
}

.setup-folder-info code {
  display: block;
  background: var(--bg-color);
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  word-break: break-all;
  color: var(--accent-text);
}

/* Token help dropdown */
.token-help {
  margin-top: 8px;
  font-size: 13px;
}

.token-help summary {
  cursor: pointer;
  color: var(--accent-text);
  user-select: none;
}

.token-help summary:hover {
  text-decoration: underline;
}

.token-help-content {
  margin-top: 12px;
  padding: 12px;
  background: var(--input-bg);
  border-radius: 8px;
}

.token-help-content p {
  margin: 0 0 8px 0;
  color: var(--text-secondary);
}

.token-help-content .config-path {
  display: block;
  padding: 8px 12px;
  background: var(--bg-color);
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 12px;
}

.copy-command {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-color);
  border-radius: 4px;
  padding: 4px 4px 4px 12px;
  margin-bottom: 12px;
}

.copy-command code {
  flex: 1;
  font-size: 11px;
  overflow-x: auto;
  white-space: nowrap;
}

.copy-cmd-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.copy-cmd-btn:hover {
  background: var(--border-color);
}

.token-help-link {
  margin-top: 12px;
  margin-bottom: 0 !important;
}

.token-help-link a {
  color: var(--accent-text);
  text-decoration: none;
}

.token-help-link a:hover {
  text-decoration: underline;
}

.gateway-status {
  position: absolute;
  right: 12px;
  font-size: 16px;
}

.gateway-status.checking::after {
  content: "⏳";
}

.gateway-status.online::after {
  content: "✓";
  color: var(--accent-text);
}

.gateway-status.offline::after {
  content: "✗";
  color: #ef4444;
}

#gatewayHint.online {
  color: var(--accent-text);
}

#gatewayHint.offline {
  color: #ef4444;
}

.open-control-btn {
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.open-control-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.token-help-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.get-token-btn {
  background: var(--accent-color, #10a37f);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.15s;
}

.get-token-btn:hover {
  opacity: 0.9;
}

.token-help-or {
  color: var(--text-muted, #888);
  font-size: 12px;
}

.token-help-inline .token-help {
  margin-top: 0;
}

.token-help-inline .token-help summary {
  font-size: 12px;
}

.token-help-text {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.token-copy-cmd {
  margin-bottom: 8px;
}

.token-help-alt {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin: 0;
}

.token-help-alt .alt-cmd {
  display: inline;
  background: var(--input-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
}

.hidden-files-hint {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin: 8px 0 0 0;
  font-style: italic;
}

.openclaw-help-hint {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin: 12px 0 0 0;
  padding: 8px 12px;
  background: var(--input-bg, rgba(var(--ink), 0.05));
  border-radius: 6px;
  border-left: 3px solid var(--accent-color, #10a37f);
}

.openclaw-help-hint strong {
  color: var(--accent-text);
  font-family: monospace;
  background: rgba(16, 163, 127, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.token-help-text em {
  background: var(--input-bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-style: normal;
}

/* Setup Wizard - Step boxes */
.setup-step-box {
  background: var(--input-bg, rgba(var(--ink), 0.05));
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.setup-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.setup-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-color, #10a37f);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.setup-step-title {
  font-weight: 600;
  font-size: 16px;
}

.setup-step-content {
  padding-left: 40px;
}

/* Ask OpenClaw row */
.ask-openclaw-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ask-label {
  font-size: 14px;
  color: var(--text-secondary, #888);
}

.ask-phrase {
  background: var(--bg-color, #1a1a1a);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--accent-text);
  font-family: inherit;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border-color, #444);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-secondary, #888);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: var(--input-bg);
  color: var(--accent-text);
  border-color: var(--accent-color, #10a37f);
}

.copy-btn.copied {
  background: var(--accent-color, #10a37f);
  color: white;
  border-color: var(--accent-color, #10a37f);
}

/* Token input */
.token-input-wrapper {
  position: relative;
}

.token-input-wrapper input {
  width: 100%;
  padding: 12px;
  padding-right: 40px;
  border: 1px solid var(--border-color, #444);
  border-radius: 8px;
  background: var(--bg-color, #1a1a1a);
  color: var(--text-color, #fff);
  font-size: 14px;
}

.token-input-wrapper input:focus {
  outline: none;
  border-color: var(--accent-color, #10a37f);
}

.token-status {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
}

/* Setup folder instructions */
.setup-folder-instructions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color, #333);
}

.setup-folder-instructions p {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: var(--text-secondary, #888);
}

.setup-folder-hint {
  font-size: 13px;
  color: var(--text-muted, #666);
  margin-top: 8px;
}

.setup-refresh-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted, #666);
  margin-top: 12px;
}

/* Setup intro */
.setup-intro {
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-secondary);
}

/* Header button */

/* Artifacts Button */
.artifacts-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.artifacts-btn:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--accent-text);
}

.artifacts-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.artifacts-btn svg {
  width: 20px;
  height: 20px;
}

.artifacts-btn.active {
  color: var(--accent-text);
  background: rgba(16, 163, 127, 0.15);
}

.artifacts-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--accent-color);
  color: white;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 16px;
  text-align: center;
}

/* Panel */
/* Right Panel (Artifacts + Workspace) */
/* ============================================================
   RIGHT PANEL — OVERLAY DRAWER
   Pure translateX animation. Width is always fixed at 420px.
   Inner content never reflows = no squeezing, ever.
   ============================================================ */

/* ============================================================
   Document Pane — split view alongside chat
   ============================================================ */

.doc-pane {
  display: none;
  flex-direction: column;
  width: 44%;
  min-width: 280px;
  max-width: 75%;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.doc-pane.open {
  display: flex;
}

/* Draggable resize handle — left edge of pane */
.doc-pane-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}

.doc-pane-resize:hover,
.doc-pane-resize.dragging {
  background: var(--accent, #4caf50);
}

/* Header */
.doc-pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 44px;
  min-height: 44px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.doc-pane-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: 3px;
  padding: 2px 5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.doc-pane-filename {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-pane-header-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.doc-pane-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.doc-pane-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.doc-pane-btn:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
  color: var(--text-muted);
}

.doc-pane-btn.copied {
  color: var(--accent-text);
}

.doc-pane-btn.active {
  color: var(--accent-text);
  background: color-mix(in srgb, var(--accent, #4caf50) 12%, transparent);
}

.doc-pane-close-btn:hover {
  color: #ff4444;
  background: rgba(255, 68, 68, 0.1);
}

.doc-pane-esc-hint {
  font-size: 10px;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 5px;
  opacity: 0.6;
  user-select: none;
  cursor: default;
  letter-spacing: 0.3px;
}

/* Body — renderer container */
.doc-pane-body {
  flex: 1;
  overflow: auto;
  position: relative;
}

.doc-pane-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* A page with no background of its own renders on white, as in a browser tab */
.doc-pane-body iframe.doc-pane-html-preview {
  background: #fff;
}

/* Markdown renderer */
.doc-pane-markdown {
  padding: 20px 24px;
  line-height: 1.7;
  font-size: 14px;
  max-width: 800px;
}

/* Code renderer */
.doc-pane-body pre {
  margin: 0;
  padding: 20px 24px;
  font-size: 13px;
  min-height: 100%;
  box-sizing: border-box;
}

.doc-pane-body pre code {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Line a file link pointed at (notes.md:42): a band that fades out. */
.doc-pane-line-flash {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--accent-color) 22%, transparent);
  animation: doc-pane-line-flash 2.4s ease-out forwards;
}
@keyframes doc-pane-line-flash {
  0%, 40% { opacity: 1; }
  100% { opacity: 0; }
}

/* States */
.doc-pane-loading,
.doc-pane-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
}

.doc-pane-error {
  color: #ff6b6b;
}

.doc-pane-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}

.doc-pane-empty-state svg {
  opacity: 0.35;
}

.doc-pane-empty-state p {
  margin: 0;
  font-size: 14px;
}

.doc-pane-hint {
  font-size: 12px;
  opacity: 0.6;
}

.doc-pane-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: inherit;
  font-size: 11px;
  background: var(--bg-tertiary);
}

/* Edit mode */
.doc-pane-edit-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
  gap: 10px;
  box-sizing: border-box;
}

.doc-pane-textarea {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono, 'Fira Code', 'Cascadia Code', monospace);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}

.doc-pane-textarea:focus {
  border-color: var(--accent, #4caf50);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #4caf50) 15%, transparent);
}

/* General-purpose button primitives */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

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

.btn-primary:hover {
  filter: brightness(1.1);
  border-color: transparent;
}

.doc-pane-edit-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Mobile: full-screen takeover — no room for split pane */
@media (max-width: 680px) {
  .split-pane-btn {
    display: none;
  }

  .doc-pane.open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100%;
    z-index: 800;
    border-left: none;
  }

  .doc-pane-resize {
    display: none;
  }
}

/* 1. Panel: fixed position, fixed width, slides via translateX only */
:root {
  --right-panel-width: 420px;
}

.right-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: var(--right-panel-width);
  min-width: 320px;
  overflow: hidden;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.35s ease;
  box-shadow: none;
}

/* 2. Open state: slide in, add depth shadow */
.right-panel.open {
  width: var(--right-panel-width);
  min-width: 320px;
  transform: translateX(0%);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
}

/* Resize handle */
.right-panel-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}

.right-panel-resize-handle:hover,
.right-panel-resize-handle.dragging {
  background: var(--accent-color, #1f6feb);
}

/* Panel Tabs */
/* 3. Tabs bar: never shrink, always full width */
.right-panel-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-secondary);
}

.right-panel-tab {
  flex: 1;
  flex-shrink: 1 !important;
  min-width: 0 !important;
  white-space: nowrap !important;
  padding: 12px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  position: relative;
}

.right-panel-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.right-panel-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-color);
}

.right-panel-tab .tab-badge {
  background: var(--accent-color);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}

.right-panel-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.right-panel-close-btn:hover {
  color: #ef4444;
  background: var(--bg-tertiary);
}

.right-panel-close-btn svg {
  width: 16px;
  height: 16px;
}

/* 4. All panel content areas: never shrink */
.panel-content {
  flex: 1;
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Panel header */

/* Panel body */

/* Controls section */

/* Results area */

/* Footer */

/* File content rendering */

/* Loading spinner */

@keyframes intel-spin {
  to { transform: rotate(360deg); }
}

/* Topic cards */

/* (v1 section styles removed — replaced by file content rendering) */

/* Card action buttons */

/* Responsive: mobile full-width panel */
@media (max-width: 680px) {
  .right-panel.open {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    min-width: 100% !important;
    z-index: 1001;
  }

  .right-panel-resize-handle {
    display: none;
  }
}

/* ========================================
   Artifacts Panel
   ======================================== */

.artifacts-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.artifacts-panel-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.artifacts-panel-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.artifacts-list {
  flex: 1;
  padding: 16px;
}

.artifacts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.artifacts-empty svg {
  opacity: 0.3;
}

.artifacts-empty p {
  font-size: 14px;
  margin: 0;
}

.artifacts-empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Artifact Card */
.artifact-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.artifact-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  gap: 8px;
  cursor: pointer;
}

.artifact-card-header:hover {
  background: var(--bg-secondary);
}

.artifact-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.artifact-type-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.artifact-type-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent-color);
}

.artifact-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-type-badge {
  font-size: 10px;
  background: var(--accent-color);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.artifact-card-toggle {
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.artifact-card-toggle svg {
  width: 14px;
  height: 14px;
}

.artifact-card.collapsed .artifact-card-toggle {
  transform: rotate(-90deg);
}

.artifact-card-body {
  padding: 0;
  max-height: 500px;
  overflow: auto;
}

.artifact-card.collapsed .artifact-card-body {
  display: none;
}

/* Artifact Actions */
.artifact-actions {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.artifact-action-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s;
  white-space: nowrap;
}

.artifact-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.artifact-action-btn svg {
  width: 12px;
  height: 12px;
}

.artifact-action-btn.primary {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.artifact-action-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Artifact Content Renderers */
.artifact-code-block {
  position: relative;
}

.artifact-code-block pre {
  margin: 0;
  border-radius: 0;
  background: #1e1e1e;
  padding: 14px;
  overflow-x: auto;
}

[data-theme="light"] .artifact-code-block pre {
  background: var(--bg-secondary);
}

.artifact-code-block code {
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.artifact-preview-iframe {
  width: 100%;
  min-height: 300px;
  border: none;
  background: white;
}

.artifact-markdown-preview {
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.artifact-markdown-preview h1,
.artifact-markdown-preview h2,
.artifact-markdown-preview h3,
.artifact-markdown-preview h4 {
  color: var(--text-primary);
  margin: 12px 0 8px;
}

.artifact-markdown-preview h1 { font-size: 18px; }
.artifact-markdown-preview h2 { font-size: 16px; }
.artifact-markdown-preview h3 { font-size: 14px; }
.artifact-markdown-preview h4 { font-size: 13px; }

.artifact-markdown-preview p {
  margin: 8px 0;
}

.artifact-markdown-preview code {
  background: var(--bg-tertiary);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  font-size: 12px;
}

.artifact-markdown-preview pre {
  background: #1e1e1e;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

[data-theme="light"] .artifact-markdown-preview pre {
  background: var(--bg-secondary);
}

.artifact-markdown-preview ul,
.artifact-markdown-preview ol {
  padding-left: 20px;
  margin: 8px 0;
}

.artifact-markdown-preview li {
  margin: 4px 0;
}

.artifact-mermaid-diagram {
  padding: 20px;
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.artifact-table-container {
  overflow-x: auto;
  padding: 14px;
}

.artifact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.artifact-table th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
}

.artifact-table td {
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.artifact-table tr:nth-child(even) {
  background: var(--bg-secondary);
}

.artifact-view-toggle {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.artifact-view-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.15s;
}

.artifact-view-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.artifact-view-btn.active {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* ========================================
   Workspace Panel
   ======================================== */

.workspace-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.workspace-panel-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.workspace-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.workspace-header-btn,
.workspace-refresh-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.workspace-header-btn:hover,
.workspace-refresh-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-text);
}

.workspace-header-btn svg,
.workspace-refresh-btn svg {
  width: 16px;
  height: 16px;
}

.workspace-panel-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.workspace-path-bar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.workspace-path-up-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.workspace-path-up-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-text);
}

.workspace-path-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
}

.workspace-path-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.workspace-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  transition: background 0.15s;
}

.workspace-tree.workspace-drop-active {
  background: var(--accent-color-10, rgba(99, 102, 241, 0.1));
  border: 2px dashed var(--accent-color, #6366f1);
  border-radius: 8px;
  margin: 4px;
}

/* File manager items */
.workspace-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  border-bottom: 1px solid var(--border-color-subtle, rgba(var(--ink), 0.04));
}

.workspace-file-item:hover {
  background: var(--bg-tertiary);
}

.workspace-file-item:active {
  background: var(--bg-quaternary, rgba(var(--ink), 0.08));
}

.workspace-file-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.workspace-file-dir .workspace-file-icon {
  color: var(--accent-text);
}

.workspace-file-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.workspace-file-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.7;
}

.workspace-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}

.workspace-empty svg {
  opacity: 0.3;
}

.workspace-empty p {
  font-size: 14px;
  margin: 0;
}

.workspace-empty-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.workspace-viewer {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.workspace-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.workspace-viewer-filename {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
}

.workspace-viewer-actions {
  display: flex;
  gap: 4px;
}

.workspace-viewer-action-btn,
.workspace-viewer-edit-btn,
.workspace-viewer-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.workspace-viewer-action-btn:hover,
.workspace-viewer-edit-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-text);
}

.workspace-viewer-close-btn:hover {
  background: var(--bg-tertiary);
  color: #ef4444;
}

.workspace-viewer-content {
  flex: 1;
  overflow: auto;
  background: #1e1e1e;
  padding: 0;
}

[data-theme="light"] .workspace-viewer-content {
  background: var(--bg-secondary);
}

.workspace-viewer-content pre {
  margin: 0;
  padding: 16px;
  background: transparent;
}

.workspace-viewer-content code {
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.workspace-editor {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.workspace-editor textarea {
  flex: 1;
  background: #1e1e1e;
  color: var(--text-primary);
  border: none;
  padding: 16px;
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: none;
}

[data-theme="light"] .workspace-editor textarea {
  background: var(--bg-secondary);
}

.workspace-editor textarea:focus {
  outline: none;
}

.workspace-editor-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  justify-content: flex-end;
  flex-shrink: 0;
}

.workspace-editor-save-btn,
.workspace-editor-cancel-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.workspace-editor-save-btn {
  background: var(--accent-color);
  color: white;
}

.workspace-editor-save-btn:hover {
  background: var(--accent-hover);
}

.workspace-editor-cancel-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.workspace-editor-cancel-btn:hover {
  background: var(--border-color);
}

.workspace-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  position: relative;
}

.workspace-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.workspace-btn.active {
  background: var(--bg-tertiary);
  color: var(--accent-text);
}

.workspace-btn svg {
  width: 18px;
  height: 18px;
}

.split-pane-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.split-pane-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.split-pane-btn.active {
  background: var(--bg-tertiary);
  color: var(--accent-text);
}

.split-pane-btn svg {
  width: 18px;
  height: 18px;
}

/* ===== File Attachments (from assistant) ===== */
.message-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* Attachment card (for documents, archives, etc.) */
.attachment-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
  max-width: 400px;
}

.attachment-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

.attachment-card-openable {
  cursor: pointer;
}

/* Pasted text (frontend/chat/pasted-text.js): the Control UI's chip (generated composer CSS,
   .chat-attachment-thumb--pasted-text) in the attachment row, so the tile frame stays off */
.image-preview-item.pasted-text-item {
  width: auto;
  height: auto;
  align-self: center;
  border: none;
  border-radius: 0;
  overflow: visible;
}

/* A sent paste: a chip with its excerpt, like a sent selection comment */
.message-attachments > .message-pasted-chip {
  align-self: flex-start;
  max-width: 100%;
}

.attachment-card-openable:hover {
  border-color: var(--accent-color);
  background: var(--bg-tertiary);
}

.attachment-open-hint {
  font-size: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
}

.attachment-card-openable:hover .attachment-open-hint {
  color: var(--accent-text);
  transform: translate(2px, -2px);
}

.attachment-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.attachment-info {
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-size {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* --danger is scoped to a few containers (composer-tokens.css); same values here. */
.attachment-card { --danger: #ef4444; }
[data-theme="light"] .attachment-card { --danger: #b91c1c; }

.attachment-status-error {
  color: var(--danger);
  white-space: normal;
}

.attachment-download-btn {
  background: var(--accent-color);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.attachment-download-btn:hover {
  background: var(--accent-hover);
}

/* Attachment image preview */
.attachment-image {
  max-width: 400px;
}

.attachment-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border-color);
}

.attachment-img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Attachment audio player */
.attachment-audio {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-width: 400px;
}

.attachment-audio-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attachment-audio-header .attachment-icon {
  font-size: 20px;
}

.attachment-audio-header .attachment-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}

.attachment-audio-header .attachment-size {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
}

.attachment-audio-player {
  width: 100%;
  height: 32px;
  outline: none;
}

.attachment-audio-player::-webkit-media-controls-panel {
  background: var(--bg-tertiary);
}

/* Mobile responsive for attachments */
@media (max-width: 680px) {
  .attachment-card,
  .attachment-audio,
  .attachment-image {
    max-width: 100%;
  }
}

/* Session Dashboard */
.session-dashboard {
  position: fixed;
  left: var(--sidebar-width);
  top: 0;
  bottom: 0;
  width: 400px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.session-dashboard.hidden {
  transform: translateX(-100%);
}

.session-dashboard-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.session-dashboard-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.session-dashboard-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.session-dashboard-close:hover {
  background: var(--bg-tertiary);
}

.session-dashboard-close svg {
  width: 20px;
  height: 20px;
}

.session-dashboard-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.session-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.session-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

.session-card.active {
  border-color: var(--accent-color);
  background: rgba(16, 163, 127, 0.05);
}

.session-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.session-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-status-indicator.active {
  background: #10a37f;
  box-shadow: 0 0 8px rgba(16, 163, 127, 0.5);
}

.session-status-indicator.idle {
  background: #8e8e8e;
}

.session-card-model {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: 4px;
}

.session-card-body {
  margin-bottom: 8px;
}

.session-card-preview {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.session-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.session-card-tokens {
  display: flex;
  align-items: center;
  gap: 4px;
}

.session-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.session-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.session-error {
  text-align: center;
  padding: 40px 20px;
  color: #ef4444;
}

/* Mobile responsive for session dashboard */
@media (max-width: 680px) {
  .session-dashboard {
    left: 0;
    width: 100%;
    z-index: 101;
  }
}

/* Collapsed sidebar adjustments */
.sidebar.collapsed ~ .session-dashboard {
  left: 60px;
}

/* ========================================
   Toast Notification System
   ======================================== */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-height: calc(100vh - 32px);
}

.toast-notification {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  cursor: pointer;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast-notification.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-notification.fade-out {
  transform: translateX(120%);
  opacity: 0;
}

.toast-notification:hover {
  border-color: var(--accent-color);
}

.toast-notification-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--accent-text);
  margin-top: 1px;
}

.toast-notification.toast-type-warning .toast-notification-icon {
  color: #f59e0b;
}

.toast-notification.toast-type-error .toast-notification-icon {
  color: #ef4444;
}

.toast-notification.toast-type-success .toast-notification-icon {
  color: var(--accent-text);
}

.toast-notification-body {
  flex: 1;
  min-width: 0;
}

.toast-notification-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-notification-message {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-notification-action {
  flex-shrink: 0;
  align-self: center;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.toast-notification-action:hover,
.toast-notification-action:focus-visible {
  background: rgba(var(--ink), 0.1);
}

.toast-notification-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.toast-notification:hover .toast-notification-close {
  opacity: 1;
}

.toast-notification-close:hover {
  color: var(--text-primary);
  background: rgba(var(--ink), 0.1);
}

.toast-notification-close svg {
  width: 14px;
  height: 14px;
}

/* ========================================
   Notification Bell
   ======================================== */

.notification-bell-wrapper {
  position: relative;
}

.notification-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.notification-bell:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.notification-bell svg {
  width: 20px;
  height: 20px;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #ef4444;
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* ========================================
   Notification Dropdown
   ======================================== */

.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  width: 340px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.notification-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.notification-clear-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.notification-dropdown-body {
  overflow-y: auto;
  max-height: 356px;
}

.notification-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item:hover {
  background: var(--bg-tertiary);
}

.notification-item.unread {
  background: rgba(16, 163, 127, 0.05);
}

.notification-item-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--accent-text);
  margin-top: 2px;
}

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

.notification-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-item-message {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.notification-item-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Tool Call Cards */
.tool-call-card {
  border-radius: 8px;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-color);
  background: var(--bg-secondary);
  margin: 12px 0;
  overflow: hidden;
}

.tool-call-card.tool-status-error {
  border-left-color: #ef4444;
}

.tool-call-card.tool-status-running {
  border-left-color: #f59e0b;
}

.tool-call-card.tool-status-success {
  border-left-color: var(--accent-color);
}

.tool-call-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.tool-call-header:hover {
  background: var(--bg-tertiary);
}

.tool-call-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.tool-call-name {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.tool-call-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.tool-call-card.expanded .tool-call-chevron {
  transform: rotate(180deg);
}

.tool-call-body {
  display: none;
  border-top: 1px solid var(--border-color);
  padding: 12px 14px;
}

.tool-call-card.expanded .tool-call-body {
  display: block;
}

.tool-call-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.tool-call-params pre,
.tool-call-result pre {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-primary);
  padding: 10px 12px;
  border-radius: 6px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

.tool-call-result {
  margin-top: 10px;
  position: relative;
}

.tool-call-result pre {
  max-height: 300px;
  overflow-y: auto;
}

.tool-call-copy-btn {
  position: absolute;
  top: 28px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: #888;
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s;
}

.tool-call-result:hover .tool-call-copy-btn {
  opacity: 1;
}

.tool-call-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.tool-call-copy-btn svg {
  width: 14px;
  height: 14px;
}

.tool-call-copy-btn.copied {
  color: var(--accent-text);
  opacity: 1;
}

/* Light theme overrides */
[data-theme="light"] .tool-call-copy-btn {
  background: rgba(var(--ink), 0.05);
  color: var(--text-muted);
}

[data-theme="light"] .tool-call-copy-btn:hover {
  background: rgba(var(--ink), 0.1);
  color: var(--text-secondary);
}

@media (max-width: 680px) {
  .tool-call-card {
    margin: 8px 0;
  }

  .tool-call-header {
    padding: 8px 10px;
  }

  .tool-call-body {
    padding: 8px 10px;
  }

  .tool-call-params pre,
  .tool-call-result pre {
    font-size: 11px;
    padding: 8px;
  }
}

/* --- Markdown images in chat messages (Control UI styles/chat/text.css) --- */

.message-content .markdown-inline-image-button {
  display: block;
  max-width: min(100%, 420px);
  margin-top: 0.75em;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
}

.message-content .markdown-inline-image-button:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 3px;
}

.message-content .markdown-inline-image {
  display: block;
  max-width: min(100%, 420px);
  max-height: 320px;
  width: auto;
  height: auto;
  margin-top: 0.75em;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  object-fit: contain;
}

.message-content .markdown-inline-image-button > .markdown-inline-image {
  margin-top: 0;
}

/* The agent's caption for an image it placed in its text (ClawChats extra). */
.message-content .markdown-image-caption {
  display: block;
  margin-top: 1em;
  color: var(--text-secondary);
  font-size: 0.9em;
}

.message-content .markdown-image-caption + .markdown-inline-image-button {
  margin-top: 0.35em;
}

.message-content .markdown-external-image {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35em 0.75em;
  width: 100%;
  max-width: 100%;
  margin-top: 0.75em;
  padding: 0.7em 0.8em;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.message-content .markdown-external-image > a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
  color: var(--link-color);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
}

/* --- Image Gallery in Artifacts Panel --- */

.image-gallery-section {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.image-gallery-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.image-gallery-header svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.image-gallery-count {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: auto;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.image-thumbnail {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: border-color 0.2s, transform 0.2s;
}

.image-thumbnail:hover {
  border-color: var(--accent-color);
  transform: scale(1.03);
}

.image-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Lightbox Overlay --- */

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.92);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-overlay.open {
  display: flex;
}

.lightbox-overlay:focus { outline: none; }

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  z-index: 2;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.lightbox-close svg {
  width: 24px;
  height: 24px;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 70px;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 12px 8px;
  border-radius: 6px;
  z-index: 2;
  transition: background 0.2s;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav svg {
  width: 28px;
  height: 28px;
}

.lightbox-nav[style*="display: none"] {
  display: none !important;
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.lightbox-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  color: #ccc;
  font-size: 13px;
}

.lightbox-counter {
  color: rgba(255, 255, 255, 0.6);
}

.lightbox-download {
  position: absolute;
  top: 16px;
  right: 60px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
  z-index: 2;
}

.lightbox-download:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-download svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Lightbox loading / error states (workspace image fetch) */
.lightbox-spinner {
  display: none;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.lightbox-overlay.loading .lightbox-image {
  display: none;
}

.lightbox-overlay.loading .lightbox-spinner {
  display: block;
}

.lightbox-overlay.loading .lightbox-nav,
.lightbox-overlay.loading .lightbox-download,
.lightbox-overlay.loading .lightbox-counter {
  opacity: 0;
  pointer-events: none;
}

.lightbox-overlay.error .lightbox-image {
  display: none;
}

.lightbox-overlay.error .lightbox-content::after {
  content: 'Failed to load image';
  color: rgba(255, 255, 255, 0.45);
  font-size: 14px;
  letter-spacing: 0.02em;
}

/* Debug Recording Mode */
.status.debug-recording {
  color: #e74c3c !important;
  animation: pulse-rec 1.5s ease-in-out infinite;
}
@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Pulse Animation ───────────────────────────────────────────── */
@keyframes claude-pulse {
  0% { box-shadow: inset 0 0 10px rgba(217, 119, 87, 0.5), inset 0 0 20px rgba(217, 119, 87, 0.3), inset 0 0 30px rgba(217, 119, 87, 0.1); }
  50% { box-shadow: inset 0 0 15px rgba(217, 119, 87, 0.7), inset 0 0 25px rgba(217, 119, 87, 0.5), inset 0 0 35px rgba(217, 119, 87, 0.2); }
  100% { box-shadow: inset 0 0 10px rgba(217, 119, 87, 0.5), inset 0 0 20px rgba(217, 119, 87, 0.3), inset 0 0 30px rgba(217, 119, 87, 0.1); }
}

/* ── Activity Block (collapsible tool/thinking log) ────────────────────────── */

/* ── Activity Block ───────────────────────────────────────────── */
.activity-block {
  margin: 6px 0 12px 0 !important;
  padding: 0;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Header bar (collapsed/expanded toggle) */
.activity-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 8px;
  background: rgba(var(--ink), 0.04);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(210,210,210,0.9);
  cursor: pointer;
  transition: background 0.15s ease;
  letter-spacing: 0.01em;
}

.activity-header:hover {
  background: rgba(var(--ink), 0.07);
}

.activity-icon {
  font-size: 1em;
}

.activity-summary {
  flex: 1;
  font-style: italic;
}

.activity-chevron {
  display: inline-block !important;
  font-size: 0.8em;
  opacity: 0.5;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform: rotate(0deg) !important;
}

.activity-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: activity-pulse 1.5s ease-in-out infinite;
}

@keyframes activity-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Steps container */
.activity-steps {
  margin: 3px 0 0 8px;
  padding: 2px 0 2px 12px;
  border-left: 1.5px solid rgba(var(--ink), 0.07);
}

.activity-steps.collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

/* Every step row */
.activity-step {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1.5px 4px;
  margin: 0;
  border-radius: 4px;
  transition: background 0.1s ease;
  min-height: 20px;
}

.activity-step:hover {
  background: rgba(var(--ink), 0.04);
}

/* Narration rows (AI commentary between commands) */
.activity-step-narration {
  padding: 4px 4px;
  margin: 2px 0;
  align-items: flex-start;
}

.activity-step-narration .activity-step-icon {
  font-size: 11px;
  opacity: 0.6;
  flex-shrink: 0;
  margin-top: 1px;
}

.activity-step-narration .activity-step-text {
  font-size: 11.5px;
  color: rgba(var(--ink), 0.88);
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
}

/* Icon column */
.activity-step-icon {
  font-size: 12px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  line-height: 1;
}

/* Badge label: EXEC / READ / PROCESS */
.activity-step-name {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
  min-width: 38px;
  text-align: center;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.5;
  /* default: blue (exec) */
  color: rgba(140,180,255,0.9);
  background: rgba(100,150,255,0.1);
}

/* Badge color overrides by type */
.activity-step[data-step-type="exec"] .activity-step-name {
  color: rgba(130,185,255,0.95);
  background: rgba(80,130,255,0.12);
}

.activity-step[data-step-type="read"] .activity-step-name {
  color: rgba(180,140,255,0.95);
  background: rgba(150,100,255,0.12);
}

.activity-step[data-step-type="process"] .activity-step-name {
  color: rgba(255,190,100,0.95);
  background: rgba(255,160,60,0.12);
}

.activity-step[data-step-type="done"] .activity-step-name {
  color: rgba(100,210,130,0.95);
  background: rgba(80,200,110,0.12);
}

/* Description column — truncated by default */
.activity-step-meta {
  font-size: 11px;
  color: rgba(165,165,165,0.9);
  flex: 1 1 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
  cursor: pointer;
}

.activity-step-meta:hover {
  color: rgba(200,200,200,0.95);
}

/* Expanded state */
.activity-step-meta.expanded {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow: visible !important;
  text-overflow: unset;
  cursor: default !important;
  line-height: 1.55 !important;
  color: rgba(220,220,220,0.97) !important;
}

.activity-step-meta.expanded code,
.activity-step-meta.expanded .cmd {
  font-family: 'SF Mono', 'Fira Code', monospace !important;
  font-size: 10.5px !important;
}

/* Expanded row layout — align items to top */
.activity-step:has(.activity-step-meta.expanded) {
  align-items: flex-start !important;
}

.activity-step:has(.activity-step-meta.expanded) .activity-step-status {
  align-self: flex-start !important;
  margin-top: 1px !important;
  white-space: nowrap !important;
}

.activity-step:has(.activity-step-meta.expanded) .activity-step-icon,
.activity-step:has(.activity-step-meta.expanded) .activity-step-name {
  margin-top: 2px !important;
  flex-shrink: 0 !important;
}

/* ↕ hint — fades in on row hover, stays visible when expanded */
.activity-step-meta:not(.expanded)::after {
  content: ' ↕';
  font-size: 9px;
  opacity: 0;
  color: rgba(150,180,255,0.7);
  transition: opacity 0.15s ease;
  vertical-align: middle;
}

.activity-step:hover .activity-step-meta:not(.expanded)::after {
  opacity: 1;
}

.activity-step-meta.expanded::after {
  content: ' ↕';
  font-size: 9px;
  opacity: 0.5;
  color: rgba(150,180,255,0.7);
  vertical-align: middle;
}

/* Status/timing column — ✓ (0.0s) */
.activity-step-status {
  font-size: 10px;
  color: rgba(100,195,115,0.8);
  opacity: 1;
  flex-shrink: 0;
  margin-left: 6px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.activity-step-done {
  opacity: 0.6;
}

.activity-step-thinking {
  font-style: italic;
  opacity: 0.8;
  align-items: flex-start;
}

.activity-step-text {
  color: var(--text-secondary, #999);
  font-size: 0.9em;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
}

/* Light theme overrides */
[data-theme="light"] .activity-header:hover {
  background: rgba(var(--ink), 0.04);
}

[data-theme="light"] .activity-steps {
  border-left-color: rgba(var(--ink), 0.1);
}

/* Mobile responsive */
@media (max-width: 680px) {
  .activity-block {
    margin-left: 0;
  }
}

/* ── Auth Modal ────────────────────────────────────────────────────── */

.auth-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.auth-modal-overlay.visible {
  display: flex;
}

.auth-modal {
  background: var(--bg-secondary, #1e1e2e);
  border: 1px solid var(--border-color, #333);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.auth-modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-modal-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.auth-modal-header h2 {
  color: var(--text-primary, #e0e0e0);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.auth-step {
  margin-bottom: 20px;
}

.auth-step-label {
  color: var(--text-secondary, #aaa);
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 500;
}

.auth-google-status {
  background: var(--bg-primary, #181825);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  padding: 12px;
}

.btn-google {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background 0.2s;
}

.btn-google:hover {
  background: #f5f5f5;
}

.auth-google-success {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary, #e0e0e0);
  font-size: 14px;
}

.auth-check {
  font-size: 16px;
}

.auth-switch-link {
  color: var(--accent-text);
  font-size: 12px;
  margin-left: auto;
  text-decoration: none;
}

.auth-switch-link:hover {
  text-decoration: underline;
}

.auth-totp-input input {
  width: 100%;
  padding: 12px;
  font-size: 24px;
  letter-spacing: 8px;
  text-align: center;
  background: var(--bg-primary, #181825);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  color: var(--text-primary, #e0e0e0);
  font-family: monospace;
  box-sizing: border-box;
}

.auth-totp-input input:focus {
  outline: none;
  border-color: var(--accent-color, #7c3aed);
}

.auth-totp-hint {
  color: var(--text-secondary, #888);
  font-size: 12px;
  margin-top: 6px;
}

.auth-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary, #181825);
  border: 1px solid var(--border-color, #333);
  border-radius: 6px;
  color: var(--text-primary, #e0e0e0);
  font-size: 14px;
}

.auth-error {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #f87171;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.btn-auth-submit {
  width: 100%;
  padding: 12px;
  background: var(--accent-color, #7c3aed);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-auth-submit:hover:not(:disabled) {
  background: #6d28d9;
}

.btn-auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-setup-required {
  text-align: center;
  padding: 16px 0;
}

.auth-setup-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.auth-setup-message {
  color: var(--text-primary, #e0e0e0);
  font-size: 15px;
  margin-bottom: 12px;
}

.auth-setup-help {
  color: var(--text-secondary, #aaa);
  font-size: 13px;
}

.auth-setup-help code {
  background: var(--bg-primary, #181825);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* Device-key login: pairing, key changed */
.auth-modal-body code {
  background: var(--bg-primary, #181825);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.auth-explain {
  color: var(--text-secondary, #aaa);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.auth-notice {
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.3);
  color: var(--text-primary, #e0e0e0);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-fingerprint {
  background: var(--bg-primary, #181825);
  border: 1px solid var(--border-color, #333);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary, #e0e0e0);
  font-family: monospace;
  font-size: 14px;
  letter-spacing: 1px;
  text-align: center;
  user-select: all;
}

/* "Verify your gateway (optional)": closed unless the user opens it */
.auth-verify {
  margin: 4px 0 16px;
}
.auth-verify > summary {
  cursor: pointer;
  color: var(--text-secondary, #a0a0b0);
  font-size: 13px;
  padding: 6px 0;
}
.auth-verify[open] > summary {
  margin-bottom: 6px;
}
.auth-verify .auth-text-input {
  margin-bottom: 12px;
}
.auth-verify .auth-fingerprint {
  margin: 6px 0;
}

.auth-text-input {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-primary, #181825);
  border: 1px solid var(--border-color, #333);
  border-radius: 6px;
  color: var(--text-primary, #e0e0e0);
  font-size: 14px;
  box-sizing: border-box;
}

.auth-text-input:focus {
  outline: none;
  border-color: var(--accent-color, #7c3aed);
}

/* ================================================
   CLAWCHATS SIDEBAR ENHANCEMENTS
   1. Date group separators (Today / Yesterday / This Week / Older)
   2. Hover ⋯ action button on chat items
   3. Labeled footer buttons (shown expanded, hidden collapsed)
   ================================================ */

/* ── 1. DATE GROUP SEPARATORS ── */
.chat-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 3px;
  pointer-events: none;
  user-select: none;
}

.chat-date-group span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #444;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-date-group::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(var(--ink), 0.06);
}

/* ── 2. HOVER ⋯ BUTTON ON CHAT ITEMS ── */
.chat-item {
  position: relative;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 6px;
}

.chat-item-actions {
  display: none;
  align-items: center;
  flex-shrink: 0;
}

.chat-item:hover .chat-item-actions {
  display: flex;
}

.chat-item:hover .chat-title {
  max-width: calc(100% - 28px);
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: #777;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.chat-action-btn:hover {
  background: rgba(var(--ink), 0.1);
  color: #ddd;
}

/* ── 3. FOOTER BUTTON LABELS ── */
.sidebar-footer .btn-text {
  display: block !important;
  font-size: 9px !important;
  font-weight: 500 !important;
  letter-spacing: 0.03em !important;
  margin-top: 1px;
  line-height: 1;
}

.sidebar-footer .sessions-btn,
.sidebar-footer .settings-btn,
.sidebar-footer .help-btn {
  flex-direction: column !important;
  gap: 3px !important;
  padding: 6px 4px !important;
  flex: 1 !important;
  border-radius: 7px !important;
}

.sidebar-footer .collapse-btn {
  flex: 0 0 auto !important;
  padding: 8px 6px !important;
}

/* ── 3b. COLLAPSED STATE ── */
.sidebar.collapsed .sidebar-footer .btn-text {
  display: none !important;
}

.sidebar.collapsed .sidebar-footer .cog-menu-wrapper {
  display: none;
}

/* Hide the 4 individual drawer-shortcut icons */
#artifactsBtn,
#workspaceBtn,
#memoryBtn {
  display: none !important;
}

/* Single panel toggle button */
header #ccPanelToggleBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgb(142, 142, 142);
  cursor: pointer;
  padding: 6px;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
header #ccPanelToggleBtn:hover {
  background: rgba(var(--ink), 0.08);
  color: rgb(220, 220, 220);
}
header #ccPanelToggleBtn.active {
  color: rgb(16, 163, 127);
}
header #ccPanelToggleBtn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Inline image loading placeholder */
.inline-image-loading {
  display: inline-block;
  position: relative;
  width: 200px;
  height: 150px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary, #1a1a1a);
}
.inline-image-loading img { opacity: 0; width: 100%; height: 100%; }
.image-loading-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    var(--bg-secondary, #1a1a1a) 30%,
    var(--bg-tertiary, #2a2a2a) 50%,
    var(--bg-secondary, #1a1a1a) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
.image-loading-shimmer::after {
  content: '🖼️ Loading...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted, #666);
  font-size: 0.85rem;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Workspace file bulk delete */
.ws-checkbox {
  appearance: none;
  -webkit-appearance: none;
  display: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 1.5px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
  margin-right: 4px;
}
.ws-checkbox:hover {
  border-color: var(--accent-color);
}
.ws-checkbox:checked {
  background: var(--accent-color);
  border-color: var(--accent-color);
}
.ws-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
.ws-select-mode .ws-checkbox { display: block; }
.workspace-header-btn.active {
  color: var(--accent-text);
  background: rgba(16, 163, 127, 0.15);
}
.ws-create-row {
  cursor: default;
  background: var(--bg-tertiary);
}
.ws-create-field {
  flex: 1;
  min-width: 0;
}
.ws-create-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 3px 6px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--accent-color);
  border-radius: 4px;
  outline: none;
}
.ws-create-invalid .ws-create-input {
  border-color: #ff6b6b;
}
.ws-create-error {
  font-size: 11px;
  color: #ff6b6b;
  margin-top: 3px;
}
.ws-create-error:empty {
  display: none;
}
.workspace-file-item.ws-just-created {
  animation: ws-just-created 1.6s ease-out;
}
@keyframes ws-just-created {
  from { background: rgba(16, 163, 127, 0.25); }
  to { background: transparent; }
}
.ws-action-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-color, rgba(var(--ink), 0.08));
  font-size: 12px;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}
.ws-action-bar.visible { display: flex; }
.ws-delete-selected-btn {
  padding: 4px 10px;
  border-radius: 4px;
  background: #e05252;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
}
.ws-delete-selected-btn:hover { background: #c94040; }
.ws-cancel-select-btn {
  padding: 4px 8px;
  border-radius: 4px;
  background: none;
  color: var(--text-muted, #888);
  border: 1px solid var(--border-color, rgba(var(--ink), 0.15));
  cursor: pointer;
  font-size: 12px;
}

/* ─── Per-project agent feature ─────────────────────────────────────── */
.agent-select {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  box-sizing: border-box;
}

/* Project with a chat waiting on an approval/question: the Control UI's collapsed-group attention dot
   (layout.css .sidebar-session-group-attention), placed in the tile's free top-left corner (the unread
   count takes top-right, the agent dot and lock bottom-right). The ring separates it from the tile border. */
.sidebar-session-group-attention {
  width: 6px;
  height: 6px;
  flex: none;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 6px color-mix(in srgb, var(--warn) 48%, transparent);
}

.project-rail-item .project-attention-dot {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 8px;
  height: 8px;
  margin-left: 0;
  box-shadow: 0 0 0 2px var(--bg-secondary), 0 0 6px color-mix(in srgb, var(--warn) 48%, transparent);
  pointer-events: none;
}

/* Run spinner: Control UI components.css .session-run-spinner (its --accent is the brand color, ours
   --accent-color), in the bottom-right corner (over the agent dot, which it replaces while shown); the fill and ring separate it from the tile border. */
.session-run-spinner {
  box-sizing: border-box;
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 1.5px solid color-mix(in srgb, var(--accent-color) 28%, transparent);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: session-run-spin 1.6s linear infinite;
}

@keyframes session-run-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .session-run-spinner { animation: none; border-color: var(--accent-color); }
}

.project-rail-item .project-running-spinner {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 11px;
  height: 11px;
  background: var(--bg-secondary);
  box-shadow: 0 0 0 2px var(--bg-secondary);
  pointer-events: none;
}

.project-agent-dot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-color, #58a6ff);
  opacity: 0.85;
  pointer-events: none;
}

/* ─── Project edit modal ─────────────────────────────────────────────── */
.project-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  z-index: 2147483640;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-menu-backdrop .project-context-menu {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: 460px;
  max-height: 90vh;
  overflow: hidden;
  z-index: 2147483641;
}

.project-menu-backdrop .emoji-picker {
  height: auto;
  min-height: 0;
}

.project-menu-backdrop .emoji-picker-body {
  overflow: visible;
  flex: 0 0 auto;
}

.project-context-menu .emoji-picker-header {
  display: flex;
  align-items: flex-start;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color);
}

.project-name-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.project-name-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.project-context-menu .emoji-picker-name-input {
  font-size: 13.3px;
  font-weight: 600;
  width: 100%;
  padding: 9px 10px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  height: auto;
  box-sizing: border-box;
}

.project-context-menu .emoji-picker-search {
  font-size: 13.3px;
  padding: 8px 10px;
  height: auto;
  box-sizing: border-box;
}

.project-context-menu .emoji-picker-delete-btn {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
}

.project-context-menu .emoji-picker-delete-btn svg {
  width: 18px;
  height: 18px;
}

.project-agent-section {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
}

.project-agent-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.project-agent-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Project sheet: New project / Project settings (projects.js showProjectSheet) */
.project-menu-backdrop .project-context-menu.project-sheet {
  width: min(460px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.project-sheet__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 16px 4px;
}

/* New project for a chat being moved: which chat goes in */
.project-sheet__moving {
  margin: 0;
  padding: 0 16px 4px;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-sheet__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.project-sheet__saved {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s;
}

.project-sheet__saved--on { opacity: 1; }

.project-sheet__name { padding: 10px 16px 14px; }

.project-sheet__name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-sheet__icon-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid;
  border-radius: 8px;
  background: var(--bg-tertiary);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.project-sheet__icon-btn:hover,
.project-sheet__icon-btn[aria-expanded="true"] { background: var(--bg-hover, var(--bg-tertiary)); filter: brightness(1.15); }

.project-sheet__icon-btn img,
.project-sheet__icon-btn svg { width: 22px; height: 22px; object-fit: contain; }

.project-sheet .project-sheet__name-row .emoji-picker-name-input { flex: 1; min-width: 0; }

.project-sheet__error,
.delete-project-error {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--danger, #ef4444);
}

.project-sheet__appearance { border-top: 1px solid var(--border-color); }

.project-sheet__appearance .emoji-picker-body { max-height: 220px; overflow-y: auto; }

.project-sheet__defaults {
  padding: 12px 16px 6px;
  border-top: 1px solid var(--border-color);
}

.project-sheet__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-sheet__section-head .project-name-label { margin-bottom: 0; }

.project-sheet__reset {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.project-sheet__reset:hover { color: var(--text-primary); text-decoration: underline; }

.project-sheet__hint {
  margin: 4px 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Project instructions (frontend/chat/project-instructions.js) */
.project-sheet__instructions {
  padding: 12px 16px 10px;
  border-top: 1px solid var(--border-color);
}

.project-sheet__count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.project-sheet__count--near { color: var(--warn); }

.project-sheet__instructions-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 96px;
  max-height: 40vh;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.project-sheet__instructions-input::placeholder { color: var(--text-muted); }

.project-sheet__instructions-input:focus { outline: none; border-color: var(--text-muted); }

.project-sheet__notice {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary, var(--text-primary));
}

.project-sheet__command {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
}

.project-sheet__code {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  user-select: all;
}

.project-sheet__copy {
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.project-sheet__copy:hover { border-color: var(--text-muted); }

.project-sheet__copy.copied { border-color: var(--accent-color); } /* the label says Copied; accent text was 2.3:1 in light */

.project-sheet__link {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: inherit;
  text-decoration: underline;
}

.project-sheet__missing {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--warn);
  overflow-wrap: anywhere;
}

.project-sheet__missing[hidden] { display: none; }

.project-sheet__check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary, var(--text-primary));
  cursor: pointer;
}

.project-sheet__check input { margin: 2px 0 0; }

.project-sheet__check-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.project-sheet__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}

.project-sheet__row[hidden] { display: none; }

.project-sheet__row-label {
  font-size: 13px;
  color: var(--text-secondary, var(--text-primary));
}

.project-sheet__dd { min-width: 0; }

.project-sheet__select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 5px 8px 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.project-sheet__select:hover { border-color: var(--text-muted); }

.project-sheet__select--default { color: var(--text-muted); }

.project-sheet__select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.project-sheet__select-icon:empty { display: none; }

.project-sheet__select-icon svg,
.project-sheet__select-chevron svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7px;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.project-sheet__select-chevron { opacity: 0.7; }

/* The rows' menus are the composer's own (their classes size and style them); placeMenu() in
   project-preset.js positions them fixed, since the sheet clips overflow. */
.project-sheet__dd > .cc-dd__menu.project-sheet__menu { z-index: 2147483642; }

.project-sheet__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.project-sheet__spacer { flex: 1; }

.project-sheet__delete {
  background: none;
  border: none;
  padding: 6px 4px;
  font-size: 13px;
  color: #ef4444;
  cursor: pointer;
}

.project-sheet__delete:hover { text-decoration: underline; }

.project-sheet .btn__spinner,
.delete-confirm-btn .btn__spinner {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 6px;
}

.project-sheet .btn__spinner,
.delete-confirm-btn .btn__spinner { border-radius: 50%; } /* --radius-full is only defined in the composer's scope */

.delete-confirm-btn:has(.btn__spinner) { opacity: 0.85; cursor: progress; }

#deleteProjectModal .cancel-btn:disabled,
#deleteProjectModal .close-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Banners (frontend/ui/banner.js) ─────────────────────────────
   Theme-based; severity shows as a left accent bar + tinted background. */
.cc-banner {
  --banner-accent: var(--accent-color);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--banner-accent) 8%, var(--bg-tertiary));
  border-bottom: 1px solid var(--border-color);
  box-shadow: inset 3px 0 0 var(--banner-accent);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.cc-banner--warn { --banner-accent: #d29922; }
.cc-banner--danger { --banner-accent: #e5534b; }
.cc-banner-icon { flex-shrink: 0; font-size: 14px; }
.cc-banner-text { flex: 1; min-width: 160px; }
.cc-banner-text strong { color: var(--text-primary); font-weight: 600; }
.cc-banner-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }
.cc-banner-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.cc-banner-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.cc-banner-btn--primary {
  background: var(--banner-accent);
  border-color: var(--banner-accent);
  color: #fff;
  font-weight: 600;
}
.cc-banner-btn--primary:hover { filter: brightness(1.1); color: #fff; border-color: var(--banner-accent); }
.cc-banner--warn .cc-banner-btn--primary,
.cc-banner--warn .cc-banner-btn--primary:hover { color: #1a1a1a; }
.cc-banner-btn--link { border: none; padding: 4px 2px; color: var(--accent-text); }
.cc-banner-btn--link:hover { text-decoration: underline; }
.cc-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}
.cc-banner-close:hover { color: var(--text-primary); }
.cc-banner-details { flex-basis: 100%; }

/* Sidebar is narrow: message on its own line, actions below it. */
.cc-banner--sidebar { align-items: flex-start; padding: 10px 12px; }
.cc-banner--sidebar .cc-banner-text { min-width: 0; flex: 1 1 calc(100% - 30px); }
.cc-banner--sidebar .cc-banner-actions { flex: 1 1 calc(100% - 32px); margin-left: 22px; }
.cc-banner--sidebar .cc-banner-close { margin-left: auto; }

/* Composer: quiet, centered note above the input (the read-only / plan-limit notice). */
.cc-banner--composer {
  justify-content: center;
  text-align: center;
  background: var(--bg-secondary);
  border-bottom: none;
  border-top: 1px solid var(--border-color);
  box-shadow: none;
  color: var(--text-muted);
  padding: 10px 16px;
}
.cc-banner--composer .cc-banner-text { flex: 0 1 auto; }
.cc-banner--composer a { color: var(--accent-text); text-decoration: none; }
.cc-banner--composer a:hover { text-decoration: underline; }

/* Plugin update: copyable command row */
.cc-banner-command { display: flex; align-items: center; gap: 8px; }
.cc-banner-command code {
  flex: 1;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  user-select: all;
}

/* ── Tool bubble rows (frontend/chat/activity.js renderActivityBlock) ── */
.activity-step-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.activity-step-tool .activity-step-status { margin-left: auto; flex-shrink: 0; font-size: 11px; color: var(--text-muted); }
.activity-step-status.ok { color: var(--accent-text); }
/* Error red, readable as text (≥4.5:1) on the activity background in both themes. */
.activity-step-status.error,
.activity-step-tool.is-error .activity-step-title { color: #f06a63; }
[data-theme="light"] .activity-step-status.error,
[data-theme="light"] .activity-step-tool.is-error .activity-step-title { color: #b91c1c; }
/* File tool target ("Read ~/notes.md"), as Control UI's .chat-tool-row__file-link: a faint
   underline that firms up on hover; clicking it opens the file instead of toggling the row. */
.activity-file-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 18%, transparent);
  text-underline-offset: 2px;
}
.activity-file-link:hover,
.activity-file-link:focus-visible { text-decoration-color: currentColor; }
.activity-file-link.is-checking { cursor: progress; opacity: 0.6; }
/* No dimming: faded text drops below readable contrast; the plain (unlinked) look says it. */
.activity-file-link.is-missing { cursor: default; text-decoration: none; }
.activity-step-thinking .activity-step-text { font-style: italic; color: var(--text-muted); white-space: pre-line; }
.activity-elapsed { margin-left: auto; font-size: 11px; color: var(--text-muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
/* Two-line header: fixed line boxes so emoji / text swaps during streaming never change its height. */
.activity-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.activity-header .activity-summary,
.activity-header .activity-sub { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-header .activity-summary { height: 17px; line-height: 17px; }
.activity-header .activity-sub { height: 15px; line-height: 15px; font-size: 11px; font-weight: 400; font-style: normal; color: var(--text-muted); }
.activity-header .activity-failed { color: #e5534b; }
.activity-group-header { cursor: pointer; }
.activity-group-header .activity-step-title { font-family: inherit; }
/* the agent's purpose for a command ("Check the installed version") reads as prose, not code */
.activity-step-tool.is-prose .activity-step-title { font-family: inherit; }
.activity-group-current { color: var(--text-muted); margin-left: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.activity-group-chevron { flex-shrink: 0; font-size: 10px; color: var(--text-muted); transition: transform 0.15s ease; }
.activity-group.open .activity-group-chevron { transform: rotate(90deg); }
.activity-group-current.is-prose { font-family: inherit; }
/* keeps the running step apart from a muted "· N other" right before it */
.activity-group-current::before { content: '— '; }
.activity-group-other { color: var(--text-muted); }
/* an open group lists its running step already */
.activity-group.open .activity-group-current { display: none; }
.activity-group-steps { display: none; padding-left: 18px; }
.activity-group.open .activity-group-steps { display: block; }
.activity-step-nested .activity-step-title { font-size: 11.5px; }
.activity-step-tool[role="button"] { cursor: pointer; }
.activity-step-detail { display: none; margin: 2px 0 8px 22px; }
/* a resolved question's outcome, in the run that asked it (questions.js questionsInActivity) */
.activity-question { padding: 2px 4px; }
.activity-tool.open > .activity-step-detail { display: block; }
.activity-detail-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 6px 0 3px; }
.activity-detail-pre {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}
.activity-detail-pre.is-error { border-color: color-mix(in srgb, #e5534b 50%, var(--border-color)); color: #f0908a; }
.activity-detail-empty { font-size: 11.5px; color: var(--text-muted); font-style: italic; margin: 4px 0; }
/* An opened tool row shows its full title (long commands wrap instead of ending in …). */
.activity-tool.open > .activity-step-tool .activity-step-title { white-space: pre-wrap; word-break: break-word; overflow: visible; }

/* ── Activity block type scale: one size/line-height, hierarchy by colour and style ──
   narration (the agent's words) = primary text; thinking = muted italic; tools = muted mono. */
.activity-step-narration .activity-step-text,
.activity-step-thinking .activity-step-text {
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-line;
}
.activity-step-narration .activity-step-text { color: var(--text-primary); font-style: normal; }
.activity-step-thinking { opacity: 1; font-style: normal; }
.activity-step-thinking .activity-step-text { color: var(--text-muted); font-style: italic; }
.activity-step-narration .activity-step-icon,
.activity-step-thinking .activity-step-icon { opacity: 0.55; margin-top: 2px; }
/* MEDIA: lines in narration: the images and files they name (chat/activity.js narrationHtml). */
.activity-step-media { display: block; white-space: normal; }
.activity-step-media p { margin: 0; }
.activity-step-media .markdown-inline-image-button {
  display: block; max-width: min(100%, 320px); margin: 6px 0 2px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; cursor: zoom-in;
}
.activity-step-media .markdown-inline-image {
  display: block; max-width: min(100%, 320px); max-height: 240px; width: auto; height: auto;
  border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-tertiary); object-fit: contain;
}
.activity-step-media .message-attachments { margin: 6px 0 2px; align-items: flex-start; }

/* ── Light theme: surfaces whose dark-theme colours are opaque literals ──
   Translucent tints, hairlines and text follow --ink; these are the solid fills and tinted text that
   need a light value of their own. Selectors repeat the base rule's specificity under [data-theme]. */
[data-theme="light"] .header {
  background: color-mix(in srgb, var(--bg-primary) 96%, transparent);
  box-shadow: 0 1px 3px rgba(var(--ink), 0.06);
}
[data-theme="light"] header #ccPanelToggleBtn:hover,
[data-theme="light"] .chat-action-btn:hover { color: var(--text-primary); }
[data-theme="light"] .sync-status.pending { color: #b45309; }
/* New chat's green label needs a deeper green to stay readable on the parchment sidebar */
[data-theme="light"] #newChatBtn { color: #0b6e55; }
[data-theme="light"] #newChatBtn svg { stroke: #0b6e55; }
[data-theme="light"] #newChatBtn:hover { color: #095a46; }
[data-theme="light"] .loading-spinner { border-color: var(--border-color); border-top-color: var(--text-muted); }
[data-theme="light"] .date-separator::before,
[data-theme="light"] .date-separator::after { background: var(--border-color); }

/* Messages */
[data-theme="light"] .msg-action-btn { border-color: var(--border-color); color: var(--text-muted); }
[data-theme="light"] .msg-action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: #d6d0c5; }
[data-theme="light"] .message.user .message-content {
  background-color: var(--user-bg);
  border-color: var(--border-color);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(var(--ink), 0.06);
}
[data-theme="light"] .message.assistant .message-content { color: var(--text-primary); }
[data-theme="light"] .message.user .message-content pre { background: rgba(var(--ink), 0.05); }
[data-theme="light"] .message.user .message-content code { background: rgba(var(--ink), 0.06); color: var(--text-primary); }
[data-theme="light"] .message.user .message-content pre code { background: transparent; color: var(--text-secondary); }
[data-theme="light"] .message.assistant .message-content pre,
[data-theme="light"] .message.assistant .message-content pre[class*="language-"] {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}
[data-theme="light"] .message.assistant .message-content code {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: #b4532a;
}
[data-theme="light"] .message.assistant .message-content pre code { background: transparent; border: none; color: var(--text-secondary); }

/* Prism tokens: GitHub light palette (the loaded prism-tomorrow theme is dark-only) */
[data-theme="light"] code[class*="language-"],
[data-theme="light"] pre[class*="language-"] { color: var(--text-secondary); }
[data-theme="light"] .token.comment,
[data-theme="light"] .token.prolog,
[data-theme="light"] .token.doctype,
[data-theme="light"] .token.cdata { color: #6e7781; }
[data-theme="light"] .token.punctuation { color: var(--text-secondary); }
[data-theme="light"] .token.tag,
[data-theme="light"] .token.attr-name,
[data-theme="light"] .token.namespace,
[data-theme="light"] .token.deleted { color: #116329; }
[data-theme="light"] .token.function-name,
[data-theme="light"] .token.function,
[data-theme="light"] .token.class-name { color: #8250df; }
[data-theme="light"] .token.boolean,
[data-theme="light"] .token.number,
[data-theme="light"] .token.property,
[data-theme="light"] .token.constant,
[data-theme="light"] .token.symbol { color: #0550ae; }
[data-theme="light"] .token.selector,
[data-theme="light"] .token.important,
[data-theme="light"] .token.atrule,
[data-theme="light"] .token.keyword,
[data-theme="light"] .token.builtin,
[data-theme="light"] .token.operator,
[data-theme="light"] .token.entity,
[data-theme="light"] .token.url { color: #cf222e; }
[data-theme="light"] .token.string,
[data-theme="light"] .token.char,
[data-theme="light"] .token.attr-value,
[data-theme="light"] .token.regex,
[data-theme="light"] .token.variable,
[data-theme="light"] .token.inserted { color: #0a3069; }

/* Activity block (tool steps) */
[data-theme="light"] .activity-header { color: var(--text-secondary); }
[data-theme="light"] .activity-step-meta { color: var(--text-muted); }
[data-theme="light"] .activity-step-meta:hover { color: var(--text-secondary); }
[data-theme="light"] .activity-step-meta.expanded { color: var(--text-primary) !important; }
[data-theme="light"] .activity-step-name,
[data-theme="light"] .activity-step[data-step-type="exec"] .activity-step-name { color: #1d4ed8; }
[data-theme="light"] .activity-step[data-step-type="read"] .activity-step-name { color: #6d28d9; }
[data-theme="light"] .activity-step[data-step-type="process"] .activity-step-name { color: #b45309; }
[data-theme="light"] .activity-step[data-step-type="done"] .activity-step-name { color: #15803d; }

/* Setup / rename inputs */
[data-theme="light"] .ask-phrase,
[data-theme="light"] .token-input-wrapper input,
[data-theme="light"] .workspace-name-input {
  background: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}
[data-theme="light"] .copy-btn { border-color: var(--border-color); }
[data-theme="light"] .setup-folder-instructions { border-top-color: var(--border-color); }

/* Plan badge and note colours are inline (settings.js); the Pro green needs a darker shade on white */
[data-theme="light"] #accountPlanNote { color: #1a7f37 !important; }
[data-theme="light"] #accountPlanBadge[style*="185, 80"] { color: #1a7f37 !important; }
[data-theme="light"] #accountPlanBadge[style*="148, 158"] { color: var(--text-muted) !important; border-color: var(--border-color) !important; }

/* Share artifact dialog (frontend/share/share-modal.js) */
.share-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.share-select:focus { border-color: var(--accent-color); }
.share-note { margin: 0 0 16px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.share-error { margin: 0 0 16px; font-size: 13px; color: var(--danger, #ef4444); }
.share-link-row { display: flex; gap: 8px; }
.share-link-row input[type="text"] { flex: 1; min-width: 0; font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; }
.share-link-row .share-copy-btn { flex: 0 0 auto; padding: 12px 18px; }
.share-list { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.share-list h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.share-list ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.share-list li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; background: var(--bg-primary); }
.share-list-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.share-list-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-list-meta { font-size: 12px; color: var(--text-secondary); }
.share-list-delete { flex: 0 0 auto; background: none; border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-secondary); font-size: 12px; padding: 4px 10px; cursor: pointer; }
.share-list-delete:hover { color: var(--danger, #ef4444); border-color: var(--danger, #ef4444); }
.share-steps { margin: 0 0 16px; padding-left: 20px; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }
.share-steps a { color: inherit; text-decoration: underline; }
.share-steps strong, .share-note strong { color: var(--text-primary); font-weight: 600; }
.share-storage-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 0; font-size: 12px; color: var(--text-secondary); }
.share-storage-line[hidden] { display: none; }
.share-storage-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-link-btn { flex: 0 0 auto; background: none; border: none; padding: 0; color: var(--text-secondary); font-size: 12px; text-decoration: underline; cursor: pointer; }
.share-link-btn:hover { color: var(--text-primary); }
.share-warning { margin: 0 0 16px; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5; color: var(--text-primary); background: color-mix(in srgb, var(--warn, #f59e0b) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn, #f59e0b) 45%, transparent); }

/* App confirm dialog (frontend/ui/confirm-dialog.js): above other modals it's opened from. */
.modal.confirm-dialog { z-index: 1300; }
.choice-dialog__options { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.choice-dialog__option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 10px; cursor: pointer; color: var(--text-primary); }
.choice-dialog__option:has(input:checked) { border-color: var(--accent-color); background: color-mix(in srgb, var(--accent-color) 8%, transparent); }
.choice-dialog__option input { margin-top: 3px; accent-color: var(--accent-color); }
.choice-dialog__label { display: block; font-size: 14px; font-weight: 500; }
.choice-dialog__option small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.modal.confirm-dialog .modal-content { max-width: 440px; }
.confirm-dialog__message { white-space: pre-line; margin: 0 0 12px; line-height: 1.5; color: var(--text-primary); }
.confirm-dialog__details {
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  padding: 8px 10px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--bg-tertiary, rgba(127, 127, 127, 0.12));
  border: 1px solid var(--border-color);
  overflow-wrap: anywhere;
  white-space: pre-line;
}
/* Files explorer right-click menu (files-panel.js showMenu): the chat menu's look, plus shortcut hints */
.files-context-menu {
  min-width: 210px;
}
.files-context-menu .chat-context-menu-item {
  padding: 8px 14px;
  font-size: 13px;
}
.files-menu-label {
  flex: 1;
}
.files-menu-key {
  font-size: 11px;
  color: var(--text-muted);
}
.workspace-file-item.ws-menu-target {
  background: var(--bg-tertiary);
}
.workspace-file-item.ws-cut {
  opacity: 0.5;
}
.workspace-file-item:focus-visible {
  outline: 1px solid var(--accent-color, #10a37f);
  outline-offset: -1px;
}
.workspace-file-item.ws-renaming {
  cursor: default;
  background: var(--bg-tertiary);
}
.files-context-menu:focus {
  outline: none;
}
/* Shared right-click menu (frontend/ui/context-menu.js): why items are disabled, e.g. a file link's "Not found" */
.context-menu-note {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
}
/* A file link whose right-click menu is open, like the Files explorer's .ws-menu-target row */
.markdown-file-link.file-link-menu-target,
.activity-file-link.file-link-menu-target {
  /* Tinted from the text colour, so it shows on any background (user bubbles included) */
  background: color-mix(in srgb, currentColor 12%, transparent);
  border-radius: 4px;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 12%, transparent);
}

/* ── @mentions in team chats (team-chat.js): the same pill in posted messages and in the composer ── */
.mention-pill {
  border-radius: 4px;
  background: color-mix(in srgb, var(--mention-color) 16%, transparent);
  /* A ring, not padding: in the composer each glyph has to stay exactly over the textarea's. */
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mention-color) 16%, transparent);
  color: var(--mention-color);
}

.message-content .mention-pill { font-weight: 500; }

.composer-mention-backdrop {
  position: absolute;
  z-index: -1;
  box-sizing: border-box;
  margin: 0;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--text-primary);
  pointer-events: none;
}

.input-area .agent-chat__composer-combobox.has-mentions > textarea[data-ref="messageInput"] {
  color: transparent;
  caret-color: var(--text-primary);
}
