.tg-app-shell {
  min-height: 0;
  height: var(--tg-app-height, 100dvh);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 24%),
    linear-gradient(135deg, #e9eef4 0%, #dfe7f1 100%);
}

html.tg-mobile-app,
body.tg-mobile-app {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.tg-folder-rail {
  width: 72px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  color: #475569;
  border-right: 1px solid rgba(203, 213, 225, 0.78);
}

.tg-folder-rail-scroll {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 0;
  scrollbar-width: none;
}

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

.tg-folder-rail-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  color: inherit;
  transition: color 0.16s ease, transform 0.16s ease;
}

.tg-folder-rail-item:hover {
  color: #fff;
  transform: translateY(-1px);
}

.tg-folder-rail-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: transparent;
  color: currentColor;
  font-size: 15px;
  font-weight: 700;
  transition: background-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

.tg-folder-rail-item:hover .tg-folder-rail-icon,
.tg-folder-rail-item.is-active .tg-folder-rail-icon {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.tg-folder-rail-item.is-active .tg-folder-rail-icon {
  background: #2f80ed;
  color: #fff;
  box-shadow: 0 12px 26px rgba(47, 128, 237, 0.34);
}

.tg-folder-rail-icon svg {
  width: 21px;
  height: 21px;
}

.tg-folder-rail-count {
  position: absolute;
  right: 4px;
  top: 4px;
  z-index: 2;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.18);
  transform: translate(20%, -20%);
}

.tg-account-switcher-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.tg-account-switcher-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.34);
}

.tg-account-switcher-panel {
  position: absolute;
  left: 58px;
  top: 0;
  z-index: 50;
  width: 248px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  box-shadow: 0 24px 54px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(18px);
}

.tg-account-row,
.tg-account-login-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border-radius: 14px;
  padding: 9px 10px;
  color: #334155;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.tg-account-row:hover,
.tg-account-login-link:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.tg-account-row-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #2563eb;
  font-size: 13px;
  font-weight: 800;
}

.tg-account-login-link {
  justify-content: center;
  margin-top: 4px;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
}

.tg-code-editor-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0.75rem;
  background: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.tg-code-editor-shell .cm-editor {
  min-height: 430px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}

.tg-code-editor-shell .cm-focused {
  outline: none;
}

.tg-code-editor-shell:focus-within {
  border-color: rgba(139, 92, 246, 0.65);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.28), 0 12px 28px rgba(15, 23, 42, 0.14);
}

.tg-code-editor-shell .cm-scroller {
  min-height: 430px;
}

.tg-code-editor-shell .cm-tooltip {
  border: 1px solid rgba(71, 85, 105, 0.92);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.98);
  color: #e2e8f0;
  box-shadow: 0 18px 42px rgba(2, 6, 23, 0.32);
  overflow: hidden;
}

.tg-code-editor-shell .cm-tooltip-autocomplete ul {
  max-height: 16rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}

.tg-code-editor-shell .cm-tooltip-autocomplete ul li[aria-selected] {
  background: rgba(139, 92, 246, 0.36);
  color: #f8fafc;
}

.tg-code-editor-shell .cm-completionDetail {
  color: #94a3b8;
}

.tg-code-editor-context-menu {
  position: fixed;
  z-index: 80;
  width: 14rem;
  padding: 0.35rem;
}

.tg-code-editor-menu-group {
  position: relative;
}

.tg-code-editor-menu-item {
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  cursor: pointer;
  font-size: 0.8125rem;
}

.tg-code-editor-menu-parent::after {
  margin-left: auto;
  content: "›";
  color: #94a3b8;
}

.tg-code-editor-submenu {
  position: absolute;
  top: -0.35rem;
  left: calc(100% + 0.35rem);
  display: none;
  width: 16rem;
  max-height: min(22rem, calc(100vh - 2rem));
  overflow-y: auto;
  padding: 0.35rem;
}

.tg-code-editor-menu-group:hover > .tg-code-editor-submenu,
.tg-code-editor-menu-group:focus-within > .tg-code-editor-submenu {
  display: block;
}

.tg-code-editor-toast {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 4;
  max-width: calc(100% - 1.5rem);
  transform: translateY(0.5rem);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  opacity: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.28);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.tg-code-editor-toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.tg-global-theme-control {
  flex-shrink: 0;
  padding-top: 12px;
}

.tg-global-theme-toggle {
  width: 52px;
  min-height: 48px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 14px;
  color: #475569;
  transition: background-color 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.tg-global-theme-toggle:hover {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  transform: translateY(-1px);
}

.tg-global-theme-icon {
  font-size: 20px;
  line-height: 1;
}

.tg-global-theme-label {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.tg-sidebar-panel {
  background: #f7f8fb;
}

.tg-search-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 14px;
  background: #eef1f5;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}

.tg-room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tg-room-row {
  display: flex;
  align-items: stretch;
  border-radius: 16px;
  background: transparent;
  transition: background-color 0.16s ease;
}

.tg-room-row:hover,
.tg-room-row.is-active {
  background: rgba(15, 23, 42, 0.06);
}

.tg-room-row.is-active {
  border-color: rgba(59, 130, 246, 0.22);
}

.tg-room-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  padding: 12px 12px 12px 14px;
  text-align: left;
}

.tg-room-avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #2563eb;
  font-size: 18px;
  font-weight: 700;
}

.tg-room-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  min-height: 20px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  vertical-align: middle;
  flex-shrink: 0;
}

.tg-room-badge.is-large {
  padding: 6px 12px;
  min-height: 28px;
  font-size: 12px;
}

.tg-room-badge.is-official {
  background: #fef3c7;
  color: #b45309;
}

.telegram-message-list {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.52), transparent 22%),
    radial-gradient(circle at bottom right, rgba(191, 219, 254, 0.35), transparent 20%),
    linear-gradient(180deg, rgba(223, 232, 241, 0.95) 0%, rgba(213, 226, 239, 0.98) 100%);
}

.message-bubble {
  max-width: min(75%, 42rem);
  backdrop-filter: blur(1px);
}

.tg-message-group-stack {
  gap: 2px;
}

.tg-message-avatar-lane {
  align-self: stretch;
}

.tg-message-avatar-sticky {
  position: sticky;
  bottom: 8px;
  align-self: flex-end;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.message-bubble[data-sender-type="self"],
.message-bubble[data-sender-type="other"] {
  position: relative;
  overflow: visible;
}

.message-bubble[data-tail="true"][data-sender-type="self"]::after,
.message-bubble[data-tail="true"][data-sender-type="other"]::after {
  content: "";
  position: absolute;
  bottom: -1px;
  width: 12px;
  height: 12px;
  background: var(--tg-bubble-bg);
}

.message-bubble[data-tail="true"][data-sender-type="self"]::after {
  right: -6px;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  border-right: 1px solid var(--tg-bubble-border-color);
  border-bottom: 1px solid var(--tg-bubble-border-color);
}

.message-bubble[data-tail="true"][data-sender-type="other"]::after {
  left: -6px;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  border-left: 1px solid var(--tg-bubble-border-color);
  border-bottom: 1px solid var(--tg-bubble-border-color);
}

.tg-room-badge.is-group {
  background: #dbeafe;
  color: #1d4ed8;
}

.tg-room-badge.is-bot {
  background: #ede9fe;
  color: #6d28d9;
}

.tg-pin-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #0f172a;
  color: white;
  font-size: 10px;
  font-weight: 700;
}

.tg-room-menu-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  list-style: none;
  color: #94a3b8;
  cursor: pointer;
}

.tg-room-menu-trigger::-webkit-details-marker {
  display: none;
}

.tg-room-menu-trigger:hover {
  background: rgba(241, 245, 249, 0.95);
  color: #475569;
}

.tg-room-menu {
  position: absolute;
  right: 0;
  top: 42px;
  z-index: 30;
  width: 224px;
  padding: 8px;
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.16);
}

.tg-contact-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(226, 232, 240, 0.72);
  box-shadow: 0 6px 14px rgba(148, 163, 184, 0.08);
}

.tg-contact-section-header.is-letter {
  background: rgba(241, 245, 249, 0.82);
}

.tg-contact-section-accent {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.tg-contact-section-accent.is-official {
  background: #f59e0b;
}

.tg-contact-section-accent.is-group {
  background: #38bdf8;
}

.tg-contact-section-accent.is-bot {
  background: #8b5cf6;
}

.tg-contact-row {
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(226, 232, 240, 0.72);
}

.tg-section-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-height: 64px;
  padding: 10px 12px;
  border-top: 1px solid rgba(226, 232, 240, 0.85);
  background: rgba(255, 255, 255, 0.9);
}

.tg-section-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 50px;
  border-radius: 16px;
  color: #64748b;
  font-size: 0;
  font-weight: 600;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tg-section-tab:hover,
.tg-section-tab[data-active="true"] {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  transform: translateY(-1px);
}

.tg-primary-action-button,
.tg-secondary-action-button {
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1rem;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.tg-primary-action-button {
  border: 1px solid rgba(37, 99, 235, 0.2);
  background: #2563eb;
  color: #fff;
}

.tg-primary-action-button:hover {
  background: #1d4ed8;
}

.tg-secondary-action-button {
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: rgba(255, 255, 255, 0.94);
  color: #475569;
}

.tg-secondary-action-button:hover {
  background: #f8fafc;
  color: #0f172a;
}

.tg-room-actions-menu {
  border-radius: 1rem;
  border: 1px solid rgba(226, 232, 240, 0.88);
  background: rgba(255, 255, 255, 0.96);
  color: #334155;
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(16px);
}

.tg-room-actions-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tg-room-actions-menu-item:hover,
.tg-room-actions-menu-item:focus {
  background: rgba(241, 245, 249, 0.95);
  color: #0f172a;
  outline: none;
}

.emoji-panel {
  width: min(34rem, calc(100vw - 1rem));
  max-width: none;
  overflow: hidden;
}

.emoji-panel-body {
  padding: 0.75rem;
}

.emoji-panel-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  border-top: 1px solid rgba(226, 232, 240, 0.92);
  background: rgba(248, 250, 252, 0.96);
  padding: 0.55rem;
}

.emoji-panel-tab {
  min-width: 5.5rem;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.emoji-panel-tab.is-active,
.emoji-panel-tab:hover {
  background: #e2e8f0;
  color: #334155;
}

.emoji-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr));
  gap: 0.5rem;
  max-height: min(22rem, 60vh);
  min-width: min(20rem, calc(100vw - 1rem));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
  scrollbar-width: none;
}

.emoji-panel-grid::-webkit-scrollbar,
.emoji-preview-container::-webkit-scrollbar {
  display: none;
}

.emoji-item {
  width: 100%;
  height: 2.75rem;
  min-width: 0;
}

.gif-sticker-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.gif-sticker-upload {
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.gif-sticker-status {
  min-width: 0;
  flex: 1;
  color: #94a3b8;
  font-size: 0.75rem;
  text-align: right;
}

.gif-sticker-folders {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.625rem;
  scrollbar-width: none;
}

.gif-sticker-folders::-webkit-scrollbar {
  display: none;
}

.gif-sticker-folder {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.gif-sticker-folder.is-active,
.gif-sticker-folder:hover {
  background: #dbeafe;
  color: #2563eb;
}

.gif-sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.75rem, 1fr));
  gap: 0.625rem;
  max-height: min(22rem, 60vh);
  min-width: min(20rem, calc(100vw - 1rem));
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-width: none;
}

.gif-sticker-grid::-webkit-scrollbar {
  display: none;
}

.gif-sticker-item {
  position: relative;
  min-height: 4.75rem;
  border-radius: 1rem;
  background: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gif-sticker-item:hover {
  background: #f1f5f9;
}

.gif-sticker-item img {
  max-width: 100%;
  max-height: 5.75rem;
  object-fit: contain;
}

.gif-sticker-actions {
  position: absolute;
  left: 0.25rem;
  right: 0.25rem;
  bottom: 0.25rem;
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.gif-sticker-item:hover .gif-sticker-actions {
  opacity: 1;
}

.gif-sticker-action {
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: white;
  line-height: 1;
}

.gif-sticker-action svg {
  width: 0.9rem;
  height: 0.9rem;
}

.gif-sticker-empty {
  padding: 2.5rem 1rem;
  color: #94a3b8;
  font-size: 0.875rem;
  text-align: center;
}

.emoji-preview-container {
  overflow-x: hidden !important;
  scrollbar-width: none;
}

.tg-main-panel {
  background: #fff;
}

.tg-settings-card {
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.84);
  background: #fff;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.tg-settings-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.94);
  background: #f8fafc;
  padding: 8px 12px;
  color: #334155;
  font-size: 0.875rem;
  outline: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.tg-settings-input:focus {
  border-color: rgba(56, 189, 248, 0.5);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.tg-folder-settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
  background: #f8fafc;
  padding: 10px 12px;
  cursor: grab;
  transition: background-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.tg-folder-settings-row:hover {
  background: #f1f5f9;
  box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0.65);
}

.tg-folder-settings-row.is-dragging {
  opacity: 0.58;
  cursor: grabbing;
}

.tg-folder-drag-handle {
  color: #94a3b8;
  font-size: 15px;
  letter-spacing: -0.28em;
}

.tg-folder-settings-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 12px;
  background: #e2e8f0;
  color: #334155;
}

.tg-folder-settings-icon svg {
  width: 19px;
  height: 19px;
}

.tg-folder-settings-delete {
  border-radius: 999px;
  padding: 6px 10px;
  color: #dc2626;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background-color 0.16s ease;
}

.tg-folder-settings-delete:hover {
  background: #fee2e2;
}

.tg-sidebar-collapse-button,
.tg-desktop-sidebar-toggle {
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #64748b;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.tg-sidebar-collapse-button:hover,
.tg-desktop-sidebar-toggle:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #0f172a;
}

.tg-desktop-sidebar-toggle {
  position: fixed;
  top: 76px;
  left: 18px;
  z-index: 35;
  color: #475569;
}

@media (min-width: 640px) {
  .tg-desktop-sidebar-toggle:not(.hidden) {
    display: flex;
  }

  .tg-app-shell.tg-sidebar-rail-only .tg-desktop-sidebar-toggle {
    display: flex;
  }

  .tg-app-shell.tg-sidebar-rail-only .tg-desktop-sidebar-toggle {
    background: rgba(255, 255, 255, 0.46);
    box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0.72);
  }

  .tg-app-shell.tg-sidebar-rail-only .tg-desktop-sidebar-toggle:hover {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
  }

  #sidebar.tg-sidebar-collapsed {
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
    box-shadow: none;
  }

  #sidebar.tg-sidebar-collapsed .tg-sidebar-panel {
    display: none;
  }
}

.tg-chat-empty-state {
  position: relative;
  overflow: hidden;
}

.tg-chat-empty-state::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.12), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(14, 165, 233, 0.12), transparent 22%),
    radial-gradient(circle at 80% 78%, rgba(59, 130, 246, 0.08), transparent 28%);
  pointer-events: none;
}

.tg-chat-empty-icon {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  border-radius: 26px;
  background: linear-gradient(135deg, #3a7bd5 0%, #47b1ff 100%);
  color: white;
  font-size: 28px;
  box-shadow: 0 18px 32px rgba(58, 123, 213, 0.2);
}

.telegram-chat-room {
  --tg-composer-height: 76px;
  background: linear-gradient(180deg, #e7eef6 0%, #dfe8f1 100%);
}

.telegram-chat-room .telegram-chat-header {
  border-bottom: 1px solid rgba(203, 213, 225, 0.88);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.telegram-chat-room .telegram-message-list {
  position: relative;
  padding-bottom: calc(var(--tg-composer-height) + 1rem);
  scroll-padding-bottom: calc(var(--tg-composer-height) + 1rem);
  background:
    linear-gradient(180deg, rgba(236, 242, 247, 0.96), rgba(222, 233, 241, 0.98));
}

.telegram-chat-room .telegram-message-list::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.46;
  background-image:
    radial-gradient(circle at 25px 25px, rgba(141, 188, 220, 0.28) 0, rgba(141, 188, 220, 0.28) 2px, transparent 2px),
    radial-gradient(circle at 80px 70px, rgba(122, 169, 208, 0.18) 0, rgba(122, 169, 208, 0.18) 3px, transparent 3px);
  background-size: 120px 120px;
  pointer-events: none;
}

.telegram-chat-room .telegram-message-list > * {
  position: relative;
  z-index: 1;
}

.telegram-chat-room .telegram-composer {
  position: sticky;
  bottom: 0;
  min-height: 71px;
  flex-shrink: 0;
  z-index: 20;
  border-top: 1px solid rgba(203, 213, 225, 0.88);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.telegram-chat-room .telegram-composer-shell {
  border: 1px solid rgba(226, 232, 240, 0.88);
  border-radius: 20px;
  background: rgba(248, 250, 252, 0.95);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.telegram-chat-room .telegram-composer textarea {
  background: transparent;
}

.telegram-chat-room .telegram-composer textarea,
.telegram-chat-room .telegram-composer textarea::placeholder {
  font-size: 16px;
}

.tg-app-shell.tg-has-chat-background .telegram-message-list {
  background-color: transparent;
  background-size: auto;
  background-repeat: no-repeat;
  background-position: center;
}

.tg-app-shell.tg-has-chat-background .telegram-message-list::before {
  opacity: 0.12;
}

.tg-app-shell.tg-has-chat-background .telegram-chat-header,
.tg-app-shell.tg-has-chat-background .telegram-composer {
  background: rgba(255, 255, 255, 0.72);
}

html.tg-theme-dark .tg-app-shell.tg-has-chat-background .telegram-chat-header,
html.tg-theme-dark .tg-app-shell.tg-has-chat-background .telegram-composer {
  background: rgba(15, 23, 42, 0.74);
}

.tg-ui-icon {
  object-fit: contain;
  filter: saturate(1.18) contrast(1.14);
}

.tg-section-tab .tg-ui-icon,
.tg-sidebar-collapse-button .tg-ui-icon,
.tg-desktop-sidebar-toggle .tg-ui-icon {
  opacity: 0.92;
}

html.tg-theme-light .tg-app-shell {
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 24%),
    linear-gradient(135deg, #e9eef4 0%, #dfe7f1 100%);
}

html.tg-theme-light .tg-sidebar-panel {
  background: #f7f8fb;
}

html.tg-theme-light .tg-main-panel {
  background: #fff;
}

html.tg-theme-light .tg-section-switcher {
  background: rgba(255, 255, 255, 0.9);
}

.letter {
  transition: all 0.2s ease;
}

.letter.active {
  background-color: #3a7bd5;
  color: white;
  font-weight: 700;
}

html.tg-theme-dark body {
  background: #0b1120;
  color: #e2e8f0;
}

html.tg-theme-dark .tg-app-shell {
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.16), transparent 24%),
    linear-gradient(135deg, #0b1120 0%, #111827 100%);
}

html.tg-theme-dark .tg-folder-rail {
  background: linear-gradient(180deg, #111827 0%, #0b1120 100%);
  color: rgba(226, 232, 240, 0.95);
  border-color: rgba(30, 41, 59, 0.95);
}

html.tg-theme-dark .tg-folder-rail-item:hover .tg-folder-rail-icon,
html.tg-theme-dark .tg-folder-rail-item.is-active .tg-folder-rail-icon {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

html.tg-theme-dark .tg-folder-rail-item.is-active .tg-folder-rail-icon {
  background: #0ea5e9;
  color: #082f49;
  box-shadow: 0 12px 26px rgba(14, 165, 233, 0.24);
}

html.tg-theme-dark .tg-folder-rail-count {
  background: #38bdf8;
  color: #082f49;
}

html.tg-theme-dark .tg-account-switcher-panel {
  border-color: rgba(51, 65, 85, 0.92);
  background: rgba(15, 23, 42, 0.98);
  color: #e2e8f0;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.34);
}

html.tg-theme-dark .tg-account-row,
html.tg-theme-dark .tg-account-login-link {
  color: #cbd5e1;
}

html.tg-theme-dark .tg-account-row:hover,
html.tg-theme-dark .tg-account-login-link:hover {
  background: rgba(51, 65, 85, 0.96);
  color: #f8fafc;
}

html.tg-theme-dark .tg-account-row-avatar {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(37, 99, 235, 0.32));
  color: #bae6fd;
}

html.tg-theme-dark .tg-global-theme-toggle {
  background: rgba(250, 204, 21, 0.13);
  border-color: rgba(250, 204, 21, 0.18);
  color: #fde68a;
}

html.tg-theme-dark .tg-sidebar-panel,
html.tg-theme-dark .tg-main-panel {
  background: rgba(15, 23, 42, 0.96);
}

html.tg-theme-dark .tg-search-shell,
html.tg-theme-dark .tg-room-row,
html.tg-theme-dark .tg-contact-row,
html.tg-theme-dark .tg-contact-section-header,
html.tg-theme-dark .tg-section-switcher,
html.tg-theme-dark .tg-room-menu,
html.tg-theme-dark .tg-room-actions-menu,
html.tg-theme-dark .tg-settings-card,
html.tg-theme-dark .tg-folder-settings-row {
  border-color: rgba(51, 65, 85, 0.92);
  background: rgba(30, 41, 59, 0.92);
  color: #e2e8f0;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.22);
}

html.tg-theme-dark .tg-settings-input {
  border-color: rgba(51, 65, 85, 0.92);
  background: rgba(15, 23, 42, 0.82);
  color: #e2e8f0;
}

html.tg-theme-dark .tg-folder-settings-icon {
  background: rgba(51, 65, 85, 0.96);
  color: #cbd5e1;
}

html.tg-theme-dark .tg-folder-settings-row:hover {
  background: rgba(51, 65, 85, 0.95);
}

html.tg-theme-dark .tg-folder-drag-handle {
  color: #64748b;
}

html.tg-theme-dark .tg-room-row:hover,
html.tg-theme-dark .tg-room-row.is-active,
html.tg-theme-dark .tg-contact-row:hover,
html.tg-theme-dark .tg-room-actions-menu-item:hover,
html.tg-theme-dark .tg-room-actions-menu-item:focus {
  background: rgba(51, 65, 85, 0.95);
  color: #f8fafc;
}

html.tg-theme-dark .tg-contact-section-header.is-letter {
  background: rgba(15, 23, 42, 0.94);
}

html.tg-theme-dark .tg-section-tab {
  color: #94a3b8;
}

html.tg-theme-dark .tg-section-tab .tg-ui-icon,
html.tg-theme-dark .tg-sidebar-collapse-button .tg-ui-icon,
html.tg-theme-dark .tg-desktop-sidebar-toggle .tg-ui-icon {
  filter: brightness(1.35) saturate(1.12) contrast(1.08);
}

html.tg-theme-dark .tg-section-tab:hover,
html.tg-theme-dark .tg-section-tab[data-active="true"] {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

html.tg-theme-dark .tg-primary-action-button {
  border-color: rgba(56, 189, 248, 0.28);
  background: #0ea5e9;
  color: #082f49;
}

html.tg-theme-dark .tg-primary-action-button:hover {
  background: #38bdf8;
}

html.tg-theme-dark .tg-secondary-action-button {
  border-color: rgba(71, 85, 105, 0.9);
  background: rgba(30, 41, 59, 0.95);
  color: #cbd5e1;
}

html.tg-theme-dark .tg-secondary-action-button:hover {
  background: rgba(51, 65, 85, 0.96);
  color: #f8fafc;
}

html.tg-theme-dark .telegram-chat-room {
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
}

html.tg-theme-dark .telegram-chat-room .telegram-chat-header,
html.tg-theme-dark .telegram-chat-room .telegram-composer {
  border-color: rgba(51, 65, 85, 0.92);
  background: rgba(15, 23, 42, 0.88);
}

html.tg-theme-dark .telegram-chat-room .telegram-message-list {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.98));
}

html.tg-theme-dark .telegram-chat-room .telegram-composer-shell {
  border-color: rgba(51, 65, 85, 0.92);
  background: rgba(30, 41, 59, 0.94);
}

html.tg-theme-dark .emoji-panel {
  border-color: rgba(51, 65, 85, 0.92);
  background: rgba(15, 23, 42, 0.96);
}

html.tg-theme-dark .emoji-panel-tabs {
  border-color: rgba(51, 65, 85, 0.92);
  background: rgba(15, 23, 42, 0.98);
}

html.tg-theme-dark .emoji-panel-tab.is-active,
html.tg-theme-dark .emoji-panel-tab:hover,
html.tg-theme-dark .gif-sticker-folder.is-active,
html.tg-theme-dark .gif-sticker-folder:hover {
  background: rgba(37, 99, 235, 0.24);
  color: #bfdbfe;
}

html.tg-theme-dark .gif-sticker-upload,
html.tg-theme-dark .gif-sticker-folder,
html.tg-theme-dark .gif-sticker-item {
  border-color: rgba(51, 65, 85, 0.88);
  background: rgba(30, 41, 59, 0.92);
  color: #cbd5e1;
}

html.tg-theme-dark .tg-contact-detail {
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
}

html.tg-theme-dark .tg-app-shell .bg-white,
html.tg-theme-dark .tg-app-shell .bg-white\/90,
html.tg-theme-dark .tg-app-shell .bg-white\/95,
html.tg-theme-dark .tg-app-shell .bg-slate-50,
html.tg-theme-dark .tg-app-shell .bg-slate-50\/70,
html.tg-theme-dark .tg-app-shell .bg-slate-100,
html.tg-theme-dark .tg-app-shell .bg-slate-200,
html.tg-theme-dark .tg-contact-detail .bg-white,
html.tg-theme-dark .tg-contact-detail .bg-white\/95,
html.tg-theme-dark .tg-contact-detail .bg-slate-50,
html.tg-theme-dark .tg-contact-detail .bg-slate-100,
html.tg-theme-dark .tg-contact-detail .bg-slate-200 {
  background-color: rgba(30, 41, 59, 0.92) !important;
}

html.tg-theme-dark .tg-app-shell .text-slate-900,
html.tg-theme-dark .tg-app-shell .text-slate-800,
html.tg-theme-dark .tg-contact-detail .text-slate-900,
html.tg-theme-dark .tg-contact-detail .text-slate-800 {
  color: #e2e8f0 !important;
}

html.tg-theme-dark .tg-app-shell .text-slate-700,
html.tg-theme-dark .tg-app-shell .text-slate-600,
html.tg-theme-dark .tg-contact-detail .text-slate-700,
html.tg-theme-dark .tg-contact-detail .text-slate-600 {
  color: #cbd5e1 !important;
}

html.tg-theme-dark .tg-app-shell .text-slate-500,
html.tg-theme-dark .tg-app-shell .text-slate-400,
html.tg-theme-dark .tg-contact-detail .text-slate-500,
html.tg-theme-dark .tg-contact-detail .text-slate-400 {
  color: #94a3b8 !important;
}

html.tg-theme-dark .tg-app-shell .border-slate-100,
html.tg-theme-dark .tg-app-shell .border-slate-200,
html.tg-theme-dark .tg-contact-detail .border-slate-100,
html.tg-theme-dark .tg-contact-detail .border-slate-200 {
  border-color: rgba(51, 65, 85, 0.92) !important;
}

#resizer {
  min-width: 12px;
  touch-action: none;
  background: transparent;
}

#resizer:hover {
  background: transparent;
}

@media (max-width: 639px) {
  .tg-app-shell {
    width: 100vw;
    border-radius: 0;
  }

  .tg-main-panel,
  .telegram-chat-room,
  #chat-box {
    min-height: 0;
    overflow: hidden;
  }

  .tg-main-panel > .sticky {
    padding-top: calc(0.75rem + env(safe-area-inset-top));
  }

  .telegram-chat-room .telegram-chat-header {
    min-height: calc(4rem + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  .telegram-chat-room .telegram-message-list {
    padding: 1rem 1rem calc(var(--tg-composer-height) + 1rem);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-bottom: calc(var(--tg-composer-height) + env(safe-area-inset-bottom) + 0.5rem);
  }

  .telegram-chat-room .telegram-composer {
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }

  .tg-section-switcher {
    gap: 6px;
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }

  .tg-folder-rail {
    width: 78px;
    padding: 12px 8px;
  }

  .tg-folder-rail-item {
    min-height: 58px;
  }

  .emoji-panel {
    right: -0.25rem;
    width: min(30rem, calc(100vw - 0.75rem));
  }

  .emoji-panel-grid {
    min-width: 0;
    max-height: min(20rem, 56vh);
  }
}

@media (min-width: 640px) {
  .telegram-chat-room .telegram-composer textarea,
  .telegram-chat-room .telegram-composer textarea::placeholder {
    font-size: 14px;
  }
}

@media (min-width: 640px) {
  #resizer {
    min-width: 4px;
  }
}
