/* ============================================
   ИИ ДЛЯ ЖЕНЩИН — Главный стиль
   Пастельная, женственная, уютная тема
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

/* ============================================
   CSS ПЕРЕМЕННЫЕ
   ============================================ */
:root {
  --cream: #FDF8F4;
  --beige: #FAF0E6;
  --beige-dark: #F5E6D3;
  --pink: #F4B8C1;
  --pink-dark: #E8A0AA;
  --pink-light: #FDE8EC;
  --lavender: #C5B8E8;
  --lavender-light: #EDE8FA;
  --mint: #B8E0D2;
  --mint-light: #E8F7F2;
  --peach: #FDDCB5;
  --peach-light: #FFF3E0;
  --chocolate: #3D2B1F;
  --brown: #8B7355;
  --brown-light: #BFA98A;
  --white: #FFFFFF;
  --shadow: rgba(61, 43, 31, 0.08);
  --shadow-md: rgba(61, 43, 31, 0.15);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 28px;
  --transition: 0.25s ease;
}

/* ============================================
   СБРОС И БАЗА
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--cream);
  color: var(--chocolate);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  line-height: 1.3;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  border: none;
  outline: none;
  transition: all var(--transition);
}

/* ============================================
   ШАПКА (HEADER)
   ============================================ */
.header {
  background: rgba(253, 248, 244, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--beige-dark);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 24px;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--chocolate);
}

.logo-emoji {
  font-size: 28px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-text span:first-child {
  font-size: 16px;
  color: var(--pink-dark);
}

.logo-text span:last-child {
  font-size: 11px;
  color: var(--brown);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Баланс монет в шапке */
.balance-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--peach-light);
  border: 2px solid var(--peach);
  border-radius: 50px;
  padding: 6px 14px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--chocolate);
  cursor: pointer;
  transition: all var(--transition);
}

.balance-badge:hover {
  background: var(--peach);
  transform: translateY(-1px);
}

.balance-badge .coin-icon {
  font-size: 18px;
  filter: sepia(1) saturate(6) hue-rotate(5deg) brightness(1.05);
}

/* Кнопка Навигатора книги */
.btn-book-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #4CAF50;
  border: 2px solid #388E3C;
  color: #fff;
  border-radius: 50px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.35);
}

.btn-book-nav:hover {
  background: #43A047;
  border-color: #2E7D32;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.45);
}

/* Аватар пользователя */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pink-light);
  border: 2px solid var(--pink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition);
}

.user-avatar:hover {
  border-color: var(--pink-dark);
  transform: scale(1.05);
}

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

/* Кнопка входа */
.btn-login {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
  color: var(--chocolate);
  border-radius: 50px;
  padding: 10px 20px;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(244, 184, 193, 0.4);
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(244, 184, 193, 0.5);
}

/* ============================================
   БОКОВОЕ МЕНЮ — НАВИГАТОР ПО КНИГЕ
   ============================================ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, 0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.sidebar {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  max-width: 95vw;
  height: 100vh;
  background: var(--white);
  z-index: 201;
  overflow-y: auto;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px var(--shadow-md);
}

.sidebar.active {
  right: 0;
}

.sidebar-header {
  background: linear-gradient(135deg, var(--lavender-light), var(--pink-light));
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--beige-dark);
  position: sticky;
  top: 0;
}

.sidebar-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--white);
  border: none;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-close:hover {
  background: var(--pink-light);
  transform: rotate(90deg);
}

.sidebar-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--chocolate);
  margin-bottom: 6px;
}

.sidebar-subtitle {
  font-size: 13px;
  color: var(--brown);
}

.sidebar-content {
  padding: 16px;
}

.chapter-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 4px;
}

.chapter-item:hover {
  background: var(--lavender-light);
}

.chapter-num {
  min-width: 28px;
  height: 28px;
  background: var(--lavender);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--chocolate);
  margin-top: 2px;
}

.chapter-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--chocolate);
  line-height: 1.4;
}

.chapter-hub {
  font-size: 12px;
  color: var(--brown);
  margin-top: 2px;
}

/* ============================================
   ГЛАВНАЯ СТРАНИЦА — ГЕРОЙ
   ============================================ */
.hero {
  text-align: center;
  padding: 48px 24px 32px;
  background: linear-gradient(180deg, var(--pink-light) 0%, var(--cream) 100%);
}

.hero-emoji {
  font-size: 56px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hero-title {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 800;
  color: var(--chocolate);
  margin-bottom: 12px;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.hero-title span {
  color: var(--pink-dark);
}

.hero-subtitle {
  font-size: clamp(15px, 2.5vw, 18px);
  color: var(--brown);
  max-width: 520px;
  margin: 0 auto 24px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.hero-badge {
  background: var(--white);
  border: 1px solid var(--beige-dark);
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brown);
}

/* ============================================
   СЕТКА ХАБОВ (8 КАРТОЧЕК)
   ============================================ */
.hubs-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

.hubs-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--chocolate);
  margin-bottom: 24px;
}

.hubs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

/* Карточка хаба */
.hub-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow);
}

.hub-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.hub-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px var(--shadow-md);
}

.hub-card:hover::before {
  opacity: 1;
}

.hub-card:active {
  transform: translateY(-2px);
}

/* Цвета карточек */
.hub-card.psycho  { --card-color: #F4B8C1; --card-bg: #FDE8EC; }
.hub-card.chef    { --card-color: #FDDCB5; --card-bg: #FFF3E0; }
.hub-card.beauty  { --card-color: #C5B8E8; --card-bg: #EDE8FA; }
.hub-card.homework{ --card-color: #B8E0D2; --card-bg: #E8F7F2; }
.hub-card.holiday { --card-color: #F4B8C1; --card-bg: #FDE8EC; }
.hub-card.lawyer  { --card-color: #FDDCB5; --card-bg: #FFF3E0; }
.hub-card.designer { --card-color: #B8E0D2; --card-bg: #E8F7F2; }
.hub-card.detector { --card-color: #C5B8E8; --card-bg: #EDE8FA; }
.hub-card.universal{ --card-color: #F9C6D0; --card-bg: #FFF0F3; }
.hub-card.imagegen { --card-color: #FFD580; --card-bg: #FFFBF0; } /* золотистый — творчество */

.hub-card:hover {
  border-color: var(--card-color);
  background: var(--card-bg);
}

.hub-icon {
  font-size: 44px;
  margin-bottom: 14px;
  display: block;
}

.hub-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--chocolate);
  margin-bottom: 8px;
}

.hub-desc {
  font-size: 14px;
  color: var(--brown);
  line-height: 1.5;
  margin-bottom: 16px;
}

.hub-presets-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.hub-preset-tag {
  background: var(--cream);
  border: 1px solid var(--beige-dark);
  border-radius: 50px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--brown);
  transition: all var(--transition);
}

.hub-card:hover .hub-preset-tag {
  background: rgba(255,255,255,0.7);
  border-color: var(--card-color);
}

.hub-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  background: var(--card-color, var(--pink));
  color: var(--chocolate);
  transition: all var(--transition);
  box-shadow: 0 4px 12px var(--shadow);
}

.hub-btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 16px var(--shadow-md);
}

/* Строка кнопка + краткая подсказка (видна только на планшете/мобиле) */
.hub-btn-row {
  display: block;
}
.hub-short-hint {
  display: none;
}

/* VIP замок */
.vip-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: linear-gradient(135deg, #C5B8E8, #A89DD4);
  color: white;
  border-radius: 50px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hub-card.vip-locked {
  position: relative;
}

.hub-card.vip-locked .hub-btn {
  background: linear-gradient(135deg, #C5B8E8, #A89DD4);
  color: white;
}

/* ============================================
   ОКНО ПОКУПКИ МОНЕТ (МОДАЛЬНОЕ)
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, 0.5);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  max-width: 480px;
  width: 100%;
  position: relative;
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin: auto;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--beige-dark);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--brown);
  text-align: center;
  margin-bottom: 24px;
}

/* Пакеты монет */
.packages-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.package-card {
  border: 2px solid var(--beige-dark);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.package-card:hover {
  border-color: var(--pink);
  background: var(--pink-light);
  transform: translateY(-2px);
}

.package-card.popular {
  border-color: var(--pink);
  background: var(--pink-light);
}

.package-popular-label {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--pink-dark);
  color: var(--chocolate);
  font-size: 11px;
  font-weight: 700;
  border-radius: 50px;
  padding: 2px 10px;
  white-space: nowrap;
}

.package-coins {
  font-size: 22px;
  font-weight: 800;
  color: var(--chocolate);
  margin-bottom: 4px;
}

.package-label {
  font-size: 12px;
  color: var(--brown);
  margin-bottom: 8px;
}

.package-price {
  font-size: 20px;
  font-weight: 800;
  color: var(--pink-dark);
}

/* SOS блок */
.sos-block {
  background: linear-gradient(135deg, var(--peach-light), var(--pink-light));
  border: 2px solid var(--peach);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.sos-block h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.sos-block p {
  font-size: 13px;
  color: var(--brown);
  margin-bottom: 12px;
}

.btn-sos {
  background: linear-gradient(135deg, var(--peach), var(--pink));
  color: var(--chocolate);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  width: 100%;
}

/* ============================================
   СТРАНИЦА АВТОРИЗАЦИИ
   ============================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--pink-light) 0%, var(--lavender-light) 50%, var(--mint-light) 100%);
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px var(--shadow-md);
  text-align: center;
}

.auth-logo {
  font-size: 52px;
  margin-bottom: 16px;
}

.auth-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--chocolate);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--brown);
  margin-bottom: 32px;
  line-height: 1.5;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--brown-light);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--beige-dark);
}

/* OAuth кнопки */
.btn-oauth {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  transition: all var(--transition);
  text-align: left;
  color: var(--chocolate);
}

.btn-oauth:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--shadow);
}

.btn-yandex {
  background: #FFD54F;
  border: 2px solid #FFC107;
}

.btn-yandex:hover {
  box-shadow: 0 8px 20px rgba(255, 213, 79, 0.4);
}

.btn-vk {
  background: #5181B8;
  color: white;
  border: 2px solid #4B76AB;
}

.btn-vk:hover {
  box-shadow: 0 8px 20px rgba(81, 129, 184, 0.4);
}

.btn-oauth-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(255,255,255,0.3);
}

/* Email OTP форма */
.email-form {
  text-align: left;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--chocolate);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--beige-dark);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  color: var(--chocolate);
  background: var(--cream);
  transition: all var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--pink);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(244, 184, 193, 0.2);
}

.otp-input {
  letter-spacing: 12px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  font-family: 'Nunito', sans-serif;
}

.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
  color: var(--chocolate);
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-weight: 700;
  margin-top: 12px;
  box-shadow: 0 4px 16px rgba(244, 184, 193, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(244, 184, 193, 0.5);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Бонус-блок на странице авторизации */
.bonus-block {
  background: linear-gradient(135deg, var(--peach-light), var(--pink-light));
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--chocolate);
  text-align: center;
}

.bonus-block strong {
  font-size: 17px;
  display: block;
  margin-bottom: 4px;
}

/* ============================================
   ЧАТ-ОВЕРЛЕЙ (накладывается поверх главной)
   ============================================ */
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--cream);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-overlay.active {
  transform: translateX(0);
}

/* ============================================
   СТРАНИЦА ЧАТА
   ============================================ */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* iOS: динамическая высота учитывает системные панели */
  overflow: hidden;
}

.chat-header {
  background: var(--white);
  border-bottom: 1px solid var(--beige-dark);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  border: 2px solid var(--pink-dark);
  font-size: 22px;
  font-weight: 700;
  color: var(--chocolate);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 3px 10px rgba(244, 184, 193, 0.5);
  flex-shrink: 0;
}

.chat-back:hover {
  background: linear-gradient(135deg, var(--pink-dark), #d9828f);
  transform: scale(1.08);
  box-shadow: 0 5px 14px rgba(244, 184, 193, 0.7);
}

.chat-back:active {
  transform: scale(0.96);
}

.chat-hub-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-hub-emoji {
  font-size: 28px;
}

.chat-hub-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--chocolate);
}

.chat-hub-desc {
  font-size: 12px;
  color: var(--brown);
}

/* Горизонтальный скролл пресетов (Магические кнопки) */
.presets-bar {
  background: var(--white);
  border-bottom: 1px solid var(--beige-dark);
  padding: 10px 16px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  flex-shrink: 0;
}

.presets-bar::-webkit-scrollbar { display: none; }

.presets-label {
  display: inline-block;
  font-size: 12px;
  color: var(--brown);
  font-weight: 600;
  margin-right: 8px;
  vertical-align: middle;
}

.preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border: 1.5px solid var(--beige-dark);
  border-radius: 50px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--chocolate);
  margin-right: 8px;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}

.preset-btn:hover {
  background: var(--pink-light);
  border-color: var(--pink);
  transform: translateY(-1px);
}

.preset-btn:active {
  transform: translateY(0);
}

/* Область сообщений */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--beige-dark);
  border-radius: 4px;
}

/* Сообщения */
.message {
  max-width: 80%;
  animation: messageIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
  color: var(--chocolate);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--white);
  color: var(--chocolate);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px var(--shadow);
}

.message-time {
  font-size: 11px;
  color: var(--brown-light);
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time {
  text-align: right;
}

/* Изображение в сообщении */
.message-image {
  max-width: 240px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: transform var(--transition);
}

.message-image:hover {
  transform: scale(1.02);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 16px;
  background: var(--white);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 2px 8px var(--shadow);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--brown-light);
  border-radius: 50%;
  animation: typing 1.2s ease-in-out infinite;
}

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

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

/* Виральный блок после ответа */
.viral-block {
  margin: 8px 0;
  background: linear-gradient(135deg, var(--peach-light), var(--pink-light));
  border: 2px solid var(--pink);
  border-radius: var(--radius);
  padding: 16px;
  animation: messageIn 0.4s ease;
}

.viral-block h4 {
  font-size: 15px;
  color: var(--chocolate);
  margin-bottom: 8px;
}

.viral-block p {
  font-size: 13px;
  color: var(--brown);
  margin-bottom: 12px;
  line-height: 1.5;
}

.viral-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-share {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  transition: all var(--transition);
  color: var(--chocolate);
}

.btn-share.vk {
  background: #5181B8;
  color: white;
}

.btn-share.vk:hover {
  background: #4B76AB;
  transform: translateY(-1px);
}

.btn-share.copy {
  background: var(--peach);
}

.btn-share.copy:hover {
  background: var(--peach-light);
  border: 1px solid var(--peach);
}

/* Область ввода */
.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--beige-dark);
  padding: 12px 16px;
  /* iOS: отступ от системной панели Home Indicator / клавиатуры */
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}

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

.chat-input-wrapper {
  flex: 1;
  background: var(--cream);
  border: 2px solid var(--beige-dark);
  border-radius: 24px;
  padding: 10px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transition: all var(--transition);
}

.chat-input-wrapper:focus-within {
  border-color: var(--pink);
  background: var(--white);
}

.chat-textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  color: var(--chocolate);
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.5;
}

.chat-textarea::placeholder {
  color: var(--brown-light);
}

.btn-attach {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: all var(--transition);
  cursor: pointer;
}

.btn-attach:hover {
  opacity: 1;
  background: var(--pink-light);
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: var(--chocolate);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(244, 184, 193, 0.4);
  flex-shrink: 0;
  transition: all var(--transition);
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(244, 184, 193, 0.5);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Стоимость операции */
.cost-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--brown-light);
  margin-top: 6px;
  padding: 0 4px;
}

/* Превью загруженного фото */
.image-preview {
  position: relative;
  margin: 8px 0;
  display: inline-block;
}

.image-preview img {
  max-height: 120px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--pink);
}

.image-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  background: var(--chocolate);
  color: white;
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
}

/* Аудио-плеер для песни */
.song-player {
  background: linear-gradient(135deg, var(--pink-light), var(--lavender-light));
  border: 2px solid var(--pink);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}

.song-player h4 {
  font-size: 15px;
  margin-bottom: 8px;
}

.song-player audio {
  width: 100%;
  margin-bottom: 10px;
}

/* Дизайн До/После */
.before-after {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.before-after-item {
  text-align: center;
}

.before-after-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--brown);
  margin-bottom: 4px;
}

.before-after img {
  border-radius: var(--radius-sm);
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* Кнопка копирования текста */
.btn-copy-result {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 2px solid var(--beige-dark);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--brown);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}

.btn-copy-result:hover {
  border-color: var(--pink);
  color: var(--chocolate);
  background: var(--pink-light);
}

/* ============================================
   УВЕДОМЛЕНИЯ (TOAST)
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--chocolate);
  color: var(--white);
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 320px;
  text-align: center;
}

.toast.success {
  background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.toast.error {
  background: linear-gradient(135deg, #EF5350, #C62828);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   MARKDOWN В ОТВЕТАХ ИИ
   ============================================ */
.ai-response {
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-response strong { font-weight: 700; }
.ai-response em { font-style: italic; }

.ai-response ul, .ai-response ol {
  padding-left: 20px;
  margin: 8px 0;
}

.ai-response li {
  margin-bottom: 4px;
}

.ai-response h3 {
  font-size: 16px;
  margin: 12px 0 6px;
}

/* ============================================
   ЗАГРУЗКА / SPINNER
   ============================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--pink-light);
  border-top-color: var(--pink-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

/* Полноэкранная загрузка */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 500;
}

.loading-screen .spinner {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */
@media (max-width: 768px) {
  .header {
    padding: 10px 16px;
  }

  /* Скрываем весь логотип на мобильных — освобождаем место */
  .logo {
    display: none;
  }

  .logo-text {
    display: none;
  }

  /* Кнопки начинаются с левого края */
  .header-inner {
    justify-content: flex-start;
  }

  .header-actions {
    gap: 8px;
  }

  /* Кнопка «Мои разговоры» — только иконка на мобильных */
  .clear-btn-long {
    display: none;
  }
  .clear-btn-short {
    display: inline;
  }

  .btn-book-nav span {
    display: none;
  }

  .hero {
    padding: 32px 16px 24px;
  }

  .hubs-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .hub-card {
    padding: 16px 14px;
  }

  .hub-icon {
    font-size: 32px;
    margin-bottom: 8px;
  }

  .hub-name {
    font-size: 15px;
  }

  .hub-desc {
    display: none;
  }

  .hub-btn-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .hub-btn-row .hub-btn {
    width: auto;
    flex-shrink: 0;
    padding: 10px 18px;
    font-size: 14px;
  }
  .hub-short-hint {
    display: block;
    font-size: 11px;
    color: var(--brown);
    opacity: 0.75;
    line-height: 1.3;
  }

  .packages-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .modal {
    padding: 20px 16px;
    margin: auto 0;
  }

  .modal-title {
    font-size: 18px;
  }

  .modal-subtitle {
    font-size: 13px;
    margin-bottom: 16px;
  }

  .package-coins {
    font-size: 18px;
  }

  .package-price {
    font-size: 16px;
  }

  .sos-block p {
    font-size: 12px;
  }

  .auth-card {
    padding: 28px 20px;
  }
}

@media (max-width: 480px) {
  .hubs-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hub-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
  }

  .hub-icon {
    font-size: 36px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .hub-content {
    flex: 1;
  }

  .hub-presets-preview {
    display: none;
  }

  .hub-btn {
    width: auto;
    padding: 10px 20px;
  }

  .message {
    max-width: 92%;
  }
}

/* ============================================
   УТИЛИТЫ
   ============================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* Красивый скроллбар на десктопе */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--cream); }
::-webkit-scrollbar-thumb { background: var(--beige-dark); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--brown-light); }

/* ============================================
   iOS FIX: блокировка прокрутки фонового body
   когда открыт хаб-оверлей
   ============================================ */
body.hub-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  /* top устанавливается через JS: -scrollY */
}

/* ============================================
   ШТОРКА ИСТОРИИ СЕССИЙ («Мои разговоры»)
   ============================================ */

/* Кнопка в шапке */
.btn-sessions {
  background: none;
  border: 2px solid var(--lavender);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 16px;
  cursor: pointer;
  color: var(--chocolate);
  transition: all var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.btn-sessions:hover {
  background: var(--lavender-light);
  border-color: #b0a2e0;
}

/* Список сессий внутри шторки */
.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 16px;
}

.sessions-loading,
.sessions-empty {
  text-align: center;
  color: var(--brown);
  padding: 32px 20px;
  font-size: 14px;
  line-height: 1.7;
}

/* Карточка одной сессии */
.session-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--beige-dark);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.session-card:hover {
  background: var(--peach-light);
}

.session-hub-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 3px;
}

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

.session-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--chocolate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.session-name-input {
  font-size: 14px;
  font-weight: 700;
  color: var(--chocolate);
  border: 1.5px solid var(--lavender);
  border-radius: 8px;
  padding: 2px 8px;
  width: 100%;
  background: white;
  outline: none;
  font-family: inherit;
}

.session-meta {
  font-size: 12px;
  color: var(--brown);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.session-hub-label {
  background: var(--lavender-light);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  color: #5a4a99;
}

/* Кнопки действий (✏️ 🗑️) — показываются при наведении */
.session-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.18s;
}
.session-card:hover .session-actions {
  opacity: 1;
}

.session-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 5px 6px;
  border-radius: 8px;
  transition: background 0.15s;
  line-height: 1;
}
.session-btn:hover {
  background: var(--beige-dark);
}
.session-btn.session-btn-delete:hover {
  background: #FFD0D0;
}

/* На тач-устройствах всегда показываем кнопки (нет hover) */
@media (hover: none) {
  .session-actions { opacity: 1; }
}

/* ============================================
   МОБИЛЬНЫЙ ФИК — шапка хаба (чат)
   ============================================ */

/* Скрывать/показывать длинный/короткий текст кнопки «Новая тема» */
.clear-btn-long  { display: inline; }
.clear-btn-short { display: none; }

/* Правый блок шапки чата: кнопка «Новая тема» + баланс монет */
.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 560px) {
  /* Правый блок — складываем вертикально */
  .chat-header-right {
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
  }

  /* Шапка хаба */
  .chat-header {
    flex-wrap: nowrap;
    padding: 8px 10px;
    gap: 8px;
    align-items: center;
  }

  /* Emoji хаба чуть меньше */
  .chat-hub-emoji {
    font-size: 22px;
  }

  /* Название хаба */
  .chat-hub-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
  }

  /* Описание — прячем */
  .chat-hub-desc {
    display: none;
  }

  /* Пресеты — переносим на несколько строк вместо горизонтального скролла */
  .presets-bar {
    white-space: normal;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: visible;
  }

  .presets-label {
    width: 100%;
    margin-bottom: 2px;
    margin-right: 0;
  }

  .preset-btn {
    margin-right: 0;
    font-size: 12px;
    padding: 6px 10px;
    flex-shrink: 0;
  }
}

@media (max-width: 400px) {
  /* На очень маленьких экранах — прячем длинный текст кнопки */
  .clear-btn-long  { display: none; }
  .clear-btn-short { display: inline; }

  /* Название хаба ещё уже */
  .chat-hub-name {
    max-width: 90px;
  }
}
