/* Курс языков — страницы. Цвета — переменные в :root: светлая «бумажная» тема, тёмная — по настройке системы.
   Цвета тонов (t1–t5) — одни и те же во всём курсе: в словах, фразах, разговоре и тренажёре тонов. */
:root {
  --bg: #f7f2ea;
  --bg-2: #fffdf9;
  --panel: #fffdf9;
  --soft: #f1e9dd;
  --line: #e5dccd;
  --fg: #221d17;
  --muted: #6f665a;
  --accent: #c93c26;
  --accent-ink: #ffffff;
  --accent-soft: #f7ddd2;
  --jade: #24805f;
  --jade-soft: #dcefe6;
  --warn: #9a5b00;
  --danger: #c0352b;
  --t1: #d23f2a; --t2: #23855f; --t3: #2862c4; --t4: #8a3fc0; --t5: #8b8478;
  --skin: #f1cfb4; --hair: #2a211c; --cheek: #ec9f86; --robe: #24805f;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 24px rgba(60, 40, 20, .06);
  --zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120f;
    --bg-2: #1d1915;
    --panel: #1f1a16;
    --soft: #29231d;
    --line: #352d25;
    --fg: #f3ece2;
    --muted: #a89d8e;
    --accent: #ef6a4f;
    --accent-ink: #1a0d08;
    --accent-soft: #3e2219;
    --jade: #4cc497;
    --jade-soft: #193a2d;
    --warn: #f0b04a;
    --danger: #ff7a6b;
    --t1: #ff7a63; --t2: #4fca9b; --t3: #74a8ff; --t4: #c595f5; --t5: #9b9184;
    --skin: #e8c2a5; --hair: #0f0b09; --cheek: #d98a73; --robe: #2f9a72;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[lang="zh-CN"] { font-family: var(--zh); }
a { color: var(--accent); }
[hidden] { display: none !important; }
h1, h2 { line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 4vw, 38px); margin: 0 0 10px; }
h2 { font-size: 20px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { font-size: 17px; color: var(--muted); max-width: 680px; margin: 0 0 16px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sec { margin: 34px 0 14px; }
.note { font-size: 14px; color: var(--muted); }
.note.warn { color: var(--warn); }
.ico { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* Шапка */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1160px; margin: 0 auto; padding: 14px 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 700; font-size: 18px; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font: 700 19px/1 var(--zh); }
.nav { display: inline-flex; align-items: center; gap: 16px; min-width: 0; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; text-decoration: none; }
.nav-link:hover { color: var(--fg); }
.badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.who-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 30vw; }
.who-tag { padding: 1px 8px; border-radius: 999px; background: var(--jade-soft); color: var(--jade); font-size: 12px; }
.main { max-width: 1160px; margin: 0 auto; padding: 8px 16px 64px; }

/* Кнопки и поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--fg); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-main { border-color: transparent; background: var(--accent); color: var(--accent-ink); }
.btn-main:hover { border-color: transparent; filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; }
button:focus-visible, a:focus-visible, .input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.linkbtn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.linkbtn .ico { width: 16px; height: 16px; }
.linkbtn:hover { color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 6px; }
.input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); color: var(--fg); font: inherit; }
.card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.card.error { border-color: var(--danger); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--fg); font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--muted); }
.toggle[aria-pressed="true"] { border-color: var(--jade); background: var(--jade-soft); color: var(--jade); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 12px; background: var(--fg); color: var(--bg); font-size: 14px; transform: translate(-50%, 140%); transition: transform .25s; }
.toast.show { transform: translate(-50%, 0); }

/* Тоны: цвет слога */
.t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); } .t5 { color: var(--t5); }
.py { font-weight: 500; }
.no-pinyin .chat .zl-py, .no-pinyin .chat .hint-py { display: none; }
.no-translation .chat .zl-ru, .no-translation .chat .hint-ru { filter: blur(5px); cursor: pointer; transition: filter .2s; }
.no-translation .chat .zl-ru:hover, .no-translation .chat .hint-ru:hover { filter: none; }

/* Главная */
.hero { display: grid; grid-template-columns: 220px 1fr; gap: 36px; align-items: center; padding: 28px 0 8px; }
.hero-hi { margin: 0 0 6px; font-size: 18px; color: var(--accent); }
.hero-av .avatar { width: 220px; }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.lesson-card {
  position: relative; display: grid; gap: 4px; height: 100%; padding: 18px 18px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--fg); text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.lesson-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.lesson-card.locked { background: var(--soft); box-shadow: none; }
.lesson-card.done { border-color: var(--jade); }
.lc-n { position: absolute; top: 14px; right: 16px; color: var(--muted); font-weight: 700; }
.lc-zh { font-size: 28px; font-weight: 600; color: var(--accent); }
.lc-title { font-weight: 700; font-size: 17px; }
.lc-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.status .ico { width: 16px; height: 16px; }
.status.ok { color: var(--jade); }
.status.go { color: var(--accent); }
.howto { margin-top: 40px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { padding: 16px 18px; border-radius: var(--radius); background: var(--soft); font-size: 15px; counter-increment: s; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; }

/* Аватар: нарисованный портрет или видео из /avatar/ */
.avatar { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; }
.av-stage { position: absolute; inset: 0; overflow: hidden; border-radius: 50%; background: var(--accent-soft); }
.av-svg { width: 100%; height: 100%; display: block; }
.av-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.av-video.on { opacity: 1; }
/* Говорящий портрет: портрет, поверх — рот нужной формы и моргание (прозрачные картинки того же размера) */
.av-talk { position: absolute; inset: 0; opacity: 0; transform-origin: 50% 85%; transition: opacity .2s, transform .22s ease-out; }
.av-talk.on { opacity: 1; }
.av-t-base, .av-t-part { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; }
.av-t-part { opacity: 0; transition: opacity .06s linear; }
.av-t-part.on { opacity: 1; }
.av-t-blink { transition: none; }
.av-bg { fill: var(--accent-soft); }
.av-hair { fill: var(--hair); }
.av-pin { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.av-skin { fill: var(--skin); }
.av-body { fill: var(--robe); }
.av-collar { fill: none; stroke: #f5e9d8; stroke-width: 4; stroke-linejoin: round; }
.av-eye { fill: var(--hair); transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.av-brow { fill: none; stroke: var(--hair); stroke-width: 3; stroke-linecap: round; }
.av-cheek { fill: var(--cheek); opacity: .45; }
.av-mouth { fill: none; stroke: #9c4a3a; stroke-width: 3.5; stroke-linecap: round; }
.av-mouth-open { fill: #9c4a3a; opacity: 0; transform-box: fill-box; transform-origin: center; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.av-speaking .av-mouth { opacity: 0; }
.av-speaking .av-mouth-open { opacity: 1; animation: talk .32s ease-in-out infinite alternate; }
/* Нарисованный аватар тоже открывает рот по слогам, когда известен текст (data-mouth ставит visemes.js) */
.av-lips .av-mouth-open { animation: none; transition: transform .07s; }
.av-lips[data-mouth="M"] .av-mouth-open { transform: scale(.9, .15); }
.av-lips[data-mouth="half"] .av-mouth-open { transform: scale(.9, .45); }
.av-lips[data-mouth="A"] .av-mouth-open { transform: scale(1, 1.2); }
.av-lips[data-mouth="E"] .av-mouth-open { transform: scale(1.1, .75); }
.av-lips[data-mouth="I"] .av-mouth-open { transform: scale(1.3, .4); }
.av-lips[data-mouth="O"] .av-mouth-open { transform: scale(.75, .95); }
.av-lips[data-mouth="U"] .av-mouth-open { transform: scale(.55, .6); }
@keyframes talk { from { transform: scaleY(.35); } to { transform: scaleY(1.1); } }
.avatar::after { content: ""; position: absolute; inset: -6px; border: 3px solid transparent; border-radius: 50%; transition: border-color .3s; pointer-events: none; }
.av-listening::after { border-color: var(--jade); animation: pulse 1.2s ease-in-out infinite; }
.av-speaking::after { border-color: var(--accent); }
@keyframes pulse { 50% { transform: scale(1.04); opacity: .55; } }
.av-praise .av-stage { animation: hop .5s ease 2; }
.av-praise .av-mouth { d: path("M86 122q14 14 28 0"); }
@keyframes hop { 50% { transform: translateY(-6px) rotate(-2deg); } }
.av-dots { position: absolute; right: 2%; top: 4%; display: none; gap: 4px; padding: 8px 10px; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.av-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite; }
.av-dots i:nth-child(2) { animation-delay: .15s; } .av-dots i:nth-child(3) { animation-delay: .3s; }
.av-thinking .av-dots { display: flex; }
@keyframes dot { 50% { transform: translateY(-4px); opacity: .5; } }

/* Урок */
.lesson-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 12px 0 6px; }
.head-av { width: 150px; }
.back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 12px; color: var(--muted); font-size: 14px; text-decoration: none; }
.back:hover { color: var(--fg); }
.h1-zh { color: var(--accent); font-weight: 600; }
.tabs { display: flex; gap: 6px; margin: 18px 0 20px; padding: 5px; border-radius: 14px; background: var(--soft); width: max-content; max-width: 100%; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--panel); color: var(--fg); box-shadow: var(--shadow); }
.tab-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--line); font-size: 12px; }
.tab[aria-selected="true"] .tab-n { background: var(--accent); color: var(--accent-ink); }
.tab-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 24px; }
.hint-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; }
.hint-line .ico { color: var(--warn); }
.hint-line span { font-weight: 700; }

.words { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.word { position: relative; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.word:hover { border-color: var(--accent); transform: translateY(-1px); }
.word-main { display: grid; justify-items: center; gap: 2px; width: 100%; height: 100%; padding: 16px 10px 14px; border: 0; border-radius: 16px; background: none; color: var(--fg); font: inherit; text-align: center; cursor: pointer; }
.word-main:active { transform: scale(.98); }
.word-mic { position: absolute; top: 6px; right: 6px; display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--jade-soft); color: var(--jade); cursor: pointer; opacity: .75; }
.word-mic:hover, .word-mic:focus-visible { opacity: 1; }
.word-mic .ico { width: 16px; height: 16px; }
.word-zh { font-size: 34px; line-height: 1.25; }
.word-py { font-size: 16px; }
.word-ru { color: var(--muted); font-size: 13px; line-height: 1.35; }

.phrases { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.phrase { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.phrase .zl { flex: 1 1 auto; }
.practice-btn { flex: none; border-color: var(--jade); color: var(--jade); }
.practice-btn .ico { width: 16px; height: 16px; }

/* Тренажёр произношения — панель снизу */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 0 12px; background: rgba(20, 14, 8, 0); transition: background .2s; }
.sheet.open { background: rgba(20, 14, 8, .35); }
.sheet-card { position: relative; width: 100%; max-width: 600px; max-height: 92vh; overflow-y: auto; padding: 22px 20px 18px; border-radius: 22px 22px 0 0; background: var(--panel); box-shadow: 0 -8px 40px rgba(0, 0, 0, .25); transform: translateY(100%); transition: transform .22s ease-out; }
.sheet.open .sheet-card { transform: none; }
.sheet-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.sheet-target { text-align: center; }
.sheet-zh { font-size: 40px; line-height: 1.25; }
.sheet-py { font-size: 20px; }
.sheet-live { display: block; width: 100%; height: 70px; margin: 10px 0 4px; border-radius: 12px; background: var(--soft); color: var(--accent); opacity: .5; transition: opacity .2s; }
.sheet-card.recording .sheet-live { opacity: 1; }
.sheet-status { min-height: 24px; margin: 8px 0; font-weight: 600; text-align: center; }
.syls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.syl { display: grid; justify-items: center; gap: 0; min-width: 76px; padding: 8px 6px 6px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg-2); }
.syl.ok { border-color: var(--jade); }
.syl.tone { border-color: var(--warn); }
.syl.bad { border-color: var(--danger); }
.syl.miss { opacity: .6; }
.syl-zh { font-size: 24px; line-height: 1.2; }
.syl-py { font-size: 14px; }
.syl-heard { color: var(--muted); font-size: 11px; }
.syl-chart { width: 64px; height: 44px; }
.syl-chart polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.syl-chart .ideal { stroke: currentColor; stroke-width: 2; stroke-dasharray: 3 4; opacity: .45; }
.syl-chart .voice { stroke: var(--fg); stroke-width: 3; }
.syl.ok .voice { stroke: var(--jade); }
.syl.tone .voice { stroke: var(--warn); }
.sheet-tips { margin: 10px 0 0; padding-left: 20px; font-size: 14px; }
.sheet-tips li { margin: 4px 0; }
.sheet .actions { justify-content: center; }
.zl-zh { font-size: 22px; line-height: 1.35; }
.zl.big .zl-zh { font-size: 24px; }
.zl-py { display: block; font-size: 15px; }
.zl-ru { color: var(--muted); font-size: 14px; }
.notes { margin-top: 28px; padding: 18px 20px; border-radius: var(--radius); background: var(--soft); }
.notes ul, .notes-list { margin: 0; padding-left: 20px; }
.notes li, .notes-list li { margin: 6px 0; }
.play { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent); cursor: pointer; }
.play:hover { filter: brightness(.96); }
.play .ico { width: 18px; height: 18px; }

/* Разговор */
.gate { max-width: 560px; }
.chat { display: grid; grid-template-columns: 290px minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "side main" "extra main"; gap: 16px 24px; align-items: start; }
.chat-side { grid-area: side; display: grid; gap: 16px; }
.chat-extra { grid-area: extra; display: grid; gap: 10px; justify-items: start; }
.chat-extra p { margin: 0; }
.chat-main { grid-area: main; }
.side-av { width: 190px; margin: 0 auto; }
.scene p:last-child { margin: 0; font-size: 15px; }
.goals { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.goals li { display: flex; align-items: flex-start; gap: 10px; }
.goals li.ok { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--jade); }
.goal-box { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; margin-top: 1px; border: 2px solid var(--line); border-radius: 7px; }
.goals li.ok .goal-box { border-color: var(--jade); background: var(--jade); color: #fff; }
.goal-box .ico { width: 16px; height: 16px; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.done-banner { padding: 14px 16px; border-radius: 16px; background: var(--jade-soft); }
.done-banner p { margin: 0 0 8px; }
.done-title { display: flex; align-items: center; gap: 6px; color: var(--jade); font-weight: 700; font-size: 17px; }

.chat-main { display: flex; flex-direction: column; min-height: min(72vh, 720px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.log { flex: 1 1 auto; display: flex; flex-direction: column; gap: 14px; max-height: 62vh; min-height: 300px; overflow-y: auto; padding: 20px; scroll-behavior: smooth; }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.tutor { align-self: flex-start; }
.msg.learner { align-self: flex-end; align-items: flex-end; }
.bubble { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-radius: 18px; }
.tutor .bubble { border-top-left-radius: 6px; background: var(--soft); }
.learner .bubble { border-top-right-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 18px; }
.bubble.pending { opacity: .6; }
.msg.tutor { gap: 8px; }
/* Подсказка учителя по-русски и фразы, которые нужно сказать */
.bubble.help { background: var(--jade-soft); }
.help-text { margin: 0; font-size: 16px; line-height: 1.45; }
.teach { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; border: 2px solid var(--accent-soft); border-radius: 18px; background: var(--bg-2); }
.teach .zl-zh { font-size: 28px; }
.teach .zl { flex: 1 1 auto; }
.say-it { border-color: var(--jade); color: var(--jade); }
.say-it .ico { width: 16px; height: 16px; }
.stuck { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 0 20px 10px; }
.fix { margin-top: 6px; max-width: 100%; padding: 10px 14px; border: 1px dashed var(--warn); border-radius: 14px; background: var(--bg-2); }
.fix-t { display: flex; align-items: flex-start; gap: 6px; margin: 0 0 6px; color: var(--warn); font-size: 13px; }
.fix-t .ico { width: 16px; height: 16px; margin-top: 2px; }
.fix-line { display: flex; align-items: flex-start; gap: 10px; }
.fix .zl-zh { font-size: 19px; }
.hints { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 20px 10px; }
.hints:empty { display: none; }
.hint { flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 14px; border-radius: 14px; text-align: left; }
.hint [lang="zh-CN"] { font-size: 16px; }
.hint-py { font-size: 12px; }
.hint-ru { color: var(--muted); font-size: 12px; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.composer-input { min-height: 46px; max-height: 140px; resize: none; line-height: 1.4; font-size: 17px; }
.mic, .send { display: inline-grid; place-items: center; flex: none; width: 46px; height: 46px; border: 0; border-radius: 50%; cursor: pointer; }
.mic { display: inline-flex; gap: 2px; width: auto; padding: 0 12px 0 10px; border-radius: 23px; background: var(--jade); color: #fff; }
.mic-l { font-weight: 700; font-size: 15px; }
.mic-ru { border: 2px solid var(--jade); background: var(--panel); color: var(--jade); }
.mic { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mic.on { color: #fff; border-color: transparent; }
.mic.on { background: var(--danger); animation: pulse 1s infinite; }
.send { background: var(--accent); color: var(--accent-ink); }
.mic:disabled, .send:disabled { opacity: .45; cursor: default; }
.composer-status { min-height: 20px; margin: 0; padding: 0 20px 12px; }

/* Тренажёр тонов */
.tone-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tone-card { display: grid; justify-items: center; gap: 4px; padding: 14px 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--fg); font: inherit; text-align: center; cursor: pointer; }
.tone-card b { font-size: 26px; }
.contour { width: 56px; height: 50px; }
.contour path { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.notes-list { margin: 18px 0 0; }
.quiz { margin-top: 30px; max-width: 640px; }
.big-play { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 16px; padding: 12px 20px; border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.tone-opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tone-opt { display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg-2); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer; }
.tone-opt.right { border-color: var(--jade); background: var(--jade-soft); }
.tone-opt.wrong { border-color: var(--danger); }
.quiz-result { min-height: 26px; font-size: 16px; }

/* Повторение */
.seg { display: inline-flex; gap: 4px; margin: 6px 0 16px; padding: 4px; border-radius: 12px; background: var(--soft); }
.seg button { padding: 8px 16px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--fg); box-shadow: var(--shadow); }
.flash { display: grid; justify-items: center; gap: 10px; max-width: 520px; padding: 28px 20px; text-align: center; }
.flash-zh { padding: 0; border: 0; background: none; color: var(--fg); font-family: var(--zh); font-size: 64px; line-height: 1.2; cursor: pointer; }
.flash-answer { display: grid; justify-items: center; gap: 2px; }
.flash-answer .flash-zh { font-size: 44px; cursor: default; }
.flash-py { font-size: 24px; }
.flash-ru { font-size: 18px; }
.flash .actions { justify-content: center; }

/* Телефон */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 16px; text-align: left; }
  .hero-av .avatar { width: 150px; }
  .lesson-head { gap: 14px; align-items: start; }
  .head-av { width: 84px; margin-top: 30px; }
  .chat { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "main" "extra"; gap: 14px; }
  .chat-side { grid-template-columns: 84px 1fr; gap: 10px 14px; align-items: start; }
  .side-av { width: 84px; }
  .chat-side > :not(.side-av):not(.scene) { grid-column: 1 / -1; }
  .goals { font-size: 14px; gap: 6px; }
  .log { max-height: 58vh; padding: 14px; }
  .msg { max-width: 94%; }
  .tone-legend, .tone-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .brand > span:last-child { display: none; }
  .nav { gap: 12px; }
  .words { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-zh { font-size: 30px; }
  .composer { padding: 10px; gap: 8px; }
  .tab { padding: 0 12px; gap: 6px; }
  /* Поле ввода — первой строкой, микрофоны и отправка — под ним */
  .composer { flex-wrap: wrap; }
  .composer-input { order: -1; flex: 1 1 100%; }
  .send { margin-left: auto; }
  .stuck { padding: 0 14px 8px; }
  /* Подсказки ответов и «Застрял?» — одной строкой с прокруткой, чтобы разговору оставалось место */
  .hints, .stuck { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .hints::-webkit-scrollbar, .stuck::-webkit-scrollbar { display: none; }
  .hints > *, .stuck > * { flex: none; }
  .hints-t, .stuck > span { display: none; }
  .tab-n { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
