/* Modern Premium Style System for befchan chat */

:root {
  --bg-main: #070913;
  --bg-sidebar: #0d0f20;
  --bg-card: rgba(18, 22, 45, 0.4);
  --bg-card-hover: rgba(26, 32, 64, 0.6);
  --bg-user-bubble: #6366f1;
  --bg-assistant-bubble: rgba(22, 28, 58, 0.6);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  --accent-primary: #6366f1;
  --accent-secondary: #06b6d4;
  --accent-success: #10b981;
  
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
  
  --font-family-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-family-title: 'Outfit', sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-family-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */
.sidebar {
  width: 320px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  transition: var(--transition-smooth);
}

.sidebar-header {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  color: var(--text-inverse);
}

.logo-icon i {
  width: 20px;
  height: 20px;
}

.logo-text {
  font-family: var(--font-family-title);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 14px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-inverse);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn-new-chat {
  width: 100%;
}

.history-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--text-muted);
}

.history-item:hover, .history-item.active {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.03);
}

.history-item.active {
  background-color: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.2);
  color: var(--text-main);
}

.history-item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.history-item-title i {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.delete-chat-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.delete-chat-btn:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
}

.history-item:hover .delete-chat-btn {
  display: flex;
}

.sidebar-footer {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background-color: var(--accent-success);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

/* Main Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-main);
}

.chat-header {
  height: 70px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background-color: rgba(7, 9, 19, 0.5);
  backdrop-filter: blur(10px);
}

.toggle-sidebar-btn {
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  display: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}

.toggle-sidebar-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.model-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-badge {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.model-opt-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(6, 182, 212, 0.1);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}

.header-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome Screen */
.welcome-screen {
  max-width: 800px;
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;
}

.welcome-logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.3);
  margin-bottom: 10px;
}

.welcome-logo i {
  width: 44px;
  height: 44px;
}

.welcome-screen h1 {
  font-family: var(--font-family-title);
  font-weight: 800;
  font-size: 36px;
  letter-spacing: -1px;
}

.welcome-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 500px;
  line-height: 1.6;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  width: 100%;
  margin-top: 40px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: left;
  transition: var(--transition-smooth);
}

.feature-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.15);
  background-color: var(--bg-card-hover);
}

.feature-icon {
  font-size: 24px;
  margin-bottom: 16px;
  display: inline-block;
}

.font-gradient-1 { color: #818cf8; }
.font-gradient-2 { color: #22d3ee; }
.font-gradient-3 { color: #34d399; }

.feature-card h3 {
  font-family: var(--font-family-title);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
}

.feature-card p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Chat Messages bubbles */
.message-row {
  display: flex;
  width: 100%;
  margin-bottom: 8px;
}

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

.message-bubble {
  max-width: 80%;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  line-height: 1.6;
  font-size: 15px;
}

.message-row.user .message-bubble {
  background-color: var(--bg-user-bubble);
  color: var(--text-inverse);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
}

.message-row.assistant .message-bubble {
  background: var(--bg-assistant-bubble);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

/* Markdown styling inside assistant bubble */
.message-bubble p {
  margin-bottom: 12px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble code {
  font-family: monospace;
  background-color: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.message-bubble pre {
  margin: 12px 0;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.message-bubble pre code {
  padding: 16px;
  display: block;
  background-color: #1e1e1e !important;
}

/* Stream Cursor */
.cursor-blink {
  display: inline-block;
  width: 8px;
  height: 15px;
  background-color: var(--accent-secondary);
  animation: blink 0.8s infinite;
  vertical-align: middle;
  margin-left: 4px;
}

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

/* Input Panel */
.input-container {
  padding: 24px;
  background-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-form {
  width: 100%;
  max-width: 800px;
}

.input-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: flex-end;
  padding: 10px 14px;
  transition: var(--transition-smooth);
  backdrop-filter: blur(10px);
}

.input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
  background-color: rgba(26, 32, 64, 0.4);
}

.input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-family-sans);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  padding: 8px 10px;
}

.send-btn {
  background: var(--gradient-primary);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  cursor: pointer;
  transition: var(--transition-smooth);
  margin-bottom: 2px;
}

.send-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.2);
  cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
  opacity: 0.9;
  transform: scale(1.05);
}

.input-footer {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(5px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  animation: modal-enter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-enter {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-header h2 {
  font-family: var(--font-family-title);
  font-size: 18px;
  font-weight: 700;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

.close-modal-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.setting-group textarea, .setting-group input[type="text"] {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-main);
  font-family: var(--font-family-sans);
  font-size: 14px;
  outline: none;
}

.setting-group textarea:focus, .setting-group input[type="text"]:focus {
  border-color: var(--border-focus);
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.setting-group input[type="range"] {
  width: 100%;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: -320px;
    top: 0;
    bottom: 0;
  }
  
  .sidebar.active {
    left: 0;
  }
  
  .toggle-sidebar-btn {
    display: block;
  }
}

/* Thought/Reasoning block for reasoning models (e.g. Qwen 3.5) */
.thought-container {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.thought-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-family: var(--font-family-title);
  color: #818cf8;
  margin-bottom: 6px;
}

.thought-body {
  white-space: pre-wrap;
  line-height: 1.5;
  font-family: var(--font-family-sans);
}

/* ─── Main Area (replaces .chat-area) ─── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-main);
  overflow: hidden;
}

/* ─── Panels ─── */
.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}
.panel.hidden { display: none; }

.panel-header {
  height: 70px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  background-color: rgba(7, 9, 19, 0.5);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}
.panel-header h2 {
  font-family: var(--font-family-title);
  font-size: 18px;
  font-weight: 700;
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ─── Sidebar Nav Tabs ─── */
.sidebar-nav {
  display: flex;
  padding: 8px 12px;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.nav-tab i { width: 16px; height: 16px; }
.nav-tab:hover { color: var(--text-main); background: rgba(255,255,255,0.04); }
.nav-tab.active { color: var(--accent-primary); background: rgba(99,102,241,0.12); }

/* ─── RAG Toggle in header ─── */
.header-rag-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.rag-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.rag-toggle-label input { display: none; }
.toggle-track {
  width: 34px; height: 18px;
  background: rgba(255,255,255,0.1);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}
.rag-toggle-label input:checked ~ .toggle-track { background: rgba(99,102,241,0.5); }
.rag-toggle-label input:checked ~ .toggle-track::after { transform: translateX(16px); background: var(--accent-primary); }
.toggle-text { color: inherit; }
.rag-toggle-label input:checked ~ .toggle-track ~ .toggle-text { color: var(--accent-primary); }

.rag-ns-select {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
  max-width: 130px;
}

/* ─── Inline system prompt bar ─── */
.sys-prompt-bar {
  border-bottom: 1px solid var(--border-color);
  background: rgba(13,15,32,0.8);
  padding: 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.sys-prompt-bar.hidden { display: none; }
.sys-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sys-prompt-bar textarea {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-family-sans);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  resize: vertical;
  line-height: 1.5;
}
.sys-prompt-bar textarea:focus { border-color: var(--border-focus); }
.sys-prompt-footer { display: flex; justify-content: flex-end; }

/* ─── Buttons ─── */
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-danger { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: var(--transition-smooth);
}
.icon-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.06); }
.icon-btn.danger:hover { color: #f87171; background: rgba(239,68,68,0.1); }

/* ─── Common input ─── */
.text-input {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-family-sans);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.2s;
}
.text-input:focus { border-color: var(--border-focus); }
.select-sm { padding: 5px 8px; font-size: 12px; }

/* ─── RAG Panel ─── */
.rag-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}
.section-title i { width: 16px; height: 16px; opacity: 0.7; }

.rag-ns-create { display: flex; gap: 8px; }
.rag-ns-create .text-input { flex: 1; }

.upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload-row .text-input { max-width: 160px; }

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.file-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.08); }
.file-btn input { display: none; }
.file-btn i { width: 16px; height: 16px; }

#upload-status { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.upload-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; }
.upload-item.ok { color: var(--accent-success); background: rgba(16,185,129,0.08); }
.upload-item.err { color: #f87171; background: rgba(239,68,68,0.08); }
.upload-item.pending { color: var(--text-muted); }

.doc-list { display: flex; flex-direction: column; gap: 4px; }

.search-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; }

.search-results { display: flex; flex-direction: column; gap: 10px; }
.search-result {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.result-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.result-score { font-size: 12px; color: var(--accent-secondary); }
.result-src { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.result-text { font-size: 13px; color: var(--text-muted); line-height: 1.5; max-height: 100px; overflow-y: auto; }

/* ─── Common item rows ─── */
.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.15);
  font-size: 13px;
  margin-bottom: 4px;
}
.item-row i { opacity: 0.6; flex-shrink: 0; }
.item-row > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .icon-btn { margin-left: auto; }
.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(99,102,241,0.15);
  color: #818cf8;
  border: 1px solid rgba(99,102,241,0.2);
  white-space: nowrap;
}
.ns-badge { background: rgba(6,182,212,0.12); color: #22d3ee; border-color: rgba(6,182,212,0.2); }
.empty-msg { font-size: 13px; color: var(--text-muted); padding: 8px 0; }
.history-empty { font-size: 13px; color: var(--text-muted); padding: 12px 20px; }

/* ─── Settings Panel ─── */
.settings-body { gap: 24px; }
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-family-title);
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}
.settings-section-title i { width: 16px; height: 16px; }

.token-form, .mcp-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.token-form .text-input, .mcp-form .text-input { flex: 1; min-width: 130px; }

.new-token-display { margin-top: 4px; }
.new-token-display.hidden { display: none; }
.token-reveal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.token-reveal span { font-size: 12px; color: var(--text-muted); }
.token-reveal code {
  font-family: monospace;
  font-size: 13px;
  color: var(--accent-success);
  background: rgba(0,0,0,0.2);
  padding: 2px 8px;
  border-radius: 4px;
  word-break: break-all;
}
.item-list { display: flex; flex-direction: column; gap: 0; }

/* ─── ns-list uses item-row ─── */
.ns-list { display: flex; flex-direction: column; gap: 4px; }

/* ─── Status dot states ─── */
.status-dot.warn { background: #f59e0b; box-shadow: 0 0 10px rgba(245,158,11,0.6); }
.status-dot.error { background: #ef4444; box-shadow: 0 0 10px rgba(239,68,68,0.6); }

/* ─── Process (tool-use) display ─── */
.process-container {
  margin-bottom: 10px;
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  background: rgba(0, 255, 128, 0.03);
  overflow: hidden;
}
.process-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(16, 185, 129, 0.8);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.process-header::-webkit-details-marker { display: none; }
.process-header .proc-icon { font-size: 14px; }
details.process-container[open] .process-header { border-bottom: 1px solid rgba(16,185,129,0.15); }
.process-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px;
}
.process-step {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 12px;
}
.process-step.call {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
}
.process-step.result {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.12);
}
.pstep-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.pstep-icon { font-size: 13px; }
.call-icon { color: #818cf8; }
.result-icon { color: var(--accent-success); }
.pstep-name {
  font-family: monospace;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
}
.pstep-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pstep-badge.call { background: rgba(99,102,241,0.2); color: #818cf8; }
.pstep-badge.result { background: rgba(16,185,129,0.2); color: var(--accent-success); }
.pstep-args, .pstep-result {
  margin: 0;
  padding: 5px 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}

/* ─── File / Image Attachment UI ─── */
.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  margin-bottom: 2px;
}
.attach-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.06); }
.attach-btn input { display: none; }
.attach-btn i { width: 18px; height: 18px; pointer-events: none; }

.attach-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 10px;
}
.attach-preview.has-items { display: flex; }

.att-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-sm);
  padding: 4px 8px 4px 6px;
  max-width: 200px;
}
.att-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.att-file-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.att-name {
  font-size: 12px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.att-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.att-remove:hover { color: #f87171; }

/* Attachment display in user message bubbles */
.user-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.user-att-img {
  max-width: 260px;
  max-height: 200px;
  border-radius: var(--radius-md);
  object-fit: cover;
  display: block;
}
.user-att-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.user-text { white-space: pre-wrap; word-break: break-word; }
