/* ─── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* VS Code Dark Modern palette */
  --bg:            #1e1e1e;
  --bg-elev-1:     #252526;
  --bg-elev-2:     #2d2d30;
  --bg-input:      #3c3c3c;
  --bg-titlebar:   #3c3c3c;
  --bg-statusbar:  #007acc;
  --bg-sidebar:    #252526;
  --border:        #2d2d30;
  --border-light:  #3c3c3c;
  --text:          #cccccc;
  --text-bright:   #ffffff;
  --text-muted:    #858585;
  --text-faint:    #6b6b6b;
  --accent:        #4ec9b0;     /* claude / cyan */
  --accent-blue:   #007acc;     /* vscode blue */
  --accent-blue-h: #1f8ad2;
  --selection:     #094771;
  --warning:       #dcdcaa;
  --error:         #f48771;
  --success:       #4ec9b0;
  --user-bubble:   #094771;
  --assistant-bg:  #252526;
  --code-bg:       #1e1e1e;
  --tool-bg:       #2d2d30;

  --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  --titlebar-h:    44px;
  --statusbar-h:   24px;
  --inputbar-h:    62px;
  --sidebar-w:     280px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

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

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

textarea { resize: none; }

.hidden { display: none !important; }

.screen { position: fixed; inset: 0; }

/* ─── Login screen ─────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: max(24px, var(--safe-top)) 24px max(24px, var(--safe-bottom));
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo { display: flex; justify-content: center; margin-bottom: 16px; }

.login-card h1 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 28px;
  font-family: var(--font-mono);
}

.login-card form { display: flex; flex-direction: column; gap: 10px; }

.login-card input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--font-mono);
  text-align: center;
  letter-spacing: 0.5px;
}

.login-card input:focus { border-color: var(--accent-blue); }

.login-card button {
  width: 100%;
  padding: 14px;
  background: var(--accent-blue);
  color: white;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s;
}

.login-card button:hover,
.login-card button:active { background: var(--accent-blue-h); }

.error-text {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

.login-hint {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 18px;
  font-family: var(--font-mono);
}

/* ─── App layout ───────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows:
    calc(var(--titlebar-h) + var(--safe-top))
    1fr
    var(--inputbar-h)
    calc(var(--statusbar-h) + var(--safe-bottom));
  grid-template-areas:
    "title"
    "main"
    "input"
    "status";
  background: var(--bg);
}

/* ─── Title bar ────────────────────────────────────────────────────────── */
.titlebar {
  grid-area: title;
  display: flex;
  align-items: center;
  background: var(--bg-titlebar);
  border-bottom: 1px solid var(--border);
  padding: var(--safe-top) 8px 0 8px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-app-region: drag;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text);
  -webkit-app-region: no-drag;
  flex-shrink: 0;
}

.icon-btn:hover,
.icon-btn:active { background: rgba(255, 255, 255, 0.08); }

.titlebar-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-mono);
  min-width: 0;
}

.titlebar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}

.titlebar-cwd {
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  max-width: 85vw;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  z-index: 51;
  display: flex;
  flex-direction: column;
  padding: max(16px, var(--safe-top)) 0 max(16px, var(--safe-bottom));
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar:not(.hidden) { transform: translateX(0); }

.sidebar-section { padding: 16px 16px 8px; }

.sidebar-section.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.mini-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 14px;
}
.mini-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.sidebar-input-wrap input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.sidebar-input-wrap input:focus { border-color: var(--accent-blue); }

.cwd-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.preset-btn {
  padding: 4px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.preset-btn:hover { background: var(--bg-input); color: var(--text); }
.preset-btn.active { background: var(--selection); color: var(--text-bright); border-color: var(--accent-blue); }

.model-toggle {
  display: flex;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 2px;
}

.model-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  border-radius: 4px;
  transition: all 0.15s;
}
.model-btn.active { background: var(--accent-blue); color: white; }

.threads-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 40vh;
  overflow-y: auto;
}

.threads-empty {
  color: var(--text-faint);
  font-size: 12px;
  padding: 8px 0;
  font-style: italic;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.1s;
}
.thread-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.thread-item.active { background: var(--selection); color: var(--text-bright); }

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

.thread-delete {
  opacity: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}
.thread-item:hover .thread-delete { opacity: 1; }
.thread-delete:hover { background: rgba(255, 255, 255, 0.1); color: var(--error); }

.logout-btn {
  width: 100%;
  padding: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  transition: all 0.15s;
}
.logout-btn:hover { color: var(--error); border-color: var(--error); }

/* ─── Main / messages area ─────────────────────────────────────────────── */
.main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 24px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.welcome-icon { margin-bottom: 16px; opacity: 0.8; }

.welcome h2 {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.welcome p { max-width: 320px; line-height: 1.6; }

.welcome-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 28px;
  width: 100%;
  max-width: 320px;
}

.suggestion {
  padding: 12px 16px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s;
}
.suggestion:hover {
  background: var(--bg-elev-2);
  border-color: var(--accent-blue);
}

/* ─── Message bubbles ──────────────────────────────────────────────────── */
.message {
  display: flex;
  margin-bottom: 14px;
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-user { justify-content: flex-end; }
.message-assistant { justify-content: flex-start; }

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.message-user .bubble {
  background: var(--user-bubble);
  color: var(--text-bright);
  border-bottom-right-radius: 4px;
}

.message-assistant .bubble {
  background: var(--assistant-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  max-width: 92%;
}

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }

.bubble code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--accent);
}

.bubble pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.bubble pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
}

.bubble ul, .bubble ol { margin: 8px 0 8px 20px; }
.bubble li { margin: 2px 0; }

.bubble h1, .bubble h2, .bubble h3 {
  margin: 12px 0 6px;
  color: var(--text-bright);
  font-weight: 600;
}
.bubble h1 { font-size: 18px; }
.bubble h2 { font-size: 16px; }
.bubble h3 { font-size: 14px; }

.bubble a { color: var(--accent-blue); text-decoration: underline; }

.bubble blockquote {
  border-left: 3px solid var(--accent-blue);
  padding-left: 10px;
  color: var(--text-muted);
  margin: 8px 0;
}

/* ─── Tool call cards ──────────────────────────────────────────────────── */
.tool-card {
  margin: 8px 0;
  background: var(--tool-bg);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
}

.tool-card-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.tool-card-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--accent);
}

.tool-card-name {
  color: var(--text);
  font-weight: 500;
}

.tool-card-target {
  color: var(--text-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.tool-card-status {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-muted);
}
.tool-card-status.running { color: var(--warning); }
.tool-card-status.success { color: var(--success); }
.tool-card-status.error { color: var(--error); }

.tool-card-body {
  padding: 8px 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.tool-card.expanded .tool-card-body { display: block; }

/* ─── Streaming indicator ──────────────────────────────────────────────── */
.cursor-blink {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.thinking-indicator {
  display: inline-flex;
  gap: 3px;
  padding: 4px 0;
}
.thinking-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: thinking 1.4s infinite ease-in-out both;
}
.thinking-indicator span:nth-child(1) { animation-delay: -0.32s; }
.thinking-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes thinking {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── Tool panel (terminal-like) ───────────────────────────────────────── */
.tool-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-elev-1);
  flex-shrink: 0;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
}

.tool-panel.collapsed { max-height: 32px; }

.tool-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  height: 32px;
}

.chevron {
  font-size: 8px;
  transition: transform 0.2s;
}
.tool-panel:not(.collapsed) .chevron { transform: rotate(90deg); }

.tool-badge {
  margin-left: auto;
  padding: 1px 7px;
  background: var(--accent-blue);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  min-width: 18px;
  text-align: center;
  display: none;
}
.tool-badge.visible { display: inline-block; }

.tool-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.tool-panel.collapsed .tool-panel-body { display: none; }

.tool-log-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.tool-log-entry:last-child { border-bottom: none; }
.tool-log-entry .ts { color: var(--text-faint); margin-right: 8px; }
.tool-log-entry .label { color: var(--accent); margin-right: 8px; }

/* ─── Input bar ────────────────────────────────────────────────────────── */
.input-bar {
  grid-area: input;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px;
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
  padding-left: max(10px, var(--safe-left));
  padding-right: max(10px, var(--safe-right));
}

.input-wrap {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  min-height: 42px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--accent-blue); }

#input {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
}

#input::placeholder { color: var(--text-faint); }

.action-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text);
  transition: all 0.15s;
}

.mic-btn { background: var(--bg-elev-2); border: 1px solid var(--border-light); }
.mic-btn:hover { background: var(--bg-input); }
.mic-btn.recording {
  background: var(--error);
  border-color: var(--error);
  color: white;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 135, 113, 0.6); }
  50%      { box-shadow: 0 0 0 10px rgba(244, 135, 113, 0); }
}

.send-btn { background: var(--accent-blue); color: white; }
.send-btn:hover { background: var(--accent-blue-h); }
.send-btn:disabled { background: var(--bg-elev-2); color: var(--text-faint); cursor: not-allowed; }

/* ─── Status bar ───────────────────────────────────────────────────────── */
.statusbar {
  grid-area: status;
  background: var(--bg-statusbar);
  color: white;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  padding-bottom: var(--safe-bottom);
  font-size: 11px;
  font-family: var(--font-mono);
  height: calc(var(--statusbar-h) + var(--safe-bottom));
  overflow-x: auto;
  white-space: nowrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  display: inline-block;
}
.conn-dot.connected { background: #4ec9b0; box-shadow: 0 0 4px #4ec9b0; }
.conn-dot.error     { background: #f48771; }

/* ─── Cancel button ────────────────────────────────────────────────────── */
.cancel-btn {
  position: fixed;
  bottom: calc(var(--inputbar-h) + var(--statusbar-h) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  z-index: 40;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.cancel-btn:hover { border-color: var(--error); color: var(--error); }

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--text-faint);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Tablet / desktop ─────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .sidebar { transform: translateX(0); position: relative; }
  .sidebar-overlay { display: none !important; }

  #app {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows:
      calc(var(--titlebar-h) + var(--safe-top))
      1fr
      var(--inputbar-h)
      calc(var(--statusbar-h) + var(--safe-bottom));
    grid-template-areas:
      "title  title"
      "side   main"
      "side   input"
      "status status";
  }

  .sidebar { grid-area: side; }

  #menu-btn { display: none; }

  .bubble { max-width: 720px; }
}

/* ─── Highlight.js override for VS Code Dark Modern feel ──────────────── */
.hljs { background: transparent !important; padding: 0 !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-input); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ═══════════════════════════════════════════════════════════════════════
   PHASE D — Specialized tool renderers (VS Code style)
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Bash terminal card ───────────────────────────────────────────────── */
.bash-card {
  margin: 10px 0;
  background: #0c0c0c;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.bash-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #2d2d2d, #1f1f1f);
  border-bottom: 1px solid #2a2a2a;
  font-size: 11px;
  color: #aaa;
}

.bash-traffic-lights {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.bash-traffic-lights span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.bash-traffic-lights span:nth-child(1) { background: #ff5f56; }
.bash-traffic-lights span:nth-child(2) { background: #ffbd2e; }
.bash-traffic-lights span:nth-child(3) { background: #27c93f; }

.bash-card-title {
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bash-card-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
}
.bash-card-status.running { color: #ffbd2e; }
.bash-card-status.success { color: #27c93f; }
.bash-card-status.error   { color: #ff5f56; }

.bash-prompt {
  padding: 8px 12px 4px;
  color: #569cd6;
}
.bash-prompt::before {
  content: "$ ";
  color: #4ec9b0;
  font-weight: bold;
}
.bash-prompt-cmd {
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-all;
}
.bash-description {
  padding: 0 12px 6px 12px;
  color: #6a9955;
  font-style: italic;
  font-size: 11px;
}
.bash-description::before { content: "# "; color: #6a9955; }

.bash-output {
  padding: 4px 12px 8px;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 320px;
  overflow-y: auto;
  font-size: 11.5px;
  line-height: 1.4;
}
.bash-output.stderr { color: #f48771; }
.bash-output:empty::before { content: "(running…)"; color: #6a6a6a; font-style: italic; }

.bash-exit {
  padding: 4px 12px;
  border-top: 1px solid #1a1a1a;
  font-size: 10px;
  color: #6a6a6a;
}
.bash-exit.error { color: #f48771; }

/* ─── Diff view (Edit / Write) ─────────────────────────────────────────── */
.diff-card {
  margin: 10px 0;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}

.diff-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.diff-card-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--accent);
}

.diff-card-path {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-card-stat {
  display: flex;
  gap: 6px;
  font-size: 10px;
}
.diff-stat-add { color: #4ec9b0; }
.diff-stat-rem { color: #f48771; }

.diff-card-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-muted);
}
.diff-card-status.running { color: var(--warning); }
.diff-card-status.success { color: var(--success); }
.diff-card-status.error   { color: var(--error); }

.diff-body {
  max-height: 360px;
  overflow: auto;
}

.diff-line {
  display: flex;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
}

.diff-line-num {
  flex-shrink: 0;
  width: 36px;
  padding: 0 6px 0 0;
  text-align: right;
  color: var(--text-faint);
  user-select: none;
  border-right: 1px solid var(--border);
  background: var(--bg-elev-1);
}

.diff-line-content {
  padding: 0 8px;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-line.add { background: rgba(78, 201, 176, 0.10); }
.diff-line.add .diff-line-content { color: #c5e8df; }
.diff-line.add .diff-line-content::before { content: "+"; color: #4ec9b0; margin-right: 4px; }

.diff-line.rem { background: rgba(244, 135, 113, 0.10); }
.diff-line.rem .diff-line-content { color: #f5cdc4; }
.diff-line.rem .diff-line-content::before { content: "−"; color: #f48771; margin-right: 4px; }

.diff-line.ctx .diff-line-content { color: var(--text-muted); }
.diff-line.ctx .diff-line-content::before { content: " "; margin-right: 4px; }

/* ─── Read file viewer ─────────────────────────────────────────────────── */
.read-card {
  margin: 10px 0;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}

.read-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.read-card-path {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.read-card-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.read-body {
  max-height: 360px;
  overflow: auto;
}

.read-line {
  display: flex;
  font-size: 11px;
  line-height: 1.45;
}

.read-line-num {
  flex-shrink: 0;
  width: 44px;
  padding: 0 8px 0 0;
  text-align: right;
  color: var(--text-faint);
  user-select: none;
  border-right: 1px solid var(--border);
  background: var(--bg-elev-1);
}

.read-line-content {
  padding: 0 8px;
  flex: 1;
  white-space: pre;
  color: var(--text);
}

/* ─── TodoWrite checklist ──────────────────────────────────────────────── */
.todo-card {
  margin: 10px 0;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-blue);
  border-radius: 6px;
  overflow: hidden;
}

.todo-card-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 122, 204, 0.06);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.todo-card-progress {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
}

.todo-list {
  padding: 6px 0;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s;
}

.todo-item-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.todo-item.pending     .todo-item-icon { color: var(--text-faint); }
.todo-item.in_progress .todo-item-icon { color: var(--warning); animation: spin 2s linear infinite; }
.todo-item.completed   .todo-item-icon { color: var(--accent); }

.todo-item-text {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}
.todo-item.completed .todo-item-text {
  color: var(--text-muted);
  text-decoration: line-through;
}
.todo-item.in_progress .todo-item-text {
  color: var(--text-bright);
  font-weight: 500;
}

/* ─── AskUserQuestion modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.18s ease;
  padding: max(20px, var(--safe-top)) 12px max(20px, var(--safe-bottom));
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpModal 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUpModal {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: 18px 20px 6px;
  border-bottom: 1px solid var(--border);
}

.modal-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-blue);
  color: white;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.modal-question {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-bright);
  line-height: 1.45;
  margin: 0 0 14px;
}

.modal-options {
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-option {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.modal-option:hover,
.modal-option:active {
  background: var(--selection);
  border-color: var(--accent-blue);
}

.modal-option-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-bright);
}

.modal-option-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-other {
  padding: 12px 16px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.modal-other input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
.modal-other input:focus { border-color: var(--accent-blue); }

.modal-other button {
  padding: 10px 16px;
  background: var(--accent-blue);
  color: white;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.modal-other button:hover { background: var(--accent-blue-h); }

/* ─── Slash command autocomplete ───────────────────────────────────────── */
.slash-dropdown {
  position: absolute;
  bottom: calc(var(--inputbar-h) + var(--statusbar-h) + var(--safe-bottom) + 4px);
  left: 12px;
  right: 12px;
  max-width: 600px;
  margin: 0 auto;
  max-height: 50vh;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 50;
  animation: slideUpModal 0.18s ease;
}

.slash-dropdown-header {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
}

.slash-dropdown-list {
  overflow-y: auto;
  flex: 1;
}

.slash-item {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.1s;
}
.slash-item:last-child { border-bottom: none; }
.slash-item:hover,
.slash-item.active {
  background: var(--selection);
}

.slash-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  font-family: var(--font-mono);
}

.slash-item-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slash-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
}

/* ─── Glob / Grep file list ────────────────────────────────────────────── */
.filelist-card {
  margin: 10px 0;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}

.filelist-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
}

.filelist-pattern {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filelist-count {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-muted);
}

.filelist-body {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.filelist-item {
  padding: 4px 12px;
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filelist-item:hover { background: rgba(255, 255, 255, 0.04); }

/* ─── Web (Fetch / Search) result cards ────────────────────────────────── */
.web-card {
  margin: 10px 0;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-light);
  border-left: 3px solid #569cd6;
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}

.web-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(86, 156, 214, 0.06);
}

.web-card-icon { font-size: 14px; flex-shrink: 0; }

.web-card-query {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.web-result {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.web-result-title {
  font-size: 13px;
  color: #569cd6;
  text-decoration: none;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.web-result-url {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.web-result-snippet {
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
}

/* ─── Generic file path inline pill ────────────────────────────────────── */
.file-pill {
  display: inline-block;
  padding: 1px 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}
