/* ── Moderator — Neutral Dark Theme (Claude AI style) ────────────── */

:root {
  --bg-primary: #2b2b2b;
  --bg-card: #353535;
  --bg-accent: #4a4a4a;
  --highlight: #c4956a;
  --text-primary: #ececec;
  --text-secondary: #a8a8a8;
  --text-muted: #888888;
  --bg-input: #232323;
  --bg-nav: #1e1e1e;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.35);
  --radius-card: 12px;
  --radius-input: 10px;
  --radius-md: 8px;
  --radius-badge: 6px;
  --radius-sm: 4px;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --nav-height: 60px;
  --header-height: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  /* Status colors */
  --status-active: #4ade80;
  --status-inactive: #6b7280;
  --status-amber: #fbbf24;
  --status-error: #f87171;

  /* Memory type colors — muted for dark bg */
  --type-project-context: #60a5fa;
  --type-decision: #a78bfa;
  --type-task: #fbbf24;
  --type-bug: #f87171;
  --type-pattern: #34d399;
  --type-preference: #f472b6;
  --type-correction: #fb923c;
}

/* ── Reset ────────────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-stack);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  padding-top: var(--safe-top);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

input, button, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 2px;
}

/* ── Auth Modal ──────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 32px 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: var(--shadow-elevated);
  text-align: center;
}

.modal-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-content input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 16px;
}

.modal-content input:focus {
  border-color: var(--highlight);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--highlight);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  border-radius: var(--radius-input);
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.9;
}
.btn-primary:active {
  opacity: 0.8;
}

/* ── App Shell ───────────────────────────────────────────────────── */

#app {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* ── Tab Panels ──────────────────────────────────────────────────── */

.tab-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

.tab-panel.active {
  display: flex;
}

/* ── Tab Header ──────────────────────────────────────────────────── */

.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.tab-header h1 {
  font-size: 18px;
  font-weight: 700;
}

/* ── Project Selector (standard) ─────────────────────────────────── */

.project-select {
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-badge);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  max-width: 160px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a8a8a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.project-select-sm {
  max-width: 100px;
  padding: 6px 8px;
  padding-right: 24px;
  font-size: 12px;
}

/* ── Chat (Claude AI style) ──────────────────────────────────────── */

#tab-chat {
  position: relative;
}

/* Chat area — flex column, fills the tab */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* Empty state: welcome + input centered vertically */
.chat-area--empty {
  justify-content: center;
  align-items: center;
}

.chat-area--empty .chat-messages {
  display: none;
}

.chat-area--empty .chat-status {
  display: none;
}

.chat-area--empty .chat-welcome {
  display: flex;
}

.chat-area--empty .chat-input-wrapper {
  width: 100%;
  max-width: 600px;
  padding: 16px 20px 0;
}

/* Has messages: welcome hidden, messages scroll, input at bottom */
.chat-area--active .chat-welcome {
  display: none;
}

.chat-area--active .chat-messages {
  display: flex;
}

.chat-area--active .chat-input-wrapper {
  width: 100%;
}

/* Welcome */
.chat-welcome {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
}

.chat-welcome .welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--highlight);
  margin-bottom: 8px;
}

.chat-welcome h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-muted);
}

/* Usage widget */
.usage-widget {
  margin-top: 16px;
  max-width: 220px;
  width: 100%;
}

.usage-bar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.usage-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 20px;
  text-align: right;
  font-weight: 600;
}

.usage-track {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--highlight);
  transition: width 0.5s ease, background 0.3s;
  width: 0%;
}

.usage-fill.warn {
  background: var(--status-amber);
}

.usage-fill.danger {
  background: var(--status-error);
}

.usage-pct {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 32px;
  font-variant-numeric: tabular-nums;
}

.usage-reset {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

.usage-throttle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
}

.usage-throttle-label {
  color: var(--text-muted);
}

.usage-throttle-value {
  color: var(--highlight);
  font-weight: 600;
  cursor: pointer;
  padding: 1px 6px;
  border-radius: var(--radius-badge);
  transition: background 0.2s;
}

.usage-throttle-value:hover {
  background: var(--bg-input);
}

.usage-throttle-value.paused {
  color: var(--status-error);
  animation: pulse 2s ease-in-out infinite;
}

.usage-throttle-input {
  width: 48px;
  padding: 1px 4px;
  font-size: 11px;
  text-align: center;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--highlight);
  border-radius: var(--radius-badge);
  outline: none;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 8px;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--bg-accent);
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border-bottom-left-radius: 4px;
}

.chat-msg .msg-project {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.chat-msg .msg-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}

/* ── Scroll-to-bottom button (claude.ai style) ───────────── */
#scroll-to-bottom-btn {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  animation: fadeInUp 0.2s ease;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
#scroll-to-bottom-btn[hidden] {
  display: none;
}
#scroll-to-bottom-btn:hover {
  background: var(--highlight);
  color: var(--bg-primary);
}
#scroll-to-bottom-btn:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 2px;
}
#scroll-to-bottom-btn .scroll-btn-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--highlight);
  color: var(--bg-primary);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  line-height: 1.3;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Role labels ───────────────────────────────────────────── */
.msg-role-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.chat-msg.user .msg-role-label { color: var(--highlight); }
.chat-msg.assistant .msg-role-label { color: var(--status-active); }

/* ── Inline images in chat ────────────────────────────────── */
.chat-img { max-width: 100%; max-height: 400px; border-radius: 8px; margin: 6px 0; }

/* ── Session metadata bar ──────────────────────────────────── */
.session-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted);
  margin: 0 -16px 8px -16px;
  padding: 4px 16px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 1;
}
.session-meta .meta-chip {
  background: var(--bg-accent);
  padding: 1px 6px;
  border-radius: var(--radius-badge);
}
.session-meta .meta-chip--warn {
  background: rgba(255, 80, 80, 0.25);
  color: #ff6b6b;
}
.session-meta .meta-chip--worker {
  background: rgba(100, 180, 255, 0.2);
  color: #7cb3f0;
  cursor: help;
}
.session-meta .meta-chip--worker-busy {
  background: rgba(255, 200, 60, 0.25);
  color: #f0c040;
  cursor: help;
}
.session-meta .meta-chip--worker-off {
  background: rgba(140, 140, 140, 0.15);
  color: #888;
  cursor: help;
}
.session-meta .meta-chip--worker-err {
  background: rgba(255, 80, 80, 0.25);
  color: #ff6b6b;
  cursor: help;
}

/* ── Digest findings ─────────────────────────────────────────── */
.digest-findings--empty {
  opacity: 0.5;
}
.digest-findings--empty .digest-count {
  background: #666; color: #ccc;
}
.digest-findings--empty .digest-title {
  color: #888;
}
.digest-findings {
  margin: 0 0 8px 0;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border-left: 3px solid #f0c040;
  overflow: hidden;
}
.digest-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; user-select: none;
}
.digest-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #f0c040; flex: 1;
}
.digest-count {
  font-size: 11px; font-weight: 600;
  background: #f0c040; color: #000;
  padding: 1px 7px; border-radius: 10px; min-width: 16px; text-align: center;
}
.digest-toggle { color: var(--text-muted); font-size: 10px; }
.digest-body { padding: 0 12px 10px; max-height: 300px; overflow-y: auto; }
.digest-entry {
  padding: 6px 0; position: relative;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}
.digest-entry:last-of-type { border-bottom: none; }
.digest-cat--finding { padding-left: 8px; border-left: 2px solid #f0c040; }
.digest-cat--research { padding-left: 8px; border-left: 2px solid #7cb3f0; }
.digest-cat--error { padding-left: 8px; border-left: 2px solid #ff6b6b; }
.digest-meta {
  font-size: 11px; color: var(--text-muted, #888);
}
.digest-dismiss {
  position: absolute; right: 0; top: 6px;
  background: none; border: none; color: var(--text-muted, #888);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px;
}
.digest-dismiss:hover { color: #ff6b6b; }
.digest-summary {
  font-size: 13px; color: var(--text-primary, #e0e0e0);
  line-height: 1.4; margin-top: 2px;
}
.digest-ack-btn {
  display: block; width: 100%; margin-top: 8px;
  padding: 6px; background: var(--bg-accent, rgba(255,255,255,0.05));
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 6px; color: var(--text-muted, #888);
  cursor: pointer; font-size: 11px; text-align: center;
}
.digest-ack-btn:hover { background: #f0c040; color: #000; }
.digest-controls {
  display: flex; gap: 8px; margin-bottom: 8px; align-items: center;
}
.digest-period {
  background: var(--bg-accent, rgba(255,255,255,0.05));
  color: var(--text-primary, #e0e0e0);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 6px; padding: 4px 8px; font-size: 12px;
}
.digest-gen-btn {
  background: #f0c040; color: #000; border: none;
  border-radius: 6px; padding: 4px 12px; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.digest-gen-btn:hover { background: #e0b030; }
.digest-gen-btn:disabled { opacity: 0.6; cursor: wait; }
.digest-text {
  font-size: 13px; line-height: 1.6;
  color: var(--text-primary, #e0e0e0);
  white-space: pre-wrap; margin-bottom: 8px;
  max-height: 500px; overflow-y: auto;
}
.digest-findings-list {
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  padding-top: 6px; margin-top: 4px;
}

/* ── Tool / Thinking indicators ──────────────────────────────── */
.activity-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

/* Tools summary — single collapsible block grouping all tool calls */
.tools-summary {
  font-size: 12px;
  color: var(--text-muted);
  border-left: 2px solid var(--highlight);
  border-radius: var(--radius-badge);
  background: rgba(196, 149, 106, 0.06);
  cursor: pointer;
  overflow: hidden;
}
.tools-summary-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
}
.tools-summary-header .tool-icon { font-size: 14px; color: var(--highlight); }
.tools-summary-count { font-weight: 600; color: var(--text-secondary); }
.tools-summary-current { color: var(--highlight); font-size: 12px; margin-left: 4px; font-weight: 500; }
.tools-summary-timer { color: var(--text-secondary); font-size: 11px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.tools-usage-badge { font-size: 11px; color: var(--text-muted); margin-left: 8px; font-family: var(--font-mono, monospace); }
.tools-summary-expand { font-size: 10px; color: var(--text-muted); margin-left: auto; transition: transform 0.15s; }
.tools-summary.expanded .tools-summary-expand { transform: rotate(90deg); }

.tools-list {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 8px 6px;
}
.tools-summary.expanded .tools-list { display: flex; }

.tool-indicator {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: opacity 0.3s;
  cursor: pointer;
}
.tool-indicator:hover { background: rgba(196, 149, 106, 0.08); }

.tool-indicator.tool-done {
  opacity: 0.5;
  color: var(--text-muted);
}

.tool-icon { font-size: 14px; flex-shrink: 0; }
.tool-name { font-weight: 600; white-space: nowrap; font-size: 11px; }
.tool-input { color: var(--text-muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(200px, 50vw); min-width: 0; }
.tool-expand { font-size: 10px; color: var(--text-muted); margin-left: auto; flex-shrink: 0; }

/* Tool result — collapsed by default, expand on click */
.tool-result {
  display: none;
  width: 100%;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 4px 8px;
  margin-top: 4px;
  background: rgba(196, 149, 106, 0.05);
  border-radius: var(--radius-sm);
  max-height: min(150px, 30vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: monospace;
}
.tool-indicator.expanded .tool-result { display: block; }
.tool-indicator.expanded .tool-expand { transform: rotate(90deg); }
.tool-result.tool-error { color: var(--status-error); }

/* Thinking block — collapsed by default, expand on click */
.thinking-block {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 10px;
  background: rgba(168, 168, 168, 0.06);
  border-left: 2px solid rgba(168, 168, 168, 0.25);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.thinking-block .thinking-text { white-space: pre-wrap; word-break: break-word; }
.thinking-placeholder-text { opacity: 0.5; }

/* Legacy — keep for backward compat */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 8px;
  font-style: italic;
}

/* ── Stop button state ───────────────────────────────────────── */
.btn-send.btn-stop {
  background: var(--status-error);
  color: #fff;
  border-radius: var(--radius-badge);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.btn-send.btn-stop svg { display: none; }

/* ── Image preview ───────────────────────────────────────────── */
.image-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
}
.image-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-badge);
  border: 1px solid var(--border-subtle);
}
.image-preview .image-name {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-preview .image-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.image-preview .image-remove:hover { color: var(--status-error); }

/* ── File attachment chips (Phase 2b) ────────────────────────── */
.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  margin-bottom: 4px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
}
.file-chip-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.file-chip-remove:hover { color: var(--status-error); }

.chat-image-preview {
  display: block;
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-md);
  margin-top: 6px;
  border: 1px solid var(--border-subtle);
}

.btn-image { color: var(--text-muted); }
.btn-image:hover { color: var(--highlight); }

.chat-status {
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.status-timer { color: var(--text-muted); font-size: 11px; }

.chat-status[hidden] {
  display: none;
}

.chat-status .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--highlight);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Input wrapper */
.chat-input-wrapper {
  flex-shrink: 0;
  padding: 8px 12px calc(12px + var(--safe-bottom));
}

/* Input bar — rounded card with textarea */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  transition: border-color 0.15s;
}

/* On mobile: two rows — chips top, textarea+send bottom */
@media (max-width: 479px) {
  /* Actions tab: let search + filters drop to their own rows so the
     8 checkboxes don't push content off-screen. */
  .tab-header {
    align-items: flex-start;
  }
  .actions-filters {
    flex-shrink: 1;
    flex-basis: 100%;
    gap: 6px 10px;
    font-size: 12px;
  }
  .actions-filter-sep {
    display: none;
  }
  .task-search {
    flex-basis: 100%;
  }
  .chat-input-bar {
    display: grid;
    grid-template-columns: auto auto auto auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 6px;
    align-items: center;
  }
  .chat-input-bar .btn-new-chat { grid-row: 1; grid-column: 1; }
  .chat-input-bar .btn-restart { grid-row: 1; grid-column: 2; }
  .chat-input-bar .chat-list-chip { grid-row: 1; grid-column: 3; }
  .chat-input-bar .project-chip { grid-row: 1; grid-column: 4; }
  .chat-input-bar .provider-chip { grid-row: 1; grid-column: 5; }
  .chat-input-bar textarea {
    grid-row: 2;
    grid-column: 1 / 6;
    min-width: 0;
  }
  .chat-input-bar .btn-send {
    grid-row: 2;
    grid-column: 6;
    align-self: flex-end;
  }
  .chat-input-bar .btn-image,
  .chat-input-bar .btn-voice {
    padding: 4px;
  }
  .chat-list-chip,
  .project-chip,
  .provider-chip {
    padding: 3px 8px;
    font-size: 11px;
  }
}

.chat-input-bar:focus-within {
  border-color: rgba(255, 255, 255, 0.15);
}

/* Textarea — auto-grows */
.chat-input-bar textarea {
  flex: 1;
  padding: 6px 8px;
  color: var(--text-primary);
  font-size: 15px;
  background: transparent;
  min-width: 0;
  resize: none;
  overflow-y: auto;
  max-height: 120px;
  line-height: 1.5;
  border: none;
  outline: none;
  font-family: var(--font-stack);
}

.chat-input-bar textarea::placeholder {
  color: var(--text-muted);
}

/* Input bar chips (shared) */
.input-chip,
.chat-list-chip,
.project-chip,
.provider-chip {
  background: var(--bg-accent);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 16px;
  border: none;
  font-size: 12px;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  margin-bottom: 2px;
  touch-action: manipulation;
}
.chat-list-chip { max-width: 130px; }
.project-chip { max-width: 110px; }
.provider-chip { max-width: 84px; }

/* Icon buttons */
.btn-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
  margin-bottom: 0;
}
.btn-restart { opacity: 0.4; }
.btn-restart:hover, .btn-restart:active { opacity: 0.8; background: rgba(255,180,0,0.15); }

.btn-icon:active {
  opacity: 0.7;
}

.btn-send {
  background: var(--highlight);
  color: #fff;
}

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

.btn-voice {
  color: var(--text-muted);
  background: transparent;
}

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

.btn-voice.recording {
  color: #fff;
  background: var(--status-error);
  animation: pulse 1.2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Search Bar ──────────────────────────────────────────────────── */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 14px;
}

.search-bar input:focus {
  border-color: rgba(255, 255, 255, 0.15);
}

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

/* ── Memory Stats ────────────────────────────────────────────────── */

.memory-stats {
  display: flex;
  gap: 8px;
  padding: 12px 16px 4px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  padding: 8px 14px;
  border-radius: var(--radius-badge);
  min-width: 60px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--highlight);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-chip--clickable {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  border: 1px solid transparent;
}

.stat-chip--clickable:hover {
  border-color: rgba(255, 255, 255, 0.12);
}
.stat-chip--clickable:active {
  background: var(--bg-accent);
  border-color: var(--highlight);
}

/* ── Card List ───────────────────────────────────────────────────── */

.card-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
}

.card-list .empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 14px;
}

.empty-state-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.spinner-inline {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--highlight);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* ── Memory Card ─────────────────────────────────────────────────── */

.memory-card .memory-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.memory-card .memory-content.expanded {
  -webkit-line-clamp: unset;
  display: block;
}

.memory-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.badge-keyword {
  display: inline-block;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.memory-card .memory-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-type {
  color: #fff;
}

.badge-type[data-type="project_context"] { background: var(--type-project-context); }
.badge-type[data-type="decision"]        { background: var(--type-decision); }
.badge-type[data-type="task"]            { background: var(--type-task); color: #000; }
.badge-type[data-type="bug"]             { background: var(--type-bug); }
.badge-type[data-type="pattern"]         { background: var(--type-pattern); }
.badge-type[data-type="preference"]      { background: var(--type-preference); }
.badge-type[data-type="correction"]      { background: var(--type-correction); }

.badge-project {
  background: var(--bg-accent);
  color: var(--text-secondary);
}

.badge-score {
  background: transparent;
  color: var(--text-muted);
  padding: 0;
  font-weight: 400;
  margin-left: auto;
  font-size: 12px;
}

.importance-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}

.importance-bar-track {
  width: 40px;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.importance-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--highlight);
  transition: width 0.3s ease;
}

/* ── Project Card ────────────────────────────────────────────────── */

.project-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.project-info-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-info-header .project-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

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

.status-dot.active   { background: var(--status-active); }
.status-dot.inactive { background: var(--status-inactive); }
.status-dot.paused   { background: var(--status-amber); }

.project-info-card .project-stack {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.project-info-card .project-paths {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.project-info-card .project-paths .path-label {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Task Board ─────────────────────────────────────────────────── */

.actions-filters {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
}
.actions-filter-sep {
  color: var(--border, #444);
  user-select: none;
}
.toggle-completed {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.toggle-completed input { accent-color: var(--highlight); }

.task-card {
  border-left: 3px solid var(--text-muted);
  padding: 12px 14px;
  position: relative;
}
.task-card.task-status--running   { border-left-color: var(--status-amber); }
.task-card.task-status--completed { border-left-color: var(--status-active); }
.task-card.task-status--failed    { border-left-color: var(--status-error); }
.task-card.task-status--interrupted { border-left-color: var(--status-error); opacity: 0.6; }
.task-card.task-status--blocked   { border-left-color: var(--highlight); }
.task-card.task-status--pending   { border-left-color: var(--text-muted); }

.task-done-text { text-decoration: line-through; color: var(--text-muted); }
.task-card.task-acked { opacity: 0.5; border-left-color: var(--text-muted); }
.task-card.task-acked:hover { opacity: 0.7; }
.btn-task-ack.acked { color: var(--status-active); }
.task-card.task-wife { border-left-color: #e891c0; }
.task-card.task-wife .task-status-badge--completed { background: #e891c0; color: #1a1a1a; }

.btn-load-more {
  display: block;
  width: 100%;
  padding: 8px;
  margin: 4px 0;
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  text-align: center;
}
.btn-load-more:hover { background: var(--bg-accent); color: var(--text-primary); }

/* Task details (expandable body below title) */
.task-details {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 4px;
  cursor: pointer;
}
.task-details.task-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Action buttons for user tasks (Approve / Reject / Comment) */
.task-action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.btn-action {
  padding: 6px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-accent);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  min-height: 36px;
  transition: background 0.15s, border-color 0.15s;
  flex: 1;
  text-align: center;
}
.btn-approve { border-color: var(--status-active); color: var(--status-active); }
.btn-approve:hover { background: var(--status-active); color: #000; }
.btn-start { border-color: #4fc3f7; color: #4fc3f7; }
.btn-start:hover { background: #4fc3f7; color: #000; }
.btn-reject { border-color: var(--status-error); color: var(--status-error); }
.btn-reject:hover { background: var(--status-error); color: #fff; }
.btn-comment:hover { background: var(--highlight); color: #000; }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* Running status bar */
.running-status {
  display: none;  /* Replaced by running task card in Queue */
}
.running-status .running-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-amber);
  animation: pulse 1.2s ease infinite;
  flex-shrink: 0;
}
.running-status .running-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 12px 14px 4px;
}
.task-section-count {
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.6;
}

/* Status badges */
.task-status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.3;
}
.task-status-badge--running   { background: var(--status-amber); color: #000; }
.task-status-badge--pending   { background: var(--bg-accent); color: var(--text-secondary); border: 1px solid var(--border-subtle); }
.task-status-badge--blocked   { background: var(--highlight); color: #000; }
.task-status-badge--completed { background: var(--status-active); color: #000; }
.task-status-badge--failed    { background: var(--status-error); color: #fff; }
.task-status-badge--interrupted { background: var(--bg-accent); color: var(--status-error); border: 1px solid var(--status-error); }
.user-task-check {
  font-size: 16px;
  cursor: pointer;
  user-select: none;
  line-height: 1;
}
.task-project {
  font-size: 11px;
  color: var(--highlight);
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.task-search {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 200px;
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
}
.task-search:focus { border-color: var(--highlight); }
.task-search::placeholder { color: var(--text-tertiary); }

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

.task-priority {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  line-height: 1.2;
}
.task-priority.p-high { background: var(--status-error); color: #fff; }
.task-priority.p-mid  { background: var(--status-amber); color: #000; }
.task-priority.p-low  { background: var(--bg-accent); color: var(--text-secondary); }

.task-seq {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.task-id-short {
  font-size: 10px;
  font-family: monospace;
  color: var(--text-muted);
  opacity: 0.6;
  cursor: help;
}

.task-type {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.task-running-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-amber);
  animation: pulse 1.2s ease infinite;
  flex-shrink: 0;
}

.task-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.task-prompt {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: pointer;
}

.task-prompt.task-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-context {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 10px 0;
  padding: 10px 14px;
  background: var(--bg-primary);
  border-left: 3px solid var(--highlight);
  border-radius: 0 var(--radius-badge) var(--radius-badge) 0;
  line-height: 1.6;
  word-break: break-word;
}
.task-context .ctx-h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 10px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.task-context .ctx-h2:first-child { margin-top: 0; }
.task-context .ctx-h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--highlight);
  margin: 8px 0 2px;
}
.task-context strong { color: var(--text-primary); }
.task-context .ctx-ul {
  list-style: disc;
  padding-left: 18px;
  margin: 4px 0;
}
.task-context .ctx-li {
  margin: 2px 0;
}

.task-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.btn-option {
  padding: 6px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-accent);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  min-height: 36px;
  transition: background 0.15s;
}
.btn-option:hover { background: var(--highlight); color: #000; }

.task-answer-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.task-answer-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
}
.task-answer-input:focus { border-color: var(--highlight); }
.task-answer-input::placeholder { color: var(--text-muted); }

.task-edit-area {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--highlight);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  margin: 6px 0 4px;
}
.task-edit-buttons {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.btn-sm {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-badge);
  font-size: 13px;
  cursor: pointer;
  min-height: 36px;
}

.task-answer-submit {
  width: auto !important;
  flex-shrink: 0;
  padding: 8px 18px;
}

.task-result {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  cursor: pointer;
}

.task-result.task-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-expand-hint {
  display: inline-block;
  font-size: 11px;
  color: var(--highlight);
  cursor: pointer;
  margin-top: 4px;
  opacity: 0.8;
}
.task-expand-hint:hover { opacity: 1; text-decoration: underline; }
.task-expand-hint:active { opacity: 0.5; }

.status-expand-hint {
  display: inline-block;
  font-size: 11px;
  color: var(--highlight);
  cursor: pointer;
  margin-left: 6px;
  opacity: 0.8;
}
.status-expand-hint:hover { opacity: 1; text-decoration: underline; }

.task-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}

.nav-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--highlight); color: #000;
  border-radius: 10px; padding: 1px 5px;
  font-size: 0.65rem; font-weight: 600;
  transition: background 0.3s;
}
.nav-badge.badge-pulse {
  background: var(--status-amber);
  animation: badge-pulse 1.5s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.nav-btn { position: relative; }

/* ── Bottom Navigation ───────────────────────────────────────────── */

/* ── Health Dot ──────────────────────────────────────────────────── */

.health-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: 3px;
  vertical-align: middle;
}

.health-dot--online { background: var(--status-active); }
.health-dot--offline { background: var(--status-error); }
.health-dot--checking { background: var(--text-muted); }

/* ── Offline Banner ─────────────────────────────────────────────── */

.offline-banner {
  background: rgba(248, 113, 113, 0.15);
  color: var(--status-error);
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  display: none;
}
.offline-banner:not([hidden]) {
  display: flex;
}

.btn-reconnect {
  background: rgba(248, 113, 113, 0.2);
  color: var(--status-error);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
}

.btn-reconnect:hover {
  background: rgba(248, 113, 113, 0.3);
}
.btn-reconnect:active {
  background: rgba(248, 113, 113, 0.35);
}

/* ── Toast ───────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  pointer-events: auto;
}
.toast-action {
  margin-left: 12px;
  padding: 2px 10px;
  background: var(--highlight);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-nav);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  padding: 6px 0;
}

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

.nav-btn.active,
.nav-btn.active:hover {
  color: var(--highlight);
}

.nav-btn:hover {
  color: var(--text-secondary);
}
.nav-btn:active {
  opacity: 0.7;
}

/* ── Memory Card Actions ─────────────────────────────────────────── */

.memory-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-end;
}

.btn-card {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  transition: background 0.15s, color 0.15s;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

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

.btn-card.btn-delete:hover {
  color: var(--status-error);
}

/* ── FAB (Floating Action Button) ────────────────────────────────── */

.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--highlight);
  color: #fff;
  font-size: 28px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-elevated);
  z-index: 50;
  transition: transform 0.15s, opacity 0.15s;
  border: none;
  line-height: 1;
}

.fab:active {
  transform: scale(0.92);
  opacity: 0.85;
}

/* ── Modal Form (Add Memory) ─────────────────────────────────────── */

.modal-content form textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: 14px;
  resize: vertical;
  min-height: 70px;
  margin-bottom: 12px;
  font-family: var(--font-stack);
}

.modal-content form textarea:focus {
  border-color: var(--highlight);
}

.modal-content form select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-badge);
  color: var(--text-primary);
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a8a8a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.modal-content form input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 12px;
}

.modal-content form input[type="text"]:focus {
  border-color: var(--highlight);
}

.modal-content form input[type="range"] {
  flex: 1;
  accent-color: var(--highlight);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.form-row select {
  flex: 1;
  min-width: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.form-actions button {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-input);
}

.btn-secondary {
  background: var(--bg-accent);
  color: var(--text-secondary);
  transition: opacity 0.15s;
}

.btn-secondary:hover {
  background: var(--bg-primary);
}
.btn-secondary:active {
  opacity: 0.7;
}

/* ── Scrollbar (desktop) ─────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 4px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

/* ── Utility ─────────────────────────────────────────────────────── */

.fade-in {
  animation: fadeIn 0.2s ease;
}

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

/* ── Responsive: tablets / desktop ───────────────────────────────── */

@media (min-width: 600px) {
  .chat-msg {
    max-width: 70%;
  }

  .card-list {
    padding: 12px 24px 24px;
  }

  .tab-header {
    padding: 12px 24px;
  }

  .memory-stats {
    padding: 12px 24px 4px;
  }

  .search-bar {
    padding: 8px 24px 12px;
  }

  .chat-input-wrapper {
    padding: 8px 24px 16px;
  }

  .chat-messages {
    padding: 0 24px 8px;
  }

  .chat-area--empty .chat-input-wrapper {
    padding: 16px 24px 0;
  }
}

@media (min-width: 768px) {
  :root {
    --nav-height: 64px;
  }

  .nav-btn {
    font-size: 11px;
    gap: 4px;
  }

  .nav-btn svg {
    width: 22px;
    height: 22px;
  }

  .chat-input-wrapper {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
  }

  .chat-area--empty .chat-input-wrapper {
    max-width: 600px;
  }
}

/* ── Screen-reader only ──────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Chat restored indicator ─────────────────────────────────────── */

.chat-restored-indicator {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ── History tab ────────────────────────────────────────────────── */

.history-card {
  cursor: pointer;
  margin-bottom: 4px;
}

.history-header {
  padding: 10px 12px;
}

.history-header.history-current {
  border-left: 3px solid var(--highlight);
  padding-left: 9px;
}

.history-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.history-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.history-messages {
  padding: 0 12px 8px;
  max-height: 300px;
  overflow-y: auto;
}

.history-msg {
  font-size: 13px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-msg--user {
  background: var(--bg-chat-user, rgba(100, 100, 255, 0.1));
  color: var(--text-primary);
}

.history-msg--assistant {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.history-msg-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

.history-actions {
  display: flex;
  gap: 8px;
  padding: 4px 12px 10px;
}

.btn-sm {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
}

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

.btn-delete-chat {
  color: var(--error, #e55);
  border-color: var(--error, #e55);
}

.btn-delete-chat:hover {
  background: var(--error, #e55);
  color: white;
}

.history-load-more {
  width: 100%;
  margin-top: 8px;
}

/* ── Logs tab ───────────────────────────────────────────────────── */

.log-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  background: #1a1a1a;
  font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.log-line {
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  padding: 1px 0;
}

.hidden { display: none !important; }

/* Subtab switcher (Logs | Terminal) */
.log-subtabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary, #1a1a1a);
  border-radius: 6px;
  padding: 2px;
}

.log-subtab {
  padding: 4px 14px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.log-subtab:hover {
  background: rgba(255,255,255,0.06);
}

.log-subtab.active {
  background: var(--accent, #5b9bf7);
  color: #fff;
}

/* Terminal color coding */
.term-thinking {
  color: #888;
  font-style: italic;
}

.term-tool {
  color: #5ec4ff;
}

.term-text {
  color: #d4d4d4;
}

/* ── Worker tab ────────────────────────────────────────────────── */

.worker-status-bar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.w-status-row {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
}
.w-status-secondary { margin-top: 4px; opacity: 0.7; font-size: 0.85em; }
.w-stat { display: flex; align-items: center; gap: 4px; font-size: 0.9em; }
.w-label { color: var(--text-muted); font-size: 0.85em; }
.w-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.w-dot--on { background: #22c55e; box-shadow: 0 0 4px #22c55e; }
.w-dot--off { background: #ef4444; }

.worker-send-form {
  display: flex; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.worker-task-input {
  flex: 1; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 0.9em;
}
.worker-controls { display: flex; gap: 6px; }
.btn-danger-sm { color: #ef4444 !important; border-color: #ef4444 !important; }
.btn-danger-sm:hover { background: #ef444420; }

.worker-sections {
  flex: 1; overflow-y: auto; padding: 12px;
}
.worker-dialogue h3, .worker-tasks h3 {
  font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin: 0 0 8px;
}
.w-msg {
  margin-bottom: 8px; padding: 8px 10px; border-radius: 8px;
  font-size: 0.9em; line-height: 1.4;
}
.w-msg-lead { background: var(--bg-user-msg, #1a3a5c); }
.w-msg-worker { background: var(--bg-ai-msg, #1e293b); }
.w-msg-header { display: flex; gap: 8px; margin-bottom: 4px; font-size: 0.8em; }
.w-msg-role { font-weight: 600; color: var(--highlight); }
.w-msg-ts { color: var(--text-muted); }
.w-msg-body { white-space: pre-wrap; word-break: break-word; }
.w-finding {
  padding: 6px 10px; margin-bottom: 6px; border-radius: 6px;
  background: var(--bg-card); border-left: 3px solid var(--highlight);
  font-size: 0.85em;
}
.w-task { margin-bottom: 6px; padding: 8px 10px; border-radius: 6px; font-size: 0.85em; line-height: 1.4; }
.w-task-ok { background: var(--bg-card); border-left: 3px solid #22c55e; }
.w-task-run { background: var(--bg-card); border-left: 3px solid #f59e0b; }
.w-task-fail { background: var(--bg-card); border-left: 3px solid #ef4444; }
.w-task-header { display: flex; gap: 6px; align-items: center; margin-bottom: 3px; }
.w-task-icon { font-size: 0.9em; }
.w-task-type { font-weight: 500; color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-task-result { white-space: pre-wrap; word-break: break-word; color: var(--text-muted); font-size: 0.9em; margin-top: 2px; }
.w-clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.w-empty { color: var(--text-muted); text-align: center; padding: 24px; }
.worker-offline { color: var(--text-muted); text-align: center; padding: 24px; }
.w-toast { color: #ef4444; font-size: 0.8em; padding: 4px 0; animation: fadeOut 3s forwards; }
@keyframes fadeOut { 0%,70% { opacity: 1; } 100% { opacity: 0; } }

/* ── Reduced motion ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
