/* ============================================================================
   AlfaComp AI — Mobile-First Telegram Mini App Stylesheet
   Modern Glassmorphism, Neon Accents, Cyber Aesthetics, Smooth Micro-Interactions
   ============================================================================ */

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d121d;
  --bg-card: rgba(18, 24, 38, 0.78);
  --bg-card-hover: rgba(28, 36, 56, 0.9);
  --bg-glass: rgba(14, 20, 32, 0.75);
  --bg-input: rgba(12, 17, 28, 0.88);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-glow: rgba(99, 102, 241, 0.35);
  --border-focus: rgba(6, 182, 212, 0.55);

  --accent-indigo: #6366f1;
  --accent-indigo-light: #818cf8;
  --accent-cyan: #06b6d4;
  --accent-cyan-light: #22d3ee;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'Fira Code', monospace;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-full: 9999px;

  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --shadow-cyan: 0 0 22px rgba(6, 182, 212, 0.25);
  --shadow-card: 0 12px 35px -8px rgba(0, 0, 0, 0.65);
  --blur-glass: blur(18px);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Glows & Canvas */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.32;
  animation: floatAmbient 18s ease-in-out infinite alternate;
}

.glow-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--accent-indigo) 0%, transparent 70%);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
  bottom: -150px;
  right: -100px;
  animation-delay: -9s;
}

.glow-3 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
  top: 40%;
  right: 15%;
  animation-delay: -5s;
}

@keyframes floatAmbient {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(35px, 25px) scale(1.08); }
  100% { transform: translate(-25px, -15px) scale(0.96); }
}

/* App Layout */
.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1040px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: rgba(10, 14, 22, 0.55);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Header */
.app-header {
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(13, 18, 29, 0.72);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  flex-shrink: 0;
  gap: 12px;
}

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

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

.brand-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.avatar-pulse {
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid var(--accent-cyan-light);
  opacity: 0.6;
  animation: pulseAvatar 2.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

.brand-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.badge-pro {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.35);
}

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

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  flex-shrink: 0;
}

.header-center {
  display: flex;
  align-items: center;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.28);
  color: var(--accent-cyan-light);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.channel-pill:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-cyan);
  transform: translateY(-1px);
}

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

/* Action Buttons */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--border-medium);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn-sm:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-action-glass {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glow);
  background: rgba(99, 102, 241, 0.12);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action-glass:hover {
  background: rgba(99, 102, 241, 0.24);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-action-glass:active {
  transform: scale(0.96);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Welcome Hero Banner */
.welcome-hero {
  padding: 24px 20px;
  text-align: center;
  max-width: 680px;
  margin: auto;
  animation: fadeIn 0.4s ease-out;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--border-glow);
  color: var(--accent-indigo-light);
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 10px;
  color: #fff;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-cyan-light), var(--accent-indigo-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 22px;
}

.quick-chips {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.chip {
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(18, 24, 38, 0.6);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: rgba(28, 36, 56, 0.9);
  color: #fff;
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.chip:active {
  transform: scale(0.98);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Message Rows */
.message-row {
  display: flex;
  gap: 10px;
  max-width: 86%;
  animation: messageSlideIn 0.25s ease-out;
}

.user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bot-row {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 2px;
}

.user-row .message-avatar {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  box-shadow: var(--shadow-glow);
}

.bot-row .message-avatar {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  box-shadow: var(--shadow-cyan);
}

.message-bubble {
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  position: relative;
  font-size: 0.94rem;
  line-height: 1.6;
  word-break: break-word;
}

.user-row .message-bubble {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.28), rgba(168, 85, 247, 0.28));
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bot-row .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-card);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

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

.message-actions {
  display: flex;
  gap: 4px;
  opacity: 0.85;
}

.msg-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.msg-action-btn:hover {
  color: var(--text-primary);
}

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

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

.bubble-content h1, .bubble-content h2, .bubble-content h3 {
  font-family: var(--font-display);
  margin-top: 12px;
  margin-bottom: 6px;
  color: #fff;
}

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

.bubble-content code:not(pre code) {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent-cyan-light);
}

.bubble-content a {
  color: var(--accent-cyan-light);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bubble-content blockquote {
  border-left: 3px solid var(--accent-indigo);
  padding-left: 10px;
  margin: 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Code Block Wrapper */
.code-block-wrapper {
  margin: 10px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #090d16;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-subtle);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.code-actions {
  display: flex;
  gap: 6px;
}

.code-btn {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.code-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.code-preview-btn {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.35);
  color: var(--accent-cyan-light);
}

.code-preview-btn:hover {
  background: rgba(6, 182, 212, 0.28);
  color: #fff;
}

.code-body {
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #e2e8f0;
}

/* KaTeX Math formulas */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
  margin: 8px 0;
}

/* Thinking Indicator */
.thinking-wrapper {
  padding: 12px 16px;
  animation: fadeIn 0.3s ease-out;
}

.thinking-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: rgba(18, 24, 38, 0.85);
  border: 1px solid var(--border-glow);
  box-shadow: var(--shadow-glow);
  max-width: 520px;
}

.thinking-spinner {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan-light);
  flex-shrink: 0;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent-cyan);
  border-right-color: var(--accent-indigo);
  animation: spinRing 1s linear infinite;
}

@keyframes spinRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.thinking-content {
  flex: 1;
  min-width: 0;
}

.thinking-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.thinking-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.thinking-progress-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-cyan));
  animation: progressPulse 1.8s ease-in-out infinite alternate;
}

@keyframes progressPulse {
  0% { width: 15%; transform: translateX(0); }
  100% { width: 85%; transform: translateX(20%); }
}

/* Footer & Input Bar */
.app-footer {
  padding: 10px 16px 14px;
  flex-shrink: 0;
  background: rgba(10, 14, 22, 0.75);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-top: 1px solid var(--border-subtle);
}

.input-card {
  border-radius: var(--radius-xl);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-card:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.22);
}

/* Attachment Preview */
.attachment-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.preview-thumb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-medium);
  flex-shrink: 0;
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-remove-img {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.preview-info {
  display: flex;
  flex-direction: column;
}

.preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}

.preview-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Input Row */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.tool-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Voice Recording Active Animation */
.tool-btn.voice-recording,
.tool-btn.recording {
  background: rgba(244, 63, 94, 0.25) !important;
  color: var(--accent-rose) !important;
  border-color: var(--accent-rose) !important;
  animation: pulseRecording 1.4s infinite;
}

@keyframes pulseRecording {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.6); transform: scale(1); }
  50% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); transform: scale(1.08); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); transform: scale(1); }
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.94rem;
  line-height: 1.45;
  resize: none;
  max-height: 140px;
  padding: 8px 4px;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
  transition: all 0.2s ease;
}

.btn-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.45);
}

.btn-send:active {
  transform: scale(0.92);
}

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

/* Input Meta Bar */
.input-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

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

.mode-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.math-tag { color: var(--accent-indigo-light); }
.code-tag { color: var(--accent-cyan-light); }

.icon-xs {
  width: 12px;
  height: 12px;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.modal-window {
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  border-radius: var(--radius-xl);
  background: #0f1523;
  border: 1px solid var(--border-medium);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), var(--shadow-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.preview-modal-window {
  max-width: 900px;
  height: 82vh;
}

.modal-header {
  height: 54px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  color: #fff;
}

.badge-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.badge-sandbox {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan-light);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-body {
  flex: 1;
  background: #fff;
  position: relative;
}

.preview-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Settings Modal Body */
.modal-body-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tab-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.settings-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.settings-tab-btn.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: var(--border-glow);
  color: #fff;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(12, 17, 28, 0.8);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--border-focus);
}

.form-hint {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Switch Slider */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.25s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.25s;
  border-radius: 50%;
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Channel Card */
.channel-preview-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  margin-bottom: 14px;
}

.channel-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.channel-card-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.channel-card-info p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.channel-card-link {
  font-size: 0.74rem;
  color: var(--accent-cyan-light);
  font-weight: 500;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: #141c2c;
  border: 1px solid var(--accent-indigo);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
}

/* Utilities & Animations */
.hidden { display: none !important; }
.text-indigo { color: var(--accent-indigo-light); }

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

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

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

/* ============================================================================
   MOBILE-FIRST RESPONSIVE OPTIMIZATIONS (iPhone & Android Telegram Mini App)
   ============================================================================ */
@media (max-width: 680px) {
  .app-layout {
    border-left: none;
    border-right: none;
  }

  .app-header {
    height: 56px;
    padding: 0 12px;
  }

  .brand-name {
    font-size: 0.98rem;
  }

  .brand-status {
    font-size: 0.68rem;
  }

  /* Hide Channel pill in header on mobile to save space */
  .header-center {
    display: none;
  }

  /* Make New Chat button compact (icon only or small) */
  #btn-new-chat span {
    display: none;
  }

  #btn-new-chat {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
  }

  .hero-title {
    font-size: 1.65rem;
  }

  .quick-chips {
    grid-template-columns: 1fr;
  }

  .message-row {
    max-width: 94%;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
  }

  .message-bubble {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .app-footer {
    padding: 8px 10px calc(8px + var(--safe-bottom));
  }

  /* Input meta bar compact on mobile */
  .input-meta-bar {
    font-size: 0.66rem;
  }

  .input-meta-bar .mode-tag:not(:first-child):not(:last-child) {
    display: none;
  }

  /* Turn Modals into Mobile Bottom-Sheets */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-window {
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    animation: sheetSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .preview-modal-window {
    height: 88vh;
  }

  /* Toast notification centered on mobile */
  .toast-container {
    bottom: calc(75px + var(--safe-bottom));
    left: 16px;
    right: 16px;
    align-items: center;
  }

  .toast {
    width: auto;
    max-width: 100%;
  }
}
