/* Учебник: страница объяснения (часть урока, весь материал урока, шпаргалка при тренировке) */
:root {
  --paper: #fffdf9; --raise: #ffffff; --shadow: 0 1px 2px rgba(30, 40, 60, .06), 0 8px 24px rgba(30, 40, 60, .07);
  --k-dialogue: #2f6fe0; --k-phrases: #12915c; --k-grammar: #c9770a;
  --t0: #e6efff; --t1: #e3f6ea; --t2: #fff0d9; --t3: #fde7ef; --t4: #ece8ff; --t5: #dff4f6;
  --bubble-a: #eef2f7; --bubble-b: #dfeaff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #f4efe6; --raise: #232a33; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .28);
    --k-dialogue: #7fb0ff; --k-phrases: #6fd3a2; --k-grammar: #f0b860;
    --t0: #22314c; --t1: #1d3a2f; --t2: #40331c; --t3: #41273320; --t4: #2f2b52; --t5: #1c3a40;
    --bubble-a: #262e38; --bubble-b: #223656;
  }
}
@media (prefers-color-scheme: dark) { :root { --t3: #412733; } }

/* --- каркас страницы */
html, body { overflow-x: clip; }
#study.panel { background: none; border: 0; padding: 0; }
#readbar { position: fixed; left: 0; top: 0; height: 3px; width: 0; background: var(--accent); z-index: 30;
  border-radius: 0 3px 3px 0; transition: width .1s linear; }
.book-hero { padding: 6px 4px 4px; }
.book-hero .kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650;
  letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.book-hero .dots { display: inline-flex; gap: 5px; }
.book-hero .dots i { width: 18px; height: 5px; border-radius: 9px; background: var(--line); }
.book-hero .dots i.on { background: var(--accent); }
.book-hero h2 { font-size: 30px; line-height: 1.15; letter-spacing: -.01em; margin: 10px 0 8px; font-weight: 750; }
.book-hero .how { color: var(--muted); font-size: 15px; margin: 0; }
.book-hero .lesson-el { font-size: 17px; color: var(--muted); margin: 2px 0 0; }
.book-goals { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.book-goals li { padding-left: 26px; position: relative; }
.book-goals li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 18px; height: 18px; margin-top: 3px;
  border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 12px; font-weight: 800;
  display: grid; place-items: center; }

/* --- раздел */
.study .sec { margin-top: 16px; padding: 18px 18px 20px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); box-shadow: var(--shadow); border-top: 1px solid var(--line); }
.study .sec.rise { opacity: 0; transform: translateY(14px); }
.study .sec.rise.in { opacity: 1; transform: none; transition: opacity .45s ease, transform .45s ease; }
@media (prefers-reduced-motion: reduce) { .study .sec.rise { opacity: 1; transform: none; } }
.sec-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.eye { padding: 4px 9px; }
.badge { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; padding: 4px 10px; border-radius: 99px; color: var(--kc);
  background: color-mix(in srgb, var(--kc) 14%, transparent); }
.k-dialogue { --kc: var(--k-dialogue); } .k-phrases { --kc: var(--k-phrases); } .k-grammar { --kc: var(--k-grammar); }
.sec-head .sp { flex: 1; }
.eye { white-space: nowrap; border: 1px solid var(--line); background: none; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px; }
.eye.on { color: var(--accent); border-color: var(--accent); background: var(--soft); }
.study .sec h3 { font-size: 22px; line-height: 1.2; margin: 0; font-weight: 720; letter-spacing: -.005em; }
.study .sec h3 .gr { color: inherit; background: none; padding: 0; }
.study .sec .sub-title { color: var(--muted); font-size: 15px; margin-top: 2px; }
.study .sec .lead { margin: 10px 0 0; font-size: 16.5px; line-height: 1.55; }
.study .sec .lead + .lead { margin-top: 8px; color: var(--muted); }
.k-grammar .lead:first-of-type { border-left: 3px solid var(--kc); padding: 2px 0 2px 12px; }

/* греческое в тексте: не ссылка, а «живое» слово */
.study .gr { color: var(--ink); font-weight: 650; text-decoration: none; padding: 1px 5px; margin: 0 -1px; border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 13%, transparent); transition: background .15s; }
.study .gr:hover, .study .gr.playing { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* кнопка «слушать запись» */
.study .sec .listen { margin: 14px 0 2px; }
.study .listen button { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 650; padding: 8px 14px; }
.study .listen button:first-child { border-radius: 99px 0 0 99px; padding-left: 16px; }
.study .listen button:last-child { border-radius: 0 99px 99px 0; border-left: 1px solid color-mix(in srgb, var(--accent-ink) 25%, transparent); }

/* --- строки: слово или фраза с переводом */
.lines { margin-top: 14px; display: grid; gap: 6px; }
.line { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 3.5%, transparent); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .1s; }
.line:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.line:active { transform: scale(.985); }
.line.playing { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.line .pl { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding-left: 2px; }
.line.playing .pl { background: var(--accent); color: var(--accent-ink); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.line .el { font-size: 19px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.line .ru { color: var(--muted); font-size: 15px; line-height: 1.35; margin-top: 1px; transition: filter .2s; }
.line.plain { grid-template-columns: 1fr; cursor: default; }
.line.plain:hover { background: color-mix(in srgb, var(--ink) 3.5%, transparent); }
.hide-ru .ru, .hide-ru .tile .ru, .hide-ru .chip .ru { filter: blur(6px); user-select: none; }
.hide-ru .show .ru { filter: none; }

/* --- диалог: реплики пузырями */
.chat { margin-top: 14px; display: grid; gap: 8px; }
.say { max-width: 86%; padding: 10px 14px; border-radius: 18px; cursor: pointer; background: var(--bubble-a);
  justify-self: start; border-bottom-left-radius: 6px; -webkit-tap-highlight-color: transparent; transition: transform .1s, box-shadow .15s; }
.say:nth-child(even) { justify-self: end; background: var(--bubble-b); border-radius: 18px; border-bottom-right-radius: 6px; }
.say:active { transform: scale(.98); }
.say.playing { box-shadow: 0 0 0 2px var(--accent); }
.say .el { font-size: 18.5px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.say .ru { color: var(--muted); font-size: 14.5px; margin-top: 2px; transition: filter .2s; }
.say.note { max-width: 100%; justify-self: stretch; border-radius: 14px; }   /* текст, а не разговор */

/* --- короткие слова сеткой: числа, дни недели, буквы */
.chips { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--raise); border-radius: 16px; padding: 10px 8px 9px; text-align: center;
  cursor: pointer; color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; transition: transform .12s, border-color .15s; }
.chip:hover { border-color: var(--accent); }
.chip:active { transform: scale(.95); }
.chip.playing { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.chip .num { font-size: 30px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.chip .el { font-size: 17px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.chip .num + .el { margin-top: 5px; font-size: 16px; }
.chip .ru { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

/* --- слова с картинками */
.tiles { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; }
.tile { margin: 0; padding: 0; border: 0; border-radius: 20px; overflow: hidden; background: var(--tint, var(--t0)); cursor: pointer;
  text-align: left; color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; transition: transform .15s; }
.tile:nth-child(6n+1) { --tint: var(--t0); } .tile:nth-child(6n+2) { --tint: var(--t1); } .tile:nth-child(6n+3) { --tint: var(--t2); }
.tile:nth-child(6n+4) { --tint: var(--t3); } .tile:nth-child(6n+5) { --tint: var(--t4); } .tile:nth-child(6n) { --tint: var(--t5); }
.tile:active { transform: scale(.96); }
.tile .stage { aspect-ratio: 1 / .86; display: grid; place-items: center; padding: 10px 10px 0; }
.tile .stage img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .22));
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.tile:hover .stage img, .tile.playing .stage img { transform: translateY(-4px) scale(1.06) rotate(-2deg); }
.tile .stage.photo { padding: 0; }
.tile .stage.photo img { object-fit: cover; filter: none; }
.tile figcaption, .tile .cap { display: block; padding: 8px 12px 12px; }
.tile .el { display: block; font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.tile .ru { display: block; color: color-mix(in srgb, var(--ink) 62%, transparent); font-size: 14px; margin-top: 1px; }
.tile.playing { box-shadow: 0 0 0 2px var(--accent); }

/* --- картинка из книги: как вложенный листок */
.paper { margin: 16px auto 4px; width: fit-content; max-width: 100%; background: var(--paper); padding: 8px; border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 14px 30px rgba(0, 0, 0, .18); transform: rotate(-1deg); cursor: zoom-in;
  transition: transform .2s; }
.paper:nth-of-type(even) { transform: rotate(1deg); }
.paper:hover { transform: rotate(0) scale(1.01); }
.paper img { display: block; max-width: 100%; max-height: 340px; border-radius: 6px; }
.paper figcaption { font-size: 12px; color: #7b7466; text-align: center; padding-top: 6px; letter-spacing: .03em; }
.stagepic { margin: 14px auto 0; width: min(240px, 70%); aspect-ratio: 1; border-radius: 28px; background: var(--t0);
  display: grid; place-items: center; padding: 14px; }
.stagepic img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .25)); }
#zoom { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 14, .88); display: grid; place-items: center; padding: 14px;
  cursor: zoom-out; }
#zoom img { max-width: 100%; max-height: 100%; border-radius: 10px; background: var(--paper); }

/* --- низ страницы: кнопка всегда под рукой */
#study > .row { position: sticky; bottom: 0; margin: 18px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); flex-wrap: nowrap; z-index: 5; }
#study > .row #study-go { flex: 1; min-width: 0; border-radius: 14px; padding: 14px 12px; font-size: 17px; white-space: nowrap;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
#study > .row #study-back { border-radius: 14px; padding: 14px 12px; white-space: nowrap; font-size: 15px; }

/* --- шпаргалка при тренировке: то же, но плотнее */
.ref .study .sec { box-shadow: none; border-radius: 14px; padding: 12px; margin-top: 10px; background: var(--card); }
.ref .study .sec h3 { font-size: 17px; }
.ref .study .sec-head { display: none; }
.ref .study .line { padding: 6px 8px; grid-template-columns: 26px 1fr; }
.ref .study .line.plain { grid-template-columns: 1fr; }
.ref .study .line .pl { width: 26px; height: 26px; font-size: 10px; }
.ref .study .line .el, .ref .study .say .el { font-size: 16.5px; }
.ref .study .chips { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
.ref .study .chip .num { font-size: 22px; }
.ref .study .tiles { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.ref .study .paper img { max-height: 200px; }

/* --- картинка над заданием */
.pic.cut { width: min(210px, 60%); max-height: none; aspect-ratio: 1; object-fit: contain; padding: 12px; border-radius: 26px;
  background: var(--t0); filter: none; }
.pic:not(.cut) { background: var(--paper); padding: 6px; border-radius: 12px; box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 10px 24px rgba(0, 0, 0, .18); }

/* --- главный экран */
.panel:has(> #home-top) { border: 0; color: #fff; padding: 22px;
  background: radial-gradient(120% 140% at 0% 0%, #3d7df0 0%, #5b4fd6 55%, #7a3fc4 100%);
  box-shadow: 0 14px 34px rgba(60, 70, 200, .28); border-radius: 22px; }
.panel:has(> #home-top) .home-title { font-size: 26px; font-weight: 780; letter-spacing: -.01em; }
.panel:has(> #home-top) .summary, .panel:has(> #home-top) .hint { color: rgba(255, 255, 255, .86); }
.panel:has(> #home-top) button { background: #fff; color: #2c2a7a; border-color: #fff; border-radius: 14px; padding: 13px 20px; }
.panel:has(> #home-top) button.ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); }
.chapter { margin: 30px 4px 12px; }
.chapter .kicker { font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.chapter .study-title { font-size: 26px; font-weight: 780; letter-spacing: -.01em; }
#home-lessons .panel.lesson { border-radius: 20px; padding: 16px 18px; box-shadow: var(--shadow); }
.lesson-top { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; }
.lesson-num { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-weight: 800; font-size: 18px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lesson-num.done { color: var(--ok); background: var(--ok-bg); }
.lesson-name { font-size: 19px; font-weight: 700; line-height: 1.25; margin-top: 1px; }
.lesson-icon { width: 58px; height: 58px; object-fit: contain; filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .25)); }
details.lesson[open] .lesson-icon { transform: scale(1.12) rotate(-4deg); transition: transform .3s cubic-bezier(.3, 1.6, .5, 1); }
#home-lessons .progress .bar { height: 6px; }
.chapter:first-child { margin-top: 26px; }

/* --- мини-игра в разделе */
.eye.play { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.quizzing .tiles, .quizzing .lines, .quizzing .chips, .quizzing .lead, .quizzing .paper, .quizzing .listen, .quizzing .stagepic { display: none; }
.quiz { margin-top: 14px; padding: 16px; border-radius: 18px; text-align: center;
  background: color-mix(in srgb, var(--accent) 8%, transparent); border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent); }
.quiz-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 650; }
.quiz-ask { color: var(--muted); font-size: 14px; margin-top: 6px; }
.quiz-word { font-size: 30px; font-weight: 800; line-height: 1.2; margin: 2px 0 14px; cursor: pointer; overflow-wrap: anywhere; }
.quiz-score { font-size: 46px; line-height: 1.1; margin-top: 6px; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-pics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt { background: var(--raise); color: var(--ink); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px;
  font-size: 17px; font-weight: 600; transition: transform .1s, border-color .15s, background .15s; }
.quiz-opt:active { transform: scale(.97); }
.quiz-pics .quiz-opt { padding: 8px; aspect-ratio: 1; }
.quiz-pics .quiz-opt img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .2)); }
.quiz-opt.ok { border-color: var(--ok); background: var(--ok-bg); animation: pop .35s; }
.quiz-opt.bad { border-color: var(--bad); background: var(--bad-bg); animation: shake .35s; }
@keyframes pop { 50% { transform: scale(1.06); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.ref .study .eye { display: none; }
