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

:root {
  --bg-base: #151517;
  --bg-sidebar: #151517;
  --bg-layer-2: #2c2c2e;
  --bg-layer-3: #353638;
  --bg-input: #1c1c1e;
  --bg-bubble: #1c1c1e;
  --bg-chat-active: #2c2c2e;
  --bg-card: #1c1c1e;
  --bg-modal: #2c2c2e;
  --bg-hover: rgba(255, 255, 255, 0.08);
  --bg-mask: rgba(0, 0, 0, 0.6);

  --text-primary: #f5f5f7;
  --text-secondary: #98989d;
  --text-tertiary: #86868b;
  --text-caption: #6e6e73;

  --border-l1: rgba(255, 255, 255, 0.08);
  --border-l2: rgba(255, 255, 255, 0.15);
  --border-l2-thin: rgba(255, 255, 255, 0.08);
  --border-l3: rgba(255, 255, 255, 0.2);
  --border-inverted: rgba(255, 255, 255, 0.08);

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-text: #0071e3;

  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --purple: #af52de;

  --scroll-color: rgba(255, 255, 255, 0.15);
  --scroll-color-hover: rgba(255, 255, 255, 0.24);

  --font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-code: Menlo, Monaco, Consolas, "Cascadia Mono", "Ubuntu Mono", "DejaVu Sans Mono", "JetBrains Mono", "Fira Code", "Courier New", monospace;

  --sider-width: 261px;
  --message-max-width: 840px;
  --message-padding-horizontal: 44px;

  --control-height-l: 40px;
  --control-height-m: 36px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-2xl: 24px;
  --radius-round: 100px;

  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(0, 0, .2, 1);
  --transition-duration: .2s;
  --transition-duration-fast: .1s;
  --transition-duration-slow: .3s;

  --shadow-lv3: 0 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 4px 0 rgba(0, 0, 0, 0.02), 0 12px 32px 0 rgba(0, 0, 0, 0.08);
}

[data-theme="light"] {
  --bg-base: #f5f5f7;
  --bg-sidebar: rgba(245, 245, 247, 0.8);
  --bg-layer-2: #ffffff;
  --bg-layer-3: #ffffff;
  --bg-input: #ffffff;
  --bg-bubble: #ffffff;
  --bg-chat-active: rgba(0, 113, 227, 0.08);
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-mask: rgba(0, 0, 0, 0.2);

  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #6e6e73;
  --text-caption: #aeaeb2;

  --border-l1: rgba(0, 0, 0, 0.06);
  --border-l2: rgba(0, 0, 0, 0.1);
  --border-l2-thin: rgba(0, 0, 0, 0.06);
  --border-l3: rgba(0, 0, 0, 0.15);
  --border-inverted: transparent;

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-text: #0071e3;

  --scroll-color: rgba(0, 0, 0, 0.08);
  --scroll-color-hover: rgba(0, 0, 0, 0.15);
  --tooltip-bg: #636366;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 25px;
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-variant-ligatures: normal;
  letter-spacing: -0.01em;
  word-break: break-word;
  margin: 0;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

::-webkit-scrollbar { width: 0px; height: 0px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: transparent; }

.icon-xs { width: 14px; height: 14px; stroke-width: 2.5; }
.icon-sm { width: 16px; height: 16px; stroke-width: 2; }
.icon-md { width: 20px; height: 20px; stroke-width: 1.8; }
[data-lucide] { vertical-align: middle; }

/* Все модалки и меню — поверх сайдбара */
.modal.show,
.profile-menu-modal.show,
.lang-modal.show,
.chat-action-modal.show,
.admin-confirm-overlay,
.admin-modal-overlay.show {
  z-index: 200 !important;
}

/* ========== САЙДБАР ========== */
.sidebar {
  width: var(--sider-width);
  max-width: var(--sider-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border-l1);
  overflow: hidden;
  z-index: 50;
  padding: 6px 12px 10px;
  box-sizing: border-box;
  position: relative;
}

[data-theme="light"] .sidebar {
  -webkit-backdrop-filter: blur(40px);
  backdrop-filter: blur(40px);
  -webkit--webkit-backdrop-filter: blur(40px);
  backdrop-filter: blur(40px);
}

/* Кнопка-сэндвич внутри сайдбара (мобильные) */
.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 20px;
  cursor: pointer;
  z-index: 10;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.sidebar-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 48px;
  padding: 15px 0 10px 4px;
  margin-bottom: 16px;
  box-sizing: border-box;
  gap: 4px;
}

.sidebar-top-row .logo {
  flex: 1;
  min-width: 0;
}

.sidebar-top-row .btn-collapse-sidebar {
  flex-shrink: 0;
}

.logo { display: flex; align-items: center; gap: 8px; cursor: pointer; flex-shrink: 0; }
.logo img { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; }
.logo-text { font-size: 14px; font-weight: 500; line-height: 22px; color: var(--text-primary); }

.btn-collapse-sidebar {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm); width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-duration-fast) var(--ease-in-out); flex-shrink: 0;
}
.btn-collapse-sidebar:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Бургер в шапке */
.btn-toggle-sidebar {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.btn-toggle-sidebar:hover { 
  background: var(--bg-hover); 
  color: var(--text-primary); 
}

.btn-new-chat {
  width: 100%; height: var(--control-height-l); background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border-l2-thin); padding: 0 16px; border-radius: var(--radius-round);
  cursor: pointer; font-size: 14px; font-weight: 500; line-height: 22px;
  display: flex; align-items: center; gap: 6px; font-family: var(--font-family);
  margin-bottom: 8px; outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.btn-new-chat:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.15);
  transform: translateY(-1px);
  color: var(--accent);
}

/* Кнопка Новый чат в шапке (мобильные) */
.btn-new-chat-header {
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-l2);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-round);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-family);
  transition: all 0.2s ease;
}
.btn-new-chat-header:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* FAB убран */
.btn-new-chat-fab {
  display: none;
}

.chat-section {
  flex: 1; overflow-y: auto; margin: 0 -2px; padding: 0 2px;
  position: relative; min-height: 0;
}

.chat-section-title {
  font-size: 12px; font-weight: 500; line-height: 18px; color: var(--text-tertiary);
  padding: 6px 10px 0; position: sticky; top: 0; background: var(--bg-sidebar); z-index: 2;
}

.chat-list { display: flex; flex-direction: column; }

.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px 9px 10px; border-radius: var(--radius-md);
  cursor: pointer; font-size: 14px; line-height: 22px; color: var(--text-primary);
  height: var(--control-height-l); text-decoration: none; position: relative;
  transition: background-color var(--transition-duration) var(--ease-in-out); box-sizing: border-box;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-chat-active); color: var(--accent); }
.chat-item.active .chat-item-title { color: var(--accent); font-weight: 500; }

.chat-item-info { flex: 1; min-width: 0; overflow: hidden; }
.chat-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 22px; color: var(--text-primary); font-weight: 400; }
.chat-item-date { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }

/* Три точки всегда видны */
.chat-item-actions { 
  display: flex; 
  position: absolute; 
  right: 4px; 
  top: 50%; 
  transform: translateY(-50%); 
  opacity: 0.4;
  transition: opacity 0.2s ease;
}
.chat-item:hover .chat-item-actions { opacity: 1; }

.btn-chat-action {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  padding: 4px; border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-duration-fast) var(--ease-in-out);
}
.btn-chat-action:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }

.chat-section-fade {
  position: sticky; bottom: 0; left: 0; right: 0;
  height: 68px;
  background: linear-gradient(180deg, transparent 0%, var(--bg-sidebar) 80.65%);
  pointer-events: none; flex-shrink: 0;
}

.sidebar-bottom { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border-l1); }

.sidebar-profile-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px 6px 6px; border-radius: var(--radius-md);
  cursor: pointer; transition: background-color var(--transition-duration-fast) var(--ease-in-out);
  box-sizing: border-box;
}
.sidebar-profile-row:hover { background: var(--bg-hover); }

.sidebar-profile-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #af52de); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500; flex-shrink: 0;
}
.sidebar-profile-info { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-profile-name { font-size: 14px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile-email { font-size: 12px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-profile-dots {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: 16px;
  transition: all var(--transition-duration-fast) var(--ease-in-out);
}
.sidebar-profile-dots:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ==================== КОЛЛАПС САЙДБАРА ==================== */
.floating-sidebar-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(44, 44, 46, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(40px);
  -webkit--webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.floating-sidebar-btn.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.floating-sidebar-btn:hover {
  background: rgba(60, 60, 62, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}
[data-theme="light"] .floating-sidebar-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .floating-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.15);
}

/* Сайдбар уезжает влево */
.sidebar.collapsed {
  transform: translateX(-100%);
  width: 0;
  max-width: 0;
  padding: 0;
  border: none;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              width 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              max-width 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              padding 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Плавный переход сайдбара */
.sidebar {
  transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              width 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              max-width 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* На мобилках плавающая кнопка не нужна */
@media (max-width: 768px) {
  .floating-sidebar-btn {
    display: none !important;
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sider-width);
    max-width: 100vw;
    padding: 6px 12px 10px;
    border-right: 1px solid var(--border-l1);
  }
}

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

/* ========== ХЕДЕР ========== */
.header {
  display: flex; justify-content: space-between; align-items: center;
  height: 60px; padding: 0 16px; background: var(--bg-base); flex-shrink: 0; box-sizing: border-box;
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; min-width: 0; }

.btn-header {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm); width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-duration-fast) var(--ease-in-out); flex-shrink: 0;
}
.btn-header:hover { background: var(--bg-hover); color: var(--text-primary); }

.chat-title { font-size: 14px; font-weight: 500; line-height: 22px; color: var(--text-primary); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; max-width: 400px; display: flex; align-items: baseline; gap: 6px; }
.chat-subtitle { font-size: 12px; font-weight: 400; color: var(--text-tertiary); }

.online-header { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-tertiary); }
.online-dot-header { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(52, 199, 89, 0.5); animation: breathing 2s ease-in-out infinite; }

@keyframes breathing {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

.tariff-badge {
  background: rgba(0, 113, 227, 0.08); color: var(--accent);
  padding: 5px 14px; border-radius: var(--radius-round); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--transition-duration-fast) var(--ease-in-out);
  border: 0.5px solid rgba(0, 113, 227, 0.15); white-space: nowrap;
}
.tariff-badge:hover { background: rgba(0, 113, 227, 0.15); }

.requests-counter {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0, 113, 227, 0.06); color: var(--accent);
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  margin-right: 4px; white-space: nowrap;
}
.requests-counter .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.requests-counter.low { background: rgba(255, 149, 0, 0.08); color: var(--orange); }
.requests-counter.low .dot { background: var(--orange); }
.requests-counter.empty { background: rgba(255, 59, 48, 0.08); color: var(--red); }
.requests-counter.empty .dot { background: var(--red); }

.btn-login-header {
  text-decoration: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-round);
  background: linear-gradient(135deg, #0071e3, #0a84ff, #409cff, #0071e3);
  background-size: 300% 300%;
  white-space: nowrap;
  margin-right: 4px;
  box-shadow: 0 2px 8px rgba(0,113,227,0.3);
  transition: all 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.btn-login-header:hover {
  background-position: 100% 50%;
  box-shadow: 0 8px 24px rgba(0,113,227,0.5);
  transform: translateY(-1px);
}
.btn-login-header:active { transform: scale(0.97); }

/* ========== ОСНОВНОЙ ЭКРАН ========== */
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; background: var(--bg-base); scroll-behavior: smooth; padding-bottom: 0; border-top: none !important; box-shadow: none !important; }

.premium-welcome {
  max-width: var(--message-max-width); width: 100%;
  padding: 60px var(--message-padding-horizontal) 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  flex: 1; margin-top: 0;
}
.welcome-title { font-size: 24px; font-weight: 600; line-height: 32px; color: var(--text-primary); margin-bottom: 21px; text-align: center; }
.welcome-subtitle { font-size: 15px; color: var(--text-secondary); margin-bottom: 16px; text-align: center; }

/* ========== СЕТКА КАТЕГОРИЙ ========== */
.premium-categories { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 14px; width: 100%; }

.premium-cat-card {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 12px; background: var(--bg-card); border: 1px solid var(--border-l2);
  border-radius: var(--radius-lg); cursor: pointer; width: 240px; min-height: 64px;
  transition: all 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
  outline: none; box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.premium-cat-card:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--accent);
}

.premium-cat-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; }

.premium-cat-card[data-color="#0071e3"] .premium-cat-icon { background: rgba(0, 113, 227, 0.15); color: #0071e3; }
.premium-cat-card[data-color="#af52de"] .premium-cat-icon { background: rgba(175, 82, 222, 0.15); color: #af52de; }
.premium-cat-card[data-color="#34c759"] .premium-cat-icon { background: rgba(52, 199, 89, 0.15); color: #34c759; }
.premium-cat-card[data-color="#ff3b30"] .premium-cat-icon { background: rgba(255, 59, 48, 0.15); color: #ff3b30; }
.premium-cat-card[data-color="#ff9500"] .premium-cat-icon { background: rgba(255, 149, 0, 0.15); color: #ff9500; }
.premium-cat-card[data-color="#5856d6"] .premium-cat-icon { background: rgba(99, 102, 241, 0.15); color: #6366f1; }

.premium-cat-info { flex: 1; min-width: 0; overflow: hidden; }
.premium-cat-name { font-size: 14px; font-weight: 500; line-height: 22px; color: var(--text-primary); display: block; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.premium-cat-desc { font-size: 12px; line-height: 15px; color: var(--text-tertiary); display: block; }

.premium-cat-arrow { color: var(--text-tertiary); opacity: 0; transition: all var(--transition-duration-fast) var(--ease-in-out); flex-shrink: 0; }
.premium-cat-card:hover .premium-cat-arrow { opacity: 1; transform: translateX(3px); }

.trending-questions { width: 100%; margin-top: 12px; margin-bottom: 10px; text-align: center; }
.trending-label { font-size: 12px; font-weight: 500; color: var(--orange); display: block; margin-bottom: 8px; text-align: center; }

.btn-all-categories {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-input); border: 1px solid var(--border-l2); color: var(--text-tertiary);
  padding: 8px 16px; border-radius: var(--radius-round); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all var(--transition-duration-fast) var(--ease-in-out);
  margin-bottom: 8px; font-family: var(--font-family);
}
.btn-all-categories:hover { background: var(--border-l2); color: var(--text-primary); }

/* ========== СООБЩЕНИЯ ========== */
.message {
  display: flex; flex-direction: column; width: 100%;
  max-width: var(--message-max-width); padding: 0 var(--message-padding-horizontal);
  padding-bottom: 20px; position: relative; box-sizing: border-box;
}
.message.user + .message.assistant { padding-top: 28px; }

.message-content { font-size: 15px; line-height: 1.7; color: var(--text-primary); max-width: 100%; min-width: 0; letter-spacing: -0.01em; }

.message.user { align-items: flex-end; }
.message.user .message-content {
  background: var(--bg-bubble); border: none; color: var(--text-primary);
  padding: 10px 16px; border-radius: var(--radius-xl); width: auto;
  max-width: calc(100% - 88px); font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; box-sizing: border-box;
  letter-spacing: -0.01em;
}

.message.assistant { align-items: flex-start; }
.message.assistant .message-content { background: transparent; border: none; padding: 0; color: var(--text-primary); width: 100%; }

.message-content p { margin: 12px 0; }
.message-content p:first-child { margin-top: 0; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 12px 0; padding-left: 20px; }
.message-content li:not(:first-child) { margin-top: 4px; }
.message-content li::marker { color: var(--text-secondary); }
.message-content h1, .message-content h2, .message-content h3 { margin: 24px 0 12px; font-weight: 600; letter-spacing: -0.02em; }
.message-content h4, .message-content h5, .message-content h6 { margin: 16px 0 8px; font-weight: 600; }
.message-content h1 { font-size: 20px; line-height: 1.4; }
.message-content h2 { font-size: 18px; line-height: 1.4; }
.message-content h3 { font-size: 16px; line-height: 1.5; }
.message-content h4 { font-size: 15px; line-height: 1.5; }
.message-content strong { font-weight: 600; }
.message-content a { color: var(--accent-text); text-decoration: none; }
.message-content a:hover { text-decoration: underline; }
.message-content blockquote { border-left: 2px solid var(--text-caption); margin: 12px 0; padding-left: 14px; color: var(--text-secondary); }
.message-content hr { background: var(--border-l2); border: none; height: 1px; margin: 24px 0; }

.message-content pre {
  background: var(--bg-card); border: 1px solid var(--border-l1);
  border-radius: var(--radius-md); padding: 16px; overflow-x: auto;
  font-family: var(--font-code); font-size: 13px; line-height: 1.6;
  margin: 12px 0; position: relative;
}
.message-content code { font-family: var(--font-code); font-size: 13px; background: rgba(255,255,255,0.06); border-radius: 4px; padding: 2px 6px; }
.message-content pre code { background: none; padding: 0; border-radius: 0; font-size: 13px; line-height: 1.6; }
.message-content table { border-collapse: collapse; width: max-content; max-width: 100%; font-size: 14px; }
.message-content th { border-bottom: 1px solid var(--border-l3); font-weight: 600; font-size: 14px; padding: 8px 16px; text-align: left; }
.message-content td { border-bottom: 1px solid var(--border-l2); font-size: 14px; padding: 8px 16px; }

.code-copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; padding: 6px 10px; border-radius: 6px;
  cursor: pointer; font-size: 14px; z-index: 5;
  transition: all var(--transition-duration-fast) var(--ease-in-out);
}
.code-copy-btn:hover { background: rgba(255,255,255,0.2); }

.message-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition-duration-fast) var(--ease-in-out); margin-top: 6px; }
.message:hover .message-actions { opacity: 1; }
.message.user .message-actions { justify-content: flex-end; }
.message.assistant .message-actions { justify-content: flex-start; }

.btn-message-action {
  background: transparent; border: none; border-radius: var(--radius-sm);
  padding: 4px 6px; cursor: pointer; color: var(--text-tertiary);
  font-size: 14px; transition: all var(--transition-duration-fast) var(--ease-in-out);
}
.btn-message-action:hover { background: var(--bg-hover); color: var(--accent); }

.typing-dots { display: inline-flex; gap: 4px; padding: 12px 0; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); animation: typingBounce 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-7px); opacity: 1; }
}

/* ========== ПОЛЕ ВВОДА ========== */
.input-area {
  position: sticky; bottom: 0; left: 0; right: 0;
  margin: auto 32px 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; z-index: 10;
  background: var(--bg-base);
  border-top: none !important; box-shadow: none !important;
}

.input-wrapper {
  display: flex; align-items: flex-end; gap: 4px;
  background: var(--bg-input); border: 1.5px solid var(--border-l2);
  border-radius: var(--radius-2xl); padding: 12px;
  width: 100%; max-width: var(--message-max-width);
  box-shadow: none;
  transition: all var(--transition-duration) var(--ease-in-out);
  box-sizing: border-box;
}

[data-theme="light"] .input-wrapper {
  border-width: 2px;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

[data-theme="light"] .input-wrapper:focus-within {
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}

.input-wrapper textarea {
  flex: 1; background: none; border: none; color: var(--text-primary);
  font-size: 16px; line-height: 24px; resize: none; outline: none; padding: 12px 0;
  font-family: var(--font-family); min-height: 56px; max-height: 400px;
  overflow-y: auto; caret-color: var(--accent-text); align-self: center;
}
.input-wrapper textarea::placeholder { color: var(--text-caption); }

.input-action-btn {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  padding: 6px; border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all var(--transition-duration-fast) var(--ease-in-out);
  align-self: flex-end;
  margin-bottom: 6px;
}
.input-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-send {
  background: linear-gradient(135deg, #0071e3, #409cff);
  border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition-duration) var(--ease-in-out);
  align-self: flex-end;
  margin-bottom: 6px;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}
.btn-send:hover {
  background: linear-gradient(135deg, #0077ed, #409cff);
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.4);
  transform: translateY(-1px) scale(1.05);
}
.btn-send:active { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.input-hint { text-align: center; color: var(--text-tertiary); font-size: 11px; line-height: 16px; margin-top: 6px; }

/* ========== МОДАЛКИ ========== */
.modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-mask); justify-content: center; align-items: center;
  z-index: 100; -webkit-backdrop-filter: blur(2px); -webkit--webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(40px);
}
.modal.show { display: flex; }

.modal-content {
  background: var(--bg-modal); border: 1px solid var(--border-inverted);
  border-radius: var(--radius-2xl); padding: 24px; width: 440px;
  max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lv3);
  animation: modalIn var(--transition-duration-slow) var(--ease-out);
  box-sizing: border-box; outline: none;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-wide { width: 820px; max-width: 94vw; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 600; line-height: 24px; }

.modal-close {
  background: none; border: none; color: var(--text-tertiary); font-size: 20px;
  cursor: pointer; padding: 6px; border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-duration-fast) var(--ease-in-out);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-content input, .modal-content textarea, .modal-content select {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-l2);
  color: var(--text-primary); padding: 10px 14px; border-radius: 10px;
  font-size: 14px; margin-bottom: 10px; font-family: var(--font-family);
  outline: none; box-sizing: border-box;
  transition: border-color var(--transition-duration-fast) var(--ease-in-out);
}
.modal-content input:focus, .modal-content textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15); }

.btn-primary, .btn-secondary {
  padding: 10px 20px; border-radius: 10px; font-size: 14px; cursor: pointer;
  border: none; font-weight: 500; transition: all var(--transition-duration) var(--ease-in-out);
  font-family: var(--font-family); display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
}
.btn-primary { background: linear-gradient(135deg, #0071e3, #409cff); color: #fff; box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(0, 113, 227, 0.4); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-l2); }
.btn-secondary:hover { background: var(--bg-hover); }

/* ========== ТАРИФЫ ========== */
.tariffs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tariff-card { background: var(--bg-input); border: 1px solid var(--border-l2); border-radius: var(--radius-lg); padding: 20px 16px; text-align: center; transition: all var(--transition-duration) var(--ease-in-out); position: relative; box-sizing: border-box; }
.tariff-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.tariff-card.popular { border-color: var(--accent); background: rgba(0, 113, 227, 0.08); }
.tariff-popular-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 4px 14px; border-radius: var(--radius-round); font-size: 11px; font-weight: 600; }
.tariff-icon { font-size: 28px; margin-bottom: 8px; }
.tariff-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.tariff-card .price { font-size: 28px; font-weight: 800; margin: 8px 0; }
.tariff-card .price.free { color: var(--green); }
.tariff-divider { height: 0.5px; background: var(--border-l2); margin: 10px 0; }
.tariff-features { text-align: left; font-size: 12px; margin-bottom: 12px; }
.tariff-feature { display: flex; align-items: center; gap: 6px; padding: 3px 0; color: var(--text-secondary); }
.tariff-feature i { color: var(--green); }
.tariff-feature.disabled { color: var(--text-tertiary); opacity: 0.5; text-decoration: line-through; }
.tariff-card .btn-primary { min-height: 44px; }

/* ========== КАТЕГОРИИ В МОДАЛКЕ ========== */
.categories-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 55vh; overflow-y: auto; padding: 4px; }
.category-item { background: var(--bg-input); border: 1px solid var(--border-l2); border-radius: var(--radius-md); padding: 14px 10px; cursor: pointer; text-align: center; transition: all var(--transition-duration-fast) var(--ease-in-out); }
.category-item:hover { border-color: var(--accent); background: rgba(0, 113, 227, 0.08); transform: translateY(-2px); }
.category-item .cat-icon { font-size: 22px; display: block; margin-bottom: 4px; }
.category-item .cat-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }

/* ========== ПРОФИЛЬ ========== */
.profile-modal-content { padding: 0; overflow: hidden; }
.profile-modal-header { display: flex; align-items: center; gap: 14px; padding: 24px; border-bottom: 1px solid var(--border-l1); }
.profile-avatar-large { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, #0071e3, #af52de); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; }
.profile-modal-name { font-size: 12px; color: var(--text-secondary); }
.profile-stats { display: flex; padding: 18px; gap: 8px; border-bottom: 0.5px solid var(--border-l1); }
.profile-stat { flex: 1; text-align: center; }
.profile-stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.profile-stat-label { font-size: 12px; color: var(--text-tertiary); }
.profile-menu { padding: 4px 0; }
.profile-menu-item { width: 100%; background: none; border: none; color: var(--text-primary); padding: 15px 24px; font-size: 15px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: all var(--transition-duration-fast) var(--ease-in-out); font-family: var(--font-family); }
.profile-menu-item:hover { background: var(--bg-hover); }
.profile-menu-arrow { color: var(--text-tertiary); font-size: 18px; }

/* ========== ПРОФИЛЬ-МЕНЮ ========== */
.profile-menu-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-mask); justify-content: center; align-items: center; z-index: 200; -webkit-backdrop-filter: blur(2px); -webkit--webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(40px); }
.profile-menu-modal.show { display: flex; }
.profile-menu-content { background: var(--bg-modal); border: 1px solid var(--border-inverted); border-radius: var(--radius-2xl); padding: 8px; width: 300px; box-shadow: var(--shadow-lv3); animation: modalIn var(--transition-duration-slow) var(--ease-out); }
.profile-menu-item-new { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 15px; font-family: var(--font-family); color: var(--text-primary); transition: all var(--transition-duration-fast) var(--ease-in-out); }
.profile-menu-item-new:hover { background: rgba(0, 113, 227, 0.08); }
.profile-menu-item-new.danger { color: var(--red); }
.profile-menu-item-new.danger:hover { background: rgba(255, 59, 48, 0.08); }
.profile-menu-icon-new { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; background: rgba(0, 113, 227, 0.08); color: var(--accent); flex-shrink: 0; }

/* ========== СФЕРЫ ========== */
.sfery-modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 50vh; overflow-y: auto; padding: 4px; }
.sfery-modal-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-l2); background: rgba(255, 255, 255, 0.02); cursor: pointer; transition: all var(--transition-duration-fast) var(--ease-in-out); font-size: 13px; font-weight: 500; color: var(--text-primary); }
.sfery-modal-item:hover { border-color: var(--accent); background: rgba(0, 113, 227, 0.08); transform: translateY(-1px); }
.sfery-modal-item .sf-icon { font-size: 20px; flex-shrink: 0; }
.sfery-modal-category { margin-bottom: 16px; }
.sfery-modal-category h4 { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.sfery-modal-search { width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border-l2); background: rgba(255, 255, 255, 0.04); color: var(--text-primary); font-size: 14px; font-family: var(--font-family); margin-bottom: 16px; outline: none; box-sizing: border-box; }
.sfery-modal-search::placeholder { color: var(--text-caption); }
.sfery-modal-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.08); }

/* ========== ПОДДЕРЖКА ========== */
.support-tab { flex: 1; padding: 10px 12px; border-radius: var(--radius-sm); border: none; background: transparent; color: var(--text-tertiary); font-size: 13px; font-weight: 500; cursor: pointer; transition: all var(--transition-duration-fast) var(--ease-in-out); font-family: var(--font-family); text-align: center; }
.support-tab.active { background: var(--bg-input); color: var(--text-primary); font-weight: 600; }
.support-tab:hover:not(.active) { color: var(--text-primary); }

/* ========== БЕЙДЖИ ========== */
.admin-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.admin-badge.danger { background: rgba(255, 59, 48, 0.1); color: var(--red); }
.admin-badge.success { background: rgba(52, 199, 89, 0.1); color: var(--green); }
.admin-badge.warning { background: rgba(255, 149, 0, 0.1); color: var(--orange); }
.admin-badge.info { background: rgba(0, 113, 227, 0.1); color: var(--accent); }

/* ========== ДОКУМЕНТЫ ========== */
.docs-links { display: flex; flex-direction: column; gap: 4px; }
.doc-link { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: var(--radius-md); color: var(--text-primary); text-decoration: none; font-size: 15px; transition: all var(--transition-duration-fast) var(--ease-in-out); }
.doc-link:hover { background: var(--border-l1); }

/* ========== ЧАТ-ЭКШН ========== */
.chat-action-modal { position: fixed; background: var(--bg-modal); border: 1px solid var(--border-inverted); border-radius: var(--radius-lg); padding: 6px; z-index: 150; box-shadow: var(--shadow-lv3); min-width: 180px; display: none; }
.chat-action-modal.show { display: block; }
.chat-action-item { width: 100%; background: none; border: none; color: var(--text-primary); padding: 11px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; text-align: left; display: flex; align-items: center; gap: 10px; transition: all var(--transition-duration-fast) var(--ease-in-out); font-family: var(--font-family); }
.chat-action-item:hover { background: var(--bg-hover); }
.chat-action-item.danger { color: var(--red); }

/* ========== ЯЗЫКОВАЯ МОДАЛКА ========== */
.lang-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-mask); justify-content: center; align-items: center; z-index: 200; -webkit-backdrop-filter: blur(2px); -webkit--webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(40px); }
.lang-modal.show { display: flex; }
.lang-modal-content { background: var(--bg-modal); border: 1px solid var(--border-inverted); border-radius: var(--radius-2xl); padding: 28px; width: 420px; max-height: 70vh; overflow-y: auto; box-shadow: var(--shadow-lv3); animation: modalIn var(--transition-duration-slow) var(--ease-out); box-sizing: border-box; }
.lang-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.lang-modal-header h3 { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.lang-modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-tertiary); padding: 4px 8px; border-radius: 50%; transition: all var(--transition-duration-fast) var(--ease-in-out); }
.lang-modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.lang-list { display: flex; flex-direction: column; gap: 4px; }
.lang-option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius-md); cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 15px; font-family: var(--font-family); color: var(--text-primary); transition: all var(--transition-duration-fast) var(--ease-in-out); }
.lang-option:hover { background: rgba(0, 113, 227, 0.08); }
.lang-option.active { background: rgba(0, 113, 227, 0.12); font-weight: 600; }
.lang-flag { font-size: 22px; }
.lang-name { flex: 1; }
.lang-check { color: var(--accent); font-weight: 600; font-size: 14px; }

/* ========== TOAST ========== */
.toast { position: fixed; top: 40px; left: 50%; transform: translateX(-50%); background: var(--bg-layer-3); color: #fff; padding: 12px 18px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; line-height: 22px; z-index: 999; opacity: 0; transition: all var(--transition-duration-slow) var(--ease-in-out); pointer-events: none; border: 1px solid var(--border-inverted); box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.04), 0 4px 16px 0 rgba(0, 0, 0, 0.1); }

/* ========== TOOLTIP ========== */
.tooltip { display: none; position: fixed; background: #3a3a3c; color: #f5f5f7; padding: 6px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; line-height: 1.5; z-index: 200; pointer-events: none; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); border: 1px solid var(--border-inverted); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.tooltip.show { display: block; }

/* ========== БАННЕРЫ ========== */
.offline-banner { display: none; position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; padding: 8px; z-index: 300; font-size: 13px; font-weight: 500; }
.offline-banner.show { display: block; }
.update-banner { position: fixed; bottom: 20px; left: 20px; right: 20px; background: var(--bg-modal); border: 0.5px solid var(--accent); border-radius: var(--radius-lg); padding: 12px 20px; display: none; justify-content: space-between; align-items: center; z-index: 1000; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); font-size: 14px; gap: 12px; flex-wrap: wrap; -webkit-backdrop-filter: blur(20px); -webkit--webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(40px); }
.update-banner.show { display: flex; }
.update-banner button { background: var(--accent); color: #fff; border: none; padding: 8px 20px; border-radius: 30px; cursor: pointer; font-weight: 600; font-size: 13px; transition: all var(--transition-duration-fast) var(--ease-in-out); white-space: nowrap; font-family: var(--font-family); }
.update-banner button:hover { background: var(--accent-hover); transform: scale(1.02); }

/* ========== COOKIE ========== */
.cookie-banner { position: fixed; bottom: 20px; left: 20px; right: 20px; background: var(--bg-modal); border: 1px solid var(--border-l1); border-radius: var(--radius-lg); padding: 16px 20px; z-index: 1000; display: none; justify-content: space-between; align-items: center; gap: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); font-size: 14px; flex-wrap: wrap; }
.cookie-banner.show { display: flex; }
.cookie-banner a { color: var(--accent); text-decoration: underline; }
.cookie-banner .btn-primary { white-space: nowrap; }

/* ========== ПОДСВЕТКА СИНТАКСИСА ========== */
.message-content pre code.hljs { color: #e3eaf2; background: transparent; }
.message-content .hljs-comment, .message-content .hljs-quote { color: #8da1b9; }
.message-content .hljs-keyword, .message-content .hljs-selector-tag, .message-content .hljs-addition { color: #e9ae7e; }
.message-content .hljs-string, .message-content .hljs-doctag, .message-content .hljs-regexp, .message-content .hljs-meta .hljs-string { color: #91d076; }
.message-content .hljs-number, .message-content .hljs-literal, .message-content .hljs-variable, .message-content .hljs-template-variable, .message-content .hljs-tag .hljs-attr { color: #e6d37a; }
.message-content .hljs-title, .message-content .hljs-attr, .message-content .hljs-params, .message-content .hljs-built_in, .message-content .hljs-type { color: #6cb8e6; }
.message-content .hljs-symbol, .message-content .hljs-bullet, .message-content .hljs-link, .message-content .hljs-meta, .message-content .hljs-selector-id, .message-content .hljs-selector-class { color: #f4adf4; }
.message-content .hljs-deletion, .message-content .hljs-strong { color: #cd6660; }
.message-content .hljs-emphasis { font-style: italic; }
.message-content .hljs-strong { font-weight: 700; }

/* ========== МОБИЛЬНАЯ НАВИГАЦИЯ ========== */
.mobile-nav { display: none !important; }

/* ========== АДАПТИВ ========== */
@media (max-width: 1024px) {
  :root { --message-max-width: 712px; --message-padding-horizontal: 36px; }
  .input-area { margin: auto 16px 0; }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -100%; top: 0; height: 100vh; height: 100dvh; width: var(--sider-width); max-width: 100vw; transition: left var(--transition-duration-slow) var(--ease-in-out); z-index: 1000; border-radius: 0; border: none; }
  .sidebar.open { left: 0; z-index: 50; }
  .sidebar-overlay.active { display: block; }
  .btn-toggle-sidebar { display: flex; }
  .btn-collapse-sidebar { display: none; }
  :root { --message-padding-horizontal: 24px; }
  .header { padding: 0 20px; }
  .header-left { gap: 4px; }
  .input-area { 
    margin: auto 16px 0; 
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)); 
    background: var(--bg-base);
  }
  .messages { padding-bottom: 0; }
  
  /* Кнопка Новый чат в шапке */
  .btn-new-chat-header { display: flex; }
  
  /* Горизонтальный скролл категорий */
  .premium-categories {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 0 16px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-padding: 0 16px;
  }
  .premium-cat-card { 
    flex-shrink: 0; 
    width: 160px; 
    min-height: 52px; 
    padding: 10px; 
    gap: 6px; 
  }
  .premium-cat-card .premium-cat-icon { width: 24px; height: 24px; font-size: 16px; }
  .premium-cat-card .premium-cat-name { font-size: 12px; }
  .premium-cat-card .premium-cat-desc { font-size: 10px; }
  .premium-cat-card:last-child { margin-right: 16px; }
  .trending-questions { display: block; padding: 0 16px; }
  
  .welcome-title { font-size: 20px; line-height: 28px; }
  .message.user .message-content { max-width: calc(100% - 68px); }
  .modal-content { width: 94vw; padding: 22px; }
  .modal-wide { width: 96vw; }
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
  .tariffs-grid { grid-template-columns: 1fr 1fr; }
  .online-header { display: none; }
  .chat-subtitle { display: none; }
  .btn-login-header { display: none; }
  
  /* Скрыть OpaGPT на мобильных */
  .chat-title { display: none; }
  
  /* Убрать логотип в сайдбаре */
  .sidebar .logo img { display: none; }
  
  /* Убрать счётчик запросов */
  .requests-counter { display: none !important; }
  
  /* Убрать "Сгенерировано ИИ" */
  .input-hint { display: none; }
  
  /* Увеличить поле ввода */
  .input-wrapper { padding: 16px 14px; }
  .input-wrapper textarea { min-height: 48px; font-size: 16px; }
  
  /* Показать кнопку-сэндвич в сайдбаре */
  .sidebar-close-btn { display: flex; }
}

@media (max-width: 480px) {
  .header { padding: 0 14px; }
  .header-left, .header-right { gap: 6px; }
  .messages { padding: 12px 0; }
  .welcome-title { font-size: 18px; line-height: 26px; }
  :root { --message-padding-horizontal: 16px; }
  .input-area { margin: auto 8px 0; padding-bottom: max(14px, env(safe-area-inset-bottom, 14px)); }
  .input-wrapper { padding: 12px 14px; }
  .input-wrapper textarea { font-size: 16px; }
  .input-action-btn { width: 28px; height: 28px; padding: 4px; }
  .btn-send { width: 28px; height: 28px; }
  .modal-content { padding: 18px; width: 96vw; max-height: 75vh; border-radius: var(--radius-2xl) var(--radius-2xl) 0 0; }
  .modal-header h2 { font-size: 18px; }
  .modal-close { width: 40px; height: 40px; font-size: 24px; }
  .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .category-item { padding: 10px 8px; }
  .category-item .cat-icon { font-size: 18px; }
  .category-item .cat-name { font-size: 11px; }
  .tariffs-grid { grid-template-columns: 1fr; gap: 8px; }
  .tariff-card { padding: 12px 10px; }
  .tariff-card h3 { font-size: 14px; }
  .tariff-card .price { font-size: 20px; }
  .tariff-icon { font-size: 22px; margin-bottom: 4px; }
  .tariff-features { font-size: 11px; }
  .tariff-feature { padding: 2px 0; }
  .tariff-divider { margin: 6px 0; }
  .profile-stat-value { font-size: 20px; }
  .btn-primary, .btn-secondary { min-height: 44px; padding: 12px 20px; font-size: 14px; }
  .update-banner { flex-direction: column; text-align: center; }
  .update-banner button { width: 100%; }
  .tariff-badge { font-size: 10px; padding: 4px 10px; }
  .requests-counter { font-size: 11px; padding: 3px 10px; }
  .sfery-modal-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 375px) {
  .welcome-title { font-size: 20px; }
  .btn-header { width: 28px; height: 28px; }
  .input-wrapper textarea { font-size: 16px; }
  .modal-content { padding: 14px; }
  .messages { padding: 8px 0; }
  .input-area { margin: auto 6px 0; padding-bottom: max(10px, env(safe-area-inset-bottom, 10px)); }
}

@supports (-webkit-touch-callout: none) {
  .input-area { position: sticky; bottom: 0; }
  .messages { padding-bottom: 0; }
}

/* ==================== ЗАКРЕПЛЁННЫЙ ЧАТ ==================== */
.chat-item.pinned {
  background: rgba(0, 113, 227, 0.06);
  border-left: 3px solid var(--accent);
  padding-left: 7px;
  border-radius: var(--radius-sm) var(--radius-md) var(--radius-md) var(--radius-sm);
}
.chat-item.pinned:hover { background: rgba(0, 113, 227, 0.12); }
.chat-item.pinned::before { content: '📌'; position: absolute; left: -16px; top: 50%; transform: translateY(-50%); font-size: 11px; opacity: 0.7; pointer-events: none; }
.chat-item.pinned.active { background: var(--bg-chat-active); border-left-color: var(--accent); }
[data-theme="light"] .chat-item.pinned { background: rgba(0, 113, 227, 0.06); }
[data-theme="light"] .chat-item.pinned:hover { background: rgba(0, 113, 227, 0.12); }

/* ==================== МОДАЛКА УДАЛЕНИЯ / ПЕРЕИМЕНОВАНИЯ ==================== */
.admin-confirm-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-mask); display: flex; justify-content: center; align-items: center;
  z-index: 300; -webkit-backdrop-filter: blur(4px); -webkit--webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(40px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.admin-confirm-dialog {
  background: var(--bg-modal); border: 1px solid var(--border-inverted);
  border-radius: var(--radius-2xl); padding: 28px 24px; width: 380px; max-width: 90vw;
  box-shadow: var(--shadow-lv3); text-align: center;
  animation: modalIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.admin-confirm-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.admin-confirm-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.5; }
.admin-confirm-actions { display: flex; gap: 8px; }
.admin-confirm-actions .admin-btn { flex: 1; padding: 12px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font-family); border: none; transition: all var(--transition-duration-fast) var(--ease-in-out); }
.admin-btn { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-l2); }
.admin-btn:hover { background: var(--bg-hover); }
.admin-btn.primary { background: var(--accent); color: #fff; border: none; }
.admin-btn.primary:hover { background: var(--accent-hover); }
.admin-btn.danger { background: var(--red); color: #fff; border: none; }
.admin-btn.danger:hover { background: #dc2626; }

/* ==================== МОДАЛКА ДЕЙСТВИЙ С ЧАТОМ (⋮) ==================== */
.chat-action-modal.show { display: block; }

/* ==================== ПОЛЕ ВВОДА В МОДАЛКЕ ==================== */
.modal-input { width: 100%; background: var(--bg-input); border: 1px solid var(--border-l2); color: var(--text-primary); padding: 12px 16px; border-radius: var(--radius-md); font-size: 15px; font-family: var(--font-family); outline: none; margin-bottom: 20px; box-sizing: border-box; transition: border-color var(--transition-duration-fast) var(--ease-in-out); }
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15); }
.modal-textarea { width: 100%; background: var(--bg-input); border: 1px solid var(--border-l2); color: var(--text-primary); padding: 12px 16px; border-radius: var(--radius-md); font-size: 15px; font-family: var(--font-family); outline: none; resize: vertical; box-sizing: border-box; transition: border-color var(--transition-duration-fast) var(--ease-in-out); }
.modal-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15); }

/* ==================== ПУСТОЙ ЧАТ ==================== */
.chat-empty { text-align: center; color: var(--text-secondary); padding: 60px 20px; font-size: 15px; }

/* ==================== КНОПКА ОЗВУЧКИ В СООБЩЕНИИ ==================== */
.btn-speak-msg { position: absolute; top: 4px; right: 4px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--text-secondary); padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; z-index: 5; transition: all var(--transition-duration-fast) var(--ease-in-out); opacity: 0; }
.message.assistant:hover .btn-speak-msg { opacity: 1; }
.btn-speak-msg:hover { background: rgba(255, 255, 255, 0.12); color: var(--text-primary); }
.btn-speak-msg.speaking { color: var(--accent); background: rgba(0, 113, 227, 0.15); animation: speakPulse 1s ease-in-out infinite; }
@keyframes speakPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(0, 113, 227, 0); } }

/* ==================== ИНЛАЙН РЕДАКТИРОВАНИЕ ==================== */
.inline-edit-textarea { width: 100%; background: var(--bg-input); border: 1px solid var(--accent); color: var(--text-primary); padding: 12px 16px; border-radius: var(--radius-lg); font-size: 15px; font-family: var(--font-family); outline: none; resize: none; box-sizing: border-box; margin-top: 8px; }
.inline-edit-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.btn-inline-cancel, .btn-inline-save { padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font-family); border: none; transition: all var(--transition-duration-fast) var(--ease-in-out); }
.btn-inline-cancel { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-l2); }
.btn-inline-cancel:hover { background: var(--bg-hover); }
.btn-inline-save { background: var(--accent); color: #fff; }
.btn-inline-save:hover { background: var(--accent-hover); }

/* ========== МОДАЛКА ПОДЕЛИТЬСЯ ========== */
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.share-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px 8px; border-radius: var(--radius-lg); border: none; background: var(--share-bg, var(--bg-input)); color: #fff; cursor: pointer; font-size: 12px; font-weight: 600; font-family: var(--font-family); min-height: 80px; transition: all 0.2s ease; }
.share-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.3); filter: brightness(1.15); }
.share-btn:active { transform: scale(0.95); }
.share-icon-svg { width: 28px; height: 28px; stroke-width: 1.5; }
.share-btn[data-platform="copy"] { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-l2); }
.share-btn[data-platform="copy"]:hover { background: var(--bg-hover); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
@media (max-width: 480px) { .share-grid { gap: 8px; } .share-btn { padding: 12px 6px; font-size: 11px; min-height: 70px; } .share-icon-svg { width: 24px; height: 24px; } }

@media print { .sidebar, .header, .input-area, .btn-new-chat-fab, .mobile-nav, .sidebar-overlay { display: none !important; } .messages { overflow: visible; height: auto; max-height: none; } body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; overflow: visible; height: auto; } }

/* ========== КОНФЕТТИ ========== */
.confetti-particle { position: fixed; pointer-events: none; z-index: 9999; opacity: 1; animation: confettiFall var(--duration, 3s) cubic-bezier(0.22, 0.61, 0.36, 1) forwards; }
@keyframes confettiFall { 0% { transform: translate(0, 0) rotate(0deg); opacity: 1; } 100% { transform: translate(var(--drift, 0px), 100vh) rotate(var(--rotation, 360deg)); opacity: 0; } }

/* ========== ЧАСТИЦЫ ОТПРАВКИ ========== */
.send-particle { position: fixed; pointer-events: none; z-index: 999; border-radius: 50%; opacity: 1; animation: particleBurst 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) forwards; }
@keyframes particleBurst { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(0); opacity: 0; } }

/* ===== ИКОНКИ ПОД СООБЩЕНИЕМ ===== */
.message-actions { display: flex; gap: 4px; margin-top: 8px; opacity: 1; }
.message.user .message-actions { justify-content: flex-end; }
.message.assistant .message-actions { justify-content: flex-start; }

.msg-action-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: transparent; border: none; color: var(--text-secondary); cursor: pointer; transition: all 0.2s ease; }
.msg-action-btn:hover { background: var(--bg-hover); color: var(--accent); }
.msg-action-btn::after { content: attr(data-tooltip); position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%) scale(0.8); padding: 6px 12px; background: var(--tooltip-bg, rgba(0,0,0,0.85)); color: #fff; font-size: 12px; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; white-space: nowrap; border-radius: 12px; pointer-events: none; opacity: 0; transition: all 0.2s cubic-bezier(0.22, 0.61, 0.36, 1); z-index: 100; }
.msg-action-btn:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }
[data-theme="dark"] .msg-action-btn::after { --tooltip-bg: rgba(255,255,255,0.9); color: #000; }

/* ========== БЛОК КОДА С ШАПКОЙ ========== */
.code-block-wrapper { margin: 16px 0; border-radius: var(--radius-md); border: 1px solid var(--border-l1); overflow: hidden; background: var(--bg-card); }
.code-block-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: rgba(255,255,255,0.04); border-bottom: 1px solid var(--border-l1); font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.code-block-header-left { display: flex; align-items: center; gap: 8px; }
.code-block-header-actions { display: flex; gap: 4px; }
.code-block-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; border: none; background: transparent; color: var(--text-tertiary); cursor: pointer; transition: all 0.15s ease; }
.code-block-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.code-block-btn.copied { color: var(--green); }
.code-block-content { padding: 0; }
.code-block-content pre { margin: 0 !important; border: none !important; border-radius: 0 !important; background: transparent !important; }

.input-mic-btn.listening { animation: micPulse 1.2s ease-in-out infinite; color: var(--red) !important; background: rgba(255, 59, 48, 0.1) !important; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); } 50% { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); } }
[data-theme="cyberpunk"] {
  --bg-base: #0a0a12;
  --bg-sidebar: rgba(10, 10, 18, 0.9);
  --bg-layer-2: #12121f;
  --bg-layer-3: #1a1a2e;
  --bg-input: #1a1a2e;
  --bg-bubble: #ff00ff33;
  --bg-chat-active: rgba(0, 240, 255, 0.1);
  --bg-card: #12121f;
  --bg-modal: #12121f;
  --bg-hover: rgba(157, 0, 255, 0.08);
  --bg-mask: rgba(0, 0, 0, 0.7);
  --text-primary: #e0e0ff;
  --text-secondary: #8888aa;
  --text-tertiary: #6666aa;
  --text-caption: #5555aa;
  --border-l1: rgba(157, 0, 255, 0.2);
  --border-l2: rgba(0, 240, 255, 0.3);
  --border-l2-thin: rgba(157, 0, 255, 0.15);
  --border-l3: rgba(255, 0, 255, 0.4);
  --border-inverted: rgba(157, 0, 255, 0.08);
  --accent: #ff00ff;
  --accent-hover: #ff44ff;
  --accent-text: #ff00ff;
  --scroll-color: rgba(157, 0, 255, 0.3);
  --scroll-color-hover: rgba(0, 240, 255, 0.5);
}

[data-theme="midnight"] {
  --bg-base: #0a1628;
  --bg-sidebar: rgba(10, 22, 40, 0.9);
  --bg-layer-2: #142437;
  --bg-layer-3: #1a3050;
  --bg-input: #0d1f35;
  --bg-bubble: #1a3050;
  --bg-chat-active: rgba(77, 166, 255, 0.1);
  --bg-card: #142437;
  --bg-modal: #142437;
  --bg-hover: rgba(77, 166, 255, 0.08);
  --bg-mask: rgba(0, 0, 0, 0.6);
  --text-primary: #e3ecff;
  --text-secondary: #7a8fbf;
  --text-tertiary: #5a6f9f;
  --text-caption: #4a5a7a;
  --border-l1: rgba(100, 140, 200, 0.1);
  --border-l2: rgba(100, 140, 200, 0.2);
  --border-l2-thin: rgba(100, 140, 200, 0.1);
  --border-l3: rgba(100, 140, 200, 0.3);
  --border-inverted: rgba(100, 140, 200, 0.08);
  --accent: #4da6ff;
  --accent-hover: #6db9ff;
  --accent-text: #4da6ff;
  --scroll-color: rgba(100, 140, 200, 0.2);
  --scroll-color-hover: rgba(100, 140, 200, 0.4);
}

