/* Экран урока: шапка, картинка, текст (слова, пропуски, заливка по буквам), панель плеера, подсказки, настройки.
   Анимации на экране урока — только transform и opacity (и clip-path у одной заливки звучащего слова): раскладку они не трогают. */
.lesson { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); --hdr: calc(52px + var(--safe-t)); }

/* шапка лежит поверх текста — её появление и скрытие текст не сдвигает */
.lhead {
  position: absolute; z-index: 5; top: 0; left: 0; right: 0; height: var(--hdr); padding: var(--safe-t) calc(6px + var(--safe-r)) 0 calc(4px + var(--safe-l));
  display: flex; align-items: center; gap: 2px; background: color-mix(in srgb, var(--bg) 94%, transparent);
  transition: transform .3s cubic-bezier(.2, 0, 0, 1), opacity .22s ease, visibility 0s;
}
.ltitle { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.mode-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 10px 0 14px; border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--fg); font-weight: 600; font-size: 14.5px; white-space: nowrap; margin-right: 2px; }
.mode-btn svg { width: 18px; height: 18px; }
.hide-again { min-height: 36px; padding: 0 10px; font-size: 14px; }
.chrome-hidden .lhead { transform: translate3d(0, -100%, 0); opacity: 0; visibility: hidden; transition: transform .26s cubic-bezier(.4, 0, 1, 1), opacity .2s ease, visibility 0s .26s; pointer-events: none; }

/* строка над текстом с кнопкой «спрятать» справа (когда картинки нет); с картинкой кнопка стоит справа от неё */
.tools-row { flex: none; display: flex; align-items: center; justify-content: flex-end; min-height: calc(var(--hdr) + 46px); padding: var(--hdr) calc(14px + var(--safe-r)) 0 calc(10px + var(--safe-l)); }
.hide-tools { width: 38px; height: 38px; background: color-mix(in srgb, var(--card) 92%, transparent); color: var(--muted);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .25), 0 0 0 1px var(--outline); animation: tools-in .22s ease-out; }
.hide-tools svg { width: 22px; height: 22px; }
.hide-tools:hover:not(:disabled) { background: var(--accent-soft); color: var(--fg); }
.hide-tools.is-on, .hide-tools[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
.hide-tools.is-on:hover:not(:disabled), .hide-tools[aria-expanded="true"]:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); }
@keyframes tools-in { from { opacity: 0; transform: scale(.7); } }
/* окошко режима 2: значение и вертикальный ползунок, правым краем под кнопкой */
.hide-pop { position: fixed; z-index: 65; width: 64px; padding: 10px 6px 12px; display: grid; justify-items: center; gap: 6px; background: var(--card); color: var(--fg);
  border: 1px solid var(--outline); border-radius: 22px; box-shadow: var(--shadow); animation: pop .14s ease-out; transform-origin: var(--ox, 50%) 0%; }
.hide-pop-value { font-weight: 650; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hide-pop-value.is-on { color: var(--accent); }

/* вертикальный ползунок (widgets.js: verticalSlider) */
.vslider { --p: 0; --r: 11px; position: relative; width: 48px; height: 208px; touch-action: none; cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.vs-track { position: absolute; left: 50%; top: var(--r); bottom: var(--r); width: 4px; margin-left: -2px; border-radius: 2px; background: var(--outline); }
.vs-fill { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--p) * 100%); border-radius: 2px; background: var(--accent); }
.vs-dot { position: absolute; left: 50%; width: 4px; height: 4px; margin: 0 0 -2px -2px; border-radius: 50%; background: var(--muted); opacity: .55; }
.vs-dot.is-on { background: var(--on-accent); opacity: .9; }
.vs-thumb { position: absolute; left: 50%; bottom: calc(var(--r) + var(--p) * (100% - 2 * var(--r))); width: calc(2 * var(--r)); height: calc(2 * var(--r)); margin: 0 0 calc(-1 * var(--r)) calc(-1 * var(--r));
  border-radius: 50%; background: var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: transform .12s ease; }
.vs-thumb::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--on-accent); }
.vslider.is-dragging .vs-thumb, .vslider:focus-visible .vs-thumb { transform: scale(1.12); }
.vslider:focus-visible .vs-thumb { box-shadow: 0 0 0 3px var(--accent-soft), 0 1px 4px rgba(0, 0, 0, .3); }

/* картинка: по центру; справа от неё — место под кнопку «спрятать» (img-slot), слева — такая же пустая колонка,
   чтобы картинка оставалась посередине. На узком экране место под кнопку сохраняется за счёт ширины картинки. */
.img-head { flex: none; padding: var(--hdr) calc(16px + var(--safe-r)) 6px calc(16px + var(--safe-l)); display: flex; align-items: flex-start; justify-content: center; }
.img-spacer, .img-slot { flex: 1 1 0; min-width: 0; }
.img-slot { display: flex; justify-content: flex-start; }
.img-head.with-tools .img-slot { min-width: 46px; padding-left: 8px; }
.img-fig { position: relative; flex: 0 1 auto; min-width: 0; margin: 0; max-width: 100%; border-radius: 16px; overflow: hidden; background: var(--card); line-height: 0; }
.img-zoom { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; touch-action: pan-x; }
.img-fig img { display: block; max-width: 100%; max-height: min(26dvh, 220px); width: auto; height: auto; object-fit: contain; }
@media (min-height: 800px) { .img-fig img { max-height: min(30dvh, 300px); } }
/* «скрыть картинку» — в левом верхнем углу: правый край картинки занят соседней кнопкой «спрятать слова» */
.img-hide { position: absolute; top: 6px; left: 6px; width: 34px; height: 34px; background: rgba(0, 0, 0, .5); color: #fff; }
.img-hide:hover:not(:disabled) { background: rgba(0, 0, 0, .7); }
.img-hide svg { width: 18px; height: 18px; }
dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; background: rgba(0, 0, 0, .94); overflow: hidden; }
.viewer-stage { position: absolute; inset: 0; display: grid; place-items: center; touch-action: none; cursor: zoom-in; user-select: none; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; will-change: transform; }
.viewer-close { position: absolute; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); background: rgba(255, 255, 255, .16); color: #fff; z-index: 2; }

/* область текста */
.text-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.text-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; outline: none;
  /* снизу — запас под панель плеера, которая лежит поверх текста (её высота приходит от ResizeObserver в --panel-h) */
  padding: calc(var(--hdr) + 8px) calc(18px + var(--safe-r)) calc(var(--panel-h, 168px) + 14px) calc(18px + var(--safe-l)); }
.lesson.has-image .text-scroll, .lesson.has-tools .text-scroll { padding-top: 8px; }
.text-col { max-width: 760px; margin: 0 auto; }
/* длинный урок: то, что далеко от экрана, браузер не раскладывает и не рисует (размер пока прикидочный, потом запоминается) */
.text-col.is-long .scard { content-visibility: auto; contain-intrinsic-size: auto 118px; }
.text-col.is-long .para { content-visibility: auto; contain-intrinsic-size: auto 260px; }
.note-noparts { font-size: 14px; color: var(--muted); margin-bottom: 14px; }

.w {
  position: relative; display: inline-block; padding: 2px 4px; border-radius: 8px; white-space: nowrap; isolation: isolate; cursor: pointer;
  font-family: var(--font-ko); font-size: var(--ko-size, 20px); line-height: 1.5; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background-color .24s ease;
}
.w:hover:not(.is-label) { background-color: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.w.is-label { font-size: calc(var(--ko-size, 20px) * .78); font-weight: 700; color: var(--accent); cursor: default; padding-left: 4px; padding-right: 8px; }
.w.seeked { background-color: var(--accent-soft); }
.words, .sent { display: flex; flex-wrap: wrap; row-gap: 2px; align-items: baseline; }
.para { display: grid; gap: 6px; }
.para + .para { margin-top: 22px; }
.sent.current .w:not(.is-label), .scard.current .w:not(.is-label) { background-color: var(--accent-soft); }

/* режим 1: карточки предложений */
.scard { display: flex; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 20px; background: var(--card); transition: background-color .26s ease; }
.scard + .scard { margin-top: 10px; }
.scard.current { background: var(--accent-soft); }
.scard.current .w:not(.is-label) { background-color: transparent; }
.scard-play { width: 38px; height: 38px; margin-top: 2px; }
.scard-play svg { width: 20px; height: 20px; }
.scard-main { flex: 1; min-width: 0; }
.scard-tr { margin-top: 6px; color: var(--muted); font-size: clamp(13px, calc(var(--ko-size, 20px) * .75), 24px); line-height: 1.4; padding-left: 4px; }

/* пропуски: место слова занято, текст прозрачен, поверх мягкая «дышащая» плашка (дышит только её прозрачность — это транзит на GPU) */
.seg { transition: color .35s ease; }
.seg.blank { position: relative; color: transparent; border-radius: 7px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--muted) 24%, transparent); }
.seg.blank::after { content: ''; position: absolute; inset: 0; border-radius: 7px; background: var(--muted); opacity: .24; pointer-events: none; }
.lesson.is-playing .seg.blank::after { animation: breath 3.6s ease-in-out infinite; }
@keyframes breath { 50% { opacity: .34; } }
.w.endmode .seg[data-e] { font-weight: 700; color: var(--ec-l); }
:root[data-kind="dark"] .w.endmode .seg[data-e] { color: var(--ec-d); }
.w.endmode .seg[data-e].blank { color: transparent; }
.w.can-reveal { cursor: pointer; }

/* звучащее слово: заливка слева направо по буквам + светлая копия текста поверх */
.w.active .seg[data-e] { color: inherit; }
.w.active > .seg:not(.blank) { color: var(--fg); }
.w .fill { position: absolute; inset: 0; background: var(--accent); z-index: -1; pointer-events: none; clip-path: inset(0 calc(100% - var(--sw, 0px)) 0 0 round 8px); }
.w .ov { position: absolute; left: 4px; right: 4px; top: 2px; white-space: nowrap; color: var(--on-accent); pointer-events: none; clip-path: inset(0 calc(100% - var(--sw, 0px) + 4px) 0 0); }
.w .ov .seg { color: var(--on-accent) !important; }
.w .ov .seg.blank { color: transparent !important; box-shadow: none; }
.w .ov .seg.blank::after { display: none; }

/* панель плеера */
.player-error { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 4px 8px; color: var(--danger); font-size: 14px; font-weight: 500; }
.player-error .btn { min-height: 36px; padding: 0 14px; font-size: 14px; flex: none; }
.panel-wrap { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; transition: transform .3s cubic-bezier(.2, 0, 0, 1), opacity .24s ease, visibility 0s; }
.chrome-hidden .panel-wrap { transform: translate3d(0, 100%, 0); opacity: 0; visibility: hidden; pointer-events: none; transition: transform .26s cubic-bezier(.4, 0, 1, 1), opacity .2s ease, visibility 0s .26s; }
.panel { background: var(--card); border-radius: 28px 28px 0 0; padding: 8px calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l)); box-shadow: 0 -2px 14px rgba(0, 0, 0, .06); }
.panel > * { max-width: 620px; margin-left: auto; margin-right: auto; }
.seek { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 36px; margin: 0 auto; background: transparent; cursor: pointer; touch-action: none; --p: 0%; }
.seek::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--outline) var(--p)); }
.seek::-moz-range-track { height: 5px; border-radius: 3px; background: var(--outline); }
.seek::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7.5px; border-radius: 50%; background: var(--accent); border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.seek::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 0; }
.times { display: flex; justify-content: space-between; padding: 0 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; margin-top: 2px; }
.controls .side { width: 56px; display: grid; place-items: center; flex: none; }
.controls .mid { flex: 1; display: flex; justify-content: space-evenly; align-items: center; }
.speed-btn { min-width: 52px; height: 34px; padding: 0 10px; border: 0; border-radius: 17px; background: var(--accent-soft); color: var(--fg); font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.mid .icon-btn { color: var(--fg); }
.mid .icon-btn svg { width: 26px; height: 26px; }
.repeat-btn.is-on { color: var(--accent); background: var(--accent-soft); }
.repeat-btn:not(.is-on) { color: var(--muted); }
.play-btn { position: relative; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); transition: transform .12s; }
.play-btn:active { transform: scale(.92); }
.play-btn svg { width: 30px; height: 30px; position: relative; }
.play-btn .ring { position: absolute; inset: 0; border-radius: 50%; background: var(--accent); opacity: 0; pointer-events: none; }
.play-btn.is-playing .ring { animation: pulse 1.8s linear infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .35; } to { transform: scale(1.22); opacity: 0; } }
@media (max-width: 360px) { .controls .side { width: 46px; } .mid .icon-btn { width: 40px; } }

.mini-progress { position: absolute; left: calc(18px + var(--safe-l)); right: calc(18px + var(--safe-r)); bottom: calc(6px + var(--safe-b)); height: 2px; border-radius: 1px; background: color-mix(in srgb, var(--muted) 18%, transparent); opacity: 0; transition: opacity .4s ease; pointer-events: none; }
.mini-progress i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left center; background: color-mix(in srgb, var(--accent) 60%, transparent); border-radius: 1px; }
.chrome-hidden .mini-progress { opacity: 1; }

/* подсказки к словам и окончаниям */
.tip { position: fixed; z-index: 70; width: max-content; max-width: min(300px, calc(100vw - 16px)); background: var(--card); color: var(--fg); border: 1px solid var(--outline); border-radius: 18px; box-shadow: var(--shadow); animation: pop .14s ease-out; transform-origin: var(--ox, 50%) var(--oy, 0%); }
.tip-body { display: grid; gap: 8px; padding: 12px 16px; font-size: 15px; line-height: 1.4; }
.tip-word { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tip-literal { font-size: 16px; }
.tip-title { font-size: 17px; font-weight: 650; }
.tip-label { font-size: 12px; color: var(--muted); }
.tip-ending { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14.5px; flex-wrap: wrap; }
.tip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.w.tip-open { background-color: var(--accent-soft); }

/* настройки */
.settings { display: grid; gap: 10px; }
.set-title { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.set-preview { margin: 0; padding: 12px; border-radius: 14px; background: var(--bg); line-height: 1.5; overflow-wrap: anywhere; }
.set-size { display: flex; align-items: center; gap: 10px; }
.set-row { display: flex; flex-wrap: wrap; gap: 8px; }
.set-accents { gap: 14px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; box-shadow: inset 0 0 0 0 transparent; transition: transform .12s; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--card), 0 0 0 6px var(--fg); }
.swatch:active { transform: scale(.92); }
@media (max-height: 520px) { .lesson { --hdr: calc(46px + var(--safe-t)); } }

/* стрелки «страница назад / вперёд» по краям (мышь): между режимами. Не нужны на сенсорных экранах — там свайп. */
.mode-arrow { position: absolute; top: 50%; z-index: 4; width: 36px; height: 56px; margin-top: -28px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 14px; background: color-mix(in srgb, var(--card) 70%, transparent); color: var(--muted); opacity: .55;
  transition: opacity .25s ease, background-color .15s ease, color .15s ease; }
.mode-arrow.is-prev { left: calc(6px + var(--safe-l)); }
.mode-arrow.is-next { right: calc(6px + var(--safe-r)); }
.mode-arrow svg { width: 22px; height: 22px; }
.mode-arrow:hover, .mode-arrow:focus-visible { opacity: 1; background: var(--accent-soft); color: var(--fg); }
.lesson.mouse-idle .mode-arrow:not(:focus-visible) { opacity: 0; }
.lesson.mouse-idle .mode-arrow:hover { opacity: 1; }
@media (hover: none), (pointer: coarse) { .mode-arrow { display: none; } }
@media (hover: hover) and (pointer: fine) {
  .text-scroll { padding-left: calc(48px + var(--safe-l)); padding-right: calc(48px + var(--safe-r)); }
}
