/* =============================================================================
   archi Chat UI - Professional AI Assistant Interface
   Version: 2.0.0
   
   Design System:
   - ChatGPT/Claude-inspired layout
   - Full-width message rows (no bubbles)
   - Dark code blocks with syntax highlighting
   - Collapsible sidebar with conversation history
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CSS Variables - Design Tokens
   ----------------------------------------------------------------------------- */
:root {
  /* Colors - Light Theme */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #e5e7eb;
  
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  
  --border-color: #e5e7eb;
  --border-light: #f3f4f6;
  
  --accent: #10a37f;
  --accent-hover: #0d8a6a;
  --accent-light: rgba(16, 163, 127, 0.1);
  
  --user-bg: #f3f4f6;
  --assistant-bg: #ffffff;
  
  --code-bg: #1e1e1e;
  --code-header-bg: #2d2d2d;
  --code-text: #d4d4d4;
  
  --error-bg: #fef2f2;
  --error-text: #dc2626;
  
  /* Semantic aliases for data/upload/database pages */
  --text-muted: #9ca3af;
  --accent-color: #10a37f;
  --success-color: #16a34a;
  --danger-color: #dc2626;
  --warning-color: #ca8a04;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;
  
  --text-base: 15px;
  --text-sm: 14px;
  --text-xs: 12px;
  --line-height: 1.6;
  
  /* Spacing */
  --sidebar-width: 260px;
  --header-height: 56px;
  --input-height: 90px;
  --message-max-width: 768px;
  --message-padding-y: 24px;
  --message-padding-x: 24px;
  
  /* Icon sizes - standardized */
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
  
  /* Border radii - standardized */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  /* Touch target minimum */
  --touch-target-min: 44px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* -----------------------------------------------------------------------------
   Dark Theme Overrides
   ----------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  --bg-primary: #0f1217;
  --bg-secondary: #141923;
  --bg-tertiary: #1b2432;
  --bg-hover: #232f43;

  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;

  --border-color: #253246;
  --border-light: #1b2432;

  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-light: rgba(34, 197, 94, 0.16);

  --user-bg: #192130;
  --assistant-bg: #0f1217;

  --code-bg: #0b0f17;
  --code-header-bg: #141923;
  --code-text: #e2e8f0;

  --error-bg: #3b1515;
  --error-text: #f87171;

  /* Semantic aliases for data/upload/database pages */
  --text-muted: #6b7280;
  --accent-color: #22c55e;
  --success-color: #3fb950;
  --danger-color: #f85149;
  --warning-color: #d29922;
}

/* -----------------------------------------------------------------------------
   Reset & Base Styles
   ----------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height);
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

/* -----------------------------------------------------------------------------
   App Layout - Three-Column Grid
   ----------------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr var(--input-height);
  grid-template-areas:
    "sidebar header"
    "sidebar messages"
    "sidebar input";
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

.app.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

/* -----------------------------------------------------------------------------
   Header
   ----------------------------------------------------------------------------- */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

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

.header-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-left: auto;
  border-bottom: 1px solid var(--border-color);
  height: 100%;
}

.header-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: -1px;
}

.header-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.header-tab.active,
.header-tab[aria-current="page"] {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: transparent;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.model-select {
  padding: 8px 12px;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.model-select:hover {
  border-color: var(--text-tertiary);
}

.model-select:focus {
  outline: none;
  border-color: var(--accent);
}

.ab-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: var(--touch-target-min);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ab-toggle:hover {
  border-color: var(--text-tertiary);
}

.ab-toggle.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.ab-toggle input {
  display: none;
}

/* -----------------------------------------------------------------------------
   Sidebar
   ----------------------------------------------------------------------------- */
.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  overflow: hidden;
  transition: transform var(--transition-normal);
  z-index: 20;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.sidebar-brand svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.sidebar-brand img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.new-chat-btn:hover {
  background: var(--accent-hover);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-group {
  margin-bottom: 16px;
}

.conversation-group-label {
  padding: 8px 12px 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: var(--touch-target-min);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.conversation-item.active {
  background: var(--bg-tertiary);
}

.conversation-item-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

.conversation-item-title {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item-delete {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.conversation-item:hover .conversation-item-delete {
  display: flex;
}

.conversation-item-delete:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

/* -----------------------------------------------------------------------------
   User Profile Widget (Bottom of Sidebar)
   ----------------------------------------------------------------------------- */
.user-profile-widget {
  display: none;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.user-profile-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-profile-content:hover {
  background: var(--bg-hover);
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

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

.user-email {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-roles-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.user-roles-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.user-profile-widget.expanded .user-roles-toggle {
  transform: rotate(180deg);
}

.user-roles-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal);
  border-top: 1px solid transparent;
}

.user-profile-widget.expanded .user-roles-panel {
  max-height: 300px;
  border-top-color: var(--border-color);
}

.user-roles-header {
  padding: 12px 16px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-roles-list {
  padding: 0 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 500;
}

.user-role-badge svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Special role styling */
.user-role-badge.role-admin {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

:root[data-theme="dark"] .user-role-badge.role-admin {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.user-role-badge.role-expert {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

:root[data-theme="dark"] .user-role-badge.role-expert {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.user-roles-footer {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border-color);
}

.user-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-logout-btn:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

/* -----------------------------------------------------------------------------
   Messages Area
   ----------------------------------------------------------------------------- */
.messages {
  grid-area: messages;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.messages-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.message {
  padding: var(--message-padding-y) var(--message-padding-x);
  border-bottom: 1px solid var(--border-light);
}

.message.user {
  background: var(--user-bg);
}

.message.assistant {
  background: var(--assistant-bg);
}

.message-inner {
  max-width: var(--message-max-width);
  margin: 0 auto;
}

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

.message-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.message-avatar img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.message.user .message-avatar {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.message.assistant .message-avatar {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.message-sender {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.message-label {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.message-content {
  font-size: var(--text-base);
  line-height: var(--line-height);
  color: var(--text-primary);
}

/* Markdown Content Styles */
.message-content p {
  margin-bottom: 16px;
}

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

.message-content ul, .message-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.message-content li {
  margin-bottom: 8px;
}

.message-content strong {
  font-weight: 600;
}

.message-content a {
  color: var(--accent);
  text-decoration: none;
}

.message-content a:hover {
  text-decoration: underline;
}

/* Inline Code */
.message-content code:not(pre code) {
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

/* Code Blocks */
.message-content pre {
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--code-bg);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--code-header-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-block-lang {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--code-text);
  text-transform: lowercase;
}

.code-block-copy {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  min-height: 36px;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  color: var(--code-text);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.code-block-copy:hover {
  background: rgba(255, 255, 255, 0.1);
}

.code-block-copy.copied {
  color: var(--accent);
}

.message-content pre code {
  display: block;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--code-text);
  overflow-x: auto;
}

/* Streaming cursor */
.message-content .streaming-cursor {
  display: inline-block;
  width: 8px;
  height: 18px;
  margin-left: 2px;
  background: var(--accent);
  animation: blink 1s infinite;
  vertical-align: text-bottom;
}

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

/* Empty State */
.messages-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.messages-empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  color: var(--accent);
}

.messages-empty-logo {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  object-fit: contain;
}

.messages-empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.messages-empty-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 400px;
}

/* Typing Indicator */
.typing-indicator {
  padding: var(--message-padding-y) var(--message-padding-x);
  background: var(--assistant-bg);
}

.typing-indicator-inner {
  max-width: var(--message-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: typing 1.4s 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 {
  grid-area: input;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

.input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: var(--message-max-width);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.input-left-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.input-field {
  flex: 1;
  max-height: 150px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-left-controls .model-select,
.input-wrapper .model-select {
  padding: 4px 8px;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.input-toolbar .model-select:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.input-toolbar .model-select:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.data-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

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

.entry-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
  padding: 0;
  text-align: center;
  max-width: 640px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  color: white;
}

.send-btn:disabled {
  color: var(--border-color);
  cursor: not-allowed;
}

.agent-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.agent-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--text-xs);
  transition: all var(--transition-fast);
  max-width: 180px;
}

.agent-dropdown-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.agent-dropdown-label {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  top: auto;
  left: 0;
  min-width: 220px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22);
  padding: 8px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-dropdown-menu[hidden] {
  display: none;
}

.agent-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.agent-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.agent-dropdown-item:hover {
  color: var(--text-primary);
  background: var(--surface-alt);
}

.agent-dropdown-item.active {
  color: var(--text-primary);
  background: var(--accent-light);
  border: 1px solid var(--accent);
}

.agent-dropdown-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-dropdown-check {
  flex-shrink: 0;
  color: var(--accent);
}

.agent-dropdown-check-spacer {
  display: inline-block;
  width: 14px;
  flex-shrink: 0;
}

.agent-dropdown-actions {
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.agent-dropdown-item:hover .agent-dropdown-actions {
  opacity: 1;
}

.agent-dropdown-edit,
.agent-dropdown-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  color: var(--text-tertiary);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.agent-dropdown-edit:hover {
  color: var(--text-primary);
  background: var(--surface);
}

.agent-dropdown-delete:hover {
  color: var(--error-text);
  background: rgba(239, 68, 68, 0.1);
}

.agent-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 2px 0;
}

.agent-dropdown-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: var(--text-xs);
  cursor: pointer;
}

.agent-dropdown-add:hover {
  background: var(--accent-hover);
}

/* Delete inline confirmation */
.agent-dropdown-item-confirming {
  background: rgba(239, 68, 68, 0.08) !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.agent-dropdown-confirm-text {
  font-size: var(--text-xs);
  color: var(--error-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.agent-dropdown-confirm-actions {
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
}

.agent-dropdown-confirm-yes {
  border: none;
  background: var(--error-text);
  color: white;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.agent-dropdown-confirm-yes:hover {
  opacity: 0.85;
}

.agent-dropdown-confirm-no {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
}

.agent-dropdown-confirm-no:hover {
  background: var(--surface-alt);
}


.send-btn.stop-mode {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error-text);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.send-btn.stop-mode:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error-text);
}

/* -----------------------------------------------------------------------------
   Settings Modal
   ----------------------------------------------------------------------------- */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.settings-panel {
  position: relative;
  width: 95%;
  max-width: 680px;
  max-height: 85vh;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.settings-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-close {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* Settings Layout with Sidebar */
.settings-content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Settings Navigation Sidebar */
.settings-nav {
  display: flex;
  flex-direction: column;
  width: 180px;
  padding: 12px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.settings-nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.settings-nav-item.active {
  background: var(--accent);
  color: white;
}

.settings-nav-item.active svg {
  stroke: white;
}

.settings-nav-item svg {
  flex-shrink: 0;
  stroke: currentColor;
}

/* Settings Body */
.settings-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  min-height: 0;
}

/* Settings Sections */
.settings-section {
  display: none;
}

.settings-section.active {
  display: block;
}

.settings-section[hidden] {
  display: none !important;
}

.settings-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

.settings-group {
  margin-bottom: 24px;
}

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

.settings-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.settings-group-bordered {
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.settings-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.settings-field-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.settings-description {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Compact Toggle (for inline use) */
.settings-toggle-compact {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.settings-toggle-compact input {
  display: none;
}

.toggle-slider-compact {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--bg-tertiary);
  border-radius: 11px;
  transition: background var(--transition-fast);
}

.toggle-slider-compact::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

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

.settings-toggle-compact input:checked + .toggle-slider-compact::after {
  transform: translateX(18px);
}

/* Standard Toggle */
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.settings-toggle input {
  display: none;
}

.settings-toggle .toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  transition: background var(--transition-fast);
}

.settings-toggle .toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

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

.settings-toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.toggle-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.settings-group .model-select {
  width: 100%;
  padding: 10px 12px;
  font-size: var(--text-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
}

.ab-model-group {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Provider Selection Styles */
.provider-selection {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.provider-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.message-meta {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Message Feedback Actions */
.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message:hover .message-actions {
  opacity: 1;
}

.message-actions.feedback-submitted {
  opacity: 1;
}

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

.message-actions.feedback-like-active .feedback-like {
  color: var(--success-text, #22c55e);
  background: rgba(34, 197, 94, 0.15);
}

.message-actions.feedback-like-active .feedback-like svg {
  fill: rgba(34, 197, 94, 0.3);
}

.message-actions.feedback-dislike-active .feedback-dislike {
  color: var(--error-text);
  background: rgba(239, 68, 68, 0.15);
}

.message-actions.feedback-dislike-active .feedback-dislike svg {
  fill: rgba(239, 68, 68, 0.2);
}

.feedback-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Feedback Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

/* Feedback Modal */
.feedback-modal-content {
  max-width: 480px;
  width: 90%;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: modalSlideIn 0.2s ease-out;
  overflow: hidden;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.feedback-modal-content .modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.feedback-modal-content .modal-icon {
  color: var(--accent);
}

.feedback-modal-content .modal-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.feedback-modal-content .modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.feedback-modal-content .modal-body {
  padding: 24px;
}

.feedback-description {
  margin: 0 0 16px 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.feedback-label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.feedback-modal-content textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.feedback-modal-content textarea::placeholder {
  color: var(--text-tertiary);
}

.feedback-modal-content textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 59, 130, 246), 0.1);
}

.feedback-hint {
  margin: 12px 0 0 0;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.feedback-modal-content .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px 24px;
}

.feedback-modal-content .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.feedback-modal-content .btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.feedback-modal-content .btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.feedback-modal-content .btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white;
}

.feedback-modal-content .btn-primary:hover {
  filter: brightness(1.1);
}

.feedback-modal-content .btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.feedback-modal-content .btn-primary .spinner {
  animation: spin 1s linear infinite;
}

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

.custom-model-row input.model-select {
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.provider-row .settings-label,
.provider-row .settings-sublabel {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.settings-sublabel {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 400;
}

.provider-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-top: 0.5rem;
  border-radius: 6px;
  font-size: var(--text-xs);
}

.provider-status.connected {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.provider-status.disconnected {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.provider-status.loading {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.provider-status .status-icon {
  font-size: 0.75rem;
}

.provider-select:disabled,
.model-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Collapsible Settings Section */
.settings-collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
}

.settings-collapsible:hover {
  color: var(--accent-color);
}

.settings-collapsible .settings-label {
  margin: 0;
}

.collapsible-icon {
  transition: transform 0.2s ease;
  color: var(--text-secondary);
}

.settings-collapsible[aria-expanded="true"] .collapsible-icon {
  transform: rotate(180deg);
}

.settings-collapsible-content {
  margin-top: 0.75rem;
}

.settings-collapsible-content[hidden] {
  display: none;
}

/* API Keys Section */
.api-keys-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.api-key-loading {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  padding: 0.5rem;
}

.api-key-row {
  display: grid;
  grid-template-columns: 90px auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--message-bg);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.api-key-provider {
  font-weight: 500;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.api-key-status {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  min-width: 50px;
}

.api-key-status.configured {
  color: #22c55e;
}

.api-key-status.not-configured {
  color: var(--text-tertiary);
}

.api-key-status .status-dot {
  font-size: 0.75rem;
}

.api-key-status .status-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.api-key-actions {
  display: flex;
  gap: 0.25rem;
}

.api-key-input {
  min-width: 0;
  padding: 0.375rem 0.5rem;
  font-size: var(--text-xs);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.api-key-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.1);
}

.api-key-input::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.api-key-btn {
  padding: 0.375rem 0.625rem;
  font-size: var(--text-xs);
  font-weight: 500;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.api-key-btn:hover {
  background: var(--message-bg);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.api-key-btn.save-btn {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.api-key-btn.save-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.api-key-btn.clear-btn {
  padding: 0.375rem 0.5rem;
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  background: transparent;
}

.api-key-btn.clear-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

.api-key-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* -----------------------------------------------------------------------------
   Scrollbar Styling
   ----------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
}

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

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

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

/* -----------------------------------------------------------------------------
   Responsive Design
   ----------------------------------------------------------------------------- */

/* Sidebar Overlay - Only visible on mobile when sidebar is open */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 15;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 0 1fr;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 25;
  }
  
  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }
  
  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }
  
  .app.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  
  .header-controls {
    gap: 8px;
  }
  
  .ab-toggle span {
    display: none;
  }
  
  /* Input area - reduce padding on mobile */
  .input-area {
    padding: 12px 16px 16px;
  }
  
  /* Message padding - reduce on mobile */
  .message {
    padding: 16px 16px;
  }
}

/* Extra small screens (320px) */
@media (max-width: 380px) {
  .input-area {
    padding: 10px 12px 14px;
  }
  
  .message {
    padding: 12px 12px;
  }
  
  .toolbar-left {
    gap: 2px;
  }
  
  .input-toolbar .model-select {
    padding: 4px 6px;
    font-size: 11px;
  }
  
  .settings-btn,
  .send-btn {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
  }
}

/* =============================================================================
   A/B Testing UI Styles
   ============================================================================= */

/* -----------------------------------------------------------------------------
   A/B Comparison Container - Side-by-Side Layout
   ----------------------------------------------------------------------------- */
.ab-comparison {
  display: flex;
  gap: 16px;
  margin: 0 auto;
  max-width: calc(var(--message-max-width) * 2 + 32px);
  padding: var(--message-padding-y) var(--message-padding-x);
}

.ab-response {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 500px;
}

.ab-response-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.ab-response-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ab-response-label::before {
  content: '';
}

.ab-response-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* Winner/Loser States */
.ab-response-winner {
  border: none;
  background: transparent;
  flex: none;
  width: 100%;
  max-width: var(--message-max-width);
}

.ab-comparison-resolved {
  display: block;
  gap: 0;
}

.ab-comparison-resolved .ab-response-winner {
  padding: 0;
}

.ab-comparison-resolved .ab-response-winner .ab-response-content {
  padding: 0;
}

.ab-response-loser {
  display: none;
}

.ab-response-tie {
  border-color: var(--text-tertiary);
}

.ab-winner-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 2px 8px;
  background: var(--accent);
  color: white;
  border-radius: 9999px;
  font-size: var(--text-xs);
  font-weight: 500;
}

/* -----------------------------------------------------------------------------
   Vote Buttons
   ----------------------------------------------------------------------------- */
.ab-vote-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  margin: 0 auto;
  max-width: calc(var(--message-max-width) * 2 + 32px);
}

.ab-vote-prompt {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.ab-vote-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.ab-vote-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  min-height: var(--touch-target-min);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ab-vote-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: translateY(-1px);
}

.ab-vote-btn:active {
  transform: translateY(0);
}

.ab-vote-icon {
  font-size: 16px;
}

.ab-vote-btn-tie {
  background: transparent;
}

.ab-vote-btn-tie:hover {
  background: var(--text-tertiary);
  border-color: var(--text-tertiary);
}

/* Thank You Message */
.ab-thanks-message {
  text-align: center;
  padding: 12px;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* -----------------------------------------------------------------------------
   A/B Warning Modal
   ----------------------------------------------------------------------------- */
.ab-warning-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.ab-warning-modal {
  background: var(--bg-primary);
  border-radius: 16px;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: modalSlideIn 0.2s ease;
}

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

.ab-warning-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.ab-warning-modal-header svg {
  color: #f59e0b;
  flex-shrink: 0;
}

.ab-warning-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.ab-warning-modal-body {
  padding: 20px 24px;
}

.ab-warning-modal-body p {
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.ab-warning-modal-body ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.ab-warning-modal-body li {
  margin-bottom: 6px;
}

.ab-warning-modal-body li strong {
  color: var(--text-primary);
}

.ab-warning-modal-actions {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  justify-content: flex-end;
}

.ab-warning-btn {
  padding: 10px 20px;
  min-height: var(--touch-target-min);
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ab-warning-btn-cancel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.ab-warning-btn-cancel:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.ab-warning-btn-confirm {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white;
}

.ab-warning-btn-confirm:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* -----------------------------------------------------------------------------
   Toast Notifications
   ----------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1001;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* -----------------------------------------------------------------------------
   A/B Error Message
   ----------------------------------------------------------------------------- */
.ab-error-message {
  border-left: 4px solid var(--error-text);
  background: var(--error-bg);
}

/* -----------------------------------------------------------------------------
   A/B Responsive - Mobile Stack Layout
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .ab-comparison {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }
  
  .ab-response {
    max-height: 350px;
  }
  
  .ab-vote-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .ab-vote-btn {
    justify-content: center;
    width: 100%;
  }
  
  .ab-warning-modal {
    max-width: 95%;
  }
}

/* =============================================================================
   Agent Trace Styles
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Trace Container
   ----------------------------------------------------------------------------- */
.trace-container {
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  font-size: var(--text-sm);
  background: var(--bg-secondary);
}

.trace-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
}

.trace-header:hover {
  background: var(--bg-hover);
}

.trace-icon {
  font-size: 16px;
  line-height: 1;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.trace-label {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.trace-toggle {
  background: none;
  border: none;
  padding: 4px;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.trace-toggle:hover {
  color: var(--text-primary);
}

.toggle-icon {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.trace-content {
  padding: 8px;
  max-height: 500px;
  overflow-y: auto;
}

.trace-container.collapsed .trace-content {
  display: none;
}

/* A/B Testing Trace Container */
.ab-trace-container {
  margin: 0 0 8px 0;
  font-size: var(--text-xs);
}

.ab-trace-container .trace-header {
  padding: 6px 10px;
}

.ab-trace-container .trace-content {
  padding: 6px;
  max-height: 300px;
}

.ab-trace-container .tool-block {
  font-size: var(--text-xs);
}

.ab-trace-container .tool-header {
  padding: 4px 8px;
}

.ab-trace-container .tool-args,
.ab-trace-container .tool-output {
  padding: 4px 8px;
  font-size: 11px;
}

/* -----------------------------------------------------------------------------
   Tool Block
   ----------------------------------------------------------------------------- */
.tool-block {
  margin: 4px 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-primary);
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
}

.tool-header:hover {
  background: var(--bg-tertiary);
}

.tool-icon {
  font-size: 14px;
}

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

.tool-status {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Spinner for running tools */
.tool-running .spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Tool status icons */
.tool-success .checkmark {
  color: var(--accent);
}

.tool-error .error-icon {
  color: var(--error-text);
}

.tool-success .tool-header {
  border-left: 3px solid var(--accent);
}

.tool-error .tool-header {
  border-left: 3px solid var(--error-text);
}

/* Tool details (collapsed by default) */
.tool-details {
  display: none;
  border-top: 1px solid var(--border-color);
}

.tool-block.expanded .tool-details {
  display: block;
}

.tool-section-label {
  padding: 6px 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
}

.tool-args pre,
.tool-output-section pre {
  margin: 0;
  padding: 12px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  max-height: 200px;
  overflow-y: auto;
}

.truncation-notice {
  padding: 4px 12px;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
}

/* -----------------------------------------------------------------------------
   Trace Timer
   ----------------------------------------------------------------------------- */
.trace-timer {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: 2px 8px;
  background: var(--bg-primary);
  border-radius: 4px;
}

/* -----------------------------------------------------------------------------
   Context Meter
   ----------------------------------------------------------------------------- */
.context-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: 11px;
  opacity: 0.55;
  transition: opacity 0.2s ease;
  cursor: default;
}

.context-meter:hover {
  opacity: 0.9;
}

.meter-bar {
  flex: 0 0 80px;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.meter-label {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   Step Timeline
   ----------------------------------------------------------------------------- */
.step-timeline {
  padding: 4px 0;
}

.step {
  display: flex;
  gap: 12px;
  position: relative;
}

.step:last-child .step-line {
  display: none;
}

.step-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
}

.step-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  z-index: 1;
}

.thinking-marker {
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

.completed-marker {
  background: var(--accent);
  border-color: var(--accent);
}

.tool-marker {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

.success-marker {
  background: var(--accent);
  border-color: var(--accent);
}

.error-marker {
  background: var(--error-text);
  border-color: var(--error-text);
}

.step-line {
  flex: 1;
  width: 2px;
  background: var(--border-color);
  min-height: 20px;
}

.step-content {
  flex: 1;
  min-width: 0;
  padding-bottom: 8px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}

.step-header:hover {
  background: var(--bg-tertiary);
}

.step-icon {
  font-size: 12px;
  width: 20px;
  text-align: center;
}

.tool-icon-glyph {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  background: var(--accent);
  color: var(--bg-primary);
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-label {
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-status {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.step-status .spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.step-status .checkmark {
  color: var(--accent);
}

.step-status .error-icon {
  color: var(--error-text);
}

.step-timer {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
}

.step-toggle {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-toggle:hover {
  color: var(--text-primary);
}

.step-details {
  margin-top: 4px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-primary);
}

.step-details .section-label {
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
}

.step-details pre {
  margin: 0;
  padding: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Thinking step specific styles */
.thinking-step .step-label {
  color: var(--text-secondary);
  font-style: italic;
}

.thinking-dots span {
  animation: blink 1.4s infinite both;
}

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

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

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

.thinking-step.completed .thinking-dots {
  display: none;
}

.thinking-step.completed .step-label {
  font-style: normal;
}

/* Tool step states */
.tool-step.tool-running .step-header {
  background: var(--bg-secondary);
}

.tool-step.tool-success .step-header {
  border-left: 2px solid var(--accent);
  margin-left: -2px;
  padding-left: 10px;
}

.tool-step.tool-error .step-header {
  border-left: 2px solid var(--error-text);
  margin-left: -2px;
  padding-left: 10px;
}

/* -----------------------------------------------------------------------------
   Cancel Button
   ----------------------------------------------------------------------------- */
.cancel-stream-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  min-height: var(--touch-target-min);
  margin-top: 8px;
  border: 1px solid var(--error-text);
  border-radius: 4px;
  background: transparent;
  color: var(--error-text);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 500;
  transition: all 0.15s ease;
}

.cancel-stream-btn:hover {
  background: var(--error-text);
  color: white;
}

/* -----------------------------------------------------------------------------
   Cancelled Notice
   ----------------------------------------------------------------------------- */
.cancelled-notice {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* -----------------------------------------------------------------------------
   Agent Info Modal
   ----------------------------------------------------------------------------- */
.agent-info-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.agent-info-panel {
  position: relative;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}

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

.agent-info-body {
  padding: 16px 20px;
  overflow-y: auto;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.agent-info-close {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.agent-info-section {
  margin-bottom: 16px;
}

.agent-info-section h4 {
  margin-bottom: 6px;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.agent-info-list {
  margin: 0;
  padding-left: 18px;
}

.agent-info-prompt {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  font-size: var(--text-sm);
  color: var(--text-primary);
  max-height: 240px;
  overflow: auto;
}

/* -----------------------------------------------------------------------------
   Agent Spec Editor Modal
   ----------------------------------------------------------------------------- */
.agent-spec-modal {
  position: fixed;
  inset: 0;
  z-index: 115;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-spec-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.agent-spec-panel {
  position: relative;
  width: 92%;
  max-width: 860px;
  max-height: 85vh;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.agent-spec-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-spec-content {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
  gap: 16px;
  align-items: start;
}

.agent-spec-editor-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-spec-tools-pane {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.agent-spec-tools-header {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.agent-spec-tools-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-spec-tool {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.agent-spec-tool:hover {
  border-color: var(--text-tertiary);
}

.agent-spec-tool-checkbox {
  margin-top: 2px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.agent-spec-tool-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.agent-spec-tool-name {
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.agent-spec-tool-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.35;
}

@media (max-width: 900px) {
  .agent-spec-content {
    grid-template-columns: 1fr;
  }
}

/* -- Structured form fields ------------------------------------------------ */

.agent-spec-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-spec-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.agent-spec-name-input {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text-primary);
  font-size: var(--text-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

.agent-spec-name-input:focus {
  border-color: var(--accent);
}

.agent-spec-prompt-input {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text-primary);
  font-size: var(--text-sm);
  padding: 10px 12px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  min-height: 280px;
  resize: vertical;
  white-space: pre-wrap;
  outline: none;
  transition: border-color 0.15s ease;
}

.agent-spec-prompt-input:focus {
  border-color: var(--accent);
}

.field-error {
  border-color: var(--error-text) !important;
}

/* Hidden raw editor (serialisation target) */
.agent-spec-editor {
  display: none;
}

/* -- Resize handle --------------------------------------------------------- */

.agent-spec-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  z-index: 5;
  background: linear-gradient(
    135deg,
    transparent 40%,
    var(--text-tertiary) 40%,
    var(--text-tertiary) 45%,
    transparent 45%,
    transparent 55%,
    var(--text-tertiary) 55%,
    var(--text-tertiary) 60%,
    transparent 60%,
    transparent 70%,
    var(--text-tertiary) 70%,
    var(--text-tertiary) 75%,
    transparent 75%
  );
  opacity: 0.5;
  border-radius: 0 0 16px 0;
  transition: opacity 0.15s ease;
}

.agent-spec-resize-handle:hover {
  opacity: 0.9;
}

.agent-spec-status {
  min-height: 18px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.agent-spec-status.error {
  color: var(--error-text);
}

.agent-spec-status.success {
  color: var(--accent);
}

.agent-spec-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.agent-spec-reset,
.agent-spec-save {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: var(--text-sm);
  cursor: pointer;
}

.agent-spec-reset {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.agent-spec-save {
  background: var(--accent);
  color: white;
}

.agent-spec-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* -----------------------------------------------------------------------------
   Settings - Radio Group for Trace Verbose Mode
   ----------------------------------------------------------------------------- */
.settings-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.settings-radio {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-radio:hover {
  background: var(--bg-secondary);
  border-color: var(--text-tertiary);
}

.settings-radio:has(input:checked) {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.05);
}

.settings-radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-check {
  position: relative;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s ease;
}

.settings-radio:has(input:checked) .radio-check {
  border-color: var(--accent);
}

.settings-radio:has(input:checked) .radio-check::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.radio-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-radio .radio-label {
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.settings-radio .radio-description {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* -----------------------------------------------------------------------------
   Settings - Mobile Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .settings-panel {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  
  .settings-content {
    flex-direction: column;
  }
  
  .settings-nav {
    width: 100%;
    flex-direction: row;
    padding: 8px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    gap: 4px;
  }
  
  .settings-nav-item {
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    font-size: 11px;
    white-space: nowrap;
  }
  
  .settings-nav-item svg {
    width: 20px;
    height: 20px;
  }
  
  .settings-body {
    padding: 16px;
  }
}

/* -----------------------------------------------------------------------------
   Trace Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .trace-container {
    margin-bottom: 8px;
  }
  
  .trace-content {
    max-height: 300px;
  }
  
  .tool-args pre,
  .tool-output-section pre {
    max-height: 150px;
  }
}
