/* ─── Agents Uni Chat — Dark Tech Theme ─── */

:root,
:root[data-theme="dark"] {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-hover: #22223a;
  --border: #2a2a3e;
  --border-light: #3a3a5e;
  --text-primary: #e0e0e8;
  --text-secondary: #8888a0;
  --text-muted: #5a5a72;
  --accent: #7c5cfc;
  --accent-light: #9b7eff;
  --accent-dim: rgba(124, 92, 252, 0.15);
  --user-bubble: #2a2a5e;
  --agent-bubble: #1e1e30;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --modal-bg: rgba(0, 0, 0, 0.6);
}

:root[data-theme="light"] {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f1f3;
  --bg-hover: #e8e9ec;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #6d4ddc;
  --accent-light: #8b6cf7;
  --accent-dim: rgba(109, 77, 220, 0.1);
  --user-bubble: #e0e0ff;
  --agent-bubble: #f3f4f6;
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  --info: #3b82f6;
  --modal-bg: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* ─── App Layout ─── */

.app {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ─── */

.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.3rem;
}

.universe-name {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sidebar-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-section:last-of-type {
  flex: 1;
}

.sidebar-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.powered-by {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ─── Participant List ─── */

.participant-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}

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

.participant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.participant-info {
  min-width: 0;
}

.participant-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.participant-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Relationship List ─── */

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sidebar-title-row .sidebar-title {
  margin-bottom: 0;
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 2px;
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.toggle-btn.active {
  background: var(--accent-dim);
  color: var(--accent-light);
}

.toggle-btn:hover:not(.active) {
  color: var(--text-secondary);
}

.relationship-graph {
  height: 350px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}

.relationship-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.relationship-item {
  font-size: 0.75rem;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rel-agents {
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.rel-arrow {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.rel-dim-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rel-dim {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 80px;
}

.rel-strength-bar {
  flex: 1;
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}

.rel-strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.rel-strength-fill.positive { background: var(--success); }
.rel-strength-fill.negative { background: var(--error); }
.rel-dim.positive { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.rel-dim.negative { background: rgba(248, 113, 113, 0.15); color: var(--error); }

/* ─── Relationship Timeline ─── */

.relationship-timeline {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-event {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  font-size: 0.7rem;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 3px;
  flex-shrink: 0;
}

.timeline-dot.consensus { background: var(--success); }
.timeline-dot.disagreement { background: var(--error); }
.timeline-dot.collaboration { background: var(--info); }
.timeline-dot.default { background: var(--text-muted); }

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

.timeline-desc {
  color: var(--text-primary);
  line-height: 1.3;
}

.timeline-meta {
  color: var(--text-muted);
  font-size: 0.6rem;
  margin-top: 2px;
}

/* ─── Chat Main ─── */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Chat Header ─── */

.chat-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chat-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.mode-selector {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 5px 8px;
  border-radius: 6px;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
}

.mode-selector:focus {
  border-color: var(--accent);
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

.status-dot.idle { background: var(--success); }
.status-dot.processing { background: var(--warning); animation: pulse 1.5s ease-in-out infinite; }

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

.agent-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ─── Messages ─── */

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

.welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.welcome-icon { font-size: 3rem; margin-bottom: 16px; }
.welcome-message h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text-primary); }
.welcome-message p { font-size: 0.85rem; max-width: 400px; margin: 0 auto 8px; line-height: 1.5; }
.welcome-hint { font-size: 0.75rem !important; color: var(--text-muted) !important; }

/* Message Bubbles */

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: messageIn 0.3s ease-out;
}

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

.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.agent { align-self: flex-start; }
.message.system { align-self: center; max-width: 80%; }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s;
}

.message-avatar:hover { transform: scale(1.1); }
.message.user .message-avatar { background: var(--accent); }

.message-body { display: flex; flex-direction: column; gap: 4px; }
.message-sender { font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); }
.message.user .message-sender { text-align: right; }

.message-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .message-content { background: var(--user-bubble); border-top-right-radius: 4px; }
.message.agent .message-content { background: var(--agent-bubble); border: 1px solid var(--border); border-top-left-radius: 4px; }
.message.system .message-content {
  background: transparent;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  border-radius: 20px;
  padding: 4px 14px;
}

.message-time { font-size: 0.65rem; color: var(--text-muted); }
.message.user .message-time { text-align: right; }

/* ─── Processing / Thinking Indicator ─── */

.processing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.thinking-agents {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 16px;
}

.thinking-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease-out;
}

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

.thinking-agent-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.4s ease-in-out infinite;
}

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

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

/* ─── Input Area ─── */

.input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  transition: border-color 0.2s;
  position: relative;
}

.input-wrapper:focus-within { border-color: var(--accent); }

.message-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
}

.message-input::placeholder { color: var(--text-muted); }
.message-input:disabled { opacity: 0.5; cursor: not-allowed; }

.send-button {
  background: var(--accent);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.send-button:hover { background: var(--accent-light); }
.send-button:active { transform: scale(0.95); }
.send-button:disabled { background: var(--bg-hover); cursor: not-allowed; opacity: 0.5; }
.send-button.empty { background: var(--bg-hover); opacity: 0.5; }

.input-hint {
  margin-top: 6px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: right;
}

.input-hint kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
}

/* ─── Scrollbar ─── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── @Mention Dropdown ─── */

.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 4px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.mention-item:hover,
.mention-item.selected { background: var(--bg-hover); }

.mention-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.mention-name { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); }
.mention-role { font-size: 0.7rem; color: var(--text-muted); margin-left: auto; }
.mention-highlight { font-weight: 600; cursor: default; }
.mention-all { color: var(--warning) !important; }

/* ─── Markdown in Messages ─── */

.md-code-block {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 6px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre;
}

.md-inline-code {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.82em;
}

.md-list { margin: 4px 0; padding-left: 20px; }
.md-list li { margin: 2px 0; }
.message-content strong { font-weight: 600; }
.message-content em { font-style: italic; color: var(--text-secondary); }

/* ─── Search Modal ─── */

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--modal-bg);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.search-modal.open { display: flex; }

.search-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
}

.search-input::placeholder { color: var(--text-muted); }

.search-kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.search-result-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

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

.search-result-sender {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 4px;
}

.search-result-content {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.search-result-content mark {
  background: rgba(251, 191, 36, 0.3);
  color: var(--warning);
  border-radius: 2px;
  padding: 0 2px;
}

.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── Agent Popover ─── */

.agent-popover {
  position: fixed;
  z-index: 1500;
  display: none;
}

.agent-popover.open { display: block; }

.agent-popover-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px;
  min-width: 240px;
  max-width: 320px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.popover-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.popover-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.popover-name { font-size: 0.9rem; font-weight: 600; }
.popover-role { font-size: 0.7rem; color: var(--text-muted); }

.popover-section { margin-top: 10px; }
.popover-section-title { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }

.popover-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.popover-trait {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent-light);
  font-family: var(--font-mono);
}

.popover-rel-item {
  font-size: 0.72rem;
  padding: 2px 0;
  color: var(--text-secondary);
}

/* ─── Toast Notifications ─── */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: toastIn 0.3s ease-out;
  max-width: 360px;
}

.toast.removing { animation: toastOut 0.3s ease-in forwards; }
.toast.info { border-left: 3px solid var(--info); }
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.error { border-left: 3px solid var(--error); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }

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

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ─── Sidebar Overlay (mobile) ─── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}

.sidebar-overlay.open { display: block; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.mobile-menu-btn:hover { background: var(--bg-hover); }

.empty-state {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 12px;
  line-height: 1.5;
}

/* ─── Fullscreen Graph Modal ─── */

.graph-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-primary);
  display: none;
  flex-direction: column;
}

.graph-modal.open { display: flex; }

.graph-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.graph-modal-header h3 { font-size: 1rem; font-weight: 600; }

.graph-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}

.graph-modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.graph-modal-body { flex: 1; display: flex; overflow: hidden; }
.graph-modal-canvas { flex: 1; }

.graph-modal-panel {
  width: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
}

.graph-modal-panel.open { width: 320px; }

/* ─── Edit Panel ─── */

.edit-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.edit-panel-header h4 { font-size: 0.9rem; font-weight: 600; }
.edit-panel-close { background: none; border: none; color: var(--text-secondary); font-size: 1.2rem; cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.edit-panel-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.edit-panel-body { flex: 1; padding: 16px; overflow-y: auto; }
.edit-panel-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.edit-dim-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.edit-dim-label { font-size: 0.75rem; color: var(--text-secondary); min-width: 60px; font-family: var(--font-mono); }

.edit-dim-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.edit-dim-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-primary); }
.edit-dim-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-primary); }

.edit-dim-value { font-size: 0.75rem; font-family: var(--font-mono); color: var(--text-primary); min-width: 32px; text-align: right; }

.edit-save-btn { background: var(--accent); border: none; color: #fff; padding: 6px 16px; border-radius: 6px; font-size: 0.8rem; cursor: pointer; font-family: var(--font-sans); transition: background 0.2s; }
.edit-save-btn:hover { background: var(--accent-light); }
.edit-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.edit-cancel-btn { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); padding: 6px 16px; border-radius: 6px; font-size: 0.8rem; cursor: pointer; font-family: var(--font-sans); transition: background 0.2s; }
.edit-cancel-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.edit-empty { font-size: 0.8rem; color: var(--text-muted); text-align: center; padding: 20px 0; }
.fullscreen-btn { font-size: 0.75rem; padding: 3px 6px; }

.rel-edit-btn { background: none; border: none; color: var(--text-muted); font-size: 0.75rem; cursor: pointer; margin-left: auto; padding: 2px 4px; border-radius: 3px; opacity: 0; transition: opacity 0.2s, color 0.2s; }
.relationship-item:hover .rel-edit-btn { opacity: 1; }
.rel-edit-btn:hover { color: var(--accent-light); background: var(--accent-dim); }

.rel-inline-edit { padding-top: 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.edit-inline-actions { display: flex; gap: 6px; margin-top: 8px; }
.edit-inline-actions .edit-save-btn, .edit-inline-actions .edit-cancel-btn { padding: 4px 12px; font-size: 0.7rem; }

/* ─── Responsive ─── */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: block; }
  .messages-container { padding: 16px; }
  .message { max-width: 95%; }
  .chat-header-actions { gap: 4px; }

  .agent-popover-content {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    min-width: auto;
  }

  .search-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .search-modal { padding-top: 0; }

  .toast-container {
    top: auto;
    bottom: 20px;
    right: 50%;
    transform: translateX(50%);
  }

  .toast { max-width: 90vw; }

  .header-btn { width: 28px; height: 28px; }
  .mode-selector { font-size: 0.7rem; padding: 4px 6px; }
}

@media (max-width: 480px) {
  .chat-header { padding: 10px 12px; }
  .input-area { padding: 12px; }
  .agent-count { display: none; }
}
