:root {
  color-scheme: dark;
  --bg-primary: #181818;
  --bg-secondary: #141414;
  --bg-surface: #1e1e1e;
  --bg-input: rgba(228, 228, 228, 0.04);
  --bg-hover: rgba(228, 228, 228, 0.08);
  --bg-user-msg: rgba(228, 228, 228, 0.06);
  --bg-agent-msg: transparent;
  --bg-tool: rgba(228, 228, 228, 0.03);
  --bg-code: rgba(0, 0, 0, 0.25);

  --text-primary: rgba(228, 228, 228, 0.92);
  --text-secondary: rgba(228, 228, 228, 0.70);
  --text-tertiary: rgba(228, 228, 228, 0.48);
  --text-quaternary: rgba(228, 228, 228, 0.32);

  --accent-green: #3fa266;
  --accent-red: #e34671;
  --accent-yellow: #f1b467;
  --accent-blue: #3794ff;
  --accent-purple: #b180d7;
  --accent-link: #81a1c1;

  --border-color: rgba(228, 228, 228, 0.08);

  --radius: 10px;
  --radius-sm: 6px;

  --header-height: 44px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  /* Scrollbars: opaque dark track avoids UA light (white/grey) fallback */
  --scrollbar-track: rgba(0, 0, 0, 0.45);
  --scrollbar-thumb: rgba(228, 228, 228, 0.22);
  --scrollbar-thumb-hover: rgba(228, 228, 228, 0.34);

  /* Soft-keyboard overlap when the layout viewport is not resized (WebView / iOS). */
  --keyboard-inset: 0px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: calc(100% - var(--keyboard-inset, 0px));
  max-height: calc(100% - var(--keyboard-inset, 0px));
  width: 100%;
  margin: 0 auto;
}

#app.layout-agents {
  flex-direction: row;
  align-items: stretch;
}

.main-column {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* --- Agents sidebar (Cursor Agents-window style) --- */

.agents-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #141414;
  border-right: 1px solid var(--border-color);
  z-index: 20;
  height: 100%;
}

.agents-sidebar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

.agents-new-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
}

.agents-new-btn:hover { background: rgba(228, 228, 228, 0.12); }
.agents-new-icon {
  font-size: 16px;
  line-height: 1;
  color: var(--text-secondary);
}

.agents-sidebar-close {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
}

.agents-sidebar-section-label {
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.agents-sidebar-list,
.agents-windows-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 8px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.agents-empty {
  padding: 16px 10px;
  font-size: 12px;
  color: var(--text-quaternary);
}

.agents-project {
  margin-bottom: 6px;
}

.agents-project-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  font-family: var(--font-sans);
  text-align: left;
}

.agents-project-head:hover { background: var(--bg-hover); }

.agents-project-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agents-project-count {
  font-size: 10px;
  color: var(--text-quaternary);
  flex-shrink: 0;
}

.agents-project-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 6px 6px;
}

.agents-date-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding-top: 5px;
}

.agents-date-group:first-child { padding-top: 1px; }

.agents-date-heading {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px 4px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
}

.agents-date-heading:hover { color: var(--text-secondary); }
.agents-date-heading:disabled { cursor: wait; opacity: 0.65; }

.agents-date-chevron {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.agents-date-group.expanded .agents-date-chevron { transform: rotate(90deg); }

.agents-project.collapsed .agents-project-body {
  display: none !important;
}

.agents-project-chevron {
  display: inline-block;
  width: 0;
  height: 0;
  margin: 0 4px 0 2px;
  border-style: solid;
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent var(--text-quaternary);
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.agents-project:not(.collapsed) .agents-project-chevron {
  transform: rotate(90deg);
}

.agents-session {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
}

.agents-session:hover { background: var(--bg-hover); color: var(--text-primary); }

.agents-session.active {
  background: rgba(228, 228, 228, 0.12);
  color: var(--text-primary);
  font-weight: 500;
}

.agents-session-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agents-session-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--text-tertiary);
}

.agents-session-status--running::before {
  content: '';
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--text-quaternary);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: agentsSessionSpin 0.85s linear infinite;
}

.agents-session-status--done-seen,
.agents-session-status--done-unseen {
  border: 1.25px solid currentColor;
  border-radius: 50%;
}

.agents-session-status--done-seen::after,
.agents-session-status--done-unseen::after {
  content: '';
  width: 3px;
  height: 6px;
  margin-top: -2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.agents-session-status--done-unseen { color: var(--text-secondary); }

.agents-session-unread {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-blue);
  box-shadow: 0 0 0 1.5px var(--bg-secondary);
}

.agents-session-status--needs-attention {
  border: 1.25px solid var(--accent-yellow);
  border-radius: 50%;
  color: var(--accent-yellow);
}

.agents-session-status--needs-attention::after {
  content: '!';
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

.agents-session-status--draft::before {
  content: '';
  width: 7px;
  height: 7px;
  border: 1.25px solid var(--text-quaternary);
  border-radius: 50%;
}

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

@media (prefers-reduced-motion: reduce) {
  .agents-session-status--running::before { animation: none; }
}

.sidebar-toggle {
  display: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  padding: 0;
  margin-right: 4px;
  cursor: pointer;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-toggle-bars {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  position: relative;
}
.sidebar-toggle-bars::before,
.sidebar-toggle-bars::after {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.sidebar-toggle-bars::before { top: -5px; }
.sidebar-toggle-bars::after { top: 5px; }

.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.header-center {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
  display: flex;
  justify-content: center;
}

.active-session-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.sidebar-backdrop {
  display: none;
}

.agents-windows-list.hidden { display: none; }

@media (max-width: 820px), (pointer: coarse), (hover: none) {
  .agents-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.35);
  }
  #app.sidebar-open .agents-sidebar {
    transform: translateX(0);
  }
  .agents-sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop:not(.hidden) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 15;
  }
}

/* Android/iOS WebView shell: always use drawer + visible toggle */
html.cr-native-shell .agents-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  transform: translateX(-105%);
  transition: transform 0.2s ease;
  box-shadow: 8px 0 24px rgba(0,0,0,0.35);
}
html.cr-native-shell #app.sidebar-open .agents-sidebar {
  transform: translateX(0);
}
html.cr-native-shell .agents-sidebar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
html.cr-native-shell .sidebar-toggle {
  display: inline-flex !important;
}
html.cr-native-shell .sidebar-backdrop:not(.hidden) {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 15;
}

/* --- Header --- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.header-right.header-right-hidden {
  display: none;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.connected { background: var(--accent-green); }
.dot.disconnected { background: var(--accent-red); }
.dot.reconnecting { background: var(--accent-yellow); }

#agent-status-icon { font-size: 12px; }

#agent-status-text {
  max-width: min(200px, 45vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#agent-status-text.agent-status-shimmer {
  background: linear-gradient(
    90deg,
    var(--text-secondary) 0%,
    var(--text-primary) 45%,
    var(--text-secondary) 90%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: statusShimmer 2.2s ease-in-out infinite;
}

@keyframes statusShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --- Messages area --- */

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  /* Allow vertical panning; nested code/table handlers still capture their own axes. */
  touch-action: pan-y pinch-zoom;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--text-tertiary);
  gap: 8px;
}

.empty-state code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-surface);
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--accent-blue);
}

.hint { font-size: 12px; }

/* --- Chat element base --- */

.chat-el {
  animation: fadeIn 0.12s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Human message --- */

.el-human {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 6px;
  padding: 2px 0;
}

.human-bubble {
  position: relative;
  max-width: 85%;
  padding: 6px 12px;
  background: var(--bg-user-msg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  word-break: break-word;
}

.human-message-edit {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-quaternary);
  font-size: 16px;
  cursor: pointer;
  opacity: 0;
}

.human-bubble:hover .human-message-edit,
.human-message-edit:focus-visible {
  opacity: 1;
  background: var(--bg-hover);
  color: var(--text-primary);
}

.human-message-edit:disabled { display: none; }

.human-bubble-editable .human-text { padding-right: 24px; }

.human-bubble-editing {
  width: min(100%, 680px);
  max-width: 100%;
  padding: 10px;
  background: var(--bg-secondary);
  border-color: rgba(228, 228, 228, 0.22);
}

.history-message-edit-input {
  width: 100%;
  min-height: 88px;
  max-height: 220px;
  resize: vertical;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  outline: none;
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
  line-height: 1.5;
}

.history-message-edit-input:focus { border-color: var(--accent-blue); }

.history-message-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.history-message-cancel,
.history-message-submit {
  min-height: 34px;
  padding: 6px 12px;
}

.history-message-submit {
  background: var(--accent-blue);
  color: #fff;
}

@media (hover: none) {
  .human-message-edit { opacity: 1; }
}

.quoted-widget {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-blue);
  background: rgba(55, 148, 255, 0.08);
}

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

.quoted-text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

.mentions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 3px;
}

.mention-badge {
  font-size: 11px;
  padding: 0px 5px;
  border-radius: 3px;
  background: rgba(55, 148, 255, 0.15);
  color: var(--accent-blue);
  font-family: var(--font-mono);
}

.human-text {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.human-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: min(360px, 72vw);
  margin: 2px 0 6px;
}

.human-images-single { grid-template-columns: minmax(0, 1fr); }

.human-image-tile {
  position: relative;
  min-width: 0;
}

.human-image-tile-removable .human-image-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.human-image-tile-removable .human-image-remove:hover,
.human-image-tile-removable .human-image-remove:focus-visible {
  background: rgba(227, 70, 113, 0.92);
  outline: none;
}

.human-image-link.human-image-failed {
  outline: 1px solid rgba(227, 70, 113, 0.45);
}

.human-image-link.human-image-failed::after {
  content: 'Image unavailable';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: rgba(228, 228, 228, 0.55);
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.human-image-link {
  display: block;
  position: relative;
  min-width: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.human-images-single .human-image-link {
  aspect-ratio: auto;
  max-height: 360px;
}

.human-image {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
}

.human-images-single .human-image { height: auto; max-height: 360px; object-fit: contain; }

/* --- Assistant message --- */

.el-assistant {
  display: flex;
  justify-content: flex-start;
  padding: 2px 0;
}

.assistant-bubble {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 6px 8px;
  word-break: break-word;
  overflow: visible;
  max-height: none;
}

.assistant-content {
  min-width: 0;
  font-size: 14px;
  line-height: 1.62;
  overflow: visible;
  max-height: none;
}

/* Streamdown / markdown may still use horizontal scroll regions inside prose */
.assistant-bubble .ui-scroll-area,
.assistant-bubble .ui-scroll-area__viewport,
.assistant-bubble .ui-scroll-area__content {
  max-height: none !important;
  height: auto !important;
}

.assistant-bubble .ui-scroll-area__viewport,
.assistant-bubble .ui-scroll-area__content {
  overflow-y: visible !important;
}

.assistant-bubble .ui-scroll-area[data-direction="horizontal"] .ui-scroll-area__viewport,
.assistant-bubble .ui-scroll-area[data-direction="horizontal"] .ui-scroll-area__content {
  overflow-x: auto !important;
  overflow-y: visible !important;
}

.el-tool .tool-diff-host {
  margin-top: 10px;
}

.assistant-bubble .native-code-block {
  margin-top: 8px;
}

.assistant-bubble .overflow-auto,
.assistant-bubble .overflow-y-auto,
.assistant-bubble .overflow-scroll {
  max-height: none !important;
  overflow-y: visible !important;
}

.assistant-content.markdown-body p { margin-bottom: 8px; }
.assistant-content.markdown-body p:last-child { margin-bottom: 0; }
.assistant-content.markdown-body ol,
.assistant-content.markdown-body ul { padding-left: 20px; margin: 6px 0 10px; }
.assistant-content.markdown-body li { margin-bottom: 3px; padding-left: 2px; }
.assistant-content.markdown-body .markdown-section {
  display: block;
  margin-bottom: 8px;
}
.assistant-content.markdown-body .markdown-section:empty { display: none; }
.assistant-content.markdown-body .markdown-section:last-child { margin-bottom: 0; }
.assistant-content.markdown-body .remote-mermaid-diagram {
  --cursor-bg-editor: var(--bg-code);
  --cursor-text-primary: var(--text-primary);
  --cursor-stroke-secondary: var(--text-tertiary);
  --cursor-text-cyan-primary: var(--accent-link);
  --cursor-text-secondary: var(--text-secondary);
  --cursor-bg-tertiary: rgba(228, 228, 228, 0.035);
  --cursor-stroke-primary: var(--border-color);
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 10px 0 14px;
  overflow: hidden;
  contain: layout paint;
  isolation: isolate;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
  touch-action: pan-y pinch-zoom;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.assistant-content.markdown-body .remote-mermaid-diagram svg {
  position: static !important;
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  transform: none !important;
  pointer-events: none;
}
.mermaid-expand-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(228, 228, 228, 0.18);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  background: rgba(24, 24, 24, 0.86);
  cursor: pointer;
}
.mermaid-expand-btn:active { background: rgba(228, 228, 228, 0.14); }
.remote-mermaid-diagram:focus-visible,
.mermaid-expand-btn:focus-visible { outline: 2px solid var(--accent-link); outline-offset: 2px; }

body.mermaid-fs-open { overflow: hidden; }
.mermaid-fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #111;
}
.mermaid-fs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 56px;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--border-color);
  background: #181818;
}
.mermaid-fs-title {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}
.mermaid-fs-controls { display: flex; align-items: center; gap: 4px; }
.mermaid-fs-control {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  background: rgba(228, 228, 228, 0.07);
  font-size: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mermaid-fs-control:disabled { opacity: 0.35; }
.mermaid-fs-control:active:not(:disabled) { background: rgba(228, 228, 228, 0.16); }
.mermaid-fs-control:focus-visible { outline: 2px solid var(--accent-link); outline-offset: -2px; }
.mermaid-fs-zoom { min-width: 58px; font-size: 12px; font-variant-numeric: tabular-nums; }
.mermaid-fs-close { margin-left: 4px; }
.mermaid-fs-viewport {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
}
.mermaid-fs-stage {
  --cursor-bg-editor: var(--bg-code);
  --cursor-text-primary: var(--text-primary);
  --cursor-stroke-secondary: var(--text-tertiary);
  --cursor-text-cyan-primary: var(--accent-link);
  --cursor-text-secondary: var(--text-secondary);
  --cursor-bg-tertiary: rgba(228, 228, 228, 0.035);
  --cursor-stroke-primary: var(--border-color);
  position: relative;
  margin: 0 auto;
  background: var(--bg-code);
}
.mermaid-fs-stage svg {
  position: static !important;
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  transform: none !important;
}

@media (max-width: 520px) {
  .mermaid-fs-header { padding-left: 10px; }
  .mermaid-fs-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .mermaid-fs-controls { width: 100%; justify-content: flex-end; }
  .mermaid-fs-viewport { padding: 10px; }
}
.assistant-content.markdown-body h1,
.assistant-content.markdown-body h2,
.assistant-content.markdown-body h3,
.assistant-content.markdown-body h4 {
  color: var(--text-primary);
  font-weight: 650;
  line-height: 1.35;
}
.assistant-content.markdown-body h1 { margin: 18px 0 9px; font-size: 20px; }
.assistant-content.markdown-body h2 { margin: 16px 0 8px; font-size: 18px; }
.assistant-content.markdown-body h3 { margin: 14px 0 7px; font-size: 16px; }
.assistant-content.markdown-body h4 { margin: 12px 0 6px; font-size: 15px; }
.assistant-content.markdown-body > :first-child h1,
.assistant-content.markdown-body > :first-child h2,
.assistant-content.markdown-body > :first-child h3,
.assistant-content.markdown-body > :first-child h4 { margin-top: 0; }
.assistant-content.markdown-body blockquote {
  margin: 8px 0 10px;
  padding-left: 12px;
  color: var(--text-secondary);
  border-left: 2px solid rgba(228, 228, 228, 0.18);
}
.assistant-content.markdown-body .markdown-table-container {
  width: 100% !important;
  max-width: 100% !important;
  margin: 10px 0 14px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  -webkit-overflow-scrolling: touch;
}
.assistant-content.markdown-body .markdown-table-wrapper {
  width: max-content;
  min-width: 100%;
  overflow: visible !important;
}
.assistant-content.markdown-body table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}
.assistant-content.markdown-body th,
.assistant-content.markdown-body td {
  padding: 7px 9px;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: top;
}
.assistant-content.markdown-body th {
  color: var(--text-primary);
  font-weight: 600;
  background: rgba(228, 228, 228, 0.035);
}
.assistant-content.markdown-body tr:last-child td { border-bottom: 0; }
.assistant-content.markdown-body th:last-child,
.assistant-content.markdown-body td:last-child { border-right: 0; }
.assistant-content.markdown-body pre {
  margin: 6px 0;
  padding: 8px 10px;
  overflow: auto;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}
.assistant-content.markdown-body code,
.assistant-content.markdown-body .markdown-inline-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(228, 228, 228, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
}
.assistant-content.markdown-body [data-link] {
  color: var(--accent-link) !important;
}
.assistant-content.markdown-body pre code {
  display: block;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--shiki-foreground);
  white-space: pre;
  line-height: 1.5;
}
.assistant-content.markdown-body pre code span {
  color: inherit;
}
.assistant-content.markdown-body pre code .line,
.assistant-content.markdown-body pre code [data-line] {
  display: block;
}
.assistant-content.markdown-body strong,
.assistant-content.markdown-body .font-semibold { font-weight: 600; }
.assistant-content.markdown-body a {
  color: var(--accent-link);
  text-decoration: none;
}

/* Shiki vars if Streamdown embeds inline code blocks in markdown HTML */
.assistant-content.markdown-body {
  --shiki-foreground: rgba(228, 228, 228, 0.92);
  --shiki-token-comment: #7f848e;
  --shiki-token-keyword: #c678dd;
  --shiki-token-type: #e5c07b;
  --shiki-token-function: #61afef;
  --shiki-token-string: #98c379;
  --shiki-token-punctuation: rgba(228, 228, 228, 0.72);
  --shiki-token-constant: #d19a66;
  --shiki-token-parameter: #abb2bf;
  --shiki-token-deleted: #e06c75;
  --shiki-token-inserted: #98c379;
}

/* --- Code blocks (native renderer) --- */

.code-block {
  --cb-font: 12px;
  --cb-lh: 1.45;
  --cb-lines: 7;
  margin: 6px 0 4px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
}

.code-block-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 8px;
  min-height: 40px;
  box-sizing: border-box;
  background: rgba(228, 228, 228, 0.03);
  border-bottom: 1px solid var(--border-color);
}

.code-block-toolbar--actions-only {
  justify-content: flex-end;
  padding-right: 2px;
}

.code-block-header {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  padding: 2px 0;
}

.code-block-fullscreen-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.code-block-fullscreen-btn:active {
  background: rgba(228, 228, 228, 0.1);
  color: var(--text-primary);
}

/* Scroll viewport: at most ~7 lines of code, then vertical scroll */
.code-block-viewport {
  max-height: calc(var(--cb-font) * var(--cb-lh) * var(--cb-lines) + 12px);
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
}

@media (pointer: coarse), (hover: none) {
  #messages {
    scroll-behavior: auto;
    /* Was pan-x only — that blocked vertical swipe on mobile/WeChat WebViews,
       so the transcript could not scroll up to older messages. */
    touch-action: pan-y pinch-zoom;
  }
}

html.cr-native-shell #messages {
  scroll-behavior: auto;
  touch-action: pan-y pinch-zoom;
}

/* Code block scrollbars: dark track + themed thumb (WebKit + Firefox) */
.code-block-viewport,
.code-block-fs-scroll {
  color-scheme: dark;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.code-block-viewport::-webkit-scrollbar,
.code-block-fs-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.code-block-viewport::-webkit-scrollbar-button,
.code-block-fs-scroll::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.code-block-viewport::-webkit-scrollbar-track,
.code-block-fs-scroll::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 3px;
}

.code-block-viewport::-webkit-scrollbar-thumb,
.code-block-fs-scroll::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 3px;
}

.code-block-viewport::-webkit-scrollbar-thumb:hover,
.code-block-fs-scroll::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

.code-block-viewport::-webkit-scrollbar-corner,
.code-block-fs-scroll::-webkit-scrollbar-corner {
  background: var(--scrollbar-track);
}

.code-block pre {
  margin: 0;
  padding: 6px 8px;
  overflow-x: visible;
  font-family: var(--font-mono);
  font-size: var(--cb-font);
  line-height: var(--cb-lh);
  color: var(--text-primary);
  white-space: pre;
}

.code-block code { background: none; padding: 0; }

/* Line-level diff (structured diffLines from server) */
.code-block-diff-plain {
  margin: 0;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: var(--cb-font);
  line-height: var(--cb-lh);
  background: var(--bg-code);
}

.code-block-diff-plain--raw pre {
  margin: 0;
  white-space: pre;
  color: var(--text-primary);
}

/* Full-screen code reader (mobile: safe areas, large close target) */
.code-block-fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
}

.code-block-fs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}

.code-block-fs-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(960px, 100%);
  max-height: 100%;
  margin: auto;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.code-block-fs-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(228, 228, 228, 0.04);
}

.code-block-fs-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-block-fs-close {
  flex-shrink: 0;
  min-width: 48px;
  min-height: 48px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.code-block-fs-close:active {
  background: rgba(228, 228, 228, 0.1);
  color: var(--text-primary);
}

.code-block-fs-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.code-block-fs-scroll .code-block-diff-plain {
  max-width: none;
}

.code-block-fs-scroll .code-block-diff-line {
  margin-left: 0;
  margin-right: 0;
}

.code-block-diff-line {
  white-space: pre;
  padding: 1px 6px 1px 8px;
  margin: 0 -6px;
  border-radius: 2px;
}

.code-block-diff-line--ctx {
  color: var(--text-primary);
}

.code-block-diff-line--add {
  background: rgba(63, 185, 80, 0.22);
  color: rgba(230, 245, 233, 0.98);
  border-left: 3px solid rgba(63, 185, 80, 0.95);
  padding-left: 10px;
}

.code-block-diff-line--rem {
  background: rgba(248, 81, 73, 0.2);
  color: rgba(255, 232, 230, 0.98);
  border-left: 3px solid rgba(248, 81, 73, 0.9);
  padding-left: 10px;
}

.code-block-diff-line--meta,
.code-block-diff-line--hunk {
  color: var(--text-tertiary);
  background: rgba(228, 228, 228, 0.05);
  font-size: 11px;
}

/* --- Tool call line --- */

.el-tool { padding: 1px 0; }

.tool-line {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tool-line.completed .tool-icon { color: var(--text-tertiary); }
.tool-line.loading .tool-icon { color: var(--accent-yellow); }

.tool-actions-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 8px 2px;
}

.tool-icon {
  flex-shrink: 0;
  font-size: 12px;
  width: 14px;
  text-align: center;
}

.tool-action {
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.tool-details {
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-file-info {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
  font-size: 11px;
}

.tool-filename {
  color: var(--text-secondary);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-additions { color: var(--accent-green); }
.tool-deletions { color: var(--accent-red); }

.tool-summary {
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Thought block --- */

.el-thought {
  padding: 4px 0 6px;
}

.thought-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 2px 4px;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
}

.thought-line.thought-line-summary {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.thought-line.thought-line-step {
  margin-left: 0;
  padding-left: 0;
  border-left: none;
  color: var(--text-secondary);
  font-size: 13px;
}

.thought-line {
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.thought-detail {
  margin: 2px 4px 0;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-quaternary);
  border-left: 2px solid rgba(228, 228, 228, 0.12);
}

/* --- Plan block --- */

.el-plan { padding: 2px 0; }

.plan-card {
  padding: 8px 10px;
  background: rgba(228, 228, 228, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.plan-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.plan-todo-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.plan-todo-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.plan-todo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.plan-todo-pending { background: var(--text-tertiary); }
.plan-todo-completed { background: var(--accent-green); }
.plan-todo-in_progress { background: var(--accent-blue); }

.plan-todo-text {
  flex: 1;
  min-width: 0;
}

.plan-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 16px;
}

.plan-progress-track {
  flex: 1;
  height: 3px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.plan-progress-bar {
  height: 100%;
  background: var(--accent-green);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.plan-progress-text {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.plan-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.plan-btn {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.plan-btn-build {
  background: var(--accent-blue);
  color: #fff;
}

.plan-btn-view {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.plan-model-badge {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: auto;
}

.plan-card-widget {
  background: var(--bg-surface);
  border-color: color-mix(in srgb, var(--border-color) 80%, var(--accent-blue));
  gap: 6px;
}

.plan-widget-header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.plan-widget-icon {
  font-size: 12px;
  opacity: 0.85;
  flex-shrink: 0;
}

.plan-widget-filename {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-description.markdown-body {
  font-size: 12px;
  line-height: 1.45;
  max-height: 160px;
  overflow-y: auto;
}

.plan-description.markdown-body p { margin-bottom: 6px; }
.plan-description.markdown-body p:last-child { margin-bottom: 0; }

.plan-todos-more {
  font-size: 11px;
  color: var(--text-quaternary);
  padding: 2px 0 0 14px;
}

.plan-actions-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px solid var(--border-color);
}

.plan-actions-left,
.plan-actions-center,
.plan-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.plan-actions-center {
  flex: 1;
  justify-content: center;
  overflow: hidden;
}

.plan-model-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}

.plan-model-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.plan-model-pill-chev {
  flex-shrink: 0;
  opacity: 0.7;
  font-size: 10px;
}

.plan-model-badge-inline {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-card-modal {
  background: transparent;
  border: none;
  padding: 0;
}

.plan-card-modal .plan-description.markdown-body,
.plan-card-modal .plan-todo-list {
  max-height: none;
}

.plan-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.66);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 12px;
}

.plan-modal-overlay.hidden { display: none; }

.plan-modal {
  width: 100%;
  max-width: 720px;
  max-height: min(82vh, 720px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.plan-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.plan-modal-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.plan-modal-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.plan-modal-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 26px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.plan-modal-body {
  overflow-y: auto;
  padding: 16px;
}

/* --- Composer queue strip --- */

.composer-queue-bar {
  flex-shrink: 0;
  padding: 6px 12px 8px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.composer-queue-bar.hidden { display: none; }

.composer-queue-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.composer-queue-chevron {
  font-size: 10px;
  color: var(--text-quaternary);
  transition: transform 0.15s ease;
}

.composer-queue-bar.collapsed .composer-queue-chevron { transform: rotate(-90deg); }
.composer-queue-bar.collapsed .composer-queue-header { margin-bottom: 0; }
.composer-queue-bar.collapsed .composer-queue-items { display: none; }

.composer-queue-label {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-queue-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 156px;
  overflow-y: auto;
}

.composer-queue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
}

.composer-queue-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--text-tertiary);
  flex-shrink: 0;
  opacity: 0.5;
}

.composer-queue-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.composer-queue-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.composer-queue-action {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.composer-queue-action:hover,
.composer-queue-action:focus-visible {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.composer-queue-action:disabled {
  opacity: 0.35;
  cursor: default;
}

.composer-queue-action-remove:hover,
.composer-queue-action-remove:focus-visible { color: var(--accent-red); }

/* --- Standalone todo list card --- */

.el-todo-list { padding: 2px 0; }

.todo-list-card {
  padding: 8px 10px;
  background: rgba(228, 228, 228, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.todo-list-card-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.todo-list-card-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.todo-list-card-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.todo-list-card-icon {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1.35;
}

.todo-list-card-text {
  flex: 1;
  min-width: 0;
}

/* --- Run command --- */

.el-run-command { padding: 2px 0; }

.run-card {
  padding: 8px 10px;
  background: rgba(228, 228, 228, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.run-header {
  font-size: 12px;
}

.run-description {
  color: var(--text-secondary);
  font-weight: 500;
}

.run-candidates {
  color: var(--text-tertiary);
}

.run-command-block {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

.run-prompt {
  color: var(--accent-green);
  user-select: none;
}

.run-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.run-btn {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

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

.run-btn-skip {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.run-btn-allow {
  background: var(--accent-blue);
  color: #fff;
}

/* --- Loading indicator --- */

.el-loading { padding: 2px 0; }

.loading-dots {
  display: flex;
  gap: 3px;
  padding: 2px 8px;
}

.dot-anim {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-quaternary);
  animation: dotBounce 1.4s ease-in-out infinite;
}

.dot-anim:nth-child(2) { animation-delay: 0.16s; }
.dot-anim:nth-child(3) { animation-delay: 0.32s; }

@keyframes dotBounce {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* --- Approval Bar --- */

.system-notice-bar {
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.system-notice-bar.hidden { display: none; }

/* Mirror Cursor Desktop's blocking "Submit from a previous message?" dialog. */
.system-notice-bar.system-notice-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(8, 10, 14, 0.62);
  border-top: 0;
}

.system-notice-bar.system-notice-modal .system-notice-inner {
  width: min(420px, 100%);
  max-width: 100%;
  grid-template-columns: 24px minmax(0, 1fr);
  grid-template-areas:
    "icon copy"
    ". action";
  align-items: start;
  padding: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.system-notice-bar.system-notice-modal .system-notice-actions {
  width: 100%;
  justify-content: flex-end;
}

.system-notice-bar.system-notice-modal .system-notice-action {
  flex: 0 1 auto;
  min-width: 0;
}

.system-notice-inner {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto 32px;
  grid-template-areas: "icon copy action dismiss";
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(228, 228, 228, 0.16);
  border-radius: var(--radius-sm);
}

.system-notice-icon {
  grid-area: icon;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--accent-yellow);
  font-size: 12px;
  font-weight: 700;
}

.system-notice-error .system-notice-icon { color: var(--accent-red); }
.system-notice-info .system-notice-icon { color: var(--accent-blue); }

.system-notice-copy {
  grid-area: copy;
  min-width: 0;
}

.system-notice-title {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.system-notice-message {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.system-notice-actions {
  grid-area: action;
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.system-notice-action {
  min-height: 34px;
  padding: 7px 12px;
  background: #8eacd0;
  color: #121820;
  white-space: nowrap;
}

.system-notice-action-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.system-notice-dismiss {
  grid-area: dismiss;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.system-notice-action:hover:not(:disabled),
.system-notice-dismiss:hover:not(:disabled) { opacity: 0.82; }

.system-notice-action:disabled,
.system-notice-dismiss:disabled { opacity: 0.45; cursor: wait; }

@media (max-width: 560px) {
  .system-notice-inner {
    grid-template-columns: 22px minmax(0, 1fr) 32px;
    grid-template-areas:
      "icon copy dismiss"
      ". action action";
    align-items: start;
  }

  .system-notice-actions {
    width: 100%;
    justify-content: stretch;
  }

  .system-notice-action {
    flex: 1 1 120px;
    white-space: normal;
  }
}

.approval-bar {
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.approval-bar.hidden { display: none; }

.approval-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-align: center;
}

.approval-actions { display: flex; gap: 10px; }

/* --- Questionnaire Bar --- */

.questionnaire-bar {
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  max-height: 55vh;
}

.questionnaire-bar.hidden { display: none; }

.questionnaire-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.questionnaire-icon { font-size: 14px; }

.questionnaire-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.questionnaire-stepper {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
}

#questionnaire-questions {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
  flex: 1;
}

.questionnaire-question {
  margin-bottom: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary, rgba(255,255,255,0.04));
}

.questionnaire-question-active {
  border-left: 2px solid var(--accent-blue);
}

.questionnaire-question-label {
  display: flex;
  gap: 4px;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.questionnaire-question-number {
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.questionnaire-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.questionnaire-option {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.questionnaire-option:active { transform: scale(0.97); }
.questionnaire-option:hover { border-color: var(--accent-blue); }
.questionnaire-option-selected {
  border-color: var(--accent-blue);
  background: rgba(55, 148, 255, 0.15);
}

.questionnaire-option-letter {
  font-weight: 600;
  color: var(--accent-blue);
}

.questionnaire-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-shrink: 0;
}

.btn-q-skip {
  flex: 1;
  height: 40px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-q-continue {
  flex: 1;
  height: 40px;
  background: var(--accent-blue);
  color: #fff;
}

.btn-q-continue:disabled { opacity: 0.35; }
.btn-q-skip:hover:not(:disabled) { border-color: var(--text-secondary); }
.btn-q-continue:hover:not(:disabled) { opacity: 0.85; }

/* --- Buttons --- */

.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-approve {
  flex: 1;
  height: 48px;
  background: var(--accent-green);
  color: #fff;
}

.btn-reject {
  flex: 1;
  height: 48px;
  background: var(--accent-red);
  color: #fff;
}

.btn-approve:hover:not(:disabled), .btn-reject:hover:not(:disabled) { opacity: 0.85; }

/* --- Input Bar (Agents-style composer) --- */

#input-bar {
  position: relative;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

/* Home-indicator inset is already above the IME when the keyboard is open. */
html.keyboard-open #input-bar {
  padding-bottom: 8px;
}

.composer-suggestions {
  position: absolute;
  left: 12px;
  bottom: calc(100% - 2px);
  width: min(520px, calc(100% - 24px));
  max-height: min(360px, 48vh);
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-surface);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.composer-suggestions[hidden] { display: none; }

.composer-suggestion-header {
  position: sticky;
  top: -5px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 3px 5px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  z-index: 1;
}

.composer-suggestion-back {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
}

.composer-suggestion-back:hover { color: var(--text-primary); background: var(--bg-hover); }

.composer-suggestion-group {
  padding: 7px 8px 3px;
  color: var(--text-quaternary);
  font-size: 10px;
  font-weight: 600;
  text-transform: none;
}

.composer-suggestion-item {
  width: 100%;
  min-height: 36px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.composer-suggestion-item:hover,
.composer-suggestion-item.selected {
  background: var(--bg-hover);
}

.composer-suggestion-icon {
  width: 22px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.composer-suggestion-copy { min-width: 0; }

.composer-suggestion-label,
.composer-suggestion-detail {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-suggestion-label { font-size: 12px; line-height: 16px; }
.composer-suggestion-detail { color: var(--text-quaternary); font-size: 10px; line-height: 14px; }
.composer-suggestion-chevron { color: var(--text-quaternary); font-size: 14px; }

.composer-suggestion-empty {
  padding: 14px 10px;
  color: var(--text-quaternary);
  font-size: 12px;
  text-align: center;
}

.composer-prompt {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-input);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  transition: border-color 0.2s;
  overflow: hidden;
}

.composer-prompt:focus-within { border-color: rgba(228, 228, 228, 0.16); }
.composer-prompt.drag-over {
  border-color: rgba(55, 148, 255, 0.7);
  background: rgba(55, 148, 255, 0.08);
}

.attachment-preview {
  display: flex;
  gap: 8px;
  min-height: 74px;
  padding: 10px 10px 4px;
  overflow-x: auto;
}

.attachment-preview[hidden] { display: none; }

.attachment-tile {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.attachment-tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.attachment-open {
  width: 100%;
  height: 100%;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.attachment-open:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: -2px;
}

.attachment-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 18px;
  line-height: 20px;
  cursor: pointer;
}

body.image-lightbox-open { overflow: hidden; }

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: rgba(0, 0, 0, 0.94);
}

.image-lightbox-viewport {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.image-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.image-lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.image-lightbox-close:focus-visible { outline: 2px solid #fff; }

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 6px 8px;
  border-top: 1px solid rgba(228, 228, 228, 0.04);
}

.composer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.btn-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-icon:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-attach {
  position: relative;
  overflow: hidden;
}

.native-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

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

.btn-attach.disabled:hover { background: transparent; color: var(--text-secondary); }
.native-file-input:disabled { cursor: not-allowed; }

#message-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  padding: 10px 12px 6px;
}

#message-input::placeholder { color: var(--text-quaternary); }
#message-input:disabled { opacity: 0.4; }

.btn-send {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-link);
  color: #fff;
  border-radius: 50%;
  padding: 0;
}

.btn-send:disabled { background: var(--text-quaternary); }

.btn-send.btn-stop {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.btn-send.btn-stop:hover {
  background: #fff;
}

/* --- Toast --- */

#toast-container {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.2s ease-out;
  white-space: nowrap;
}

.toast.error { border-left: 2px solid var(--accent-red); }
.toast.success { border-left: 2px solid var(--accent-green); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Scrollbar (#messages) --- */

#messages {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

#messages::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 3px;
}

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

#messages::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

/* --- Window Bar --- */

.window-bar {
  display: flex;
  align-items: center;
  height: 32px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
  padding: 0 4px;
}

.window-bar.hidden { display: none; }

.window-list {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 3px 0;
}

.window-list::-webkit-scrollbar { display: none; }

.window-item {
  flex-shrink: 0;
  padding: 3px 10px;
  font-size: 10px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-quaternary);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-sans);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.window-item:active { transform: scale(0.97); }
.window-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
  font-weight: 500;
}

/* --- Tab Bar --- */

.tab-bar {
  display: flex;
  align-items: center;
  height: 36px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
  padding: 0 4px;
  gap: 2px;
}

.tab-bar.hidden { display: none; }

.tab-list {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

.tab-list::-webkit-scrollbar { display: none; }

.tab-item {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-sans);
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab-item:active { transform: scale(0.97); }
.tab-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 500;
}

.tab-item .tab-status {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.tab-status.running { background: var(--accent-yellow); }
.tab-status.completed { background: var(--accent-green); }
.tab-status.error { background: var(--accent-red); }

.tab-new-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.tab-new-btn:active { background: var(--bg-hover); }

/* --- In-flight generation control (Cursor Desktop parity) --- */

.generation-control {
  flex-shrink: 0;
  padding: 8px 12px 0;
  background: var(--bg-primary);
}

.generation-control.hidden { display: none; }

.generation-request {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 56px;
  padding: 8px 10px 8px 12px;
  border: 1px solid rgba(228, 228, 228, 0.22);
  border-radius: var(--radius);
  background: rgba(228, 228, 228, 0.025);
}

.generation-request-copy {
  min-width: 0;
  flex: 1;
}

.generation-request-mentions {
  display: flex;
  gap: 5px;
  min-width: 0;
  margin-bottom: 3px;
  overflow: hidden;
}

.generation-request-mentions[hidden] { display: none; }

.generation-request-mention {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 7px;
  background: rgba(55, 148, 255, 0.14);
  color: #8fc9ef;
  font-size: 12px;
  line-height: 18px;
}

.generation-request-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.generation-stop {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg-primary);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.generation-stop:hover:not(:disabled) { background: #fff; }
.generation-stop:active:not(:disabled) { transform: scale(0.96); }
.generation-stop:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 560px) {
  .generation-control { padding-left: 8px; padding-right: 8px; }
  .generation-request { gap: 8px; padding-left: 10px; }
  .generation-request-text { font-size: 14px; }
}

/* --- Mode/Model Pills --- */

.composer-toolbar .pill {
  margin: 0;
}

.mode-model-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-sans);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.pill:active { background: var(--bg-hover); }

.pill-icon {
  font-size: 12px;
  line-height: 1;
  opacity: 0.7;
}

.pill-chevron {
  font-size: 8px;
  opacity: 0.5;
  line-height: 1;
}

/* --- Bottom Sheet --- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
}

.sheet-overlay.hidden { display: none; }

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-surface);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  padding: 12px 0;
  z-index: 210;
  max-height: 60vh;
  overflow-y: auto;
  animation: sheetSlideUp 0.2s ease-out;
}

.bottom-sheet.hidden { display: none; }

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 16px 10px;
  border-bottom: 1px solid var(--border-color);
}

.sheet-list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-sans);
  text-align: left;
}

.sheet-item:active { background: var(--bg-hover); }

.sheet-item.selected {
  color: var(--accent-blue);
  font-weight: 500;
}

.sheet-item-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  opacity: 0.7;
}

.sheet-item-check {
  font-size: 14px;
  color: var(--accent-blue);
}

.sheet-item-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sheet-item-tag {
  font-size: 10px;
  opacity: 0.5;
}

.sheet-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.sheet-item-badge {
  font-size: 12px;
  opacity: 0.5;
  line-height: 1;
}

.sheet-loading, .sheet-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.sheet-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 16px;
}

.sheet-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
}

.toggle-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg-hover);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
}

.toggle-switch.on {
  background: var(--accent-green);
}

.toggle-knob {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.toggle-switch.on .toggle-knob {
  transform: translateX(16px);
}

/* --- Desktop --- */

@media (min-width: 768px) {
  #messages {
    padding-left: max(16px, calc((100% - 800px) / 2));
    padding-right: max(16px, calc((100% - 800px) / 2));
  }
  .human-bubble { max-width: 75%; }
  .btn-approve, .btn-reject { height: 44px; }
  .approval-bar,
  .questionnaire-bar,
  .system-notice-bar,
  #input-bar {
    padding-left: max(14px, calc((100% - 800px) / 2));
    padding-right: max(14px, calc((100% - 800px) / 2));
  }
}
