/* Полиглот — стили. Адаптивная раскладка:
   • десктоп/ноутбук — две колонки (видео | материалы), страница не прокручивается, прокручиваются панели;
   • планшет в портрете и телефон — видео сверху, вкладки и материалы под ним (режим «Мини» уменьшает видео);
   • телефон в альбомной ориентации и низкие окна — компактные две колонки.
   Кнопки плеера подстраиваются под ширину видео (container queries), таблицы — под ширину панели. */

:root {
  --bg: #f5f2ec;
  --card: #ffffff;
  --ink: #1d1f24;
  --muted: #6b6f78;
  --line: #e7e1d6;
  --red: #c8102e;
  --red-dark: #a00c24;
  --gold: #f1bf00;
  --gold-soft: #fff5cc;
  --gold-line: #f0d77a;
  --green: #1e8a4c;
  --green-soft: #e6f5ec;
  --bad: #c62828;
  --bad-soft: #fdecee;
  --amber-soft: #fff4dc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 20px rgba(0, 0, 0, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --vh: 1vh;          /* высота экрана; ниже заменяется на dvh — учитывает панели мобильного браузера */
  --bar-h: 56px;      /* высота верхней панели */
  --pad: 20px;        /* поля страницы */
  --gap-y: 18px;      /* вертикальные поля раскладки */
  --reserve: 245px;   /* место под субтитры, кнопки и описание урока под видео */
}
@supports (height: 1dvh) {
  :root { --vh: 1dvh; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  height: calc(100 * var(--vh));
  display: flex;
  flex-direction: column;
  overflow: hidden; /* прокручиваются панели, а не страница */
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
h4 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; background: #fff; font: 600 11px/18px var(--mono); text-align: center; color: var(--muted);
}
[hidden] { display: none !important; }
.es { font-weight: 600; }

/* ================================================================ верхняя панель */
.topbar {
  flex: none; position: relative; z-index: 30; height: var(--bar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 max(var(--pad), env(safe-area-inset-right)) 0 max(var(--pad), env(safe-area-inset-left));
  background: #fff; border-bottom: 1px solid var(--line);
}
.brand {
  flex: none; font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: .01em;
  white-space: nowrap;
}
.brand span {
  font-weight: 700; color: #fff; background: var(--red); border-radius: 6px; padding: 1px 7px; margin-left: 4px;
  box-shadow: inset 0 -3px 0 var(--gold);
}
.lesson-nav { display: flex; gap: 6px; min-width: 0; overflow-x: auto; padding: 5px 5px 4px; scrollbar-width: thin; }
.lesson-btn {
  position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font-weight: 700; font-size: 14px; text-decoration: none;
}
.lesson-btn:hover { border-color: var(--red); color: var(--red); }
.lesson-btn.soon { color: #b5afa4; background: #faf8f4; border-style: dashed; }
.lesson-btn[aria-current="true"] { background: var(--red); border-color: var(--red); color: #fff; border-style: solid; }
.lesson-btn.good::after, .lesson-btn.mid::after, .lesson-btn.low::after {
  content: ""; position: absolute; left: 7px; right: 7px; bottom: 3px; height: 3px; border-radius: 2px;
}
.lesson-btn.good::after { background: var(--green); }
.lesson-btn.mid::after { background: var(--gold); }
.lesson-btn.low::after { background: var(--bad); }
/* пройденный урок — зелёная галочка в углу; текущий (с которого продолжать) — золотая рамка */
.lesson-btn.done::before {
  content: "✓"; position: absolute; top: -5px; right: -5px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--green); color: #fff; font: 800 9px/14px var(--font); text-align: center;
  box-shadow: 0 0 0 1.5px #fff;
}
.lesson-btn.current { box-shadow: 0 0 0 2px var(--gold); border-color: var(--gold); }
.lesson-btn.current[aria-current="true"] { border-color: var(--red); }
.lesson-select {
  display: none; margin-left: auto; min-width: 0; max-width: 60%;
  padding: 7px 30px 7px 12px; border: 1px solid var(--line); border-radius: 9px; background-color: #fff;
  font: 600 15px var(--font); color: var(--ink);
}

/* ================================================================ раскладка */
.layout {
  flex: 1; min-height: 0; width: 100%; max-width: 1640px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, 1fr); gap: var(--pad);
  padding: var(--gap-y) max(var(--pad), env(safe-area-inset-right)) var(--gap-y) max(var(--pad), env(safe-area-inset-left));
}
.stage { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.stage-inner {
  --video-h: calc(100 * var(--vh) - var(--bar-h) - 2 * var(--gap-y) - var(--reserve));
  container: stage / inline-size;
  width: 100%;
  max-width: max(300px, calc(var(--video-h) * 4 / 3));
  margin: 0 auto;
}
.panel {
  container: panel / inline-size;
  min-height: 0; display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}

/* ================================================================ видео */
.video-box {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
video { display: block; width: 100%; height: 100%; background: #000; }
.video-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 8px;
  padding: 16px; background: rgba(20, 20, 24, .92); color: #fff; text-align: center; font-size: 14px;
}
.video-msg span { color: #c9c9cf; }
.subline {
  margin-top: 10px; min-height: 52px; padding: 7px 14px; border-radius: 10px; background: #17181c; color: #fff;
  font-size: 16px; line-height: 1.45; text-align: center; display: flex; align-items: center; justify-content: center;
}
.subline:empty { background: #ebe6dc; }
.subline.off { display: none; }

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; }
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px;
  padding: 6px 11px; font: 600 13px/1.2 var(--font); cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #cfc6b6; background: #fffdf8; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }
.btn.big { padding: 11px 22px; font-size: 15px; }
.speed { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.speed button {
  border: 0; background: transparent; padding: 6px 9px; font: 600 12px/1.2 var(--font); color: var(--muted); cursor: pointer;
}
.speed button + button { border-left: 1px solid var(--line); }
.speed button.on { background: var(--ink); color: #fff; }
.speed-cycle { display: none; min-width: 46px; }
.mini-toggle { display: none; }
.mini-toggle[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }

/* кнопки плеера по ширине видео */
@container stage (max-width: 700px) {
  .controls .lbl { display: none; }
  .controls [data-act="prev"], .controls [data-act="next"] { min-width: 38px; }
}
@container stage (max-width: 600px) {
  .controls .lbl-r { display: none; }
  .controls [data-act="repeat"] { min-width: 38px; }
  .speed { display: none; }
  .speed-cycle { display: inline-flex; }
}
@container stage (max-width: 520px) {
  .subline { min-height: 0; font-size: 14.5px; padding: 6px 12px; }
}
@container stage (max-width: 480px) {
  .subs-toggle { display: none; }
}
@container stage (max-width: 400px) {
  .controls { gap: 4px; }
  .controls .btn { padding: 6px 8px; }
  .controls [data-act="prev"], .controls [data-act="next"], .controls [data-act="repeat"] { min-width: 36px; }
  .speed-cycle { min-width: 42px; }
}
@container stage (max-width: 330px) {
  .controls .skip-btn { display: none; }
}

.lesson-info { margin-top: 14px; font-size: 14px; }
.li-title { font-weight: 800; font-size: 16px; line-height: 1.35; margin: 0; letter-spacing: 0; }
.li-topic { color: var(--muted); margin-top: 2px; }
.li-now { margin-top: 8px; min-height: 22px; }
.li-keys { margin-top: 10px; color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.li-nav { margin-top: 10px; font-size: 13px; color: var(--muted); }
.li-nav a, .pane-pager a { color: var(--red); font-weight: 700; text-decoration: none; white-space: nowrap; }
.li-nav a:hover, .pane-pager a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* строка прогресса урока: «Просмотрено 37 % · Тесты: 80 %» и отметка «пройден» */
.lesson-progress {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px;
  margin-top: 10px; font-size: 13px; color: var(--muted);
}
.lesson-progress:empty { display: none; }
.lp-stat { font-weight: 600; white-space: nowrap; }
.lp-done { padding: 5px 10px; font-size: 12.5px; }
.lp-done.on { background: var(--green-soft); border-color: #b8e2c8; color: var(--green); }
.lp-done.on:hover:not(:disabled) { background: #d9f0e2; border-color: #9fd6b4; }
.lp-next { font-weight: 700; color: var(--red); text-decoration: none; white-space: nowrap; }
.lp-next:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ================================================================ ссылки-тайм-коды */
.tchip {
  display: inline-flex; align-items: center; gap: 5px; padding: 0 8px 0 7px; height: 22px; border-radius: 999px;
  background: var(--gold-soft); border: 1px solid var(--gold-line); color: #6b4e00;
  font: 600 12px/20px var(--mono); text-decoration: none; white-space: nowrap; vertical-align: 1px; cursor: pointer;
}
.tchip::before {
  content: ""; width: 0; height: 0; border-left: 7px solid currentColor;
  border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent;
}
.tchip:hover { background: var(--gold); border-color: var(--gold); color: #2a2000; }
.tchip.big { height: 30px; padding: 0 12px 0 10px; font: 600 13px/28px var(--font); white-space: normal; }

/* ================================================================ вкладки */
.tabs {
  flex: none; display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
/* строка вкладок + кнопка «развернуть панель на весь экран» (удобно для тестов и текста на телефоне) */
.tabs-row { flex: none; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.tabs-row .tabs { flex: 1; min-width: 0; border-bottom: 0; }
.panel-expand {
  flex: none; appearance: none; border: 0; border-left: 1px solid var(--line); background: none; cursor: pointer;
  width: 46px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.panel-expand:hover { color: var(--ink); }
.panel-expand:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.panel-expand svg { width: 20px; height: 20px; }
.panel-expand .ic-collapse { display: none; }
body.panel-full { overflow: hidden; }
body.panel-full .panel-expand { color: var(--red); }
body.panel-full .panel-expand .ic-expand { display: none; }
body.panel-full .panel-expand .ic-collapse { display: block; }
body.panel-full .panel {
  position: fixed; inset: 0; z-index: 40; height: 100%; height: 100dvh; border-radius: 0; box-shadow: none;
  align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
body.panel-full .panel > * { width: 100%; max-width: 980px; }
.tabs button {
  appearance: none; border: 0; background: none; padding: 13px 13px 11px; font: 700 14px/1 var(--font); color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--red); border-bottom-color: var(--red); }
.t-short { display: none; }
.pane {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 22px 28px;
}
.pane-head { margin-bottom: 12px; }
.pane-tools {
  position: sticky; top: -16px; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: -16px -22px 10px; padding: 12px 22px; background: #fff; border-bottom: 1px solid var(--line);
}
.search {
  flex: 1 1 200px; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px;
  font: 15px var(--font); background: #fbfaf7;
}
.search:focus { outline: 2px solid var(--gold); border-color: var(--gold); background: #fff; }
.hint { color: var(--muted); font-size: 13px; }
.footnote { margin-top: 22px; color: var(--muted); font-size: 12px; }
.empty { padding: 30px 6px; }

/* ================================================================ оглавление */
.toc { list-style: none; margin: 0; padding: 0; }
.toc-item {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: baseline;
  padding: 8px 10px; border-radius: 9px; color: var(--ink); text-decoration: none;
}
.toc-item:hover { background: #faf6ec; }
.toc-time { font: 600 13px var(--mono); color: #8a6a00; }
.toc-dur { font-size: 12px; color: var(--muted); white-space: nowrap; }
.toc li.current .toc-item { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--red); }
.toc li.current .toc-title { font-weight: 700; }

/* ================================================================ текст урока */
.transcript { font-size: 15.5px; line-height: 1.7; overflow-wrap: break-word; }
.para { margin: 0 0 14px; }
.para-time { margin-right: 8px; }
.seg { cursor: pointer; border-radius: 4px; padding: 1px 0; transition: background-color .15s; }
.seg:hover { background: #f3eee2; }
.seg.active { background: var(--gold-soft); box-shadow: 0 0 0 2px var(--gold-soft); }
.seg.hit { background: #ffe58a; }
.seg.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: var(--gold); } 100% { background: transparent; } }
.transcript.no-caps .cap { display: none; }
.search-results {
  margin: 0 0 14px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fbfaf7;
  max-height: 40%; overflow: auto;
}
.sr-count { font-size: 12px; color: var(--muted); padding: 2px 6px 6px; }
.sr-item {
  display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 5px 6px; border-radius: 7px;
  color: var(--ink); text-decoration: none; font-size: 14px;
}
.sr-item:hover { background: #fff; }
.sr-time { font: 600 12px var(--mono); color: #8a6a00; padding-top: 2px; }
mark { background: #ffe58a; border-radius: 3px; padding: 0 1px; }

/* ================================================================ карточки «На экране» */
.cap {
  margin: 4px 0 16px; padding: 10px 14px; border-radius: 10px; border: 1px solid #ecdcb0;
  background: #fffdf6;
}
.cap-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.cap-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--red); }
.cap-title { font-weight: 800; }
.cap-rows { border-collapse: collapse; width: 100%; }
.cap-rows td { padding: 2px 10px 2px 0; vertical-align: top; }
.cap-rows td.es { width: 46%; }
.cap-rows.multi td.es { width: auto; padding-right: 22px; }   /* таблица из нескольких испанских столбцов */
.cap-rows.multi tr:first-child td { font-weight: 800; }        /* первая строка — инфинитивы-заголовки */
.cap-lines div { padding: 1px 0; }
.cap-rule .cap-lines { font-weight: 600; }
.cap-note { margin-top: 6px; font-size: 12.5px; color: var(--muted); font-style: italic; }
.cap-credits { font-size: 13.5px; }

/* ================================================================ словарь */
.vsec { margin-bottom: 22px; }
.vsec details > summary { list-style: none; cursor: pointer; }
.vsec details > summary::-webkit-details-marker { display: none; }
.vsec details > summary h3::after { content: " ▾"; }
.vt { width: 100%; border-collapse: collapse; }
.vt tr { border-bottom: 1px solid #f0ebe1; }
.vt td { padding: 6px 8px 6px 0; vertical-align: top; }
.vt td.es { width: 40%; }
.vt td.vt-t { width: 1%; text-align: right; padding-right: 0; }
.vt .note { color: var(--muted); font-size: 13px; }
.verbs { display: flex; flex-direction: column; gap: 6px; }
.verb { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.verb > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 9px 0; cursor: pointer; list-style: none;
}
.verb > summary::-webkit-details-marker { display: none; }
.verb > summary::before { content: "▸"; color: var(--muted); width: 10px; }
.verb[open] > summary::before { content: "▾"; }
.verb-inf { font-size: 16px; }
.verb-tense { font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.verb-tense.past { color: var(--red); border-color: currentColor; }
.verb-ru { color: var(--muted); flex: 1; min-width: 120px; }
.verb-links { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.verb .conj { margin: 0 0 6px; }
.verb .note { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }

/* ================================================================ тесты: настройки */
.qs-head { margin-bottom: 4px; }
.qs-stats { color: var(--green); font-weight: 600; }
.qs-cats { display: flex; flex-direction: column; gap: 6px; }
.qs-cat {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff;
}
.qs-cat:hover { border-color: #d8cdb8; }
.qs-cat.disabled { opacity: .5; cursor: default; }
.qs-cat input { width: 17px; height: 17px; margin: 0; accent-color: var(--red); }
.qs-cat-main { display: flex; flex-direction: column; min-width: 0; }
.qs-cat-title { font-weight: 700; }
.qs-cat-hint { font-size: 12.5px; color: var(--muted); }
.qs-cat-count {
  font: 600 12px var(--mono); color: var(--muted); background: #f4f1ea; border-radius: 999px; padding: 2px 8px;
}
.seg-ctl { display: inline-flex; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg-ctl button {
  border: 0; background: none; padding: 8px 14px; font: 600 13px var(--font); color: var(--muted); cursor: pointer;
}
.seg-ctl button + button { border-left: 1px solid var(--line); }
.seg-ctl button.on { background: var(--ink); color: #fff; }
.qs-start { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 22px; font-size: 13px; }

/* ================================================================ тесты: вопрос */
.q-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.q-count { font-weight: 700; color: var(--ink); }
.q-cat { flex: 1; }
.linkbtn {
  border: 0; background: none; padding: 0; font: 600 13px var(--font); color: var(--red); cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.linkbtn:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.q-bar { height: 5px; background: #efe9dd; border-radius: 3px; margin: 8px 0 18px; overflow: hidden; }
.q-bar i { display: block; height: 100%; background: var(--red); border-radius: 3px; transition: width .3s; }
.q-prompt { font-size: 20px; line-height: 1.4; font-weight: 600; margin-bottom: 4px; overflow-wrap: break-word; }
.q-prompt .es { color: var(--red-dark); }
.q-sub { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.q-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; font: 15px/1.4 var(--font); color: var(--ink); cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--red); background: #fffafa; }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled:not(.right):not(.wrong) { opacity: .6; }
.q-form { display: flex; gap: 8px; margin-top: 16px; }
.q-input {
  flex: 1; min-width: 0; padding: 11px 14px; border: 1px solid #d9d1c2; border-radius: 10px; font: 18px var(--font); background: #fff;
}
.q-input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.q-input.right { border-color: var(--green); background: var(--green-soft); }
.q-input.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q-input.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
/* 9 клавиш всегда в один ряд: на узком экране они делят ширину поровну */
.accents { display: grid; grid-template-columns: repeat(9, minmax(0, 40px)); gap: 5px; margin-top: 8px; }
.acc {
  width: 100%; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fbfaf7;
  font: 600 16px var(--font); cursor: pointer; color: var(--ink);
}
.acc:hover:not(:disabled) { background: var(--gold-soft); border-color: var(--gold-line); }
.q-help { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; margin-top: 10px; font-size: 13px; }
.q-feedback { margin-top: 18px; padding: 13px 15px; border-radius: 10px; border: 1px solid var(--line); overflow-wrap: break-word; }
.q-feedback.ok { background: var(--green-soft); border-color: #b8e2c8; }
.q-feedback.almost { background: var(--amber-soft); border-color: #f2d899; }
.q-feedback.bad { background: var(--bad-soft); border-color: #f3c3c8; }
.fb-title { font-weight: 800; margin-bottom: 4px; }
.q-feedback.ok .fb-title { color: var(--green); }
.q-feedback.bad .fb-title { color: var(--bad); }
.q-feedback.almost .fb-title { color: #8a5a00; }
.fb-answer, .fb-given { font-size: 16px; }
.fb-explain { margin-top: 6px; color: #3d4048; }
.fb-link { margin-top: 10px; }
.q-next { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; }

/* ================================================================ тесты: результат */
.q-result { display: flex; align-items: center; gap: 20px; margin: 6px 0 10px; }
.ring {
  --p: 0; flex: none; width: 104px; height: 104px; border-radius: 50%;
  background: conic-gradient(var(--red) calc(var(--p) * 1%), #efe9dd 0);
  display: grid; place-items: center;
}
.ring span {
  width: 80px; height: 80px; border-radius: 50%; background: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 22px;
}
.qr-text h2 { font-size: 24px; }
.mistakes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mistakes li { padding: 10px 12px; border: 1px solid #f3c3c8; border-radius: 10px; background: #fffafa; overflow-wrap: break-word; }
.mistakes.soft li { border-color: #f2d899; background: #fffbf0; }
.m-q { font-weight: 600; }
.m-a { margin: 3px 0 6px; }
.m-given { color: var(--bad); text-decoration: line-through; }
.mistakes.soft .m-given { color: #8a5a00; text-decoration: none; }
.qr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

/* ================================================================ материалы по ширине панели */
@container panel (max-width: 520px) {
  .pane { padding: 14px 14px 28px; }
  /* на узкой панели поиск не закрепляется — уезжает вместе с текстом и не отнимает место */
  .pane-tools { position: static; margin: -14px -14px 10px; padding: 10px 14px; gap: 8px 12px; }
  .pane-tools .toggle { font-size: 12.5px; }
  .transcript { font-size: 15px; line-height: 1.65; }
  /* словарь: испанский и время в строку, перевод под ними */
  .vt:not(.conj) tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; padding: 7px 0; }
  .vt:not(.conj) td { padding: 0; width: auto; }
  .vt:not(.conj) td.es { grid-column: 1; grid-row: 1; }
  .vt:not(.conj) td:nth-child(2) { grid-column: 1; grid-row: 2; color: #3d4048; }
  .vt:not(.conj) td.vt-t { grid-column: 2; grid-row: 1 / span 2; align-self: center; width: auto; }
  .verb-ru { flex-basis: 100%; order: 2; }
  .verb-links { order: 3; padding-bottom: 2px; }
  .q-prompt { font-size: 18px; }
  .q-result { flex-direction: column; align-items: flex-start; gap: 12px; }
  .seg-ctl { display: flex; width: 100%; }
  .seg-ctl button { flex: 1 1 0; padding: 9px 6px; white-space: normal; }
  .qs-start .btn.big { width: 100%; }
}
@container panel (max-width: 400px) {
  .toc-item { grid-template-columns: 48px 1fr; gap: 8px; padding: 8px 6px; }
  .toc-dur { display: none; }
  .cap { padding: 9px 11px; }
  .cap-rows td.es { width: 50%; }
  .q-form { flex-wrap: wrap; }
  .q-form .btn { flex: 1 1 100%; padding: 10px; }
  .qs-cat { padding: 9px 10px; gap: 8px; }
}

/* ================================================================ уведомление */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px;
  width: max-content; max-width: calc(100vw - 24px); padding: 10px 16px; border-radius: 12px;
  background: #1d1f24; color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-size: 14px;
}

/* ================================================================ фокус */
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px;
}

/* ================================================================ невысокие экраны с двумя колонками */
@media (max-height: 820px) {
  :root { --reserve: 200px; }
  .li-topic, .li-keys { display: none; }
}
@media (max-height: 680px) {
  :root { --reserve: 150px; --gap-y: 12px; }
  .lesson-info { display: none; }
  .subline { min-height: 0; }
}

/* ================================================================ одна колонка: телефон и планшет в портрете */
@media (max-width: 899px) and (min-height: 561px), (orientation: portrait) and (max-width: 1199px) {
  :root { --bar-h: 52px; --pad: 12px; }
  .layout { display: flex; flex-direction: column; gap: 0; padding: 0; max-width: none; }
  .stage {
    flex: none; overflow: visible;
    padding: 10px max(var(--pad), env(safe-area-inset-right)) 8px max(var(--pad), env(safe-area-inset-left));
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  /* видео ограничено по высоте, а субтитры и кнопки — во всю ширину */
  .stage-inner { --video-h: calc(30 * var(--vh)); max-width: 820px; }
  .video-box { max-width: calc(var(--video-h) * 4 / 3); margin: 0 auto; border-radius: 10px; }
  .subline {
    display: block; margin-top: 8px; min-height: 0; height: 30px; padding: 5px 12px; border-radius: 8px;
    font-size: 14px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .subline.off { display: none; }
  .controls { margin-top: 8px; }
  .lesson-info { display: none; }
  .mini-toggle { display: inline-flex; }
  .panel { flex: 1; border-radius: 0; box-shadow: none; }
  .tabs { padding: 0; gap: 0; }
  .tabs button { flex: 1 1 0; padding: 13px 6px 11px; font-size: 14px; }
  .pane { padding-bottom: max(28px, env(safe-area-inset-bottom)); }

  /* мини-видео: маленькое видео и текст текущей фразы рядом */
  .stage.mini .stage-inner {
    max-width: 760px; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px;
  }
  .stage.mini .video-box { grid-row: 1; grid-column: 1; width: calc(15 * var(--vh) * 4 / 3); max-width: 42vw; margin: 0; }
  .stage.mini .subline {
    grid-row: 1; grid-column: 2; align-self: stretch; height: auto; margin: 0;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; white-space: normal;
    text-align: left; font-size: 14px; line-height: 1.4;
  }
  .stage.mini .subline:empty { display: block; }
  .stage.mini .controls { grid-row: 2; grid-column: 1 / -1; }
}
/* планшет в портрете — видео крупнее */
@media (orientation: portrait) and (min-width: 600px) and (max-width: 1199px) {
  .stage-inner { --video-h: calc(38 * var(--vh)); }
  .stage.mini .video-box { width: calc(17 * var(--vh) * 4 / 3); }
}
/* лента уроков в шапке: компактнее на планшетах, на узких экранах — выпадающий список */
@media (max-width: 899px) {
  .lesson-nav { gap: 4px; }
  .lesson-btn { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
  .topbar { gap: 12px; }
}
@media (max-width: 799px) {
  .brand span { display: none; }
}
@media (max-width: 699px) {
  .lesson-nav { display: none; }
  .lesson-select { display: block; }
  .brand span { display: none; }
}
@media (max-width: 400px) {
  .t-long { display: none; }
  .t-short { display: inline; }
  .tabs button { font-size: 13.5px; }
}

/* ================================================================ телефон в альбомной ориентации и низкие окна */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --bar-h: 44px; --pad: 10px; --gap-y: 0px; --reserve: 92px; }
  .topbar { gap: 12px; }
  .brand { font-size: 16px; }
  .lesson-btn { width: 30px; height: 30px; font-size: 13px; }
  .layout {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 0;
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); max-width: none;
  }
  .stage { padding: 8px var(--pad); border-right: 1px solid var(--line); }
  .stage-inner { --video-h: calc(100 * var(--vh) - var(--bar-h) - 16px - var(--reserve)); }
  .video-box { border-radius: 8px; }
  .subline {
    display: block; margin-top: 6px; min-height: 0; height: 28px; padding: 4px 10px; border-radius: 8px;
    font-size: 13.5px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .subline.off { display: none; }
  .controls { margin-top: 6px; }
  .lesson-info { display: none; }
  .panel { border-radius: 0; box-shadow: none; }
  .tabs button { padding: 11px 10px 9px; font-size: 13.5px; }
  .pane-tools { position: static; }
}

/* ================================================================ сенсорные экраны */
@media (pointer: coarse) {
  .btn { min-height: 38px; }
  .speed button { min-height: 36px; }
  .tchip { height: 28px; padding: 0 11px 0 9px; font-size: 13px; line-height: 26px; }
  .tchip.big { height: 34px; }
  .opt { padding: 13px 14px; }
  .acc { height: 40px; }
  .seg-ctl button { min-height: 40px; }
  .li-keys, .kbd-hint { display: none !important; }
}
@media (hover: none) {
  .seg:hover, .toc-item:hover, .sr-item:hover { background: none; }
  .toc li.current .toc-item { background: var(--gold-soft); }
}

/* ================================================================ страница урока: дополнения */
/* статическая версия материалов (видна до запуска скриптов и поисковикам) */
.pane-pager {
  margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--line); text-align: center;
  font-size: 13px; color: var(--muted);
}
.tx-h {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: 18px 0 8px;
  font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink);
}
.ssr-text .para { margin: 0 0 12px; }
.vt th {
  padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); text-align: left;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
@container panel (max-width: 520px) {
  .vt thead { display: none; }
}
@media (max-width: 899px) and (min-height: 561px), (orientation: portrait) and (max-width: 1199px) {
  .lesson-progress { margin-top: 8px; gap: 4px 10px; font-size: 12.5px; }
  .stage.mini .lesson-progress { grid-row: 3; grid-column: 1 / -1; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .lesson-progress { margin-top: 6px; }
}

/* ================================================================ главная и 404: обычная прокручиваемая страница */
body.page-home { height: auto; min-height: 100%; display: block; overflow: visible; }
.page-home .topbar { position: sticky; top: 0; }
.page-home section[id] { scroll-margin-top: calc(var(--bar-h) + 10px); }
.home-links { display: flex; gap: 6px 18px; margin-left: auto; min-width: 0; }
.home-links a { color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.home-links a:hover { color: var(--red); }
a.btn { text-decoration: none; }
.home {
  width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 26px max(var(--pad), env(safe-area-inset-right)) 10px max(var(--pad), env(safe-area-inset-left));
}
.hero {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, 1fr); gap: 28px; align-items: center;
}
.hero h1 { font-size: clamp(27px, 3.6vw, 40px); line-height: 1.15; margin: 0 0 14px; letter-spacing: -.01em; }
.hero p { font-size: 16px; line-height: 1.6; color: #33363d; }
.hero .lead { font-size: 18px; color: var(--ink); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.progress-box { padding: 18px 20px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.pb-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.pb-title { font-weight: 800; font-size: 16px; }
.pb-count { font-weight: 700; color: var(--green); }
.pbar { height: 10px; margin: 12px 0 10px; border-radius: 6px; background: #efe9dd; overflow: hidden; }
.pbar i { display: block; width: 0; height: 100%; border-radius: 6px; background: var(--green); transition: width .4s; }
.pb-note { margin: 0; font-size: 13px; color: var(--muted); }

.lessons h2, .about h2 { font-size: 24px; margin: 38px 0 14px; }
.lcards {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px;
}
.lcard { min-width: 0; }
.lc-link {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
a.lc-link:hover { border-color: var(--red); box-shadow: 0 2px 4px rgba(0, 0, 0, .06), 0 10px 26px rgba(0, 0, 0, .1); }
.lcard.is-current .lc-link { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), var(--shadow); }
.lc-img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: #d9d4ca; }
.lc-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px 14px 14px; }
.lc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lc-title { margin: 0; font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.lc-dur { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.lc-topic {
  font-size: 13.5px; line-height: 1.45; color: #3d4048; overflow-wrap: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden;
}
.lc-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 22px; }
.lc-status { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.lc-status:empty { display: none; }
.lc-status.done { background: var(--green-soft); color: var(--green); }
.lc-status.done::before { content: "✓ "; }
.lc-status.current { background: var(--red); color: #fff; }
.lc-status.started { background: var(--gold-soft); color: #6b4e00; }
.lc-status.new { background: #f1ede5; color: var(--muted); }
.lc-quiz { font-size: 12px; color: var(--muted); white-space: nowrap; }
.lc-bar { display: block; height: 4px; border-radius: 3px; background: #efe9dd; overflow: hidden; }
.lc-bar i { display: block; width: 0; height: 100%; background: var(--gold); }
.lcard.is-done .lc-bar i { background: var(--green); }
.lcard.soon .lc-link { opacity: .6; }

.about p { max-width: 820px; margin: 0 0 12px; font-size: 16px; line-height: 1.65; }
.site-footer {
  max-width: 1180px; margin: 40px auto 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
  padding: 18px max(var(--pad), env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left));
}
.site-footer p { margin: 0 0 8px; }
.hero-404 { grid-template-columns: minmax(0, 1fr); padding: 30px 0 0; }
.links-404 { columns: 2 280px; column-gap: 28px; margin: 0; padding-left: 20px; }
.links-404 li { margin: 0 0 6px; break-inside: avoid; }
.links-404 a { color: var(--ink); }

@media (max-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .hero .lead { font-size: 17px; }
  .home { padding-top: 18px; }
  .lessons h2, .about h2 { font-size: 21px; margin-top: 30px; }
}
/* телефон: карточки уроков — строкой, картинка слева */
@media (max-width: 560px) {
  .home-links { gap: 14px; }
  .lcards { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .lc-link { flex-direction: row; }
  .lc-img { flex: none; width: 36%; max-width: 160px; height: auto; align-self: stretch; aspect-ratio: auto; min-height: 96px; }
  .lc-body { padding: 10px 12px 12px; gap: 5px; }
  .lc-title { font-size: 16px; }
  .lc-topic { font-size: 13px; -webkit-line-clamp: 3; line-clamp: 3; }
  .hero-actions .btn { flex: 1 1 auto; }
  .about p { font-size: 15.5px; }
}
@media (max-width: 380px) {
  .home-links a:last-child { display: none; }
}

/* ================================================================ меньше анимации */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
