/* ==============================================================================
   Serv Bot - AI FAQ & Diagnostics Chat UI CSS (v1.0.0)
   ============================================================================== */

/* Page layout */
.bot-page-container {
  max-width: 620px;
}

/* Badge dot */
.badge-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
}

.badge-status-dot.online {
  background-color: #3fb950;
  box-shadow: 0 0 8px #3fb950;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

/* Chat Card Container */
.chat-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  min-height: 560px;
  height: calc(100vh - 230px);
  max-height: 760px;
  overflow-x: hidden !important;
}

/* Messages feed */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden !important;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 4px;
  scroll-behavior: smooth;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
  height: 0px;
}

.chat-messages::-webkit-scrollbar:horizontal {
  display: none !important;
  height: 0px !important;
  width: 0px !important;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(240, 246, 252, 0.15);
  border-radius: 4px;
}

/* Message bubbles */
.message-bubble {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeInBubble 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

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

/* User Bubble */
.user-message {
  align-self: flex-end;
  max-width: 85%;
  position: relative;
}

.user-message:hover .btn-bubble-copy {
  opacity: 1;
}

.btn-bubble-copy {
  position: absolute;
  top: -8px;
  right: -8px;
  background: rgba(18, 22, 29, 0.95);
  border: 1px solid rgba(240, 246, 252, 0.2);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.15s ease;
  padding: 0;
  color: var(--text-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.btn-bubble-copy:hover {
  transform: scale(1.15);
  color: #fff;
  border-color: var(--border-focus);
}

.user-message .bubble-content {
  background: linear-gradient(135deg, rgba(31, 111, 235, 0.35) 0%, rgba(35, 134, 54, 0.3) 100%);
  border: 1px solid rgba(56, 139, 253, 0.4);
  color: #ffffff;
  padding: 11px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.93rem;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  word-break: break-word;
}

/* Bot Bubble */
.bot-message {
  align-self: flex-start;
  max-width: 95%;
}

.bot-message .bubble-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.bot-avatar {
  font-size: 1rem;
}

.sender-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.model-badge {
  font-size: 0.65rem;
  background: rgba(88, 166, 255, 0.15);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: #58a6ff;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  user-select: none;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.model-badge.cipher-gemini {
  background: rgba(88, 166, 255, 0.16);
  border-color: rgba(88, 166, 255, 0.4);
  color: #79c0ff;
  font-size: 0.72rem;
  padding: 1px 5px;
}

.model-badge.cipher-gemini-lite {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  font-size: 0.72rem;
  padding: 1px 5px;
}

.model-badge.cipher-gemma-26 {
  background: rgba(163, 113, 247, 0.14);
  border-color: rgba(163, 113, 247, 0.35);
  color: #d2a8ff;
  font-size: 0.72rem;
  padding: 1px 5px;
}

.model-badge.cipher-gemma-31 {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
  color: #bc8cff;
  font-size: 0.72rem;
  padding: 1px 5px;
}

.model-badge.cipher-deepseek-flash {
  background: rgba(0, 210, 255, 0.14);
  border-color: rgba(0, 210, 255, 0.4);
  color: #00d2ff;
  font-size: 0.72rem;
  padding: 1px 5px;
  box-shadow: 0 0 6px rgba(0, 210, 255, 0.15);
}

.model-badge.cipher-deepseek-pro {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(129, 140, 248, 0.45);
  color: #a5b4fc;
  font-size: 0.72rem;
  padding: 1px 5px;
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.15);
}

/* Copy Bot Reply Button in Bubble Header */
.btn-copy-bot-reply {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(240, 246, 252, 0.05);
  border: 1px solid rgba(240, 246, 252, 0.12);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary, #8b949e);
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
}

.btn-copy-bot-reply:hover {
  background: rgba(240, 246, 252, 0.12);
  border-color: rgba(88, 166, 255, 0.4);
  color: #c9d1d9;
  transform: translateY(-1px);
}

.btn-copy-bot-reply.copied {
  background: rgba(35, 134, 54, 0.2);
  border-color: rgba(46, 160, 67, 0.4);
  color: #3fb950;
}

.btn-copy-bot-reply .copy-icon {
  font-size: 0.8rem;
}

@media (max-width: 420px) {
  .btn-copy-bot-reply .copy-label {
    display: none;
  }
  .btn-copy-bot-reply {
    padding: 2px 6px;
  }
}

/* Bottom Actions in Bot Bubble */
.bot-message .bubble-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  padding: 0 4px;
}

.btn-copy-bot-reply-bottom {
  margin-left: 0;
  padding: 4px 10px;
  font-size: 0.76rem;
  background: rgba(240, 246, 252, 0.04);
  border: 1px solid rgba(240, 246, 252, 0.1);
  border-radius: 8px;
}

.btn-copy-bot-reply-bottom:hover {
  background: rgba(240, 246, 252, 0.1);
  border-color: rgba(88, 166, 255, 0.4);
  color: #c9d1d9;
}

@media (max-width: 420px) {
  .btn-copy-bot-reply-bottom .copy-label {
    display: inline; /* Keep label on bottom button for readability */
  }
}

.bot-message .bubble-content {
  background: rgba(18, 23, 31, 0.95);
  border: 1px solid rgba(240, 246, 252, 0.08);
  padding: 14px 16px;
  border-radius: 16px 16px 16px 4px;
  color: #aab2be; /* Т.3.А: Сланцевый графит (68% яркости, мягкий для глаз) */
  font-size: 0.94rem;
  line-height: 1.6;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  word-break: break-word;
}

/* Markdown formatting inside Bot Content */
.bubble-content p {
  margin-bottom: 10px;
}

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

.bubble-content strong {
  color: #ced5df; /* Мягкий контрастный акцент вместо слепящего #ffffff */
  font-weight: 700;
}

.bubble-content code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.84em;
  background: rgba(240, 246, 252, 0.08);
  color: #7ee787;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(240, 246, 252, 0.06);
}

.bubble-content pre {
  background: #090c10;
  border: 1px solid rgba(240, 246, 252, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
  overflow-x: auto;
  color: #aab2be;
}

.bubble-content pre code {
  background: transparent;
  padding: 0;
  border: none;
  font-size: 0.82em;
}

.bubble-content ul, .bubble-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.bubble-content li {
  margin-bottom: 4px;
}

.bubble-content a {
  color: #58a6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
  word-break: break-all;
}

.bubble-content a:hover {
  color: #79c0ff;
}

/* Responsive tables in bot messages */
.bubble-content .table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 10px 0;
  -webkit-overflow-scrolling: touch;
}

.bubble-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 4px 0;
}

.bubble-content th,
.bubble-content td {
  padding: 6px 10px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  text-align: left;
}

.bubble-content th {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
}

/* Quick Suggestion Chips */
.quick-chips-wrapper {
  margin: 6px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-chips-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quick-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-chip {
  background: rgba(22, 28, 38, 0.85);
  border: 1px solid rgba(240, 246, 252, 0.1);
  color: #c9d1d9;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-align: left;
}

.quick-chip:hover {
  background: rgba(31, 111, 235, 0.18);
  border-color: rgba(88, 166, 255, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
}

.chip-emoji {
  font-size: 0.85rem;
}

/* ==============================================================================
   Stage 1: Scanning In-Flight Indicator
   ============================================================================== */
.in-flight-bubble {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.diagnostic-scanning-box {
  background: rgba(13, 20, 32, 0.95);
  border: 1px dashed rgba(88, 166, 255, 0.45);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.scanning-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.scanning-radar {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(88, 166, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.scanning-radar::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #58a6ff;
  box-shadow: 0 0 10px #58a6ff;
  animation: radar-ping 1.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radar-ping {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.scanning-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #58a6ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

/* Matrix Thought Terminal: 100% fluid width, strictly fixed height, no jumping, no flicker */
.matrix-thought-terminal {
  background: #030603;
  border: 1px solid rgba(56, 161, 105, 0.28);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  box-shadow: none;
  font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  height: 68px;
  min-height: 68px;
  max-height: 68px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.matrix-lines-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 0;
}

.matrix-line {
  color: #38a169;
  text-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 18px;
  line-height: 18px;
  opacity: 0.40;
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.matrix-line.active {
  opacity: 0.90;
  color: #4ade80;
  font-weight: 500;
}

.matrix-prefix {
  opacity: 0.5;
  flex-shrink: 0;
}

.matrix-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
}

.matrix-cursor {
  display: inline-block;
  color: #4ade80;
  font-size: 0.75em;
  animation: blinkCursor 0.7s infinite;
  margin-left: 2px;
  flex-shrink: 0;
}

.typing-cursor {
  display: inline-block;
  color: #38a169;
  font-weight: 700;
  margin-left: 2px;
  animation: blinkCursor 0.7s infinite;
  vertical-align: baseline;
  line-height: 1;
}

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

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

/* ==============================================================================
   Stage 2: Compact Diagnostic Result Card
   ============================================================================== */
.bot-diagnostic-card {
  background: linear-gradient(135deg, rgba(16, 21, 30, 0.95) 0%, rgba(12, 16, 22, 0.98) 100%);
  border: 1px solid rgba(240, 246, 252, 0.12);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: visible;
  flex-shrink: 0;
  min-height: fit-content;
}

.bot-diagnostic-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  bottom: 0;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.bot-diagnostic-card.status-success::before {
  background: #3fb950;
  box-shadow: 0 0 10px #3fb950;
}

.bot-diagnostic-card.status-warning::before {
  background: #d29922;
  box-shadow: 0 0 10px #d29922;
}

.bot-diagnostic-card.status-danger::before {
  background: #f85149;
  box-shadow: 0 0 10px #f85149;
}

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

.diag-badge-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diag-emoji {
  font-size: 1.3rem;
  line-height: 1;
}

.diag-title-box {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.diag-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
}

.diag-target-label {
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', Consolas, monospace;
  color: var(--text-secondary);
}

/* Metric stats */
.diag-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.diag-stat-pill {
  background: rgba(24, 30, 42, 0.7);
  border: 1px solid rgba(240, 246, 252, 0.08);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diag-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.diag-stat-val {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e6edf3;
}

/* Anomalies Tags */
.diag-anomalies-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diag-anomaly-chip {
  font-size: 0.74rem;
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: #ff7b72;
  padding: 3px 8px;
  border-radius: 4px;
}

/* CTA Link */
.btn-diag-report {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(31, 111, 235, 0.25) 0%, rgba(56, 139, 253, 0.18) 100%);
  border: 1px solid rgba(56, 139, 253, 0.5);
  color: #79c0ff;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.18s ease;
  margin-top: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-diag-report:hover {
  background: rgba(31, 111, 235, 0.4);
  border-color: rgba(88, 166, 255, 0.8);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(31, 111, 235, 0.3);
}

/* Sources Footer in Bot Message */
.sources-accordion {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(240, 246, 252, 0.08);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sources-label {
  font-weight: 600;
  margin-bottom: 4px;
}

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-tag {
  background: rgba(240, 246, 252, 0.06);
  border: 1px solid rgba(240, 246, 252, 0.1);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.73rem;
  transition: all 0.15s ease;
}

.source-tag:hover {
  background: rgba(88, 166, 255, 0.15);
  border-color: rgba(88, 166, 255, 0.3);
  color: #58a6ff;
}

/* Web sources (Google Search Grounding) — distinct green accent */
.web-sources-accordion {
  border-top-color: rgba(63, 185, 80, 0.15);
}

.web-source-tag {
  background: rgba(63, 185, 80, 0.07);
  border-color: rgba(63, 185, 80, 0.18);
  color: #7ee787;
}

.web-source-tag:hover {
  background: rgba(63, 185, 80, 0.18);
  border-color: rgba(63, 185, 80, 0.4);
  color: #aff5b4;
}

/* ==============================================================================
   Rate Limit Countdown Banner
   ============================================================================== */
.rate-limit-banner {
  background: linear-gradient(135deg, rgba(210, 153, 34, 0.16) 0%, rgba(20, 16, 10, 0.95) 100%);
  border: 1px solid rgba(210, 153, 34, 0.4);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.rate-limit-banner.hidden {
  display: none;
}

.rate-limit-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rate-limit-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f0883e;
}

.rate-limit-sub {
  font-size: 0.78rem;
  color: #d29922;
}

.rate-limit-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(210, 153, 34, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.rate-limit-bar-fill {
  height: 100%;
  background: #f0883e;
  width: 100%;
  transition: width 1s linear;
}

/* ==============================================================================
   Chat Input Form
   ============================================================================== */
.chat-input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(240, 246, 252, 0.08);
  padding-top: 12px;
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.chat-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 130px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 38px 10px 14px;
  resize: none;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* Chat Toolbar */
.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(18, 22, 29, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  gap: 8px;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}

.chat-toolbar-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.context-indicator-dot.active {
  background-color: #3fb950;
  box-shadow: 0 0 7px rgba(63, 185, 80, 0.65);
}

.context-status-text {
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* Response Mode Segmented Switcher */
.response-mode-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid rgba(240, 246, 252, 0.15);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  user-select: none;
}

.btn-mode-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 500;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  line-height: 1.2;
}

.btn-mode-toggle:hover:not(.active):not(:disabled) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.btn-mode-toggle.active {
  background: #238636;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(35, 134, 54, 0.4);
}

.btn-mode-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Reset Context Button */
.btn-reset-context {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(240, 246, 252, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(240, 246, 252, 0.12);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.btn-reset-context:hover {
  background: rgba(248, 81, 73, 0.12);
  border-color: rgba(248, 81, 73, 0.4);
  color: #ff7b72;
  box-shadow: 0 2px 8px rgba(248, 81, 73, 0.15);
  transform: translateY(-1px);
}

.btn-reset-context:active {
  transform: translateY(0) scale(0.97);
}

.btn-reset-context.has-history {
  background: rgba(240, 246, 252, 0.08);
  color: var(--text-primary);
  border-color: rgba(240, 246, 252, 0.22);
}

.btn-reset-context .reset-icon {
  font-size: 0.85rem;
  display: inline-block;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-reset-context:hover .reset-icon {
  transform: rotate(-180deg);
}

.btn-reset-context.spinning .reset-icon {
  animation: spin-once 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes spin-once {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* System Reset Notice in Chat Feed */
.system-reset-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  margin: 4px 0 10px;
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.25);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  animation: fadeInNotice 0.3s ease;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.system-reset-notice.fade-out {
  opacity: 0;
  transform: translateY(-6px);
}

.system-reset-notice .notice-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.system-reset-notice .notice-text {
  flex: 1;
  color: #c9d1d9;
}

.btn-undo-reset {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #58a6ff;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-undo-reset:hover {
  background: rgba(88, 166, 255, 0.2);
  border-color: #58a6ff;
  color: #fff;
}

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

/* Error message bubble & Retry Action */
.error-message-bubble {
  border: 1px solid rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.08);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  max-width: 95%;
  animation: fadeInBubble 0.25s ease;
}

.error-badge {
  background: rgba(248, 81, 73, 0.2);
  color: #ff7b72;
  border: 1px solid rgba(248, 81, 73, 0.35);
}

.error-text-msg {
  color: #ff7b72;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
  word-break: break-word;
}

/* Error actions toolbar */
.error-actions-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(248, 81, 73, 0.2);
}

.btn-retry-message {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(248, 81, 73, 0.22);
  border: 1px solid rgba(248, 81, 73, 0.5);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(248, 81, 73, 0.2);
}

.btn-retry-message:hover {
  background: rgba(248, 81, 73, 0.35);
  border-color: #ff7b72;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(248, 81, 73, 0.35);
}

.btn-retry-message:active {
  transform: translateY(0);
}

.btn-retry-message .retry-icon {
  font-size: 0.95rem;
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-retry-message:hover .retry-icon {
  transform: rotate(180deg);
}

.btn-copy-to-input {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(240, 246, 252, 0.15);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-copy-to-input:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(240, 246, 252, 0.3);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-chat-send {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-chat-send .send-icon {
  font-size: 1.05rem;
  transform: translateX(1px);
}

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

.chat-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
}

@media (max-width: 480px) {
  .chat-card {
    height: calc(100vh - 180px);
    padding: 10px;
  }

  .chat-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }

  .chat-toolbar-status {
    order: 1;
    flex: 1 1 auto;
  }

  .btn-reset-context {
    order: 2;
    padding: 4px 8px;
  }

  .response-mode-toggle {
    order: 3;
    width: 100%;
    justify-content: stretch;
  }

  .btn-mode-toggle {
    flex: 1;
    text-align: center;
    padding: 5px 6px;
  }

  .bot-message {
    max-width: 100%;
  }

  .in-flight-bubble {
    width: 100%;
    max-width: 100%;
  }

  .diagnostic-scanning-box {
    padding: 8px 10px;
    gap: 6px;
  }

  .matrix-thought-terminal {
    font-size: 0.67rem;
    padding: 4px 8px;
    height: 60px;
    min-height: 60px;
    max-height: 60px;
  }

  .matrix-line {
    height: 15px;
    line-height: 15px;
    gap: 4px;
  }

  .diag-stats-grid {
    grid-template-columns: 1fr;
  }

  .chat-meta-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

/* ── Clickable links inside bot bubbles (v1.8.2) ──────────────────────── */
.bubble-content a {
  color: #7dd3fc;          /* sky-300 — читается на тёмном фоне */
  text-decoration: underline;
  text-decoration-color: rgba(125, 211, 252, 0.45);
  text-underline-offset: 2px;
  word-break: break-all;   /* длинные URL не вылазят за пределы пузыря */
  transition: color 0.15s ease;
}
.bubble-content a:hover {
  color: #38bdf8;          /* sky-400 */
  text-decoration-color: rgba(56, 189, 248, 0.7);
}

/* ── Responsive tables inside bot bubbles ─────────────────────────────── */
.bubble-content .table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0;
  border-radius: 8px;
}
.bubble-content table {
  border-collapse: collapse;
  min-width: 280px;
  font-size: 0.85rem;
}
.bubble-content th,
.bubble-content td {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  text-align: left;
}
.bubble-content th {
  background: rgba(255,255,255,0.08);
  font-weight: 600;
}
.bubble-content tr:nth-child(even) td {
  background: rgba(255,255,255,0.03);
}

/* ── Bot Donation Card (Support banner inside chat) ───────────────────── */
.bot-donation-card {
  margin-top: 12px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.92) 100%);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), 0 0 16px rgba(99, 102, 241, 0.08);
  animation: donationBannerFadeIn 0.3s ease-out;
}

.bot-donation-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.bot-donation-text-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;
}

.bot-donation-icon {
  font-size: 1.25rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  flex-shrink: 0;
}

.bot-donation-text {
  font-size: 0.86rem;
  line-height: 1.35;
  color: #f1f5f9;
  font-weight: 500;
}

.bot-donation-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-bot-donation-pay {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff !important;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-bot-donation-pay:hover {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-bot-donation-qr {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-bot-donation-qr:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: rgba(99, 102, 241, 0.4);
}

/* ── Bot Promo Alert Banner (Solutions banner inside chat) ───────────── */
.chat-alert-banner-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  animation: fadeInBubble 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  margin-top: 4px;
}

.chat-alert-banner-container .alert-promo-banner {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.chat-alert-banner-container .top-banner-inner {
  padding: 12px 14px;
  gap: 12px;
}

/* ── Bottom banners below chat card ───────────────────── */
.bot-page-container .donation-banner-slot {
  margin-top: 14px;
}

.bot-page-container .alert-banner-slot {
  margin-top: 8px;
  margin-bottom: 16px;
}



