/* ===== Рита Mini App — стили ===== */
/* Пастель, крупные элементы, дружелюбно для девочки 11–12 */

:root {
  --pink:        #ff8fc0;
  --pink-soft:   #ffb6d5;
  --pink-bg:     #fff0f6;
  --lilac:       #c9b6ff;
  --mint:        #b6f0d8;
  --cream:       #fffaf3;
  --ink:         #5a4a55;
  --ink-soft:    #9a8a93;
  --white:       #ffffff;
  --bubble-me:   #ffd6e8;
  --bubble-rita: #ffffff;
  --radius:      22px;
  --shadow:      0 6px 24px rgba(255, 143, 192, .22);
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Segoe UI', 'Helvetica Neue', system-ui, -apple-system, 'Comic Sans MS', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--pink-bg) 0%, #f3ecff 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

/* ===================== ЛОГИН ===================== */
.login-screen {
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--cream);
  border-radius: 32px;
  padding: 36px 26px 30px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop .45s cubic-bezier(.18,.89,.32,1.28);
}

@keyframes pop {
  from { transform: scale(.86); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.login-emoji {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

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

.login-title {
  font-size: 26px;
  color: var(--pink);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 26px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }

.field-label {
  font-size: 13px;
  color: var(--ink-soft);
  padding-left: 10px;
}

.field input {
  font-family: var(--font);
  font-size: 17px;
  color: var(--ink);
  background: var(--white);
  border: 2px solid #ffe1ee;
  border-radius: var(--radius);
  padding: 15px 18px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.field input:focus {
  border-color: var(--pink-soft);
  box-shadow: 0 0 0 4px rgba(255, 182, 213, .3);
}

.login-error {
  color: #e85b8a;
  font-size: 14px;
  text-align: center;
  margin: -4px 0 0;
}

.btn-primary {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  background: linear-gradient(135deg, var(--pink) 0%, var(--lilac) 100%);
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 6px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, filter .2s;
}

.btn-primary:active { transform: scale(.96); filter: brightness(.97); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ===================== ЧАТ ===================== */
.chat-screen { background: linear-gradient(160deg, var(--pink-bg) 0%, #f3ecff 100%); }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--white);
  box-shadow: 0 2px 12px rgba(255, 143, 192, .15);
  z-index: 5;
}

.chat-avatar {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 26px;
  background: linear-gradient(135deg, var(--pink-soft), var(--lilac));
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-size: 17px; font-weight: 700; color: var(--ink); }
.chat-header-status { font-size: 13px; color: var(--mint); filter: brightness(.75); }
.chat-header-status.typing-now { color: var(--pink); }

.chat-logout {
  font-size: 22px;
  color: var(--ink-soft);
  background: none; border: none;
  padding: 8px;
  cursor: pointer;
  border-radius: 12px;
}
.chat-logout:active { background: #ffe1ee; }

/* Лента сообщений */
.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 20px;
  font-size: 16px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  animation: bubbleIn .25s ease;
  box-shadow: 0 2px 8px rgba(180, 140, 170, .12);
}

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

.bubble.rita {
  align-self: flex-start;
  background: var(--bubble-rita);
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.bubble.me {
  align-self: flex-end;
  background: var(--bubble-me);
  color: var(--ink);
  border-bottom-right-radius: 6px;
}

.bubble a { color: var(--pink); text-decoration: underline; }

.bubble img {
  display: block;
  max-width: 100%;
  border-radius: 14px;
  margin-top: 6px;
}
.bubble img:first-child { margin-top: 0; }

.bubble .bubble-time {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 4px;
  text-align: right;
}

/* Индикатор "печатает" */
.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 22px 6px;
  font-size: 13px;
  color: var(--ink-soft);
}
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i {
  width: 7px; height: 7px;
  background: var(--pink-soft);
  border-radius: 50%;
  animation: blink 1.2s infinite both;
}
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40%           { opacity: 1;  transform: scale(1); }
}

/* Поле ввода */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--white);
  box-shadow: 0 -2px 12px rgba(255, 143, 192, .15);
}

.composer-attach,
.composer-mic,
.composer-send {
  flex-shrink: 0;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 22px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform .12s;
}

.composer-attach { background: #fff0f6; color: var(--pink); }
.composer-attach:active { transform: scale(.9); }

.composer-send {
  background: linear-gradient(135deg, var(--pink), var(--lilac));
  color: var(--white);
  font-size: 20px;
}
.composer-send:active { transform: scale(.9); }

.composer-mic { background: #fff0f6; color: var(--pink); }
.composer-mic:active { transform: scale(.9); }
/* Состояние записи — пульсирующий красный */
.composer-mic.recording {
  background: linear-gradient(135deg, #ff5e7e, #ff85a1);
  color: var(--white);
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,94,126,.55); }
  50%      { box-shadow: 0 0 0 10px rgba(255,94,126,0); }
}
@media (prefers-reduced-motion: reduce) {
  .composer-mic.recording { animation: none; }
}

.composer-input {
  flex: 1;
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  background: #fff0f6;
  border: 2px solid #ffe1ee;
  border-radius: 22px;
  padding: 12px 16px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.35;
  transition: border-color .2s;
}
.composer-input:focus { border-color: var(--pink-soft); }

/* Меню прикрепления */
.attach-sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.attach-sheet-backdrop { position: absolute; inset: 0; background: rgba(90, 74, 85, .35); }
.attach-sheet-menu {
  position: relative;
  width: 100%;
  background: var(--cream);
  border-radius: 28px 28px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.attach-option {
  font-family: var(--font);
  font-size: 17px;
  color: var(--ink);
  background: var(--white);
  border: none;
  border-radius: 18px;
  padding: 16px;
  cursor: pointer;
  text-align: center;
}
.attach-option:active { background: #ffe1ee; }
.attach-cancel { color: var(--ink-soft); font-weight: 600; }

/* Превью отправляемого фото в пузыре me */
.bubble.me .upload-preview { max-width: 180px; }

/* Десктоп — центрируем как «телефон» */
@media (min-width: 600px) {
  .chat-screen, .login-screen {
    max-width: 420px;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(180, 140, 170, .18);
  }
}

/* Кнопка озвучки ответов (TTS) - тумблер в шапке, токены темы */
.chat-voice {
  font-size: 22px;
  color: var(--ink-soft);
  background: none; border: none;
  padding: 8px;
  min-width: 40px; min-height: 40px;
  cursor: pointer;
  border-radius: 12px;
  transition: color .2s, box-shadow .2s;
}
.chat-voice:active { background: #ffe1ee; }
.chat-voice.on {
  color: var(--pink);
  box-shadow: var(--shadow);
}
.chat-voice.speaking { animation: voicePulse 1.2s ease-in-out infinite; }
@keyframes voicePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-voice.speaking { animation: none; }
}
