:root {
  /* Workspace: Светло-серый фон */
  --bg-primary: #f2f3f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e6e8f0;
  --bg-hover: #dce0eb;
  --border-color: #d6d9e4;

  /* Слева окно: Крем-брюле серый */
  --sidebar-bg: #ece6dc;
  --sidebar-border: #ded8cd;
  --sidebar-hover: #e2dbcf;
  --sidebar-active: #d6cebf;
  --sidebar-text: #2c2823;
  --sidebar-text-muted: #787066;

  --accent-color: #5c60f5;
  --accent-hover: #484cdb;
  --text-primary: #1e212b;
  --text-secondary: #4b5263;
  --text-muted: #7e8597;
  --user-msg-bg: #5c60f5;
  --user-msg-text: #ffffff;
  --assistant-msg-bg: #ffffff;
  --danger-color: #ef4444;
  --success-color: #10b981;
  --code-bg: #1e202e;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 270px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100dvh;
  overflow: hidden;
  display: flex;
}

.app-layout {
  display: flex;
  width: 100vw;
  height: 100dvh;
  position: relative;
}

/* ==========================================================================
   Sidebar Styles (Крем-брюле серый)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--sidebar-text);
  letter-spacing: -0.02em;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--accent-color);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

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

.sidebar-search {
  margin: 12px 14px 4px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.sidebar-search svg {
  color: var(--sidebar-text-muted);
}

.sidebar-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--sidebar-text);
  font-size: 0.85rem;
  width: 100%;
}

.sidebar-search input::placeholder {
  color: var(--sidebar-text-muted);
}

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

.chat-list-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 4px 8px;
  letter-spacing: 0.05em;
}

.chat-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  transition: all 0.15s ease;
  position: relative;
}

.chat-item:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.chat-item.active {
  background-color: var(--sidebar-active);
  color: var(--sidebar-text);
  font-weight: 600;
}

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

.chat-item-actions {
  display: none;
  gap: 4px;
}

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

.btn-item-action {
  background: transparent;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}

.btn-item-action:hover {
  color: var(--sidebar-text);
}

.btn-item-action.delete:hover {
  color: var(--danger-color);
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.sidebar-btn:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.sidebar-btn.text-danger {
  color: #dc2626;
}

.sidebar-btn.text-danger:hover {
  background-color: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

/* ==========================================================================
   Chat Workspace
   ========================================================================== */
.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-primary);
  min-width: 0;
  overflow: hidden;
}

.chat-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  z-index: 10;
}

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

.current-chat-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.current-chat-title {
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.model-select-badge {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

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

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* ==========================================================================
   Messages Area
   ========================================================================= */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 10px 16px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  min-width: 0;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.welcome-card {
  max-width: 820px;
  margin: auto;
  text-align: center;
  padding: 30px 20px;
}

.welcome-icon {
  font-size: 54px;
  margin-bottom: 12px;
}

.welcome-card h2 {
  font-size: 1.85rem;
  margin-bottom: 8px;
}

.welcome-desc {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

.models-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.model-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.model-card:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--accent-color);
  transform: translateY(-2px);
}

.model-card.active {
  border-color: var(--accent-color);
  background-color: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.25);
}

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

.model-card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.12rem;
}

.model-card-icon {
  font-size: 1.35rem;
}

.model-tag {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tag-fast {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-reasoning {
  background-color: rgba(244, 114, 182, 0.15);
  color: #f472b6;
  border: 1px solid rgba(244, 114, 182, 0.3);
}

.tag-heavy {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.tag-web {
  background-color: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.model-tags-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-card-desc {
  font-size: 0.94rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* AI Status & Capabilities Banner */
.ai-status-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 22px;
  text-align: left;
}

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

.status-live-dot {
  width: 10px;
  height: 10px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  flex-shrink: 0;
  animation: pulseLive 2s infinite ease-in-out;
}

@keyframes pulseLive {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.ai-status-title {
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.35;
}

.ai-capabilities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.ai-cap-badge {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.94rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.ai-cap-badge strong {
  color: var(--text-primary);
}

.welcome-suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.suggestion-chip {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 1.02rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.suggestion-chip:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--accent-color);
}

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

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

.message-bubble {
  max-width: 85%;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.94rem;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
  overflow: hidden;
  min-width: 0;
}

.message-row.user .message-bubble {
  background-color: var(--user-msg-bg);
  border-radius: var(--radius-md);
  border-top-right-radius: 4px;
  color: #fff;
  box-shadow: 0 2px 6px rgba(92, 96, 245, 0.25);
}

.message-row.assistant .message-bubble {
  background-color: #ffffff;
  border: 1px solid #e2e4ec;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 100%;
  color: var(--text-primary);
}

/* Collapsible Reasoning Block */
.reasoning-box {
  background-color: #f8f9fc;
  border: 1px solid #e2e5f0;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

.reasoning-box summary {
  cursor: pointer;
  color: #5c60f5;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  font-size: 0.86rem;
}

.reasoning-box summary:hover {
  color: #484cdb;
}

.reasoning-content {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #d6d9e4;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
}

.thinking-placeholder {
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.pulsing-dot-inline {
  display: inline-block;
  width: 7px;
  height: 7px;
  background-color: var(--accent-color);
  border-radius: 50%;
  animation: pulse 1.2s infinite ease-in-out;
}

/* Markdown typography */
.message-content h1 {
  font-size: 1.25rem;
  margin: 12px 0 6px 0;
}

.message-content h2 {
  font-size: 1.12rem;
  margin: 10px 0 6px 0;
}

.message-content h3 {
  font-size: 1.02rem;
  margin: 8px 0 4px 0;
}

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

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

.message-content ul, .message-content ol {
  margin: 6px 0 10px 20px;
}

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

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.88rem;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

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

.message-content th {
  background-color: var(--bg-tertiary);
  font-weight: 600;
}

.message-content code:not(pre code) {
  background-color: var(--bg-tertiary);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.88em;
  color: #f472b6;
}

.message-content {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

.message-content img {
  max-width: 100% !important;
  max-height: 420px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  margin: 10px 0;
  display: block;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.message-content img:hover {
  transform: scale(1.01);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Code block container */
.code-block-wrapper {
  margin: 12px 0;
  border-radius: var(--radius-sm);
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #1a1c29;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.btn-copy-code {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-copy-code:hover {
  color: #fff;
  background-color: var(--bg-tertiary);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-size: 0.96rem;
  line-height: 1.5;
}

/* ==========================================================================
   Input Area
   ========================================================================== */
.chat-input-area {
  padding: 8px 16px 12px 16px;
  background-color: var(--bg-primary);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.generating-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.pulsing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-color);
  border-radius: 50%;
  animation: pulse 1.2s infinite ease-in-out;
}

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

.btn-stop {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.82rem;
  cursor: pointer;
  margin-left: 8px;
}

.btn-stop:hover {
  background-color: var(--bg-hover);
  border-color: var(--danger-color);
}

.input-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transition: border-color 0.15s ease;
}

.input-card:focus-within {
  border-color: var(--accent-color);
}

.chat-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.94rem;
  line-height: 1.45;
  resize: none;
  min-height: 24px;
  max-height: 160px;
  font-family: inherit;
}

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

.input-left-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.btn-attachment {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

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

.bottom-selector {
  max-width: 280px;
  text-overflow: ellipsis;
}

/* Attachments Preview Container */
.attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-primary);
}

.attachment-chip .file-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip .btn-remove-attachment {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0 2px;
  line-height: 1;
}

.attachment-chip .btn-remove-attachment:hover {
  color: var(--danger-color);
}

.attachment-chip.image-chip {
  padding: 3px 8px 3px 4px;
}

.attachment-thumb {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.attached-badge-in-msg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  margin-bottom: 8px;
  color: #a5b4fc;
}

.attached-img-in-msg {
  margin-bottom: 8px;
}

.msg-attached-img {
  max-width: 320px;
  max-height: 200px;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
  cursor: pointer;
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.msg-attached-img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.pill-badge {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.input-right-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Voice input & mic button */
.btn-mic {
  transition: all 0.2s ease;
}

.btn-mic.recording {
  color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.15) !important;
  animation: pulse-mic 1s infinite alternate ease-in-out;
}

@keyframes pulse-mic {
  0% { transform: scale(1); }
  100% { transform: scale(1.15); box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
}

.btn-web-search {
  transition: all 0.2s ease;
}

.btn-web-search.active {
  color: #2563eb !important;
  background-color: rgba(37, 99, 235, 0.14) !important;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.25);
}

.voice-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 4px 9px;
  border-radius: 14px;
  font-size: 0.76rem;
  color: #dc2626;
  font-weight: 600;
  white-space: nowrap;
}

.recording-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #ef4444;
  animation: pulse 1s infinite ease-in-out;
}

.btn-send {
  background-color: var(--accent-color);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-send:hover {
  background-color: var(--accent-hover);
  transform: scale(1.05);
}

.btn-send:disabled {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h2 {
  font-size: 1.25rem;
}

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

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.form-group label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.98rem;
  outline: none;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-color);
}

.form-hint {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.input-with-action {
  display: flex;
  position: relative;
}

.input-with-action input {
  width: 100%;
  padding-right: 40px;
}

.btn-input-action {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.provider-preset-chips {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.preset-chip {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.preset-chip.active,
.preset-chip:hover {
  background-color: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

/* QR Modal Specifics */
.modal-qr {
  max-width: 420px;
}

.text-center {
  text-align: center;
}

.qr-instruction {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.qrcode-wrapper {
  display: flex;
  justify-content: center;
  margin: 16px auto;
  padding: 16px;
  background-color: #fff;
  border-radius: var(--radius-md);
  width: fit-content;
}

.direct-link-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  margin-top: 10px;
}

.direct-link-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.copy-input-row {
  display: flex;
  gap: 8px;
}

.copy-input-row input {
  flex: 1;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
}

.tunnel-hint {
  margin-top: 16px;
  background-color: var(--bg-tertiary);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.tunnel-hint code {
  color: #a5b4fc;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.6);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

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

  .messages-container {
    padding: 12px 10px;
  }

  .chat-input-area {
    padding: 8px 10px env(safe-area-inset-bottom, 10px) 10px;
  }

  .message-bubble {
    max-width: 95%;
  }
}
