/* ==========================================================================
   SLMAgents AI Chat Studio - Premium Modern Architecture
   Optimized for Mobile Touch Excellence & Desktop Precision
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --bg-app: #ffffff;
  --bg-sidebar: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-focus: #4f46e5;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  --primary-glow: rgba(79, 70, 229, 0.25);
  
  --sidebar-width: 260px;
  --chat-max-width: 820px;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   1. Application Shell
   ========================================================================== */

.chat-app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--bg-app);
}

/* ==========================================================================
   2. Left Sidebar (History & RAM telemetry)
   ========================================================================== */

.chat-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 12px;
  z-index: 60;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.25s ease;
  overflow: hidden;
}

.chat-sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.sidebar-logo-text {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.sidebar-icon-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.sidebar-action-icon:hover {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-subtle);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* History List */
.sidebar-history-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 6px;
}

.history-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.btn-clear-history {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.btn-clear-history:hover {
  color: #ef4444;
}

.chat-session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.chat-session-item:hover {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.chat-session-item.active {
  background: #ffffff;
  color: #4f46e5;
  font-weight: 700;
  border-color: #c7d2fe;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.08);
}

.chat-session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-session-delete,
.btn-del-session {
  opacity: 0.6;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.chat-session-item:hover .chat-session-delete,
.chat-session-item:hover .btn-del-session {
  opacity: 1;
}

.chat-session-delete:hover,
.btn-del-session:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* RAM Footprint */
.chat-sidebar-footer {
  margin-top: auto;
}

.ram-footprint-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.ram-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ram-badge-live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #059669;
}

.dot-green {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.ram-process-mb {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ram-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.ram-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.ram-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
}

.ram-runtime-tag {
  font-size: 0.66rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-purge-ram {
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-purge-ram:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

/* ==========================================================================
   3. Main Chat Canvas & Top Header
   ========================================================================== */

.chat-main-pane {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #ffffff;
  overflow: hidden;
}

.chat-top-actions {
  height: 54px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 30;
  flex-shrink: 0;
}

.top-actions-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-sidebar-toggle-clean {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sidebar-toggle-clean:hover {
  background: #f8fafc;
  color: var(--text-primary);
  border-color: #cbd5e1;
}

/* Agent Dropdown Pill */
.custom-agent-dropdown {
  position: relative;
}

.custom-agent-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.custom-agent-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.agent-btn-icon {
  display: flex;
  align-items: center;
  color: #4f46e5;
}

.agent-btn-text {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-btn-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.custom-agent-dropdown.open .agent-btn-chevron {
  transform: rotate(180deg);
}

.custom-agent-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 290px;
  max-height: 400px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 6px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-cat-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.dropdown-agent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

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

.dropdown-agent-item.selected {
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 700;
}

.dropdown-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-svg {
  display: flex;
  align-items: center;
  color: #4f46e5;
}

.dropdown-check-icon {
  color: #4f46e5;
}

.top-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-top-mobile-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--primary-gradient);
  color: #ffffff;
  border: none;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 6px var(--primary-glow);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-top-mobile-new:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-top-github-issue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-top-github-issue:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

/* ==========================================================================
   4. Chat Messages Stream Viewport
   ========================================================================== */

.chat-messages-viewport {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat-messages-viewport::-webkit-scrollbar {
  width: 6px;
}
.chat-messages-viewport::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Welcome Hero State */
.chat-welcome-hero {
  max-width: var(--chat-max-width);
  width: 100%;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 10px;
}

.welcome-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 20px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #4338ca;
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.hero-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.chat-welcome-hero h2 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-welcome-hero p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 540px;
  line-height: 1.55;
  margin-bottom: 24px;
}

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

.suggestion-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.suggestion-card:hover {
  transform: translateY(-2px);
  border-color: #a5b4fc;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.08);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon.code-icon { background: #e0e7ff; color: #4338ca; }
.card-icon.sql-icon { background: #dcfce7; color: #15803d; }
.card-icon.planner-icon { background: #fef3c7; color: #b45309; }
.card-icon.math-icon { background: #fce7f3; color: #be185d; }

.card-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.suggestion-card strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.suggestion-card p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

/* ==========================================================================
   5. Message Rows (User & Assistant)
   ========================================================================== */

.chat-msg-row {
  width: 100%;
  max-width: var(--chat-max-width);
  display: flex;
  gap: 12px;
  animation: fadeInMsg 0.2s ease-out;
}

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

/* User Message: Clean right-aligned pill */
.chat-msg-row.user {
  justify-content: flex-end;
}

.chat-msg-user-bubble {
  background: var(--primary-gradient);
  color: #ffffff;
  border-radius: 20px 20px 4px 20px;
  padding: 12px 18px;
  max-width: 82%;
  font-size: 0.93rem;
  line-height: 1.55;
  box-shadow: 0 4px 14px var(--primary-glow);
  word-break: break-word;
}

/* Assistant Message: Clean Avatar + Structured Body */
.chat-msg-row.assistant {
  justify-content: flex-start;
  align-items: flex-start;
}

.chat-assistant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4f46e5;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-assistant-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-assistant-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.assistant-agent-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 12px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #4f46e5;
  font-size: 0.73rem;
  font-weight: 700;
}

.tag-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.chat-assistant-content {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

.chat-assistant-content p {
  margin-bottom: 10px;
}
.chat-assistant-content p:last-child {
  margin-bottom: 0;
}

/* Code Block Wrapper */
.code-block-wrapper {
  margin: 12px 0;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid #21262d;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #161b22;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  color: #8b949e;
  border-bottom: 1px solid #21262d;
}

.code-copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #c9d1d9;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 9px;
  border-radius: 5px;
  transition: all 0.15s;
}

.code-copy-btn:hover {
  background: #6366f1;
  color: #ffffff;
  border-color: #6366f1;
}

.code-block-wrapper pre {
  margin: 0;
  padding: 14px 16px;
  background: #0d1117 !important;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  overflow-x: auto;
  color: #f0f6fc !important;
}

/* Reasoning Accordion */
.thought-accordion {
  display: inline-block;
  margin: 4px 0 8px 0;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  max-width: 100%;
}

.thought-header {
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}

.thought-header:hover {
  background: #eef2ff;
  color: #4f46e5;
}

.thought-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.thought-accordion.open .thought-chevron {
  transform: rotate(180deg);
}

.thought-content {
  display: none;
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
}

.thought-accordion.open .thought-content {
  display: block;
}

.thought-timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 8px;
  border-left: 2px solid #e2e8f0;
}

.thought-step {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Ghost Actions */
.chat-msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.btn-ghost-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost-action:hover {
  background: #f1f5f9;
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

/* Attachments */
.chat-msg-attachments {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.msg-att-img {
  max-width: 200px;
  max-height: 140px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  object-fit: cover;
}

.msg-att-file {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==========================================================================
   6. Live Reasoning Engine Card (Streaming State)
   ========================================================================== */

.live-engine-card {
  margin: 6px 0 10px 0;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  animation: fadeInMsg 0.2s ease-out;
}

.live-engine-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

.live-engine-title-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #4f46e5;
  font-size: 0.74rem;
  font-weight: 600;
}

.live-engine-title {
  color: #334155;
}

.live-engine-timer {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
}

.live-engine-timeline {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
}

.live-step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #475569;
  animation: fadeInMsg 0.15s ease-out;
}

.live-step-row.completed .live-step-text {
  color: #64748b;
}

.live-step-row.active .live-step-text {
  color: #0f172a;
  font-weight: 600;
}

.live-step-icon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f1f5f9;
}

.live-step-row.completed .live-step-icon {
  background: #ecfdf5;
}

.live-step-row.active .live-step-icon {
  background: #eef2ff;
}

.step-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid #c7d2fe;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ==========================================================================
   7. Floating Command Center / Input Dock
   ========================================================================== */

.chat-floating-dock-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 18px 16px;
  background: linear-gradient(to top, #ffffff 85%, rgba(255, 255, 255, 0) 100%);
  z-index: 40;
  gap: 8px;
}

.chat-command-form {
  width: 100%;
  max-width: var(--chat-max-width);
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  padding: 8px 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-command-form:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 12px 36px rgba(99, 102, 241, 0.16), 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.btn-dock-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-dock-icon:hover {
  background: #eef2ff;
  color: #4f46e5;
  border-color: #c7d2fe;
}

.chat-command-textarea {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  padding: 8px 6px;
  max-height: 140px;
  height: 38px;
}

.chat-command-textarea::placeholder {
  color: var(--text-muted);
}

.btn-dock-send {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--primary-gradient);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  box-shadow: 0 3px 12px var(--primary-glow);
}

.btn-dock-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px var(--primary-glow);
}

.btn-dock-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.chat-dock-footer {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   8. Mobile Responsive Drawer & Touch Layout (< 860px)
   ========================================================================== */

.chat-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.chat-sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

@media (max-width: 860px) {
  .chat-app-container {
    display: block !important;
    position: relative !important;
    width: 100vw !important;
    height: 100vh !important;
  }

  .chat-sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    width: min(290px, 86vw) !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    z-index: 1000 !important;
    margin-left: 0 !important;
    transform: translateX(-100%) !important;
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.28) !important;
    visibility: hidden;
    pointer-events: none;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  .chat-sidebar.open {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .ram-footprint-card {
    box-sizing: border-box !important;
    width: 100% !important;
  }

  .ram-header-row,
  .ram-detail-row,
  .ram-footer-actions {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }

  .chat-main-pane {
    width: 100vw !important;
    height: 100vh !important;
  }

  .chat-top-actions {
    padding: 0 10px !important;
    gap: 6px !important;
    height: 52px !important;
  }

  .top-actions-left {
    gap: 6px !important;
    min-width: 0 !important;
    flex: 1 !important;
  }

  .custom-agent-btn {
    max-width: 160px !important;
    padding: 4px 8px !important;
    height: 34px !important;
    white-space: nowrap !important;
  }

  .agent-btn-text {
    max-width: 95px !important;
    font-size: 0.74rem !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .top-actions-right {
    gap: 6px !important;
    flex-shrink: 0 !important;
  }

  .btn-top-mobile-new {
    height: 34px !important;
    padding: 0 8px !important;
    gap: 4px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
  }

  .btn-top-github-issue {
    height: 34px !important;
    padding: 0 8px !important;
    gap: 4px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
  }

  .chat-messages-viewport {
    padding: 14px 10px 135px !important;
    box-sizing: border-box !important;
  }

  .welcome-suggestions-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .chat-floating-dock-container {
    padding: 0 10px 12px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .chat-command-form {
    padding: 6px 8px !important;
    border-radius: 16px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .chat-command-textarea {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    word-break: break-word !important;
  }

  .chat-dock-footer {
    word-break: break-word !important;
    font-size: 0.62rem !important;
    text-align: center !important;
    line-height: 1.3 !important;
  }

  .btn-dock-icon {
    width: 32px !important;
    height: 32px !important;
  }

  .btn-dock-send {
    width: 34px !important;
    height: 34px !important;
  }
}

@media (max-width: 480px) {
  .chat-top-actions {
    padding: 0 8px !important;
    gap: 4px !important;
  }

  .top-actions-left {
    gap: 4px !important;
  }

  .custom-agent-btn {
    max-width: 145px !important;
    padding: 3px 6px !important;
  }

  .agent-btn-text {
    max-width: 80px !important;
    font-size: 0.72rem !important;
  }

  .top-actions-right {
    gap: 4px !important;
  }

  .btn-top-mobile-new {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 8px !important;
  }
  .btn-top-mobile-new .btn-text {
    display: none !important;
  }

  .btn-top-github-issue {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 8px !important;
  }
  .btn-top-github-issue .btn-text {
    display: none !important;
  }
}

/* ==========================================================================
   9. Attachments Tray, Voice Recording & Modals
   ========================================================================== */

.chat-attachments-tray {
  width: 100%;
  max-width: var(--chat-max-width);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 2px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
}

.btn-del-attachment {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.btn-del-attachment:hover {
  color: #ef4444;
}

.chat-voice-recording-bar {
  width: 100%;
  max-width: var(--chat-max-width);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.recording-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: pulseRec 1s infinite;
}

@keyframes pulseRec {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.recording-text {
  font-size: 0.82rem;
  font-weight: 600;
  flex: 1;
}

.btn-voice-cancel {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-voice-done {
  background: var(--primary-gradient);
  border: none;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
}

/* GitHub Issue Modal */
.chat-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-issue-modal-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.issue-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: #fafafa;
}

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

.issue-github-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.issue-modal-title h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.issue-modal-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-close-modal:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

.issue-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 65vh;
  overflow-y: auto;
}

.issue-form-row {
  display: flex;
  gap: 14px;
}

.issue-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.issue-form-group.half {
  flex: 1;
}

.issue-form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.issue-input,
.issue-select,
.issue-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.issue-textarea {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  resize: vertical;
  line-height: 1.5;
}

.issue-input:focus,
.issue-select:focus,
.issue-textarea:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.issue-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: #fafafa;
}

.btn-issue-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-issue-secondary:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

.btn-issue-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 8px;
  background: #0f172a;
  border: 1px solid #0f172a;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-issue-primary:hover {
  background: #1e293b;
}
