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

:root {
  --bg-primary: #111b21;
  --bg-secondary: #202c33;
  --bg-tertiary: #2a3942;
  --bg-chat: #0b141a;
  --bg-message-out: #005c4b;
  --bg-message-in: #202c33;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --accent: #00a884;
  --accent-hover: #06cf9c;
  --danger: #ea4335;
  --border: #313d45;
  --sidebar-width: 380px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

.screen {
  height: 100vh;
  width: 100%;
}

/* Setup Screen */
.setup-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 20px;
}

.logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo h1 {
  margin-top: 16px;
  font-size: 24px;
  font-weight: 600;
}

.logo p {
  color: var(--text-secondary);
  margin-top: 8px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, textarea, select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238696a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.instance-row select,
.instance-row input {
  flex: 1;
}

.btn-primary {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 12px 24px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
  width: 100%;
}

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

.btn-danger {
  padding: 12px 24px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}

.btn-danger:hover { background: rgba(234,67,53,0.1); }

.btn-icon {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.2s;
  flex-shrink: 0;
}

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

.btn-large { width: 100%; margin-top: 20px; }

/* QR Code */
#qr-section {
  text-align: center;
  margin: 20px 0;
}

.qr-hint {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
}

#qr-container {
  display: inline-block;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}

#qr-container img {
  width: 256px;
  height: 256px;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-radius: 20px;
  margin: 16px 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.status-badge.connected .status-dot { background: var(--accent); }
.status-badge.disconnected .status-dot { background: var(--danger); }

/* Chat Layout */
.chat-layout {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
}

.sidebar-header h2 { font-size: 18px; font-weight: 600; }

.sidebar-actions {
  display: flex;
  gap: 4px;
}

.sidebar-actions .btn-icon {
  background: transparent;
  border: none;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.search-box {
  padding: 8px 12px;
}

.search-box input {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
}

/* Chat filter tabs */
.chat-filter-tabs {
  display: flex;
  gap: 6px;
  padding: 4px 12px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chat-filter-tabs::-webkit-scrollbar {
  display: none;
}

.chat-filter-tabs button {
  flex: 0 0 auto;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-filter-tabs button:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.chat-filter-tabs button.active {
  background: var(--accent);
  color: #fff;
}

/* Chat list */
.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(134,150,160,0.08);
  border-left: 6px solid transparent;
}

.chat-list-item.platform-wa {
  border-left-color: #25D366;
}

.chat-list-item.platform-tg {
  border-left-color: #2AABEE;
}

.chat-list-item.awaiting-reply {
  border-left-color: #E53935 !important;
}

.chat-list-item.awaiting-reply .chat-item-time {
  color: #E53935;
}

.chat-list-item:hover { background: var(--bg-secondary); }
.chat-list-item.active { background: var(--bg-tertiary); }

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chat-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.avatar-initials {
  z-index: 0;
}

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

.chat-item-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-item-meta {
  text-align: right;
  flex-shrink: 0;
}

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

.chat-item-unread {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  padding: 0 5px;
  margin-top: 4px;
}

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 16px;
}

.empty-chat h3 { font-size: 20px; color: var(--text-primary); }

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  overflow: hidden;
  flex-shrink: 0;
}

.chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-header-name {
  font-size: 16px;
  font-weight: 500;
}

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

.chat-header-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-export {
  margin-left: auto;
  color: var(--text-secondary);
  flex-shrink: 0;
}

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

.btn-export:disabled {
  opacity: 0.6;
  cursor: wait;
}

.export-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-secondary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.export-progress-bar {
  padding: 6px 20px;
  background: var(--bg-tertiary);
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.btn-back-mobile {
  display: none;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-chat);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}

.message-out {
  align-self: flex-end;
  background: var(--bg-message-out);
  border-radius: 8px 0 8px 8px;
}

.message-in {
  align-self: flex-start;
  background: var(--bg-message-in);
  border-radius: 0 8px 8px 8px;
}

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

.message-text a {
  color: #53bdeb;
  text-decoration: none;
  word-break: break-all;
}

.message-text a:hover {
  text-decoration: underline;
}

.message-media {
  padding: 3px;
  max-width: 330px;
}

.message-media .message-text {
  padding: 4px 8px 0;
}

.message-media .message-time {
  padding: 0 4px;
}

.message-image {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

.message-image-placeholder {
  width: 250px;
  height: 150px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.message-image-placeholder:hover {
  background: rgba(255,255,255,0.1);
}

.message-text code {
  font-family: monospace;
  background: rgba(255,255,255,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
}

/* Document */
.message-document {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 200px;
}

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

.message-document-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-document-download {
  flex-shrink: 0;
  opacity: 0.7;
}

.message-document:hover .message-document-download {
  opacity: 1;
}

.message-voice {
  min-width: 280px;
}
.message-voice .message-sender {
  padding: 4px 10px 0;
}
.message-voice .message-time {
  padding: 0 8px;
}

/* Voice message player */
.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  padding: 6px 8px;
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.voice-play-btn:hover { background: rgba(255,255,255,0.25); }
.message-out .voice-play-btn { background: rgba(255,255,255,0.2); }
.message-out .voice-play-btn:hover { background: rgba(255,255,255,0.35); }

.voice-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.voice-waveform {
  position: relative;
  height: 28px;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
}

.voice-waveform-progress {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: rgba(83, 189, 235, 0.25);
  border-radius: 4px;
  transition: width 0.1s linear;
  pointer-events: none;
}

.voice-waveform-bars {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
  z-index: 1;
}

.voice-bar {
  flex: 1;
  min-width: 2px;
  border-radius: 1px;
  background: rgba(255,255,255,0.35);
  transition: background 0.1s;
}

.voice-waveform-progress ~ .voice-waveform-bars .voice-bar {
  background: rgba(255,255,255,0.35);
}

.voice-duration {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}

.message-out .voice-bar { background: rgba(255,255,255,0.4); }

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

/* Quoted message (reply) */
.message-quote {
  background: rgba(0,0,0,0.15);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 6px 10px 4px;
  margin-bottom: 8px;
  cursor: pointer;
  max-height: 70px;
  overflow: hidden;
}

.message-quote:hover {
  background: rgba(0,0,0,0.25);
}

.message-quote-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.message-quote-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Highlight when scrolling to quoted message */
.message-highlight {
  animation: msg-highlight 2s ease-out;
}

@keyframes msg-highlight {
  0%, 20% { background: rgba(0,168,132,0.25); }
  100% { background: transparent; }
}

/* Reply button */
.message-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 75%;
}

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

/* Outgoing messages align right */
.message-wrapper:has(.message-out) {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-wrapper:has(.message-in) {
  align-self: flex-start;
}

.btn-reply {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.message-wrapper:hover .btn-reply {
  opacity: 0.7;
}

.btn-reply:hover {
  opacity: 1 !important;
  background: rgba(255,255,255,0.1);
}

/* Reply preview above input */
.reply-preview {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  gap: 8px;
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.reply-preview-author {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

.reply-preview-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--text-secondary);
}

/* Reactions */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 14px;
  cursor: default;
}

.reaction-count {
  font-size: 11px;
  color: var(--text-secondary);
}

.message-time {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  text-align: right;
  margin-top: 2px;
}

.message-status {
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  vertical-align: middle;
}
.message-status svg { display: block; }
.status-pending, .status-sent, .status-delivered {
  color: rgba(255, 255, 255, 0.5);
}
.status-read {
  color: #53bdeb;
}

.message-date-divider {
  align-self: center;
  background: var(--bg-secondary);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 12px 0;
}

.message-action {
  align-self: center;
  background: rgba(0,0,0,0.2);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0;
  text-align: center;
  max-width: 80%;
  font-style: italic;
}

/* Message input */
.message-input-area {
  padding: 12px 20px;
  background: var(--bg-secondary);
}

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

.input-row textarea {
  flex: 1;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  resize: none;
  max-height: 200px;
  min-height: 44px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.4;
}

/* AI Assist button */
/* AI icon in sidebar */
.btn-icon-ai {
  color: #b39ddb;
}

.btn-icon-ai:hover {
  color: #ce93d8;
}

/* AI Assist button */
.btn-ai-assist {
  width: 48px;
  height: 48px;
  background: transparent;
  color: #b39ddb;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.btn-ai-assist:hover {
  color: #ce93d8;
  background: var(--bg-tertiary);
}

.btn-ai-assist:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ai-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #b39ddb;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  overflow: hidden;
}

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

.modal-header h3 { font-size: 17px; }

.modal-body {
  padding: 20px;
}

.setting-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

.setting-item strong { color: var(--text-primary); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 200;
  transition: opacity 0.3s;
}

.toast.error { border-left: 3px solid var(--danger); }
.toast.success { border-left: 3px solid var(--accent); }

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

#connecting-spinner {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
}

/* Loading */
.loading {
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }

/* Voice Manager Modal */
.voice-manager-modal {
  width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.voice-manager-modal .modal-body {
  overflow-y: auto;
  flex: 1;
}

.voice-upload-section,
.voice-categories-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.voice-upload-section h4,
.voice-categories-section h4,
.voice-list-section h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.voice-add-category {
  display: flex;
  gap: 8px;
}

.voice-add-category input {
  flex: 1;
}

.voice-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 4px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.voice-cat-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}

.voice-cat-delete:hover {
  color: var(--danger);
  background: rgba(234,67,53,0.1);
}

.voice-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.voice-item:hover {
  background: var(--bg-tertiary);
}

.voice-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.voice-play-btn:hover {
  background: var(--accent);
}

.voice-item-name {
  flex: 1;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-delete-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.voice-item:hover .voice-delete-btn {
  opacity: 1;
}

.voice-delete-btn:hover {
  color: var(--danger);
  background: rgba(234,67,53,0.1);
}

.voice-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-size: 14px;
}

/* Voice Picker (popup in chat input) */
.voice-picker-wrapper {
  position: relative;
  flex-shrink: 0;
}

.btn-voice-picker {
  width: 48px;
  height: 48px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

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

.voice-picker {
  position: absolute;
  bottom: 56px;
  right: 0;
  width: 280px;
  max-height: 360px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.voice-picker-header {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.voice-picker-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.voice-picker-cat {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 8px 4px;
}

.voice-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.voice-picker-item:hover {
  background: var(--bg-tertiary);
}

.voice-picker-name {
  flex: 1;
  font-size: 14px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-picker .voice-play-btn {
  width: 28px;
  height: 28px;
}

/* Template items */
.template-item {
  flex-direction: row;
  align-items: flex-start;
}

.template-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-picker-item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.template-picker-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Connect Screen — Dual Panel ===== */

.setup-container-dual {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
}

.connect-title {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 28px;
}

.connect-panels {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
}

.connect-panel {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.connect-panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.connect-panel-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.connect-panel-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.connect-panel-ok {
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
  margin-top: 12px;
}

.tg-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.tg-hint a {
  color: var(--accent);
  text-decoration: none;
}

.connect-panel .form-group {
  margin-bottom: 12px;
  text-align: left;
}

.connect-panel .btn-primary {
  width: 100%;
}

/* ===== Platform Color Bar ===== */

/* ===== Chat Header Platform Icon ===== */

.chat-header-platform {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  vertical-align: middle;
}

/* ===== Settings Platform Section ===== */

.settings-platform-section h4 {
  font-size: 15px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar { width: 100%; }
  .chat-main { display: none; }

  .chat-layout.chat-open .sidebar { display: none; }
  .chat-layout.chat-open .chat-main { display: flex; }

  .btn-back-mobile { display: block; }

  .message { max-width: 85%; }

  .connect-panels {
    flex-direction: column;
  }
}

/* ===== Connect Screen User Bar ===== */

.connect-user-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.connect-user-name {
  color: var(--text-secondary);
  font-size: 14px;
}

.connect-logout-btn {
  color: var(--text-secondary) !important;
  transition: color 0.15s;
}

.connect-logout-btn:hover {
  color: var(--danger) !important;
}

/* ===== Login Screen ===== */

.login-container {
  max-width: 360px;
  text-align: center;
}

.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}

.login-error {
  background: rgba(234, 67, 53, 0.15);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ===== Admin Panel ===== */

.admin-panel-modal {
  max-width: 800px;
  width: 90vw;
}

.admin-section {
  margin-bottom: 24px;
}

.admin-section h4 {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-create-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-create-form input,
.admin-create-form select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 14px;
}

.admin-create-form button {
  grid-column: span 2;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-users-table th,
.admin-users-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-users-table th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
}

.admin-role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.admin-role-badge.admin {
  background: rgba(0, 168, 132, 0.2);
  color: var(--accent);
}

.admin-role-badge.user {
  background: rgba(134, 150, 160, 0.2);
  color: var(--text-secondary);
}

.admin-actions-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.admin-actions-cell input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-size: 13px;
}

.btn-danger-icon {
  color: var(--danger) !important;
}


/* Password success message */
.password-success {
  background: rgba(0, 168, 132, 0.15) !important;
  color: var(--accent) !important;
}
