:root {
  --cui-font-sans-serif: 'Manrope', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cui-body-bg: #f3f6fa;
  --cui-body-color: #1f2d3d;
  --cui-primary: #2481cc;
  --cui-primary-rgb: 36, 129, 204;
  --cui-link-color: #2481cc;
  --cui-link-hover-color: #1b6aa8;
}
body { letter-spacing: 0.1px; }
.header {
  --cui-header-bg: #ffffff;
  --cui-header-border-color: rgba(36, 129, 204, 0.08);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.footer {
  --cui-footer-bg: transparent;
  --cui-footer-border-color: rgba(15, 23, 42, 0.06);
  color: #8a93a2;
  font-size: 0.875rem;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--cui-primary);
  font-weight: 800;
  font-size: 1.1rem;
  text-decoration: none;
}
.app-brand:hover { color: var(--cui-link-hover-color); }
.card { border-radius: 0.85rem; border: none; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06); }
.list-group { border-radius: 0.85rem; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06); }
.list-group-item { border-color: rgba(15, 23, 42, 0.06); }
.btn { border-radius: 0.6rem; font-weight: 600; }
.form-control, .form-select { border-radius: 0.6rem; }
.min-w-0 { min-width: 0; }

.bot-avatar {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3fa9f5, #2481cc);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
}
.chat-avatar { background: linear-gradient(135deg, #a3b8cc, #6c829b); }

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  padding: 1rem;
  background: #e7eef5;
}
/* the first bubble sits at the bottom of a short chat, like in Telegram */
.chat-log > :first-child { margin-top: auto; }
.chat-message {
  max-width: min(75%, 36rem);
  padding: 0.5rem 0.75rem;
  border-radius: 0.85rem;
  background: #fff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.06);
  align-self: flex-start;
}
.chat-message-out { align-self: flex-end; background: #d9efff; }
.chat-sender { font-size: 0.8rem; font-weight: 700; color: var(--cui-primary); }
.chat-kind { font-size: 0.8rem; font-weight: 600; color: #6c829b; }
.chat-text { white-space: pre-wrap; word-wrap: break-word; }
.chat-meta { font-size: 0.75rem; color: #8a93a2; text-align: right; }

.chat-composer { flex: none; padding: 0.75rem; background: #fff; border-top: 1px solid rgba(15, 23, 42, 0.06); }
.chat-composer textarea { resize: none; }
.chat-media {
  display: block;
  max-width: 100%;
  max-height: 22rem;
  width: auto;
  height: auto;
  border-radius: 0.6rem;
  margin-bottom: 0.25rem;
}
.chat-media-sticker { max-width: 10rem; max-height: 10rem; }
.chat-media-video_note { width: 14rem; height: 14rem; border-radius: 50%; object-fit: cover; }
.chat-audio { display: block; width: 18rem; max-width: 100%; }
.chat-file::before { content: "📎 "; }

/* the bot page: dialogs on the left, the open one on the right, filling the viewport */
.tg-wrapper { height: 100dvh; }
.tg-body { min-height: 0; display: flex; }
.tg-app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
  background: #fff;
  border-radius: 0.85rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.tg-sidebar {
  flex: 0 0 22rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
}
.tg-sidebar-header { flex: none; padding: 0.75rem; border-bottom: 1px solid rgba(15, 23, 42, 0.06); }
.tg-sidebar-header .form-control { border-radius: 1rem; background: #f1f4f8; border-color: transparent; }
.tg-dialogs { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0.25rem; }
.tg-dialog {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.6rem;
  color: inherit;
  text-decoration: none;
}
.tg-dialog:hover { background: #f1f4f8; color: inherit; }
.tg-dialog-title { font-weight: 700; }
.tg-dialog-time { flex: none; font-size: 0.75rem; color: #8a93a2; }
.tg-dialog-preview { font-size: 0.875rem; color: #6c7a8b; }
.tg-dialog.active { background: var(--cui-primary); color: #fff; }
.tg-dialog.active .tg-dialog-time, .tg-dialog.active .tg-dialog-preview { color: rgba(255, 255, 255, 0.85); }
.tg-dialog.active .chat-avatar { background: rgba(255, 255, 255, 0.25); }
.tg-sidebar-empty { padding: 1rem; font-size: 0.875rem; color: #6c7a8b; }
.tg-dialog.unread .tg-dialog-preview { color: #1f2937; }
.tg-dialog-you { color: var(--cui-primary); }
.tg-dialog-gone { color: #b45309; font-style: italic; }
.tg-dialog-badge {
  flex: none;
  min-width: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 0.7rem;
  background: var(--cui-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}
.tg-dialog-waiting { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #f59e0b; }
.tg-dialog.active .tg-dialog-you, .tg-dialog.active .tg-dialog-gone, .tg-dialog.active.unread .tg-dialog-preview { color: #fff; }
.tg-dialog.active .tg-dialog-badge { background: #fff; color: var(--cui-primary); }
.tg-dialog-filter { display: flex; gap: 0.25rem; }
.tg-dialog-filter button {
  border: none;
  border-radius: 1rem;
  padding: 0.15rem 0.7rem;
  background: transparent;
  color: #6c7a8b;
  font-size: 0.8125rem;
  font-weight: 600;
}
.tg-dialog-filter button:hover { background: #f1f4f8; }
.tg-dialog-filter button.active { background: rgba(var(--cui-primary-rgb), 0.12); color: var(--cui-primary); }
.chat-gone {
  flex: none;
  padding: 0.5rem 1rem;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.875rem;
}
.tg-back {
  flex: none;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #6c7a8b;
  font-size: 1.2rem;
  text-decoration: none;
}
.tg-back:hover { background: #f1f4f8; color: var(--cui-primary); }
.tg-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: #e7eef5; }
.tg-chat-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #fff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.tg-placeholder { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; }
.tg-placeholder span {
  padding: 0.25rem 0.85rem;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.25);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
}
/* phones: either the list or the open dialog, never both */
@media (max-width: 767.98px) {
  .tg-body { padding: 0 !important; }
  .tg-app { border-radius: 0; }
  .tg-sidebar { flex: 1 1 auto; border-right: none; }
  .tg-main { display: none; }
  .tg-app-chat-open .tg-sidebar { display: none; }
  .tg-app-chat-open .tg-main { display: flex; }
}

.chat-attach { flex: none; color: #6c7a8b; }
.chat-attachment {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.6rem;
  background: #f1f4f8;
}
.chat-attachment-preview { flex: none; width: 4rem; height: 4rem; border-radius: 0.5rem; overflow: hidden; background: #dde5ee; }
.chat-attachment-preview img, .chat-attachment-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tg-main.chat-dragover .chat-log { outline: 3px dashed var(--cui-primary); outline-offset: -0.75rem; }
