/* Ronnie Mini App — styles. Phone-first (360–430 px). Animations use transform / opacity only. */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

h1, h2, p { margin: 0; }
img, video, canvas, svg { display: block; }
button {
  font: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
:focus { outline: none; }
:focus-visible { outline: 3px solid rgba(216, 87, 74, 0.5); outline-offset: 2px; }
.ic { flex: none; }

/* ---------- shell ---------- */
.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* --vvh: the visible height, set by js/keyboard.js — the app ends where the on-screen keyboard begins */
  height: min(var(--tg-viewport-stable-height, var(--app-h)), var(--vvh, 100000px));
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.screen {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg); /* backdrop for Ronnie's "darken" blend while the screen fades in */
  animation: screen-in 0.24s var(--ease); /* no fill-mode: the screen must not stay a stacking context (sheets are fixed) */
}
.screen__scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(var(--safe-top) + var(--s3)) var(--s4) var(--s6);
  scrollbar-width: none;
}
.screen__scroll::-webkit-scrollbar { display: none; }
.screen__head { flex: none; padding: calc(var(--safe-top) + 14px) var(--s4) var(--s2); }
.screen__head + .screen__scroll { padding-top: var(--s2); }
/* what scrolls away under a header fades out instead of being cut by a hard edge (the header itself stays
   transparent and is no stacking context — Ronnie's "darken" blend needs the screen's own background) */
.screen__head, .words__top { position: relative; }
.screen__head::after, .words__top::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 12px;
  z-index: 2;
  background: linear-gradient(to bottom, var(--bg), rgba(245, 239, 222, 0));
  pointer-events: none;
}

.title { font-size: 26px; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; }
.subtitle { margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-2); }

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin-top: var(--s4); }
.stack--in > * { animation: rise 0.42s var(--ease) both; }
.stack--in > :nth-child(2) { animation-delay: 0.05s; }
.stack--in > :nth-child(3) { animation-delay: 0.1s; }
.stack--in > :nth-child(4) { animation-delay: 0.15s; }

.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s4); }
.card__title { font-size: 18px; font-weight: 800; margin-bottom: var(--s3); }

/* ---------- tab bar ---------- */
.tabbar {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(86, 66, 30, 0.05);
  z-index: 10;
}
.tab {
  flex: 1;
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--r-md);
  color: var(--ink-3);
  /* five tabs, the longest label is «Грамматика»: every label is set a touch smaller and tighter, so it fits a
     360 px phone without being cut */
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.tab__icon {
  position: relative;
  width: min(58px, 100%);
  height: 30px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  transition: transform 0.2s var(--spring), background-color 0.2s ease;
}
.tab:active .tab__icon { transform: scale(0.9); }
.tab.is-active { color: var(--accent-ink); }
.tab.is-active .tab__icon { background: var(--accent-tint); }
.tab__badge {
  position: absolute;
  top: -4px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
  animation: pop-in 0.3s var(--spring);
}
.tab__badge--dot { top: 0; right: 12px; min-width: 10px; width: 10px; height: 10px; padding: 0; }
/* five tabs: the labels stay on one line on narrow phones */
.tab__label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* typing: the keyboard takes half of the screen — the tab bar gives its room to the text field */
.kb-open .tabbar { display: none; }

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 56px;
  padding: 0 var(--s5);
  border-radius: 18px;
  font-size: var(--fs-md);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  transition: transform 0.12s var(--ease), opacity 0.15s ease;
}
.btn:active { transform: translateY(2px) scale(0.985); }
.btn--block { width: 100%; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-deep), 0 10px 22px rgba(216, 87, 74, 0.25); }
.btn--green { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-deep), 0 10px 22px rgba(76, 154, 106, 0.22); }
.btn--amber { background: var(--amber-tint); color: var(--amber-ink); box-shadow: 0 3px 0 #EDD49B; }
.btn--soft { background: var(--accent-tint); color: var(--accent-ink); box-shadow: 0 3px 0 #F1C9C1; }
.btn--ghost { background: var(--surface); color: var(--ink); box-shadow: 0 3px 0 #E2D9C2, inset 0 0 0 1.5px var(--line); }
/* an offer, not a step of the day («Взять ещё слова»): flat, lower than the buttons around it */
.btn--quiet { min-height: 48px; color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px rgba(177, 63, 52, 0.28); }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn.is-busy { opacity: 1; }
/* a quiet text link with an icon: «Мой словарь · 12 ›» */
.linkbtn { position: relative; display: inline-flex; align-items: center; gap: 4px; min-height: 26px; font-size: 14px; font-weight: 700; line-height: 1.2; color: var(--accent-ink); white-space: nowrap; }
.linkbtn::after { content: ''; position: absolute; inset: -9px -8px; } /* 44 px touch target */
.linkbtn:active { opacity: 0.6; }

/* ---------- chips, tags, status marks ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-sm);
  font-weight: 800;
  white-space: nowrap;
}
.chip--streak { color: var(--accent-ink); }
.chip--streak.is-off { color: var(--ink-2); }
.chip--streak.is-off .chip__emoji { filter: grayscale(1); opacity: 0.55; }
.chip--level { color: var(--grey-ink); }

/* the language the student learns: a round flag between the two pills, and its sheet */
.flag { flex: none; display: block; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(43, 41, 38, 0.12); }
.langbtn { position: relative; flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); transition: transform 0.12s var(--ease); }
.langbtn::after { content: ''; position: absolute; inset: -6px; } /* 48 px touch target */
.langbtn:active { transform: scale(0.92); }
/* three controls in one row: on a narrow phone the pills give way (the streak label is cut with «…», the little
   arrows go) rather than push the row wider than the screen */
.home__top .chip { min-width: 0; }
.home__top .chip--level { flex: none; }
.chip__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) {
  .home__top .chip { padding: 0 12px; }
  .home__top .chip__go { display: none; }
}
.langs__title { font-size: var(--fs-lg); font-weight: 800; line-height: 1.2; }
.langs__text { margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.langs__list { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); list-style: none; padding: 0; }
.lang { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 60px; padding: 10px 14px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); text-align: left; transition: transform 0.12s var(--ease); }
.lang:active { transform: scale(0.985); }
.lang.is-current { box-shadow: inset 0 0 0 2px var(--green-ink); background: var(--green-tint); }
.lang:not(.is-current) .flag { filter: grayscale(0.35); opacity: 0.85; }
.lang__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lang__title { font-size: var(--fs-md); font-weight: 800; line-height: 1.2; }
.lang__native { font-size: var(--fs-sm); color: var(--ink-2); }
.lang__mark { flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 12px; background: var(--amber-tint); color: var(--amber-ink); font-size: 13px; font-weight: 800; }
.lang__mark--on { background: none; padding-right: 0; color: var(--green-ink); }

.tag, .status {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
}
.tag--new, .status--learning { background: var(--accent-tint); color: var(--accent-ink); }
.tag--review, .status--learned { background: var(--green-tint); color: var(--green-ink); }
.status--known { background: var(--grey-tint); color: var(--grey-ink); }
.status--new { background: var(--amber-tint); color: var(--amber-ink); }

/* ---------- Ronnie ---------- */
.ronnie {
  position: relative;
  flex: none;
  width: var(--ronnie-size, 240px);
  height: var(--ronnie-size, 240px);
  pointer-events: none; /* the clip has wide empty margins; only the raccoon itself is tappable */
}
.ronnie__stage {
  position: absolute;
  inset: 0;
  /* The clip background is cream too, but video colours drift by a shade — a soft round mask hides the square for good. */
  -webkit-mask-image: radial-gradient(circle closest-side, #000 80%, transparent 100%);
  mask-image: radial-gradient(circle closest-side, #000 80%, transparent 100%);
  /* …and "darken" clamps the slightly lighter video cream to the exact page cream (the raccoon itself is darker, so it stays). */
  mix-blend-mode: darken;
  transform-origin: 50% 86%;
}
.ronnie__stage.is-boop { animation: boop 0.45s var(--spring); }
.ronnie__poster, .ronnie__v {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.ronnie__v { opacity: 0; transition: opacity 0.16s linear; background: transparent; }
.ronnie__v.is-on { opacity: 1; z-index: 2; }
.ronnie__v.is-under { opacity: 1; z-index: 1; transition: none; }
.ronnie__hit {
  position: absolute;
  left: 26%;
  right: 22%;
  top: 14%;
  bottom: 12%;
  z-index: 3;
  border-radius: 40%;
  pointer-events: auto;
}
/* bust = zoomed on head and paws, for small sizes */
.ronnie--bust .ronnie__stage { overflow: hidden; border-radius: 50%; }
.ronnie--bust .ronnie__poster, .ronnie--bust .ronnie__v { transform: scale(1.45); transform-origin: 47% 30%; }
.ronnie--bust .ronnie__hit { inset: 8%; border-radius: 50%; }

.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg) url(../ronnie/poster.png) no-repeat 50% 26% / 290%;
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.avatar--sm { width: 36px; height: 36px; }

/* ---------- speech bubble & typing dots ---------- */
.bubble {
  position: relative;
  max-width: min(330px, 100%);
  padding: 12px 18px;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-1);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  transform-origin: 50% 100%;
  animation: bubble-pop 0.5s var(--spring) both;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  background: inherit;
  border-radius: 0 0 5px 0;
  transform: rotate(45deg);
}
.typing { display: inline-flex; align-items: center; gap: 5px; height: 23px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: typing 1.1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
.typing--inline { height: auto; gap: 3px; margin-left: 5px; vertical-align: baseline; }
.typing--inline i { width: 4px; height: 4px; }

/* ---------- skeletons ---------- */
.sk { display: block; position: relative; overflow: hidden; background: var(--bg-deep); }
.sk::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 253, 247, 0.6), transparent);
  animation: shimmer 1.3s ease-in-out infinite;
}
.sk--right { margin-left: auto; }

/* ---------- states ---------- */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--s6) var(--s3); }
.state--full { justify-content: center; padding: calc(var(--safe-top) + var(--s6)) var(--s6) calc(var(--safe-bottom) + var(--s6)); }
.state--compact { padding: var(--s2) var(--s3) var(--s4); }
.state__ronnie { --ronnie-size: clamp(220px, 66vw, 280px); margin-bottom: calc(var(--ronnie-size) * -0.07); }
.state__ronnie--sm { --ronnie-size: 136px; margin-bottom: var(--s1); }
.state__title { font-size: 22px; font-weight: 800; line-height: 1.2; }
.state__text { margin-top: var(--s2); max-width: 330px; font-size: 16px; line-height: 1.45; color: var(--ink-2); }
.state__btn { margin-top: var(--s5); }
.state--full .state__btn { max-width: 340px; }

/* ---------- toast ---------- */
.toast {
  position: absolute;
  left: var(--s4);
  right: var(--s4);
  top: calc(var(--safe-top) + var(--s3)); /* at the top: never covers the action buttons */
  z-index: 60;
  padding: 12px var(--s4);
  border-radius: var(--r-md);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.25s ease, transform 0.25s var(--ease);
  pointer-events: none;
}
.toast.is-in { opacity: 1; transform: none; }

/* ---------- bottom sheet ---------- */
.sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tg-viewport-stable-height, var(--app-h));
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet__backdrop { position: absolute; inset: 0; background: rgba(43, 41, 38, 0.45); opacity: 0; transition: opacity 0.26s ease; }
.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  background: var(--bg); /* cream, so Ronnie's clips blend in here too */
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 40px rgba(43, 41, 38, 0.2);
  padding-bottom: var(--safe-bottom);
  transform: translateY(104%);
  transition: transform 0.28s var(--ease);
  will-change: transform;
}
.sheet.is-open .sheet__backdrop { opacity: 1; }
.sheet.is-open .sheet__panel { transform: none; }
.sheet__grip { flex: none; height: 30px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.sheet__grip::before { content: ''; width: 44px; height: 5px; border-radius: 3px; background: rgba(43, 41, 38, 0.18); }
.sheet__body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px var(--s5) var(--s5); scrollbar-width: none; }
.sheet__body::-webkit-scrollbar { display: none; }

/* ---------- pictures ---------- */
.pic { position: relative; overflow: hidden; aspect-ratio: 1 / 1; border-radius: var(--r-lg); background: var(--bg-deep); }
.pic.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 253, 247, 0.6), transparent);
  animation: shimmer 1.3s ease-in-out infinite;
}
.pic__img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s ease; }
.pic__img.is-ok { opacity: 1; }
.pic__empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  background: linear-gradient(140deg, var(--accent-tint), var(--amber-tint));
  color: var(--accent-ink);
}
.pic__letter { font-size: 64px; font-weight: 800; line-height: 1; opacity: 0.9; }
.wcard__pic .pic__letter, .detail__pic .pic__letter { font-size: 92px; }
.pic__caption { font-size: 14px; font-weight: 600; opacity: 0.8; }
.pic__paw { position: absolute; opacity: 0.16; }
.pic__paw--1 { top: 12%; right: 12%; transform: rotate(18deg); }
.pic__paw--2 { bottom: 14%; left: 12%; transform: rotate(-22deg); }

/* ---------- speaker ---------- */
.speaker {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  transition: transform 0.12s var(--ease);
}
.speaker:active { transform: scale(0.92); }
.speaker::before { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 2px var(--accent); opacity: 0; }
.speaker.is-playing::before { animation: ping 1.1s ease-out infinite; }
.speaker.is-playing .ic-wave--1 { animation: wave 0.9s ease-in-out infinite; }
.speaker.is-playing .ic-wave--2 { animation: wave 0.9s ease-in-out 0.2s infinite; }

/* ================= Главная ================= */
.home__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 36px; }
.hero { display: flex; flex-direction: column; align-items: center; margin-top: var(--s2); }
.hero__bubble-slot { position: relative; z-index: 2; width: 100%; min-height: 94px; display: flex; align-items: flex-end; justify-content: center; }
.hero__ronnie {
  --ronnie-size: clamp(236px, 74vw, 304px);
  margin-top: calc(var(--ronnie-size) * -0.105);
  margin-bottom: calc(var(--ronnie-size) * -0.1);
}

.daycard {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  padding: var(--s5);
  border-radius: var(--r-xl);
  text-align: left;
  color: #fff;
  background: linear-gradient(135deg, #E46C5F 0%, var(--accent) 55%, #C94C40 100%);
  box-shadow: 0 3px 0 var(--accent-deep), 0 14px 28px rgba(216, 87, 74, 0.3);
  transition: transform 0.14s var(--ease);
}
.daycard:active { transform: translateY(2px) scale(0.985); }
.daycard__text { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); }
.daycard__eyebrow { font-size: 13.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.88; }
.daycard__title { font-size: 22px; font-weight: 800; line-height: 1.2; }
.daycard__cta {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 var(--s4);
  border-radius: 20px;
  background: #fff;
  color: var(--accent-ink);
  font-size: 16px;
  font-weight: 800;
}
.daycard__paw { position: absolute; color: #fff; opacity: 0.1; }
.daycard__paw--1 { top: -14px; right: 96px; transform: rotate(20deg); }
.daycard__paw--2 { bottom: -6px; right: 4px; transform: rotate(-24deg); }

.ring { position: relative; flex: none; width: 76px; height: 76px; }
.ring > svg { transform: rotate(-90deg); }
.ring__track { fill: none; stroke: rgba(255, 255, 255, 0.28); stroke-width: 8; }
.ring__bar { fill: none; stroke: #fff; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease); }
.ring__label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; line-height: 1; }
.ring__label small { font-size: 14px; font-weight: 700; opacity: 0.85; }

.lastline { display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left; transition: transform 0.12s var(--ease); }
.lastline:active { transform: scale(0.985); }
.lastline__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lastline__label { font-size: 13.5px; font-weight: 700; color: var(--ink-3); }
.lastline__en { font-size: var(--fs-md); font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lastline__ru { font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lastline__go { color: var(--ink-3); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px var(--s2); border-radius: var(--r-md); text-align: center; }
.stat b { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat span { font-size: 13.5px; font-weight: 700; }
.stat--green { background: var(--green-tint); color: var(--green-ink); }
.stat--accent { background: var(--accent-tint); color: var(--accent-ink); }
.stat--grey { background: var(--grey-tint); color: var(--grey-ink); }
.stat--amber { background: var(--amber-tint); color: var(--amber-ink); }

/* «Письмо · 5 минут» on the home screen; the same calm card says «Слова дня · готово» once today's words are done */
.wrcard { display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left; transition: transform 0.12s var(--ease); }
.wrcard:active { transform: scale(0.985); }
.wrcard__icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: var(--amber-tint); color: var(--amber-ink); }
.wrcard--done .wrcard__icon { background: var(--green-tint); color: var(--green-ink); }
.wrcard__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.wrcard__label { font-size: 13.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--amber-ink); }
.wrcard--done .wrcard__label { color: var(--green-ink); }
.wrcard__title { font-size: var(--fs-md); font-weight: 800; line-height: 1.25; }
.wrcard__text { font-size: var(--fs-sm); line-height: 1.3; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.days { margin-top: var(--s4); }
.days__head { display: flex; justify-content: space-between; gap: var(--s2); margin-bottom: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.days__dots { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: var(--s1); justify-items: center; }
.day { width: 100%; max-width: 16px; aspect-ratio: 1 / 1; border-radius: 50%; background: var(--grey-tint); }
.day.is-on { background: var(--green); }
.day.is-today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.progress__foot { margin-top: 14px; font-size: 14.5px; color: var(--ink-2); }
.progress__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.progress__head .card__title { margin-bottom: 0; }

/* ================= Слова ================= */
.words__top { flex: none; display: flex; align-items: center; gap: var(--s1); padding: calc(var(--safe-top) + 6px) var(--s4) 0 var(--s2); }
.words__ronnie { --ronnie-size: 96px; margin: -6px 0 -10px; }
.words__progress { flex: 1; min-width: 0; }
.words__meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 26px; }
.words__count { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.steps { display: flex; gap: 6px; margin-top: 10px; }
.step { flex: 1; height: 8px; border-radius: 4px; background: var(--grey-tint); transition: background-color 0.3s ease; }
.step.is-done { background: var(--green); }
.step.is-now { background: var(--accent); }
.steps--bar { display: block; height: 8px; border-radius: 4px; background: var(--grey-tint); overflow: hidden; }
.steps--bar i { display: block; height: 100%; border-radius: 4px; background: var(--green); transform-origin: 0 50%; transition: transform 0.4s var(--ease); }

/* «Мой словарь · 12»: under the steps, in the room next to Ronnie — the header does not grow */
.words__dict { display: flex; width: max-content; margin: 5px 0 -2px auto; }
.done__dict { margin-top: var(--s4); }

.words__scroll { padding-top: var(--s2); padding-bottom: var(--s4); }

.wcard {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  padding: var(--s3) var(--s3) 18px;
  animation: card-in 0.36s var(--ease) both;
}
.wcard.is-leaving { animation: card-out-left 0.24s ease-in both; }
.wcard.is-leaving--right { animation-name: card-out-right; }
/* 25vh: every card has its 💡 line now — the picture leaves it room, so the card needs no scroll on a phone */
.wcard__pic { width: min(100%, 25vh, 300px); margin: 0 auto; }
.wcard__head { display: flex; align-items: center; gap: var(--s3); margin-top: 14px; padding: 0 var(--s1); }
.wcard__titles { flex: 1; min-width: 0; }
.wcard__word {
  /* a long word gets smaller letters instead of breaking in the middle: --len = letters of its longest part
     (set by the card), --word-room = the width the headword has next to the speaker (and the picture) */
  --word-max: var(--fs-2xl);
  --word-room: calc(min(100vw, 480px) - 128px);
  font-size: clamp(18px, calc(var(--word-room) / (var(--len, 6) * 0.6)), var(--word-max));
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}
.wcard__ipa { margin-top: var(--s1); font-size: var(--fs-md); color: var(--ink-3); }
.wcard__ru { margin-top: var(--s2); padding: 0 var(--s1); font-size: 21px; font-weight: 600; line-height: 1.3; }
.wcard > .sk { margin-top: var(--s3); }

.example { margin-top: var(--s3); padding: 12px 14px; border-radius: var(--r-md); background: var(--bg); }
.example__en { font-size: var(--fs-md); font-weight: 600; line-height: 1.5; }
.example__en mark { background: none; color: var(--accent-ink); font-weight: 800; }
.example__ru { margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-2); }
.example__tip { margin-top: 6px; font-size: 13px; line-height: 1.3; color: var(--ink-3); }
/* the 💡 line: a usage tip in Russian with English bits inside — up to three lines on a 360 px phone */
.mnemo { display: flex; align-items: flex-start; gap: var(--s2); margin-top: var(--s2); padding: 10px 14px; border-radius: var(--r-md); background: var(--amber-tint); color: #5E4310; font-size: var(--fs-sm); line-height: 1.4; text-align: left; }
.mnemo__icon { flex: none; }
.mnemo__text { min-width: 0; overflow-wrap: break-word; }
.mnemo__text b { font-weight: 700; color: #3D2A06; }
.mnemo__text b.is-short { white-space: nowrap; }

.words__actions { position: relative; flex: none; padding: var(--s1) var(--s4) var(--s3); }
.words__actions::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -18px;
  height: 18px;
  background: linear-gradient(to top, var(--bg), rgba(245, 239, 222, 0));
  pointer-events: none;
}
.words__buttons { display: grid; gap: 10px; }
.words__buttons--new { grid-template-columns: 1fr 1.25fr; }
/* «✅ Помню» / «🔁 Ещё не запомнил»: the long label gets the wider column and stays on one line at 360 px */
.words__buttons--review { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
.words__buttons .btn { min-height: 58px; padding: 0 var(--s2); }
.words__hint { margin-top: 10px; font-size: 14px; line-height: 1.35; color: var(--ink-2); text-align: center; }

.done { display: flex; flex-direction: column; align-items: center; text-align: center; }
.done::before { content: ''; flex: 1 1 0; }
.done::after { content: ''; flex: 2 1 0; } /* safe vertical centring, a little above the middle */
/* Ronnie gives way on a lower screen: with «Взять ещё слова» there are four buttons under him */
.done__ronnie { --ronnie-size: clamp(132px, min(68vw, 29vh), 280px); margin-bottom: calc(var(--ronnie-size) * -0.08); }
.done__title { font-size: 26px; font-weight: 800; line-height: 1.15; }
.done__text { margin-top: var(--s2); max-width: 330px; font-size: 16px; line-height: 1.45; color: var(--ink-2); }
.done__stats { width: 100%; margin-top: var(--s5); }
.done__stats .stat { animation: pop-in 0.45s var(--spring) both; }
.done__stats .stat:nth-child(2) { animation-delay: 0.08s; }
.done__stats .stat:nth-child(3) { animation-delay: 0.16s; }
.done__actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin-top: var(--s6); }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }

/* ================= Разговор ================= */
.talk__head { display: flex; align-items: center; gap: var(--s2); padding-top: calc(var(--safe-top) + 6px); padding-bottom: 2px; }
.talk__ronnie { --ronnie-size: 64px; margin: -2px 0 -4px -6px; }
.talk__titles { flex: 1; min-width: 0; }
.talk__titles .title { font-size: 22px; }
.talk__titles .subtitle { margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talk__tochat { position: relative; flex: none; align-self: flex-start; height: 34px; padding: 0 12px; margin-top: 2px; border-radius: 17px; font-size: 14px; font-weight: 700; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line); }
.talk__tochat::after { content: ''; position: absolute; inset: -7px -4px; } /* 48 px touch target */
.talk__tochat:active { transform: scale(0.95); }
.talk__scroll { padding-bottom: var(--s4); }
.talk__notice { margin: var(--s3) auto 0; max-width: 88%; padding: 8px 14px; border-radius: 14px; background: var(--amber-tint); color: #5E4310; font-size: var(--fs-sm); line-height: 1.4; text-align: center; text-wrap: balance; white-space: pre-line; animation: rise 0.24s var(--ease); }
.talk__start { display: flex; justify-content: center; margin-top: var(--s4); }
.chipbtn { min-height: 44px; padding: 0 18px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); font-size: var(--fs-sm); font-weight: 800; color: var(--accent-ink); transition: transform 0.12s var(--ease); }
.chipbtn:active { transform: scale(0.96); }

/* the composer: a text field and one big round button (microphone, or «send» once there is text) */
.composer { position: relative; flex: none; padding: var(--s2) var(--s3) var(--s3); background: var(--bg); }
.composer::before { content: ''; position: absolute; left: 0; right: 0; top: -16px; height: 16px; background: linear-gradient(to top, var(--bg), rgba(245, 239, 222, 0)); pointer-events: none; }
.composer__row { display: flex; align-items: flex-end; gap: var(--s2); }
.composer__input {
  flex: 1;
  min-width: 0;
  /* one line when empty (52 px), two lines at most (76 px), then the text scrolls inside — js/screens/talk.js */
  height: 52px;
  min-height: 52px;
  max-height: 76px;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
  color: var(--ink);
  font: 400 var(--fs-md)/1.4 var(--font);
  resize: none;
  user-select: text;
  -webkit-user-select: text;
  -webkit-appearance: none;
  appearance: none;
}
/* the hint never makes the field taller: one line, cut with «…» if a phone is narrower than expected */
.composer__input::placeholder { color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer__input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.composer__input:focus-visible, .winput:focus-visible { outline: none; } /* the field has its own focus ring */
.composer__btn { position: relative; flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; color: #fff; background: var(--accent); box-shadow: 0 3px 0 var(--accent-deep), 0 8px 18px rgba(216, 87, 74, 0.28); transition: transform 0.12s var(--ease), opacity 0.15s ease; }
.composer__btn:active { transform: translateY(2px) scale(0.96); }
.composer__btn[disabled] { opacity: 0.5; pointer-events: none; }
.composer__btn.is-starting { opacity: 0.7; }
.composer__btn.is-rec { background: var(--green); box-shadow: 0 3px 0 var(--green-deep), 0 8px 18px rgba(76, 154, 106, 0.3); }
.composer__btn.is-rec::before { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 3px var(--green); animation: ping 1.2s ease-out infinite; }
.composer__side { flex: none; display: grid; place-items: center; width: 48px; height: 56px; border-radius: 24px; color: var(--ink-2); }
.composer__rec { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 16px; border-radius: 28px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); }
.composer__dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); animation: wave 1s ease-in-out infinite; }
.composer__time { font-size: var(--fs-md); font-weight: 800; font-variant-numeric: tabular-nums; }
.composer__rechint { min-width: 0; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer__note { margin: 0 var(--s1) var(--s2); padding: 10px 14px; border-radius: var(--r-md); background: var(--amber-tint); color: #5E4310; font-size: var(--fs-sm); line-height: 1.4; animation: rise 0.24s var(--ease); }
.talk__skeleton { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: var(--s2); }
.daysep { display: flex; justify-content: center; margin: var(--s4) 0 var(--s1); }
.daysep:first-child { margin-top: var(--s1); }
.daysep span { padding: 3px 12px; border-radius: 12px; background: var(--bg-deep); font-size: 13px; font-weight: 700; color: var(--ink-2); }

.msg { display: flex; align-items: flex-start; gap: var(--s2); margin-top: var(--s3); }
.msg--me { justify-content: flex-end; }
.msg__col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(86%, 350px); }
.msg--me .msg__col { align-items: flex-end; }
.msg__bubble { padding: 10px 14px; border-radius: 20px 20px 20px 6px; background: var(--surface); box-shadow: var(--shadow-1); }
.msg--me .msg__bubble { border-radius: 20px 20px 6px 20px; background: var(--accent-tint); box-shadow: none; }
.msg__en { font-size: var(--fs-md); line-height: 1.6; overflow-wrap: anywhere; }
.msg--me .msg__en { line-height: 1.45; }
.msg__ru { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); font-size: var(--fs-sm); line-height: 1.4; color: var(--ink-2); animation: rise 0.24s var(--ease); }
.msg__ru--shown { animation: none; } /* the Russian that is under the line from the start (only an asked translation rises in) */
/* «Скажи так: …» — Ronnie's help for a stuck student */
.msg__help { display: flex; align-items: flex-start; gap: 6px; margin-top: var(--s2); padding: 8px 10px; border-radius: 12px; background: var(--amber-tint); color: #5E4310; font-size: var(--fs-sm); line-height: 1.4; overflow-wrap: anywhere; }
.msg__help .ic { margin-top: 2px; color: var(--amber-ink); }
.msg__help span { min-width: 0; }
/* Ronnie asks to write the corrected sentence again: the same look as «ответь текстом», as a whole line */
.msg__bubble--ask { background: var(--amber-tint); box-shadow: none; }
.msg__bubble--ask .msg__en { line-height: 1.5; }
.msg__bubble--ask .msg__ru { border-top-color: rgba(138, 90, 11, 0.22); color: var(--amber-ink); font-weight: 600; }
.msg__bubble--ask .msg__help { background: rgba(255, 253, 247, 0.6); }
.msg__askicon { display: inline-block; vertical-align: -3px; margin-right: 6px; color: var(--amber-ink); }
.msg__target { font-weight: 800; }
.msg__ask { display: flex; align-items: center; gap: 6px; margin-top: var(--s2); padding: 6px 10px; border-radius: 12px; background: var(--amber-tint); color: var(--amber-ink); font-size: 14px; font-weight: 700; line-height: 1.3; }
.msg__via { display: inline-block; vertical-align: -2px; margin-right: 4px; }
.msg.is-pending .msg__bubble { opacity: 0.7; }
.msg.is-failed .msg__bubble { opacity: 1; box-shadow: inset 0 0 0 1.5px var(--accent); }
.msg__fail { margin-top: 6px; padding: 0 var(--s2); font-size: 13.5px; line-height: 1.35; color: var(--accent-ink); text-align: right; } /* why the line did not go */
.msg__bubble--typing { padding: 12px 16px; }
.tool.tool--warn { color: var(--accent-ink); } /* two classes: declared before .tool, must still win over its colour */
.tool[disabled] { opacity: 0.6; pointer-events: none; }
.msg__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 2px; min-height: 36px; margin-top: 2px; }
.msg--me .msg__tools { justify-content: flex-end; }
.msg__tools--bare { min-height: 22px; } /* only the time: a text reply has no «Слушать» */
.msg__time { padding: 0 var(--s2); font-size: 13px; color: var(--ink-3); }
/* «✅ Теперь верно!» under the student's own line: the sentence Ronnie asked to write again is right now */
.msg__ok { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 14px; background: var(--green-tint); color: var(--green-ink); font-size: 13.5px; font-weight: 800; white-space: nowrap; animation: pop-in 0.3s var(--spring); }
/* the student's line and its review are ONE block: a thin dashed frame holds the bubble, the «Разбор» toggle and
   the review card, so it is clear which review belongs to which line */
.msg--turn .msg__col {
  align-items: stretch;
  max-width: min(94%, 380px);
  padding: 6px 6px var(--s2);
  border: 1.5px dashed rgba(177, 63, 52, 0.34);
  border-radius: 24px 24px 12px 24px;
  background: rgba(255, 253, 247, 0.45);
}
.msg--turn .msg__bubble { align-self: flex-end; max-width: 100%; }
.msg--turn .msg__tools { margin-top: 0; }
.msg--turn .fix { margin-top: 0; box-shadow: none; }

.tt mark { background: none; color: var(--accent-ink); font-weight: 800; }
.w { padding: 3px 2px; margin: -3px -2px; border-radius: 7px; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; }
.w:active, .w.is-sel { background: var(--accent-tint); color: var(--accent-ink); }
.w.is-added { text-decoration: underline; text-decoration-color: var(--green); text-decoration-thickness: 2px; text-underline-offset: 4px; }

.tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  border-radius: 17px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.12s var(--ease);
}
.tool::after { content: ''; position: absolute; inset: -7px 0; } /* 48 px touch target */
.tool:active { transform: scale(0.95); }
.tool.is-active { background: var(--grey-tint); color: var(--ink); }
.tool__chev { transition: transform 0.2s var(--ease); }
.tool__chev.is-up { transform: rotate(180deg); }

.fix { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin-top: var(--s1); padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); text-align: left; scroll-margin: var(--s4) 0 var(--s2); /* opens clear of the header's fade */ }
.fix--in { animation: rise 0.24s var(--ease); } /* opened again by hand; from the start it is simply there */
.fix__item { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
.fix__item + .fix__item { padding-top: var(--s3); border-top: 1px solid var(--line); }
.fix__row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.fix__label { font-size: 12.5px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-3); }
.fix__text { font-size: var(--fs-sm); line-height: 1.4; }
.fix__row--said .fix__text { color: var(--ink-2); }
.fix__row--better .fix__label { color: var(--green-ink); }
/* «Лучше»: a calm dark-green sentence, only the words that changed stand out (red, bold) */
.fix__row--better .fix__text { font-size: 16px; font-weight: 500; color: var(--green-ink); }
.fix__row--better .fix__text--whole { font-weight: 700; } /* most of the sentence is new: highlighted as a whole */
.fix__new { font-weight: 800; color: var(--accent-deep); }
/* …and in the student's own sentence the words that were replaced or dropped are softly underlined */
.fix__old { text-decoration: underline; text-decoration-color: rgba(216, 87, 74, 0.55); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* word lookup sheet */
.lookup__top { display: flex; align-items: center; gap: var(--s2); min-height: 124px; }
.lookup__ronnie { --ronnie-size: 116px; margin-left: -10px; }
.lookup__info { flex: 1; min-width: 0; }
.lookup__word { font-size: 30px; font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.lookup__thinking { margin: 6px 0 var(--s2); font-size: 16px; color: var(--ink-2); }
.lookup__ipa { margin-top: 2px; font-size: 16px; color: var(--ink-3); }
.lookup__ru { margin-top: 6px; font-size: 20px; font-weight: 700; line-height: 1.25; }
.lookup__ctx { margin-top: 6px; font-size: 14.5px; line-height: 1.35; color: var(--ink-2); overflow-wrap: anywhere; } /* «в этом предложении: look at — смотреть на» */
.lookup__ctx b { font-weight: 700; color: var(--ink); }
.lookup__from { margin-top: var(--s1); font-size: 14px; color: var(--ink-3); }
.lookup__error { margin-top: var(--s2); font-size: var(--fs-sm); color: var(--accent-ink); }
.lookup__done { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s3); padding: 12px 14px; border-radius: var(--r-md); background: var(--green-tint); color: var(--green-ink); text-align: left; animation: pop-in 0.4s var(--spring); }
.lookup__done b { display: block; font-size: 16px; }
.lookup__done div span { display: block; margin-top: 1px; font-size: 14.5px; line-height: 1.35; }
.lookup__done > div { min-width: 0; }
.lookup__done--queued { background: var(--amber-tint); color: var(--amber-ink); } /* it waits for its day */
.lookup__done--queued .lookup__check { background: var(--amber); }
.lookup__check { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: #fff; }
.lookup__actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin-top: var(--s4); }

/* ================= Словарь ================= */
.dict__titlebar { display: flex; align-items: center; gap: var(--s1); }
.dict__titlebar .title { flex: 1; min-width: 0; }
/* the dictionary is opened from «Слова»: the arrow leads back there */
.dict__back { flex: none; display: grid; place-items: center; width: 40px; height: 44px; margin-left: -10px; border-radius: 22px; color: var(--ink-2); }
.dict__back:active { transform: scale(0.92); }
.dict__count { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.fchips { display: flex; gap: var(--s2); margin-top: var(--s1); }
.fchip { display: inline-flex; align-items: center; height: 48px; }
.fchip span {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 18px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--ink-2);
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s var(--ease);
}
.fchip:active span { transform: scale(0.95); }
.fchip.is-active span { background: var(--ink); color: #fff; box-shadow: none; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); animation: rise 0.3s var(--ease); }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: var(--s2) var(--s2) 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-align: left;
  transition: transform 0.12s var(--ease);
}
.tile:active { transform: scale(0.97); }
.tile__pic { border-radius: 14px; } /* square, like the generated pictures — nothing is cropped */
.tile__pic .pic__letter { font-size: 44px; }
.tile__status { position: absolute; top: 14px; left: 14px; height: 24px; padding: 0 9px; font-size: 12.5px; box-shadow: 0 1px 3px rgba(43, 41, 38, 0.12); }
.tile__lemma { margin: 10px var(--s1) 0; font-size: 18px; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__ru { margin: 2px var(--s1) 0; font-size: var(--fs-sm); line-height: 1.3; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dict__more { margin-top: var(--s4); }

.detail__pic { width: min(100%, 36vh, 300px); margin: 0 auto; }
.detail .example { background: var(--surface); }
.detail__meta { display: flex; align-items: center; gap: 10px; margin: var(--s4) var(--s1) var(--s5); }
.detail__due { font-size: var(--fs-sm); line-height: 1.35; color: var(--ink-2); }

/* ---------- keyframes ---------- */
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.8); } }
@keyframes bubble-pop { from { opacity: 0; transform: translateY(10px) scale(0.6); } }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes boop { 0% { transform: scale(1); } 35% { transform: scale(1.05, 0.95); } 70% { transform: scale(0.98, 1.02); } 100% { transform: scale(1); } }
@keyframes ping { from { transform: scale(1); opacity: 0.6; } to { transform: scale(1.5); opacity: 0; } }
@keyframes wave { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
@keyframes card-out-left { to { opacity: 0; transform: translateX(-40px) rotate(-4deg); } }
@keyframes card-out-right { to { opacity: 0; transform: translateX(40px) rotate(4deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* A short window (Telegram Desktop: about 393×600, a phone with the keyboard up): the word card lies on its
   side — the picture next to the word — so the whole card with its example fits without scrolling. */
@media (max-height: 700px) {
  .words__ronnie { --ronnie-size: 72px; margin: -4px 0 -8px; }
  .wcard { --pic: clamp(104px, 21vh, 132px); display: grid; grid-template-columns: var(--pic) minmax(0, 1fr); column-gap: var(--s3); align-items: center; padding: var(--s3) var(--s3) 14px; }
  .wcard__pic { grid-row: 1 / span 2; width: var(--pic); margin: 0; border-radius: var(--r-md); }
  .wcard__pic .pic__letter { font-size: 52px; }
  .wcard__pic .pic__caption { display: none; }
  .wcard > .wcard__head { grid-column: 2; align-self: end; margin-top: 0; padding: 0; gap: var(--s2); }
  .wcard .wcard__word { --word-max: 28px; --word-room: calc(min(100vw, 480px) - 122px - var(--pic)); }
  .wcard .wcard__ipa { margin-top: 0; font-size: var(--fs-sm); }
  .wcard > .wcard__ru { grid-column: 2; align-self: start; margin-top: 2px; padding: 0; font-size: 18px; }
  .wcard .speaker { width: 46px; height: 46px; }
  .wcard > .example, .wcard > .mnemo, .wcard > .sk { grid-column: 1 / -1; }
  .wcard > .example { margin-top: var(--s3); padding: 10px 12px; }
  .wcard > .mnemo { padding: 8px 12px; }
  .words__buttons .btn { min-height: 52px; }
  .words__hint { margin-top: 6px; font-size: 13px; }
  .hero__ronnie { --ronnie-size: clamp(180px, 56vw, 240px); }
  .hero__bubble-slot { min-height: 72px; }
  /* the «готово» screens: a smaller Ronnie, so the numbers and the first buttons are seen without scrolling */
  .done__ronnie { --ronnie-size: clamp(132px, 27vh, 200px); }
  .done__title { font-size: 24px; }
  .done__stats { margin-top: var(--s3); }
  .done__stats .stat { padding: var(--s2); }
  .done__actions { margin-top: var(--s4); gap: 10px; }
  .done__actions .btn { min-height: 52px; }
  .done__actions .btn--quiet { min-height: 44px; }
}

/* narrow phones (360 px): Ronnie's line in the header of «Разговор» fits next to the «в чат» button */
@media (max-width: 374px) {
  .talk__titles .subtitle { font-size: 13.5px; }
  .tab { font-size: 11px; } /* «Грамматика» keeps a few pixels of air in its fifth of the bar */
  .words__buttons--review .btn { font-size: 16px; } /* «🔁 Ещё не запомнил» keeps to one line with room to spare */
}

/* very small phones */
@media (max-width: 350px) {
  .daycard { padding: var(--s4); gap: var(--s3); }
  .daycard__title { font-size: 20px; }
  .words__buttons .btn { font-size: 15px; }
  .tab { font-size: 10.5px; }
  .tabbar { gap: 0; padding-left: 2px; padding-right: 2px; }
}
