/* ===========================================================
   EDUTAINMENT — Telegram Mini App
   Палитра: #FFD6E0 (пастель) · #B5597B (малина) · #7A2E4D (тёмная малина)
   =========================================================== */

:root {
  --pink-soft: #FFD6E0;
  --pink-raspberry: #B5597B;
  --pink-dark: #7A2E4D;

  /* производные от палитры */
  --pink-soft-2: #FBE7EC;
  --pink-tint: #F6D9E2;
  --white: #FFFFFF;
  --ink: #7A2E4D;
  --ink-60: rgba(122, 46, 77, 0.62);
  --ink-40: rgba(122, 46, 77, 0.40);
  --ink-15: rgba(122, 46, 77, 0.15);

  --shadow-card: 0 10px 28px rgba(122, 46, 77, 0.14);
  --shadow-soft: 0 4px 14px rgba(122, 46, 77, 0.10);
  --shadow-btn: 0 8px 20px rgba(181, 89, 123, 0.36);

  --radius-lg: 26px;
  --radius-md: 20px;
  --radius-sm: 14px;

  --font-head: "Fredoka", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--pink-soft);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: var(--app-vh, 100vh);
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
}

/* ===================== ОБЩЕЕ ===================== */

.screen { display: none; flex-direction: column; gap: 16px; animation: fade .28s ease; }
.screen.active { display: flex; }

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

.muted { color: var(--ink-60); }
.center { text-align: center; }

/* Шапка раздела с кнопкой назад */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.back-btn {
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--white);
  color: var(--pink-raspberry);
  font-size: 20px;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  flex: 0 0 auto;
  transition: transform .15s ease;
}
.back-btn:active { transform: scale(.92); }
.topbar-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  flex: 0 0 auto;
  box-shadow: 0 4px 10px rgba(181,89,123,.18);
}
.topbar h2 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .2px;
}

/* Кнопки */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-head);
  letter-spacing: .2px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--pink-raspberry);
  color: var(--white);
  box-shadow: var(--shadow-btn);
  width: 100%;
}
.btn-primary:disabled { opacity: .45; box-shadow: none; }

.btn-ghost {
  background: var(--white);
  color: var(--pink-dark);
  box-shadow: var(--shadow-soft);
  width: 100%;
}

/* Чипы */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1.5px solid var(--ink-15);
  background: var(--white);
  color: var(--pink-dark);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.chip:active { transform: scale(.95); }
.chip.selected { background: var(--pink-raspberry); color: var(--white); border-color: var(--pink-raspberry); }

/* ===================== ГЛАВНЫЙ ЭКРАН ===================== */

.hero {
  text-align: center;
  padding: 20px 8px 6px;
}
.logo-img {
  width: 100%;
  max-width: 340px;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 8px 18px rgba(181, 89, 123, 0.28));
}
.logo-sub {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  font-style: italic;
  color: var(--pink-raspberry);
  opacity: .92;
}
.hero-tag {
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink-60);
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 6px;
}
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 16px 20px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
  position: relative;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .2s ease;
}
.card:active { transform: translateY(2px) scale(.985); box-shadow: var(--shadow-soft); }
.card.wide { grid-column: 1 / -1; min-height: auto; flex-direction: row; align-items: center; gap: 14px; }

.card-icon {
  width: 64px; height: 64px;
  border-radius: 18px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(181, 89, 123, 0.20);
}
.card.wide .card-icon { width: 56px; height: 56px; border-radius: 16px; }
.card-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; line-height: 1.15; }
.card-desc { font-size: 12.5px; color: var(--ink-60); line-height: 1.4; }
.card.wide .card-body { display: flex; flex-direction: column; gap: 4px; }

.card-badge {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--pink-soft);
  color: var(--pink-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

/* ===================== ЧАТ (grammar / vocabulary) ===================== */

.chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}
.bubble {
  max-width: 86%;
  padding: 14px 16px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.5;
  animation: pop .25s ease;
  white-space: pre-wrap;
  word-break: break-word;
}
@keyframes pop { from { opacity:0; transform: translateY(6px) scale(.98);} to {opacity:1; transform:none;} }

.bubble.bot {
  align-self: flex-start;
  background: var(--white);
  color: var(--pink-dark);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-soft);
}
.bubble.user {
  align-self: flex-end;
  background: var(--pink-raspberry);
  color: var(--white);
  border-bottom-right-radius: 6px;
}
.bubble.typing { display: inline-flex; gap: 5px; align-items: center; padding: 16px 18px; }
.bubble.typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--pink-raspberry); opacity: .4;
  animation: typing 1s infinite ease-in-out;
}
.bubble.typing span:nth-child(2) { animation-delay: .2s; }
.bubble.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.bubble.cta {
  align-self: stretch;
  max-width: 100%;
  background: var(--pink-dark);
  color: var(--white);
  text-align: center;
  font-weight: 700;
}
.bubble strong { font-weight: 800; }
.bubble .word-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid rgba(122,46,77,.08); }
.bubble .word-row:last-child { border-bottom: none; }
.bubble .w-en { font-weight: 700; }
.bubble .w-ru { color: var(--ink-60); text-align: right; }

.composer {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 6px;
}
.composer input {
  flex: 1;
  border: 1.5px solid var(--ink-15);
  border-radius: 999px;
  padding: 14px 18px;
  font-size: 15px;
  font-family: inherit;
  color: var(--pink-dark);
  background: var(--white);
  outline: none;
}
.composer input:focus { border-color: var(--pink-raspberry); }
.composer .send {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--pink-raspberry);
  color: var(--white);
  font-size: 20px;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: var(--shadow-btn);
}
.composer .send:active { transform: scale(.92); }

/* Оверлей-просмотрщик PDF-конспекта */
.pdf-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--white);
  display: flex; flex-direction: column;
  animation: fade .2s ease;
  padding-top: var(--safe-top);
}
.pdf-overlay-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--pink-raspberry);
  color: var(--white);
  flex: 0 0 auto;
}
.pdf-overlay-title {
  font-family: var(--font-head); font-weight: 600; font-size: 16px;
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pdf-ext {
  background: rgba(255,255,255,.22); color: var(--white);
  border: none; border-radius: 999px; padding: 7px 12px;
  font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer;
}
.pdf-close {
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.22); color: var(--white);
  font-size: 16px; cursor: pointer; flex: 0 0 auto;
}
.pdf-frame { flex: 1; width: 100%; border: none; background: #e9e3e6; }
.pdf-pages { flex: 1; overflow-y: auto; background: #efe7ea; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.pdf-page { width: 100%; height: auto; display: block; border-radius: 8px; box-shadow: 0 4px 14px rgba(122,46,77,.18); background: #fff; }
.pdf-more { text-align: center; font-size: 13px; color: var(--ink-60); padding: 8px 12px 16px; }

.pdf-btn {
  align-self: flex-start;
  background: var(--white);
  color: var(--pink-raspberry);
  border: 1.5px solid var(--ink-15);
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .15s ease;
}
.pdf-btn:active { transform: scale(.96); }

.hint-row { margin-bottom: 4px; }
.hint-label { font-size: 13px; color: var(--ink-60); margin-bottom: 8px; }

/* ===================== LEVEL TEST ===================== */

.progress {
  height: 8px;
  background: var(--white);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--ink-15);
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--pink-raspberry);
  border-radius: 999px;
  transition: width .3s ease;
}
.q-counter { font-size: 13px; color: var(--ink-60); font-weight: 700; }
.q-text {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px;
  font-family: var(--font-head);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: var(--shadow-soft);
}
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  background: var(--white);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 15.5px;
  font-weight: 600;
  text-align: left;
  color: var(--pink-dark);
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-soft);
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.option:active { transform: scale(.98); }
.option.correct { border-color: #2e9e6b; background: #e9f8f0; }
.option.wrong { border-color: var(--pink-raspberry); background: #fbe7ee; }
.option.dim { opacity: .5; }

/* Результат */
.result-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 30px 22px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.result-level {
  font-family: var(--font-head);
  font-size: 60px;
  font-weight: 700;
  color: var(--pink-raspberry);
  line-height: 1;
  text-shadow: 0 4px 12px rgba(181,89,123,.3);
}
.result-name { font-family: var(--font-head); font-size: 22px; font-weight: 600; margin-top: 8px; }
.result-score { font-size: 14px; color: var(--ink-60); margin-top: 6px; }
.result-desc { font-size: 14.5px; line-height: 1.55; margin-top: 16px; color: var(--ink-60); }

/* ===================== ABOUT ===================== */

.about-head { text-align: center; padding: 6px 0 2px; }
.about-photo {
  width: 120px; height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 12px;
  display: block;
  border: 4px solid var(--white);
  box-shadow: 0 10px 24px rgba(181, 89, 123, 0.28);
}
.about-name { font-family: var(--font-head); font-size: 25px; font-weight: 600; color: var(--pink-raspberry); }
.about-role { font-size: 14px; color: var(--ink-60); margin-top: 4px; }

.about-block {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}
.about-block h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--pink-raspberry);
  display: flex; align-items: center; gap: 10px;
}
.about-block h3::before {
  content: "";
  width: 18px; height: 4px;
  border-radius: 999px;
  background: var(--pink-raspberry);
  flex: 0 0 auto;
}
.about-block p { margin: 0; font-size: 14.5px; line-height: 1.6; }
.li {
  display: flex; gap: 10px;
  padding: 9px 0;
  font-size: 14.5px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(122,46,77,.07);
}
.li:last-child { border-bottom: none; }
.li .dot { color: var(--pink-raspberry); flex: 0 0 auto; font-weight: 900; }
.li .place { font-weight: 700; }
.li .spec { color: var(--ink-60); }

.stat-row { display: flex; gap: 10px; }
.stat {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.stat b { display: block; font-family: var(--font-head); font-size: 22px; font-weight: 600; color: var(--pink-raspberry); }
.stat span { font-size: 11.5px; color: var(--ink-60); }

/* ===================== TRANSLATOR / SOON ===================== */

.soon {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.soon .emoji { font-size: 54px; }
.soon-icon { width: 110px; height: 110px; border-radius: 28px; box-shadow: 0 10px 24px rgba(181,89,123,.22); }
.soon h3 { margin: 16px 0 8px; font-family: var(--font-head); font-size: 23px; font-weight: 600; }
.soon p { margin: 0; color: var(--ink-60); font-size: 14.5px; line-height: 1.5; }

/* ===================== EXERCISES ===================== */

.step-q {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  padding: 4px 2px;
}
.exercise {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}
.exercise .read-text { font-size: 15px; line-height: 1.7; margin-bottom: 4px; margin-top: 8px; }
.lvl-badge { background: var(--pink-soft); color: var(--pink-dark); font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; vertical-align: middle; }
.read-pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }
.read-pick-title { flex: 1; min-width: 0; }
.ex-q { font-weight: 700; margin: 14px 0 10px; font-size: 15.5px; }
.ex-feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: none;
}
.ex-feedback.ok { display: block; background: #e9f8f0; color: #1f7a52; }
.ex-feedback.no { display: block; background: #fbe7ee; color: var(--pink-dark); }

.audio-box {
  background: var(--pink-tint);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--ink-60);
}
.audio-box .emoji { font-size: 32px; display: block; margin-bottom: 6px; }

/* Видео-карточки аудирования */
.video-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-soft);
  transition: transform .15s ease;
}
.video-card:active { transform: scale(.98); }
.video-thumb {
  position: relative;
  width: 116px; height: 70px;
  flex: 0 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: var(--pink-tint);
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb.noimg { display: grid; place-items: center; }
.video-thumb.noimg span { font-weight: 800; color: var(--pink-raspberry); font-size: 14px; letter-spacing: .5px; }
.video-play {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(122, 46, 77, 0.78);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px;
  padding-left: 2px;
}
.video-meta { min-width: 0; flex: 1; }
.video-title {
  font-size: 14.5px; font-weight: 700; line-height: 1.3; color: var(--pink-dark);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.video-tag { margin-top: 5px; font-size: 12px; color: var(--ink-60); font-weight: 600; }
