:root {
  --bg-dark: #0e1621;
  --bg-sidebar: #17212b;
  --bg-header: #17212b;
  --bg-chat: #0e1621;
  --bg-card: #242f3d;
  --bg-input: #242f3d;
  --accent-cyan: #3390ec;
  --accent-blue: #3390ec;
  --accent-indigo: #2b5278;
  --accent-emerald: #4ade80;
  --accent-amber: #f59e0b;
  --accent-rose: #f472b6;
  --text-main: #f5f5f5;
  --text-muted: #7f91a4;
  --bubble-user: #182533;
  --bubble-bot-start: #2b5278;
  --bubble-bot-end: #2b5278;
  --border-color: #101921;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-dark);
  color: var(--text-main);
  overflow: hidden;
}

/* App Main Container Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

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

/* Buttons & Utilities */
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

/* ==========================================================================
   LEFT SIDEBAR
   ========================================================================== */
.sidebar {
  width: 360px;
  min-width: 320px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  z-index: 10;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  background-color: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

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

.brand-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.status-indicator {
  font-size: 12px;
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  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 8px rgba(16, 185, 129, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Search Box */
.search-box {
  padding: 12px 16px;
  position: relative;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background-color: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--accent-cyan);
  background-color: var(--bg-dark);
}

/* Stage Filter Pills */
.filter-pills {
  display: flex;
  gap: 8px;
  padding: 4px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.filter-pills::-webkit-scrollbar {
  display: none;
}

.pill {
  padding: 6px 14px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill.active,
.pill:hover {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Chat List */
.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin: 0 auto 12px;
}

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

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background-color 0.2s ease;
  position: relative;
}

.chat-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.chat-item.active {
  background-color: rgba(56, 189, 248, 0.12);
  border-left: 4px solid var(--accent-cyan);
}

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #64748b, #334155);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

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

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-item-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

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

.chat-item-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Badges */
.badge-stage {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-stage.START {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
}

.badge-stage.WAITING_EXPERIENCE {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.badge-stage.WAITING_REGISTERED {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.badge-stage.JOIN_VIP {
  background: rgba(236, 72, 153, 0.2);
  color: #f472b6;
}

.badge-stage.VIP_ACTIVE {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.badge-unread {
  background-color: var(--accent-cyan);
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.badge-ai-paused {
  background-color: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ==========================================================================
   MAIN CHAT WINDOW
   ========================================================================== */
.chat-main {
  flex: 1;
  background-color: var(--bg-chat);
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.placeholder-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.placeholder-view h2 {
  color: var(--text-main);
  font-size: 22px;
  margin-bottom: 8px;
}

.placeholder-view p {
  max-width: 440px;
  line-height: 1.5;
  font-size: 14px;
}

.active-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  min-height: 0;
}

/* Chat Window Header */
.chat-header {
  padding: 12px 20px;
  padding-top: max(12px, env(safe-area-inset-top));
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}

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

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

.user-details {
  min-width: 0;
}

.user-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-subtext {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.stage-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.stage-dropdown {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* AI Switch Toggle */
.ai-toggle-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.ai-toggle-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #475569;
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked+.slider {
  background-color: var(--accent-emerald);
}

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

.slider.round {
  border-radius: 20px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Message Feed */
.messages-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #0e1621;
  background-image: url('/chat_doodle.svg');
  background-repeat: repeat;
  background-size: 440px;
  -webkit-overflow-scrolling: touch;
}

.msg-date-divider {
  align-self: center;
  background: rgba(15, 23, 33, 0.75);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 12px;
  margin: 8px 0;
  backdrop-filter: blur(4px);
}

.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  position: relative;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.msg-bubble.user {
  align-self: flex-start;
  background-color: #182533;
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.msg-bubble.model {
  align-self: flex-end;
  background-color: #2b5278;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.msg-header {
  display: none !important;
}

.msg-text {
  white-space: pre-wrap;
}

.msg-text a {
  color: #7dd3fc;
  text-decoration: underline;
}

.msg-media-photo {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  margin-top: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.msg-media-photo:hover {
  transform: scale(1.02);
}

.msg-audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: 8px;
}

.audio-play-btn {
  background: var(--accent-cyan);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.msg-time {
  font-size: 10px;
  margin-top: 4px;
  text-align: right;
  opacity: 0.7;
}

/* Quick Reply Ribbon */
.quick-templates {
  padding: 8px 16px;
  background-color: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.quick-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-template {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-template:hover {
  background: var(--accent-cyan);
  color: #0f172a;
}

/* Composer Bar */
.chat-composer {
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background-color: var(--bg-header);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.composer-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.btn-attach {
  color: var(--text-muted);
  flex-shrink: 0;
}

.btn-attach:hover {
  color: var(--accent-cyan);
}

.composer-form textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 16px;
  /* 16px prevents iOS Safari auto-zoom on input focus */
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s ease;
}

.composer-form textarea:focus {
  border-color: var(--accent-cyan);
}

.btn-send {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border: none;
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.05);
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--accent-cyan);
}

/* ==========================================================================
   RIGHT USER INFO DRAWER
   ========================================================================== */
.info-drawer {
  width: 300px;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  position: absolute;
  right: -300px;
  top: 0;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 40;
}

.info-drawer.open {
  right: 0;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.drawer-header {
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  background-color: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

#closeDrawerBtn {
  font-size: 32px;
  width: 44px;
  height: 44px;
  line-height: 1;
  color: var(--text-main);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#closeDrawerBtn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.drawer-content {
  padding: 24px 20px;
  overflow-y: auto;
  text-align: center;
  flex: 1;
}

.drawer-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: var(--shadow-lg);
}

.drawer-content h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.drawer-content p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.info-card {
  background: var(--bg-header);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: left;
  margin-bottom: 20px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 12px;
  color: var(--text-muted);
}

.info-value {
  font-size: 12px;
  font-weight: 600;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
}

.lightbox-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.lightbox-close {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  z-index: 1010;
}

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

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

  .sidebar {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    height: 100dvh;
    z-index: 30;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .app-container.chat-active .sidebar {
    transform: translateX(-100%);
  }

  .chat-main {
    width: 100%;
    height: 100%;
    height: 100dvh;
  }

  .info-drawer {
    width: 100%;
    right: -100%;
  }

  .info-drawer.open {
    right: 0;
  }

  /* 1. Hide stage selector dropdown on mobile phones */
  .stage-control {
    display: none !important;
  }

  /* 2. Hide username & ID subtext on mobile phones (just display name) */
  .user-subtext {
    display: none !important;
  }

  /* 3. Make chat bubbles significantly wider on phone screens */
  .msg-bubble {
    max-width: 88% !important;
  }

  .chat-header {
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 8px;
  }

  .header-controls {
    gap: 8px;
  }

  .ai-toggle-box {
    padding: 3px 8px;
  }

  .ai-toggle-label {
    font-size: 11px;
  }

  .messages-feed {
    padding: 12px;
    gap: 8px;
  }

  .quick-templates {
    padding: 6px 10px;
    gap: 6px;
  }

  .chat-composer {
    padding: 6px 10px;
    padding-bottom: max(6px, calc(env(safe-area-inset-bottom) - 14px));
  }

  #closeDrawerBtn {
    font-size: 34px;
    width: 48px;
    height: 48px;
  }
}

/* ==========================================================================
   BROADCAST SUITE & INLINE BUTTONS STYLES
   ========================================================================== */

/* Header Broadcast Button */
.btn-broadcast-header {
  margin-left: auto;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-broadcast-header:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.45);
}

/* Modal Overlay */
.broadcast-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease-out;
}

.broadcast-modal-container {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1100px;
  height: 90vh;
  max-height: 850px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* Modal Header */
.broadcast-modal-header {
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.broadcast-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.broadcast-icon {
  font-size: 28px;
}

.broadcast-header-title h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.broadcast-header-title p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

/* Suite Body: Dual Panel */
.broadcast-suite-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.broadcast-composer-panel {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.broadcast-preview-panel {
  width: 420px;
  background: #090d16;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  gap: 16px;
}

/* Form Section Labels */
.broadcast-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-cyan);
}

/* Audience Grid */
.audience-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease;
}

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

.audience-stats-pill {
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.25);
  color: #38bdf8;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

/* Type Segmented Pills */
.type-segmented-pills {
  display: flex;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.type-pill {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.type-pill.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* File Drop Zone */
.file-drop-zone {
  background: rgba(255, 255, 255, 0.02);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-drop-zone:hover {
  border-color: var(--accent-cyan);
  background: rgba(14, 165, 233, 0.04);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.upload-icon {
  font-size: 24px;
}

.drop-zone-content p {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
}

.file-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.file-selected-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.btn-remove-file {
  background: transparent;
  border: none;
  color: var(--accent-rose);
  font-size: 18px;
  cursor: pointer;
}

/* Text Editor & Toolbar */
.formatting-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px 8px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
}

.btn-format,
.btn-emoji {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-format:hover,
.btn-emoji:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.format-divider {
  width: 1px;
  height: 16px;
  background: var(--border-color);
  margin: 0 4px;
}

.broadcast-textarea {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-family: inherit;
  resize: vertical;
}

/* Button Matrix Builder */
.section-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-secondary-sm {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary-sm:hover {
  background: rgba(255, 255, 255, 0.15);
}

.button-matrix-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.matrix-row-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.matrix-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-row-del {
  background: transparent;
  border: none;
  color: var(--accent-rose);
  font-size: 11px;
  cursor: pointer;
}

.matrix-buttons-flex {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-btn-edit-card {
  display: grid;
  grid-template-columns: 2fr 1fr 3fr auto;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Telegram Phone Preview Card */
.preview-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.preview-card-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.preview-badge {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.tg-phone-mockup {
  width: 100%;
  max-width: 360px;
  background: #17212b;
  border-radius: 16px;
  border: 1px solid #242f3d;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tg-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #242f3d;
}

.tg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: white;
}

.tg-title-box {
  display: flex;
  flex-direction: column;
}

.tg-name {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tg-sub {
  font-size: 11px;
  color: #708499;
}

.tg-message-bubble {
  background: #182533;
  border-radius: 12px 12px 12px 2px;
  padding: 10px 12px;
  color: #f5f5f5;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}

.tg-media-preview {
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  max-height: 180px;
}

.tg-media-preview img,
.tg-media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tg-text-preview {
  white-space: pre-wrap;
}

.tg-text-preview b {
  font-weight: 700;
  color: #ffffff;
}

.tg-text-preview i {
  font-style: italic;
}

.tg-text-preview code {
  font-family: monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 4px;
  border-radius: 4px;
  color: #38bdf8;
}

.tg-text-preview a {
  color: #64b5ef;
  text-decoration: none;
}

.tg-time {
  font-size: 10px;
  color: #6c7c8c;
  text-align: right;
  margin-top: 4px;
}

/* Telegram Matrix Inline Buttons Preview & Feed Rendering */
.tg-buttons-matrix,
.msg-inline-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  width: 100%;
}

.tg-btn-row,
.inline-btn-row {
  display: flex;
  gap: 4px;
  width: 100%;
}

.tg-inline-btn {
  flex: 1;
  background: rgba(43, 82, 120, 0.45);
  border: 1px solid rgba(100, 181, 239, 0.25);
  color: #64b5ef;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tg-inline-btn:hover {
  background: rgba(43, 82, 120, 0.8);
  border-color: #64b5ef;
  color: #ffffff;
}

/* Progress Box */
.broadcast-progress-box {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.progress-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.progress-percent {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-blue);
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #2563eb);
  transition: width 0.3s ease;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Modal Footer */
.broadcast-modal-footer {
  padding: 14px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-launch {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-launch:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
}

/* ==========================================================================
   VOICE RECORDER & MESSAGE CONTEXT MENU STYLES
   ========================================================================== */
.btn-mic {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn-mic:hover {
  background-color: #2b82dc;
  box-shadow: 0 4px 12px rgba(51, 144, 236, 0.4);
}

.btn-mic.recording {
  transform: scale(1.25);
  background-color: #ef4444 !important;
  box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.25), 0 0 20px rgba(239, 68, 68, 0.5) !important;
  animation: micPulse 1.2s infinite ease-in-out;
}

@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.voice-rec-overlay {
  position: absolute;
  left: 56px;
  right: 60px;
  top: 0;
  bottom: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 5;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
  user-select: none;
}

.voice-rec-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.voice-timer {
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

.voice-wave-anim {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}

.voice-wave-anim span {
  width: 3px;
  height: 100%;
  background-color: var(--accent-cyan);
  border-radius: 2px;
  animation: waveBar 0.8s infinite ease-in-out alternate;
}

.voice-wave-anim span:nth-child(1) { animation-delay: 0.1s; }
.voice-wave-anim span:nth-child(2) { animation-delay: 0.3s; }
.voice-wave-anim span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave-anim span:nth-child(4) { animation-delay: 0.4s; }
.voice-wave-anim span:nth-child(5) { animation-delay: 0.15s; }

@keyframes waveBar {
  0% { height: 4px; opacity: 0.4; }
  100% { height: 20px; opacity: 1; }
}

.voice-cancel-prompt {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.1s ease, color 0.15s ease;
}

.voice-cancel-prompt.cancelling {
  color: #ef4444;
  font-weight: 600;
}

.swipe-arrow {
  font-size: 16px;
  font-weight: 700;
  animation: slideLeft 1.2s infinite ease-in-out;
}

@keyframes slideLeft {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-5px); }
}

/* Telegram Style Context Menu */
.msg-context-menu {
  position: fixed;
  z-index: 10000;
  background-color: rgba(23, 33, 43, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
  padding: 6px;
  min-width: 160px;
  animation: contextMenuPop 0.15s cubic-bezier(0.1, 0.9, 0.2, 1);
  transform-origin: top left;
}

@keyframes contextMenuPop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.context-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
}

.context-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.context-item.danger {
  color: #f87171;
}

.context-item.danger:hover {
  background-color: rgba(248, 113, 113, 0.15);
}

/* Message Bubble Selected / Active State */
.msg-bubble {
  user-select: text;
  -webkit-user-select: text;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.msg-bubble.context-selected {
  outline: 2px solid var(--accent-cyan);
  box-shadow: 0 0 12px rgba(51, 144, 236, 0.4);
}