/**
 * Unified Workspace Style
 * NotebookLM Aesthetic with Zen Reading Typography
 */

:root {
  /* Layout */
  --sidebar-w: 280px;
  --pane-min-w: 260px;
  --output-w: 400px;
  
  /* Colors - Zen Palette */
  --bg-app: #fdfdfb;
  --bg-pane: #ffffff;
  --bg-sidebar: #f4f4f2;
  --border-color: #e0e0de;
  --accent-color: #4a5d4e; /* Deep Sage Green */
  --accent-soft: #f0f2f0;
  --text-primary: #1a1a1a;
  --text-muted: #5f5f5d;
  --error-color: #ff4d4f;
  --success-color: #10b981;
  --overlay-bg: rgba(255, 255, 255, 0.85);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --scrollbar-bg: rgba(0, 0, 0, 0.1);
  --scrollbar-hover: rgba(0, 0, 0, 0.2);
  --code-bg: rgba(0, 0, 0, 0.05);
  --thumbnail-overlay: rgba(0, 0, 0, 0.4);
  --video-duration-bg: rgba(0, 0, 0, 0.75);
  
  /* Component Colors */
  --tag-bg: #e6f4ea;
  --tag-color: #1e4620;
  
  /* Typography */
  --font-display: 'Literata', serif;
  --font-body: 'Literata', serif;
  --font-ui: 'Inter', sans-serif;
  
  /* Transitions */
  --transition: all 0.4s cubic-bezier(0.2, 0, 0, 1);
}

[data-theme="dark"] {
  /* Colors - Zen Dark Palette */
  --bg-app: #181818;
  --bg-pane: #202020;
  --bg-sidebar: #1c1c1c;
  --border-color: #333333;
  --accent-color: #a3bfa8; /* Lighter Sage Green for dark mode */
  --accent-soft: #2a2f2b;
  --text-primary: #e6e6e6;
  --text-muted: #9e9e9e;
  --error-color: #ff4d4f;
  --success-color: #10b981;
  --overlay-bg: rgba(255, 255, 255, 0.85);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --scrollbar-bg: rgba(0, 0, 0, 0.1);
  --scrollbar-hover: rgba(0, 0, 0, 0.2);
  --code-bg: rgba(0, 0, 0, 0.05);
  --thumbnail-overlay: rgba(0, 0, 0, 0.4);
  --video-duration-bg: rgba(0, 0, 0, 0.75);
  --text-on-accent: #1a1a1a;
  --overlay-bg: rgba(0, 0, 0, 0.85);
  --hover-bg: rgba(255, 255, 255, 0.05);
  --scrollbar-bg: rgba(255, 255, 255, 0.1);
  --scrollbar-hover: rgba(255, 255, 255, 0.2);
  --code-bg: rgba(255, 255, 255, 0.1);
  --thumbnail-overlay: rgba(0, 0, 0, 0.6);
  --video-duration-bg: rgba(0, 0, 0, 0.85);
  
  /* Component Colors */
  --tag-bg: rgba(163, 191, 168, 0.2);
  --tag-color: #a3bfa8;
}

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

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.workspace-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  transition: all 0.3s ease;
}

/* Pane Styles */
.pane {
  display: flex; flex-direction: column;
  background: var(--bg-pane);
  position: relative;
  overflow: hidden;
  min-width: 0;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), flex 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.pane.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  flex: 0 0 0 !important;
  opacity: 0;
  pointer-events: none;
}

/* Fullscreen Output Mode */
.workspace-container.fullscreen-output #pane-sources,
.workspace-container.fullscreen-output #resizer-1,
.workspace-container.fullscreen-output #pane-chat,
.workspace-container.fullscreen-output #resizer-2 {
  display: none !important;
}

.workspace-container.fullscreen-output #pane-output {
  width: 100vw !important;
  max-width: none !important;
  flex: 1 !important;
}

.toggle-pane-btn {
  padding: 4px;
  margin-right: 8px;
  border-radius: 4px;
}

.toggle-pane-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-color);
}

.workspace-container.resizing,
.workspace-container.resizing .pane {
  transition: none !important;
}

/* Resizers */
.resizer {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s;
  z-index: 10;
}

.resizer:hover, .resizer.dragging {
  background: var(--accent-color);
}

/* Pane Header & Layout Controls */
.pane-header {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  justify-content: space-between;
  background: var(--bg-pane);
  flex-shrink: 0;
  gap: 12px;
  position: relative;
  z-index: 10;
}

.header-actions-left, .header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.export-dropdown {
  position: relative;
}

.export-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 120px;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.10);
  padding: 6px;
  z-index: 200;
}

.export-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.export-menu-item:hover {
  background: var(--bg-sidebar);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--accent-soft);
  padding: 2px;
  border-radius: 8px;
}

.tabs-bar {
  display: flex;
  align-items: center;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  height: 36px;
  flex-shrink: 0;
}

.tabs-bar .tabs {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
}

.tabs-bar .tab-btn {
  font-size: 12px;
  height: 100%;
  padding: 0 2px;
  font-weight: 500;
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.tabs-bar .tab-btn:hover {
  color: var(--text-primary);
}

.tabs-bar .tab-btn.active {
  color: var(--accent-color);
  font-weight: 600;
}

.tabs-bar .tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent-color);
}

.toggle-pane-btn {
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  justify-content: center;
}

.toggle-pane-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-color);
}

.workspace-container.fullscreen-output #pane-output {
  width: 100vw !important;
  max-width: none !important;
  flex: 1 !important;
}

/* Resizers */
.resizer {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s;
  z-index: 10;
}

.resizer:hover, .resizer.dragging {
  background: var(--accent-color);
}

/* Pane Content & Media Queries */
.pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.output-pane {
  padding: 0; /* Content area should handle its own padding */
}

/* Pane Content Layout */
.pane-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* Pane 1: Sources Library */
#pane-sources {
  width: var(--sidebar-w);
  min-width: 240px;
  max-width: 400px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  height: 100%;
  display: flex; flex-direction: column;
}

#pane-sources .pane-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

.source-list {
  display: flex; flex-direction: column;
  gap: 10px;
}

.source-item {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  overflow: hidden;
}

.source-item:hover {
  border-color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.source-item.active {
  background: var(--bg-app);
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-color);
}

[data-theme="dark"] .source-item.active {
  background: var(--accent-soft);
}

.source-checkbox-wrapper {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}

.source-checkbox-wrapper input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.source-icon-small {
  display: flex;
  align-items: center;
  font-size: 20px;
  width: 36px;
  min-width: 36px;
  height: 36px;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-radius: 6px;
  margin: 8px;
}

.source-item.has-thumbnail .source-icon-small {
  width: 80px;
  min-width: 80px;
  height: 60px;
  background: var(--text-primary);
  border-radius: 6px;
  overflow: hidden;
  margin: 8px;
  position: relative;
}

.source-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.source-info-small {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 8px 8px 8px 0;
  justify-content: center;
}

.source-title-small {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-meta-small {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-tag-processing {
  background: var(--tag-bg);
  color: var(--tag-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .source-tag-processing {
  background: var(--tag-bg);
  color: var(--tag-color);
  border-color: var(--border-color);
}

.processing-spinner {
  width: 8px;
  height: 8px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.source-tag-skeleton {
  color: var(--accent-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

[data-theme="dark"] .source-tag-skeleton {
  background: rgba(163, 191, 168, 0.2);
  color: var(--accent-color);
}

.source-actions {
  display: flex; flex-direction: column;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 8px;
  justify-content: center;
}

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

.source-item.has-thumbnail .source-checkbox-wrapper {
  background: rgba(0,0,0,0.4);
  border-radius: 4px;
  padding: 2px;
}

.source-item.has-thumbnail .source-checkbox-wrapper input {
  accent-color: var(--accent-color);
}

/* Pane 2: Intelligence Hub (Chat) */
#pane-chat {
  flex: 1;
  min-width: var(--pane-min-w);
  background: var(--bg-app);
}

.chat-pane {
  background: var(--bg-app);
  display: flex; flex-direction: column;
}

.chat-messages {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 24px;
  padding: 30px;
  overflow-y: auto;
}

.message {
  max-width: 85%;
  padding: 16px 20px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.6;
  position: relative;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--accent-color);
  color: var(--text-on-accent);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.message.ai {
  align-self: flex-start;
  background: var(--bg-pane);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

/* Markdown Content Styles in Messages */
.message.ai h1, .message.ai h2, .message.ai h3 {
  margin: 12px 0 8px 0;
  line-height: 1.3;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.message.ai h1 { font-size: 1.4em; border-bottom: 1px solid var(--border-color); padding-bottom: 4px; }
.message.ai h2 { font-size: 1.25em; }
.message.ai h3 { font-size: 1.1em; }

.message.ai p {
  margin-bottom: 10px;
  line-height: 1.6;
}

.message.ai ul, .message.ai ol {
  margin: 10px 0;
  padding-left: 20px;
}

.message.ai li {
  margin-bottom: 6px;
}

.message.ai code {
  background: rgba(0,0,0,0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  color: var(--accent-color);
}

.message.ai pre {
  background: var(--bg-sidebar);
  padding: 16px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border-color);
}

.message.ai pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.message.ai blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 16px;
  font-style: italic;
  margin: 16px 0;
  background: var(--accent-soft);
  padding-top: 8px;
  padding-bottom: 8px;
  border-radius: 0 8px 8px 0;
}

.message.ai table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9em;
}

.message.ai th, .message.ai td {
  border: 1px solid var(--border-color);
  padding: 10px;
  text-align: left;
}

.message.ai th {
  background: var(--bg-sidebar);
  font-weight: 600;
}

.message.ai strong {
  color: var(--accent-color);
}

.chat-input-container {
  padding: 24px;
  background: var(--bg-app);
  border-top: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  gap: 12px;
  position: relative;
}

.chat-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  padding: 10px 20px;
  transition: var(--transition);
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 4px 20px rgba(74, 93, 78, 0.08);
}

[data-theme="dark"] .chat-input-wrapper:focus-within {
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.chat-textarea {
  flex: 1;
  border: none;
  background: var(--bg-pane);
  padding: 8px 0;
  resize: none;
  max-height: 150px;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Prose/Reading Experience */
.prose-content {
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-primary);
}

.prose-content h1, .prose-content h2, .prose-content h3 {
  font-family: var(--font-display);
  color: var(--text-primary);
  margin: 1.8em 0 0.8em;
  line-height: 1.3;
}

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

/* Auth Buttons */
.auth-btn:hover {
  background: var(--hover-bg);
  border-color: var(--text-muted);
}

.auth-btn svg {
  flex-shrink: 0;
}

/* ==================== Modals Overhaul ==================== */
.modal-overlay {
  align-items: center;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  justify-content: center;
  z-index: 2000;
}

/* login-modal 完全由 HTML 内联样式控制 */

.modal {
  background: var(--bg-pane);
  width: 95%;
  max-width: 520px;
  border-radius: 32px;
  box-shadow: 0 30px 60px -12px rgba(0,0,0,0.25), 0 18px 36px -18px rgba(0,0,0,0.3);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
  animation: modal-slide-up 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes modal-slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 32px 40px 24px;
  justify-content: space-between;
  background: var(--bg-pane);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.8px;
}

.close-modal {
  display: flex;
  align-items: center;
  background: var(--bg-sidebar);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 20px;
}

.close-modal:hover {
  background: var(--tag-bg);
  color: var(--error-color);
  transform: rotate(90deg);
}

.modal-body {
  padding: 32px 40px;
  overflow-y: auto;
  max-height: 75vh;
}

/* Form Styling within Modals */
.form-group {
  margin-bottom: 28px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: 0.2px;
}

.modal-body input[type="text"],
.modal-body input[type="password"],
.modal-body textarea,
.modal-body select {
  width: 100% !important;
  display: block !important;
  padding: 16px 18px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--bg-app);
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text-primary);
  transition: all 0.3s ease;
  outline: none;
  box-sizing: border-box;
}

.modal-body input:hover,
.modal-body textarea:hover,
.modal-body select:hover {
  background: var(--bg-pane);
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  border-color: var(--accent-color);
  background: var(--bg-pane);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.modal-body textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
}

.cookies-textarea {
  resize: vertical;
  min-height: 80px;
  max-height: 150px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
}

/* Extension Indicator - Zen Design */
.extension-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  position: relative;
  overflow: hidden;
}

.extension-indicator:hover {
  background: var(--bg-pane);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.extension-indicator.connected {
  background: var(--accent-soft);
  color: var(--accent-color);
  border-color: rgba(74, 93, 78, 0.2);
  padding-right: 14px;
  cursor: default;
}

.extension-indicator.connected:hover {
  transform: none;
  box-shadow: none;
  background: var(--accent-soft);
}

.extension-indicator svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}

.extension-indicator:not(.connected):hover svg {
  transform: rotate(90deg);
}

.extension-indicator.connected svg {
  transform: none;
}

.modal-footer {
  display: flex;
  align-items: center;
  padding: 32px 48px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  justify-content: space-between;
}

.modal-footer .primary-btn {
  padding: 16px 32px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(74, 93, 78, 0.15);
}

/* Tabs inside Modal */
.input-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-sidebar);
  padding: 6px;
  border-radius: 18px;
  margin-bottom: 32px;
}

.input-tabs .tab-btn {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.2, 0, 0, 1);
}

.input-tabs .tab-btn.active {
  background: var(--bg-pane);
  color: var(--accent-color);
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

/* File Drop Zone Refined */
.file-drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 24px;
  padding: 60px 24px;
  text-align: center;
  background: var(--bg-app);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex; flex-direction: column;
  gap: 12px;
}

.file-drop-zone:hover, .file-drop-zone.dragover {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  transform: scale(1.01);
}

.file-drop-zone p {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 16px;
}

/* URL Queue Refined */
.url-queue-list {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  margin-bottom: 24px;
  max-height: 220px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 500;
  justify-content: space-between;
}

.queue-item:last-child {
  border-bottom: none;
}

/* Preview Modal Specifics */
.preview-modal {
  max-width: 800px !important;
}

.preview-tab-content {
  display: none;
  animation: fade-in 0.3s ease;
}

.preview-tab-content.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.preview-tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.preview-tabs .tab-btn {
  padding: 12px 4px;
  font-weight: 600;
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
}

.preview-tabs .tab-btn.active {
  color: var(--accent-color);
}

.preview-tabs .tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-color);
}

/* Preview Content Box */
.preview-content-box {
  background: var(--bg-app);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 32px;
  font-size: 15px;
  color: var(--text-primary);
}

#preview-fulltext {
  color: var(--text-muted);
}

/* Onboarding Modal Refined */
.onboarding-card {
  max-width: 500px !important;
  border-radius: 40px !important;
}

.onboarding-logo {
  padding: 48px 0 24px !important;
}

.onboarding-logo svg {
  background: var(--accent-soft);
  padding: 24px;
  border-radius: 28px;
  width: 90px;
  height: 90px;
  color: var(--accent-color);
}

.onboarding-features {
  background: var(--bg-sidebar) !important;
  padding: 28px !important;
  border-radius: 24px !important;
  border: 1px solid var(--border-color);
  margin-bottom: 32px !important;
}

/* ==================== Professional Design System: Forms & Modals ==================== */
.config-section {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.config-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.section-header svg {
  color: var(--accent-color);
  opacity: 0.9;
  background: var(--accent-soft);
  padding: 12px;
  border-radius: 14px;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.8), 0 4px 12px rgba(0,0,0,0.03);
}

.section-header h4 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1.8px;
  opacity: 0.9;
}

.field-group {
  margin-bottom: 28px;
}

.field-label-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.field-help {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.6;
}

.input-shell {
  position: relative;
  background: var(--bg-app);
  border: 1.5px solid var(--border-color);
  border-radius: 18px;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.input-shell:hover {
  background: var(--bg-pane);
}

.input-shell:focus-within {
  border-color: var(--accent-color);
  background: var(--bg-pane);
  box-shadow: 0 0 0 6px var(--accent-soft), 0 8px 24px rgba(0,0,0,0.1);
}

.input-shell svg.input-icon {
  position: absolute;
  left: 20px;
  opacity: 0.5;
  pointer-events: none;
  transition: all 0.3s ease;
}

.input-shell:focus-within svg.input-icon {
  color: var(--accent-color);
  opacity: 0.9;
  transform: scale(1.1);
}

.input-shell input, 
.input-shell select, 
.input-shell textarea {
  width: 100% !important;
  padding: 18px 20px 18px 56px !important;
  border: none !important;
  background: transparent !important;
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  outline: none !important;
}

.input-shell textarea {
  min-height: 140px;
  line-height: 1.7;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 12px;
}

.model-card {
  padding: 24px;
  border: 2px solid var(--border-color);
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  background: var(--bg-pane);
}

.model-card:hover {
  border-color: var(--accent-soft);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.06);
}

.model-card.active {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.model-card .active-check {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--accent-color);
  color: var(--text-on-accent);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.model-card.active .active-check {
  opacity: 1;
  transform: scale(1);
}

.model-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.model-desc {
  font-size: 12px;
  line-height: 1.6;
}

/* Provider Cards - Hearthstone Style */
.provider-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.provider-grid.compact {
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.provider-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  border: 2px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  background: var(--bg-pane);
  position: relative;
  overflow: hidden;
}

.provider-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

.provider-card:hover {
  border-color: var(--accent-color);
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
}

.provider-card:hover::before {
  opacity: 1;
}

.provider-card.active {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  box-shadow: 0 8px 24px rgba(74, 93, 78, 0.2);
}

.provider-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.provider-icon svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.provider-icon-small {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.provider-icon-small svg {
  width: 100%;
  height: 100%;
}

/* AI Config Button Dynamic Icon */
.ai-btn-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.ai-btn-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ai-config-btn:hover .ai-btn-icon {
  transform: scale(1.1);
}

.ai-config-btn.has-provider .ai-btn-icon {
  width: 20px;
  height: 20px;
}

.provider-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.provider-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.provider-tag.recommended {
  background: var(--accent-color);
  color: var(--text-on-accent);
}

.more-providers-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.more-providers-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent-color);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.back-btn:hover {
  background: var(--accent-soft);
}

.provider-config-panel {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.provider-icon-small {
  font-size: 20px;
  margin-right: 8px;
}

.change-provider-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  transition: all 0.2s;
}

.change-provider-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.test-connection-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.test-result {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.test-result.success {
  color: #22c55e;
}

.test-result.error {
  color: #ef4444;
}

.test-result.loading {
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  align-items: center;
  padding: 32px 48px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  justify-content: space-between;
}

.footer-tip {
  display: flex;
  align-items: center;
  font-size: 12px;
  gap: 10px;
  opacity: 0.7;
  font-weight: 500;
}

.primary-btn {
  background: var(--accent-color);
  color: var(--text-on-accent);
  border: none;
  padding: 16px 36px;
  border-radius: 18px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.primary-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: 0.5s;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(74, 93, 78, 0.3);
}

.primary-btn:hover::after {
  left: 100%;
}

.primary-btn:active {
  transform: scale(0.96);
}

/* Model Card: Light Flow Effect */
.model-card.active::before {
  content: '';
  position: absolute;
  inset: -2px;
  z-index: -1;
  background: linear-gradient(135deg, transparent, var(--accent-soft), transparent);
  background-size: 200% 200%;
  animation: light-flow 3s linear infinite;
  border-radius: 24px;
  opacity: 0.5;
}

@keyframes light-flow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.model-card.active {
  transform: scale(1.02);
  border-color: var(--accent-color);
}

/* AI Thinking Indicator: Artistic Wave */
.thinking-process {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--accent-soft);
  border-radius: 16px;
  width: fit-content;
  margin-bottom: 16px;
}

.thinking-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s infinite cubic-bezier(0.5, 0.1, 0.4, 0.9);
}

.thinking-text {
  font-size: 13px;
  color: var(--accent-color);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Streaming & Loading */
.icon-btn {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  justify-content: center;
  transition: var(--transition);
  color: var(--text-muted);
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-color);
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  overflow: visible;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  font-family: var(--font-ui);
  transition: background 0.2s;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--hover-bg);
}

.dropdown-item svg {
  flex-shrink: 0;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Agent UI */
.agent-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-color);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.push-to-output {
  font-size: 12px;
  margin-top: 12px;
  color: var(--accent-color);
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.push-to-output:hover {
  border-color: var(--accent-color);
}

.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.suggestion-chip {
  padding: 8px 16px;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.suggestion-chip:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: var(--accent-soft);
}

.chat-mentions-popup {
  position: absolute;
  bottom: 100%;
  left: 24px;
  right: 24px;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.1);
  margin-bottom: 12px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.mention-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  gap: 12px;
  font-size: 14px;
  transition: background 0.2s;
  color: var(--text-primary);
}

.mention-item:hover {
  background: var(--accent-soft);
}

/* Onboarding Modal */
.onboarding-card {
  max-width: 480px !important;
  border-radius: 24px !important;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.onboarding-logo {
  display: flex;
  width: 100%;
  justify-content: center;
  padding: 32px 0 16px;
}

.onboarding-logo svg {
  background: var(--accent-soft);
  padding: 16px;
  border-radius: 20px;
}

.onboarding-features b {
  color: var(--text-primary);
  font-weight: 600;
}

.toast-card.error {
  background: var(--error-color);
}

.primary-btn.sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.divider-v {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 8px;
}

/* Loading Overlay */
.loading-full {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(10px);
  justify-content: center;
  z-index: 2000;
}

[data-theme="dark"] .loading-full {
  background: var(--overlay-bg);
}

.bar-loader {
  width: 200px;
  height: 4px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.bar-loader::after {
  content: '';
  position: absolute;
  left: -50%;
  width: 50%;
  height: 100%;
  background: var(--accent-color);
  animation: loading 1.5s infinite;
}

@keyframes loading {
  from { left: -50%; }
  to { left: 100%; }
}

/* Mobile/Tablet Layout Optimization */
@media (max-width: 1024px) {
  .workspace-container {
    display: flex; flex-direction: column;
    overflow-y: auto;
    height: 100vh;
  }
  
  .pane {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 400px;
    height: auto !important;
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--border-color);
    flex: none !important;
  }
  
  #pane-sources { height: 350px !important; min-height: 300px; }
  #pane-chat { height: 600px !important; }
  #pane-output { height: 600px !important; }
  
  .resizer {
    display: none;
  }
}

@media (max-width: 768px) {
  .pane-header {
    padding: 0 12px;
    height: 56px;
  }

  .header-actions .primary-btn span {
    display: none; /* Hide button text on small screens */
  }
  
  .header-actions .primary-btn svg {
    margin-right: 0 !important;
  }
  
  .message {
    max-width: 95%;
    font-size: 14px;
  }
  
  .chat-input-container {
    padding: 12px;
  }
  
  #floating-player {
    width: 90vw;
    right: 5vw;
    left: 5vw;
    bottom: 20px;
  }
}

/* Animations & Polish */
.pane {
  transition: opacity 0.3s ease;
}

.source-item, .session-item, .memory-item {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

.source-item:active, .session-item:active {
  transform: scale(0.98);
}

.loading-full {
  background: var(--overlay-bg);
}

.toast-card {
  animation: toast-up 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes toast-up {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.session-list, .source-list, .memory-list, .temp-list {
  padding: 8px 12px;
  overflow-y: auto;
}

.session-list { max-height: 200px; }
.source-list { flex: 1; min-height: 0; }
.memory-list { max-height: 250px; }
.temp-list { max-height: 150px; }

/* Temp Section */
.temp-section {
  border-top: 1px solid var(--border-color);
  margin-top: 8px;
}

.temp-section .section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
}

.temp-section .section-header:hover {
  background: rgba(0,0,0,0.02);
}

.temp-section .section-icon {
  font-size: 14px;
}

.temp-section .section-title {
  font-weight: 500;
}

.temp-section .section-badge {
  background: var(--accent-soft);
  color: var(--accent-color);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.temp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 6px;
  font-size: 12px;
}

.temp-item:hover {
  border-color: var(--accent-color);
  background: var(--accent-soft);
}

.temp-item.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-color);
}

.temp-item .temp-icon {
  flex-shrink: 0;
}

.temp-item .temp-info {
  flex: 1;
  min-width: 0;
}

.temp-item .temp-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.temp-item .temp-time {
  font-size: 10px;
}

.temp-item .temp-actions {
  opacity: 0;
  transition: opacity 0.2s;
}

.temp-item:hover .temp-actions {
  opacity: 1;
}

.memory-item {
  padding: 8px 12px;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 8px;
  position: relative;
  line-height: 1.4;
}

.memory-item:hover {
  border-color: var(--accent-color);
}

.memory-item .delete-memory {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  cursor: pointer;
}

.memory-item:hover .delete-memory {
  opacity: 0.6;
}

.delete-memory:hover {
  color: var(--error-color);
}

.session-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  justify-content: space-between;
  transition: background 0.2s;
  border-left: 3px solid transparent;
  position: relative;
}

.session-item:hover {
  background: var(--accent-soft);
}

.session-item.active {
  background: var(--accent-soft);
  border-left-color: var(--accent-color);
}

.session-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

.session-meta {
  margin-right: 8px;
}

.delete-session {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: all 0.2s;
  flex-shrink: 0;
}

.delete-session:hover {
  background: var(--tag-bg);
  color: var(--error-color);
}

.timestamp-link {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
  font-family: monospace;
  background: var(--accent-soft);
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.timestamp-link:hover {
  background: var(--accent-color);
  color: var(--text-on-accent);
}

/* Floating Player */
.floating-player {
  position: fixed;
  bottom: 80px;
  left: 20px;
  width: 400px;
  min-width: 280px;
  max-width: 90vw;
  background: var(--bg-pane);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 1500;
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.player-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--accent-color);
  color: var(--text-on-accent);
  justify-content: space-between;
  font-size: 12px;
  cursor: move;
}

.close-player {
  background: none;
  border: none;
  color: var(--text-on-accent);
  cursor: pointer;
  font-size: 16px;
}

/* Custom resize handle */
.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  z-index: 20;
}

.resize-handle::before {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--accent-color);
  border-bottom: 2px solid var(--accent-color);
  opacity: 0.5;
  transition: opacity 0.2s;
}

.floating-player:hover .resize-handle::before {
  opacity: 1;
}

.player-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  background: #000;
}

#youtube-iframe-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.yt-player-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#yt-player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#youtube-iframe-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.player-fallback {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.9);
  text-align: center;
  z-index: 10;
}

.fallback-text {
  color: #fff;
  line-height: 1.6;
  font-size: 13px;
}

.fallback-text span {
  font-size: 11px;
  opacity: 0.7;
}

.fallback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 8px;
  background: #ff0000;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  gap: 6px;
  transition: background 0.2s;
}

.fallback-btn:hover {
  background: #cc0000;
}

.view-actions-float {
  position: absolute;
  top: 16px;
  right: 16px;
  gap: 8px;
  z-index: 5;
}

.citation-link {
  color: var(--accent-color);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  background: var(--accent-soft);
  padding: 0 4px;
  border-radius: 4px;
  font-size: 0.9em;
  transition: all 0.2s;
}

.citation-link:hover {
  background: var(--accent-color);
  color: var(--text-on-accent);
}

.source-item.highlight-flash {
  animation: highlight-pulse 2s ease-in-out;
}

@keyframes highlight-pulse {
  0% { background-color: var(--accent-color); color: var(--text-on-accent); }
  50% { background-color: var(--accent-soft); color: var(--accent-color); }
  100% { background-color: var(--text-on-accent); color: var(--text-primary); }
}

.toast-card.success {
  background: var(--accent-color);
}

.toast-card.error {
  background: var(--error-color);
}

.primary-btn.sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.divider-v {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 8px;
}

.source-checkbox-wrapper {
  padding-right: 8px;
}

.source-tag-skeleton {
  display: inline-block;
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent-color);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  font-weight: 600;
}

.source-actions {
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

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

.icon-btn-small {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
  color: var(--text-muted);
}

.icon-btn-small:hover {
  background: var(--accent-soft);
  color: var(--accent-color);
}

.play-video-btn {
  color: var(--accent-color);
}

.play-video-btn:hover {
  background: var(--accent-color) !important;
  color: var(--text-on-accent) !important;
}

.message-mode-selector {
  margin-bottom: 8px;
  padding: 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.message-mode-selector::-webkit-scrollbar {
  display: none;
}

.mode-chip {
  padding: 4px 10px;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.mode-chip.active {
  background: var(--accent-color);
  color: var(--text-on-accent);
  border-color: var(--accent-color);
}

/* Empty State Styling */
.empty-state {
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  font-size: 14px;
}

.empty-state p {
  margin: 0;
}

.empty-state::before {
  content: "∅";
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Memory Item Styling */
.memory-item {
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-app);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 13px;
  line-height: 1.5;
  transition: all 0.2s ease;
}

.memory-item:hover {
  border-color: var(--accent-soft);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.memory-fact {
  flex: 1;
  color: var(--text-primary);
}

.delete-memory {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s;
}

.memory-item:hover .delete-memory {
  opacity: 1;
}

.delete-memory:hover {
  color: var(--error-color);
}

/* Suggested Questions Styling */
.suggestion-chip {
  background: var(--bg-pane);
  border: 1px solid var(--accent-soft);
  color: var(--accent-color);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* Scrollbar Polish */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* URL Queue List */
.url-queue-list {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.queue-item {
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  transition: background 0.2s;
}

.queue-item:last-child {
  border-bottom: none;
}

.queue-item:hover {
  background: rgba(0,0,0,0.02);
}

.remove-url {
  background: none;
  border: none;
  color: var(--error-color);
  cursor: pointer;
  font-size: 18px;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.remove-url:hover {
  background: var(--tag-bg);
}

/* Archive View Overlay */
.archive-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-pane);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex; flex-direction: column;
  animation: slide-in-down 0.3s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes slide-in-down {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.archive-header {
  padding: 16px 24px;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-pane);
}

.archive-header h4 {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-primary);
}

.archive-view .session-list {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.archive-view .session-item {
  padding: 14px 20px;
  margin-bottom: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.archive-view .session-item:hover {
  background: var(--bg-sidebar);
  border-color: var(--border-color);
}

.archive-view .session-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-color);
}

.archive-view .session-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

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

/* Inline Loading (non-blocking) */
.inline-loader {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--bg-pane) 100%);
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  animation: pulse-subtle 2s ease-in-out infinite;
}

.inline-loader-content {
    display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Typing Indicator for AI */
.typing-indicator {
  padding: 12px 16px !important;
}

.typing-dots {
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

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

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

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

/* Refined Modal Styles */
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-primary);
  font-weight: 600;
}

.modal-body label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-body input[type="text"],
.modal-body input[type="password"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-app);
  font-family: var(--font-ui);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  border-color: var(--accent-color);
  background: var(--bg-pane);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.input-tabs {
  gap: 8px;
  background: var(--bg-sidebar);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.input-tabs .tab-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.input-tabs .tab-btn.active {
  background: var(--bg-pane);
  color: var(--accent-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}


.url-input-group {
  gap: 12px;
  margin-bottom: 20px;
}

.browser-options {
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-sidebar);
  border-radius: 12px;
  margin-top: 20px;
}

.browser-options label {
  margin-bottom: 0;
  font-weight: 500;
}

.browser-options select {
  width: auto;
  padding: 6px 12px;
}

.tab-content {
  display: none;
  animation: fade-in 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Streaming message styles */
.message.streaming {
  border-left: 2px solid var(--accent-color);
}

.message.streaming::after {
  content: '▌';
  animation: blink 1s step-end infinite;
  color: var(--accent-color);
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Thinking Process Indicator */
.thinking-process {
  background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--bg-pane) 100%) !important;
  border-left: 3px solid var(--accent-color) !important;
  animation: thinking-pulse 2s ease-in-out infinite;
}

.thinking-content {
  gap: 10px;
  font-size: 13px;
}

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

.thinking-text {
  font-style: italic;
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ==================== Mindmap Enhanced Controls ==================== */
.mindmap-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  border-radius: 12px;
}

.mindmap-wrapper #mindmap-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}

.mindmap-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  gap: 8px;
  background: var(--bg-pane);
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  z-index: 100;
}

.mm-ctrl-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-sidebar);
  border-radius: 8px;
  cursor: pointer;
  justify-content: center;
  transition: all 0.2s ease;
}

.mm-ctrl-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-color);
}

.mm-ctrl-btn:active {
  transform: scale(0.95);
}

.mm-zoom-level {
  font-size: 12px;
  min-width: 40px;
  text-align: center;
  font-weight: 500;
}

.mm-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

.mm-tip {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: var(--text-on-accent);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 100;
  transition: opacity 0.5s ease;
}

.mm-tip.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Mindmap node hover effects */
.mindmap-wrapper .markmap-node {
  cursor: pointer;
}

.mindmap-wrapper .markmap-node:hover circle {
  stroke-width: 3px;
}

.mindmap-wrapper .markmap-node:hover text {
  font-weight: 600;
}

/* Output pane - flex layout (no hardcoded heights) */
#pane-output {
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border-color);
  width: var(--output-w);
  min-width: 300px;
  max-width: 600px;
}

#pane-output .pane-header {
  flex-shrink: 0;
}

#pane-output .tabs-bar {
  flex-shrink: 0;
}

#pane-output .output-pane {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Output Pane Layout Optimization */
.output-pane {
  position: relative;
  overflow: hidden;
  flex: 1;
  background: var(--bg-pane);
}

/* View Content - Simple Tab Switching */
.view-content {
  display: none;
  height: 100%;
  width: 100%;
}

.view-content.active {
  display: flex; flex-direction: column;
}

#mindmap-view {
  background: var(--bg-app);
}

#mindmap-view .mindmap-wrapper {
  flex: 1;
  min-height: 0;
}

#article-view {
  overflow: hidden;
  padding: 0;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
}

#article-view.active {
  display: flex;
}

/* Vditor WYSIWYG Editor */
#vditor {
  flex: 1;
  height: 100%;
  border: none !important;
}

#vditor .vditor-toolbar {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-pane);
}

#vditor .vditor-content {
  background: var(--bg-app);
}

#vditor .vditor-ir {
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.8;
}

/* Vditor Dark Theme - Optimized for reading */
[data-theme="dark"] #vditor {
  --vditor-ir-heading-color: #e8e8e8;
  --vditor-toolbar-background-color: #1e1e1e;
}

[data-theme="dark"] #vditor .vditor-toolbar {
  background: #1a1a1a;
  border-color: #333;
}

[data-theme="dark"] #vditor .vditor-content {
  background: #1e1e1e;
}

[data-theme="dark"] #vditor .vditor-ir {
  background: #1e1e1e;
  color: #d4d4d4;
}

[data-theme="dark"] #vditor .vditor-ir pre.vditor-reset {
  background: #1e1e1e;
  color: #d4d4d4;
}

[data-theme="dark"] #vditor .vditor-ir h1,
[data-theme="dark"] #vditor .vditor-ir h2,
[data-theme="dark"] #vditor .vditor-ir h3,
[data-theme="dark"] #vditor .vditor-ir h4,
[data-theme="dark"] #vditor .vditor-ir h5 {
  color: #f0f0f0;
}

[data-theme="dark"] #vditor .vditor-ir a {
  color: #6db3f2;
}

[data-theme="dark"] #vditor .vditor-ir code {
  background: #2d2d2d;
  color: #ce9178;
}

[data-theme="dark"] #vditor .vditor-ir blockquote {
  border-left-color: #4a5d4e;
  background: rgba(74, 93, 78, 0.1);
  color: #b0b0b0;
}

[data-theme="dark"] #vditor .vditor-ir ul,
[data-theme="dark"] #vditor .vditor-ir ol {
  color: #d4d4d4;
}

[data-theme="dark"] #vditor .vditor-ir hr {
  border-color: #444;
}

[data-theme="dark"] #vditor .vditor-ir table th,
[data-theme="dark"] #vditor .vditor-ir table td {
  border-color: #444;
}

[data-theme="dark"] #vditor .vditor-ir table th {
  background: #2a2a2a;
}

/* 覆盖模式特有的全屏效果 */
.workspace-container.fullscreen-output #pane-output {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  z-index: 1000;
}

.file-size {
  opacity: 0.5;
}

/* Transcript Styles */
.transcript-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.transcript-row {
  display: flex;
  align-items: baseline;
}

.transcript-timestamp-wrapper {
  flex-shrink: 0;
}

.transcript-timestamp-inactive {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 13px;
  margin-right: 8px;
}

.transcript-text {
  line-height: 1.6;
}

.empty-text {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

.extension-link {
  color: var(--accent-color);
}

/* Dark Theme Specific Overrides for Comfort */
[data-theme="dark"] .source-item {
  box-shadow: none;
}

[data-theme="dark"] .source-item:hover {
  background: var(--hover-bg);
}

[data-theme="dark"] .message.ai {
  background: var(--bg-sidebar); /* Slightly darker for AI message to stand out less than user */
  border: 1px solid var(--border-color);
  box-shadow: none;
}

[data-theme="dark"] .chat-input-wrapper {
  background: var(--bg-sidebar);
}

[data-theme="dark"] .input-shell {
  background: var(--bg-sidebar);
}

[data-theme="dark"] .modal {
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .model-card {
  background: var(--bg-sidebar);
}

[data-theme="dark"] .primary-btn {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

[data-theme="dark"] .primary-btn:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

/* ==================== MCP Tools Configuration ==================== */
.mcp-tools-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mcp-tool-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-app);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  transition: all 0.3s ease;
}

.mcp-tool-item:hover {
  background: var(--bg-pane);
  border-color: var(--accent-soft);
}

.mcp-tool-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mcp-tool-icon {
  font-size: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 12px;
}

.mcp-tool-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mcp-tool-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.mcp-tool-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.mcp-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

.mcp-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.mcp-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-color);
  border-radius: 26px;
  transition: all 0.3s ease;
}

.mcp-toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mcp-toggle input:checked + .mcp-toggle-slider {
  background: var(--accent-color);
}

.mcp-toggle input:checked + .mcp-toggle-slider::before {
  transform: translateX(22px);
}

.mcp-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--accent-soft);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.mcp-hint svg {
  color: var(--accent-color);
  flex-shrink: 0;
}

/* MCP Modal Specific */
.mcp-modal {
  max-width: 500px;
}

.mcp-modal-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-soft), rgba(99, 102, 241, 0.15));
  border-radius: 12px;
}

.mcp-modal-icon svg {
  color: var(--accent-color);
}

.mcp-intro {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-app);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.mcp-intro p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

/* Config Tabs in AI Modal */
.config-tabs {
  display: flex;
  gap: 8px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-color);
}

.config-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -1px;
}

.config-tab:hover {
  color: var(--text-primary);
}

.config-tab.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
}

.config-tab svg {
  opacity: 0.7;
}

.config-tab.active svg {
  opacity: 1;
}

.config-tab-content {
  display: none;
}

.config-tab-content.active {
  display: block;
}
