:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --danger: #ef4444;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 310px;
  --header-height: 60px;
}

/* Dark Theme */
:root,
[data-theme="dark"] {
  --bg-card: rgba(18, 24, 38, 0.85);
  --bg-sidebar: #171717;
  --bg-main: #212121;
  --border-card: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(11, 15, 25, 0.7);
  --border-input: rgba(255, 255, 255, 0.12);
  --code-block-bg: rgba(0, 0, 0, 0.3);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --chat-user-bg: linear-gradient(135deg, #5F99F7, #8285F4);
  --chat-user-text: #ffffff;
  --chat-assistant-text: #f1f5f9;
  --thinking-bg: rgba(139, 92, 246, 0.08);
  --thinking-border: rgba(139, 92, 246, 0.28);
  --thinking-text: #ddd6fe;
  --thinking-header-text: #a78bfa;
  --segmented-bg: rgba(255, 255, 255, 0.05);
  --segmented-active-bg: rgba(59, 130, 246, 0.22);
  --segmented-active-border: rgba(59, 130, 246, 0.4);
  --segmented-active-text: #ffffff;
  --theme-btn-active: rgba(255, 255, 255, 0.16);
  --item-hover: rgba(255, 255, 255, 0.06);
  --item-active: rgba(59, 130, 246, 0.15);
  --backdrop-bg: rgba(0, 0, 0, 0.65);
}

/* Light Theme */
[data-theme="light"] {
  --bg-card: rgba(255, 255, 255, 0.94);
  --bg-sidebar: #f9f9f9;
  --bg-main: #ffffff;
  --border-card: rgba(225, 232, 240, 0.95);
  --bg-input: #ffffff;
  --border-input: #cbd5e1;
  --code-block-bg: #fafafa;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --chat-user-bg: linear-gradient(135deg, #3b82f6, #818cf8);
  --chat-user-text: #ffffff;
  --chat-assistant-text: #1e293b;
  --thinking-bg: rgba(124, 58, 237, 0.05);
  --thinking-border: rgba(124, 58, 237, 0.2);
  --thinking-text: #5b21b6;
  --thinking-header-text: #6d28d9;
  --segmented-bg: #e2e8f0;
  --segmented-active-bg: #ffffff;
  --segmented-active-border: #cbd5e1;
  --segmented-active-text: #1e293b;
  --theme-btn-active: #ffffff;
  --item-hover: rgba(0, 0, 0, 0.04);
  --item-active: rgba(37, 99, 235, 0.1);
  --backdrop-bg: rgba(15, 23, 42, 0.35);
}

/* System theme auto switch when data-theme="system" */
@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    --bg-card: rgba(255, 255, 255, 0.94);
    --bg-sidebar: #f9f9f9;
    --bg-main: #ffffff;
    --border-card: rgba(226, 232, 240, 0.95);
    --bg-input: #ffffff;
    --border-input: #cbd5e1;
    --code-block-bg: #f0f0f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --chat-user-bg: linear-gradient(135deg, #3b82f6, #818cf8);
    --chat-user-text: #ffffff;
    --chat-assistant-text: #1e293b;
    --thinking-bg: rgba(124, 58, 237, 0.05);
    --thinking-border: rgba(124, 58, 237, 0.2);
    --thinking-text: #5b21b6;
    --thinking-header-text: #6d28d9;
    --segmented-bg: #e2e8f0;
    --segmented-active-bg: #ffffff;
    --segmented-active-border: #cbd5e1;
    --segmented-active-text: #1e293b;
    --theme-btn-active: #ffffff;
    --item-hover: rgba(0, 0, 0, 0.04);
    --item-active: rgba(37, 99, 235, 0.1);
    --backdrop-bg: rgba(15, 23, 42, 0.35);
  }
}

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

body {
  background-color: var(--bg-sidebar);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  display: block;
  padding: 0;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  width: calc(100% - var(--sidebar-width));
  max-width: none;
  height: 100vh;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg-main);
}

/* Top Header */
header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  min-height: var(--header-height);
  flex-shrink: 0;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-card);
  transition: var(--transition-smooth);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Menu Toggle Button */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--segmented-bg);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--item-hover);
  transform: translateY(-1px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 2px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: none;
  background-color: transparent;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 2px;
  transform-origin: left center;
  transition: transform 0.7s ease-in-out;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-emerald);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  transition: max-width 0.45s ease-in-out, padding 0.45s ease-in-out, gap 0.45s ease-in-out,
    background-color 0.3s ease, border-color 0.3s ease;
}

#statusText {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  transition: max-width 0.45s ease-in-out, opacity 0.45s ease-in-out, transform 0.45s ease-in-out;
}

.status-badge.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: currentColor;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.3);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

.mode-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.3);
  transition: var(--transition-smooth);
}

.mode-pill-badge:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--accent-blue);
  color: var(--text-main);
  transform: translateY(-1px);
}

.mode-pill-badge.think {
  background: rgba(139, 92, 246, 0.18);
  color: var(--accent-purple);
  border-color: rgba(139, 92, 246, 0.35);
}

.mode-pill-badge.think:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--accent-purple);
  color: var(--text-main);
  transform: translateY(-1px);
}

.mode-text-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  margin-left: 0;
  pointer-events: none;
  transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-footer-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  padding-right: 10px;
  min-width: 0;
}

.mode-toggle-button {
  appearance: none;
  flex-shrink: 0;
  cursor: pointer;
}

/* Sample Prompts Row */
.sample-prompts-row {
  display: flex;
  gap: 8px;
  max-height: 48px;
  overflow-x: auto;
  padding: 8px 24px;
  scrollbar-width: none;
  opacity: 1;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-card);
  transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
}

.sample-prompts-row::-webkit-scrollbar {
  display: none;
}

.prompt-pill {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.prompt-pill:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--accent-blue);
  color: var(--text-main);
  transform: translateY(-1px);
}

/* Chat Container — this is now the scroll container */
.chat-container {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  box-shadow: none;
}

.container.prompts-hidden .sample-prompts-row {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
  border-bottom: 0;
  pointer-events: none;
}

.container.prompts-hidden .brand-subtitle {
  transform: translateY(-500%);
  pointer-events: none;
}

.container.prompts-hidden #statusText {
  opacity: 0;
  transform: translateY(-150%);
  max-width: 0;
  pointer-events: none;
}

.container.prompts-hidden .status-badge {
  border-radius: 50px;
  gap: 0;
}

.chat-messages {
  flex: 1;
  overflow: visible;
  padding: 0 118px 110px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-messages> :first-child {
  margin-top: 18px;
}

.message {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 25px;
  font-size: 0.92rem;
  line-height: 1.55;
  animation: fadeIn 0.25s ease-out;
  word-break: break-word;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  position: relative;
  align-self: stretch;
  max-width: 100%;
  padding-bottom: 0;
  background: var(--chat-user-bg);
  color: var(--chat-user-text);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
}

.user-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.user-content p:last-child {
  margin-bottom: 0 !important;
}

.user-message-group {
  align-self: flex-end;
  width: fit-content;
  max-width: 88%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.message-controls {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  margin-top: 8px;
}

.edit-prompt-button {
  position: static;
  width: 24px;
  height: 24px;
  padding: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.copy-message-button {
  position: static;
  width: 24px;
  height: 24px;
  padding: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.message:hover .copy-message-button,
.user-message-group:hover .copy-message-button,
.copy-message-button.long-press-visible {
  opacity: 1;
  pointer-events: auto;
}

.copy-message-button:hover {
  color: var(--text-main);
}

.user-message-group:hover .edit-prompt-button,
.edit-prompt-button.long-press-visible {
  opacity: 1;
  pointer-events: auto;
}

.edit-prompt-button:hover {
  color: var(--accent-blue);
}

.message.assistant {
  position: relative;
  align-self: stretch;
  max-width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  color: var(--chat-assistant-text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message.assistant .copy-message-button {
  align-self: flex-start;
  flex: 0 0 24px;
}

.assistant-message-controls {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  min-height: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.message.assistant:hover .assistant-message-controls,
.message.assistant:focus-within .assistant-message-controls,
.assistant-message-controls.long-press-visible {
  opacity: 1;
  pointer-events: auto;
}

.assistant-message-controls .copy-message-button {
  opacity: 1;
  pointer-events: auto;
}

.feedback-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.feedback-button:hover:not(:disabled) {
  color: var(--text-main);
}

.feedback-button.selected[aria-label="Good response"] {
  color: var(--accent-blue);
}

.feedback-button.selected[aria-label="Bad response"] {
  color: var(--danger);
}

.feedback-button:disabled {
  cursor: default;
  opacity: 0.75;
}

.regenerate-response-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

.regenerate-response-button:hover {
  color: var(--text-main);
}

.cache-healing-dialog {
  position: fixed;
  inset: 0;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  overflow-y: auto;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--accent-blue) 22%, var(--border-card));
  border-radius: 18px;
  color: var(--text-main);
  background: color-mix(in srgb, var(--bg-sidebar) 58%, transparent);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  animation: cache-dialog-enter 0.2s ease-out;
}

.cache-healing-dialog::backdrop {
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(3px);
}

.cache-healing-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 26px;
}

.cache-healing-icon {
  width: 42px;
  height: 42px;
  border: 1px solid color-mix(in srgb, var(--accent-blue) 25%, transparent);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--accent-blue);
  background: color-mix(in srgb, var(--accent-blue) 10%, transparent);
  font-size: 22px;
}

.cache-healing-form h2 {
  font-size: 1.1rem;
}

.cache-healing-form p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.cache-healing-form textarea {
  width: 100%;
  min-height: 120px;
  padding: 11px 12px;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  color: var(--text-main);
  background: var(--bg-input);
  font: inherit;
  resize: vertical;
}

.cache-healing-form textarea:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 1px;
}

.cache-healing-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.cache-healing-actions button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.cache-healing-cancel {
  color: var(--text-main);
  background: transparent;
}

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

@keyframes cache-dialog-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.assistant::after,
.code-block-wrapper::after {
  content: "";
  width: 100%;
  height: 1px;
  flex: 0 0 1px;
  background: var(--border-card);
  opacity: 0.7;
}

.aalo-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  padding: 9px 14px;
  border: 1px solid var(--border-card);
  border-radius: 25px;
  background: var(--bg-sidebar);
  color: var(--text-main);
  box-shadow: var(--card-shadow);
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.aalo-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.message.system-note {
  align-self: center;
  background: var(--segmented-bg);
  border: 1px dashed var(--border-card);
  color: var(--text-muted);
  font-size: 0.78rem;
  border-radius: 25px;
  padding: 6px 14px;
  text-align: center;
}

/* Thinking Process Accordion */
.thinking-block {
  background: var(--thinking-bg);
  border: 1px solid var(--thinking-border);
  border-radius: 25px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--thinking-text);
  margin-bottom: 6px;
}

.thinking-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--thinking-header-text);
  user-select: none;
}

.thinking-header::-webkit-details-marker {
  display: none;
}

.thinking-icon {
  font-size: 1rem;
  animation: spinSlow 4s linear infinite;
}

@keyframes spinSlow {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.thinking-meta {
  font-size: 0.72rem;
  opacity: 0.8;
  margin-left: auto;
  font-family: var(--font-mono);
}

.assistant-working-indicator {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 9px;
  min-height: 30px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.assistant-working-indicator[hidden] {
  display: none;
}

.working-status-text.is-changing {
  animation: working-text-in 0.25s ease-out;
}

.assistant-working-sources {
  width: 84px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}

.assistant-working-sources[hidden] {
  display: none;
}

.assistant-searching-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}

.assistant-searching-dots[hidden] {
  display: none;
}

.assistant-searching-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.25;
  animation: searching-dot-pulse 0.9s ease-in-out infinite;
}

.assistant-searching-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.assistant-searching-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.assistant-working-source {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  object-fit: contain;
  color: var(--accent-blue);
  font-size: 16px;
  opacity: 0;
  animation: source-icon-sweep 1.8s ease-in-out infinite;
}

.working-icon {
  color: var(--accent-blue);
  font-size: 21px;
  border-radius: 50%;
  animation: working-pulse 1.5s ease-in-out infinite;
}

@keyframes working-pulse {

  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.88);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes working-text-in {
  from {
    opacity: 0.55;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes searching-dot-pulse {

  0%,
  70%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }

  35% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes source-icon-sweep {
  0% {
    opacity: 0;
    transform: translateX(-12px);
  }

  20%,
  70% {
    opacity: 1;
    transform: translateX(0);
  }

  100% {
    opacity: 0;
    transform: translateX(12px);
  }
}

.thinking-content {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--thinking-border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  opacity: 0.92;
  max-height: 220px;
  overflow-y: auto;
}

.response-content {
  white-space: normal;
  line-height: 1.55;
}

.response-content .katex-display {
  max-width: 100%;
  margin: 0.7em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 0;
}

.response-citations {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  margin-top: 6px;
}

.response-citations[hidden] {
  display: none;
}

.citation-heading {
  align-self: flex-start;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: bold;
}

.citation-row {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.citation-row[hidden] {
  display: none;
}

.citation-row::-webkit-scrollbar {
  display: none;
}

.citation-pill {
  max-width: min(280px, 70vw);
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--border-card);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  background: var(--segmented-bg);
  font-size: 0.73rem;
  line-height: 1.2;
  text-decoration: none;
  flex: 0 0 auto;
}

.citation-pill[href]:hover {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.citation-card {
  width: min(275px, calc(100vw - 56px));
  min-height: 112px;
  padding: 11px;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
  background: var(--bg-card);
  text-decoration: none;
  flex: 0 0 auto;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.citation-card:hover {
  border-color: var(--accent-blue);
  background: var(--item-hover);
}

.citation-card-content {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 5px;
}

.citation-card-source {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.citation-card-favicon,
.citation-card-fallback-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: contain;
  flex: 0 0 16px;
}

.citation-card-fallback-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.citation-card-source-name,
.citation-card-title,
.citation-card-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
}

.citation-card-source-name {
  white-space: nowrap;
}

.citation-card-id {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.6;
}

.citation-card-title {
  display: -webkit-box;
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.citation-card-snippet {
  display: -webkit-box;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.citation-card-image {
  width: 78px;
  height: 78px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 78px;
}

.citation-icon {
  font-size: 15px;
  flex: 0 0 auto;
}

.citation-site-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: contain;
}

.citation-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.response-content h1,
.response-content h2,
.response-content h3 {
  margin: 0.8em 0 0.35em;
  line-height: 1.25;
}

.response-content h1:first-child,
.response-content h2:first-child,
.response-content h3:first-child {
  margin-top: 0;
}

.response-content p {
  margin: 0 0 0.9em !important;
}

.response-content p:first-child {
  margin-top: 0;
}

.response-content p:last-child {
  margin-bottom: 0 !important;
}

.response-content>br,
.response-content p>br {
  display: block;
  content: "";
  margin-bottom: 0.9em;
}

.response-content ul,
.response-content ol {
  margin: 0.55em 0;
  padding-left: 1.5em;
}

.response-content blockquote {
  margin: 0.7em 0;
  padding: 0.1em 0.9em;
  border-left: 3px solid var(--accent-blue);
  color: var(--text-muted);
}

.response-content code {
  padding: 0.12em 0.35em;
  border-radius: 25px;
  background: var(--segmented-bg);
  font-family: var(--font-mono);
  font-size: 0.88em;
}

.response-content pre {
  margin: 0;
  padding: 0.85em 1em;
  overflow-x: auto;
  border: 1px solid var(--border-card);
  border-radius: 25px;
  background: var(--code-block-bg);
}

.response-content pre code {
  padding: 5px;
  background: transparent;
  white-space: pre;
}

/* Single-line & Multi-line Comments (Green) */
.hljs-comment,
.hljs-quote,
.hljs-doctag {
  color: #6a9955 !important;
  font-style: italic;
}

/* Strings (Orange/Coral) */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
  color: #ce9178 !important;
}

/* Keywords (Blue) */
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
  color: #569cd6 !important;
  font-weight: bold;
}

/* Functions (Yellow) */
.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: #dcdcaa !important;
}

.copy-code-button {
  position: static;
  align-self: flex-start;
  margin-top: 8px;
  width: 24px;
  height: 24px;
  padding: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, color 0.18s ease, background 0.18s ease;
}


.code-block-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0.7em 0;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  background: var(--code-block-bg);
}

.code-block-wrapper pre {
  border: 0;
  border-radius: 0 0 9px 9px;
  background: transparent;
  max-width: 100%;
  min-width: 0;
}

.code-action-row {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  background: var(--code-block-bg);
  border-bottom: 1px solid var(--border-card);
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.code-language-tag {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  padding-left: 4px;
  user-select: none;
}

.code-action-row .copy-code-button {
  margin-top: 0;
  margin-left: auto;
  align-self: center;
  opacity: 0.85;
  pointer-events: auto;
}

.code-action-row .copy-code-button:hover,
.code-action-row .copy-code-button:focus-visible,
.code-block-wrapper:hover .copy-code-button,
.copy-code-button.long-press-visible,
.copy-code-button:focus-visible {
  opacity: 1;
}

.copy-code-button:hover {
  color: var(--accent-blue);
}

.response-content a {
  color: var(--accent-cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.response-content hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--border-card);
}

.response-content table {
  width: 100%;
  margin: 0.7em 0;
  border-collapse: collapse;
  font-size: 0.9em;
  overflow: hidden;
}

.response-content th,
.response-content td {
  padding: 6px 8px;
  border: 1px solid var(--border-card);
  text-align: left;
}

.response-content th {
  background: var(--segmented-bg);
  font-weight: 700;
}

/* Chat Footer & Input Row */
.chat-footer-overlay {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
  background: transparent;
  /* Prevent this from shifting layout — it's an overlay on .container */
  flex-shrink: 0;
}

.chat-footer-overlay .metrics-bar,
.chat-footer-overlay .chat-input-row {
  pointer-events: auto;
  background: transparent;
  border-top: 0;
}

.chat-footer-overlay .metrics-bar {
  background: color-mix(in srgb, var(--bg-sidebar) 58%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.chat-input-row {
  position: relative;
  display: flex;
  padding: 5px 100px;
  border-top: 1px solid var(--border-card);
}

.chat-input-shell {
  position: relative;
  width: 100%;
  background: color-mix(in srgb, var(--bg-sidebar) 58%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 1px solid var(--border-input);
  border-radius: 25px;
  overflow: visible;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-shell:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.chat-input {
  width: 100%;
  min-height: 55px;
  max-height: 180px;
  resize: none;
  overflow-y: hidden;
  display: block;
  padding: 18px 134px 12px 46px;
  background: transparent;
  border: 0;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  outline: none;
}

.chat-input:focus {
  outline: none;
}

.chat-input-row.has-prompt:not(.is-expanded):not(.voice-recording) .chat-input {
  padding-right: 190px;
}

.chat-input-row.is-streaming:not(.is-expanded):not(.voice-recording) .chat-input {
  padding-right: 190px;
}

.chat-input-actions {
  position: absolute;
  z-index: 7;
  top: 50%;
  right: 5px;
  left: 5px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  transform: translateY(-50%);
  pointer-events: none;
}

.attachment-actions {
  --attachment-menu-width: 230px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: auto;
}

.btn-attachment,
.selected-document>button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}

.btn-attachment:hover,
.selected-document>button:hover {
  background: color-mix(in srgb, var(--text-main) 10%, transparent);
}

.btn-attachment .material-icons {
  font-size: 25px;
}

.attachment-menu {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 10px);
  left: 0;
  width: var(--attachment-menu-width);
  padding: 6px;
  background: color-mix(in srgb, var(--bg-sidebar) 95%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

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

.attachment-menu button {
  width: 100%;
  min-height: 40px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.attachment-menu button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text-main) 9%, transparent);
}

.attachment-menu button:disabled {
  color: var(--text-subtle);
  cursor: not-allowed;
  opacity: 0.62;
}

.attachment-menu button .material-icons {
  font-size: 20px;
}

.attachment-menu button small {
  margin-left: auto;
  font-size: 0.68rem;
}

.voice-control-button {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--text-main);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}

.voice-mic-button {
  width: 48px;
  height: 48px;
  order: 2;
}

.mode-footer-group {
  order: 1;
  flex: 0 1 auto;
}

.btn-send {
  order: 3;
}

.chat-input-row:not(.has-prompt):not(.is-streaming) .btn-send {
  display: none;
}

.voice-control-button:hover:not(:disabled) {
  color: var(--accent-blue);
  background: color-mix(in srgb, var(--text-main) 10%, transparent);
}

.voice-control-button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.voice-control-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.voice-controls {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 18px;
  bottom: 0;
  left: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  pointer-events: none;
}

.voice-controls[hidden],
.voice-mic-button[hidden],
.mode-footer-group[hidden],
.btn-send[hidden] {
  display: none;
}

.voice-mic-button:hover {
  color: var(--accent-blue);
}

.voice-mic-button.is-recording {
  color: #ef4444;
  background: color-mix(in srgb, #ef4444 14%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, #ef4444 18%, transparent);
  animation: voice-recording-pulse 1.4s ease-in-out infinite;
}

.voice-processing .voice-mic-button .material-symbols-outlined {
  animation: voice-processing-spin 1.2s linear infinite;
}

.voice-visualizer {
  width: min(100%, 460px);
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 25%) minmax(0, 75%);
  align-items: center;
  gap: 0;
  color: var(--accent-blue);
  font-size: 1.0rem;
  white-space: nowrap;
}

.voice-visualizer #voiceStatusText {
  min-width: 0;
  padding-right: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-visualizer-bars {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  min-width: 0;
}

.voice-visualizer-bars i {
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: currentColor;
  transform: scaleY(var(--bar-scale, 0.16));
  transition: transform 90ms ease-out;
}

.voice-visualizer.is-speaking {
  color: #ef4444;
}

.voice-visualizer.processing .voice-visualizer-bars {
  width: 30px;
  height: 12px;
  gap: 5px;
  justify-self: start;
}

.voice-visualizer.processing .voice-visualizer-bars i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: none;
  animation: voice-processing-pulse 0.9s ease-in-out infinite;
}

.voice-visualizer.processing .voice-visualizer-bars i:nth-child(n+4) {
  display: none;
}

.voice-visualizer.processing .voice-visualizer-bars i:nth-child(2n) {
  animation-delay: 0.15s;
}

.voice-visualizer.processing .voice-visualizer-bars i:nth-child(3n) {
  animation-delay: 0.3s;
}

.selected-documents {
  position: absolute;
  z-index: 6;
  top: -35px;
  right: 0;
  left: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  pointer-events: none;
}

.selected-documents[hidden] {
  display: none;
}

.selected-document {
  max-width: min(230px, 34vw);
  height: 32px;
  padding: 0 3px 0 8px;
  border: 1px solid var(--border-card);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-main);
  background: var(--bg-sidebar);
  font-size: 0.75rem;
  flex: 0 0 auto;
  pointer-events: auto;
}

.selected-document>.material-symbols-outlined {
  font-size: 18px;
  flex: 0 0 auto;
}

.selected-document>span:not(.material-symbols-outlined) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-document>button {
  width: 24px;
  height: 24px;
}

.selected-document>button .material-symbols-outlined {
  font-size: 18px;
}

.mode-footer-group,
.btn-send {
  pointer-events: auto;
}

.mode-footer-group {
  margin-left: auto;
}

.btn-send {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 5px;
  border-radius: 50%;
  background: none;
  background-color: var(--accent-blue);
  border: none;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: var(--transition-smooth);
  flex-shrink: 0;
}

.btn-send:hover .material-icons {
  transform: translateY(-1px) scale(1.03);
  filter: drop-shadow(0px 4px 6px rgba(59, 130, 246, 0.45));
  transition: filter 0.2s ease, transform 0.2s ease;
}

.btn-send:active {
  transform: scale(0.98);
}

.btn-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  color: var(--text-main);
  background-color: transparent;
}

.chat-input-row.is-expanded .chat-input-shell {
  display: grid;
  grid-template-rows: auto 45px;
}

.chat-input-row.is-expanded .chat-input {
  grid-row: 1;
  min-height: 55px;
  max-height: 128px;
  padding: 14px 20px 0;
  overflow-y: auto;
}

.chat-input-row.voice-recording .chat-input,
.chat-input-row.voice-processing .chat-input {
  visibility: hidden;
  pointer-events: none;
}

.chat-input-row.is-expanded .chat-input-actions {
  position: static;
  grid-row: 2;
  padding-right: 5px;
  padding-left: 5px;
  padding-bottom: 5px;
  justify-content: flex-start;
  min-height: 45px;
  transform: none;
}

.chat-input-row.is-expanded .mode-footer-group {
  padding-right: 10px;
}

.chat-input-row.is-expanded .mode-text-desc {
  opacity: 1;
  margin-left: 8px;
  pointer-events: auto;
}

.chat-input-row.is-expanded .mode-text-desc {
  max-width: 380px;
}

.chat-input-row.is-expanded .btn-send,
.chat-input-row.is-expanded .btn-send:disabled {
  transform: rotate(-90deg);
}

.chat-input-row.is-expanded .btn-send:active {
  transform: rotate(-90deg) scale(0.98);
}

.metrics-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding: 6px 16px;
  background: transparent;
  font-family: var(--font-mono);
}

@media (max-width: 620px) {

  .voice-control-button {
    width: 48px;
    height: 48px;
  }

  .voice-mic-button {
    width: 48px;
    height: 48px;
  }

  .voice-visualizer {
    font-size: 0.65rem;
  }

  .voice-visualizer #voiceStatusText {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .voice-visualizer-bars {
    gap: 1px;
  }

  .mode-text-desc,
  .chat-input-row.is-expanded .mode-text-desc {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    pointer-events: none;
  }

  .selected-document {
    max-width: 28vw;
  }

  .selected-documents {
    right: 16px;
    left: 16px;
  }

  .attachment-actions {
    --attachment-menu-width: min(210px, calc(100vw - 140px));
  }
}

@media (max-width: 400px) {
  .voice-controls {
    right: 12px;
    left: 12px;
  }

  .voice-visualizer {
    font-size: 0.72rem;
  }
}

@keyframes voice-recording-pulse {
  50% {
    box-shadow: 0 0 0 7px color-mix(in srgb, #ef4444 8%, transparent);
  }
}

@keyframes voice-processing-pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

@keyframes voice-processing-spin {
  to {
    transform: rotateX(360deg);
  }
}

.cursor-blink {
  display: inline-block;
  width: 6px;
  height: 14px;
  background-color: var(--accent-cyan);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 0.9s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* =========================================================================
       SIDEBAR & BACKDROP
   ========================================================================= */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  max-width: 85vw;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-card);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.32s cubic-bezier(0.33, 1, 0.68, 1);
}

.sidebar.open {
  transform: translateX(0);
}

.btn-close-sidebar {
  display: none;
}

#menuBtn {
  display: none;
}

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

.btn-new-chat {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border-card);
  border-color: var(--accent-blue);
  border-radius: 25px;
  color: var(--segmented-active-text);
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--font-main);
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.4);
}

.btn-close-sidebar {
  margin-left: 10px;
  border-radius: 50%;
  background-color: transparent;
}

/* Sidebar Search */
.sidebar-search-box {
  padding: 10px 14px 4px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 25px;
  padding: 3px 10px;
  transition: var(--transition-smooth);
}

.search-input-wrapper:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.82rem;
  padding: 6px 0;
  outline: none;
}

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

.search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 4px;
  display: none;
  transition: color 0.15s ease;
}

.search-clear-btn:hover {
  color: var(--text-main);
}

.search-empty-state {
  font-size: 0.78rem;
  color: var(--text-subtle);
  padding: 18px 10px;
  text-align: center;
  line-height: 1.45;
}

.search-snippet {
  display: block;
  font-size: 0.7rem;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

/* Sessions History List */
.sidebar-section-title {
  padding: 14px 16px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 25px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 0.85rem;
  gap: 8px;
}

.session-item:hover {
  background: var(--item-hover);
  color: var(--text-main);
}

.session-item.active {
  background: var(--item-active);
  color: var(--accent-blue);
  font-weight: 600;
}

.session-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

.session-title-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.btn-delete-session {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-item:hover .btn-delete-session {
  opacity: 1;
}

.btn-delete-session:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

/* Sidebar Settings Section (Bottom Drawer) */
.sidebar-settings {
  border-top: 1px solid var(--border-card);
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.settings-section-title {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-settings-header:hover {
  color: var(--text-main);
}

.sidebar-settings-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 520px;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.sidebar-settings.collapsed {
  gap: 0;
}

.sidebar-settings.collapsed .sidebar-settings-content {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-field-sm,
.select-field-sm {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 25px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-field-sm:focus,
.select-field-sm:focus {
  border-color: var(--accent-blue);
}

/* Theme Segmented Switcher in Settings */
.theme-selector-sidebar {
  display: flex;
  background: var(--segmented-bg);
  border: 1px solid var(--border-card);
  border-radius: 25px;
  padding: 2px;
  gap: 2px;
}

.theme-btn-sidebar {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 25px;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-main);
  font-weight: 500;
  transition: var(--transition-smooth);
}

.theme-btn-sidebar.active {
  background: var(--theme-btn-active);
  color: var(--text-main);
  font-weight: 600;
}

.btn-clear-all {
  padding: 7px 10px;
  background: transparent;
  border: 1px dashed var(--border-card);
  border-radius: 8px;
  color: var(--text-subtle);
  font-size: 0.72rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-smooth);
}

.btn-clear-all:hover {
  color: var(--danger);
  border-color: var(--danger);
}

@media (max-width: 840px) {
  .container {
    width: 100%;
    margin-left: 0;
  }

  .chat-messages {
    padding-left: 20px;
    padding-right: 20px;
  }

  .chat-input-row {
    padding-right: 16px;
    padding-left: 16px;
  }

  .btn-send {
    right: 24px;
  }

  #menuBtn {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .btn-close-sidebar {
    display: flex;
  }
}

/* ==========================================================================
   Image Preview & Multimedia Styles
   ========================================================================== */

.chat-input-shell.drag-over {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.08);
}

.selected-document-image {
  padding-left: 4px;
}

.chip-image-thumb {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  flex: 0 0 24px;
  cursor: pointer;
  border: 1px solid var(--border-card);
  transition: transform 0.15s ease;
}

.chip-image-thumb:hover {
  transform: scale(1.1);
}

.citation-pill-image {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 3px 10px 3px 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 14px;
}

.citation-pill-image:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

.citation-pill-thumb {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  flex: 0 0 18px;
}

/* Image Lightbox Modal */
.image-lightbox-modal {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(0, 0, 0, 0.82);
  z-index: 9999;
}

.image-lightbox-modal:not([open]) {
  display: none;
}

.image-lightbox-content {
  position: relative;
  max-width: min(92vw, 1200px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: lightboxScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lightboxScaleUp {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.image-lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-card);
  background: var(--bg-sidebar);
}

.image-lightbox-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.image-lightbox-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-smooth);
}

.image-lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.image-lightbox-btn .material-symbols-outlined {
  font-size: 19px;
}

.image-lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  max-height: calc(90vh - 60px);
  overflow: auto;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.35) 0%, rgba(15, 23, 42, 0.6) 100%);
}

.image-lightbox-body img {
  max-width: 100%;
  max-height: calc(90vh - 90px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}