/* ==============================================================================
   Soryn — Office Messenger Design System & Stylesheet
   ============================================================================== */

:root {
  /* Soryn palette: ink violet from the logo, gold as its accent */
  --tg-primary: #4b3fa0;
  --tg-primary-hover: #3e3487;
  --tg-primary-light: rgba(75, 63, 160, 0.12);
  --soryn-ink: #1b1a2e;
  --soryn-gold: #ffc857;
  --tg-bg-page: #f1f1f1;
  --tg-bg-sidebar: #ffffff;
  --tg-bg-chat: #8ebe8a; /* Soft green chat wallpaper */
  --tg-bg-header: #ffffff;
  --tg-bubble-in: #ffffff;
  --tg-bubble-out: #efebff;
  --tg-bubble-out-meta: #6a5fc0;
  --tg-text: #000000;
  --tg-text-secondary: #707579;
  --tg-borders: #dadce0;
  --tg-search-bg: #f4f4f5;
  --tg-item-hover: #f4f4f5;
  --tg-item-active: #4b3fa0;
  --tg-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --tg-grad-1: linear-gradient(135deg, #e57373, #f06292);
  --tg-grad-2: linear-gradient(135deg, #ba68c8, #9575cd);
  --tg-grad-3: linear-gradient(135deg, #4fc3f7, #4dd0e1);
  --tg-grad-4: linear-gradient(135deg, #81c784, #aed581);
  /* Surface aliases used by popups, modals and inputs */
  --tg-panel-bg: var(--tg-bg-sidebar);
  --tg-chat-hover: var(--tg-item-hover);
  --tg-bg-secondary: var(--tg-search-bg);
  --tg-border-light: var(--tg-borders);
}

body.theme-dark {
  --tg-primary: #7a6ae0;
  --tg-primary-hover: #6c5cd4;
  --tg-primary-light: rgba(122, 106, 224, 0.18);
  --tg-bg-page: #0e0d16;
  --tg-bg-sidebar: #191826;
  --tg-bg-chat: #12111c;
  --tg-bg-header: #191826;
  --tg-bubble-in: #222033;
  --tg-bubble-out: #3a3266;
  --tg-bubble-out-meta: #b4aaf2;
  --tg-text: #ffffff;
  --tg-text-secondary: #8e8aa6;
  --tg-borders: #2c2a3f;
  --tg-search-bg: #2c2a3f;
  --tg-item-hover: #232134;
  --tg-item-active: #3a3266;
  --tg-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  /* Surface aliases used by popups, modals and inputs */
  --tg-panel-bg: var(--tg-bg-sidebar);
  --tg-chat-hover: var(--tg-item-hover);
  --tg-bg-secondary: var(--tg-search-bg);
  --tg-border-light: var(--tg-borders);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

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

/* ==============================================================================
   1. AUTHENTIC LOGIN SCREEN
   ============================================================================== */
.tg-auth-screen {
  position: fixed;
  inset: 0;
  background: var(--tg-bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  overflow-y: auto;
}

.auth-form-card {
  background: var(--tg-bg-sidebar);
  border-radius: 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
  background: url("soryn-logo.svg") center no-repeat;
  background-size: 100%;
}

.auth-monkey-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 16px;
  background: url("monkey.svg") center no-repeat;
  background-size: contain;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-code-title {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-note {
  font-size: 13.5px;
  color: var(--tg-text-secondary);
  line-height: 1.45;
  margin-bottom: 24px;
}

.auth-inputs-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tg-country-picker-wrap {
  position: relative;
  text-align: left;
}

.tg-country-select-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-search-bg);
  cursor: pointer;
  user-select: none;
}

#auth-country-flag {
  font-size: 18px;
}

#auth-country-name {
  flex: 1;
  font-size: 14.5px;
  font-weight: 600;
}

#auth-country-code {
  color: var(--tg-text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.tg-chevron-down {
  color: var(--tg-text-secondary);
}

.tg-country-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--tg-bg-sidebar);
  border: 1px solid var(--tg-borders);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  margin-top: 6px;
  padding: 8px;
}

.tg-country-dropdown input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-search-bg);
  color: var(--tg-text);
  font-size: 13px;
  outline: none;
  margin-bottom: 6px;
}

.tg-country-items-scroll {
  max-height: 180px;
  overflow-y: auto;
}

.tg-country-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background-color 0.15s;
}

.tg-country-item:hover {
  background: var(--tg-item-hover);
}

.tg-country-item-flag {
  font-size: 16px;
}

.tg-country-item-name {
  flex: 1;
}

.tg-country-item-code {
  color: var(--tg-primary);
  font-weight: 600;
}

.tg-phone-field-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--tg-borders);
  border-radius: 12px;
  background: var(--tg-search-bg);
  overflow: hidden;
  transition: border-color 0.2s;
}

.tg-phone-field-row:focus-within {
  border-color: var(--tg-primary);
}

.tg-phone-prefix {
  padding-left: 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--tg-primary);
  user-select: none;
}

.tg-phone-field-row input {
  border: none !important;
  background: transparent !important;
  padding: 12px 14px 12px 8px !important;
}

.tg-email-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--tg-borders);
  border-radius: 12px;
  background: var(--tg-search-bg);
  overflow: hidden;
  transition: border-color 0.2s;
}

.tg-email-field-wrap:focus-within {
  border-color: var(--tg-primary);
}

.tg-email-field-wrap input {
  border: none !important;
  background: transparent !important;
  padding: 12px 140px 12px 14px !important;
  font-size: 15px;
  color: var(--tg-text);
  width: 100%;
}

.tg-domain-badge {
  position: absolute;
  right: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-primary);
  background: rgba(75, 63, 160, 0.12);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}

.tg-floating-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tg-text-secondary);
  margin-bottom: 6px;
  text-align: left;
}

.tg-keep-session-row {
  text-align: left;
  margin-top: 4px;
}

.tg-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  user-select: none;
}

.auth-button {
  margin-top: 14px;
}

.tg-btn-text {
  background: none;
  border: none;
  color: var(--tg-primary);
  font-size: 13.5px;
  font-weight: 700;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.tg-btn-text:hover {
  background: var(--tg-item-hover);
}

.tg-auth-demo-hint {
  margin-top: 10px;
  color: var(--tg-text-secondary);
  line-height: 1.4;
  font-size: 12px;
  text-align: center;
}

/* QR Code Screen */
.qr-outer {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.qr-container {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.qr-plane-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tg-qr-help-list {
  padding: 0 16px;
  margin: 18px 0;
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
  list-style: none;
  counter-reset: qr-step;
}

.tg-qr-help-list li {
  counter-increment: qr-step;
  display: flex;
  align-items: flex-start;
  margin: 8px 0;
}

.tg-qr-help-list li::before {
  content: counter(qr-step);
  background: var(--tg-primary);
  color: #fff;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-right: 10px;
  margin-top: 2px;
  flex-shrink: 0;
}

/* Verification Code Screen */
.auth-number-edit {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  margin-left: 6px;
  border-radius: 6px;
}

.tg-sms-toast {
  background: rgba(75, 63, 160, 0.12);
  border-left: 4px solid var(--tg-primary);
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  text-align: left;
  font-size: 13px;
}

.tg-sms-icon {
  font-size: 20px;
}

.tg-sms-text strong {
  display: block;
  font-size: 12px;
  color: var(--tg-primary);
}

.tg-code-input {
  text-align: center !important;
  font-size: 26px !important;
  font-weight: 700 !important;
  letter-spacing: 10px !important;
  padding: 12px !important;
}

/* Registration Avatar Editable */
.AvatarEditable {
  margin-bottom: 18px;
}

.AvatarEditable label {
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 90px;
  margin: 0 auto;
  border-radius: 50%;
  color: white;
  background-color: var(--tg-primary);
  transition: transform 0.15s ease, background-color 0.15s;
}

.AvatarEditable label:hover {
  transform: scale(1.05);
}

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

.tg-input-group {
  text-align: left;
}

.tg-input-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tg-text-secondary);
  margin-bottom: 6px;
}

.tg-input-group input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-search-bg);
  color: var(--tg-text);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s;
}

.tg-input-group input:focus {
  border-color: var(--tg-primary);
}

.tg-btn-primary {
  background: var(--tg-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s;
}

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

.tg-btn-block {
  width: 100%;
}

.tg-auth-badge {
  margin-top: 18px;
  font-size: 12px;
  color: #f59e0b;
  font-weight: 600;
}

/* ==============================================================================
   2. HAMBURGER DRAWER MENU
   ============================================================================== */
.tg-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.tg-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.tg-drawer-menu {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 285px;
  background: var(--tg-bg-sidebar);
  z-index: 501;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
}

.tg-drawer-menu.open {
  transform: translateX(0);
}

.tg-drawer-header {
  background: var(--tg-primary);
  color: #fff;
  padding: 24px 18px 18px;
}

.tg-drawer-avatar {
  width: 56px;
  height: 56px;
  font-size: 20px;
  margin-bottom: 12px;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.tg-drawer-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tg-drawer-name {
  font-size: 16px;
  font-weight: 700;
}

.tg-star-badge {
  font-size: 15px;
}

.tg-drawer-handle {
  display: block;
  font-size: 13px;
  opacity: 0.85;
}

.tg-drawer-bio {
  display: block;
  font-size: 11.5px;
  opacity: 0.75;
  margin-top: 4px;
}

.tg-drawer-list {
  padding: 10px 0;
  flex: 1;
  overflow-y: auto;
}

.tg-drawer-row {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  gap: 16px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 500;
  transition: background-color 0.15s;
}

.tg-drawer-row:hover {
  background: var(--tg-item-hover);
}

.tg-row-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.tg-row-title {
  flex: 1;
}

.tg-vip-tag {
  background: #f59e0b;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
}

.tg-row-danger {
  color: #ef4444;
}

.tg-drawer-separator {
  height: 1px;
  background: var(--tg-borders);
  margin: 8px 0;
}

/* Switch Toggle */
.tg-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}

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

.tg-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  transition: .3s;
  border-radius: 22px;
}

.tg-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .tg-slider {
  background-color: var(--tg-primary);
}

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

/* ==============================================================================
   3. MAIN APPLICATION LAYOUT (2 Columns)
   ============================================================================== */
.tg-app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* LEFT SIDEBAR */
.tg-sidebar {
  width: 380px;
  min-width: 300px;
  max-width: 440px;
  background: var(--tg-bg-sidebar);
  border-right: 1px solid var(--tg-borders);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tg-sidebar-header {
  height: 56px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--tg-borders);
}

.tg-icon-btn {
  background: none;
  border: none;
  color: var(--tg-text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.tg-icon-btn:hover {
  background: var(--tg-item-hover);
}

.tg-search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.tg-search-lens {
  position: absolute;
  left: 12px;
  color: var(--tg-text-secondary);
  pointer-events: none;
}

.tg-search-wrapper input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: 22px;
  border: 1px solid transparent;
  background: var(--tg-search-bg);
  color: var(--tg-text);
  font-size: 13.5px;
  outline: none;
}

.tg-search-wrapper input:focus {
  border-color: var(--tg-primary);
  background: var(--tg-bg-sidebar);
}

.tg-tabs-nav {
  display: flex;
  padding: 0 10px;
  border-bottom: 1px solid var(--tg-borders);
  overflow-x: auto;
}

.tg-tab-btn {
  background: none;
  border: none;
  padding: 10px 14px;
  color: var(--tg-text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

.tg-tab-btn.active {
  color: var(--tg-primary);
}

.tg-tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 3px;
  background: var(--tg-primary);
  border-radius: 3px 3px 0 0;
}

.tg-chats-container {
  flex: 1;
  overflow-y: auto;
}

.tg-chat-row {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  gap: 12px;
  cursor: pointer;
  transition: background-color 0.15s;
  border-radius: 10px;
  margin: 2px 6px;
}

.tg-chat-row:hover {
  background: var(--tg-item-hover);
}

.tg-chat-row.active {
  background: var(--tg-primary);
  color: #fff !important;
}

.tg-chat-row.active .tg-chat-row-time,
.tg-chat-row.active .tg-chat-row-preview {
  color: rgba(255, 255, 255, 0.85) !important;
}

.tg-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--tg-grad-1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.tg-avatar-lg {
  width: 68px;
  height: 68px;
  font-size: 26px;
  margin: 0 auto 12px;
}

.tg-chat-row-body {
  flex: 1;
  min-width: 0;
}

.tg-chat-row-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}

.tg-chat-row-title {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-chat-row-time {
  font-size: 11.5px;
  color: var(--tg-text-secondary);
}

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

/* ==============================================================================
   4. CHAT PANE (Active Conversation)
   ============================================================================== */
.tg-chat-pane {
  flex: 1;
  /* As a flex item it would otherwise be at least as wide as its widest one-line child: a long
     message in the reply or edit bar (ellipsised, nowrap) pushed the composer buttons off screen. */
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--tg-bg-chat);
  height: 100%;
  position: relative;
}

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

.tg-back-mobile {
  display: none;
  background: none;
  border: none;
  font-size: 26px;
  color: var(--tg-primary);
  cursor: pointer;
  margin-right: 8px;
}

.tg-chat-title-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.tg-header-avatar {
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.tg-header-text {
  display: flex;
  flex-direction: column;
}

.tg-header-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tg-header-name-line h2 {
  font-size: 15.5px;
  font-weight: 700;
}

.tg-type-tag {
  font-size: 10px;
  font-weight: 700;
  background: var(--tg-primary-light);
  color: var(--tg-primary);
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

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

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

/* Pinned Bar */
.tg-pinned-banner {
  background: var(--tg-bg-sidebar);
  border-bottom: 1px solid var(--tg-borders);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9;
}

.tg-pinned-line {
  width: 3px;
  height: 28px;
  background: var(--tg-primary);
  border-radius: 2px;
}

.tg-pinned-text-wrap {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.tg-pinned-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--tg-primary);
}

.tg-pinned-text {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Messages Stream */
.tg-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--tg-bg-chat);
  background-image: url('patterns/kantor.svg');
  background-repeat: repeat;
  background-size: 420px auto;
  background-position: center;
}

body.theme-dark .tg-stream {
  background-color: #12111c;
  background-image: url('patterns/kantor-dark.svg');
}

.tg-welcome-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  text-align: center;
  color: var(--tg-text-secondary);
}

.tg-welcome-plane {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

/* Chat Bubbles */
.tg-bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 14px;
  position: relative;
  word-break: break-word;
  box-shadow: var(--tg-shadow);
}

.tg-bubble.incoming {
  align-self: flex-start;
  background-color: var(--tg-bubble-in);
  border-bottom-left-radius: 4px;
}

.tg-bubble.outgoing {
  align-self: flex-end;
  background-color: var(--tg-bubble-out);
  border-bottom-right-radius: 4px;
}

.tg-msg-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--tg-primary);
  margin-bottom: 3px;
}

.tg-reply-quote-box {
  border-left: 3px solid var(--tg-primary);
  background: rgba(0, 0, 0, 0.04);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 12px;
}

.tg-reply-quote-sender {
  font-weight: 700;
  color: var(--tg-primary);
  display: block;
}

.tg-reply-quote-text {
  color: var(--tg-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.tg-msg-text {
  font-size: 14.5px;
  line-height: 1.4;
}

.tg-msg-text code {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

body.theme-dark .tg-msg-text code {
  background: rgba(255, 255, 255, 0.12);
}

.tg-msg-text pre {
  background: rgba(0, 0, 0, 0.08);
  padding: 8px 12px;
  border-radius: 8px;
  margin: 6px 0;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.4;
}

body.theme-dark .tg-msg-text pre {
  background: rgba(0, 0, 0, 0.25);
}

.tg-msg-text a {
  color: var(--tg-primary);
  text-decoration: underline;
}

.tg-msg-edited-tag {
  font-size: 11px;
  color: var(--tg-text-secondary);
  font-style: italic;
  margin-right: 4px;
}

.tg-msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.04);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 4px;
  text-decoration: none;
  color: inherit;
}

.tg-msg-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.tg-voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tg-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.tg-voice-waveform {
  height: 20px;
  flex: 1;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
}

.tg-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: var(--tg-text-secondary);
  margin-top: 4px;
}

.outgoing .tg-msg-meta {
  color: var(--tg-bubble-out-meta);
}

.tg-check-marks {
  font-size: 12px;
}

/* Reactions on bubbles */
.tg-reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tg-rx-pill {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
}

.tg-rx-pill.active {
  background: rgba(75, 63, 160, 0.15);
  border-color: var(--tg-primary);
}

/* Typing Row */
.tg-typing-row {
  padding: 6px 20px;
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  background: var(--tg-bg-header);
  border-top: 1px solid var(--tg-borders);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tg-typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--tg-text-secondary);
  border-radius: 50%;
  animation: tg-bounce 1s infinite alternate;
}

.tg-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.tg-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tg-bounce {
  to { opacity: 0.2; transform: translateY(-4px); }
}

/* Reply Composer Bar */
.tg-reply-composer-bar {
  background: var(--tg-bg-sidebar);
  border-top: 1px solid var(--tg-borders);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tg-reply-bar-line {
  width: 3px;
  height: 28px;
  background: var(--tg-primary);
  border-radius: 2px;
}

.tg-reply-bar-details {
  flex: 1;
  min-width: 0;
}

.tg-reply-bar-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--tg-primary);
  display: block;
}

.tg-reply-bar-text {
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Edit Composer Bar */
.tg-edit-composer-bar {
  background: var(--tg-bg-sidebar);
  border-top: 1px solid var(--tg-borders);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tg-edit-bar-line {
  width: 3px;
  height: 28px;
  background: #f59e0b;
  border-radius: 2px;
}

.tg-edit-bar-details {
  flex: 1;
  min-width: 0;
}

.tg-edit-bar-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #f59e0b;
  display: block;
}

.tg-edit-bar-text {
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Voice Bar */
.tg-voice-bar {
  background: var(--tg-bg-sidebar);
  border-top: 1px solid var(--tg-borders);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tg-rec-dot {
  color: #ef4444;
  animation: pulse 1s infinite;
}

.tg-rec-timer {
  font-weight: 700;
  color: #ef4444;
}

.tg-rec-label {
  font-size: 13px;
  color: var(--tg-text-secondary);
  flex: 1;
}

/* Composer Footer */
.tg-composer-footer {
  padding: 10px 16px;
  background: var(--tg-bg-header);
  border-top: 1px solid var(--tg-borders);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.tg-composer-input-wrap {
  flex: 1;
}

.tg-composer-input-wrap textarea {
  width: 100%;
  border: 1px solid var(--tg-borders);
  background: var(--tg-search-bg);
  color: var(--tg-text);
  padding: 10px 14px;
  border-radius: 20px;
  resize: none;
  font-size: 14.5px;
  outline: none;
  max-height: 168px;
  overflow-y: auto;
}

.tg-composer-input-wrap textarea:focus {
  border-color: var(--tg-primary);
}

.tg-send-circle-btn {
  background: var(--tg-primary);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}

.tg-send-circle-btn:hover {
  background: var(--tg-primary-hover);
}

/* Emoji Popup */
.tg-emoji-popup {
  position: absolute;
  bottom: 66px;
  right: 20px;
  width: 330px;
  height: 310px;
  background: var(--tg-bg-sidebar);
  border: 1px solid var(--tg-borders);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.tg-emoji-nav {
  display: flex;
  border-bottom: 1px solid var(--tg-borders);
  padding: 8px 12px;
  gap: 8px;
}

.tg-emoji-tab {
  background: none;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tg-text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.tg-emoji-tab.active {
  color: var(--tg-primary);
  background: var(--tg-primary-light);
}

.tg-emoji-grid {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  font-size: 24px;
  text-align: center;
}

.tg-emoji-cell {
  cursor: pointer;
  border-radius: 6px;
  padding: 4px;
  transition: transform 0.1s;
}

.tg-emoji-cell:hover {
  transform: scale(1.2);
  background: rgba(0, 0, 0, 0.05);
}

/* Context Menu */
.tg-context-popup {
  position: fixed;
  background: var(--tg-bg-sidebar);
  border: 1px solid var(--tg-borders);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 300;
  width: 200px;
  padding: 6px 0;
}

.tg-reactions-strip {
  display: flex;
  justify-content: space-around;
  padding: 6px 10px;
  border-bottom: 1px solid var(--tg-borders);
  font-size: 20px;
}

.rx-btn {
  cursor: pointer;
  transition: transform 0.15s;
}

.rx-btn:hover {
  transform: scale(1.3);
}

.tg-ctx-item {
  padding: 8px 16px;
  font-size: 13.5px;
  cursor: pointer;
}

.tg-ctx-item:hover {
  background: var(--tg-item-hover);
}

.tg-ctx-line {
  height: 1px;
  background: var(--tg-borders);
  margin: 4px 0;
}

.tg-ctx-danger {
  color: #ef4444;
}

/* Modals */
.tg-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

/* Confirm and one-field prompts always open from inside another dialog (sticker
   manager, group info, call screen), so they stack above every dialog but stay
   below the tab-conflict screen. */
#confirm-modal {
  z-index: 4500;
}

.tg-dialog-card {
  background: var(--tg-bg-sidebar);
  border-radius: 16px;
  padding: 22px 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.tg-dialog-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.tg-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.tg-btn-sm {
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 13.5px;
}

.tg-btn-secondary {
  background: var(--tg-borders);
  color: var(--tg-text);
}

.tg-btn-xs {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--tg-text-secondary);
  cursor: pointer;
  padding: 4px;
}

.tg-info-body {
  text-align: center;
}

.tg-info-desc {
  font-size: 13px;
  color: var(--tg-text-secondary);
  margin: 6px 0 16px;
}

.tg-members-block {
  text-align: left;
  border-top: 1px solid var(--tg-borders);
  padding-top: 12px;
}

.tg-members-header {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--tg-text-secondary);
  margin-bottom: 8px;
}

.tg-members-scroll {
  max-height: 180px;
  overflow-y: auto;
}

.tg-member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.tg-member-item:hover {
  background: var(--tg-item-hover);
}

.tg-perks-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tg-perk-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.tg-perk-icon {
  font-size: 22px;
}

.tg-perk-row strong {
  font-size: 13.5px;
}

.tg-perk-row p {
  font-size: 12px;
  color: var(--tg-text-secondary);
  margin-top: 2px;
}

/* ==============================================================================
   5. COMPREHENSIVE SETTINGS MODAL STYLING
   ============================================================================== */
.tg-settings-card {
  max-width: 460px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
}

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

.tg-settings-scroll {
  overflow-y: auto;
  max-height: calc(85vh - 70px);
  padding-right: 4px;
}

.tg-settings-profile-card {
  background: var(--tg-search-bg);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 16px;
}

.tg-settings-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.tg-settings-name-row h3 {
  font-size: 17px;
  font-weight: 700;
}

.tg-settings-handle {
  font-size: 13px;
  color: var(--tg-primary);
  display: block;
}

.tg-settings-bio {
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  margin-top: 4px;
}

.tg-settings-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tg-settings-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--tg-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 10px 4px 6px;
}

.tg-settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.tg-settings-row:hover {
  background: var(--tg-item-hover);
}

.tg-settings-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tg-settings-row-title {
  font-size: 14px;
  font-weight: 600;
}

.tg-settings-row-desc {
  font-size: 12px;
  color: var(--tg-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-row-arrow {
  color: var(--tg-text-secondary);
  font-size: 18px;
}

.tg-wallpapers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tg-wp-card {
  border: 2px solid var(--tg-borders);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.15s;
}

.tg-wp-card:hover, .tg-wp-card.active {
  border-color: var(--tg-primary);
}

.tg-wp-sample {
  height: 64px;
  border-radius: 8px;
  margin-bottom: 6px;
}

.tg-wp-green,
.tg-wp-geo-green,
.tg-wp-kontur-green {
  background-color: #8ebe8a;
  background-size: 210px;
}

.tg-wp-dark,
.tg-wp-geo-dark,
.tg-wp-kontur-dark {
  background-color: #12111c;
  background-size: 210px;
}

.tg-wp-green { background-image: url('patterns/kantor.svg'); }
.tg-wp-dark { background-image: url('patterns/kantor-dark.svg'); }
.tg-wp-geo-green { background-image: url('patterns/geometri.svg'); }
.tg-wp-geo-dark { background-image: url('patterns/geometri-dark.svg'); }
.tg-wp-kontur-green { background-image: url('patterns/kontur.svg'); }
.tg-wp-kontur-dark { background-image: url('patterns/kontur-dark.svg'); }

.tg-wp-blue {
  background: linear-gradient(135deg, #4fc3f7, #0288d1);
}

.tg-wp-sunset {
  background: linear-gradient(135deg, #ff7043, #d84315);
}

.tg-font-size-options {
  display: flex;
  gap: 8px;
}

.tg-font-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-search-bg);
  color: var(--tg-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tg-font-btn.active {
  background: var(--tg-primary);
  color: #fff;
  border-color: var(--tg-primary);
}

.tg-settings-switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--tg-borders);
}

.tg-settings-switch-row strong {
  font-size: 14px;
  display: block;
}

.tg-settings-switch-row p {
  font-size: 12px;
  color: var(--tg-text-secondary);
}

.tg-storage-stat-box {
  background: var(--tg-search-bg);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tg-stat-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.tg-stat-item strong {
  color: var(--tg-primary);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .tg-sidebar {
    width: 100%;
    max-width: 100%;
  }

  .tg-chat-pane {
    position: fixed;
    inset: 0;
    z-index: 5;
    transform: translateX(100%);
    transition: transform 0.25s ease-in-out;
  }

  .tg-chat-pane.mobile-open {
    transform: translateX(0);
  }

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

/* ========================================================
   AUTHENTIC ATTACHMENT MENU, MODAL & MEDIA VIEW
   ======================================================== */

.tg-attach-btn-wrap {
  position: relative;
  display: inline-flex;
}

.tg-attach-popup {
  position: absolute;
  bottom: 50px;
  left: 0;
  min-width: 210px;
  background: var(--tg-panel-bg);
  border: 1px solid var(--tg-borders);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  padding: 6px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: tgPopupScale 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
  transform-origin: bottom left;
}

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

.tg-attach-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--tg-text);
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease;
}

.tg-attach-menu-item:hover {
  background: var(--tg-chat-hover);
}

.tg-attach-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.tg-attach-media-color {
  background: linear-gradient(135deg, #00c0ff, #0078d4);
}

.tg-attach-doc-color {
  background: linear-gradient(135deg, #4b3fa0, #3a3266);
}

.tg-attach-item-text {
  font-size: 13.5px;
  font-weight: 500;
}

/* Drag and Drop Overlay */
.tg-drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(75, 63, 160, 0.14);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border: 2px dashed var(--tg-primary);
  margin: 10px;
  border-radius: 16px;
}

.tg-drop-card {
  background: var(--tg-panel-bg);
  padding: 30px 40px;
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  text-align: center;
  animation: tgPopupScale 0.2s ease-out;
}

.tg-drop-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.tg-drop-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--tg-primary);
  margin-bottom: 4px;
}

.tg-drop-desc {
  font-size: 13px;
  color: var(--tg-text-secondary);
}

/* Attachment Confirmation Modal Backdrop & Card */
.tg-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tgFadeIn 0.15s ease-out;
}

.tg-modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--tg-text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.tg-modal-close:hover {
  background: var(--tg-chat-hover);
  color: var(--tg-text);
}

.tg-attach-modal-card {
  background: var(--tg-panel-bg);
  width: 90%;
  max-width: 460px;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: tgPopupScale 0.2s ease-out;
  margin: auto;
}

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

.tg-attach-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--tg-text);
}

.tg-attach-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tg-attach-preview-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tg-search-bg);
  border-radius: 12px;
  padding: 12px;
  min-height: 140px;
  max-height: 260px;
  overflow: hidden;
}

.tg-attach-preview-img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tg-attach-preview-file-box {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.tg-attach-preview-file-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--tg-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.tg-attach-preview-file-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tg-attach-preview-file-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-attach-preview-file-size {
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  margin-top: 3px;
}

.tg-attach-caption-wrap textarea {
  width: 100%;
  border: 1px solid var(--tg-borders);
  border-radius: 10px;
  background: var(--tg-search-bg);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--tg-text);
  resize: none;
  font-family: inherit;
  box-sizing: border-box;
}

.tg-attach-caption-wrap textarea:focus {
  outline: none;
  border-color: var(--tg-primary);
}

.tg-attach-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--tg-borders);
  background: rgba(0, 0, 0, 0.02);
}

.tg-attach-meta-text {
  font-size: 12px;
  color: var(--tg-text-secondary);
  font-weight: 500;
}

.tg-attach-actions {
  display: flex;
  gap: 10px;
}

/* Chat Message Bubbles - Photo Rendering */
.tg-msg-photo-wrap {
  position: relative;
  max-width: 360px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 4px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.05);
}

.tg-msg-photo-wrap img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
  border-radius: 12px;
  transition: transform 0.2s ease;
}

.tg-msg-photo-wrap:hover img {
  transform: scale(1.015);
}

.tg-photo-pill-meta {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

/* Chat Message Bubbles - Authentic Document Box */
.tg-msg-doc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.05);
  padding: 8px 12px;
  border-radius: 10px;
  margin-top: 4px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
  min-width: 220px;
  max-width: 340px;
}

.tg-msg-doc-card:hover {
  background: rgba(0, 0, 0, 0.08);
}

.tg-msg.outgoing .tg-msg-doc-card {
  background: rgba(0, 0, 0, 0.06);
}

.tg-msg.outgoing .tg-msg-doc-card:hover {
  background: rgba(0, 0, 0, 0.1);
}

.tg-msg-doc-card.is-missing,
.tg-msg-doc-card.is-missing:hover {
  background: rgba(0, 0, 0, 0.04);
  cursor: default;
}

.tg-msg-doc-card.is-missing .tg-doc-badge-circle {
  background: var(--tg-text-secondary);
  opacity: 0.55;
}

.tg-msg-doc-card.is-missing .tg-doc-name-text {
  color: var(--tg-text-secondary);
  text-decoration: line-through;
}

.tg-doc-badge-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.ext-pdf { background: linear-gradient(135deg, #e53935, #d32f2f); }
.ext-doc, .ext-docx, .ext-txt { background: linear-gradient(135deg, #1e88e5, #1976d2); }
.ext-xls, .ext-xlsx, .ext-csv { background: linear-gradient(135deg, #43a047, #388e3c); }
.ext-zip, .ext-rar, .ext-7z, .ext-tar { background: linear-gradient(135deg, #fb8c00, #f57c00); }
.ext-code { background: linear-gradient(135deg, #8e24aa, #7b1fa2); }
.ext-default { background: linear-gradient(135deg, #3a3266, #4b3fa0); }

.tg-doc-text-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.tg-doc-name-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-doc-sub-text {
  font-size: 11.5px;
  color: var(--tg-text-secondary);
  margin-top: 2px;
}

.tg-doc-download-icon {
  color: var(--tg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Photo Lightbox / Media Viewer */
.tg-lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: tgFadeIn 0.2s ease-out;
}

.tg-lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  z-index: 10;
}

.tg-lightbox-info {
  display: flex;
  flex-direction: column;
  color: #fff;
}

#lightbox-sender-name {
  font-size: 15px;
  font-weight: 700;
}

.tg-lightbox-date {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.tg-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tg-lightbox-action-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  text-decoration: none;
  transition: background 0.2s ease;
}

.tg-lightbox-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.tg-lightbox-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

#lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  animation: tgPopupScale 0.2s ease-out;
}

.tg-lightbox-caption {
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 24px;
  font-size: 14px;
}


/* ---------- Reply jump, history, date dividers, in-chat search ---------- */
.tg-reply-quote-link {
  cursor: pointer;
}

.tg-reply-quote-link:hover {
  background: var(--tg-primary-light);
}

@keyframes tgBubbleFlash {
  0%, 40% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.85); }
  100% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0); }
}

.tg-bubble-flash {
  animation: tgBubbleFlash 1.6s ease-out;
}

.tg-date-divider {
  align-self: center;
  margin: 4px 0;
  pointer-events: none;
}

.tg-date-divider span {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
}

.tg-scroll-fab {
  position: absolute;
  right: 20px;
  bottom: 84px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--tg-bg-sidebar);
  color: var(--tg-text-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 8;
}

.tg-scroll-fab:hover {
  color: var(--tg-primary);
}

.tg-chat-search-bar {
  background: var(--tg-bg-sidebar);
  border-bottom: 1px solid var(--tg-borders);
  padding: 6px 12px;
  align-items: center;
  gap: 6px;
  z-index: 9;
}

.tg-chat-search-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  border-radius: 16px;
  padding: 7px 12px;
  background: var(--tg-search-bg);
  color: var(--tg-text);
  font-size: 14px;
}

.tg-chat-search-count {
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  white-space: nowrap;
}

.tg-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(10px);
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
}

.tg-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Unread badges, drafts, forwarded header ---------- */
.tg-chat-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tg-chat-row-bottom .tg-chat-row-preview {
  flex: 1;
  min-width: 0;
}

.tg-unread-badge {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--tg-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  box-sizing: border-box;
}

.tg-chat-row.active .tg-unread-badge {
  background: #fff;
  color: var(--tg-primary);
}

.tg-draft-label {
  color: #e53935;
  font-weight: 500;
}

.tg-chat-row.active .tg-draft-label {
  color: #fff;
}

.tg-fwd-header {
  font-size: 12.5px;
  color: var(--tg-primary);
  margin-bottom: 4px;
}

/* ---------- Update bar (bottom of chat list) ---------- */
.tg-update-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--tg-borders);
  background: var(--tg-primary-light);
}

.tg-update-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--tg-text);
}

.tg-update-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 16px;
  padding: 6px 14px;
  background: var(--tg-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tg-update-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Inline video ---------- */
.tg-msg-video-wrap {
  max-width: 360px;
  margin-top: 4px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.tg-msg-video-wrap video {
  display: block;
  width: 100%;
  max-height: 380px;
}

.tg-msg-video-fallback {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--tg-primary);
  word-break: break-all;
}

.tg-attach-preview-video {
  display: block;
  width: 100%;
  max-height: 300px;
  border-radius: 10px;
  background: #000;
}

/* ==============================================================================
   Presence, mute, pinned chats, @mentions
   ============================================================================== */
.tg-avatar {
  position: relative;
}

.tg-online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--tg-bg-sidebar);
  box-sizing: border-box;
}

.tg-chat-row.active .tg-online-dot {
  border-color: var(--tg-primary);
}

.tg-header-status.online {
  color: var(--tg-primary);
}

.tg-chat-row-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.tg-muted-icon {
  flex-shrink: 0;
  font-size: 11px;
  opacity: 0.6;
}

.tg-unread-badge.muted {
  background: var(--tg-text-secondary);
}

.tg-unread-badge.mark {
  min-width: 12px;
  height: 12px;
  padding: 0;
  margin: 4px 4px 4px 0;
}

.tg-chat-row.active .tg-unread-badge.muted {
  background: rgba(255, 255, 255, 0.75);
}

.tg-mention-badge {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--tg-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.tg-chat-row.active .tg-mention-badge {
  background: #fff;
  color: var(--tg-primary);
}

.tg-pin-icon {
  flex-shrink: 0;
  font-size: 12px;
  opacity: 0.55;
}

#chat-context-menu {
  width: 220px;
}

.tg-mute-options {
  display: flex;
  flex-direction: column;
  padding: 4px 0 2px;
}

.tg-mute-options button {
  text-align: left;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--tg-text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.tg-mute-options button:hover,
.tg-mute-options button:focus-visible {
  background: var(--tg-item-hover);
  outline: none;
}

.tg-composer-input-wrap {
  position: relative;
}

.tg-mention-popup {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  max-width: 360px;
  padding: 6px 0;
  background: var(--tg-bg-sidebar);
  border: 1px solid var(--tg-borders);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 250;
}

.tg-mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
}

.tg-mention-item.active,
.tg-mention-item:hover {
  background: var(--tg-item-hover);
}

.tg-avatar.tg-avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.tg-avatar-sm .tg-online-dot {
  width: 10px;
  height: 10px;
}

.tg-mention-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-mention-username {
  font-size: 13px;
  color: var(--tg-text-secondary);
  white-space: nowrap;
}

.tg-mention {
  color: var(--tg-primary);
  font-weight: 500;
  cursor: pointer;
}

.tg-mention-me {
  background: rgba(75, 63, 160, 0.15);
  border-radius: 4px;
  padding: 0 2px;
}

.tg-bubble.outgoing .tg-mention {
  color: inherit;
  text-decoration: underline;
}

/* ==============================================================================
   Folder tabs, delete/leave dialogs, forum topics
   ============================================================================== */
.tg-tabs-nav {
  align-items: center;
  scrollbar-width: none;
}

.tg-tabs-nav::-webkit-scrollbar {
  display: none;
}

.tg-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.tg-tab-emoji {
  font-size: 13px;
}

.tg-tab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--tg-text-secondary);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

.tg-tab-btn.active .tg-tab-badge,
.tg-tab-badge.mention {
  background: var(--tg-primary);
}

.tg-tab-edit {
  flex-shrink: 0;
  margin-left: auto;
  background: none;
  border: none;
  padding: 8px 10px;
  color: var(--tg-text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
}

.tg-tab-edit:hover {
  color: var(--tg-primary);
  background: var(--tg-item-hover);
}

.tg-empty-list {
  padding: 24px 16px;
  text-align: center;
  color: var(--tg-text-secondary);
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tg-empty-edit {
  color: var(--tg-primary) !important;
  font-weight: 600;
}

/* Confirmation dialog */
.tg-confirm-body {
  margin: 4px 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--tg-text);
}

.tg-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tg-confirm-btn {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: var(--tg-search-bg);
  color: var(--tg-primary);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.tg-confirm-btn:hover,
.tg-confirm-btn:focus-visible {
  background: var(--tg-item-hover);
  outline: none;
}

.tg-confirm-btn.danger {
  color: #ef4444;
}

.tg-confirm-btn.cancel {
  background: none;
  color: var(--tg-text-secondary);
  font-weight: 500;
}

/* Info modal actions */
.tg-info-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  text-align: left;
}

.tg-info-actions:empty {
  display: none;
}

.tg-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--tg-search-bg);
  cursor: pointer;
}

.tg-switch-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tg-switch-title {
  font-size: 14px;
  font-weight: 600;
}

.tg-switch-desc {
  font-size: 12px;
  color: var(--tg-text-secondary);
}

.tg-switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--tg-borders);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.tg-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.tg-switch:checked {
  background: var(--tg-primary);
}

.tg-switch:checked::after {
  transform: translateX(16px);
}

.tg-switch:focus-visible {
  outline: 2px solid var(--tg-primary);
  outline-offset: 2px;
}

.tg-info-danger {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: #ef4444;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.tg-info-danger:hover,
.tg-info-danger:focus-visible {
  background: rgba(239, 68, 68, 0.08);
  outline: none;
}

/* Shared form bits */
.tg-field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tg-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tg-folder-edit-body input[type="text"],
.tg-topic-form input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-search-bg);
  color: var(--tg-text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.tg-folder-edit-body input[type="text"]:focus,
.tg-topic-form input[type="text"]:focus {
  border-color: var(--tg-primary);
}

.tg-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
}

.tg-check-row:hover {
  background: var(--tg-item-hover);
}

.tg-check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--tg-primary);
}

.tg-form-error {
  min-height: 1em;
  margin: 10px 0 0;
  font-size: 13px;
  color: #ef4444;
}

/* Folder manager and editor */
.tg-folder-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--tg-text-secondary);
}

.tg-folder-manage-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 360px;
  overflow-y: auto;
}

.tg-folder-manage-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
}

.tg-folder-manage-row:hover {
  background: var(--tg-item-hover);
}

.tg-folder-manage-emoji {
  width: 32px;
  font-size: 20px;
  text-align: center;
  flex-shrink: 0;
}

.tg-folder-manage-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tg-folder-manage-title {
  font-size: 14px;
  font-weight: 600;
}

.tg-folder-manage-desc {
  font-size: 12px;
  color: var(--tg-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-folder-manage-row .tg-btn-xs:disabled {
  opacity: 0.3;
  cursor: default;
}

.tg-folder-new {
  width: 100%;
  margin-top: 12px;
}

.tg-folder-edit-card {
  max-width: 460px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.tg-folder-edit-body {
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.tg-emoji-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tg-emoji-choice {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--tg-search-bg);
  font-size: 18px;
  cursor: pointer;
  color: var(--tg-text-secondary);
}

.tg-emoji-choice.selected {
  border-color: var(--tg-primary);
}

.tg-folder-chat-list {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--tg-borders);
  border-radius: 10px;
}

.tg-folder-chat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--tg-borders);
}

.tg-folder-chat-row:last-child {
  border-bottom: none;
}

.tg-folder-chat-name {
  min-width: 0;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-folder-chat-name small {
  margin-left: 6px;
  font-size: 11.5px;
  color: var(--tg-text-secondary);
}

.tg-folder-chat-row select {
  flex-shrink: 0;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-bg-sidebar);
  color: var(--tg-text);
  font: inherit;
  font-size: 12.5px;
}

.tg-chat-folders-list {
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow-y: auto;
}

/* Forum topics */
.tg-topic-back {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--tg-primary);
  cursor: pointer;
  margin-right: 6px;
  padding: 0 4px;
}

.tg-topic-view {
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--tg-bg-sidebar);
}

.tg-topic-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--tg-borders);
}

.tg-topic-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-text-secondary);
}

.tg-topic-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.tg-topic-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
}

.tg-topic-row:hover,
.tg-topic-row:focus-visible {
  background: var(--tg-item-hover);
  outline: none;
}

.tg-topic-row.unread .tg-chat-row-title {
  font-weight: 700;
}

.tg-topic-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.tg-topic-icon-lg {
  width: 64px;
  height: 64px;
  font-size: 26px;
}

.tg-topic-lock {
  flex-shrink: 0;
  font-size: 11px;
}

.tg-topic-sender {
  color: var(--tg-text);
  font-weight: 500;
}

.tg-topic-closed-bar {
  padding: 14px 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--tg-text-secondary);
  background: var(--tg-bg-sidebar);
  border-top: 1px solid var(--tg-borders);
}

.tg-topic-preview {
  display: flex;
  justify-content: center;
  margin: 4px 0 6px;
}

.tg-color-choices {
  display: flex;
  gap: 10px;
}

.tg-color-choice {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.tg-color-choice.selected {
  border-color: var(--tg-text);
}

.tg-color-choice:focus-visible,
.tg-emoji-choice:focus-visible {
  outline: 2px solid var(--tg-primary);
  outline-offset: 2px;
}

.tg-tabs-nav {
  overflow: hidden;
  padding-right: 4px;
}

.tg-tab-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.tg-tab-scroll::-webkit-scrollbar {
  display: none;
}

/* Status text over the wallpaper needs its own backdrop to stay readable. */
.tg-stream .tg-welcome-placeholder > p:only-child {
  padding: 6px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 13.5px;
}

/* The editor body already scrolls; avoid a second scroll area inside it. */
.tg-folder-edit-body .tg-folder-chat-list {
  max-height: none;
  overflow: visible;
}

/* Topic system messages (created / renamed / closed / hidden) */
.tg-bubble.system {
  align-self: center;
  max-width: 86%;
  padding: 0;
  background: none;
  box-shadow: none;
  text-align: center;
}

.tg-system-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
}

/* Hidden General topic sits at the end of the list */
.tg-topic-row.is-hidden .tg-chat-row-title,
.tg-topic-row.is-hidden .tg-chat-row-preview {
  opacity: 0.6;
}

.tg-topic-hidden-tag {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--tg-item-hover);
  color: var(--tg-text-secondary);
  font-size: 11px;
  font-weight: 500;
}

/* Folder drag-to-reorder */
.tg-drag-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
  padding: 4px 6px;
  color: var(--tg-text-secondary);
  font-size: 16px;
  line-height: 1;
}

.tg-folder-manage-row.dragging {
  background: var(--tg-item-hover);
  box-shadow: var(--tg-shadow);
  position: relative;
  z-index: 1;
}

.tg-folder-manage-row.dragging .tg-drag-handle {
  cursor: grabbing;
}

/* ===================================================================== */
/* Backlog 7–16                                                          */
/* ===================================================================== */

/* Pinned bar: one segment per pin (up to 4), the shown pin highlighted */
.tg-pinned-segments {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 3px;
  height: 30px;
  flex-shrink: 0;
}
.tg-pinned-segments span {
  flex: 1;
  border-radius: 2px;
  background: var(--tg-primary);
  opacity: 0.35;
}
.tg-pinned-segments span.active { opacity: 1; }
.tg-pinned-text-wrap { flex: 1; min-width: 0; cursor: pointer; }

/* Audio player pane */
.tg-audio-pane {
  background: var(--tg-bg-sidebar);
  border-bottom: 1px solid var(--tg-borders);
  padding: 4px 12px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 9;
}
.tg-audio-pane .tg-btn-xs:disabled { opacity: 0.35; cursor: default; }
.tg-audio-play { color: var(--tg-primary); font-size: 16px; }
.tg-audio-info { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.tg-audio-title { font-size: 13px; font-weight: 600; color: var(--tg-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-audio-sub { font-size: 11.5px; color: var(--tg-text-secondary); }
.tg-audio-rate { font-weight: 700; min-width: 34px; }
.tg-audio-seek {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 4px;
  margin: 0;
  accent-color: var(--tg-primary);
  cursor: pointer;
}

/* Select mode */
.tg-stream.select-mode .tg-bubble:not(.system) { cursor: pointer; }
.tg-stream.select-mode .tg-bubble.selected { outline: 2px solid var(--tg-primary); outline-offset: 2px; }
.tg-stream.select-mode .tg-quick-rx { display: none !important; }
.tg-select-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--tg-bg-sidebar);
  border-top: 1px solid var(--tg-borders);
}
.tg-select-count { flex: 1; font-size: 14px; font-weight: 600; color: var(--tg-text); }
.tg-select-delete {
  background: #e53935;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}
.tg-select-delete:disabled { opacity: 0.4; cursor: default; }

/* Quick reaction (desktop hover) */
.tg-bubble { position: relative; }
.tg-quick-rx {
  position: absolute;
  bottom: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--tg-borders);
  background: var(--tg-bg-sidebar);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.tg-bubble.incoming .tg-quick-rx { right: -36px; }
.tg-bubble.outgoing .tg-quick-rx { left: -36px; }
/* The button sits 8px outside the bubble; this invisible strip bridges that gap so the
   pointer stays inside the bubble's :hover on its way to the button. */
.tg-quick-rx::before { content: ''; position: absolute; top: -4px; bottom: -4px; width: 12px; }
.tg-bubble.incoming .tg-quick-rx::before { left: -12px; }
.tg-bubble.outgoing .tg-quick-rx::before { right: -12px; }
@media (hover: hover) {
  .tg-bubble:hover .tg-quick-rx { opacity: 1; pointer-events: auto; }
}

/* Stickers */
.tg-bubble.sticker { background: none !important; box-shadow: none; padding: 0; }
.tg-msg-sticker img { width: 140px; height: 140px; object-fit: contain; display: block; }
.tg-bubble.sticker .tg-msg-meta {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
}

/* Video expand button */
.tg-msg-video-wrap { position: relative; }
.tg-video-expand {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.tg-audio-file-play { margin-right: 8px; }

/* Clickable system notices (pins) */
.tg-bubble.system.clickable .tg-system-pill { cursor: pointer; }
.tg-bubble.system.clickable .tg-system-pill:hover { background: rgba(0, 0, 0, 0.42); }

/* Context menu: scrollable reaction strip and info rows */
.tg-context-popup { width: 230px; }
.tg-reactions-strip { overflow-x: auto; justify-content: flex-start; gap: 8px; scrollbar-width: none; }
.tg-reactions-strip::-webkit-scrollbar { display: none; }
.rx-btn:hover { transform: scale(1.2); }
.tg-ctx-info { font-size: 12.5px; color: var(--tg-text-secondary); }
.tg-ctx-info.static { cursor: default; }
.tg-ctx-info.static:hover { background: none; }
.tg-dialog-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13.5px; cursor: pointer; }
.tg-dialog-hint { display: block; margin-top: 10px; font-size: 12.5px; color: var(--tg-text-secondary); }

/* Generic sheet */
.tg-sheet-card { max-width: 400px; max-height: 80vh; display: flex; flex-direction: column; }
.tg-sheet-body { overflow-y: auto; margin: 0 -8px; padding: 0 8px; flex: 1; min-height: 60px; }
.tg-sheet-tabs { margin-bottom: 8px; }
.tg-sheet-footer { padding-top: 12px; }
.tg-sheet-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 10px; }
.tg-sheet-row.clickable { cursor: pointer; }
.tg-sheet-row.clickable:hover { background: var(--tg-item-hover); }
.tg-sheet-avatar { width: 38px; height: 38px; font-size: 14px; flex-shrink: 0; }
.tg-sheet-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tg-sheet-row-title { font-size: 14px; font-weight: 600; color: var(--tg-text); }
.tg-sheet-row-sub { font-size: 12.5px; color: var(--tg-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-sheet-row-right { font-size: 20px; }
.tg-sheet-danger, .tg-sheet-primary {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
}
.tg-sheet-danger { background: rgba(229, 57, 53, 0.12); color: #e53935; }
.tg-sheet-primary { background: var(--tg-primary); color: #fff; }
.tg-sheet-actions { display: flex; gap: 8px; }
.tg-pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tg-pill-tabs button {
  border: 1px solid var(--tg-borders);
  background: none;
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--tg-text);
}
.tg-pill-tabs button.active { background: var(--tg-primary); color: #fff; border-color: var(--tg-primary); }
.tg-radio-list { display: flex; flex-direction: column; gap: 2px; }
.tg-radio-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--tg-text); }
.tg-radio-row:hover { background: var(--tg-item-hover); }
.tg-radio-emoji { font-size: 22px; }
.tg-rx-checks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.tg-rx-check { display: flex; align-items: center; gap: 4px; font-size: 20px; cursor: pointer; }
.tg-info-row-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 0;
  cursor: pointer;
  text-align: left;
  color: var(--tg-text);
}

/* In-chat search filters */
.tg-search-chips { display: flex; gap: 4px; flex-shrink: 0; }
.tg-chip {
  background: rgba(75, 63, 160, 0.14);
  color: var(--tg-primary);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tg-hidden-date { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.tg-chat-search-bar { position: relative; }
.tg-chat-search-bar input[type="text"] { flex: 1; min-width: 60px; }

/* Sidebar search tabs, date suggestions, result headings */
.tg-search-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--tg-borders);
  scrollbar-width: none;
}
.tg-search-tabs::-webkit-scrollbar { display: none; }
.tg-search-tabs button {
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tg-text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.tg-search-tabs button.active { background: rgba(75, 63, 160, 0.14); color: var(--tg-primary); }
.tg-date-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
.tg-date-suggest button {
  border: 1px solid var(--tg-borders);
  background: var(--tg-bg-sidebar);
  color: var(--tg-text);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.tg-search-head { padding: 8px 16px 4px; font-size: 12px; font-weight: 700; color: var(--tg-text-secondary); text-transform: capitalize; }

/* Media viewer */
.tg-lightbox-info[role="button"] { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; }
.tg-mv-avatar { width: 36px; height: 36px; font-size: 13px; }
.tg-mv-text { display: flex; flex-direction: column; }
.tg-mv-counter { color: rgba(255, 255, 255, 0.8); font-size: 13px; }
.tg-mv-rate {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 6px 8px;
  cursor: pointer;
}
.tg-mv-rate option { color: #000; }
.tg-lightbox-body { position: relative; }
.tg-mv-media { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.tg-mv-media img, .tg-mv-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  transition: transform 0.12s ease-out;
}
.tg-mv-media img.zoomed { cursor: grab; transition: none; }
.tg-mv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  z-index: 2;
}
.tg-mv-nav.prev { left: 16px; }
.tg-mv-nav.next { right: 16px; }
.tg-lightbox-caption { cursor: pointer; }
@media (hover: none) {
  .tg-mv-nav { display: none; }
}

/* Emoji / sticker / GIF picker */
.tg-emoji-popup { width: 352px; height: 400px; }
.tg-emoji-nav { align-items: center; }
.tg-emoji-tab.active { color: var(--tg-primary); background: rgba(75, 63, 160, 0.12); }
.tg-emoji-manage {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--tg-text-secondary);
}
.tg-emoji-search {
  margin: 8px 10px 0;
  padding: 7px 12px;
  border-radius: 16px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-search-bg, var(--tg-bg-secondary));
  color: var(--tg-text);
  font-size: 13px;
  outline: none;
}
.tg-emoji-cats { display: flex; gap: 2px; padding: 6px 8px 0; overflow-x: auto; scrollbar-width: none; }
.tg-emoji-cats button { background: none; border: none; font-size: 18px; cursor: pointer; padding: 3px 5px; border-radius: 8px; }
.tg-emoji-cats button:hover { background: var(--tg-item-hover); }
.tg-emoji-grid { grid-template-columns: repeat(8, 1fr); gap: 2px; font-size: 22px; align-content: start; }
.tg-emoji-grid .emoji-cell { cursor: pointer; border-radius: 8px; padding: 3px 0; }
.tg-emoji-grid .emoji-cell:hover { background: var(--tg-item-hover); }
.tg-emoji-head {
  grid-column: 1 / -1;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--tg-text-secondary);
  padding: 6px 2px 2px;
}
.tg-emoji-grid.media { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tg-sticker-cell { cursor: pointer; border-radius: 10px; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.tg-sticker-cell:hover { background: var(--tg-item-hover); }
.tg-sticker-cell img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tg-picker-empty { grid-column: 1 / -1; padding: 24px 12px; font-size: 13px; color: var(--tg-text-secondary); text-align: center; }

/* Sticker manager */
.tg-set-box { border: 1px solid var(--tg-borders); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.tg-set-head { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--tg-text); }
.tg-set-kind { font-size: 12px; color: var(--tg-text-secondary); }
.tg-set-actions { margin-left: auto; display: flex; gap: 4px; }
.tg-set-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.tg-set-item { position: relative; aspect-ratio: 1; border-radius: 8px; background: var(--tg-item-hover); display: flex; align-items: center; justify-content: center; }
.tg-set-item img { max-width: 90%; max-height: 90%; object-fit: contain; }
.tg-set-item span { position: absolute; bottom: 1px; left: 3px; font-size: 13px; }
.tg-set-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #e53935;
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .tg-emoji-popup { right: 8px; left: 8px; width: auto; }
  .tg-quick-rx { display: none; }
  .tg-lightbox-actions { gap: 6px; }
  .tg-lightbox-action-btn { width: 34px; height: 34px; font-size: 15px; }
  #mv-zoom-in, #mv-zoom-out { display: none !important; }
}
.tg-ask-input {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--tg-borders);
  background: var(--tg-bg-secondary);
  color: var(--tg-text);
  font-size: 14px;
  box-sizing: border-box;
}
.tg-audio-pane .tg-btn-xs { font-size: 15px; min-width: 28px; }
.tg-audio-pane .tg-audio-rate { font-size: 12.5px; }
.tg-audio-pane .tg-btn-xs { color: var(--tg-text); }
.tg-audio-pane .tg-audio-play { color: var(--tg-primary); }

/* ===================================================================== */
/* Backlog 17–28                                                         */
/* ===================================================================== */

/* Chat management rows, checklists of rights and permissions */
.tg-info-manage { width: 100%; margin: 6px 0; }
.tg-member-item.clickable { cursor: pointer; border-radius: 10px; }
.tg-member-item.clickable:hover { background: var(--tg-item-hover); }
.tg-check-list { display: flex; flex-direction: column; gap: 2px; }
.tg-check-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; font-size: 14px; color: var(--tg-text); cursor: pointer; }
.tg-check-row:hover { background: var(--tg-item-hover); }
.tg-check-row.disabled { opacity: 0.5; cursor: default; }
.tg-sheet-note { font-size: 12.5px; color: var(--tg-text-secondary); margin: 4px 0; }
.tg-sheet-head { font-size: 12px; font-weight: 700; color: var(--tg-text-secondary); text-transform: uppercase; letter-spacing: 0.3px; margin: 14px 0 4px; }
.tg-invite-primary code {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--tg-item-hover);
  font-size: 12.5px;
  word-break: break-all;
  margin: 8px 0;
}
.tg-sheet-row .tg-btn-xs { flex-shrink: 0; }
.tg-btn-xs.tg-btn-primary { background: var(--tg-primary); color: #fff; }
.tg-join-preview { text-align: center; }
.tg-join-preview .tg-avatar-lg { margin: 0 auto 8px; }
.tg-join-members { display: flex; justify-content: center; gap: 4px; margin-top: 8px; }

/* Shared media tabs in chat info */
.tg-info-tabs { display: flex; gap: 2px; overflow-x: auto; width: 100%; border-bottom: 1px solid var(--tg-borders); margin-top: 8px; scrollbar-width: none; }
.tg-info-tabs::-webkit-scrollbar { display: none; }
.tg-info-tabs button { background: none; border: none; padding: 8px 10px; font-size: 12.5px; font-weight: 600; color: var(--tg-text-secondary); cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; }
.tg-info-tabs button.active { color: var(--tg-primary); border-bottom-color: var(--tg-primary); }
.tg-info-tab-body { width: 100%; max-height: 320px; overflow-y: auto; margin-top: 6px; }
.tg-info-tab-body.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.tg-info-media { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 6px; cursor: pointer; background: var(--tg-item-hover); }
.tg-info-media img, .tg-info-media video { width: 100%; height: 100%; object-fit: cover; }
.tg-info-media span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }

/* Polls and checklists */
.tg-poll, .tg-todo { min-width: 240px; max-width: 340px; }
.tg-poll-head { display: flex; align-items: center; gap: 6px; }
.tg-poll-type { font-size: 12px; color: var(--tg-text-secondary); }
.tg-poll-voters { display: flex; }
.tg-mini-avatar { width: 18px; height: 18px; border-radius: 50%; background: var(--tg-primary); color: #fff; font-size: 8px; display: inline-flex; align-items: center; justify-content: center; margin-left: -4px; border: 1px solid var(--tg-bg-sidebar); }
.tg-poll-q { font-weight: 700; font-size: 14.5px; margin: 4px 0 8px; color: var(--tg-text); }
.tg-poll-options { display: flex; flex-direction: column; gap: 6px; }
.tg-poll-choice { display: flex; align-items: center; gap: 10px; padding: 7px 4px; cursor: pointer; border-radius: 8px; font-size: 14px; }
.tg-poll-choice:hover { background: rgba(0, 0, 0, 0.05); }
.tg-poll-choice.static { cursor: default; }
.tg-poll-choice.static:hover { background: none; }
.tg-poll-radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--tg-text-secondary); flex-shrink: 0; }
.tg-poll-result-top { display: flex; align-items: baseline; gap: 6px; font-size: 14px; }
.tg-poll-pct { font-weight: 700; min-width: 36px; }
.tg-poll-text { flex: 1; }
.tg-poll-names { font-size: 11px; color: var(--tg-text-secondary); }
.tg-poll-mark { color: var(--tg-primary); font-weight: 700; }
.tg-poll-mark.ok { color: #22a35a; }
.tg-poll-mark.bad { color: #e53935; }
.tg-poll-bar { height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.08); margin-top: 3px; }
.tg-poll-bar span { display: block; height: 100%; border-radius: 2px; background: var(--tg-primary); transition: width 0.3s; }
.tg-poll-result.voted .tg-poll-bar span { background: #22a35a; }
.tg-poll-foot { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 8px; }
.tg-poll-foot button, .tg-poll-explain, .tg-todo-add { background: none; border: none; color: var(--tg-primary); font-weight: 600; cursor: pointer; font-size: 13px; }
.tg-poll-total { font-size: 12px; color: var(--tg-text-secondary); }
.tg-poll-ends { font-size: 11.5px; color: var(--tg-text-secondary); text-align: center; }
.tg-poll-add { width: 100%; margin-top: 6px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--tg-borders); background: transparent; color: var(--tg-text); box-sizing: border-box; }
.tg-poll-expl { font-size: 12.5px; background: rgba(75, 63, 160, 0.1); border-radius: 8px; padding: 6px 10px; margin-top: 4px; }
.tg-poll-form-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tg-poll-form-row .tg-ask-input { margin-top: 0; }
.tg-todo-items { display: flex; flex-direction: column; gap: 4px; }
.tg-todo-item { display: flex; align-items: flex-start; gap: 10px; padding: 5px 2px; font-size: 14px; cursor: pointer; }
.tg-todo-item.readonly { cursor: default; }
.tg-todo-item.done .tg-todo-text { color: var(--tg-text-secondary); text-decoration: line-through; }
.tg-todo-text { display: flex; flex-direction: column; }
.tg-todo-by { font-size: 11px; text-decoration: none; color: var(--tg-text-secondary); }
.tf-item { margin-bottom: 6px; }

/* Channel comments */
.tg-comment-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 8px 2px 2px;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: none;
  color: var(--tg-primary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.tg-comment-chev { margin-left: auto; }

/* Link previews */
.tg-link-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--tg-bg-sidebar);
  border-top: 1px solid var(--tg-borders);
}
.tg-lp-icon { color: var(--tg-primary); font-size: 16px; }
.tg-lp-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.tg-lp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; border-left: 2px solid var(--tg-primary); padding-left: 8px; }
.tg-lp-text b { font-size: 13px; color: var(--tg-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-lp-text span { font-size: 12.5px; color: var(--tg-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-webpage {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 8px 6px 10px;
  border-left: 3px solid var(--tg-primary);
  border-radius: 4px 8px 8px 4px;
  background: rgba(75, 63, 160, 0.08);
  text-decoration: none;
  color: inherit;
  max-width: 360px;
}
.tg-webpage.large { flex-direction: column; }
.tg-wp-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tg-wp-site { font-size: 12.5px; font-weight: 700; color: var(--tg-primary); }
.tg-wp-title { font-size: 13.5px; font-weight: 600; color: var(--tg-text); }
.tg-wp-desc { font-size: 12.5px; color: var(--tg-text); opacity: 0.85; }
.tg-wp-img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.tg-wp-img.large { width: 100%; height: auto; max-height: 220px; }
/* YouTube: thumbnail with a play button, replaced by the player when clicked */
.tg-wp-video { width: 360px; max-width: 100%; }
.tg-wp-video .tg-wp-title { text-decoration: none; }
.tg-wp-video .tg-wp-title:hover { text-decoration: underline; }
.tg-wp-player { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: none; border-radius: 8px; overflow: hidden; background: #000; cursor: pointer; }
.tg-wp-player img, .tg-wp-video-blank { display: block; width: 100%; height: 100%; object-fit: cover; }
.tg-wp-play { position: absolute; left: 50%; top: 50%; width: 64px; height: 44px; transform: translate(-50%, -50%); border-radius: 12px; background: rgba(0, 0, 0, 0.62); transition: background 0.15s; }
.tg-wp-play::after { content: ''; position: absolute; left: 26px; top: 12px; border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff; }
.tg-wp-player:hover .tg-wp-play { background: #e62117; }
.tg-wp-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: none; border-radius: 8px; background: #000; }

/* Location and contact */
.tg-msg-location { cursor: pointer; margin-top: 4px; }
.tg-map { position: relative; overflow: hidden; border-radius: 10px; background: #e5e3df; max-width: 100%; }
.tg-map img { position: absolute; width: 256px; height: 256px; max-width: none; }
.tg-map-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); font-size: 26px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.tg-map-attr { position: absolute; right: 2px; bottom: 2px; font-size: 9px; background: rgba(255,255,255,.75); color: #333; padding: 0 3px; border-radius: 3px; }
.tg-loc-caption { font-size: 12.5px; color: var(--tg-text-secondary); margin-top: 4px; }
.tg-contact-msg { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.tg-contact-text { flex: 1; display: flex; flex-direction: column; font-size: 13.5px; }
.tg-contact-text span { font-size: 12px; color: var(--tg-text-secondary); }

/* Rich text */
.tg-format-toolbar {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
  background: var(--tg-bg-sidebar);
  border: 1px solid var(--tg-borders);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  z-index: 60;
}
.tg-composer-input-wrap { position: relative; }
.tg-format-toolbar button { background: none; border: none; min-width: 30px; height: 30px; border-radius: 6px; cursor: pointer; color: var(--tg-text); font-size: 14px; }
.tg-format-toolbar button:hover { background: var(--tg-item-hover); }
.tg-spoiler { background: var(--tg-text-secondary); color: transparent; border-radius: 4px; cursor: pointer; transition: background .2s, color .2s; }
.tg-spoiler.revealed { background: rgba(0, 0, 0, 0.07); color: inherit; cursor: text; }
.tg-quote { margin: 4px 0; padding: 4px 10px; border-left: 3px solid var(--tg-primary); background: rgba(75, 63, 160, 0.08); border-radius: 4px 8px 8px 4px; }
.tg-quote.collapsed { max-height: 5.6em; overflow: hidden; cursor: pointer; position: relative; }
.tg-quote.collapsed::after { content: '▾'; position: absolute; right: 6px; bottom: 2px; color: var(--tg-primary); }
.tg-quote.expanded { cursor: pointer; }
.tg-codeblock { margin: 4px 0; border-radius: 8px; overflow: hidden; background: rgba(0, 0, 0, 0.06); }
.tg-code-head { display: flex; justify-content: space-between; align-items: center; padding: 3px 8px; font-size: 11.5px; color: var(--tg-primary); font-weight: 600; }
.tg-code-copy { background: none; border: none; color: var(--tg-primary); cursor: pointer; font-size: 13px; }
.tg-codeblock pre { margin: 0; padding: 6px 10px 8px; overflow-x: auto; font-size: 12.5px; }

/* Scheduled-messages button */
#btn-scheduled-list { font-size: 18px; }

/* Albums */
.tg-album-group { max-width: 360px; width: 72%; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; box-shadow: var(--tg-shadow); }
.tg-album-group.incoming { align-self: flex-start; background: var(--tg-bubble-in); }
.tg-album-group.outgoing { align-self: flex-end; background: var(--tg-bubble-out); }
.tg-album-sender { padding: 6px 12px 4px; font-size: 12px; font-weight: 700; color: var(--tg-primary); }
.tg-album.media { position: relative; width: 100%; }
.tg-album.media > .tg-bubble.album-item {
  position: absolute;
  max-width: none;
  margin: 0;
  padding: 1px;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.tg-album.media > .album-item .tg-msg-photo-wrap,
.tg-album.media > .album-item .tg-msg-video-wrap { width: 100%; height: 100%; max-width: none; margin: 0; border-radius: 2px; }
.tg-album.media > .album-item img,
.tg-album.media > .album-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tg-album > .album-item .tg-msg-sender,
.tg-album > .album-item .tg-msg-text,
.tg-album > .album-item .tg-msg-meta,
.tg-album > .album-item .tg-quick-rx,
.tg-album > .album-item .tg-fwd-header,
.tg-album > .album-item .tg-reply-quote-box { display: none; }
.tg-album.docs > .tg-bubble.album-item { max-width: none; margin: 0; border-radius: 0; box-shadow: none; background: none; padding: 4px 10px; }
.tg-album-foot { padding: 4px 12px 6px; }
.tg-album-foot:empty { display: none; }
.tg-stream.select-mode .tg-album > .tg-bubble.selected { outline: 3px solid var(--tg-primary); outline-offset: -3px; }

/* Attachment modal: several files */
.tg-attach-preview-container.multi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 320px; overflow-y: auto; }
.tg-attach-item { position: relative; }
.tg-attach-preview-container.multi .tg-attach-item img,
.tg-attach-preview-container.multi .tg-attach-item video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.tg-attach-preview-container.multi .tg-attach-preview-file-box { aspect-ratio: 1; flex-direction: column; justify-content: center; padding: 6px; }
.tg-attach-remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; cursor: pointer; }
.tg-attach-options { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 2px 0; font-size: 13px; }
.tg-attach-opt { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--tg-text); }
.tg-attach-poll-color { background: #f59e0b; color: #fff; }
.tg-attach-todo-color { background: #22a35a; color: #fff; }
.tg-attach-loc-color { background: #e53935; color: #fff; }
.tg-attach-contact-color { background: #8e24aa; color: #fff; }
.tg-attach-tr-color { background: #4b3fa0; color: #fff; }
/* Translate: beside the composer on wide screens, in the attach menu on phones (room for typing). */
@media (max-width: 768px) { #btn-compose-translate { display: none !important; } }
@media (min-width: 769px) { #btn-attach-translate { display: none !important; } }

/* Round video */
.tg-round-recorder { position: fixed; inset: 0; z-index: 1200; background: rgba(0, 0, 0, 0.55); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.tg-round-circle { position: relative; width: min(22.5rem, 70vmin); height: min(22.5rem, 70vmin); border-radius: 50%; overflow: hidden; background: #000; animation: tgRoundIn 0.35s ease-out; }
@keyframes tgRoundIn { from { transform: translateY(40px) scale(0.25); opacity: 0; } to { transform: none; opacity: 1; } }
.tg-round-circle video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.tg-round-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.tg-round-ring circle { fill: none; stroke: rgba(255, 255, 255, 0.25); stroke-width: 2; }
.tg-round-ring circle + circle, .tg-round-progress { stroke: #fff !important; stroke-linecap: round; }
.tg-round-controls { display: flex; align-items: center; gap: 12px; }
.tg-round-timer { color: #fff; font-weight: 700; min-width: 44px; text-align: center; }
.tg-bubble.round { background: none !important; box-shadow: none; padding: 0; }
.tg-round { position: relative; width: 240px; height: 240px; border-radius: 50%; overflow: hidden; cursor: pointer; background: #000; }
.tg-round video { width: 100%; height: 100%; object-fit: cover; }
.tg-round .tg-round-ring circle { stroke: #fff; stroke-width: 3; opacity: 0; }
.tg-round.active .tg-round-ring circle { opacity: 1; }
.tg-round-time { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 11.5px; padding: 1px 7px; border-radius: 10px; }
.tg-bubble.round .tg-msg-meta { display: inline-flex; background: rgba(0, 0, 0, 0.35); color: #fff; border-radius: 10px; padding: 1px 6px; }
#btn-voice-toggle.video-mode svg { display: none; }
#btn-voice-toggle.video-mode::after { content: '📹'; font-size: 19px; }

@media (max-width: 768px) {
  .tg-round { width: 200px; height: 200px; }
  .tg-album-group { width: 86%; }
}
.tg-codeblock pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; color: inherit; }
.tg-album-group { flex-shrink: 0; }
.tg-poll, .tg-todo { min-width: min(240px, 100%); }
.tg-poll-result-top { min-width: 0; }
.tg-poll-text { min-width: 0; overflow-wrap: anywhere; }
.tg-poll-names { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; }

/* ===================================================================== */
/* Backlog 29–42                                                         */
/* ===================================================================== */

/* Sheet building blocks */
.tg-sheet-section { font-size: 12px; font-weight: 700; color: var(--tg-primary); margin: 14px 6px 4px; }
.tg-sheet-section:first-child { margin-top: 2px; }
.tg-sheet-empty { padding: 18px 8px; text-align: center; font-size: 13px; color: var(--tg-text-secondary); }
.tg-sheet-secondary { width: 100%; border: none; border-radius: 10px; padding: 10px; font-weight: 600; cursor: pointer; background: var(--tg-item-hover); color: var(--tg-text); }
.tg-sheet-gap { margin: 8px 0 4px; }
.tg-btn-danger-xs { color: #e53935 !important; }
.tg-switch-row.disabled { opacity: 0.5; }
.tg-sheet-body .tg-switch-row { margin-bottom: 6px; }
.tg-settings-link-icon { width: 28px; text-align: center; font-size: 18px; flex-shrink: 0; }
.tg-settings-link-value { font-size: 13px; color: var(--tg-text-secondary); white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.tg-settings-link .tg-row-arrow { color: var(--tg-text-secondary); font-size: 18px; }
.tg-volume-row { display: flex; align-items: center; gap: 10px; padding: 6px; font-size: 16px; }
.tg-volume-row input { flex: 1; accent-color: var(--tg-primary); }
.tg-pick-list, .tg-forward-list { margin-top: 8px; }
.tg-sheet-row.kbd-active { background: var(--tg-primary-light); }
.tg-forward-check { width: 18px; height: 18px; accent-color: var(--tg-primary); flex-shrink: 0; }
.tg-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tg-chip-row:empty { display: none; }
#sheet-footer #fwd-caption { margin: 0 0 8px; }

/* Select mode actions */
.tg-select-action {
  background: var(--tg-item-hover);
  color: var(--tg-text);
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tg-select-action:disabled { opacity: 0.4; cursor: default; }
.tg-select-bar { flex-wrap: wrap; row-gap: 8px; }

/* Composer: pending forward and blocked chat */
.tg-forward-bar { cursor: pointer; }
.tg-blocked-bar {
  justify-content: center;
  padding: 12px 16px;
  background: var(--tg-bg-sidebar);
  border-top: 1px solid var(--tg-borders);
}
.tg-blocked-bar .tg-btn-text { font-weight: 700; color: var(--tg-primary); width: auto; }

/* Archive */
.tg-archive-avatar { background: var(--tg-text-secondary) !important; font-size: 20px; }
.tg-archive-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--tg-borders); color: var(--tg-text); }
.tg-archive-head .tg-btn-xs { font-size: 20px; line-height: 1; }
.tg-drawer-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--tg-primary); color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
.tg-drawer-badge:empty { display: none; }
#btn-hamburger.has-badge { position: relative; }
#btn-hamburger.has-badge::after { content: ''; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #e53935; border: 2px solid var(--tg-bg-sidebar); }

/* Auto-delete badge on the chat avatar */
.tg-ttl-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 18px;
  padding: 0 3px;
  height: 16px;
  border-radius: 8px;
  background: var(--tg-primary);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border: 2px solid var(--tg-bg-sidebar);
  box-sizing: content-box;
}

/* Calendar */
.tg-date-divider span { cursor: pointer; }
.tg-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--tg-text); }
.tg-cal-head .tg-btn-xs { font-size: 22px; line-height: 1; padding: 2px 10px; }
.tg-cal-head .tg-btn-xs:disabled { opacity: 0.3; }
.tg-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.tg-cal-week span { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--tg-text-secondary); padding: 4px 0; }
.tg-cal-day { aspect-ratio: 1; border: none; border-radius: 50%; background: none; color: var(--tg-text); font-size: 14px; cursor: pointer; }
.tg-cal-day:hover:not(:disabled) { background: var(--tg-item-hover); }
.tg-cal-day.today { color: var(--tg-primary); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--tg-primary); }
.tg-cal-day:disabled { opacity: 0.3; cursor: default; }

/* Connection state */
.tg-conn-banner { padding: 6px 12px; font-size: 12.5px; font-weight: 600; text-align: center; color: var(--tg-text-secondary); background: var(--tg-search-bg); border-bottom: 1px solid var(--tg-borders); }

/* Sessions */
.tg-session-icon { background: var(--tg-search-bg) !important; font-size: 19px; }
.tg-session-when { font-size: 12px; color: var(--tg-text-secondary); white-space: nowrap; align-self: flex-start; padding-top: 2px; }
.tg-session-detail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0 12px; color: var(--tg-text); }
.tg-session-detail span { font-size: 12.5px; color: var(--tg-text-secondary); }
.tg-session-big { font-size: 44px; }
.tg-info-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; color: var(--tg-text); margin: 0 6px; }
.tg-info-dl dt { color: var(--tg-text-secondary); }
.tg-info-dl dd { margin: 0; word-break: break-word; }

/* Info panel rows */
.tg-info-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--tg-text); }
.tg-info-row:hover { background: var(--tg-item-hover); }
.tg-info-row.danger { color: #e53935; }
.tg-info-row-icon { width: 24px; text-align: center; }
.tg-info-row-title { flex: 1; }
.tg-info-row-value { font-size: 13px; color: var(--tg-text-secondary); }

/* Reports */
.tg-report-card { border: 1px solid var(--tg-borders); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; color: var(--tg-text); }
.tg-report-top { display: flex; justify-content: space-between; gap: 8px; }
.tg-report-reason { font-weight: 700; font-size: 14px; }
.tg-report-time, .tg-report-meta { font-size: 12px; color: var(--tg-text-secondary); }
.tg-report-comment-text { font-size: 13px; font-style: italic; }
.tg-report-msgs { font-size: 12.5px; background: var(--tg-search-bg); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; word-break: break-word; }
.tg-report-card .tg-sheet-actions { flex-wrap: wrap; justify-content: flex-end; }
.tg-report-card .tg-btn-xs { border: 1px solid var(--tg-borders); border-radius: 8px; padding: 4px 10px; background: none; color: var(--tg-text); cursor: pointer; }
.tg-report-comment { resize: vertical; min-height: 64px; font-family: inherit; }

/* Download progress inside file cards */
.tg-msg-doc-card { position: relative; overflow: hidden; }
.tg-msg-doc-card.downloading::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: var(--dl, 0%);
  background: var(--tg-primary);
  transition: width 0.15s;
}

/* Keyboard shortcuts */
.tg-shortcuts { display: flex; flex-direction: column; gap: 6px; }
.tg-shortcuts div { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--tg-text); padding: 4px 6px; }
.tg-shortcuts kbd { font-family: inherit; font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: var(--tg-search-bg); border: 1px solid var(--tg-borders); white-space: nowrap; }
.tg-shortcuts span { text-align: right; color: var(--tg-text-secondary); }

/* Passcode lock screen */
body.app-locked #app-window, body.app-locked .tg-drawer-menu, body.app-locked .tg-dialog-overlay, body.app-locked .tg-modal-overlay { visibility: hidden !important; }
.tg-lock-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--tg-bg-page);
  padding: 16px;
}
.tg-lock-card { width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--tg-text); }
.tg-lock-card h2 { font-size: 20px; }
.tg-lock-icon { font-size: 54px; }
.tg-lock-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.tg-lock-form .tg-ask-input { text-align: center; font-size: 16px; }
.tg-lock-error { min-height: 18px; font-size: 13px; color: #e53935; }
.tg-lock-forgot { width: auto; font-size: 13px; }
.tg-lock-card.shake { animation: tg-shake 0.35s; }
@keyframes tg-shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Calls */
.tg-call {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(160deg, #1f3b57, #12111c);
  color: #fff;
  padding: 16px 16px 28px;
  overflow: hidden;
}
.tg-call.open { display: flex; }
.tg-call.minimized { display: none; }
.tg-call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: none; }
.tg-call.remote-video .tg-call-remote { display: block; }
.tg-call-local { position: absolute; right: 16px; top: 60px; width: 28vw; max-width: 180px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; background: #000; display: none; z-index: 2; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); transform: scaleX(-1); }
.tg-call.video-on .tg-call-local { display: block; }
.tg-call-head { width: 100%; display: flex; justify-content: flex-start; z-index: 3; }
.tg-call-min { background: rgba(255, 255, 255, 0.15); border: none; color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 20px; cursor: pointer; }
.tg-call-center { display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.tg-call.remote-video .tg-call-center { position: absolute; top: 16px; left: 64px; right: 64px; }
.tg-call.remote-video .tg-call-avatar { display: none; }
.tg-call-avatar { width: 110px; height: 110px; font-size: 38px; }
.tg-call-name { font-size: 22px; font-weight: 700; }
.tg-call-status { font-size: 14px; opacity: 0.85; min-height: 18px; }
.tg-call-controls { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; z-index: 3; }
.tg-call-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; color: #fff; cursor: pointer; }
.tg-call-btn span { width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; background: rgba(255, 255, 255, 0.18); }
.tg-call-btn small { font-size: 12px; opacity: 0.9; }
.tg-call-btn.off span { background: #fff; color: #000; }
.tg-call-btn.on span { background: var(--tg-primary); }
.tg-call-btn.danger span { background: #e53935; }
.tg-call-btn.accept span { background: #22c55e; }
.tg-call-bar { display: flex; align-items: center; gap: 8px; padding: 7px 14px; background: #22c55e; color: #fff; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.tg-call-msg { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.tg-call-msg-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; background: rgba(34, 197, 94, 0.15); color: #16a34a; flex-shrink: 0; }
.tg-call-msg-icon.bad { background: rgba(229, 57, 53, 0.14); color: #e53935; }
.tg-call-msg-text { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
.tg-call-msg-text span { font-size: 12px; color: var(--tg-text-secondary); }
.tg-call-redial { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; }

@media (max-width: 768px) {
  .tg-select-bar { gap: 8px; padding: 8px 10px; }
  .tg-select-count { flex-basis: calc(100% - 48px); }
  .tg-call-btn span { width: 52px; height: 52px; font-size: 22px; }
  .tg-call-controls { gap: 10px; }
}

/* Profile photos (1.10.1) */
.tg-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; z-index: 1; background: var(--tg-bg-sidebar); }
.tg-avatar > .tg-online-dot, .tg-avatar > .tg-ttl-badge { z-index: 2; }
.tg-avatar-editor { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 16px; }
.tg-avatar-xl { width: 96px; height: 96px; font-size: 32px; cursor: pointer; }
.tg-avatar-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tg-btn-danger-text { color: #e53935 !important; }
.tg-crop { display: flex; justify-content: center; margin: 4px 0 8px; }
.tg-crop canvas { width: min(280px, 100%); aspect-ratio: 1; border-radius: 16px; cursor: grab; touch-action: none; background: #000; }
.tg-crop canvas:active { cursor: grabbing; }

/* ---- Backlog E1: public links, chat photos, profiles, unread state, search, QR ---- */
.tg-system-peer { color: #fff; font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.45); }
.tg-bubble.system { flex-direction: column; align-items: center; }
.tg-system-photo { display: block; width: 72px; height: 72px; margin: 6px auto 0; border-radius: 50%; object-fit: cover; cursor: pointer; }
.tg-reaction-badge { background: #e53935; font-size: 11px; }
.tg-unread-divider { align-self: stretch; text-align: center; margin: 6px 0; pointer-events: none; background: rgba(0, 0, 0, 0.12); }
.tg-unread-divider span { display: inline-block; padding: 3px 10px; color: var(--tg-text); font-size: 12.5px; font-weight: 500; }
.tg-scroll-fab { overflow: visible; }
.tg-fab-badge { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--tg-primary); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center; box-sizing: border-box; }
.tg-unseen-fabs { position: absolute; right: 20px; bottom: 138px; display: flex; flex-direction: column; gap: 10px; z-index: 5; pointer-events: none; }
.tg-unseen-fabs .tg-unseen-fab { position: relative; right: auto; bottom: auto; pointer-events: auto; font-size: 18px; font-weight: 700; color: var(--tg-primary); }
.tg-unseen-fabs .tg-unseen-fab[data-kind="reactions"] { color: #e53935; }
.tg-reply-quote-text.is-quote, .tg-reply-bar-text.is-quote { font-style: italic; }
.tg-reply-quote-text.is-quote::before, .tg-reply-bar-text.is-quote::before { content: '❝ '; font-style: normal; opacity: 0.7; }
.tg-protected .tg-bubble, .tg-protected .tg-bubble * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tg-protected .tg-bubble img, .tg-protected .tg-bubble video { -webkit-user-drag: none; }
.tg-protected .tg-bubble a[download], body.tg-protected-chat #btn-lightbox-download { display: none !important; }
@media print { .tg-protected { display: none !important; } }
.tg-safe-url { word-break: break-all; }
.tg-safe-warn { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: rgba(229, 57, 53, 0.1); color: #c62828; font-size: 13px; }
.tg-join-bar { display: none; justify-content: center; padding: 10px 16px; background: var(--tg-bg-sidebar); border-top: 1px solid var(--tg-border-light); }
.tg-join-bar-btn { min-width: 220px; padding: 10px 18px; border: none; border-radius: 10px; background: var(--tg-primary); color: #fff; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.tg-username-input { display: flex; align-items: center; border: 1px solid var(--tg-border-light); border-radius: 10px; overflow: hidden; background: var(--tg-bg-secondary); }
.tg-username-input span { padding: 9px 2px 9px 10px; color: var(--tg-text-secondary); font-size: 13px; white-space: nowrap; }
.tg-username-input input { flex: 1; min-width: 60px; padding: 9px 10px 9px 0; border: none; background: transparent; color: var(--tg-text); font-size: 14px; outline: none; }
.tg-sheet-note.tg-err { color: #e53935; }
.tg-sheet-note.tg-ok { color: #2e9d4f; }
.tg-radio-row span b { color: var(--tg-text); }
.tg-member-search { width: 100%; box-sizing: border-box; margin: 0 0 8px; padding: 8px 12px; border: 1px solid var(--tg-border-light); border-radius: 18px; background: var(--tg-bg-secondary); color: var(--tg-text); font-size: 13.5px; outline: none; }
.tg-gif-badge { position: absolute; left: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 10.5px; font-weight: 700; }
.tg-info-media { position: relative; }
.tg-profile-top { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 12px; }
.tg-profile-top h3 { margin: 6px 0 0; color: var(--tg-text); font-size: 18px; }
.tg-profile-status { color: var(--tg-text-secondary); font-size: 13px; }
.tg-profile-status.online { color: var(--tg-primary); }
.tg-profile-rows { display: flex; flex-direction: column; margin-bottom: 10px; border-radius: 12px; overflow: hidden; background: var(--tg-bg-secondary); }
.tg-profile-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; border: none; background: transparent; color: var(--tg-text); text-align: left; font: inherit; }
button.tg-profile-row { cursor: pointer; }
button.tg-profile-row:hover { background: var(--tg-hover, rgba(0, 0, 0, 0.04)); }
.tg-profile-row.tg-switch-row { flex-direction: row; align-items: center; }
.tg-profile-row-title { font-size: 14.5px; word-break: break-word; }
.tg-profile-row-sub { color: var(--tg-text-secondary); font-size: 12.5px; }
.tg-top-peers { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px 10px; scrollbar-width: thin; }
.tg-top-peer { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 64px; flex-shrink: 0; padding: 4px 0; border: none; border-radius: 10px; background: transparent; color: var(--tg-text); font-size: 12px; cursor: pointer; }
.tg-top-peer:hover { background: var(--tg-hover, rgba(0, 0, 0, 0.05)); }
.tg-top-peer .tg-avatar { width: 48px; height: 48px; }
.tg-top-peer span:last-child { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-search-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qr-container { position: relative; }
.qr-container .qr-live { width: 220px; height: 220px; padding: 10px; border-radius: 16px; background: #fff; box-sizing: border-box; }
.qr-container .qr-live svg { width: 100%; height: 100%; display: block; }
.qr-container.loading::after { content: 'Memuat…'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #888; font-size: 13px; }
.tg-qr-scan video { width: 100%; max-height: 320px; border-radius: 12px; background: #000; object-fit: cover; }
.tg-qr-scan details { margin-top: 8px; }
.tg-qr-scan details input { margin: 6px 0; }

/* ---- Backlog E2: member tags, signatures, group calls ---- */
.tg-rank { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 8px; font-size: 11px; font-weight: 600; line-height: 17px; cursor: pointer; vertical-align: 1px; }
.tg-rank-owner { background: rgba(142, 85, 233, 0.15); color: #8e55e9; }
.tg-rank-admin { background: rgba(34, 160, 90, 0.15); color: #1f9d55; }
.tg-rank-member { background: rgba(120, 130, 140, 0.16); color: #6b7680; }
.tg-msg-signature { font-style: italic; opacity: 0.85; margin-right: 4px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-gcall-pane { display: none; align-items: center; gap: 10px; padding: 8px 14px; background: var(--tg-bg-sidebar); border-bottom: 1px solid var(--tg-border-light); cursor: pointer; }
.tg-gcall-pane-text { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 13.5px; color: var(--tg-text); }
.tg-gcall-pane-text span { font-size: 12px; color: var(--tg-text-secondary); }
.tg-gcall-pane-avatars { display: flex; }
.tg-gcall-pane-avatars .tg-avatar { width: 28px; height: 28px; font-size: 11px; margin-left: -6px; border: 2px solid var(--tg-bg-sidebar); }
.tg-gcall-pane-join { padding: 6px 16px; border: none; border-radius: 16px; background: var(--tg-primary); color: #fff; font-weight: 600; cursor: pointer; }
.tg-gcall { position: fixed; inset: 0; z-index: 4000; display: none; flex-direction: column; background: #10171f; color: #fff; }
.tg-gcall.open { display: flex; }
.tg-gcall.minimized { display: none; }
.tg-gcall-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.tg-gcall-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tg-gcall-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-gcall-title span { font-size: 12.5px; opacity: 0.75; }
.tg-gcall-hbtn { width: 38px; height: 38px; border: none; border-radius: 50%; background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 17px; cursor: pointer; }
.tg-gcall-body { flex: 1; display: flex; gap: 10px; min-height: 0; padding: 0 16px; }
.tg-gcall-grid { flex: 1; display: grid; gap: 8px 10px; align-content: center; min-height: 0; }
.tg-gcall-grid.pinned { grid-template-columns: 1fr !important; }
.tg-gcall-tile { position: relative; aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; background: #1d2733; display: flex; align-items: center; justify-content: center; cursor: pointer; outline: 3px solid transparent; transition: outline-color 0.2s; }
.tg-gcall-tile.speaking { outline-color: #22c55e; }
.tg-gcall-tile.hidden-by-pin { display: none; }
.tg-gcall-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.tg-gcall-tile.has-video video { display: block; }
.tg-gcall-tile.self.has-video video { transform: scaleX(-1); }
.tg-gcall-tile.has-video .tg-gcall-avatar { display: none; }
.tg-gcall-avatar { width: 72px; height: 72px; font-size: 26px; }
.tg-gcall-name { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; align-items: center; max-width: calc(100% - 16px); padding: 3px 8px; border-radius: 10px; background: rgba(0, 0, 0, 0.5); font-size: 12.5px; }
.tg-gcall-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-gcall-list { width: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.tg-gcall-person { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; cursor: pointer; }
.tg-gcall-person:hover { background: rgba(255, 255, 255, 0.06); }
.tg-gcall-person .tg-avatar { width: 34px; height: 34px; font-size: 12px; }
.tg-gcall-person-text { flex: 1; display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.tg-gcall-person-text small { font-size: 11.5px; opacity: 0.7; }
.tg-gcall-person-text small.green { color: #4ade80; opacity: 1; }
.tg-gcall-person-text small.blue { color: #60a5fa; opacity: 1; }
.tg-gcall-person-text small.red { color: #f87171; opacity: 1; }
.tg-gcall-controls { display: flex; justify-content: center; gap: 22px; padding: 14px 16px 22px; }
@media (max-width: 768px) {
  .tg-gcall-body { flex-direction: column; padding: 0 10px; }
  .tg-gcall-list { width: auto; max-height: 30vh; }
  .tg-gcall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .tg-gcall-controls { gap: 12px; }
}

/* ---- Backlog E3 ---------------------------------------------------------------------------- */

/* #67 emoji and sticker suggestions above the composer */
.tg-chat-footer, #chat-footer { position: relative; }
.tg-emoji-suggest {
  display: none;
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 6px);
  gap: 2px;
  padding: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--tg-panel-bg, var(--tg-bg-sidebar));
  border: 1px solid var(--tg-borders);
  border-radius: 12px;
  box-shadow: 0 4px 16px var(--tg-shadow, rgba(0, 0, 0, 0.15));
  z-index: 30;
}
.tg-emoji-suggest-item {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.tg-emoji-suggest-item:hover, .tg-emoji-suggest-item.active { background: var(--tg-item-hover); }
.tg-emoji-suggest-sticker { flex: 0 0 auto; border: none; background: none; padding: 2px; border-radius: 8px; cursor: pointer; }
.tg-emoji-suggest-sticker img { width: 64px; height: 64px; object-fit: contain; display: block; }
.tg-emoji-suggest-sticker:hover { background: var(--tg-item-hover); }

/* #68 live waveform */
.tg-rec-wave { flex: 1; min-width: 80px; max-width: 220px; height: 32px; }

/* #70 views, #71 hashtags, #72 typing in the list */
.tg-msg-views { margin-right: 4px; opacity: 0.85; white-space: nowrap; }
.tg-hashtag { color: var(--tg-primary); cursor: pointer; }
.tg-hashtag:hover { text-decoration: underline; }
.tg-list-typing { color: var(--tg-primary); }
.tg-fwd-link { cursor: pointer; }
.tg-fwd-link:hover { text-decoration: underline; }

/* #74 call devices and a weak connection */
.tg-weak-net { display: none; text-align: center; font-size: 12px; padding: 4px 8px; color: #ffd166; }
.tg-call.weak-net .tg-weak-net, .tg-gcall.weak-net .tg-weak-net { display: block; }

/* #84 birthdays, #85 local names */
.tg-bday-icon { margin-left: 4px; font-size: 13px; }
.tg-profile-realname { font-size: 13px; color: var(--tg-text-secondary); margin-top: -4px; }
.tg-birthday-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tg-birthday-row select, .tg-birthday-row input {
  flex: 1 1 90px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--tg-borders);
  border-radius: 8px;
  background: var(--tg-bg-sidebar);
  color: var(--tg-text);
  font: inherit;
}
.tg-birthday-actions { display: flex; gap: 8px; }
.tg-birthday-actions .tg-btn-primary { flex: 1; }

/* #86 block formatting */
.tg-msg-text .tg-h { font-weight: 700; margin: 4px 0 2px; line-height: 1.3; }
.tg-msg-text .tg-h1 { font-size: 1.35em; }
.tg-msg-text .tg-h2 { font-size: 1.2em; }
.tg-msg-text .tg-h3 { font-size: 1.05em; }
.tg-msg-text .tg-list { margin: 4px 0; padding-left: 1.6em; }
.tg-msg-text .tg-list .tg-list { margin: 2px 0 2px; padding-left: 1.4em; }
.tg-msg-text .tg-list li { margin: 2px 0; padding-left: 2px; }
.tg-msg-text ul.tg-list { list-style: disc; }
.tg-msg-text ul.tg-list ul.tg-list { list-style: circle; }
.tg-msg-text ul.tg-list ul.tg-list ul.tg-list { list-style: square; }
.tg-msg-text ol.tg-list ol.tg-list { list-style: lower-alpha; }
.tg-msg-text ol.tg-list ol.tg-list ol.tg-list { list-style: lower-roman; }
.tg-msg-text ol.tg-list > li::marker { font-weight: 600; font-variant-numeric: tabular-nums; }
.tg-msg-text .tg-list li::marker { color: var(--tg-primary); }
.tg-msg-text .tg-hr { border: none; border-top: 1px solid currentColor; opacity: 0.25; margin: 8px 0; }
.tg-table-wrap { overflow-x: auto; margin: 6px 0; max-width: 100%; border: 1px solid rgba(127, 127, 127, 0.3); border-radius: 10px; }
.tg-table { border-collapse: collapse; min-width: 100%; font-size: 0.93em; font-variant-numeric: tabular-nums; word-break: normal; overflow-wrap: normal; }
.tg-table th, .tg-table td { padding: 6px 10px; text-align: left; vertical-align: top; min-width: 3em; max-width: 22em; hyphens: manual; border-bottom: 1px solid rgba(127, 127, 127, 0.22); }
.tg-table th + th, .tg-table td + td { border-left: 1px solid rgba(127, 127, 127, 0.16); }
.tg-table tbody tr:last-child td { border-bottom: none; }
.tg-table th { font-weight: 700; background: rgba(127, 127, 127, 0.12); white-space: nowrap; }
.tg-table tbody tr:nth-child(even) td { background: rgba(127, 127, 127, 0.05); }

/* #83 folder colors, tags, links, tabs on the left */
.tg-folder-colors { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tg-folder-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--tg-bg-secondary);
  color: var(--tg-text-secondary);
  cursor: pointer;
  font-size: 13px;
}
.tg-folder-color.selected { border-color: var(--tg-text); box-shadow: 0 0 0 2px var(--tg-bg-sidebar) inset; }
.tg-tab-color { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.tg-folder-tags { display: flex; gap: 4px; margin-top: 3px; overflow: hidden; }
.tg-folder-tag { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 6px; white-space: nowrap; line-height: 17px; }
.tg-folder-suggest { margin-top: 14px; }
.tg-folder-join-head { text-align: center; margin-bottom: 8px; }
.tg-folder-join-emoji { display: block; font-size: 40px; }
.tg-tabs-nav.tg-tabs-side {
  flex-direction: column;
  width: 82px;
  flex: 0 0 82px;
  padding: 6px 0;
  border-bottom: none;
  border-right: 1px solid var(--tg-borders);
  background: var(--tg-bg-sidebar);
  overflow-x: hidden;
  overflow-y: auto;
}
.tg-tabs-side .tg-tab-scroll { flex-direction: column; overflow-x: hidden; overflow-y: auto; flex: 0 1 auto; }
.tg-tabs-side .tg-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  white-space: normal;
  text-align: center;
  font-size: 11px;
  padding: 10px 4px;
  word-break: break-word;
}
.tg-tabs-side .tg-tab-emoji { font-size: 22px; margin: 0; }
.tg-tabs-side .tg-tab-btn.active::after { left: 0; right: auto; top: 10px; bottom: 10px; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
.tg-tabs-side .tg-tab-badge { position: absolute; top: 4px; right: 10px; }
.tg-tabs-side .tg-tab-edit { margin: 6px auto; }

/* #87 slow mode */
.tg-slow-choices { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.tg-slow-choices label { cursor: pointer; }
.tg-slow-choices input { position: absolute; opacity: 0; pointer-events: none; }
.tg-slow-choices span { display: inline-block; padding: 5px 10px; border-radius: 14px; border: 1px solid var(--tg-borders); font-size: 13px; }
.tg-slow-choices input:checked + span { background: var(--tg-primary); border-color: var(--tg-primary); color: #fff; }
.tg-slow-choices input:focus-visible + span { outline: 2px solid var(--tg-primary); outline-offset: 2px; }
.tg-slow-chip {
  position: absolute;
  right: 64px;
  top: -30px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--tg-panel-bg, var(--tg-bg-sidebar));
  border: 1px solid var(--tg-borders);
  color: var(--tg-text-secondary);
  z-index: 5;
}

/* #77 media waiting for a tap */
.tg-media-held { position: relative; min-width: 200px; min-height: 140px; background: rgba(127, 127, 127, 0.18); border-radius: 10px; }
.tg-media-held img, .tg-media-held video { visibility: hidden; }
.tg-media-load {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 8px 14px;
  border: none;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.tg-round.tg-media-held { min-width: 0; border-radius: 50%; }

/* #88 performance */
.tg-gif-paused { filter: saturate(0.85); }
body.no-anim *, body.no-anim *::before, body.no-anim *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

/* #81 confirm a new login */
.tg-new-login {
  margin: 8px 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--tg-primary-light, rgba(75, 63, 160, 0.12));
  border: 1px solid var(--tg-borders);
  font-size: 13px;
}
.tg-new-login-title { font-weight: 700; margin-bottom: 4px; }
.tg-new-login-text { color: var(--tg-text-secondary); }
.tg-new-login-q { margin: 8px 0 6px; font-weight: 600; }
.tg-new-login-actions { display: flex; gap: 8px; }
.tg-new-login-actions button { flex: 1; }

/* #80 password login */
.tg-password-wrap { position: relative; display: flex; align-items: center; }
.tg-password-wrap input { width: 100%; padding-right: 44px; }
.tg-password-eye { position: absolute; right: 6px; background: none; border: none; font-size: 18px; cursor: pointer; padding: 6px; }
.auth-lock-logo { display: flex; align-items: center; justify-content: center; font-size: 64px; background: none !important; }

/* #77 settings */
.tg-autodl-group { margin: 6px 0 10px; }
.tg-autodl-group b { display: block; margin-bottom: 2px; }

/* #79 keyboard focus */
.tg-chat-row:focus-visible, .tg-tab-btn:focus-visible, .tg-icon-btn:focus-visible, .tg-hashtag:focus-visible, .tg-drawer-row:focus-visible {
  outline: 2px solid var(--tg-primary);
  outline-offset: -2px;
}
.tg-tabs-side .tg-tab-btn[data-folder="all"]::before { content: "💬"; font-size: 22px; line-height: 1; }
.tg-chat-row.active .tg-list-typing { color: inherit; }
.tg-auth-lang { font-size: 13px; opacity: 0.8; text-transform: none; }

/* ---- Backlog E4 ---------------------------------------------------------------------------- */

/* #90 spoilers and view-once */
.tg-spoilered { position: relative; overflow: hidden; cursor: pointer; }
.tg-spoilered img, .tg-spoilered video { filter: blur(25px) saturate(1.2); transform: scale(1.1); }
.tg-spoiler-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: radial-gradient(rgba(255, 255, 255, 0.55) 1px, transparent 1.4px);
  background-size: 7px 7px;
  animation: tg-spoiler-dots 2.4s linear infinite;
}
.tg-spoiler-cover span { background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 12px; }
@keyframes tg-spoiler-dots { from { background-position: 0 0; } to { background-position: 14px 7px; } }
.tg-msg-once {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.tg-msg-once .tg-once-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--tg-primary);
  color: var(--tg-primary);
  font-weight: 800;
}
.tg-msg-once.opened { cursor: default; opacity: 0.75; }
.tg-msg-once.opened .tg-once-icon { border: none; font-size: 22px; }
.tg-once-dur { font-size: 12px; color: var(--tg-text-secondary); }
.tg-once-toggle.active { background: var(--tg-primary); color: #fff; }
.tg-once-modal {
  position: fixed;
  inset: 0;
  z-index: 4200;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  color: #fff;
}
.tg-once-video { width: min(70vw, 420px); aspect-ratio: 1; border-radius: 50%; object-fit: cover; }
.tg-once-voice { display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 48px; }
.tg-once-voice span { font-size: 15px; }
.tg-once-close { padding: 10px 22px; border-radius: 20px; border: none; background: rgba(255, 255, 255, 0.15); color: #fff; font-size: 15px; cursor: pointer; }

/* #94 dice and big emoji */
.tg-dice { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 10px; cursor: pointer; user-select: none; }
.tg-dice-emoji { font-size: 64px; line-height: 1.1; }
.tg-dice-result { font-size: 15px; font-weight: 700; }
.tg-dice.rolling .tg-dice-emoji { animation: tg-dice-roll 0.35s linear 4; }
.tg-dice.rolling .tg-dice-result { visibility: hidden; }
@keyframes tg-dice-roll { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.15); } 100% { transform: rotate(360deg) scale(1); } }
.tg-bubble.emoji-only { background: transparent !important; box-shadow: none !important; }
.tg-bubble.emoji-only::before, .tg-bubble.emoji-only::after { display: none !important; }
.tg-bubble.emoji-only .tg-msg-text { font-size: 2.25rem; line-height: 1.15; }
.tg-bubble.emoji-only-1 .tg-msg-text { font-size: 7rem; }
.tg-bubble.emoji-only-2 .tg-msg-text { font-size: 5.625rem; }
.tg-bubble.emoji-only-3 .tg-msg-text { font-size: 5.25rem; }
.tg-bubble.emoji-only-4 .tg-msg-text { font-size: 4.5rem; }
.tg-bubble.emoji-only-5 .tg-msg-text { font-size: 3.75rem; }
.tg-bubble.emoji-only-6 .tg-msg-text { font-size: 3rem; }
.tg-bubble.emoji-only-7 .tg-msg-text { font-size: 2.25rem; }
.tg-bubble.emoji-only .tg-msg-meta { background: rgba(0, 0, 0, 0.3); color: #fff; border-radius: 10px; padding: 1px 6px; }

/* #95 live location and venues */
.tg-msg-location.live .tg-loc-caption { color: var(--tg-primary); }
.tg-live-left { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 8px; border: 1px solid currentColor; }
.tg-live-stop { margin-left: 6px; }
.tg-venue-addr { font-size: 12px; color: var(--tg-text-secondary); }
.tg-venue-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }

/* #93 send-as and chats as senders */
.tg-send-as { background: none; border: none; padding: 0; cursor: pointer; align-self: center; }
.tg-send-as-av { width: 34px; height: 34px; font-size: 13px; }
.tg-msg-sender.clickable { cursor: pointer; }
.tg-admin-title { font-size: 11px; font-weight: 500; color: var(--tg-text-secondary); margin-left: 4px; }

/* #97 stickers */
.tg-clear-recent { float: right; background: none; border: none; color: var(--tg-text-secondary); cursor: pointer; }

/* #103 profile photos */
.tg-photo-dashes { display: flex; gap: 3px; justify-content: center; margin-bottom: 6px; }
.tg-photo-dashes span { flex: 0 1 28px; height: 3px; border-radius: 2px; background: rgba(127, 127, 127, 0.35); }
.tg-photo-dashes span.on { background: var(--tg-primary); }
.tg-avatar.clickable { cursor: pointer; }
.tg-mv-profile-actions {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 6px 12px;
  border-radius: 18px;
  z-index: 5;
}
.tg-mv-profile-actions .tg-btn-xs { color: #fff; background: rgba(255, 255, 255, 0.12); }
.tg-mv-profile-label { font-size: 12px; opacity: 0.85; }

/* #104 quick preview */
.tg-quick-preview { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 6px; background: var(--tg-bg-chat, #8ebe8a); border-radius: 12px; cursor: pointer; }
.tg-qp-msg { align-self: flex-start; max-width: 80%; background: var(--tg-bubble-in); color: var(--tg-text); padding: 6px 10px; border-radius: 12px; font-size: 14px; position: relative; }
.tg-qp-msg.own { align-self: flex-end; background: var(--tg-bubble-out); }
.tg-qp-msg.system { align-self: center; background: rgba(0, 0, 0, 0.3); color: #fff; font-size: 12px; }
.tg-qp-msg b { display: block; font-size: 12px; color: var(--tg-primary); }
.tg-qp-time { display: block; text-align: right; font-size: 10px; color: var(--tg-text-secondary); }

/* #105 video controls */
.tg-vplayer { position: relative; display: inline-flex; max-width: 100%; max-height: 100%; }
.tg-vplayer video { max-width: 100%; max-height: 80vh; display: block; }
.tg-vplayer:fullscreen video { max-height: 100vh; width: 100%; height: 100%; object-fit: contain; }
.tg-vbar { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.7)); color: #fff; transition: opacity 0.3s; }
.tg-vplayer.idle .tg-vbar { opacity: 0; }
.tg-vplayer.idle { cursor: none; }
.tg-vseek { position: relative; height: 14px; cursor: pointer; }
.tg-vseek > div:not(.tg-vtip) { position: absolute; left: 0; top: 6px; height: 3px; border-radius: 2px; }
.tg-vseek::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.25); }
.tg-vbuf { background: rgba(255, 255, 255, 0.45); }
.tg-vprog { background: var(--tg-primary); }
.tg-vthumb { width: 11px !important; height: 11px !important; top: 2px !important; margin-left: -5px; border-radius: 50% !important; background: #fff; }
.tg-vtip { display: none; position: absolute; bottom: 18px; flex-direction: column; align-items: center; gap: 2px; background: rgba(0, 0, 0, 0.8); border-radius: 6px; padding: 3px; font-size: 12px; pointer-events: none; }
.tg-vtip canvas { width: 160px; height: 90px; border-radius: 4px; background: #000; }
.tg-vrow { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.tg-vbtn { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; padding: 2px 6px; min-width: 30px; }
.tg-vvol { width: 80px; }
.tg-vtime { font-size: 12px; font-variant-numeric: tabular-nums; }
.tg-vspace { flex: 1; }

/* #106 call rating and key emoji */
.tg-rate-stars { display: flex; justify-content: center; gap: 1rem; margin: 6px 0 12px; }
.tg-rate-stars button { background: none; border: none; font-size: 2rem; cursor: pointer; color: var(--tg-text-secondary); opacity: 0.5; }
.tg-rate-stars button.on { color: var(--tg-primary); opacity: 1; }
.tg-call-emoji { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 6; background: none; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; }
.tg-call-emoji-set { font-size: 1.5rem; letter-spacing: 4px; transition: transform 0.25s; }
.tg-call-emoji-tip { display: none; max-width: 20rem; text-align: center; font-size: 14px; background: rgba(0, 0, 0, 0.6); padding: 10px 14px; border-radius: 12px; }
.tg-call-emoji.open .tg-call-emoji-set { transform: scale(2) translateY(1rem); }
.tg-call-emoji.open .tg-call-emoji-tip { display: block; margin-top: 2.2rem; }

/* #107 Instant View */
.tg-iv-btn { display: block; width: 100%; margin-top: 4px; padding: 6px; border: none; border-radius: 8px; background: var(--tg-primary-light, rgba(75, 63, 160, 0.12)); color: var(--tg-primary); font-weight: 700; font-size: 12px; letter-spacing: 0.5px; cursor: pointer; }
.tg-iv-modal { position: fixed; inset: 0; z-index: 3000; display: none; align-items: stretch; justify-content: center; background: rgba(0, 0, 0, 0.5); }
.tg-iv-panel { width: min(760px, 100%); background: var(--tg-bg-sidebar); color: var(--tg-text); display: flex; flex-direction: column; }
.tg-iv-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--tg-borders); }
.tg-iv-site { flex: 1; font-weight: 600; color: var(--tg-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-iv-body { flex: 1; overflow-y: auto; padding: 20px 28px 40px; line-height: 1.65; font-size: 1em; }
.tg-iv-body h1 { font-size: 1.7em; line-height: 1.25; margin: 0.4em 0; }
.tg-iv-body h2 { font-size: 1.3em; margin: 1.2em 0 0.4em; }
.tg-iv-body h3 { font-size: 1.1em; margin: 1em 0 0.3em; }
.tg-iv-body img { max-width: 100%; border-radius: 8px; }
.tg-iv-cover { width: 100%; max-height: 360px; object-fit: cover; }
.tg-iv-by { color: var(--tg-text-secondary); font-size: 0.9em; margin-bottom: 1em; }
.tg-iv-body blockquote { border-left: 3px solid var(--tg-primary); margin: 1em 0; padding: 0.2em 1em; color: var(--tg-text-secondary); }
.tg-iv-body pre { background: var(--tg-bg-secondary); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 0.9em; }
.tg-iv-body figure { margin: 1em 0; }
.tg-iv-body figcaption { font-size: 0.85em; color: var(--tg-text-secondary); text-align: center; }
.tg-iv-foot { margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--tg-borders); }

/* #101 QR card */
.tg-qr-card { text-align: center; }
.tg-qr-card canvas { max-width: 320px; border-radius: 16px; box-shadow: 0 4px 18px var(--tg-shadow, rgba(0, 0, 0, 0.15)); }
.tg-qr-card .tg-sheet-note { word-break: break-all; }

/* #102 wallpapers */
.tg-wp-extras { margin-top: 14px; }
.tg-wp-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.tg-wp-swatch { width: 36px; height: 36px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.tg-wp-swatch.on { border-color: var(--tg-primary); }
.tg-wp-pick { background: var(--tg-bg-secondary); }
.tg-wp-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#messages-container.tg-wp-image { position: relative; }
#messages-container.tg-wp-image { background-image: var(--tg-wp-image) !important; background-size: cover !important; background-position: center !important; background-attachment: local; }

/* #98 audio volume */
.tg-audio-vol { display: flex; align-items: center; gap: 2px; }
.tg-audio-vol input { width: 70px; }
@media (max-width: 600px) { .tg-audio-vol input { display: none; } }

/* #109 tab conflicts */
.tg-tab-conflict { position: fixed; inset: 0; z-index: 5000; background: var(--tg-bg-page, #f1f1f1); display: flex; align-items: center; justify-content: center; padding: 16px; }
.tg-tab-conflict-card { max-width: 420px; text-align: center; background: var(--tg-bg-sidebar); color: var(--tg-text); border-radius: 18px; padding: 28px; box-shadow: 0 6px 24px var(--tg-shadow, rgba(0, 0, 0, 0.1)); }
.tg-tab-conflict-icon { font-size: 54px; }
.tg-tab-conflict-card .tg-btn-primary { margin-top: 12px; padding: 10px 24px; border-radius: 10px; border: none; cursor: pointer; }

/* #110 accounts */
.tg-drawer-account { text-decoration: none; color: inherit; }
.tg-drawer-acc-av { width: 28px; height: 28px; font-size: 11px; margin-right: 6px; }
.tg-drawer-limit { opacity: 0.6; cursor: default; }

/* #112 confetti and deletion */
.tg-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 6000; }
.tg-bubble.tg-deleting { transition: transform 0.2s ease-in, opacity 0.2s ease-in; transform: scale(0.3) translateX(-50%); opacity: 0; }
.tg-bubble.outgoing.tg-deleting { transform: scale(0.3) translateX(50%); }
.tg-bubble.tg-dissolving { animation: tg-dissolve 0.9s ease-in forwards; transform-origin: bottom; }
@keyframes tg-dissolve {
  0% { filter: blur(0); opacity: 1; transform: scale(1); }
  60% { filter: blur(3px) contrast(1.4); opacity: 0.6; }
  100% { filter: blur(8px); opacity: 0; transform: scale(1.2) translateY(-10px); }
}
.tg-msg-photo-wrap.tg-spoilered { min-width: 160px; min-height: 110px; }
.tg-drawer-accounts a, .tg-drawer-accounts a:hover { text-decoration: none; color: inherit; }
.tg-iv-body p { margin: 0 0 0.85em; } .tg-iv-body ul, .tg-iv-body ol { margin: 0 0 0.85em; padding-left: 1.4em; }

/* Dialogs never grow past the window: a tall one scrolls inside, so its top (title and ✕)
   stays on screen. The info panel keeps its header fixed and scrolls the body. */
.tg-dialog-card { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
#channel-info-modal .tg-dialog-card { display: flex; flex-direction: column; overflow: hidden; }
#channel-info-modal .tg-dialog-top { flex: 0 0 auto; }
#channel-info-modal .tg-info-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* Sticker set visibility choice */
.tg-set-visibility { margin-top: 14px; text-align: left; }
.tg-set-visibility .tg-radio-row { align-items: flex-start; margin-top: 4px; font-size: 13px; color: var(--tg-text-secondary); line-height: 1.35; }
.tg-set-visibility .tg-radio-row input { margin-top: 3px; }

/* Translation: the header above a translated message, and the composer's translate sheet */
.tg-tr-head { font-size: 12px; color: var(--tg-text-secondary); margin: 2px 0 3px; }
.tg-tr-head button { background: none; border: none; padding: 0; font: inherit; color: var(--tg-primary); cursor: pointer; }
.tg-tr-head button:hover { text-decoration: underline; }
#btn-compose-translate { font-size: 19px; line-height: 1; }
.tg-ctr { display: flex; flex-direction: column; gap: 6px; }
.tg-ctr-label { font-size: 12.5px; font-weight: 600; color: var(--tg-text-secondary); margin-top: 6px; }
.tg-ctr-lang { align-self: flex-start; border: 1px solid var(--tg-borders); background: var(--tg-bg-secondary); color: var(--tg-text); border-radius: 10px; padding: 7px 12px; font: inherit; cursor: pointer; }
.tg-ctr-box { border-radius: 10px; padding: 10px 12px; background: var(--tg-bg-secondary); white-space: pre-wrap; max-height: 30vh; overflow-y: auto; }
.tg-ctr-result { white-space: normal; border-left: 3px solid var(--tg-primary); }

/* Notice at the old address (dev.ssoft.my.id/telesoft) pointing at soryn.ssoft.my.id */
.tg-move-notice { display: flex; flex-direction: column; gap: 2px; margin: 0 0 18px; text-align: left; padding: 12px 16px; border-radius: 12px; background: #1b1a2e; color: #fff; text-decoration: none; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); }
.tg-move-notice b { color: #ffc857; font-size: 14px; }
.tg-move-notice span { font-size: 13px; opacity: 0.9; }

/* @all: the whole group or channel */
.tg-mention-all { font-weight: 600; }
.tg-mention-all-avatar { background: var(--tg-primary); color: #fff; font-weight: 700; }
.tg-attach-caption-wrap { position: relative; }
.tg-attach-caption-wrap .tg-mention-popup { bottom: calc(100% + 6px); }

/* All pinned messages (reference pinned message list) */
#btn-pinned-back { display: none; }
.tg-pinned-mode #btn-pinned-back { display: inline-flex; }
.tg-pinned-mode #btn-back-mobile, .tg-pinned-mode #btn-topic-back, .tg-pinned-mode .tg-header-actions,
.tg-pinned-mode #chat-footer, .tg-pinned-mode #pinned-banner { display: none !important; }
.tg-pinned-mode .tg-bubble:not(.system) { position: relative; }
.tg-pin-goto { position: absolute; bottom: 4px; width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(0, 0, 0, 0.32); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; opacity: 0.85; }
.tg-pin-goto:hover { opacity: 1; background: rgba(0, 0, 0, 0.5); }
.tg-bubble.incoming .tg-pin-goto { right: -42px; }
.tg-bubble.outgoing .tg-pin-goto { left: -42px; }
.tg-pinned-footer { display: flex; justify-content: center; padding: 10px 16px; background: var(--tg-bg-sidebar); border-top: 1px solid var(--tg-borders); }
.tg-pinned-footer button { flex: 1; max-width: 480px; padding: 11px 16px; border: none; border-radius: 10px; background: transparent; color: #e53935; font: inherit; font-weight: 700; letter-spacing: 0.2px; cursor: pointer; }
.tg-pinned-footer button:hover { background: rgba(229, 57, 53, 0.08); }
.tg-pinned-mode .tg-quick-rx { display: none !important; }
.tg-pinned-mode #chat-header { justify-content: flex-start; gap: 6px; }
.tg-pinned-mode #unseen-fabs, .tg-pinned-mode #btn-scroll-fab { display: none !important; }
