/* static/css/chat.css - Apolynx AI Clean White Theme (Anthropic Modular LLM Architecture) */
:root {
  --chat-bg: #ffffff;
  --sidebar-bg: #f8fafc;
  --panel-bg: #ffffff;
  --panel-card: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-accent: rgba(217, 119, 87, 0.4);
  --border-card: #e2e8f0;
  
  --claude-accent: #d97757;
  --claude-light: #e88d71;
  --claude-dark: #b85a3c;
  --anthropic-gold: #c25734;
  --tech-cyan: #0284c7;
  --tech-emerald: #059669;

  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-subtle: #64748b;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

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

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

/* Chat Layout Container */
.chat-app-wrap {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  background: #ffffff;
  overflow: hidden;
}

/* Sidebar */
.chat-sidebar {
  width: 290px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 50;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #0f172a;
}

.sidebar-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.25);
}

.sidebar-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.sidebar-new-btn-wrap {
  padding: 16px 18px;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-md);
  color: #c25734;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(217, 119, 87, 0.08);
}

.btn-new-chat:hover {
  background: #ffedd5;
  border-color: var(--claude-accent);
  color: var(--claude-dark);
  transform: translateY(-1px);
}

.sidebar-history-pane {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}

.history-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  font-weight: 700;
  padding: 10px 8px 6px;
}

.history-list {
  list-style: none;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 3px;
}

.history-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.history-item.active {
  background: #fff7ed;
  color: #c25734;
  font-weight: 700;
  border-left: 3px solid var(--claude-accent);
}

.history-topic-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 6px;
  flex: 1;
}

.history-actions-wrap {
  display: none;
  align-items: center;
  gap: 2px;
}

.history-item:hover .history-actions-wrap,
.history-item.active .history-actions-wrap {
  display: flex;
}

.history-action-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 3px 5px;
  font-size: 0.8rem;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.history-action-btn:hover {
  color: #0f172a;
  background: #e2e8f0;
}

.history-action-btn.delete:hover {
  color: #ef4444;
  background: #fee2e2;
}

.history-action-btn.share:hover {
  color: var(--claude-accent);
  background: #fff7ed;
}

.history-action-btn.edit:hover {
  color: #0284c7;
  background: #f0f9ff;
}

/* Inline Rename Editor */
.history-edit-box {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.history-edit-input {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  font-size: 0.82rem;
  border: 1.5px solid var(--claude-accent);
  border-radius: 4px;
  outline: none;
  color: #0f172a;
  background: #ffffff;
  font-family: inherit;
}

.history-edit-confirm, .history-edit-cancel {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 3px 5px;
  font-size: 0.8rem;
  border-radius: 4px;
}

.history-edit-confirm { color: #059669; }
.history-edit-confirm:hover { background: #ecfdf5; }
.history-edit-cancel { color: #dc2626; }
.history-edit-cancel:hover { background: #fee2e2; }

/* User Card in Sidebar Footer */
.sidebar-user-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: #f8fafc;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.user-card:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--claude-accent), #c25734);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.user-email {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.user-verified-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.user-signout-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.user-signout-btn:hover {
  color: #ef4444;
  background: #fee2e2;
}

/* Sidebar Sign In Button for unauthenticated state */
.sidebar-signin-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sidebar-signin-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.sidebar-signin-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Main Chat Workspace */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: #f8fafc;
  border-left: 1px solid #cbd5e1;
  box-shadow: -4px 0 18px rgba(15, 23, 42, 0.04);
  min-width: 0;
}

/* Chat Topbar */
.chat-topbar {
  height: 68px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 40;
  position: relative;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}

.sidebar-toggle-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Model Selector Dropdown & Switcher */
.model-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-picker-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.model-select-dropdown {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.model-select-dropdown:focus, .model-select-dropdown:hover {
  border-color: var(--claude-accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}

.model-select-dropdown option {
  background: #ffffff;
  color: #0f172a;
}

/* Centrally Placed Large Title & Cluster Status */
.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 0 12px;
  min-width: 0;
}

.topbar-modular-title {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #0f172a;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  white-space: nowrap;
}

.topbar-title-tag {
  font-size: 0.65rem;
  font-weight: 800;
  color: #c25734;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.08em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.cluster-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 50px;
  font-size: 0.82rem;
  color: #047857;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.08);
  white-space: nowrap;
  user-select: none;
}

.cluster-status-chip .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-chip 2s infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes pulse-chip {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Topbar Sign In Button */
.btn-topbar-signin {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.btn-topbar-signin:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* Share Button in Topbar */
.btn-topbar-share {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: var(--radius-sm);
  color: #c25734;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-topbar-share:hover {
  background: #ffedd5;
  border-color: var(--claude-accent);
  color: #9a3412;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(217, 119, 87, 0.18);
}

.btn-topbar-share i {
  font-size: 0.86rem;
}

/* High-Contrast Visible Overview Button (Fixed) */
.btn-topbar-overview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-topbar-overview:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.btn-topbar-overview i {
  color: var(--claude-accent);
  font-size: 0.88rem;
}

/* Chat Messages Flow Area */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(180deg, #fafbfd 0%, #f4f6f9 100%);
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.04);
}

.chat-inner-bounds {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chat-inner-bounds:empty {
  display: none;
}

/* Empty State / Welcome Screen */
.welcome-screen {
  text-align: center;
  padding: 10px 18px;
  margin: auto;
  max-width: 680px;
  width: 100%;
}

.welcome-logo-wrap {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

.welcome-logo-wrap::before {
  content: "";
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(217, 119, 87, 0.25) 0%, rgba(217, 119, 87, 0.08) 45%, rgba(217, 119, 87, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.welcome-logo {
  position: relative;
  z-index: 1;
  width: 76px;
  height: 76px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1), 0 4px 14px rgba(217, 119, 87, 0.3);
  overflow: hidden;
}

.welcome-brand-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 16px;
  border-radius: 9999px;
  background: #ffffff;
  border: 1.5px solid rgba(217, 119, 87, 0.4);
  box-shadow: 0 2px 10px rgba(217, 119, 87, 0.1);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--claude-accent, #c05621);
}

.welcome-brand-badge .badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.7);
  display: inline-block;
}

.welcome-title {
  font-size: clamp(1.55rem, 2.7vw, 2.05rem);
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 4px;
}

.welcome-release-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  margin-bottom: 12px;
  border-radius: 9999px;
  background: rgba(217, 119, 87, 0.06);
  border: 1px solid rgba(217, 119, 87, 0.24);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #b45333;
}

.welcome-release-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--claude-accent, #d97757);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.18);
  flex-shrink: 0;
}

.welcome-from-word {
  display: block;
  font-family: 'Times New Roman', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  color: #475569;
  opacity: 0.78;
  margin: 4px 0 4px;
}

.welcome-brand-anthropic {
  color: var(--claude-accent);
  font-family: 'Cinzel', 'Times New Roman', serif;
  letter-spacing: 0.38em;
  padding-left: 0.38em;
  font-weight: 700;
  text-align: center;
  width: 100%;
  text-transform: uppercase;
  margin-bottom: 0;
}

.welcome-hairline {
  width: 64px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217, 119, 87, 0.55), transparent);
  margin: 14px auto 12px;
}

.welcome-subtitle {
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.58;
  max-width: 600px;
  margin: 0 auto 12px;
  font-weight: 400;
}

.welcome-subtitle-lead {
  display: block;
  font-family: 'Times New Roman', Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  color: #1e293b;
  letter-spacing: 0.015em;
  margin-bottom: 6px;
}

.welcome-subtitle strong {
  color: #0f172a;
  font-weight: 600;
}

.welcome-subtitle .welcome-accent-term {
  color: #b45333;
  font-weight: 600;
}

.welcome-pillars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 12px;
  margin: 0 auto 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  max-width: 600px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
}

.welcome-pillar-sep {
  color: var(--claude-accent, #d97757);
  opacity: 0.65;
  font-size: 0.85rem;
  line-height: 1;
}

.welcome-exp-note {
  max-width: 600px;
  margin: 0 auto 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(217, 119, 87, 0.05);
  border: 1px solid rgba(217, 119, 87, 0.2);
  font-size: 0.78rem;
  line-height: 1.48;
  color: #475569;
  text-align: center;
}

.welcome-exp-note .welcome-note-label {
  color: #b45333;
  font-weight: 700;
  letter-spacing: 0.02em;
}

@media (max-height: 780px) {
  .chat-messages-container {
    padding: 8px 20px;
  }
  .welcome-screen {
    padding: 4px 14px;
  }
  .welcome-release-tag {
    margin-bottom: 8px;
    padding: 3px 12px;
  }
  .welcome-title {
    font-size: clamp(1.35rem, 2.3vw, 1.75rem);
  }
  .welcome-hairline {
    margin: 9px auto 8px;
  }
  .welcome-subtitle {
    font-size: 0.84rem;
    line-height: 1.48;
    margin-bottom: 8px;
  }
  .welcome-subtitle-lead {
    font-size: 0.92rem;
    margin-bottom: 4px;
  }
  .welcome-pillars {
    padding-top: 8px;
    margin-bottom: 8px;
    font-size: 0.66rem;
  }
  .welcome-exp-note {
    padding: 6px 12px;
    font-size: 0.74rem;
    line-height: 1.4;
    margin-bottom: 6px;
  }
}

.prompt-suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  text-align: left;
}

.suggestion-card {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.suggestion-card:hover {
  background: #ffffff;
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(217, 119, 87, 0.15);
}

.suggestion-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--claude-accent);
  font-weight: 800;
  margin-bottom: 6px;
}

.suggestion-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-weight: 500;
}

/* Individual Message Rows */
.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
}

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

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 800;
  overflow: hidden;
}

.msg-avatar.ai {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.25);
}

.msg-avatar.user {
  background: #0f172a;
  color: #fff;
  border-radius: 50%;
}

.msg-content-wrap {
  max-width: 88%;
}

.msg-bubble {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 0.94rem;
  line-height: 1.65;
}

.message-row.user .msg-bubble {
  background: #0f172a;
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

/* User Message Content Wrap & Action Bar */
.message-row.user .msg-content-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 82%;
}

.user-msg-action-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
  opacity: 0.35;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.message-row.user:hover .user-msg-action-bar,
.message-row.user:focus-within .user-msg-action-bar {
  opacity: 1;
}

.user-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.user-action-btn:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.user-action-btn.btn-edit-msg:hover i {
  color: #d97706;
}

.user-action-btn.btn-copy-user-msg:hover i {
  color: #2563eb;
}

.user-action-btn.btn-load-input-msg:hover i {
  color: #059669;
}

.user-msg-edited-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 6px;
  font-style: italic;
  font-family: var(--font-mono);
}

/* In-place Question Edit Container */
.user-edit-container {
  width: 100%;
  min-width: 290px;
  max-width: 680px;
  background: #ffffff;
  border: 1.5px solid #d97706;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
  animation: fadeIn 0.2s ease;
}

.user-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #b45309;
}

.user-edit-tip {
  font-size: 0.7rem;
  font-weight: 500;
  color: #64748b;
}

.user-edit-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.user-edit-textarea:focus {
  border-color: #d97706;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.user-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.user-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.user-edit-btn.cancel {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
}

.user-edit-btn.cancel:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.user-edit-btn.save {
  background: #d97706;
  border: 1px solid #b45309;
  color: #ffffff;
}

.user-edit-btn.save:hover {
  background: #b45309;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.25);
}

.message-row.assistant .msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid var(--border-subtle);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.msg-header-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.76rem;
  color: var(--text-subtle);
}

.msg-model-badge {
  padding: 3px 9px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: #fff7ed;
  color: #c25734;
  border: 1px solid #fed7aa;
}

/* Dual Consensus Split Bubble */
.dual-consensus-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 10px;
}

.dual-node-pane {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dual-node-pane.streaming {
  border-color: var(--claude-accent);
  box-shadow: 0 0 16px rgba(217, 119, 87, 0.18);
  background: #ffffff;
}

.dual-node-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 700;
}

.dual-pane-body {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
  flex: 1;
}

.single-stream-body {
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* Real-Time Hardware Streaming Styles */
.streaming-cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background-color: var(--claude-accent);
  margin-left: 3px;
  vertical-align: middle;
  border-radius: 1px;
  animation: cursorBlink 0.75s infinite;
}

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

.streaming-status-tag {
  font-size: 0.72rem;
  color: #c25734;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

/* Floating Stop Streaming Button */
.stop-stream-btn-wrap {
  position: sticky;
  bottom: 14px;
  display: flex;
  justify-content: center;
  z-index: 60;
  margin-bottom: 6px;
  pointer-events: none;
}

.btn-stop-streaming {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  background: #ffffff;
  color: #dc2626;
  border: 1.5px solid #fecaca;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px -4px rgba(220, 38, 38, 0.25), 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  animation: stopButtonBounce 0.3s ease-out;
}

@keyframes stopButtonBounce {
  from { transform: translateY(12px) scale(0.92); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.btn-stop-streaming:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #b91c1c;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -4px rgba(220, 38, 38, 0.35);
}

.stop-icon-pulse {
  width: 18px;
  height: 18px;
  background: #fee2e2;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #dc2626;
  font-size: 0.75rem;
  animation: stopPulse 1.2s infinite;
}

@keyframes stopPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ──────────────────────────────────────────────────────────────────────
   Message Action Toolbar (Copy, WhatsApp, Print) with Fancy Animated Icons
   ────────────────────────────────────────────────────────────────────── */
.msg-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  flex-wrap: wrap;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.msg-action-btn:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.msg-action-btn:active {
  transform: translateY(0);
}

.msg-action-btn i {
  font-size: 0.84rem;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s;
}

.msg-action-btn:hover i {
  transform: scale(1.18);
}

.msg-action-btn.btn-copy-msg:hover i {
  color: var(--claude-accent);
}

.msg-action-btn.btn-whatsapp-msg:hover {
  border-color: #86efac;
  background: #f0fdf4;
  color: #15803d;
}

.msg-action-btn.btn-whatsapp-msg i {
  color: #22c55e;
}

.msg-action-btn.btn-print-msg:hover {
  border-color: #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
}

.msg-action-btn.btn-print-msg i {
  color: #0284c7;
}

.msg-action-btn.btn-share-msg:hover {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.msg-action-btn.btn-share-msg i {
  color: var(--claude-accent);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.msg-action-btn.btn-share-msg:hover i {
  transform: rotate(18deg) scale(1.25);
}

.msg-action-btn.copied {
  background: #ecfdf5 !important;
  border-color: #a7f3d0 !important;
  color: #059669 !important;
}

.msg-action-btn.copied i {
  color: #059669 !important;
  animation: checkPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes checkPop {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1.1); }
}

/* ──────────────────────────────────────────────────────────────────────
   Code Blocks in Separate Copyable Area
   ────────────────────────────────────────────────────────────────────── */
.code-block-container {
  margin: 14px 0;
  border-radius: var(--radius-md);
  border: 1px solid #1e293b;
  background: #0f172a;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.14);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: #94a3b8;
}

.code-lang-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--claude-light);
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #cbd5e1;
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.code-copy-btn.copied {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
  color: #34d399;
}

.code-copy-btn.copied i {
  animation: checkPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.code-pre {
  margin: 0;
  padding: 14px 16px;
  background: transparent;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  color: #f8fafc;
}

.code-pre code {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  color: inherit !important;
  font-family: inherit;
}

.inline-code {
  font-family: var(--font-mono);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #0f172a;
}

/* Bottom Chat Input Bar */
.chat-input-bar-wrap {
  padding: 12px 24px 10px;
  background: linear-gradient(180deg, #f1f5f9 0%, #eaeef5 100%);
  border-top: 1.5px solid #cbd5e1;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.05);
  position: relative;
  z-index: 30;
}

.input-box-shell {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #ffffff;
  border: 1.5px solid #94a3b8;
  border-radius: var(--radius-lg);
  padding: 10px 12px 10px 18px;
  min-height: 76px;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.09), 0 2px 6px rgba(15, 23, 42, 0.05), inset 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.input-box-shell:hover {
  border-color: #64748b;
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
}

.input-box-shell:focus-within {
  border-color: var(--claude-accent);
  box-shadow: 0 0 0 3.5px rgba(217, 119, 87, 0.18), 0 8px 24px rgba(217, 119, 87, 0.12);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: #0f172a;
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 54px;
  max-height: 220px;
  padding: 3px 0;
}

.chat-textarea::placeholder {
  color: #64748b;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--claude-accent), #c25734);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: linear-gradient(135deg, var(--claude-light), var(--claude-accent));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.35);
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-footer-disclaimer {
  max-width: 860px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-subtle);
  font-weight: 500;
}

/* Floating Scroll to Bottom Button */
.btn-scroll-bottom {
  position: absolute;
  bottom: 84px;
  right: 28px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 45;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-scroll-bottom:hover {
  background: #f8fafc;
  border-color: var(--claude-accent);
  color: var(--claude-accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(217, 119, 87, 0.22);
}

.btn-scroll-bottom i {
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 900px) {
  .topbar-modular-title {
    font-size: 0.95rem;
  }
  .topbar-title-tag {
    display: none;
  }
  .dual-consensus-view {
    grid-template-columns: 1fr;
  }
}

/* Share Conversation Modal Styles */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeInModal 0.2s ease-out;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

.share-modal-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px -8px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  animation: scaleUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUpModal {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.share-modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.share-modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff7ed;
  color: #c25734;
  border: 1px solid #fed7aa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.share-modal-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 2px;
}

.share-modal-topic {
  font-size: 0.78rem;
  color: #64748b;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
}

.share-modal-close:hover {
  color: #0f172a;
  background: #e2e8f0;
}

.share-modal-body {
  padding: 22px;
}

.share-field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.share-mode-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-mode-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.2s ease;
}

.share-mode-opt:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.share-mode-opt.active {
  border-color: var(--claude-accent);
  background: #fffbf9;
  box-shadow: 0 0 0 1px var(--claude-accent);
}

.mode-opt-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.mode-opt-icon.lock { background: #fef3c7; color: #d97706; }
.mode-opt-icon.eye { background: #eff6ff; color: #2563eb; }
.mode-opt-icon.chat { background: #f0fdf4; color: #16a34a; }

.mode-opt-details {
  flex: 1;
}

.mode-opt-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.mode-opt-desc {
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.35;
}

.mode-opt-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 0.72rem;
  transition: all 0.2s;
}

.share-mode-opt.active .mode-opt-check {
  background: var(--claude-accent);
  border-color: var(--claude-accent);
  color: #ffffff;
}

.share-input-group {
  display: flex;
  gap: 8px;
}

.share-url-input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: #0f172a;
  background: #f8fafc;
  outline: none;
}

.btn-copy-share-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: #0f172a;
  border: 1px solid #0f172a;
  color: #ffffff;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-copy-share-url:hover {
  background: #1e293b;
}

.btn-copy-share-url.copied {
  background: #059669 !important;
  border-color: #059669 !important;
}

.share-app-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-share-app {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-share-app.whatsapp {
  color: #15803d;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.btn-share-app.whatsapp:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.btn-share-app.whatsapp i { font-size: 1.1rem; }

.btn-share-app.native {
  color: #0369a1;
  border-color: #bae6fd;
  background: #f0f9ff;
}

.btn-share-app.native:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.share-status-toast {
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  animation: fadeInModal 0.2s ease;
}

/* ──────────────────────────────────────────────────────────────────────
   Auth Gate Card for Welcome Screen
   ────────────────────────────────────────────────────────────────────── */
.auth-gate-card {
  max-width: 600px;
  margin: 10px auto 6px;
  padding: 14px 18px;
  background: #ffffff;
  border: 1.5px solid #fed7aa;
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(217, 119, 87, 0.1);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: stopButtonBounce 0.35s ease-out;
}

.auth-gate-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.auth-gate-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff7ed;
  color: var(--claude-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.auth-gate-text-wrap {
  flex: 1;
}

.auth-gate-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.auth-gate-desc {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.55;
}

.btn-auth-gate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  background: #0f172a;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
}

.btn-auth-gate:hover {
  background: #1e293b;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.3);
}

/* ──────────────────────────────────────────────────────────────────────
   Legal Disclaimer Button in Footer
   ────────────────────────────────────────────────────────────────────── */
.btn-legal-disclaimer {
  background: none;
  border: none;
  padding: 0;
  color: #475569;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  transition: color 0.2s ease;
}

.btn-legal-disclaimer:hover {
  color: var(--claude-accent);
}

/* ──────────────────────────────────────────────────────────────────────
   Legal Protection & Liability Disclaimer Modal
   ────────────────────────────────────────────────────────────────────── */
.legal-modal-card {
  max-width: 680px;
  width: 92%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.25);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.legal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.legal-modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff7ed;
  color: var(--claude-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.legal-modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}

.legal-modal-subtitle {
  font-size: 0.74rem;
  color: #64748b;
  margin: 2px 0 0;
  font-weight: 600;
}

.legal-modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  line-height: 1.6;
}

.legal-notice-callout {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 14px 18px;
  color: #9a3412;
  font-size: 0.84rem;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  line-height: 1.55;
}

.legal-notice-callout i {
  color: #ea580c;
  font-size: 1.1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.legal-clauses-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legal-clause {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 18px;
}

.legal-clause h4 {
  font-size: 0.86rem;
  font-weight: 750;
  color: #0f172a;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.legal-clause h4 i {
  color: var(--claude-accent);
  font-size: 0.82rem;
}

.legal-clause p {
  font-size: 0.82rem;
  color: #475569;
  margin: 0;
  line-height: 1.55;
}

.legal-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  background: #f8fafc;
}

.btn-legal-accept {
  padding: 10px 22px;
  background: var(--claude-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(217, 119, 87, 0.25);
}

.btn-legal-accept:hover {
  background: #c25734;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.35);
}

/* Sidebar Close Button & Mobile Backdrop */
.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: #64748b;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
  line-height: 1;
}

.sidebar-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ─── MOBILE VIEW STYLING (PERFECT MOBILE RESPONSIVENESS & PROPORTIONS) ───── */
@media (max-width: 768px) {
  /* Mobile Sidebar Drawer - Slide In with Close Controls */
  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 295px;
    max-width: 84vw;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 14px 0 40px rgba(0, 0, 0, 0.32);
    background: #ffffff;
    display: flex;
    flex-direction: column;
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    border-bottom: 1px solid #e2e8f0;
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
  }

  .sidebar-toggle-btn {
    display: inline-flex;
    padding: 7px 9px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    font-size: 0.95rem;
    flex-shrink: 0;
  }

  .sidebar-history-pane {
    -webkit-overflow-scrolling: touch;
  }

  /* Chat Topbar on Mobile: Compact & Guaranteed Fit */
  .chat-main {
    border-left: none;
    box-shadow: none;
  }

  .chat-topbar {
    height: 48px;
    padding: 0 8px;
    gap: 6px;
  }

  .topbar-left {
    gap: 6px;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
  }

  .model-picker-wrap {
    flex: 1;
    min-width: 0;
    max-width: 105px;
    gap: 0;
    margin-left: 0 !important;
  }

  .model-picker-wrap > span {
    display: none !important;
  }

  .model-select-dropdown {
    font-size: 0.72rem;
    padding: 4px 6px;
    width: 100%;
    min-width: 0;
    height: 32px;
    border-radius: 6px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  .topbar-center {
    display: none !important;
  }

  .cluster-status-chip {
    display: none !important;
  }

  .topbar-right {
    gap: 5px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto;
  }

  .btn-topbar-overview {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
    height: 32px;
    border-radius: 6px;
  }

  .btn-topbar-overview span {
    display: inline !important;
  }

  .btn-topbar-share {
    padding: 5px 9px;
    font-size: 0.8rem;
    height: 32px;
    flex-shrink: 0;
    border-radius: 6px;
  }

  .btn-topbar-share span {
    display: none !important;
  }

  .btn-topbar-signin {
    padding: 5px 8px;
    font-size: 0.78rem;
    height: 32px;
    flex-shrink: 0;
    border-radius: 6px;
  }

  .btn-topbar-signin span {
    display: none !important;
  }

  /* Chat Messages Flow on Mobile */
  .chat-messages-container {
    padding: 6px 10px 4px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .chat-inner-bounds {
    padding: 0 0 100px;
    max-width: 100%;
    gap: 16px;
  }

  .message-row {
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
  }

  .msg-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.82rem;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .msg-content-wrap {
    max-width: calc(100% - 40px);
    width: auto;
    min-width: 0;
  }

  /* Well-Proportioned Mobile Bubble Reading Typography */
  .msg-bubble {
    padding: 12px 14px;
    font-size: 0.98rem;
    line-height: 1.6;
    letter-spacing: normal;
    border-radius: 14px;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .single-stream-body {
    font-size: 0.98rem;
    line-height: 1.6;
    color: #1e293b;
  }

  .single-stream-body p,
  .msg-bubble p {
    font-size: 0.98rem;
    line-height: 1.6;
    margin-bottom: 10px;
  }

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

  .message-row.user .msg-bubble {
    font-size: 0.98rem;
    line-height: 1.55;
    padding: 10px 14px;
    font-weight: 500;
  }

  .message-row.user .msg-content-wrap {
    max-width: 92%;
  }

  .user-msg-action-bar {
    opacity: 0.92;
    gap: 4px;
    margin-top: 5px;
  }

  .user-action-btn {
    padding: 4px 8px;
    font-size: 0.74rem;
  }

  .user-edit-container {
    min-width: 250px;
    padding: 10px;
  }

  /* Markdown Headings inside chat on mobile */
  .single-stream-body h1, .msg-bubble h1 { font-size: 1.32rem; line-height: 1.3; margin: 14px 0 8px; }
  .single-stream-body h2, .msg-bubble h2 { font-size: 1.18rem; line-height: 1.35; margin: 12px 0 6px; }
  .single-stream-body h3, .msg-bubble h3 { font-size: 1.06rem; line-height: 1.4; margin: 10px 0 6px; }
  .single-stream-body h4, .msg-bubble h4 { font-size: 0.98rem; line-height: 1.45; margin: 8px 0 4px; }

  /* Lists inside chat */
  .single-stream-body ul, .msg-bubble ul,
  .single-stream-body ol, .msg-bubble ol {
    padding-left: 20px;
    margin-bottom: 10px;
    font-size: 0.98rem;
    line-height: 1.6;
  }

  .single-stream-body li, .msg-bubble li {
    margin-bottom: 6px;
    font-size: 0.98rem;
  }

  /* Dual consensus panes on mobile stack cleanly */
  .dual-consensus-view {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dual-node-pane {
    padding: 12px 14px;
    border-radius: 10px;
  }

  .dual-pane-body {
    font-size: 0.95rem;
    line-height: 1.55;
  }

  .dual-node-header {
    font-size: 0.8rem;
    margin-bottom: 8px;
    padding-bottom: 6px;
  }

  /* Code Blocks on Mobile */
  .code-block-container {
    margin: 10px 0;
    border-radius: 8px;
    max-width: 100%;
    overflow: hidden;
  }

  .code-block-header {
    padding: 6px 12px;
  }

  .code-lang-tag {
    font-size: 0.72rem;
  }

  .code-copy-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .code-block-content pre {
    padding: 12px;
    font-size: 0.82rem;
    line-height: 1.55;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .code-block-content code {
    font-size: 0.82rem;
    line-height: 1.55;
  }

  /* Action Buttons Bar on Mobile */
  .msg-action-bar {
    gap: 6px;
    margin-top: 8px;
    padding-top: 6px;
    flex-wrap: wrap;
  }

  .msg-action-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
  }

  /* Input Bar on Mobile: Responsive Auto-Sized Typing */
  .chat-input-bar-wrap {
    padding: 6px 8px 6px;
    background: linear-gradient(180deg, #f1f5f9 0%, #eaeef5 100%);
    border-top: 1.5px solid #cbd5e1;
  }

  .input-box-shell {
    padding: 5px 7px 5px 10px;
    border-radius: 14px;
    min-height: auto;
    gap: 8px;
    align-items: flex-end;
    border: 1.5px solid #94a3b8;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  }

  .chat-textarea {
    font-size: 0.96rem;
    line-height: 1.4;
    padding: 3px 0;
    min-height: 36px;
    max-height: 120px;
  }

  .chat-textarea::placeholder {
    font-size: 0.84rem;
  }

  .chat-send-btn {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
    border-radius: 9px;
    flex-shrink: 0;
  }

  .chat-footer-disclaimer {
    font-size: 0.6rem;
    line-height: 1.28;
    margin-top: 4px;
    padding: 0 2px;
    text-align: center;
  }

  /* Welcome Screen on Mobile — Pull up cleanly, zero scroll */
  .welcome-screen {
    padding: 4px 4px 2px;
    margin: 0 auto auto;
    max-width: 100%;
  }

  .welcome-logo-wrap {
    margin-bottom: 10px;
  }

  .welcome-logo-wrap::before {
    width: 100px;
    height: 100px;
    top: 26px;
  }

  .welcome-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    margin-bottom: 8px;
  }

  .welcome-brand-badge {
    padding: 3px 12px;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
  }

  .welcome-release-tag {
    padding: 2px 10px;
    margin-bottom: 6px;
    font-size: 0.56rem;
    letter-spacing: 0.13em;
  }

  .welcome-title {
    font-size: 1.22rem;
    line-height: 1.15;
    margin-bottom: 2px;
  }

  .welcome-from-word {
    font-size: 0.76rem;
    margin: 2px 0 2px;
  }

  .welcome-brand-anthropic {
    font-size: 1.16rem;
    letter-spacing: 0.24em;
    padding-left: 0.24em;
  }

  .welcome-hairline {
    width: 42px;
    margin: 7px auto 7px;
  }

  .welcome-subtitle {
    font-size: 0.76rem;
    line-height: 1.42;
    margin-bottom: 7px;
    padding: 0 2px;
  }

  .welcome-subtitle-lead {
    font-size: 0.82rem;
    margin-bottom: 3px;
  }

  .welcome-pillars {
    gap: 3px 6px;
    padding-top: 6px;
    margin-bottom: 7px;
    font-size: 0.57rem;
    letter-spacing: 0.06em;
  }

  .welcome-exp-note {
    padding: 5px 9px;
    font-size: 0.67rem;
    line-height: 1.34;
    margin-bottom: 4px;
    border-radius: 8px;
  }

  .auth-gate-card {
    padding: 10px 11px;
    margin: 6px auto 2px;
    gap: 8px;
    border-radius: 10px;
  }

  .auth-gate-title {
    font-size: 0.86rem;
  }

  .auth-gate-desc {
    font-size: 0.72rem;
    line-height: 1.32;
  }

  .btn-auth-gate {
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
  }

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

  .suggestion-card {
    padding: 10px 12px;
    border-radius: 10px;
  }

  .suggestion-tag {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .suggestion-text {
    font-size: 0.85rem;
    line-height: 1.4;
  }

  /* Floating controls on mobile */
  .btn-scroll-bottom {
    bottom: 115px;
    right: 14px;
    width: 34px;
    height: 34px;
  }

  /* Modals on Mobile */
  .share-modal-card,
  .legal-modal-card {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 88vh !important;
    max-height: 88dvh !important;
    padding: 16px 14px !important;
    margin: 10px auto !important;
    border-radius: 14px !important;
  }

  .legal-modal-header {
    padding: 12px 14px;
  }

  .legal-modal-body {
    padding: 14px;
    overflow-y: auto;
    font-size: 0.88rem;
  }

  .share-mode-opt {
    padding: 10px 12px;
  }

  .mode-opt-name {
    font-size: 0.92rem;
  }

  .mode-opt-desc {
    font-size: 0.76rem;
  }

  .share-app-actions {
    flex-direction: column;
    gap: 8px;
  }

  .btn-share-app {
    width: 100%;
    justify-content: center;
  }

  /* Table horizontally scrollable in chat messages */
  .msg-bubble table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.84rem;
  }
}

/* Extra Compact Mobile screens (< 380px, e.g. iPhone SE) */
@media (max-width: 380px) {
  .chat-topbar {
    padding: 0 4px;
    gap: 4px;
  }

  .topbar-left {
    gap: 4px;
  }

  .model-picker-wrap {
    max-width: 78px;
  }

  .btn-topbar-overview {
    padding: 4px 7px;
    font-size: 0.74rem;
    gap: 3px;
  }

  .chat-input-bar-wrap {
    padding: 6px 8px 6px;
  }
}

/* ──────────────────────────────────────────────────────────────────────
   Shared Response Highlighting & Badge
   ────────────────────────────────────────────────────────────────────── */
.shared-msg-highlight {
  animation: sharedHighlightPulse 2.8s ease-out;
  border-radius: 18px;
  position: relative;
}

.shared-msg-highlight .msg-bubble {
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22), 0 8px 24px rgba(245, 158, 11, 0.12) !important;
}

@keyframes sharedHighlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.45);
    transform: scale(1.012);
  }
  30% {
    box-shadow: 0 0 0 10px rgba(217, 119, 6, 0.2);
    transform: scale(1.012);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0);
    transform: scale(1);
  }
}

.shared-reply-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(217, 119, 87, 0.12);
  color: var(--claude-accent);
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 8px;
  border: 1px solid rgba(217, 119, 87, 0.3);
  font-family: var(--font-mono);
}
