/* ============================================================
   NEON SLIM AI — стили
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Темы ---------- */
:root[data-theme="dark"] {
  --bg: #0a0b14;
  --bg-glow-1: rgba(255, 42, 133, 0.18);
  --bg-glow-2: rgba(0, 240, 255, 0.14);
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.10);
  --text: #eef0ff;
  --text-muted: #9aa0c0;
  --accent-pink: #ff2a85;
  --accent-cyan: #00f0ff;
  --accent-grad: linear-gradient(135deg, #ff2a85, #7b5cff 55%, #00f0ff);
  --user-bubble: linear-gradient(135deg, rgba(255, 42, 133, 0.28), rgba(123, 92, 255, 0.24));
  --user-border: rgba(255, 42, 133, 0.45);
  --bot-bubble: rgba(0, 240, 255, 0.06);
  --bot-border: rgba(0, 240, 255, 0.35);
  --shadow-neon: 0 0 24px rgba(255, 42, 133, 0.35), 0 0 40px rgba(0, 240, 255, 0.15);
}

:root[data-theme="light"] {
  --bg: #f4f2fa;
  --bg-glow-1: rgba(255, 128, 186, 0.28);
  --bg-glow-2: rgba(128, 200, 255, 0.28);
  --card: #ffffff;
  --card-border: rgba(123, 92, 255, 0.12);
  --text: #1b1c33;
  --text-muted: #6a6d8a;
  --accent-pink: #e6267c;
  --accent-cyan: #00b8d4;
  --accent-grad: linear-gradient(135deg, #ff5fa2, #9b7cff 55%, #4fd7ff);
  --user-bubble: linear-gradient(135deg, rgba(255, 95, 162, 0.18), rgba(155, 124, 255, 0.18));
  --user-border: rgba(230, 38, 124, 0.35);
  --bot-bubble: rgba(0, 184, 212, 0.08);
  --bot-border: rgba(0, 184, 212, 0.28);
  --shadow-neon: 0 6px 24px rgba(123, 92, 255, 0.18);
}

body {
  background: var(--bg);
  color: var(--text);
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Мягкое радиальное свечение фона (без фильтров) */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
body::before {
  background: radial-gradient(60% 45% at 15% 0%, var(--bg-glow-1), transparent 70%);
}
body::after {
  background: radial-gradient(55% 50% at 90% 100%, var(--bg-glow-2), transparent 70%);
}

.hidden { display: none !important; }

/* ============================================================
   ЭКРАН АВТОРИЗАЦИИ
   ============================================================ */
.auth-screen {
  position: relative;
  z-index: 1;
  height: 100dvh;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.auth-glow {
  position: fixed;
  inset: -30% -30% auto -30%;
  height: 60vh;
  background: radial-gradient(closest-side, var(--bg-glow-1), transparent 70%);
  pointer-events: none;
}
.auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-top: 20px;
}
.auth-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
}
.auth-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 320px;
  line-height: 1.45;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-neon);
  backdrop-filter: blur(2px);
}
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.auth-tabs { display: flex; gap: 6px; background: rgba(127,127,160,0.12); padding: 4px; border-radius: 12px; }
.auth-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
}
.auth-tabs button.active { background: var(--accent-grad); color: #fff; }

.field input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(127,127,160,0.12);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--accent-pink); }

.btn-primary {
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 42, 133, 0.35);
  transition: transform 0.15s ease;
}
.btn-primary:active { transform: scale(0.98); }

.auth-error { color: #ff6070; font-size: 13px; min-height: 16px; text-align: center; }
.auth-legal { color: var(--text-muted); font-size: 11px; text-align: center; margin: 0; padding-bottom: 20px; }

/* Отзывы */
.reviews-block { display: flex; flex-direction: column; gap: 10px; }
.reviews-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.reviews-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
}
.review-card {
  flex: 0 0 82%;
  scroll-snap-align: start;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 14px;
}
.review-card h4 { margin: 0 0 4px; font-size: 14px; }
.review-card .wl { color: var(--accent-pink); font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.review-card p { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.4; }

/* ============================================================
   ОСНОВНОЙ ЭКРАН
   ============================================================ */
.app-screen {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Шапка ---------- */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid var(--card-border);
  background: linear-gradient(180deg, rgba(10,11,20,0.55), transparent);
}
:root[data-theme="light"] .app-header {
  background: linear-gradient(180deg, rgba(255,255,255,0.7), transparent);
}
.header-side { display: flex; gap: 8px; align-items: center; }
.header-side.right { justify-content: flex-end; }
.header-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#avatarCanvas { display: block; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.is-on { border-color: var(--accent-cyan); box-shadow: 0 0 10px rgba(0,240,255,0.35); }

/* ---------- Индикаторы ---------- */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 14px;
}
.metric {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.metric-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  gap: 6px;
}
.metric-head span:last-child { color: var(--text); font-weight: 700; font-size: 12px; }
.metric-bar {
  height: 5px;
  background: rgba(127,127,160,0.18);
  border-radius: 999px;
  overflow: hidden;
}
.metric-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; width: 0; }
.metric-fill.kcal { background: linear-gradient(90deg, #ff2a85, #ff8ac1); }
.metric-fill.water { background: linear-gradient(90deg, #00f0ff, #6ee7ff); }

/* ---------- Чат ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: msgIn 0.22s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border: 1px solid var(--user-border);
  border-bottom-right-radius: 6px;
}
.msg.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  border: 1px solid var(--bot-border);
  border-bottom-left-radius: 6px;
}
.msg .audio-player {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg .audio-player audio { height: 28px; width: 160px; max-width: 100%; }

.typing {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,100%{opacity:0.25} 50%{opacity:1} }

/* Карточка меню */
.menu-card {
  margin-top: 10px;
  background: rgba(0,240,255,0.05);
  border: 1px solid var(--bot-border);
  border-radius: 14px;
  padding: 10px;
  font-size: 13px;
}
.menu-card h5 { margin: 6px 0; font-size: 13px; color: var(--accent-cyan); }
.menu-day { margin-bottom: 8px; }
.menu-day-title { font-weight: 700; margin-bottom: 4px; color: var(--text); }
.menu-meal { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: var(--text-muted); font-size: 12.5px; }
.menu-meal b { color: var(--text); font-weight: 600; }

.shop-cat { margin-top: 8px; }
.shop-cat-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-pink); margin-bottom: 4px; font-weight: 700; }
.shop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.shop-item:active { background: rgba(127,127,160,0.12); }
.shop-item .box {
  width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid var(--accent-cyan);
  display: grid; place-items: center; flex-shrink: 0;
}
.shop-item .box::after {
  content: "";
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--accent-cyan);
  opacity: 0; transform: scale(0.5); transition: all 0.15s;
}
.shop-item.checked .box::after { opacity: 1; transform: scale(1); }
.shop-item.checked span { text-decoration: line-through; color: var(--text-muted); }

/* ---------- Нижняя панель ---------- */
.composer {
  padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--card-border);
  background: linear-gradient(0deg, rgba(10,11,20,0.85), rgba(10,11,20,0.5) 60%, transparent);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
:root[data-theme="light"] .composer {
  background: linear-gradient(0deg, rgba(255,255,255,0.9), rgba(255,255,255,0.6) 60%, transparent);
}
.quick-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s;
}
.chip:active { border-color: var(--accent-pink); }

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.text-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  background: rgba(127,127,160,0.12);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.text-input:focus { border-color: var(--accent-cyan); }

.mic-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--accent-grad);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-neon);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.mic-btn:active { transform: scale(0.94); }
.mic-btn.recording { animation: micPulse 1.2s infinite; }
@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,42,133,0.55); }
  50% { box-shadow: 0 0 0 14px rgba(255,42,133,0); }
}

/* ---------- Модальные окна ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 1px solid var(--card-border);
  animation: slideUp 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { font-size: 14px; color: var(--text); }

.paywall { border-color: var(--accent-pink); }

/* Профиль */
.profile-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--card-border); font-size: 14px; }
.profile-row:last-child { border-bottom: 0; }
.profile-row span:first-child { color: var(--text-muted); }
.profile-row span:last-child { font-weight: 600; }

.pay-cta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.pay-price {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.pay-sub { text-align: center; color: var(--text-muted); font-size: 12.5px; margin: 0 0 8px; }
.btn-secondary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn-secondary:active { opacity: 0.85; }
.btn-danger { border-color: #ff6070; color: #ff6070; }