/* Design System Tokens */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  
  /* Colors */
  --bg-primary: 224 71% 4%;       /* Deep slate-950 background (#030712) */
  --bg-secondary: 222 47% 11%;    /* Dark panel background (#0b0f19) */
  --bg-tertiary: 223 47% 16%;     /* Active state / lighter panel (#111827) */
  --border-color: 223 47% 20%;    /* Muted borders (#1e293b) */
  
  --text-primary: 210 40% 98%;    /* Ice white (#f8fafc) */
  --text-secondary: 215 20% 65%;  /* Cool grey (#94a3b8) */
  --text-muted: 215 16% 47%;      /* Dimmed text (#64748b) */
  
  --accent: 250 84% 67%;          /* Indigo (#6366f1) */
  --accent-gradient: linear-gradient(135deg, hsl(250, 84%, 67%), hsl(270, 84%, 60%));
  --accent-light: 250 84% 75%;
  
  --danger: 0 84% 60%;            /* Rose red (#f43f5e) */
  --success: 142 71% 45%;         /* Emerald (#10b981) */
  --warning: 35 91% 56%;          /* Amber (#f59e0b) */
  
  --user-msg-bg: rgba(99, 102, 241, 0.12);
  --user-msg-border: rgba(99, 102, 241, 0.25);
  --bot-msg-bg: rgba(17, 24, 39, 0.55);
  --bot-msg-border: rgba(255, 255, 255, 0.05);
  
  --glass-bg: rgba(11, 15, 25, 0.65);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Base reset & styling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: hsl(var(--bg-primary));
  color: hsl(var(--text-primary));
  height: 100vh;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: hsl(var(--border-color));
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--text-muted));
}

/* Layout structure */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: 300px;
  background-color: hsl(var(--bg-secondary));
  border-right: 1px solid hsl(var(--border-color));
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 40;
  overflow-y: auto;
}

.sidebar.collapsed {
  margin-left: -300px;
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid hsl(var(--border-color));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  margin: 1.25rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}
.btn-new-chat:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}
.btn-new-chat:active {
  transform: translateY(0);
}

/* Chat List */
.chat-list-container {
  overflow-y: auto;
  padding: 0 0.75rem;
  max-height: 40vh;
  min-height: 60px;
  flex-shrink: 0;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 0.25rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  color: hsl(var(--text-secondary));
}
.chat-item:hover {
  background-color: hsl(var(--bg-tertiary));
  color: hsl(var(--text-primary));
}
.chat-item.active {
  background-color: hsl(var(--bg-tertiary));
  border-color: hsl(var(--border-color));
  color: hsl(var(--text-primary));
  font-weight: 500;
}

.chat-item-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}
.chat-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.875rem;
}

.chat-item-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  opacity: 1;
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  padding: 0.25rem;
  border-radius: 0.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-action-btn:hover {
  color: hsl(var(--text-primary));
  background-color: rgba(255, 255, 255, 0.05);
}
.chat-action-btn.delete-btn:hover {
  color: hsl(var(--danger));
}

/* Sidebar Settings Section */
.sidebar-settings {
  border-top: 1px solid hsl(var(--border-color));
}

.settings-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  color: hsl(var(--text-secondary));
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}
.settings-trigger:hover {
  color: hsl(var(--text-primary));
  background-color: hsl(var(--bg-tertiary));
}

.settings-panel {
  max-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 1.25rem;
}
.settings-panel.open {
  max-height: 380px;
  padding: 0.75rem 1.25rem 1.25rem;
}

.setting-group {
  margin-bottom: 1rem;
}
.setting-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--text-secondary));
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.setting-input {
  width: 100%;
  background-color: hsl(var(--bg-primary));
  border: 1px solid hsl(var(--border-color));
  color: hsl(var(--text-primary));
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}
.setting-input:focus {
  border-color: hsl(var(--accent));
  outline: none;
}
.setting-btn {
  background: hsl(var(--accent));
  color: #fff;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-family: inherit;
}
.setting-btn:hover {
  opacity: 0.85;
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.toggle-group input[type="checkbox"] {
  cursor: pointer;
  accent-color: hsl(var(--accent));
}
.toggle-group label {
  margin-bottom: 0;
  cursor: pointer;
}

/* Memory Panel */
.sidebar-memory {
  border-top: 1px solid hsl(var(--border-color));
}

.memory-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  color: hsl(var(--text-secondary));
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}
.memory-trigger:hover {
  color: hsl(var(--text-primary));
  background-color: hsl(var(--bg-tertiary));
}

.memory-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.memory-panel.open {
  max-height: 60vh;
  padding: 0.75rem 1.25rem 1rem;
}

.memory-search {
  width: 100%;
  background-color: hsl(var(--bg-primary));
  border: 1px solid hsl(var(--border-color));
  color: hsl(var(--text-primary));
  padding: 0.4rem 0.6rem;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.memory-search:focus {
  border-color: hsl(var(--accent));
}
.memory-search::placeholder {
  color: hsl(var(--text-muted));
}

.memory-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-height: 0;
}

.memory-empty {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
  text-align: center;
  padding: 1rem 0;
  font-style: italic;
}

.memory-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  transition: border-color 0.15s;
}
.memory-item:hover {
  border-color: hsl(var(--text-muted));
}

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

.memory-item-key {
  font-size: 0.75rem;
  font-weight: 700;
  color: hsl(var(--accent-light));
  font-family: var(--font-mono);
  word-break: break-all;
  margin-bottom: 0.15rem;
}

.memory-item-value {
  font-size: 0.7rem;
  color: hsl(var(--text-secondary));
  word-break: break-word;
  line-height: 1.3;
  max-height: 3.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.memory-item.expanded .memory-item-value {
  max-height: none;
  overflow: visible;
  text-overflow: clip;
}

.memory-expand-hint {
  color: hsl(var(--accent-light));
  cursor: pointer;
  font-size: 0.65rem;
  white-space: nowrap;
}

.memory-item-actions {
  display: flex;
  flex-direction: row;
  gap: 0.15rem;
  flex-shrink: 0;
  align-items: center;
}

.memory-item-edit {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.memory-item-edit:hover {
  color: hsl(var(--accent-light));
  background-color: hsl(var(--accent-light) / 0.1);
}

.memory-item-delete {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.memory-item-delete:hover {
  color: hsl(var(--danger));
  background-color: hsl(var(--danger) / 0.1);
}

.memory-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  background: transparent;
  border: 1px solid hsl(var(--danger) / 0.3);
  color: hsl(var(--danger));
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s;
}
.memory-clear-btn:hover {
  background-color: hsl(var(--danger) / 0.1);
  border-color: hsl(var(--danger));
}

/* Main Content Styling */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: hsl(var(--bg-primary));
}

/* Main Header */
.main-header {
  height: 60px;
  border-bottom: 1px solid hsl(var(--border-color));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background-color: hsl(var(--bg-secondary));
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: hsl(var(--text-secondary));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
}
.sidebar-toggle-btn:hover {
  background-color: hsl(var(--bg-tertiary));
  color: hsl(var(--text-primary));
}

.active-chat-title-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.active-chat-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-edit-input {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  background-color: hsl(var(--bg-primary));
  border: 1px solid hsl(var(--accent));
  color: hsl(var(--text-primary));
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  outline: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: transparent;
  border: 1px solid hsl(var(--border-color));
  color: hsl(var(--text-secondary));
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.header-btn:hover {
  background-color: hsl(var(--bg-tertiary));
  color: hsl(var(--text-primary));
  border-color: hsl(var(--text-muted));
}

/* Chat Area */
.chat-feed-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-feed-inner {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Welcome / Empty Screen */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto;
  padding: 2rem 1rem;
  max-width: 600px;
  animation: fadeIn 0.5s ease-out;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  border-radius: 1rem;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}
.welcome-logo svg {
  width: 32px;
  height: 32px;
  color: white;
}

.welcome-title {
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  letter-spacing: -0.025em;
}

.welcome-subtitle {
  font-size: 1.05rem;
  color: hsl(var(--text-secondary));
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

.welcome-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: hsl(var(--text-muted));
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  text-align: left;
  width: 100%;
}

.personas-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  width: 100%;
}

@media (max-width: 640px) {
  .personas-grid {
    grid-template-columns: 1fr;
  }

  .header-btn span { display: none; }
  .header-btn { padding: 0.4rem; }

  .message-bubble { max-width: 92%; }

  .connect-overlay {
    overflow-y: auto;
    align-items: flex-start;
    padding: 1rem;
  }

  .chat-feed-container { padding: 1rem 0.75rem; }
  .chat-input-container { padding: 0 0.75rem 0.75rem; }

  .welcome-title { font-size: 1.75rem; }
  .welcome-subtitle { font-size: 0.95rem; }

  .toast-container { right: auto; left: 0; width: 100%; padding: 0 0.5rem; }
  .toast { max-width: 100%; }
}

.persona-card {
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  padding: 1.25rem;
  border-radius: 0.75rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.persona-card:hover {
  border-color: hsl(var(--accent));
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
  background-color: hsl(var(--bg-tertiary));
}

.persona-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
}
.persona-card-icon {
  font-size: 1.25rem;
}
.persona-card-desc {
  font-size: 0.8rem;
  color: hsl(var(--text-secondary));
  line-height: 1.4;
}

/* Message Bubbles */
.message-row {
  display: flex;
  width: 100%;
  animation: messageSlideIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.message-row.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 85%;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  position: relative;
}

.message-row.user .message-bubble {
  background-color: var(--user-msg-bg);
  border: 1px solid var(--user-msg-border);
  border-bottom-right-radius: 0.25rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.05);
}

.message-row.assistant .message-bubble {
  background-color: var(--bot-msg-bg);
  border: 1px solid var(--bot-msg-border);
  border-top-left-radius: 0.25rem;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(12px);
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.msg-header.user {
  color: hsl(var(--accent-light));
  justify-content: flex-end;
}

.msg-header.assistant {
  color: hsl(var(--accent));
}

/* Message Contents Styles */
.msg-content {
  font-size: 0.925rem;
  line-height: 1.6;
  word-break: break-word;
}

.msg-content p {
  margin-bottom: 0.75rem;
}
.msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content ul, .msg-content ol {
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
}
.msg-content li {
  margin-bottom: 0.25rem;
}

.msg-content a {
  color: hsl(var(--accent-light));
  text-decoration: underline;
}
.msg-content a:hover {
  color: white;
}

/* Math Styling */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

/* Code Blocks */
.msg-content pre {
  background-color: #0d1117 !important;
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.5rem;
  margin: 1rem 0;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #161b22;
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid hsl(var(--border-color));
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: hsl(var(--text-secondary));
  font-weight: 600;
}

.code-block-body {
  padding: 1rem;
  margin: 0 !important;
  background-color: transparent !important;
  overflow-x: auto;
}
.code-block-body code {
  font-family: var(--font-mono) !important;
  font-size: 0.85rem !important;
  text-shadow: none !important;
}

.btn-copy-code {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background-color: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: hsl(var(--text-secondary));
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-copy-code:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
}

.msg-content code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background-color: rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  color: #e5c07b; /* Warm tone for inline code variables */
}

/* Error Bubble */
.message-bubble.error {
  border-color: hsl(var(--danger) / 0.4);
  background-color: hsl(var(--danger) / 0.08);
}
.error-text {
  color: hsl(var(--danger));
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.btn-retry {
  background-color: hsl(var(--danger));
  color: white;
  border: none;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  margin-top: 0.75rem;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: opacity 0.15s;
}
.btn-retry:hover {
  opacity: 0.9;
}

/* Message Controls (Edit/Delete etc) */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  justify-content: flex-end;
}
.message-row:hover .msg-actions {
  opacity: 1;
}

.msg-tokens {
  font-size: 0.65rem;
  color: hsl(var(--text-muted));
  opacity: 0.6;
  margin-right: auto;
}

.context-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.context-bar {
  display: inline-block;
  width: 40px;
  height: 3px;
  background: hsl(var(--border-color));
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
}

.context-bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease, background 0.3s ease;
}

.msg-action-btn {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-action-btn:hover {
  color: hsl(var(--text-primary));
  background-color: rgba(255, 255, 255, 0.05);
}

/* Thinking indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.25rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: hsl(var(--text-muted));
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Footer / Input Container */
.chat-input-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

.chat-input-wrapper {
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--glass-shadow);
}
.chat-input-wrapper:focus-within {
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 2px hsl(var(--accent) / 0.15), var(--glass-shadow);
}

.chat-textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: hsl(var(--text-primary));
  font-family: inherit;
  font-size: 0.925rem;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  outline: none;
}

/* Slash command menu */
.slash-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  margin-bottom: 0.25rem;
  background: hsl(var(--bg-card));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.625rem;
  box-shadow: 0 8px 32px hsl(0 0% 0% / 0.18);
  max-height: 160px;
  overflow-y: auto;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.slash-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid hsl(var(--border-color) / 0.4);
}
.slash-item:last-child {
  border-bottom: none;
}
.slash-item:hover,
.slash-item.highlighted {
  background: hsl(var(--bg-secondary));
}
.slash-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 0.375rem;
  background: hsl(var(--bg-tertiary));
  color: hsl(var(--text-muted));
  flex-shrink: 0;
}
.slash-item-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: hsl(var(--text-primary));
  font-family: 'JetBrains Mono', monospace;
}
.slash-item-desc {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
  margin-left: auto;
  white-space: nowrap;
}
.chat-textarea::placeholder {
  color: hsl(var(--text-muted));
}

.chat-input-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid hsl(var(--border-color) / 0.5);
  padding-top: 0.5rem;
}

.input-left-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
}

.input-right-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-send {
  background: var(--accent-gradient);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-send:hover:not(:disabled) {
  opacity: 0.95;
  transform: scale(1.05);
}
.btn-send:disabled {
  background: hsl(var(--bg-tertiary));
  color: hsl(var(--text-muted));
  cursor: not-allowed;
}

.btn-mic {
  background: transparent;
  border: 1px solid hsl(var(--border-color));
  color: hsl(var(--text-muted));
  width: 32px;
  height: 32px;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-mic:hover {
  border-color: hsl(var(--accent));
  color: hsl(var(--accent));
}
.btn-mic.recording {
  border-color: hsl(var(--danger));
  color: hsl(var(--danger));
  background: hsl(var(--danger) / 0.1);
  animation: micPulse 1s ease-in-out infinite;
}
.btn-mic.hidden {
  display: none;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 hsl(var(--danger) / 0.4); }
  50% { box-shadow: 0 0 0 6px hsl(var(--danger) / 0); }
}

.btn-stop {
  background-color: hsl(var(--danger) / 0.15);
  border: 1px solid hsl(var(--danger) / 0.4);
  color: hsl(var(--danger));
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  transition: all 0.2s;
}
.btn-stop:hover {
  background-color: hsl(var(--danger));
  color: white;
}

.limit-reached-banner {
  background-color: hsl(var(--danger) / 0.1);
  border: 1px solid hsl(var(--danger) / 0.25);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  color: hsl(var(--danger));
  text-align: center;
  font-weight: 500;
}

/* Mobile overlay styling */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 35;
  animation: fadeIn 0.2s ease-out;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* System / Notice Rows (e.g. /compact notice) */
.message-row.system .message-bubble {
  font-size: 0.82rem;
  font-style: italic;
  border-style: solid;
}

/* Command hint below textarea */
.command-hint {
  font-size: 0.72rem;
  color: hsl(var(--text-muted) / 0.45);
  padding: 0.15rem 0.25rem 0;
  user-select: none;
  letter-spacing: 0.02em;
}

/* Tool Call Bubbles (Agentic) */
.message-row.tool-call {
  justify-content: flex-start;
}
.tool-call-bubble {
  background-color: hsl(var(--bg-card)) !important;
  border: 1px dashed hsl(var(--text-muted) / 0.35) !important;
  border-top-left-radius: 0.25rem !important;
  padding: 0.5rem 0.85rem !important;
  max-width: 90% !important;
}
.tool-call-bubble .msg-content {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.tool-call-label {
  color: hsl(var(--text-muted));
  font-weight: 500;
}
.tool-call-url {
  background: hsl(var(--bg-subtle));
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}
.tool-call-status {
  color: hsl(var(--accent));
  font-weight: 600;
  animation: pulse 1.2s ease-in-out infinite;
}
.tool-call-done {
  border-color: hsl(var(--success) / 0.5) !important;
  border-style: solid !important;
  opacity: 0.7;
}
.tool-call-error {
  border-color: hsl(var(--danger) / 0.5) !important;
  border-style: solid !important;
  opacity: 0.8;
}
.tool-call-detail {
  color: hsl(var(--text-muted));
  font-size: 0.7rem;
}
.btn-download-file {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background-color: hsl(var(--accent) / 0.15);
  border: 1px solid hsl(var(--accent) / 0.3);
  color: hsl(var(--accent));
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-download-file:hover {
  background-color: hsl(var(--accent) / 0.25);
  border-color: hsl(var(--accent) / 0.5);
}
.chart-canvas {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 4px;
  background: hsl(var(--bg-primary) / 0.3);
  margin-top: 0.2rem;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Connect Screen */
.connect-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: hsl(var(--bg-primary));
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.connect-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
}
.connect-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  background: hsl(var(--accent) / 0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--accent));
}
.connect-icon svg { width: 24px; height: 24px; }
.connect-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: hsl(var(--text-primary));
}
.connect-desc {
  font-size: 0.9rem;
  color: hsl(var(--text-secondary));
  line-height: 1.5;
  margin: 0 0 1.5rem;
}
.connect-input-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}
.connect-field-group {
  margin-bottom: 0.75rem;
  text-align: left;
}
.connect-field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: hsl(var(--text-secondary));
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.connect-input-group .setting-input {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
}
.connect-btn {
  padding: 0.5rem 1.25rem;
  background: hsl(var(--accent));
  color: #fff;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
}
.connect-btn:hover { opacity: 0.85; }
.connect-btn-secondary {
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: hsl(var(--accent));
  border: 1px solid hsl(var(--accent) / 0.4);
  border-radius: 0.375rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.75rem;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.connect-btn-secondary:hover {
  background: hsl(var(--accent) / 0.1);
  border-color: hsl(var(--accent));
}
.connect-headline {
  font-size: 1.1rem;
  font-weight: 500;
  color: hsl(var(--text-primary));
  margin: 0 0 1.25rem;
  line-height: 1.4;
}
.connect-why-grid {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1.5rem;
  text-align: left;
}
.connect-why-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  transition: border-color 0.2s, box-shadow 0.2s;
}
.connect-why-card:hover {
  border-color: hsl(var(--accent) / 0.4);
  box-shadow: 0 0 0 1px hsl(var(--accent) / 0.15);
}
.connect-why-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--accent) / 0.12);
  border-radius: 8px;
  font-size: 1rem;
}
.connect-why-content {
  min-width: 0;
}
.connect-why-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: hsl(var(--text-primary));
  margin-bottom: 0.15rem;
  letter-spacing: 0.01em;
}
.connect-why-text {
  font-size: 0.7rem;
  color: hsl(var(--text-secondary));
  line-height: 1.45;
}
.connect-note {
  margin-top: 1rem;
  font-size: 0.7rem;
  color: hsl(var(--text-muted));
}

/* Mobile media query */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    overflow-y: auto;
  }
  .sidebar.collapsed {
    left: -300px;
    margin-left: 0;
  }
  .sidebar-overlay.active {
    display: block;
  }
  #close-sidebar-btn { display: flex !important; }
}

/* Export dropdown */
.export-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
}

.export-wrapper .header-btn:first-child {
  border-radius: 0.375rem 0 0 0.375rem;
}

.export-drop-btn {
  border-radius: 0 0.375rem 0.375rem 0;
  padding: 0.25rem 0.35rem;
  border-left: 1px solid hsl(var(--border-color));
}

.export-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  min-width: 130px;
  overflow: hidden;
}

.export-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  color: hsl(var(--text-secondary));
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.export-option:hover {
  background: hsl(var(--bg-tertiary));
  color: hsl(var(--text-primary));
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: hsl(var(--text-primary));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.2s ease-out;
  max-width: 340px;
}

.toast.toast-error { border-color: #ef4444; }
.toast.toast-success { border-color: #22c55e; }
.toast.toast-info { border-color: var(--accent-light, #3b82f6); }

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

/* Confirm modal */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.12s ease-out;
}

.confirm-modal {
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.75rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 380px;
  overflow: hidden;
}

.confirm-body {
  padding: 1.25rem 1.25rem 0.75rem;
  color: hsl(var(--text-primary));
  font-size: 0.9rem;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem 1.25rem;
}

.confirm-actions .btn {
  padding: 0.4rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  border: 1px solid hsl(var(--border-color));
  cursor: pointer;
  font-family: inherit;
}

.btn-cancel {
  background: transparent;
  color: hsl(var(--text-secondary));
}

.btn-cancel:hover {
  background: hsl(var(--bg-tertiary));
}

.btn-danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Keyboard Shortcuts Modal */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}

.shortcuts-modal {
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.75rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border-color));
}

.shortcuts-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--text-primary));
}

.shortcuts-close-btn {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
}

.shortcuts-close-btn:hover {
  color: hsl(var(--text-primary));
  background: hsl(var(--bg-tertiary));
}

.shortcuts-body {
  padding: 0.75rem 1.25rem 1.25rem;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  color: hsl(var(--text-secondary));
}

.shortcut-row kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: hsl(var(--bg-primary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.25rem;
  padding: 0.15rem 0.5rem;
  color: hsl(var(--text-primary));
  white-space: nowrap;
}

.shortcut-row code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: hsl(var(--bg-tertiary));
  border-radius: 0.25rem;
  padding: 0.15rem 0.5rem;
  color: hsl(var(--accent-light));
}

.shortcut-row span {
  color: hsl(var(--text-secondary));
}

.shortcuts-divider {
  height: 1px;
  background: hsl(var(--border-color));
  margin: 0.5rem 0;
}

/* ── In-Chat Search Bar ────────────────────────────────────────────────── */

.chat-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem;
  background: hsl(var(--bg-secondary));
  border-bottom: 1px solid hsl(var(--border-color));
  gap: 0.5rem;
  flex-shrink: 0;
}

.chat-search-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  color: hsl(var(--text-muted));
}

.chat-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: hsl(var(--text-primary));
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}
.chat-search-input::placeholder {
  color: hsl(var(--text-muted));
}

.chat-search-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.chat-search-counter {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
  white-space: nowrap;
  min-width: 4rem;
  text-align: right;
}

.chat-search-nav,
.chat-search-close {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.chat-search-nav:hover,
.chat-search-close:hover {
  color: hsl(var(--text-primary));
  background: hsl(var(--bg-tertiary));
}

/* Search highlight marks */
mark.search-highlight {
  background: hsl(50 100% 50% / 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

mark.search-highlight-current {
  background: hsl(50 100% 50% / 0.7);
  color: hsl(var(--bg-primary));
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Global Chat Search (Sidebar) ────────────────────────────────────── */

.chat-search-global {
  padding: 0 0.75rem 0.5rem;
  border-bottom: 1px solid hsl(var(--border-color) / 0.5);
}
.chat-search-global-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.375rem;
  padding: 0.3rem 0.5rem;
  transition: border-color 0.15s;
}
.chat-search-global-input-wrapper:focus-within {
  border-color: hsl(var(--accent));
}
.chat-search-global-input-wrapper svg {
  color: hsl(var(--text-muted));
}
.chat-search-global-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: hsl(var(--text-primary));
  font-size: 0.8rem;
  font-family: inherit;
}
.chat-search-global-input::placeholder {
  color: hsl(var(--text-muted));
}
.chat-search-global-clear {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.1rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-search-global-clear:hover {
  color: hsl(var(--text-primary));
  background: hsl(var(--bg-tertiary));
}
.chat-search-global-results {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 0.35rem;
  border-radius: 0.375rem;
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
}
.chat-search-global-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid hsl(var(--border-color) / 0.3);
}
.chat-search-global-result-item:last-child {
  border-bottom: none;
}
.chat-search-global-result-item:hover {
  background: hsl(var(--bg-tertiary));
}
.chat-search-global-result-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: hsl(var(--text-primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-search-global-result-snippet {
  font-size: 0.7rem;
  color: hsl(var(--text-muted));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.chat-search-global-result-empty {
  padding: 0.75rem;
  text-align: center;
  color: hsl(var(--text-muted));
  font-size: 0.75rem;
}

/* ── Custom Tools ─────────────────────────────────────────────────────── */

.custom-tool-card {
  background: hsl(var(--bg-tertiary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.375rem;
  padding: 0.5rem;
  margin-bottom: 0.4rem;
}
.custom-tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}
.custom-tool-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: hsl(var(--text-primary));
  font-family: var(--font-mono);
}
.custom-tool-remove {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.15rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.custom-tool-remove:hover {
  color: hsl(var(--danger));
  background: hsl(var(--danger) / 0.1);
}
.custom-tool-desc {
  font-size: 0.7rem;
  color: hsl(var(--text-secondary));
  margin-bottom: 0.3rem;
  line-height: 1.3;
}
.custom-tool-params-preview {
  font-size: 0.65rem;
  color: hsl(var(--text-muted));
  font-family: var(--font-mono);
  background: hsl(var(--bg-primary));
  border-radius: 0.25rem;
  padding: 0.3rem;
  max-height: 60px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── File Attachment ──────────────────────────────────────────────────── */

.btn-attach {
  background: transparent;
  border: 1px solid hsl(var(--border-color));
  color: hsl(var(--text-muted));
  width: 32px;
  height: 32px;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-attach:hover {
  border-color: hsl(var(--accent));
  color: hsl(var(--accent));
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: hsl(var(--bg-tertiary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.375rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  animation: fadeIn 0.15s ease-out;
}
.file-chip-name {
  font-weight: 600;
  color: hsl(var(--text-primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.file-chip-size {
  color: hsl(var(--text-muted));
  font-size: 0.7rem;
  white-space: nowrap;
}
.file-chip-remove {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.15rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
}
.file-chip-remove:hover {
  color: hsl(var(--danger));
  background: hsl(var(--danger) / 0.1);
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: hsl(var(--bg-primary) / 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
}
.drop-overlay-content {
  text-align: center;
  color: hsl(var(--text-secondary));
  pointer-events: none;
}
.drop-overlay-content svg {
  width: 48px;
  height: 48px;
  color: hsl(var(--accent));
  margin-bottom: 1rem;
}
.drop-overlay-content p {
  font-size: 1.25rem;
  font-weight: 600;
  color: hsl(var(--text-primary));
  margin-bottom: 0.5rem;
}
.drop-overlay-content span {
  font-size: 0.85rem;
  color: hsl(var(--text-muted));
}

/* Attachment display inside messages */
.attachment-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 0.5rem;
  margin-top: 0.5rem;
  object-fit: contain;
  background: hsl(var(--bg-primary));
  cursor: zoom-in;
  transition: opacity 0.15s;
  display: block;
}
.attachment-image:hover {
  opacity: 0.9;
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: hsl(var(--bg-tertiary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.5rem;
  padding: 0.6rem 0.85rem;
  margin-top: 0.5rem;
}
.attachment-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 0.375rem;
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--text-muted));
  flex-shrink: 0;
}
.attachment-card-info {
  flex: 1;
  min-width: 0;
}
.attachment-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: hsl(var(--text-primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-card-meta {
  font-size: 0.7rem;
  color: hsl(var(--text-muted));
}
.attachment-card-download {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: hsl(var(--accent) / 0.15);
  border: 1px solid hsl(var(--accent) / 0.3);
  color: hsl(var(--accent-light));
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.attachment-card-download:hover {
  background: hsl(var(--accent) / 0.25);
  border-color: hsl(var(--accent) / 0.5);
  color: hsl(var(--accent-light));
}

/* ── About Modal ───────────────────────────────────────────────────────── */
.about-trigger {
  cursor: pointer;
  color: hsl(var(--text-muted) / 0.65);
  transition: color 0.15s;
}
.about-trigger:hover {
  color: hsl(var(--accent-light));
}

.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}

.about-modal {
  background: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.75rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

.about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border-color));
}

.about-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--text-primary));
}

.about-close-btn {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
}

.about-close-btn:hover {
  color: hsl(var(--text-primary));
  background: hsl(var(--bg-tertiary));
}

.about-body {
  padding: 1.25rem;
}

.about-tagline {
  font-size: 0.9rem;
  color: hsl(var(--text-secondary));
  line-height: 1.5;
  margin: 0 0 1.25rem;
}

.about-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.about-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem;
  border-radius: 0.5rem;
  background: hsl(var(--bg-tertiary));
  border: 1px solid hsl(var(--border-color) / 0.5);
  transition: border-color 0.15s;
}

.about-feature:hover {
  border-color: hsl(var(--accent) / 0.3);
}

.about-feature-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.about-feature-info {
  min-width: 0;
}

.about-feature-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: hsl(var(--text-primary));
  margin-bottom: 0.1rem;
}

.about-feature-desc {
  font-size: 0.68rem;
  color: hsl(var(--text-muted));
  line-height: 1.3;
}

.about-feature-desc kbd {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: hsl(var(--bg-primary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0.2rem;
  padding: 0.05rem 0.3rem;
  color: hsl(var(--text-secondary));
}

.about-footer {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border-color));
}

.about-philosophy {
  font-size: 0.85rem;
  color: hsl(var(--text-secondary));
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.about-philosophy strong {
  color: hsl(var(--accent-light));
}

.about-github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: hsl(var(--accent-light));
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 0.375rem;
  background: hsl(var(--accent) / 0.1);
  border: 1px solid hsl(var(--accent) / 0.2);
  transition: all 0.15s;
}
.about-github-link:hover {
  background: hsl(var(--accent) / 0.2);
  border-color: hsl(var(--accent) / 0.4);
}

@media (max-width: 500px) {
  .about-features {
    grid-template-columns: 1fr;
  }
}

/* ── TTS ───────────────────────────────────────────────────────────────── */
.msg-tts-btn {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-tts-btn:hover {
  color: hsl(var(--accent-light));
  background-color: hsl(var(--accent-light) / 0.1);
}
.msg-tts-btn.speaking {
  color: hsl(var(--accent));
  animation: ttsPulse 0.8s ease-in-out infinite;
}
@keyframes ttsPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Local Engine UI ─────────────────────────────────────────────────── */
#engine-badge.local-loading {
  animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#model-progress-bar {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 0.25rem;
  background: hsl(var(--bg-tertiary));
  overflow: hidden;
}

#model-progress-bar::-webkit-progress-value {
  background: hsl(var(--accent));
  border-radius: 0.25rem;
  transition: width 0.3s ease;
}

#model-progress-bar::-webkit-progress-bar {
  background: hsl(var(--bg-tertiary));
  border-radius: 0.25rem;
}

#model-progress-bar::-moz-progress-bar {
  background: hsl(var(--accent));
  border-radius: 0.25rem;
}

@media (max-width: 480px) {
  .btn-mic, .btn-attach { width: 28px; height: 28px; }
  .btn-send { width: 28px; height: 28px; }
  .btn-stop { padding: 0.25rem 0.45rem; font-size: 0.65rem; }
}