﻿/* ── Reset & Variables ────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold:        #BD9B08;
  --gold-dark:   #9f8306;
  --gold-light:  #f5e9a0;
  --black:       #0f0f0f;
  --white:       #ffffff;
  --gray-50:     #f9f9f9;
  --gray-100:    #f0f0f0;
  --gray-200:    #e4e4e7;
  --gray-300:    #d1d1d6;
  --gray-500:    #8e8ea0;
  --gray-700:    #444450;
  --sidebar-w:   260px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
  --transition:  .18s ease;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--white);
  color: var(--black);
  overflow: hidden;
}

em { font-style: italic; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
body { display: flex; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  transition: transform var(--transition);
  z-index: 200;
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.sidebar-logo {
  flex: 1;
  text-align: center;
  font-size: 26px;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: -.3px;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color var(--transition);
}
.menu-toggle:hover { color: var(--white); }

/* New chat button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gold);
  color: var(--black);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: background var(--transition);
  margin-bottom: 24px;
}
.new-chat-btn:hover { background: var(--gold-dark); }

/* Search box */
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--gold); }

.search-icon { flex-shrink: 0; color: var(--gray-500); }

#searchInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--white);
  min-width: 0;
}
#searchInput::placeholder { color: var(--gray-500); }

.search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 13px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.search-clear:hover { color: var(--white); }

/* Search results */
.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background var(--transition);
}
.search-result-item:hover { background: #1e1e1e; }
.search-result-item.active { background: #252525; }

.search-result-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-preview {
  font-size: 11.5px;
  color: var(--gray-500);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-empty {
  padding: 12px 10px;
  font-size: 13px;
  color: var(--gray-500);
  text-align: center;
}

mark {
  background: rgba(189,155,8,.35);
  color: var(--gold-light);
  border-radius: 2px;
  padding: 0 1px;
}

/* Flash highlight when jumping to a message */
@keyframes msgFlash {
  0%   { background: rgba(189,155,8,.22); }
  100% { background: transparent; }
}
.msg-highlight { animation: msgFlash 1.8s ease-out forwards; border-radius: var(--radius-sm); }

/* History */
.history-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 0 4px;
  margin-bottom: 8px;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-history::-webkit-scrollbar { width: 4px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.history-item {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  width: 100%;
}
.history-item:hover { background: #1e1e1e; }
.history-item.active { background: #252525; }
.history-item:hover .history-item-delete,
.history-item.active .history-item-delete { opacity: 1; }

.history-item-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 8px 6px 8px 10px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  color: #c5c5c5;
  text-align: left;
  transition: color var(--transition);
}
.history-item:hover .history-item-btn,
.history-item.active .history-item-btn { color: var(--white); }

.history-item-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: .7;
}

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


.sidebar-footer {
  padding: 12px 4px 4px;
  border-top: 1px solid #1e1e1e;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer-text {
  font-size: 11px;
  color: var(--gray-500);
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  padding: 3px 5px;
  border-radius: 4px;
  letter-spacing: .06em;
  transition: color var(--transition), background var(--transition);
}
.lang-btn:hover { color: var(--white); }
.lang-btn.lang-active { color: var(--gold); }
.lang-sep {
  font-size: 10px;
  color: #333;
  user-select: none;
}

/* ── Main wrapper ─────────────────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Mobile header (hidden on desktop) */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--white);
}
.mobile-logo {
  font-size: 18px;
  color: var(--black);
}
.menu-toggle-mobile {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-700);
  padding: 2px 4px;
  line-height: 1;
}

/* ── Main / Chat area ─────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Welcome screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 24px;
  text-align: center;
  animation: fadeIn .35s ease;
}

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

.welcome-logo {
  font-size: 36px;
  font-weight: 300;
  color: var(--black);
  margin-bottom: 12px;
  letter-spacing: -.5px;
}
.welcome-logo em { color: var(--gold); }

.welcome-subtitle {
  font-size: 15px;
  color: var(--gray-500);
  margin-bottom: 36px;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 640px;
  width: 100%;
}

.example-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  font-family: inherit;
}
.example-card:hover {
  border-color: var(--gold);
  background: var(--white);
  box-shadow: 0 2px 12px rgba(189,155,8,.12);
}

.example-icon { font-size: 20px; margin-bottom: 2px; }
.example-title { font-size: 13.5px; font-weight: 600; color: var(--black); }
.example-desc { font-size: 12px; color: var(--gray-500); line-height: 1.4; }

/* Chat area */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 8px;
}
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Message bubbles ──────────────────────────────────────────────────────── */
.message {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  animation: fadeIn .25s ease;
}

.message.user { flex-direction: row-reverse; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.message.assistant .message-avatar {
  background: var(--gold);
  color: var(--black);
  font-style: italic;
}

.message.user .message-avatar {
  background: var(--gray-200);
  color: var(--gray-700);
  font-size: 12px;
}

.message-body { flex: 1; min-width: 0; }

.message-role {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.message.user .message-role { text-align: right; }

.message-content {
  font-size: 15px;
  line-height: 1.65;
  color: var(--black);
}
.message.user .message-content {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: inline-block;
  max-width: 100%;
  text-align: left;
}

/* Markdown content in assistant messages */
.message.assistant .message-content p { margin-bottom: .75em; }
.message.assistant .message-content p:last-child { margin-bottom: 0; }
.message.assistant .message-content ul,
.message.assistant .message-content ol { padding-left: 1.4em; margin-bottom: .75em; }
.message.assistant .message-content li { margin-bottom: .25em; }
.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3 { margin: 1em 0 .5em; font-weight: 600; }
.message.assistant .message-content h1 { font-size: 1.25em; }
.message.assistant .message-content h2 { font-size: 1.1em; }
.message.assistant .message-content h3 { font-size: 1em; }
.message.assistant .message-content code {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .88em;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.message.assistant .message-content pre {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: .75em;
}
.message.assistant .message-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: .85em;
}
.message.assistant .message-content blockquote {
  border-left: 3px solid var(--gold);
  padding-left: 12px;
  color: var(--gray-700);
  margin-bottom: .75em;
}
.message.assistant .message-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: .75em;
  font-size: .9em;
}
.message.assistant .message-content th,
.message.assistant .message-content td {
  border: 1px solid var(--gray-200);
  padding: 6px 12px;
  text-align: left;
}
.message.assistant .message-content th {
  background: var(--gray-100);
  font-weight: 600;
}
.message.assistant .message-content a {
  color: var(--gold-dark);
  text-decoration: underline;
}

/* Feedback row */
.message-feedback {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.feedback-btn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-500);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  line-height: 1;
}
.feedback-btn:hover { border-color: var(--gold); color: var(--gold); }
.feedback-btn.active-up   { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
.feedback-btn.active-down { border-color: #dc2626; color: #dc2626; background: #fef2f2; }

/* ── Drag & Drop overlay ──────────────────────────────────────────────────── */
.drag-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(189,155,8,.12);
  border: 3px dashed var(--gold);
  pointer-events: none;
  align-items: center;
  justify-content: center;
}
.drag-overlay.active { display: flex; }
.drag-overlay-inner { text-align: center; }
.drag-overlay-icon { font-size: 52px; margin-bottom: 12px; }
.drag-overlay-text { font-size: 22px; font-weight: 600; color: var(--gold); }
.drag-overlay-sub  { font-size: 13px; color: var(--gray-500); margin-top: 6px; }

/* ── Multi-file preview cards ─────────────────────────────────────────────── */
.file-preview-area {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto 8px;
  padding: 0 4px;
}
.file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 140px;
  max-width: 210px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.file-card.fc-error { border-color: #dc2626; }
.fc-icon { font-size: 22px; flex-shrink: 0; }
.fc-thumb {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 5px; object-fit: cover;
  border: 1px solid var(--gray-200); background: var(--gray-50);
}
.fc-info { flex: 1; min-width: 0; }
.fc-name { font-size: 12px; font-weight: 500; color: var(--black); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-sub  { font-size: 11px; color: var(--gray-500); margin-top: 1px; }
.file-card.fc-error .fc-sub { color: #dc2626; }
.fc-remove {
  background: none; border: none; cursor: pointer; color: var(--gray-500);
  font-size: 14px; padding: 2px 3px; line-height: 1; flex-shrink: 0;
  transition: color var(--transition);
}
.fc-remove:hover { color: #dc2626; }
.fc-prog {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--gray-200); border-radius: 0 0 8px 8px; overflow: hidden;
}
.fc-prog-bar {
  height: 100%; background: var(--gold);
  transition: width .3s ease; border-radius: 0 0 8px 8px;
}

/* Dark mode file cards */
[data-theme="dark"] .file-card   { background: #252525; border-color: #383838; }
[data-theme="dark"] .fc-name     { color: #e0e0e0; }
[data-theme="dark"] .fc-thumb    { background: #252525; border-color: #383838; }
[data-theme="dark"] .drag-overlay { background: rgba(189,155,8,.1); }

/* File attachment in message */
.message-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--gray-700);
  margin-bottom: 6px;
}

/* Bilder einer Nachricht (hochgeladen, aus der Blob-Referenz wiederhergestellt) */
.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.message-image {
  max-width: 260px;
  max-height: 260px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  cursor: zoom-in;
  object-fit: cover;
}

[data-theme="dark"] .message-image { border-color: #383838; }

/* Loading dots */
.loading-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 2px;
  background: var(--gold);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1;   }
}

/* ── Input area ───────────────────────────────────────────────────────────── */
.input-wrapper {
  padding: 12px 24px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
  flex-shrink: 0;
}

/* File preview badge */
.file-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--gray-700);
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
.file-preview-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  transition: color var(--transition);
}
.file-remove-btn:hover { color: #dc2626; }

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px 10px;
  max-width: 800px;
  margin: 0 auto;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(189,155,8,.1);
}

.attach-btn {
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
  flex-shrink: 0;
  margin-bottom: 2px;
}
.attach-btn:hover { color: var(--gold); }

.mic-btn {
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
  flex-shrink: 0;
  margin-bottom: 2px;
}
.mic-btn:hover { color: var(--gold); }
.mic-btn[hidden] { display: none; }
.mic-btn.recording {
  color: #dc2626;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .4; }
}

#messageInput {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  color: var(--black);
  max-height: 200px;
  overflow-y: auto;
}
#messageInput::placeholder { color: var(--gray-500); }

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: var(--gold);
  color: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), opacity var(--transition);
  margin-bottom: 2px;
}
.send-btn:hover:not(:disabled) { background: var(--gold-dark); }
.send-btn:disabled { background: var(--gray-200); color: var(--gray-500); cursor: not-allowed; opacity: .7; }

.disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--gray-500);
  margin-top: 10px;
}
.disclaimer-link {
  color: var(--gray-500);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.disclaimer-link:hover {
  color: var(--gray-700);
  border-bottom-color: var(--gray-400);
}
.legal-modal {
  max-width: 640px;
  width: 100%;
}
.legal-modal-body {
  max-height: 65vh;
  overflow-y: auto;
  padding: 20px 24px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--gray-700);
}
.legal-modal-body h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  margin: 18px 0 6px;
}
.legal-modal-body h3:first-of-type { margin-top: 4px; }
.legal-modal-body p, .legal-modal-body ul { margin: 0 0 8px; }
.legal-modal-body ul { padding-left: 20px; }
.legal-modal-body li { margin-bottom: 4px; }
.legal-modal-body a { color: var(--gold-dark, #b59a3c); text-decoration: none; }
.legal-modal-body a:hover { text-decoration: underline; }
.legal-meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 12px;
}
.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 13px;
}
.legal-table th, .legal-table td {
  text-align: left;
  padding: 7px 10px;
  border: 1px solid var(--gray-200);
}
.legal-table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--black);
}
.sidebar-legal-link {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 11px;
  transition: color var(--transition);
}
.sidebar-legal-link:hover { color: var(--white); }
[data-theme="dark"] .disclaimer-link { color: #555; }
[data-theme="dark"] .disclaimer-link:hover { color: #888; border-bottom-color: #666; }
[data-theme="dark"] .legal-modal-body { color: #ccc; }
[data-theme="dark"] .legal-modal-body h3 { color: #eee; }
[data-theme="dark"] .legal-table th { background: #2a2a2a; color: #eee; }
[data-theme="dark"] .legal-table th, [data-theme="dark"] .legal-table td { border-color: #333; }

/* ── Mode toggle bar ──────────────────────────────────────────────────────── */
.mode-toggle-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: transparent;
  color: var(--gray-500);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.mode-btn:hover { border-color: var(--gray-300); color: var(--gray-700); }
.mode-btn-normal.active  { border-color: var(--gray-300); color: var(--gray-700); background: var(--gray-100); }
.mode-btn-internal.active {
  border-color: #d97706;
  color: #92400e;
  background: #fef3c7;
}
.mode-btn-internal.active svg { stroke: #d97706; }

/* ── Internal mode banner ─────────────────────────────────────────────────── */
.internal-mode-banner {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 24px 8px;
  padding: 8px 14px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #92400e;
}
.internal-mode-banner-icon { font-size: 16px; }

/* ── Bezug auf das zuletzt erzeugte Bild (Bildmodus) ──────────────────────── */
.image-ref-chip {
  display: none;            /* per JS auf flex gesetzt */
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 8px;
  padding: 5px 6px 5px 12px;
  background: #fdf6e3;
  border: 1px solid #f0dfa8;
  border-radius: 20px;
  font-size: 12.5px;
  color: #7a5c00;
}
.image-ref-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.image-ref-chip-x:hover { background: rgba(0, 0, 0, .08); }

[data-theme="dark"] .image-ref-chip {
  background: #2a2410;
  border-color: #4a3f18;
  color: #e0cd8a;
}
[data-theme="dark"] .image-ref-chip-x:hover { background: rgba(255, 255, 255, .12); }

/* ── RAG source citations ──────────────────────────────────────────────────── */
.rag-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 24px 12px;
  max-width: 780px;
  margin: -4px auto 0;
}
.rag-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.rag-source-chip:hover {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0369a1;
}

/* ── AI-generated document downloads ──────────────────────────────────────── */
.doc-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 12px;
  max-width: 780px;
  margin: -4px auto 0;
}
.doc-download-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.doc-download-chip:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}
.doc-download-chip:active { transform: translateY(1px); }
[data-theme="dark"] .doc-download-chip { background: #2a1416; border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .doc-download-chip:hover { background: #3a1a1d; border-color: #b91c1c; }

/* ── Sidebar overlay (mobile) ─────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 150;
}
.sidebar-overlay.visible { display: block; }

/* ── Projects ─────────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px 4px;
}
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.section-add-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: 3px 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.section-add-btn:hover { color: var(--white); }

.section-divider {
  height: 1px;
  background: #1e1e1e;
  margin: 10px 0 2px;
}

.section-empty-hint {
  padding: 4px 10px;
  font-size: 12px;
  color: #444;
  cursor: pointer;
}
.section-empty-hint.no-click { cursor: default; }
.section-empty-hint.indented { padding-left: 22px; }

/* Project row */
.project-header {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.project-header:hover { background: #1a1a1a; }
.project-header:hover .project-actions { opacity: 1; }

.project-click-area {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  padding: 6px 4px 6px 6px;
  cursor: pointer;
}
.project-toggle { color: var(--gray-500); display: flex; align-items: center; flex-shrink: 0; }
.project-color-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.project-icon { font-size: 13px; flex-shrink: 0; }
.project-name {
  font-size: 13px;
  font-weight: 500;
  color: #c5c5c5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}
.project-header:hover .project-name { color: var(--white); }

.project-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
  padding-right: 4px;
  flex-shrink: 0;
}
.project-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  font-size: 12px;
  line-height: 1;
  transition: color var(--transition);
}
.project-action-btn:hover { color: var(--white); }
.project-del-btn:hover    { color: #dc2626; }

.project-new-chat {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 5px 10px 5px 22px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  color: var(--gray-500);
  text-align: left;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.project-new-chat:hover { color: var(--gold); background: #1a1a1a; }

/* Chat items inside a project (indented) */
.history-item.indented .history-item-btn { padding-left: 20px; }

/* History item action buttons */
.history-item-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.history-item:hover .history-item-actions,
.history-item.active .history-item-actions { opacity: 1; }

.history-item-move,
.history-item-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 13px;
  line-height: 1;
  padding: 4px 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.history-item-move:hover   { color: var(--gold); }
.history-item-delete:hover { color: #dc2626; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.visible { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 380px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  animation: fadeIn .2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--black); }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--black); }

.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.modal-input {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--black);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.modal-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(189,155,8,.1); }

.icon-picker, .color-picker { display: flex; gap: 6px; flex-wrap: wrap; }

.icon-option {
  background: var(--gray-100);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 7px;
  line-height: 1;
  transition: border-color var(--transition), background var(--transition);
}
.icon-option:hover    { background: var(--gray-200); }
.icon-option.selected { border-color: var(--gold); background: var(--white); }

.color-option {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform var(--transition);
  outline-offset: 2px;
}
.color-option:hover    { transform: scale(1.12); }
.color-option.selected { outline: 3px solid var(--black); }

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--gray-200);
}
.modal-btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition);
}
.modal-btn-cancel { background: var(--gray-100); color: var(--gray-700); }
.modal-btn-cancel:hover { background: var(--gray-200); }
.modal-btn-save   { background: var(--gold); color: var(--black); }
.modal-btn-save:hover { background: var(--gold-dark); }

/* ── Context dropdown ─────────────────────────────────────────────────────── */
.ctx-dropdown {
  display: none;
  position: fixed;
  z-index: 900;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  min-width: 190px;
  padding: 4px;
  animation: fadeIn .1s ease;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--black);
  text-align: left;
  transition: background var(--transition);
}
.ctx-item:hover { background: var(--gray-100); }
.ctx-icon { width: 18px; display: inline-block; flex-shrink: 0; }
.ctx-item-danger { color: #dc2626; }
.ctx-item-danger:hover { background: #fef2f2; color: #b91c1c; }
.ctx-back { font-size: 12px; color: var(--gray-700); }
.ctx-sep { height: 1px; background: var(--gray-200); margin: 3px 0; }
.ctx-empty { padding: 8px 10px; font-size: 12px; color: var(--gray-500); }

/* Delete confirmation inside dropdown */
.ctx-confirm-msg { padding: 10px 12px 6px; font-size: 13px; color: var(--black); line-height: 1.4; }
.ctx-confirm-actions { display: flex; gap: 6px; padding: 4px 10px 10px; }
.ctx-confirm-btn {
  flex: 1; padding: 7px 6px; border-radius: 6px; border: none;
  cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 500;
}
.ctx-confirm-cancel { background: var(--gray-100); color: var(--gray-700); }
.ctx-confirm-cancel:hover { background: var(--gray-200); }
.ctx-confirm-delete { background: #dc2626; color: #fff; }
.ctx-confirm-delete:hover { background: #b91c1c; }

/* ⋯ menu button on chat items */
.history-item-menu {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); padding: 4px 5px; border-radius: 4px;
  display: flex; align-items: center; flex-shrink: 0;
  opacity: 0; transition: opacity var(--transition), color var(--transition), background var(--transition);
}
.history-item:hover .history-item-menu,
.history-item.active .history-item-menu { opacity: 1; }
.history-item-menu:hover { color: var(--white); background: #333; }

/* Inline rename */
.rename-active { pointer-events: none; cursor: default !important; }
.rename-input {
  flex: 1; background: none; border: none;
  border-bottom: 1.5px solid var(--gold); outline: none;
  font-family: inherit; font-size: 13.5px; color: var(--white);
  padding: 0 2px; min-width: 0; pointer-events: all;
}

/* Archive items */
.archive-acts { opacity: 1 !important; }

/* Message action row (feedback + copy) */
.msg-action-row {
  display: flex; gap: 4px; margin-top: 8px;
  opacity: 0; transition: opacity var(--transition);
}
.message.assistant:hover .msg-action-row { opacity: 1; }
@media (max-width: 768px) { .msg-action-row { opacity: 1; } }

/* Copy message button */
.msg-copy-btn {
  background: none; border: 1px solid var(--gray-200); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; color: var(--gray-500);
  display: flex; align-items: center; line-height: 1;
  transition: border-color var(--transition), color var(--transition);
}
.msg-copy-btn:hover { border-color: var(--gold); color: var(--gold-dark); }
.msg-copy-btn.copied { border-color: #16a34a; color: #16a34a; }

/* Code block copy button */
.code-copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: var(--gray-200); border: none; border-radius: 4px;
  padding: 3px 8px; font-size: 11px; font-family: inherit;
  cursor: pointer; color: var(--gray-700);
  opacity: 0; transition: opacity var(--transition), background var(--transition);
}
pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: var(--gray-300); }
.code-copy-btn.copied { background: #dcfce7; color: #16a34a; opacity: 1; }

/* ── Project member management ─────────────────────────────────────────────── */
.members-modal { max-width: 480px; }
.members-list { display: flex; flex-direction: column; gap: 2px; }
.member-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--gray-100); flex-wrap: wrap;
}
.member-row:last-child { border-bottom: none; }
.member-name  { font-size: 13px; font-weight: 500; color: var(--black); flex: 1; min-width: 100px; }
.member-email { font-size: 11px; color: var(--gray-500); flex-basis: 100%; order: 3; margin-top: -4px; }
.member-role-badge { font-size: 11px; color: var(--gray-500); white-space: nowrap; }
.member-role-sel {
  font-family: inherit; font-size: 12px; border: 1px solid var(--gray-200);
  border-radius: 4px; padding: 3px 6px; background: var(--white); color: var(--black);
}
.member-del-btn {
  background: none; border: 1px solid var(--gray-300); border-radius: 4px;
  padding: 3px 8px; font-size: 11px; cursor: pointer; color: var(--gray-700);
  white-space: nowrap; transition: background var(--transition);
}
.member-del-btn:hover { background: #fef2f2; color: #dc2626; border-color: #dc2626; }

/* Role badge on shared projects in sidebar */
.proj-role-badge { font-size: 12px; flex-shrink: 0; opacity: .8; }

/* Dark mode member modal */
[data-theme="dark"] .member-name { color: #e0e0e0; }
[data-theme="dark"] .member-row { border-color: #333; }
[data-theme="dark"] .member-role-sel { background: #2a2a2a; border-color: #444; color: #e0e0e0; }

/* ── Sharing ───────────────────────────────────────────────────────────────── */
.share-indicator { font-size: 11px; margin-left: 4px; opacity: .7; }

.share-modal { max-width: 460px; }
.share-perm-group { display: flex; gap: 8px; }
.share-perm-btn {
  flex: 1; padding: 8px 10px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  background: none; font-family: inherit; font-size: 13px; cursor: pointer; color: var(--gray-700);
  transition: border-color var(--transition), background var(--transition);
}
.share-perm-btn:hover { border-color: var(--gold); }
.share-perm-btn.active { border-color: var(--gold); background: rgba(189,155,8,.08); color: var(--black); }

.share-link-row { display: flex; gap: 8px; }
.share-link-row .modal-input { flex: 1; font-size: 12px; color: var(--gray-500); }
.share-copy-btn {
  background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 8px 14px; font-family: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
  transition: background var(--transition);
}
.share-copy-btn:hover { background: var(--gray-200); }

.share-user-results {
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm); margin-top: 4px;
  max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 0;
}
.share-user-results:empty { display: none; }
.share-user-result {
  display: flex; flex-direction: column; padding: 8px 10px;
  background: none; border: none; cursor: pointer; text-align: left;
  transition: background var(--transition);
}
.share-user-result:hover { background: var(--gray-50); }
.sur-name  { font-size: 13px; font-weight: 500; color: var(--black); }
.sur-email { font-size: 11px; color: var(--gray-500); }
.sur-empty { padding: 10px; font-size: 12px; color: var(--gray-500); text-align: center; }

.share-selected-users { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.share-user-chip {
  display: flex; align-items: center; gap: 4px;
  background: rgba(189,155,8,.12); border: 1px solid var(--gold); border-radius: 20px;
  padding: 3px 8px 3px 10px; font-size: 12px; color: var(--black);
}
.chip-del {
  background: none; border: none; cursor: pointer; font-size: 10px;
  color: var(--gray-500); padding: 0 2px; line-height: 1;
}
.chip-del:hover { color: #dc2626; }

.share-deactivate-wrap { flex: 1; }
.share-deactivate-btn {
  background: none; border: 1px solid #dc2626; color: #dc2626;
  border-radius: var(--radius-sm); padding: 8px 12px; font-family: inherit;
  font-size: 12px; cursor: pointer; transition: background var(--transition);
}
.share-deactivate-btn:hover { background: #fef2f2; }

/* ── Notifications ─────────────────────────────────────────────────────────── */
.notif-bell {
  position: relative; background: none; border: none; cursor: pointer;
  font-size: 16px; padding: 4px; line-height: 1; margin-left: auto;
  display: flex; align-items: center;
}
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: #dc2626; color: #fff; border-radius: 50%;
  font-size: 9px; font-weight: 700; min-width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
}
.notif-panel {
  flex-direction: column; background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); max-height: 300px; overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); margin-bottom: 10px;
}
.notif-panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 8px; border-bottom: 1px solid var(--gray-200);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--gray-500);
}
.notif-read-all {
  background: none; border: none; cursor: pointer; font-size: 11px;
  color: var(--gold-dark); font-family: inherit; padding: 0;
}
.notif-list { overflow-y: auto; flex: 1; }
.notif-empty { padding: 16px; font-size: 13px; color: var(--gray-500); text-align: center; }
.notif-item {
  display: flex; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100); transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: rgba(189,155,8,.06); }
.notif-icon { font-size: 16px; flex-shrink: 0; }
.notif-text { font-size: 12px; color: var(--black); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* Dark mode for share/notif */
[data-theme="dark"] .share-perm-btn { border-color: #444; color: #ccc; }
[data-theme="dark"] .share-perm-btn.active { color: #e0e0e0; }
[data-theme="dark"] .share-copy-btn { background: #2a2a2a; border-color: #444; color: #ccc; }
[data-theme="dark"] .share-user-results { border-color: #444; }
[data-theme="dark"] .share-user-result:hover { background: #2a2a2a; }
[data-theme="dark"] .sur-name { color: #e0e0e0; }
[data-theme="dark"] .notif-panel { background: #1e1e1e; border-color: #333; }
[data-theme="dark"] .notif-panel-hdr { border-color: #333; }
[data-theme="dark"] .notif-item { border-color: #2a2a2a; }
[data-theme="dark"] .notif-item:hover { background: #252525; }
[data-theme="dark"] .notif-item.unread { background: rgba(189,155,8,.1); }
[data-theme="dark"] .notif-text { color: #e0e0e0; }

/* Toast */
.toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--black); color: var(--white);
  padding: 8px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 500; opacity: 0;
  pointer-events: none; z-index: 2000; white-space: nowrap;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Search result project badge */
.search-result-project { font-size: 11px; margin-top: 2px; opacity: .85; }

/* ── Font size variable ───────────────────────────────────────────────────── */
:root { --chat-font-size: 15px; }
.message-content { font-size: var(--chat-font-size); }

/* ── Dark mode overrides ──────────────────────────────────────────────────── */
[data-theme="dark"] body { background: #1a1a1a; color: #e0e0e0; }
[data-theme="dark"] .main-wrapper,
[data-theme="dark"] .main,
[data-theme="dark"] .chat-area,
[data-theme="dark"] .welcome-screen { background: #1a1a1a; }
[data-theme="dark"] .welcome-logo { color: #e0e0e0; }
[data-theme="dark"] .welcome-subtitle { color: #888; }
[data-theme="dark"] .example-card { background: #252525; border-color: #383838; }
[data-theme="dark"] .example-card:hover { background: #2e2e2e; border-color: var(--gold); }
[data-theme="dark"] .example-title { color: #e0e0e0; }
[data-theme="dark"] .example-desc  { color: #888; }
[data-theme="dark"] .message-content { color: #e0e0e0; }
[data-theme="dark"] .message.user .message-content { background: #2a2a2a; border-color: #444; }
[data-theme="dark"] .message.assistant .message-content pre { background: #252525; border-color: #383838; }
[data-theme="dark"] .message.assistant .message-content code { background: #252525; border-color: #383838; color: #e0e0e0; }
[data-theme="dark"] .message.assistant .message-content a { color: var(--gold); }
[data-theme="dark"] .message.assistant .message-content th { background: #252525; }
[data-theme="dark"] .message.assistant .message-content th,
[data-theme="dark"] .message.assistant .message-content td { border-color: #383838; }
[data-theme="dark"] .message-role { color: #666; }
[data-theme="dark"] .input-wrapper { background: #1a1a1a; border-top-color: #333; }
[data-theme="dark"] .input-box { background: #242424; border-color: #444; }
[data-theme="dark"] .mode-btn { border-color: #3a3a3a; color: #777; }
[data-theme="dark"] .mode-btn-normal.active { background: #2a2a2a; border-color: #555; color: #ccc; }
[data-theme="dark"] .mode-btn-internal.active { background: #2d2000; border-color: #78350f; color: #fbbf24; }
[data-theme="dark"] .internal-mode-banner { background: #2d2000; border-color: #78350f; color: #fbbf24; }
[data-theme="dark"] .rag-source-chip { background: #0c2233; border-color: #0c4a6e; color: #7dd3fc; }
[data-theme="dark"] .rag-source-chip:hover { background: #0c2d45; border-color: #0369a1; }
[data-theme="dark"] #messageInput { color: #e0e0e0; }
[data-theme="dark"] #messageInput::placeholder { color: #555; }
[data-theme="dark"] .disclaimer { color: #555; }
[data-theme="dark"] .file-preview { background: #252525; border-color: #383838; color: #bbb; }
[data-theme="dark"] .mobile-header { background: #1a1a1a; border-bottom-color: #333; }
[data-theme="dark"] .mobile-logo { color: #e0e0e0; }
[data-theme="dark"] .modal { background: #1e1e1e; }
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: #333; }
[data-theme="dark"] .modal-title { color: #e0e0e0; }
[data-theme="dark"] .modal-label { color: #888; }
[data-theme="dark"] .modal-input { background: #2a2a2a; border-color: #444; color: #e0e0e0; }
[data-theme="dark"] .modal-btn-cancel { background: #2a2a2a; color: #bbb; }
[data-theme="dark"] .modal-btn-cancel:hover { background: #333; }
[data-theme="dark"] .ctx-dropdown { background: #1e1e1e; border-color: #333; }
[data-theme="dark"] .ctx-item { color: #e0e0e0; }
[data-theme="dark"] .ctx-item:hover { background: #2a2a2a; }
[data-theme="dark"] .ctx-confirm-msg { color: #e0e0e0; }
[data-theme="dark"] .ctx-sep { background: #333; }
[data-theme="dark"] .search-result-item { color: #e0e0e0; }
[data-theme="dark"] .search-result-title { color: #e0e0e0; }
[data-theme="dark"] .search-result-preview { color: #888; }
[data-theme="dark"] .highlight.js-highlightjs { background: #252525; }
[data-theme="dark"] .persona-panel { background: #1e1e1e; border-color: #333; }
[data-theme="dark"] .persona-item { color: #e0e0e0; }
[data-theme="dark"] .persona-item:hover { background: #2a2a2a; }
[data-theme="dark"] .persona-item.active { background: #2a2a2a; }
[data-theme="dark"] .persona-item-desc { color: #888; }
[data-theme="dark"] .persona-panel-header { border-bottom-color: #333; }
[data-theme="dark"] .persona-panel-footer { border-top-color: #333; }
[data-theme="dark"] .persona-add-btn { color: #888; }
[data-theme="dark"] .persona-add-btn:hover { color: var(--gold); }
[data-theme="dark"] .chat-persona-bar { background: #1e1e1e; border-bottom-color: #333; }
[data-theme="dark"] .chat-persona-change { color: #888; }
[data-theme="dark"] mark { background: rgba(189,155,8,.3); color: var(--gold-light); }

/* ── Persona UI ───────────────────────────────────────────────────────────── */
.persona-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: #c5c5c5;
  margin-bottom: 10px;
  transition: background var(--transition), border-color var(--transition);
  text-align: left;
}
.persona-bar:hover { background: #222; border-color: var(--gold); }
.persona-bar svg { margin-left: auto; color: var(--gray-500); flex-shrink: 0; }

.persona-panel {
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  max-height: 320px;
}
.persona-panel-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--gray-200);
}
.persona-panel-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500); }

.persona-list {
  overflow-y: auto;
  flex: 1;
}
.persona-list::-webkit-scrollbar { width: 3px; }
.persona-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.persona-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition);
  position: relative;
}
.persona-item:hover { background: var(--gray-50); }
.persona-item.active { background: var(--gray-100); }
.persona-item.active::before { content: '✓'; position: absolute; right: 58px; color: var(--gold); font-size: 12px; }

.persona-item-icon { font-size: 18px; flex-shrink: 0; }
.persona-item-text { display: flex; flex-direction: column; min-width: 0; }
.persona-item-name { font-size: 13px; font-weight: 500; color: var(--black); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona-item-desc { font-size: 11px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona-item-edit {
  margin-left: auto; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); padding: 2px 4px; border-radius: 3px;
  opacity: 0; transition: opacity var(--transition), color var(--transition);
  display: flex; align-items: center;
}
.persona-item-del {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); font-size: 11px; padding: 2px 4px; border-radius: 3px;
  opacity: 0; transition: opacity var(--transition), color var(--transition);
}
.persona-item:hover .persona-item-edit { opacity: 1; }
.persona-item:hover .persona-item-del  { opacity: 1; }
.persona-item-edit:hover { color: #2563eb; }
.persona-item-del:hover  { color: #dc2626; }

.persona-panel-footer { padding: 6px 8px; border-top: 1px solid var(--gray-200); }
.persona-add-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px; color: var(--gray-500);
  padding: 4px 4px; border-radius: 4px; width: 100%;
  transition: color var(--transition);
}
.persona-add-btn:hover { color: var(--gold); }

/* Chat persona indicator bar */
.chat-persona-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 24px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-500);
  flex-shrink: 0;
}
.chat-persona-change {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); padding: 2px 4px; border-radius: 4px;
  display: flex; align-items: center;
  transition: color var(--transition);
}
.chat-persona-change:hover { color: var(--gold); }

/* Modal textarea */
.modal-textarea {
  resize: vertical;
  min-height: 90px;
  font-size: 13px;
  line-height: 1.5;
}

/* Footer controls row */
.sidebar-footer { flex-wrap: wrap; gap: 6px; }
.footer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Font size buttons */
.font-size-btns { display: flex; gap: 2px; }
.font-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  padding: 2px 4px;
  border-radius: 3px;
  transition: color var(--transition), background var(--transition);
}
.font-btn:hover { color: var(--white); }
.font-btn.active { color: var(--gold); }

/* Dark/light toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 3px;
  border-radius: 4px;
  line-height: 1;
  transition: transform var(--transition);
}
.theme-toggle:hover { transform: scale(1.15); }

/* ── Image generation ────────────────────────────────────────────────────── */
.mode-btn-image.active {
  background: #f0f7ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}
.generated-image {
  display: block;
  max-width: 100%;
  width: 480px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  margin-bottom: 10px;
  cursor: zoom-in;
}
.image-caption {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.5;
  margin-bottom: 10px;
  font-style: italic;
}
.image-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: #1d4ed8;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.image-download-btn:hover { background: #dbeafe; border-color: #93c5fd; }

[data-theme="dark"] .mode-btn-image.active { background: #1e2d45; border-color: #3b82f6; color: #93c5fd; }
[data-theme="dark"] .generated-image { border-color: #383838; }
[data-theme="dark"] .image-caption { color: #666; }
[data-theme="dark"] .image-download-btn { background: #1e2d45; border-color: #1e40af; color: #93c5fd; }
[data-theme="dark"] .image-download-btn:hover { background: #1e3a5f; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-header { display: flex; }

  .example-grid { grid-template-columns: 1fr; }

  .messages { padding: 0 16px; }
  .input-wrapper { padding: 10px 16px 16px; }

  .welcome-logo { font-size: 28px; }
}

