/* ============================================ */
/* CHAT INTERFACE                             */
/* ============================================ */

/* Layout */
.main-content {
  position: relative;
  top: 5px;
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: 1fr;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid var(--border);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.main-content::-webkit-scrollbar {
  width: 10px;
}

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

.main-content::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--border) 85%, black);
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-track-piece:start {
  margin-top: 22px;
}

.main-content::-webkit-scrollbar-track-piece:end {
  margin-bottom: -40px;
}

.main-content.transitions-enabled {
  transition: top 0.4s cubic-bezier(.2,.7,.2,1),
              margin-right 0.4s cubic-bezier(.2,.7,.2,1);
}

.main-content.transitions-enabled.chat-mode {
  padding-right: 0;
  padding-bottom: 43px;
  scrollbar-gutter: auto;
}

.main-content > .messages-container,
.main-content > .universal-container,
.main-content > #files-toolbar-container {
  grid-row: 1;
  grid-column: 1;
}

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  --chat-shimmer-bg-size: 300% 100%;
  --chat-status-indent-step: 20px;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

/* Chat Header */
.chat-header {
  display: flex;
  padding: 12px 16px;
  background: transparent;
  border-bottom: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  z-index: 200;
  pointer-events: none;
  position: relative;
}

.chat-header > * {
  pointer-events: auto;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 13px;
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--text);
  margin: 0;
}

.chat-title .btn-icon {
  margin-left: auto;
}

/* Branding menu button must be mobile-only */
.btn-icon.sidebar-toggle.branding-open-menu {
  display: none !important;
}

@media (max-width: 768px) {
  .btn-icon.sidebar-toggle.branding-open-menu {
    display: inline-flex !important;
  }

  #chat-title-text {
    display: none;
  }

  .chat-branding {
    font-size: 1.5rem;
    display: flex;
    visibility: visible;
    opacity: 1;
  }

  .chat-branding .branding-open-menu {
    display: inline-flex;
    align-items: center;
    width: 20px;
    height: 20px;
  }

  .chat-branding .branding-logo {
    width: 28px;
    height: 28px;
  }
}

/* Desktop: hide mobile buttons, show path bar in files mode */
@media (min-width: 769px) {
  .chat-header .mobile-only {
    display: none;
  }

  .chat-header .chat-title {
    display: none;
  }

  .chat-branding .branding-open-menu {
    display: none;
  }
}

/* Show path bar only in files mode */
.main-content.files-mode .chat-header .path-bar {
  display: block;
}

/* Path bar in chat header - shown only in files mode */
.chat-header .path-bar {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  max-width: 600px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: center;
  margin: 0 auto;
}

/* Hide path bar by default */
.chat-header .path-bar.hidden {
  display: none;
}

/* Show path bar in files mode */
.main-content.files-mode .chat-header .path-bar.hidden {
  display: block;
}



/* ============================================ */
/* MESSAGES                                   */
/* ============================================ */

.messages-container {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 0 200px 14px;
  min-height: 100%;
  scroll-behavior: auto;
  box-sizing: border-box;
  z-index: 0;
  pointer-events: auto;
  background: transparent;
  border-radius: inherit;
  transition: padding 0.3s cubic-bezier(.2,.7,.2,1);
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  scrollbar-gutter: stable;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  overscroll-behavior-y: contain;
}

/* Scrollbar styles are centralized in base.css */

/* Chat Branding */
.chat-branding {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass-surface-90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: 'Instrument Serif';
  font-size: 2rem;
  font-weight: 400;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.5px;
  line-height: 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding-bottom: 0px;
}

.messages-container .chat-branding {
  margin-left: -14px;
  margin-right: -14px;
  width: calc(100% + 28px);
  font-size: 1.6rem;
  padding-bottom: 40px;
  mask-image: linear-gradient(to bottom, black 0%, black 40%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 40%, transparent 100%);
}

.messages-container .chat-branding .branding-logo {
  width: 28px;
  height: 28px;
  margin-top: 1px;
}

.chat-branding span,
.chat-branding .branding-logo {
  transform: translateY(2px);
}

.chat-branding .branding-open-menu {
  display: none;
  position: absolute;
  left: 4px;
  top: 2px;
  transform: translateY(0);
  color: #0f172a;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 0;
}

.chat-branding .branding-logo {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  margin-top: 3px;
}

/* Animated branding (only when dynamically added) */
.chat-branding.animated {
  opacity: 0;
  animation: brandingFadeIn 0.25s ease-out forwards;
}

@keyframes brandingFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Files mode adjustments */
.main-content.files-mode {
  top: 46px;
  margin-right: 5px;
  border-color: var(--border);
  overflow: visible;
}

.main-content.files-mode .messages-container {
  display: none;
}


.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin: 8px auto;
  max-width: min(100%, var(--content-max-width));
  width: 100%;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  position: relative;
}

/* Message buttons container */
.message-buttons {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-top: 2px;
  width: 100%;
  justify-content: flex-start;
}

.message.user .message-buttons {
  align-self: flex-end;
  justify-content: flex-end;
}

.message.assistant .message-buttons {
  align-self: flex-start;
  justify-content: flex-start;
}

/* Copy button for messages */
.message-copy-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.2s ease, background 0.15s ease, transform 0.1s ease;
}

.message:hover .message-copy-btn {
  opacity: 1;
}

.message-copy-btn:hover {
  background: var(--hover_transparent_btns);
}

.message-copy-btn:focus {
  outline: none;
  box-shadow: none;
}

.message-copy-btn:focus-visible {
  outline: 2px solid var(--file-item-active-text);
  outline-offset: 2px;
}


.message-copy-btn svg {
  width: 25px;
  height: 25px;
  color: var(--muted);
  transition: color 0.15s ease;
}

.message-copy-btn:hover svg {
  color: var(--muted);
}

.message-copy-btn:active svg {
  color: var(--file-item-active-text);
}

.message-copy-btn.copied {
  background: var(--hover_transparent_btns);
  opacity: 1;
}

.message-copy-btn.copied svg {
  color: var(--file-item-active-text);
}

/* Export button for messages (same styles as copy button) */
.message-export-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.2s ease, background 0.15s ease;
}

.message:hover .message-export-btn {
  opacity: 1;
}

.message-export-btn:hover {
  background: var(--hover_transparent_btns);
}

.message-export-btn.active {
  background: var(--hover_transparent_btns);
  color: var(--file-item-active-text);
}

.message-export-btn svg {
  width: 19px;
  height: 19px;
  color: var(--muted);
  transition: color 0.15s ease;
}

.message-export-btn:hover svg {
  color: var(--muted);
}

.message-export-btn.active svg {
  color: var(--file-item-active-text);
}

.message-export-btn:active {
  background: var(--active_transparent_btns);
  opacity: 0.7;
}

/* Export dropdown menu */
.export-menu {
  position: fixed;
  z-index: 10000;
  background: var(--glass-surface-70);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 22px rgba(0,0,0,.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--padding-xs);
  width: max-content;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  user-select: none;
}

.export-menu[data-open-direction="down"] {
  transform: translateY(-8px);
}

.export-menu.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.export-menu.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
}

.export-menu.hidden[data-open-direction="down"] {
  transform: translateY(-8px);
}

.export-menu-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-menu-header {
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  text-align: center;
}

.export-format-options {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.export-format-option {
  cursor: pointer;
}

.export-format-option input[type="radio"] {
  display: none;
}

.export-format-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  min-height: var(--control-height);
  width: auto;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  transition: all 0.2s ease;
  font-size: 14px;
  color: var(--text);
}

.export-format-option:hover .export-format-label {
  background: var(--hover_transparent_btns);
  border-color: transparent;
}

.export-format-option input[type="radio"]:checked + .export-format-label {
  background: var(--file-item-active);
  color: var(--file-item-active-text);
  border-color: transparent;
}

.export-format-label svg {
  width: 16px;
  height: 16px;
}

.export-checkbox-option {
  padding: 8px 0;
  display: flex;
  justify-content: center;
}

.export-checkbox-option label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.export-checkbox-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 1px solid var(--overlay);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.export-checkbox-option input[type="checkbox"]:checked {
  background: var(--accent-300);
  border: none;
}

.export-checkbox-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 9px;
  background-color: var(--surface);
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'><path d='M1 5L5 9L13 1' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'><path d='M1 5L5 9L13 1' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transform: translate(-50%, -50%);
}

.export-menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
}

.export-menu-actions .btn,
.export-menu-actions .btn-secondary,
.export-menu-actions .btn-primary {
  margin-left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: auto;
  height: var(--control-height);
  min-height: var(--control-height);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.1s ease, filter 0.1s ease;
}

.export-menu-actions .btn-primary {
  background: var(--file-item-active);
  color: var(--file-item-active-text);
  border: 1px solid transparent;
  box-shadow: none;
}

.export-menu-actions .btn-primary:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
  color: var(--file-item-active-text);
  box-shadow: none;
}

.export-menu-actions .btn-primary:active {
  background: color-mix(in srgb, var(--hover_transparent_btns) 80%, white);
  border-color: transparent;
  color: var(--file-item-active-text);
  opacity: 1;
  transform: none;
  box-shadow: none;
  filter: none;
}

.export-menu-actions .btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.export-menu-actions .btn-secondary:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
  color: var(--text);
}

.export-menu-actions .btn-secondary:active {
  background: var(--active_transparent_btns);
  border-color: var(--border-strong);
  color: var(--text);
  opacity: 0.85;
}

.btn-sm.btn-primary,
.btn-sm.btn-secondary {
  padding: 0 13px;
}

/* Desktop only class for export button in header */
.desktop-only {
  display: flex;
}



.message-content {
  display: flex;
  flex-direction: column;
  max-width: min(100%, var(--content-max-width));
  padding: 7px 12px;
  border-radius: 18px;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  font-family: var(--font-default);
  transition: opacity 0.3s ease, transform 0.3s ease;
  margin-top: 0;
}

.message-content code,
.message-content pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Indented message content for ephemeral statuses */
.message-content.indented {
  padding-left: calc(12px + var(--indent-level, 0) * 20px);
}

.message.user {
  align-items: flex-end;
}

.message.user .message-content {
  background: var(--user_message_color);
  border: none;
  font-size: 15px;
  white-space: pre-wrap;
}

.message.assistant {
  align-items: flex-start;
}

.message.assistant .message-content {
  background: var(--surface);
  border: none;
  box-shadow: none;
  font-size: 15px;
  padding: 0 0 12px 0;
  color: var(--text);
  border-radius: 18px;
}



/* Streaming content with partial math */
.message.streaming .message-content .partial-math {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  padding: 2px var(--padding-xs);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--muted);
}

/* Link chips */
a.auto-link {
  display: inline-block;
  padding: var(--padding-xs) 10px;
  margin: 2px 0;
  border-radius: 999px;
  background: var(--accent-50);
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
  color: color-mix(in oklab, var(--accent) 60%, black);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, filter .15s ease;
}

a.auto-link:hover {
  filter: brightness(.97);
  background: var(--hover_transparent_btns);
}

/* Cross-reference buttons */
.xref-num {
  appearance: none;
  border: 1px solid var(--border);
  background: white;
  color: var(--muted);
  font: inherit;
  padding: 0 8px;
  line-height: 17px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.xref-num:hover {
  filter: brightness(.97);
}

.xref-num:active {
  filter: brightness(.99);
}

.xref-num.xref-web {
  color: var(--file-item-active-text);
}

.xref-num.xref-web:hover {
  color: color-mix(in oklab, var(--file-item-active-text) 72%, white);
}

/* Loading state for xref buttons before references are loaded */
.xref-num.xref-loading {
  opacity: 0.8;
  cursor: pointer;
  text-indent: 0;
  /* Allow clicks even in loading state */
}

.xref-preview-tooltip {
  position: fixed;
  z-index: 1200;
  max-width: min(620px, calc(100vw - 24px));
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.45;
  white-space: normal;
  pointer-events: auto;
}

.xref-preview-tooltip::-webkit-scrollbar {
  width: 10px;
}

.xref-preview-tooltip::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.xref-preview-tooltip::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--border) 85%, black);
}

.xref-preview-tooltip::-webkit-scrollbar-track {
  background: transparent;
}

.xref-preview-tooltip.hidden {
  display: none;
}

.xref-preview-meta {
  font-size: 15px;
  color: var(--muted);
  font-weight: 400;
}

.xref-preview-doc-link {
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s ease;
}

.xref-preview-doc-link:hover {
  color: color-mix(in oklab, var(--muted) 72%, white);
}

.xref-preview-web-link {
  color: var(--file-item-active-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.xref-preview-web-link:hover {
  color: color-mix(in oklab, var(--file-item-active-text) 72%, white);
}

.xref-preview-divider {
  height: 1px;
  margin: 8px 0;
  background: var(--border);
}

.xref-preview-text {
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.xref-preview-fade {
  opacity: 0.7;
}

.ref-link {
  appearance: none;
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
  background: var(--accent-50);
  color: color-mix(in oklab, var(--accent) 60%, black);
  font: inherit;
  padding: 0 6px;
  height: 20px;
  line-height: 20px;
  border-radius: var(--padding-xs);
  cursor: pointer;
  display: inline-block;
  font-size: 0.9em;
}

.ref-link:hover {
  filter: brightness(.97);
}

/* Cancelled message styling */
.message.cancelled {
  opacity: 0.7;
  position: relative;
}

.message.cancelled .message-content {
  color: var(--muted);
  font-style: italic;
}

.message.cancelled::after {
  content: "Canceled";
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--error-bg, var(--surface-2));
  color: var(--error-text, var(--danger));
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--padding-xs);
  font-weight: 500;
  border: 1px solid var(--error-border, #fecaca);
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: var(--padding-xs);
  padding: var(--padding-xs);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-10px); opacity: 1; }
}

/* ============================================ */
/* STATUS & STREAMING                         */
/* ============================================ */

/* Status text styling */
.message.assistant.streaming .message-content {
  color: var(--text);
  min-height: 24px;
}

/* Status text shimmer animation - shows while waiting for first LLM token */
.message.assistant.streaming .message-content.status-active {
  position: relative;
  display: inline-block;
  padding-top: 0;
  color: var(--muted);
  animation: status-pulse 1.5s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

@keyframes status-dot-pulse {
  0%, 100% {
    transform: scale(0.9);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.95;
  }
}

@keyframes status-item-fade {
  from {
    opacity: 0;
    transform: translateY(var(--padding-xs));
  }
  to {
    opacity: 0.8;
    transform: translateY(0);
  }
}

@keyframes shimmer-text {
  0% {
    background-position: 150% 0;
  }
  100% {
    background-position: -150% 0;
  }
}

/* Status History - persistent status messages */
.status-history {
  display: flex;
  flex-direction: column;
  gap: var(--padding-xs);
  margin-bottom: var(--padding-xs);  /* Consistent spacing between statuses and content */
  font-size: 15px;
  max-width: min(100%, var(--content-max-width));  /* Match message-content width constraint */
}

/* Hide empty status history containers */
.status-history:empty {
  display: none;
  margin-bottom: 0;
}

/* Ephemeral status (transient status shown before streaming starts) */
.ephemeral-status {
  display: none;  /* Hidden by default */
  margin-bottom: var(--padding-xs);
  font-size: 15px;
  color: var(--muted);
  line-height: 1.4;
  padding-bottom: var(--padding-xs);
  white-space: pre-line;
}

.status-external-placeholder {
  position: relative;
  height: 20px;
  margin-bottom: var(--padding-xs);
}

.status-external-placeholder::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  animation: status-dot-pulse 1.8s ease-in-out infinite;
}


/* Animate ephemeral status when active */
.ephemeral-status.status-active {
  background: none;
  -webkit-background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  animation: none;
}

.status-item {
  color: var(--muted);
  line-height: 1.4;
  animation: none;
  white-space: pre-line;
  margin-bottom: var(--padding-xs);
}

.task-row-block {
  animation: none;
}

.research-details-block:not([data-task-graph-rendered="true"]) .task-row-block {
  animation: research-details-fade 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.status-item.processing,
.status-item.indented,
.status-item.status-nested,
.ephemeral-status.indented {
  background: linear-gradient(
    90deg,
    var(--muted) 35%,
    var(--text) 50%,
    var(--muted) 65%
  );
  background-size: var(--chat-shimmer-bg-size, 300% 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 4s linear infinite;
}

/* Block enter animation like in document editor */
@keyframes block-enter {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
  }
}

@keyframes editor-block-enter {
  from {
    transform: translateY(6px);
    opacity: 0.7;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.research-details-block .status-item {
  opacity: 1;
  position: relative;
  display: block;
  font-family: var(--font-default);
  font-size: 15px;
  line-height: 1.4;
  margin: 0 0 var(--padding-xs) 0;
  animation: none;
}

.research-details-block .status-item:last-child {
  margin-bottom: 0;
}

.research-details-block .status-item.processing {
  animation: none;
  background: none;
  -webkit-text-fill-color: currentColor;
}

.research-details-block .status-item.executing,
.research-details-block .ephemeral-status.indented,
.research-details-block .ephemeral-status.status-active.executing {
  color: var(--muted);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--muted) 40%, transparent) 0%,
    color-mix(in srgb, var(--muted) 40%, transparent) 20%,
    var(--muted) 50%,
    color-mix(in srgb, var(--muted) 40%, transparent) 80%,
    color-mix(in srgb, var(--muted) 40%, transparent) 100%
  );
  background-size: var(--chat-shimmer-bg-size, 300% 100%);
  background-repeat: repeat;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 4s linear infinite;
}

.research-details-block .status-item.result,
.research-details-block .status-item.complete,
.research-details-block .status-item.status-nested,
.research-details-block .status-item.indented {
  background: none;
  -webkit-text-fill-color: currentColor;
  animation: none;
}

/* Timeline dot for root level status items */
.research-details-block .status-item:not(.indented):not(.ephemeral-status)::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 var(--padding-xs) var(--surface);
  z-index: 1;
}

/* Timeline dot for active ephemeral status */
.research-details-block .ephemeral-status.status-active:not(.indented)::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 var(--padding-xs) var(--surface);
  z-index: 1;
}

/* Indented status items - use CSS custom property for dynamic indentation */
.status-item.indented,
.ephemeral-status.indented {
  padding-left: calc(var(--indent-level, 0) * var(--chat-status-indent-step, 20px)) !important;
  opacity: 0.7;
}

/* Research Details Collapsible Block */
.research-details-block {
  margin: 0;
  max-width: min(100%, var(--content-max-width));
  width: 100%;
}

.research-details-block:empty {
  display: none;
}

/* Hide block if status-history is empty */
.research-details-block .status-history:empty {
  display: none;
  padding: 0;
}

.research-details-block:has(.status-history:empty):not(:has(.task-graph)):not(:has(.ephemeral-status.status-active)) {
  display: none;
}

@keyframes research-details-fade {
  from {
    opacity: 0;
    transform: translateY(calc(var(--padding-xs) * -1));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes research-details-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(calc(var(--padding-xs) * -1));
  }
}

.research-details-block[open]:not(.closing) .status-intro,
.research-details-block[open]:not(.closing) .task-graph,
.research-details-block[open]:not(.closing) .status-history {
  animation: research-details-fade 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.research-details-block.closing .status-intro,
.research-details-block.closing .task-graph,
.research-details-block.closing .status-history {
  animation: research-details-fade-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Summary Header */
.research-details-summary {
  padding: 0 0 8px 0;
  cursor: pointer;
  font-weight: normal;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: flex-start;
  user-select: none;
  list-style: none; /* Hide default marker */
  opacity: 0.7;
}

.research-details-summary:hover,
.thinking-summary:hover {
  color: var(--text);
}

.research-details-summary .research-summary-label {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  text-decoration: underline dashed;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.research-details-summary::-webkit-details-marker {
  display: none; /* Hide default marker in WebKit browsers */
}

/* CSS Arrow (closed: >) - using borders to create 90deg angle */
.research-details-summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transform-origin: center center;
  transition: transform 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
  display: inline-block;
}

.research-details-summary:hover::before {
  border-right-color: var(--text);
  border-bottom-color: var(--text);
}

/* CSS Arrow (open: rotated to point down ∨) */
.research-details-block[open] .research-details-summary::before {
  transform: rotate(45deg);
  transform-origin: center center;
}

/* Rotate back immediately when closing */
.research-details-block.closing .research-details-summary::before {
  transform: rotate(-45deg);
}

.research-details-summary.researching .research-summary-label {
  background: linear-gradient(
    90deg,
    var(--muted) 0%,
    var(--muted) 20%,
    var(--text) 50%,
    var(--muted) 80%,
    var(--muted) 100%
  );
  background-size: 300% 100%;
  background-repeat: repeat;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 4s linear infinite;
  text-decoration-color: var(--muted);
}

.research-details-summary.researching .research-summary-label:hover {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  animation: none;
  text-decoration-color: currentColor;
}


.research-details-summary .research-timer {
  flex: 0 0 auto;
  margin-left: 0px;
  font-family: var(--font-default);
  font-size: 15px;
  text-align: right;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  display: inline-block;
}

/* Stop animation when research is complete */
.research-details-summary:not(.researching) {
  animation: none;
}

/* Research header - container for badge and details (vertical stack) */
.research-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

/* Document count wrapper */
.doc-count-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Document count badge */
.doc-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 15px;
  line-height: 1;
  padding-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-top: 2px;
}

.doc-count-badge:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Document dropdown */
.doc-count-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  max-width: 300px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--glass-surface-70);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 22px var(--overlay-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px;
  z-index: 100;
  display: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.doc-count-dropdown.visible {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.doc-count-dropdown-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 18px;
}

.doc-count-dropdown-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Status History Container (inside details) */
.research-details-block .status-history {
  padding: 0 0 0 16px;
  margin-bottom: 0;
  margin-left: 20px;
  border-left: 1px solid var(--border);
}

.research-details-block .task-graph {
  display: flex;
  flex-direction: column;
  margin: var(--padding-xs) 0 8px 0;
}

.research-details-block .task-row-block {
  display: flex;
  flex-direction: column;
}

.research-details-block .task-row-block.hidden {
  display: none;
}

.research-details-block .task-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--padding-xs) 0;
}

.research-details-block .task-row.final {
  margin-top: var(--padding-xs);
}

.research-details-block .task-row.nested {
  margin-top: 8px;
  margin-left: 12px;
  padding-left: 10px;
}

.research-details-block .task-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 18px;
  padding: var(--padding-xs) 10px;
  font-size: 15px;
  height: var(--control-height);
  line-height: 1.2;
  cursor: pointer;
  max-width: 240px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.1s ease;
  user-select: none;
  font-family: var(--font-default);
}

.research-details-block .task-tab-label {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-details-block .task-tab-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22.5px;
  height: 22.5px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--border);
  background: var(--surface);
  font-size: 11px;
  line-height: 1;
  transition: none;
  flex-shrink: 0;
  align-self: center;
  margin-left: -3px;
  margin-top: -1px;
}

.research-details-block .task-tab:not(.complete) .task-tab-check {
  display: none;
}

.research-details-block .task-tab.complete .task-tab-check {
  display: inline-flex;
}

.research-details-block .task-tab.active.complete .task-tab-check {
  background: var(--surface);
  border: 0;
  color: var(--file-item-active-text);
}

.research-details-block .task-tab-check::before {
  content: '';
}

.research-details-block .task-tab:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
}

.research-details-block .task-tab:hover .task-tab-check {
  border-color: transparent;
}

.research-details-block .task-tab:active {
  background: color-mix(in srgb, var(--hover_transparent_btns) 70%, white);
  opacity: 1;
}

.research-details-block .task-tab.pending {
  opacity: 1;
}

.research-details-block .task-tab.in-progress {
  animation: none;
}

.research-details-block .task-tab.in-progress .task-tab-label {
  color: #000;
  background: linear-gradient(
    90deg,
    var(--muted) 0%,
    var(--muted) 20%,
    var(--text) 50%,
    var(--muted) 80%,
    var(--muted) 100%
  );
  background-size: 300% 100%;
  background-repeat: repeat;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 4s linear infinite;
}

.research-details-block .task-tab.active {
  border-color: transparent;
  background: var(--active_transparent_btns);
  color: var(--file-item-active-text);
  animation: none;
}

.research-details-block .task-tab.active .task-tab-label {
  color: var(--file-item-active-text);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--file-item-active-text) 40%, transparent) 0%,
    color-mix(in srgb, var(--file-item-active-text) 40%, transparent) 20%,
    var(--file-item-active-text) 50%,
    color-mix(in srgb, var(--file-item-active-text) 40%, transparent) 80%,
    color-mix(in srgb, var(--file-item-active-text) 40%, transparent) 100%
  );
  background-size: 300% 100%;
  background-repeat: repeat;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 4s linear infinite;
}

.research-details-block .task-tab.active.complete .task-tab-label {
  background: none;
  color: var(--file-item-active-text);
  -webkit-text-fill-color: var(--file-item-active-text);
  animation: none;
}


.research-details-block .task-tab.complete .task-tab-check::before {
  content: '';
  width: 12px;
  height: 9px;
  background-color: var(--muted);
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'><path d='M1 5L5 9L13 1' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'><path d='M1 5L5 9L13 1' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.research-details-block .task-tab.active.complete .task-tab-check::before {
  background-color: #0b3b73;
}

.research-details-block .task-tab.active:active {
  background: color-mix(in srgb, var(--active_transparent_btns) 70%, white);
  opacity: 1;
}

.research-details-block .task-tab.hidden {
  display: none;
}

.research-details-block .task-panel {
  display: none;
}

.research-details-block .task-panel.active {
  display: block;
}

.research-details-block .task-panel.hidden {
  display: none;
}

.task-panel-content {
  margin-bottom: 6px;
  margin-left: 3px;
  padding-left: 15px;
  border-left: 1px solid var(--border);
}

.research-details-block .status-intro {
  margin-left: 3px;
  padding-left: 16px;
  border-left: 0;
}

.research-details-block .status-item.intro::before {
  display: none;
}

.research-details-block .task-children-panels {
  margin-left: 12px;
  padding-left: 10px;
}

.research-details-block .status-ungrouped {
  margin-top: 8px;
}

/* Ephemeral status inside research-details-block */
.research-details-block .ephemeral-status {
  margin-top: var(--padding-xs);
  margin-bottom: var(--padding-xs);
}



/* Ensure shimmer animation works for ephemeral status inside research block */
.research-details-block .ephemeral-status.status-active {
  background: linear-gradient(
    90deg,
    var(--muted) 0%,
    var(--muted) 20%,
    var(--text) 50%,
    var(--muted) 80%,
    var(--muted) 100%
  );
  background-size: var(--chat-shimmer-bg-size, 300% 100%);
  background-repeat: repeat;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 4s linear infinite;
}

.research-details-block .task-panel:not(.active) .ephemeral-status.status-active {
  animation: none;
}

.research-details-block .ephemeral-status.status-active p {
  margin: 0 0 var(--padding-xs);
}

.research-details-block .ephemeral-status.status-active p:last-child {
  margin-bottom: 0;
}


/* Welcome State - now inside composer */
.welcome-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px 24px;
  text-align: center;
  opacity: 1;
  transition: opacity 0.1s ease-out, visibility 0.1s ease-out;
}

.welcome-content.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.welcome-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .welcome-content {
    display: none;
  }

  .welcome-header {
    gap: 6px;
    margin-bottom: var(--padding-xs);
  }

  .welcome-content h1 {
    font-size: 2rem !important;
  }
  
  .welcome-logo {
    width: 40px;
    height: 40px;
  }
  .welcome-content h2 {
    display: none;
  }
}

.welcome-logo {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  margin-top: 6px;
}

.welcome-content h1 {
  font: 700 4rem/1.1 'Instrument Serif' !important;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.5px;
}

.welcome-content h2 {
  font: normal 1.7rem/1.5 'Instrument Serif' !important;
  color: var(--muted);
  letter-spacing: -0.2px;
  margin: 0;
  user-select: none;
  -webkit-user-select: none;
}



/* ============================================ */
/* THINKING BLOCKS                            */
/* ============================================ */

.thinking-block {
  order: -1;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  max-width: min(100%, var(--content-max-width));
  width: 100%;
  box-sizing: border-box;
}

.thinking-summary {
  padding: 0 0 8px 0;
  cursor: pointer;
  font-weight: normal;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  user-select: none;
  list-style: none;
  opacity: 0.7;
}

.thinking-summary[hidden] {
  display: none !important;
}

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

.thinking-summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transform-origin: center center;
  transition: transform 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
  display: inline-block;
}

.thinking-summary:hover::before {
  border-right-color: var(--text);
  border-bottom-color: var(--text);
}

.thinking-block details[open] .thinking-summary::before {
  transform: rotate(45deg);
}

.thinking-block details.closing .thinking-summary::before {
  transform: rotate(-45deg);
}

.thinking-block details[open]:not(.closing) .task-panel.active {
  animation: research-details-fade 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.thinking-block details.thinking-streaming-active .task-panel.active {
  animation: none;
}

.message.streaming .thinking-block details[open] .task-panel.active {
  animation: none !important;
}

.thinking-block details.closing .task-panel.active {
  animation: research-details-fade-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.message.streaming .thinking-block .thinking-summary::before {
  transition: none;
}

.thinking-block .task-panel.active {
  padding: 0 0 8px 0;
  font-family: var(--font-default);
  font-size: 15px;
  color: var(--muted);
  overflow-y: visible;
  overflow-x: visible;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  scrollbar-gutter: stable;
}

.thinking-block .task-panel.active > * {
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: var(--padding-xs);
}

.thinking-block .task-panel.active > *:last-child {
  margin-bottom: 0;
}

.thinking-block .task-panel.active p,
.thinking-block .task-panel.active li {
  opacity: 1;
  position: relative;
  display: block;
  font-family: var(--font-default);
  font-size: 15px;
  line-height: 1.4;
  margin: 0 0 var(--padding-xs) 0;
  background: none;
  -webkit-text-fill-color: currentColor;
  animation: none;
}

.thinking-block .task-panel.active p:last-child,
.thinking-block .task-panel.active li:last-child {
  margin-bottom: 0;
}

.thinking-block details.thinking-streaming-active .task-panel-content > p:not(:last-child) {
  display: none;
}

.thinking-block .task-panel.active p.status-item.task.status-nested {
  margin-bottom: 0;
  color: var(--muted);
  background: none;
  -webkit-text-fill-color: currentColor;
  animation: none;
}

.thinking-block .task-panel-content > p::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 var(--padding-xs) var(--surface);
  z-index: 1;
}

.thinking-block details.thinking-streaming-active .task-panel-content > p::before {
  display: none;
}

.thinking-block details.thinking-streaming-active .task-panel-content {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

.thinking-block .task-panel.active::-webkit-scrollbar {
  width: 8px;
}

.thinking-block .task-panel.active::-webkit-scrollbar-track {
  background: transparent;
}

.thinking-block .task-panel.active::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--padding-xs);
}

.thinking-block .task-panel.active::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Во время стриминга: убрать ограничение высоты, скрыть скроллбар */
.message.streaming .thinking-block .task-panel.active {
  max-height: none;
  overflow-y: visible;
  overflow-x: visible;
}

/* ============================================ */
/* SOURCES BADGE (References Indicator)       */
/* ============================================ */

.sources-badge-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  order: 999;
  margin-left: 5px;
}

.sources-badge-wrapper.sources-dropdown-open {
  z-index: 1302;
}

.sources-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

.sources-badge:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
}

.sources-badge:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(31,122,236,.25);
}

.sources-badge:active {
  background: var(--hover_transparent_btns);
  border-color: transparent;
  color: color-mix(in srgb, var(--muted) 65%, white);
}

.sources-badge-wrapper:active .sources-badge {
  background: var(--hover_transparent_btns);
  border-color: transparent;
  color: color-mix(in srgb, var(--muted) 65%, white);
}

.sources-badge-wrapper:has(.sources-dropdown.visible) .sources-badge {
  background: var(--active_transparent_btns);
  border-color: transparent;
  color: var(--file-item-active-text);
}

.sources-badge .sources-icon {
  display: none;
}

.sources-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--glass-surface-70);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 22px var(--overlay-soft);
  padding: var(--padding-xs);
  min-width: 380px;
  max-width: min(560px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 120px));
  overflow-y: auto;
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
  z-index: 1303;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.sources-dropdown.open-down {
  top: calc(100% + 8px);
  bottom: auto;
  transform: translateY(-8px);
}

.sources-dropdown.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--control-height);
  padding: 10px 10px;
  border-radius: 18px;
  position: relative;
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease;
  background: transparent;
}

.source-item::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: var(--hover_transparent_btns);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.source-item:hover::before {
  opacity: 1;
}

.source-item:active {
  background: transparent;
  opacity: 1;
}

.source-item:active::before {
  background: color-mix(in srgb, var(--hover_transparent_btns) 70%, white);
  opacity: 1;
}

.source-item:active .source-prefix,
.source-item:active .source-title {
  color: var(--file-item-active-text);
}

.source-item .source-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.source-item .source-number {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  background: var(--state-info-soft);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.source-item .source-title {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  position: relative;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.source-item .source-prefix {
  flex-shrink: 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.source-item.is-web .source-title {
  color: var(--file-item-active-text);
}

/* Scrollbar for sources dropdown */
.sources-dropdown::-webkit-scrollbar {
  width: 6px;
}

.sources-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.sources-dropdown::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sources-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
  margin-right: 5px;
