/* Research AI V1 - Muse-inspired Chat-first Design System */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Light Theme */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-glass: rgba(255, 255, 255, 0.88);
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --accent-primary: #2563eb;
  --accent-hover: #1d4ed8;
  --bubble-user: #2563eb;
  --bubble-user-text: #ffffff;
  --bubble-ai: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 10px -1px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-glass: rgba(17, 24, 39, 0.85);
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --border-subtle: #1e293b;
  --border-strong: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent-primary: #3b82f6;
  --accent-hover: #60a5fa;
  --bubble-user: #2563eb;
  --bubble-user-text: #ffffff;
  --bubble-ai: #111827;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

/* Top Navigation Bar */
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 20px 12px 20px;
  background-color: var(--bg-surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 30;
}

.project-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-badge {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--accent-primary);
}

.demo-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
  letter-spacing: 0.02em;
}

.project-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

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

/* Budget Pill Button */
.budget-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.budget-pill:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
}

.budget-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
}

.icon-button {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.icon-button:hover {
  background-color: var(--bg-secondary);
  color: var(--text-main);
}

/* Chat Timeline */
.chat-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 140px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
}

/* Model Switch Alert Divider */
.model-switch-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0;
  font-size: 11.5px;
  color: var(--text-faint);
}

.model-switch-divider::before,
.model-switch-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border-subtle);
}

.model-switch-badge {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 2px 10px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Message Rows */
.msg-row {
  display: flex;
  animation: fadeIn 0.22s ease-out;
}

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

/* User Message */
.msg-row.user-row {
  align-self: flex-end;
  max-width: 82%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.user-bubble {
  background-color: var(--bubble-user);
  color: var(--bubble-user-text);
  padding: 11px 16px;
  border-radius: 18px 18px 4px 18px;
  font-size: 14.5px;
  line-height: 1.55;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
  word-break: break-word;
}

.user-time {
  font-size: 11px;
  color: var(--text-faint);
  margin-right: 2px;
}

/* Assistant Message (Muse Style: Avatar on left, breathable bubble) */
.msg-row.assistant-row {
  align-self: flex-start;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
}

/* Avatar Styling */
.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  margin-top: 2px;
}

.msg-content-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}

.msg-author-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 13.5px;
}

.msg-role-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.msg-time {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: auto;
}

/* Assistant Bubble */
.assistant-bubble {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px 18px 18px 18px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prose-content {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-main);
  word-break: break-word;
}

.prose-content p {
  margin-bottom: 0.75em;
}

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

.speech-bottom-line {
  font-weight: 600;
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid #6366f1;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.speech-bottom-line span {
  display: inline-block;
  font-size: 12px;
  color: #fff;
  background: #6366f1;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 8px;
}

.speech-points {
  margin: 0 0 8px 18px;
  padding: 0;
}

.speech-points li {
  margin-bottom: 4px;
}

.speech-preview {
  max-height: 9.5em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

.speech-full > summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.speech-full[open] > summary {
  margin-bottom: 8px;
}

.prose-content blockquote {
  border-left: 3px solid #eab308;
  background: rgba(234, 179, 8, 0.08);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 0.8em;
  font-size: 13.5px;
  color: var(--text-muted);
}

.quote-citation-box {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 7px 12px;
  border-radius: 6px;
  border-left: 3px solid #059669;
}

.msg-footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-faint);
  padding-left: 2px;
}

.simulated-label {
  color: #eab308;
  font-weight: 500;
}

/* Evidence Badges */
.evidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 9999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.evidence-badge.verified_evidence {
  background-color: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.evidence-badge.user_confirmed {
  background-color: rgba(37, 99, 235, 0.12);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.evidence-badge.hypothesis {
  background-color: rgba(147, 51, 234, 0.12);
  color: #9333ea;
  border: 1px solid rgba(147, 51, 234, 0.25);
}

.evidence-badge.disputed {
  background-color: rgba(234, 88, 12, 0.12);
  color: #ea580c;
  border: 1px solid rgba(234, 88, 12, 0.25);
}

.confidence-pill {
  font-size: 11px;
  color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Group Chat Session Container (Quick Review & Deep Council) */
.council-session-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.council-session-banner {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.council-session-banner.quick-review {
  border-left: 4px solid #3b82f6;
}

.council-session-banner.deep-council {
  border-left: 4px solid #8b5cf6;
}

.banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.banner-topic {
  font-size: 13.5px;
  color: var(--text-muted);
}

.banner-subtext {
  font-size: 12px;
  color: var(--text-faint);
}

/* Round Divider */
.round-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
  position: relative;
}

.round-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background-color: var(--border-subtle);
  z-index: 1;
}

.round-badge {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 3px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  position: relative;
  z-index: 2;
  box-shadow: var(--shadow-sm);
}

/* Expandable Advanced View (Collapsible Comparison & Report) */
.advanced-view-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-top: 6px;
}

.advanced-view-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--bg-secondary);
  border: none;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
  text-align: left;
}

.advanced-view-toggle:hover {
  background-color: var(--bg-tertiary);
}

.toggle-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-arrow {
  font-size: 12px;
  color: var(--text-muted);
}

.advanced-view-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* Parallel Comparison Grid in Advanced View */
.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.model-subcard {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subcard-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-main);
}

/* Disagreements Box */
.disagreement-matrix-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.disagreement-title {
  font-size: 13px;
  font-weight: 600;
  color: #ea580c;
  display: flex;
  align-items: center;
  gap: 6px;
}

.disagreement-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.disagreement-row:last-child {
  border-bottom: none;
}

.disagreement-model-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
}

.disagreement-model-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Consensus Summary Box */
.consensus-box {
  background-color: var(--bg-secondary);
  border-left: 3px solid var(--accent-primary);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.consensus-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.consensus-body {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.advanced-view-footer {
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  justify-content: flex-end;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 8px;
}

/* Bottom Interactive Toolbar & Input */
.bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 12px) 20px;
  background-color: var(--bg-surface-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-subtle);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Mode Selection Pills */
.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.mode-bar::-webkit-scrollbar {
  display: none;
}

.mode-pills-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-pill {
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.mode-pill.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

/* Model Selector Dropdown Pill */
.model-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.model-select-pill {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 24px 5px 10px;
  border-radius: 9999px;
  cursor: pointer;
}

.model-select-arrow {
  position: absolute;
  right: 8px;
  font-size: 9px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Input Form */
.input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  transition: border-color 0.15s ease;
}

.input-form:focus-within {
  border-color: var(--accent-primary);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.45;
  padding: 4px 0;
}

.send-button {
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.send-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.send-button:not(:disabled):active {
  transform: scale(0.94);
}

/* Modals & Drawers */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 85vh;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.progress-bar-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background-color: var(--bg-tertiary);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--accent-primary);
  border-radius: 9999px;
}

.progress-fill.council {
  background-color: #8b5cf6;
}

/* Research Memories List in Modal */
.memory-item-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.memory-item-title {
  font-size: 13px;
  font-weight: 600;
}

.memory-item-content {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* iPhone Touch & Responsive Optimization */
@media (max-width: 640px) {
  .app-container {
    max-width: 100%;
  }
  .chat-timeline {
    padding: 16px 14px 130px 14px;
    gap: 16px;
  }
  .top-navbar {
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px 14px;
  }
  .bottom-dock {
    padding: 8px 14px calc(env(safe-area-inset-bottom, 0px) + 10px) 14px;
  }
  .msg-row.user-row {
    max-width: 88%;
  }
  .msg-row.assistant-row {
    gap: 9px;
  }
  .msg-avatar {
    width: 30px;
    height: 30px;
    font-size: 13px;
    border-radius: 8px;
  }
  .assistant-bubble {
    padding: 12px 14px;
    font-size: 14px;
  }
  .models-grid {
    grid-template-columns: 1fr;
  }
}

.prose-content:has(.speech-full[open]) .speech-preview {
  display: none;
}

/* ===== Layout v34: nothing floats over the conversation; wide screens get a sidebar ===== */
html,
body {
  height: 100%;
}

body {
  min-height: 0;
  height: 100dvh;
}

.app-container {
  height: 100dvh;
  max-width: none;
  --content-gutter: max(20px, calc((100% - 860px) / 2));
}

.top-navbar {
  padding-left: var(--content-gutter);
  padding-right: var(--content-gutter);
}

.chat-timeline {
  min-height: 0;
  padding: 20px var(--content-gutter) 24px;
}

/* The dock is now part of the page flow instead of covering the bottom of the chat */
.bottom-dock {
  position: static;
  max-width: none;
  width: 100%;
  padding-left: var(--content-gutter);
  padding-right: var(--content-gutter);
}

.speech-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 640px) {
  .app-container {
    --content-gutter: 14px;
  }
  .chat-timeline {
    padding-bottom: 16px;
  }
  .brand-badge {
    display: none;
  }
  .project-brand {
    min-width: 0;
    flex: 1;
  }
  .project-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-actions {
    gap: 4px;
    flex-shrink: 0;
  }
  .nav-actions .budget-pill {
    padding: 4px 8px;
    white-space: nowrap;
  }
  .nav-actions .icon-button {
    padding: 4px;
  }
}

@media (min-width: 1024px) {
  .app-container {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    --content-gutter: max(32px, calc((100% - 1200px) / 2));
  }

  /* Sidebar background spanning the full height */
  .app-container::before {
    content: "";
    grid-column: 1;
    grid-row: 1 / -1;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
  }

  .top-navbar {
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 22px 18px 14px;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    position: relative;
    z-index: 1;
  }

  .project-title {
    font-size: 17px;
    line-height: 1.35;
  }

  .nav-actions {
    flex-wrap: wrap;
  }

  .bottom-dock {
    display: contents;
  }

  .mode-bar {
    grid-column: 1;
    grid-row: 2;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 6px 18px;
    overflow: visible;
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--border-subtle);
    padding-top: 16px;
  }

  .mode-pills-group {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .mode-pill {
    justify-content: flex-start;
    padding: 10px 12px;
    font-size: 13.5px;
    border-radius: 10px;
  }

  .model-select-wrapper,
  .model-select-pill {
    width: 100%;
  }

  .model-select-pill {
    border-radius: 10px;
    padding: 9px 26px 9px 10px;
    text-overflow: ellipsis;
  }

  .chat-timeline {
    grid-column: 2;
    grid-row: 1 / 4;
    padding: 28px var(--content-gutter) 20px;
  }

  .input-form {
    grid-column: 2;
    grid-row: 4;
    margin: 0 var(--content-gutter) 20px;
  }
}

/* Very wide screens: the three reviewers sit side by side */
@media (min-width: 1200px) {
  .speech-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
  }
  .speech-grid .msg-row.assistant-row {
    flex-direction: column;
    gap: 8px;
  }
  .speech-grid .msg-header {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .demo-tag {
    white-space: nowrap;
  }
  #authStatusText {
    display: inline-block;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  /* Spending is still shown before every paid request; free up room for the project title */
  #budgetPill {
    display: none;
  }
}

/* ===== v35: short model tags, compact key-point summary, follow-up buttons ===== */
.model-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-main);
}
.model-tag.tag-gpt { background: rgba(16, 163, 127, 0.15); color: #10a37f; }
.model-tag.tag-claude { background: rgba(217, 119, 87, 0.16); color: #d97757; }
.model-tag.tag-gemini { background: rgba(66, 133, 244, 0.15); color: #4285f4; }
.round-tag {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: 4px;
}

.followup-btn {
  display: inline-block;
  margin-left: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--accent-primary);
  cursor: pointer;
  vertical-align: baseline;
  white-space: nowrap;
  opacity: 0.75;
}
.followup-btn:hover {
  opacity: 1;
  background: rgba(59, 130, 246, 0.1);
}

.syn-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}
.syn-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.syn-title {
  font-size: 13px;
  font-weight: 700;
}
.syn-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  margin-left: 4px;
}
.syn-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.syn-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  font-size: 13.5px;
  line-height: 1.55;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-secondary);
}
.syn-source {
  white-space: nowrap;
}
.syn-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.syn-text.expanded {
  display: block;
}
.syn-more > summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.syn-more[open] > summary {
  margin-bottom: 6px;
}
.syn-empty,
.syn-note {
  font-size: 12px;
  color: var(--text-faint);
}

@media (max-width: 640px) {
  .syn-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .syn-source {
    grid-column: 1 / -1;
  }
}
