: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: 52px;
  --bottom-nav-height: 64px;
  --chat-gap: 4px;
  --bubble-py: 6px;
  --bubble-px: 12px;
  --shell-max: 920px;
  --agents-pane-width: 320px;
  --shell-splitter-width: 14px;
  --message-row-py: 2px;
  --assistant-stack-gap: 10px;
  --card-pad-y: 10px;
  --card-pad-x: 12px;
  --card-gap: 8px;
  --queue-pad-top: 6px;
  --queue-pad-x: 12px;
  --queue-pad-bottom: 8px;
  --queue-row-gap: 4px;
  --bar-pad-y: 10px;
  --bar-pad-x: 14px;
  --input-bar-py: 8px;
  --input-bar-px: 12px;
  --input-shell-gap: 8px;
  --input-shell-pad-y: 4px;
  --input-shell-pad-left: 12px;
  --input-shell-pad-right: 4px;
  --composer-text-pad-y: 6px;
  --send-btn-size: 36px;
  --mode-model-gap: 6px;
  --mode-model-margin-bottom: 6px;
  --pill-pad-y: 3px;
  --pill-pad-x: 8px;

  --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);
}

*, *::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: 100%;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}

/* --- 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);
  min-width: 0;
}

.header-right.header-right-hidden {
  display: none;
}

.header-left {
  gap: 10px;
}

.header-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-badge {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(177, 128, 215, 0.18);
  color: #d2b7ea;
  font-size: 12px;
  flex-shrink: 0;
}

.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(240px, 52vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.1;
}

#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%; }
}

/* --- Shell / Screens --- */

#shell {
  flex: 1;
  min-height: 0;
  position: relative;
}

.screen {
  display: none;
  min-height: 0;
  height: 100%;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.legacy-nav {
  display: none !important;
}

.screen-panel {
  width: min(100%, var(--shell-max));
  margin: 0 auto;
  padding: 16px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#shell.shell-wide {
  display: grid;
  grid-template-columns: var(--agents-pane-width) var(--shell-splitter-width) minmax(0, 1fr);
  gap: 0;
}

#shell.shell-wide #agents-screen,
#shell.shell-wide #chat-screen {
  display: flex !important;
  height: 100%;
  min-height: 0;
}

#shell.shell-wide #agents-screen {
  grid-column: 1;
  grid-row: 1;
  background: var(--bg-secondary);
}

#shell.shell-wide #chat-screen {
  grid-column: 3;
  grid-row: 1;
  background: var(--bg-primary);
}

#shell.shell-wide #shell-splitter {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  cursor: col-resize;
  touch-action: none;
  position: relative;
  background: var(--bg-secondary);
}

#shell.shell-wide #shell-splitter::before {
  content: '';
  width: 4px;
  border-radius: 999px;
  margin: 10px 0;
  background: rgba(228, 228, 228, 0.08);
  transition: background 0.15s ease;
}

#shell.shell-wide #shell-splitter:hover::before,
#shell.shell-wide #shell-splitter.is-dragging::before {
  background: rgba(55, 148, 255, 0.55);
}

#shell.shell-wide .screen-panel {
  width: 100%;
  max-width: none;
}

#shell.shell-wide #messages {
  padding-left: 18px;
  padding-right: 18px;
}

body.shell-resizing,
body.shell-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.screen-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.screen-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.screen-empty {
  padding: 18px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
}

.screen-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-primary);
}

/* --- Messages area --- */

#messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: var(--chat-gap);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.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;
  padding: var(--message-row-py) 0;
}

.human-bubble {
  max-width: 85%;
  padding: var(--bubble-py) var(--bubble-px);
  background: var(--bg-user-msg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  word-break: break-word;
}

.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;
}

/* --- Assistant message --- */

.el-assistant {
  display: flex;
  justify-content: flex-start;
  padding: var(--message-row-py) 0;
}

.assistant-bubble {
  max-width: 95%;
  padding: var(--message-row-py) 0;
  display: flex;
  flex-direction: column;
  gap: var(--assistant-stack-gap);
  word-break: break-word;
  overflow: visible;
  max-height: none;
}

.assistant-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  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: 0;
}

.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: 6px; }
.assistant-content.markdown-body p:last-child { margin-bottom: 0; }
.assistant-content.markdown-body ol,
.assistant-content.markdown-body ul { padding-left: 18px; margin-bottom: 6px; }
.assistant-content.markdown-body li { margin-bottom: 2px; }
.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 {
  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 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: contain;
}

/* 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 cards --- */

.el-tool { padding: var(--message-row-py) 0; }

.tool-card {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
  padding: var(--card-pad-y) var(--card-pad-x);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(228, 228, 228, 0.03);
}

.tool-card-loading {
  background: rgba(241, 180, 103, 0.05);
  border-color: rgba(241, 180, 103, 0.18);
}

.tool-card-waiting {
  background: rgba(241, 180, 103, 0.08);
  border-color: rgba(241, 180, 103, 0.24);
}

.tool-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.tool-status-badge {
  flex-shrink: 0;
  min-width: 68px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
}

.tool-status-badge.loading {
  color: #2a200c;
  background: rgba(241, 180, 103, 0.92);
}

.tool-status-badge.waiting {
  color: #2a200c;
  background: rgba(241, 180, 103, 0.82);
}

.tool-status-badge.completed {
  color: #0f2b1a;
  background: rgba(63, 185, 80, 0.9);
}

.tool-card-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tool-card-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tool-card-summary,
.tool-card-details {
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-card-summary {
  color: var(--text-primary);
}

.tool-card-details {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.tool-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-card-context {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

.tool-chip {
  font-size: 11px;
  line-height: 1.2;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(228, 228, 228, 0.08);
  background: rgba(228, 228, 228, 0.04);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.tool-chip-add {
  color: var(--accent-green);
}

.tool-chip-del {
  color: var(--accent-red);
}

.tool-actions-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* --- Thought cards --- */

.el-thought { padding: var(--message-row-py) 0; }

.thought-card {
  display: flex;
  flex-direction: column;
  gap: calc(var(--card-gap) - 2px);
  padding: calc(var(--card-pad-y) - 2px) calc(var(--card-pad-x) - 2px);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(228, 228, 228, 0.06);
  background: rgba(228, 228, 228, 0.03);
}

.thought-card-summary.is-live {
  border-color: rgba(55, 148, 255, 0.18);
}

.thought-card-step {
  margin-left: 16px;
  background: rgba(55, 148, 255, 0.04);
  border-color: rgba(55, 148, 255, 0.12);
}

.thought-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.thought-card-marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
  background: rgba(55, 148, 255, 0.7);
}

.thought-card-step .thought-card-marker {
  background: rgba(55, 148, 255, 0.35);
}

.thought-card-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thought-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.35;
}

.thought-card-step .thought-card-title {
  font-weight: 500;
  color: var(--text-primary);
}

.thought-card-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.thought-card-duration {
  flex-shrink: 0;
  font-size: 10px;
  line-height: 1.2;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(228, 228, 228, 0.08);
  color: var(--text-tertiary);
  background: rgba(228, 228, 228, 0.04);
}

.thought-card-detail {
  margin-left: 16px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.thought-card-body-content,
.thought-group-summary-body {
  margin-left: 16px;
  padding-top: 4px;
}

.thought-body-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.el-thought-group { padding: var(--message-row-py) 0; }

.thought-group {
  display: flex;
  flex-direction: column;
  gap: calc(var(--card-gap) - 2px);
}

.thought-group-summary {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.thought-group-summary-card {
  border-color: rgba(55, 148, 255, 0.12);
  background: rgba(55, 148, 255, 0.04);
}

.thought-group-summary:focus-visible .thought-group-summary-card {
  outline: 2px solid rgba(55, 148, 255, 0.45);
  outline-offset: 2px;
}

.thought-group-toggle-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(228, 228, 228, 0.06);
}

.thought-group-toggle-label {
  font-size: 11px;
  color: var(--text-tertiary);
}

.thought-group-preview {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thought-group-toggle-chevron {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.thought-group-body {
  display: flex;
  flex-direction: column;
  gap: calc(var(--card-gap) - 2px);
  margin-left: 16px;
  padding-left: 12px;
  border-left: 1px solid rgba(228, 228, 228, 0.08);
}

.thought-body-rich.markdown-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
}

.thought-body-rich.markdown-body p { margin-bottom: 6px; }
.thought-body-rich.markdown-body p:last-child { margin-bottom: 0; }
.thought-body-rich.markdown-body ol,
.thought-body-rich.markdown-body ul { padding-left: 18px; margin-bottom: 6px; }
.thought-body-rich.markdown-body li { margin-bottom: 2px; }

.thought-body-rich.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);
}

.thought-body-rich.markdown-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(228, 228, 228, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
}

.thought-card-body-content .native-code-block,
.thought-group-summary-body .native-code-block {
  margin-top: 8px;
}

.thought-group-placeholder {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
}

.thought-group-child-card.thought-card-step {
  margin-left: 0;
}

.thought-group-child-card.tool-card {
  background: rgba(228, 228, 228, 0.025);
}

/* --- Plan block --- */

.el-plan { padding: var(--message-row-py) 0; }

.plan-card {
  padding: calc(var(--card-pad-y) - 2px) calc(var(--card-pad-x) - 2px);
  background: rgba(228, 228, 228, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: calc(var(--card-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: var(--queue-pad-top) var(--queue-pad-x) var(--queue-pad-bottom);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.composer-queue-bar.hidden { display: none; }

.composer-queue-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.composer-queue-chevron {
  font-size: 10px;
  color: var(--text-quaternary);
}

.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: var(--queue-row-gap);
  max-height: 72px;
  overflow-y: auto;
}

.composer-queue-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.composer-queue-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--text-tertiary);
  flex-shrink: 0;
  margin-top: 4px;
  opacity: 0.5;
}

.composer-queue-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --- Standalone todo list card --- */

.el-todo-list { padding: var(--message-row-py) 0; }

.todo-list-card {
  padding: calc(var(--card-pad-y) - 2px) calc(var(--card-pad-x) - 2px);
  background: rgba(228, 228, 228, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: calc(var(--card-gap) - 2px);
}

.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: var(--message-row-py) 0; }

.run-card {
  padding: calc(var(--card-pad-y) - 2px) calc(var(--card-pad-x) - 2px);
  background: rgba(228, 228, 228, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: calc(var(--card-gap) - 2px);
}

.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: var(--message-row-py) 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 --- */

.approval-bar {
  padding: var(--bar-pad-y) var(--bar-pad-x);
  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: var(--bar-pad-y) var(--bar-pad-x);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.questionnaire-bar.hidden { display: none; }

.questionnaire-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.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-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-wrap: wrap;
  gap: 6px;
}

.questionnaire-option {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  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;
}

.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 --- */

#input-bar {
  padding: var(--input-bar-py) var(--input-bar-px);
  padding-bottom: max(var(--input-bar-py), env(safe-area-inset-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--input-shell-gap);
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: var(--input-shell-pad-y) var(--input-shell-pad-right) var(--input-shell-pad-y) var(--input-shell-pad-left);
  border: 1px solid var(--border-color);
  transition: border-color 0.2s;
}

.input-wrapper:focus-within { border-color: rgba(228, 228, 228, 0.16); }

#message-input {
  flex: 1;
  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: var(--composer-text-pad-y) 0;
}

#message-input::placeholder { color: var(--text-quaternary); }
#message-input:disabled { opacity: 0.4; }

.btn-send {
  width: var(--send-btn-size);
  height: var(--send-btn-size);
  min-width: var(--send-btn-size);
  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); }

/* --- Agents View --- */

.agents-list,
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.agents-project-group,
.settings-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.agents-project-header,
.settings-card-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(55, 148, 255, 0.14), rgba(55, 148, 255, 0.06));
}

.agents-project-title,
.settings-card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

.agents-project-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.agents-project-icon {
  flex-shrink: 0;
  font-size: 13px;
  color: #9dc7ff;
}

.agents-project-copy {
  min-width: 0;
}

.agents-project-meta,
.settings-card-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-secondary);
}

.agents-section-label {
  padding: 10px 14px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-quaternary);
}

.agents-session-list {
  display: flex;
  flex-direction: column;
}

.agents-session-row {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(228, 228, 228, 0.04);
  background: transparent;
  padding: 12px 14px;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.agents-session-row:first-child {
  border-top: none;
}

.agents-session-row:active {
  background: var(--bg-hover);
}

.agents-session-row.is-active {
  background: rgba(55, 148, 255, 0.08);
}

.agents-session-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--text-quaternary);
}

.agents-session-indicator.status-idle { background: var(--text-quaternary); }
.agents-session-indicator.status-thinking,
.agents-session-indicator.status-generating,
.agents-session-indicator.status-running_tool { background: var(--accent-yellow); }
.agents-session-indicator.status-waiting_approval { background: var(--accent-red); }
.agents-session-indicator.status-error { background: var(--accent-red); }

.agents-session-body {
  flex: 1;
  min-width: 0;
}

.agents-session-topline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agents-session-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agents-session-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.agents-session-badge.approval {
  background: rgba(227, 70, 113, 0.18);
  color: #ff9eb7;
}

.agents-session-badge.active {
  background: rgba(55, 148, 255, 0.18);
  color: #9dc7ff;
}

.agents-session-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agents-session-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-quaternary);
}

#shell.shell-wide #agents-screen .screen-panel {
  padding: 12px 12px 14px;
  gap: 10px;
}

#shell.shell-wide #agents-screen .agents-list {
  gap: 8px;
}

#shell.shell-wide #agents-screen .agents-project-group {
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

#shell.shell-wide #agents-screen .agents-project-header {
  padding: 8px 10px 7px;
  border-bottom: none;
  border: 1px solid rgba(55, 148, 255, 0.16);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(55, 148, 255, 0.12), rgba(55, 148, 255, 0.04));
  margin-bottom: 6px;
}

#shell.shell-wide #agents-screen .agents-project-title {
  font-size: 13px;
}

#shell.shell-wide #agents-screen .agents-project-meta {
  margin-top: 2px;
}

#shell.shell-wide #agents-screen .agents-section-label {
  padding: 8px 10px 4px;
  font-size: 10px;
}

#shell.shell-wide #agents-screen .agents-session-row {
  border-top: none;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
}

#shell.shell-wide #agents-screen .agents-session-row.is-active {
  box-shadow: inset 2px 0 0 rgba(55, 148, 255, 0.9);
}

/* --- Settings View --- */

.settings-card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-row-copy {
  min-width: 0;
}

.settings-row-label {
  font-size: 13px;
  color: var(--text-primary);
}

.settings-row-value,
.settings-row-help {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.settings-row-value.status-ok {
  color: var(--accent-green);
}

.settings-row-value.status-warn {
  color: var(--accent-yellow);
}

.settings-row-value.status-error {
  color: var(--accent-red);
}

.settings-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  flex-shrink: 0;
}

.settings-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.settings-toggle.is-on {
  background: rgba(63, 162, 102, 0.35);
  border-color: rgba(63, 162, 102, 0.5);
}

.settings-toggle.is-on::after {
  transform: translateX(18px);
}

.settings-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-choice {
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
}

.settings-choice.is-selected {
  color: var(--text-primary);
  border-color: rgba(55, 148, 255, 0.45);
  background: rgba(55, 148, 255, 0.12);
}

.settings-action {
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
}

.settings-action.danger {
  color: #ffb5c8;
  border-color: rgba(227, 70, 113, 0.32);
}

/* --- Bottom Navigation --- */

.bottom-nav {
  height: var(--bottom-nav-height);
  padding: 8px 12px calc(max(8px, env(safe-area-inset-bottom)));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
  z-index: 12;
}

.bottom-nav-item {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.bottom-nav-icon {
  font-size: 15px;
  line-height: 1;
}

.bottom-nav-label {
  line-height: 1;
}

/* --- Local Preferences --- */

body[data-density='compact'] {
  --chat-gap: 2px;
  --bubble-py: 4px;
  --bubble-px: 10px;
  --message-row-py: 1px;
  --assistant-stack-gap: 8px;
  --card-pad-y: 7px;
  --card-pad-x: 9px;
  --card-gap: 6px;
  --queue-pad-top: 4px;
  --queue-pad-x: 10px;
  --queue-pad-bottom: 6px;
  --queue-row-gap: 3px;
  --bar-pad-y: 8px;
  --bar-pad-x: 12px;
  --input-bar-py: 6px;
  --input-bar-px: 10px;
  --input-shell-gap: 6px;
  --input-shell-pad-y: 3px;
  --input-shell-pad-left: 10px;
  --input-shell-pad-right: 3px;
  --composer-text-pad-y: 4px;
  --send-btn-size: 32px;
  --mode-model-gap: 4px;
  --mode-model-margin-bottom: 4px;
  --pill-pad-y: 2px;
  --pill-pad-x: 7px;
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* --- 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); }

/* --- Mode/Model Pills --- */

.mode-model-bar {
  display: flex;
  gap: var(--mode-model-gap);
  margin-bottom: var(--mode-model-margin-bottom);
}

.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--pill-pad-y) var(--pill-pad-x);
  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: flex-start;
  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;
  margin-top: 2px;
}

.sheet-item-check {
  font-size: 14px;
  color: var(--accent-blue);
}

.sheet-item-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sheet-item-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-weight: 600;
}

.sheet-item-tag {
  font-size: 10px;
  opacity: 0.72;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sheet-item-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.sheet-item-help {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.sheet-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  margin-left: auto;
  flex-shrink: 0;
}

.sheet-item-badge {
  font-size: 10px;
  line-height: 1.1;
  padding: 3px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.sheet-item-badge-project {
  background: rgba(55, 148, 255, 0.16);
  color: #9dc7ff;
}

.sheet-item-badge-window {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.sheet-item-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.2;
  text-align: right;
  max-width: 120px;
}

.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,
  #input-bar {
    padding-left: max(14px, calc((100% - 800px) / 2));
    padding-right: max(14px, calc((100% - 800px) / 2));
  }
  .screen-panel {
    padding-left: max(16px, calc((100% - 800px) / 2));
    padding-right: max(16px, calc((100% - 800px) / 2));
  }
}
