/* ==========================================================================
   R-AI Production Design System & Dark Velvet Cosmic Theme
   ========================================================================== */

:root {
  /* Pitch Black Cosmic Dark Palette */
  --bg-canvas: #020408;
  --bg-deep: #050812;
  --bg-card: #080d1a;
  --bg-card-hover: #0d1527;
  --bg-elevated: #0f182c;
  --bg-surface: #141f36;
  
  /* Text & Contrast */
  --text-highlight: #ffffff;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-inverse: #020408;

  /* Vibrant Accents */
  --accent-cyan: #00f0ff;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  /* Borders & Shadows */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(0, 240, 255, 0.35);
  --border-glow-purple: rgba(139, 92, 246, 0.4);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.9);
  --shadow-glow: 0 0 30px rgba(0, 240, 255, 0.15);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing & Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --sidebar-width: 270px;
  --sidebar-collapsed-width: 68px;
  --header-height: 56px;
  --tabs-height: 48px;
}

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

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

/* Background Cosmic Canvas */
.cosmic-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 50% 10%, #0a1124 0%, #020408 75%);
}

.cosmic-stars {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,0.4), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 140px 90px, rgba(0, 240, 255, 0.6), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 260px 220px, rgba(139, 92, 246, 0.4), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 450px 120px, rgba(255,255,255,0.3), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 600px 350px, rgba(0, 240, 255, 0.5), rgba(0,0,0,0));
  background-size: 650px 650px;
  opacity: 0.65;
}

/* Main App Shell Layout */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-deep);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.2, 0, 0, 1), transform 0.25s ease;
  z-index: 30;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #00f0ff 0%, #3b82f6 50%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.4);
}

.brand-title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.5px;
  color: var(--text-highlight);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge {
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.4);
  color: var(--accent-cyan);
  font-weight: 700;
}

.sidebar-actions {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--border-medium);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-new-chat:hover {
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
  transform: translateY(-1px);
}

.provider-history-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.active-history-filter-pill {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

.search-container {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-cyan);
  background: rgba(0, 0, 0, 0.8);
}

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  position: relative;
}

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

.conversation-item.active {
  background: var(--bg-elevated);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--text-highlight);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.conversation-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 6px;
}

.conversation-item-meta {
  display: flex;
  align-items: center;
  gap: 4px;
}

.provider-tag {
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  text-transform: uppercase;
}

.btn-delete-conv {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: opacity 0.15s, color 0.15s;
}

.conversation-item:hover .btn-delete-conv {
  opacity: 1;
}

.btn-delete-conv:hover {
  color: var(--accent-red);
}

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

/* ==========================================================================
   Main Content & Provider Tabs
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  position: relative;
  background: var(--bg-canvas);
}

.top-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  z-index: 20;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-selector-wrapper {
  position: relative;
}

.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-highlight);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.model-selector-btn:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-elevated);
}

.model-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.btn-header-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-header-action:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-highlight);
  border-color: var(--border-medium);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.btn-icon:hover {
  color: var(--text-highlight);
  background: rgba(255, 255, 255, 0.06);
}

/* Dedicated Provider Workspace Ribbon / Tabs */
.provider-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  background: #03060d;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.provider-tabs-bar::-webkit-scrollbar {
  display: none;
}

.provider-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.provider-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-highlight);
  border-color: rgba(255, 255, 255, 0.18);
}

.provider-tab.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2) 0%, rgba(59, 130, 246, 0.15) 100%);
  border-color: var(--accent-cyan);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

.tab-icon {
  font-size: 0.95rem;
}

/* ==========================================================================
   Chat Thread & Message Rendering
   ========================================================================== */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 10px;
  margin: auto 0;
}

.welcome-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 30% 30%, #00f0ff, #1e1b4b 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.4);
  margin-bottom: 18px;
}

.welcome-title {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: #fff;
  margin-bottom: 8px;
}

.welcome-title span {
  background: linear-gradient(135deg, #00f0ff 0%, #38bdf8 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-desc {
  font-size: 0.96rem;
  color: var(--text-muted);
  max-width: 580px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.provider-chips-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 700px;
  margin-bottom: 30px;
}

.provider-chip {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.quick-prompts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 760px;
}

.quick-prompt-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.quick-prompt-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.quick-prompt-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.quick-prompt-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Message Rows */
.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
  animation: fadeIn 0.2s ease-out;
}

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

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

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  color: var(--accent-cyan);
}

.message-row.user .message-avatar {
  background: linear-gradient(135deg, #3b82f6 0%, #1e1b4b 100%);
  color: #fff;
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 82%;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.68;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, #1e2540 0%, #111827 100%);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #ffffff;
  border-bottom-right-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.message-row.assistant .message-bubble {
  background: #080d1a;
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #f1f5f9;
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7);
}

/* Deep Reasoning Panel */
.reasoning-panel {
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.07);
  border: 1px solid rgba(139, 92, 246, 0.25);
  margin-bottom: 6px;
  overflow: hidden;
}

.reasoning-panel.streaming-active {
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
  animation: pulsePanel 2s ease-in-out infinite;
}

@keyframes pulsePanel {
  0%, 100% { border-color: rgba(139, 92, 246, 0.4); }
  50% { border-color: rgba(139, 92, 246, 0.8); }
}

.reasoning-header {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #c084fc;
  cursor: pointer;
  user-select: none;
  background: rgba(139, 92, 246, 0.1);
}

.reasoning-content {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  border-top: 1px solid rgba(139, 92, 246, 0.15);
  background: rgba(0, 0, 0, 0.35);
  max-height: 280px;
  overflow-y: auto;
}

/* Streaming Typewriter Cursor */
.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 16px;
  background: var(--accent-cyan);
  border-radius: 2px;
  margin-left: 4px;
  vertical-align: -2px;
  box-shadow: 0 0 10px var(--accent-cyan), 0 0 4px #fff;
  animation: cursorBlink 0.75s ease-in-out infinite;
}

.reasoning-cursor {
  background: #c084fc;
  box-shadow: 0 0 10px #c084fc;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; transform: scaleY(1); }
  50% { opacity: 0.2; transform: scaleY(0.65); }
}

/* Sources & Citations */
.sources-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.25);
  color: var(--accent-cyan);
  font-size: 0.74rem;
  text-decoration: none;
  transition: all 0.15s ease;
}

.source-chip:hover {
  background: rgba(0, 240, 255, 0.18);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

/* Code Blocks */
.code-block-wrapper {
  margin: 12px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #020409;
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #090e1c;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.btn-copy-code {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-copy-code:hover {
  color: var(--accent-cyan);
}

pre code {
  display: block;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: #e2e8f0;
  overflow-x: auto;
}

/* Generated AI Image Cards (No Raw Links!) */
.generated-image-container {
  margin: 14px 0;
}

.generated-image-card {
  display: inline-block;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #03060f;
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 240, 255, 0.15);
  max-width: 480px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.generated-image-card:hover {
  transform: scale(1.01);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 240, 255, 0.3);
}

.ai-generated-image {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
}

.image-card-caption {
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: #070c18;
  border-top: 1px solid var(--border-subtle);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.image-card-link {
  color: var(--accent-cyan);
  text-decoration: none;
  font-size: 0.75rem;
  margin-left: 8px;
  transition: opacity 0.15s;
}

.image-card-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.chat-inline-link {
  color: var(--accent-cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
}

.chat-inline-link:hover {
  opacity: 0.8;
}

/* User Attached Images in Messages */
.message-attachments-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.user-attached-image-wrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  max-width: 260px;
  max-height: 220px;
  background: #000;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.user-attached-image-wrapper:hover {
  transform: scale(1.02);
  border-color: var(--accent-cyan);
}

.user-attached-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-attached-image-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  font-size: 0.7rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-main);
}

/* ==========================================================================
   Composer / Input Box
   ========================================================================== */
.composer-wrapper {
  padding: 0 20px 20px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 10;
}

.composer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.composer-card:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9), 0 0 25px rgba(0, 240, 255, 0.15);
}

.composer-card.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.05);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
}

.composer-attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.composer-thumb-card {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-medium);
  background: #000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.composer-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.composer-thumb-info {
  display: none;
}

.composer-file-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-main);
}

.btn-remove-attachment {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.composer-file-card .btn-remove-attachment {
  position: static;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  background: transparent;
  border: none;
  color: var(--text-dim);
}

.btn-remove-attachment:hover {
  background: var(--accent-red);
  color: #fff;
  transform: scale(1.1);
}

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.composer-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  resize: none;
  max-height: 180px;
  line-height: 1.5;
}

.composer-textarea::placeholder {
  color: var(--text-dim);
}

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #00f0ff 0%, #3b82f6 100%);
  border: none;
  color: #020408;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.5);
}

.composer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.composer-tools-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-toggle-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.07);
}

.tool-toggle-btn.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* ==========================================================================
   Modals & Drawers
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 8, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.credentials-modal-card {
  max-width: 880px;
  height: 640px;
}

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

.modal-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

/* 2-Column Cookies & Tokens Manager Layout */
.credentials-modal-layout {
  display: flex;
  gap: 0;
  padding: 0 !important;
  height: calc(100% - 53px);
}

.cred-sidebar {
  width: 220px;
  background: #040710;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 10px 8px;
  gap: 4px;
}

.cred-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  font-size: 0.84rem;
  transition: all 0.15s ease;
}

.cred-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.cred-nav-item.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.35);
  color: #fff;
  font-weight: 600;
}

.cred-editor-pane {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: #03060c;
  border: 1px solid var(--border-medium);
  color: #fff;
  font-size: 0.86rem;
  outline: none;
  font-family: var(--font-mono);
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.form-help {
  font-size: 0.74rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.status-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.status-pill.valid {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--accent-green);
}

.status-pill.guest {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: var(--accent-blue);
}

.status-pill.invalid, .status-pill.expired {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--accent-red);
}

.status-pill.unknown {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-dim);
}

/* ==========================================================================
   Full-Screen Authentication Gate (Login Screen)
   ========================================================================== */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(10, 16, 30, 0.96), #020408 95%);
  backdrop-filter: blur(25px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  animation: fadeIn 0.3s ease-out;
}

.auth-gate-card {
  width: 100%;
  max-width: 440px;
  background: rgba(8, 13, 24, 0.95);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 36px 30px 28px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), 0 0 50px rgba(0, 240, 255, 0.18);
  text-align: center;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-gate-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-highlight);
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.auth-gate-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.auth-gate-input {
  padding: 12px 42px 12px 14px !important;
  font-size: 0.95rem !important;
  letter-spacing: 0.5px;
  background: rgba(2, 4, 8, 0.9) !important;
}

.auth-gate-error {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
  font-size: 0.8rem;
  text-align: left;
}

/* ==========================================================================
   Models Hub Modal & Cards
   ========================================================================== */
.models-hub-modal-card {
  max-width: 980px;
  height: 720px;
}

.models-hub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: #040711;
  border-bottom: 1px solid var(--border-subtle);
}

.models-hub-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.models-filter-chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.models-filter-chip:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.models-filter-chip.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.models-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.model-hub-card {
  background: #060a16;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.model-hub-card:hover {
  background: #091024;
  border-color: rgba(0, 240, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 240, 255, 0.1);
}

.model-hub-card.active-model {
  border-color: var(--accent-cyan);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08) 0%, #060a16 100%);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.2);
}

.model-hub-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.model-hub-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.model-hub-card-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-cyan);
  margin-top: 2px;
}

.model-hub-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.model-hub-card-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cap-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 3px;
}

.cap-badge.active {
  background: rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.25);
  color: var(--accent-cyan);
}

.cap-badge.reasoning {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.cap-badge.context {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
  color: #34d399;
  font-family: var(--font-mono);
}

.btn-select-model-hub {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-select-model-hub:hover {
  background: linear-gradient(135deg, #00f0ff 0%, #3b82f6 100%);
  color: #020408;
  border-color: transparent;
  font-weight: 700;
}

.model-hub-card.active-model .btn-select-model-hub {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
