/* ===== lesson: 出題の画面、会話、4 択、講評 ===== */

/* ===== lesson screen ===== */
#scrLesson{background:var(--lesson-bg)}
.stage{flex:none;height:clamp(260px,46dvh,480px);position:relative;overflow:hidden;background:var(--surface2)}
.stage svg.scene{position:absolute;inset:0;width:100%;height:100%;display:block}
/* the partner stands on a separate layer so a photo is never cropped, whatever the stage's shape */
.charwrap{position:absolute;inset:0;display:flex;justify-content:center;align-items:flex-end;pointer-events:none}
.charwrap img.char,.charwrap svg.char{height:84%;width:auto;max-width:94%;display:block;object-fit:contain;object-position:bottom}
.charwrap svg.char{height:92%}
.stagebar{position:absolute;left:0;right:0;top:0;display:flex;align-items:center;gap:10px;padding:12px 14px 16px;z-index:2;background:linear-gradient(to bottom,rgba(60,40,10,.35),rgba(60,40,10,0))}
.stagebar .back{width:46px;height:46px;border-radius:50%;background:rgba(255,255,255,.95);color:var(--ink2);display:grid;place-items:center;font-size:20px;font-weight:800;box-shadow:0 2px 6px rgba(0,0,0,.2)}
.dots{flex:1;display:flex;gap:8px;align-items:center;justify-content:center}
.dots i{width:18px;height:18px;border-radius:50%;background:rgba(255,255,255,.45);border:2px solid rgba(255,255,255,.8)}
.dots i.done{background:var(--good);border-color:var(--good)}
.dots i.now{background:#fff;border-color:#fff}
.dots.many i{width:10px;height:10px;border-width:1.5px}
.stagebar .state{border-radius:999px;padding:6px 14px;font-size:14px;font-weight:800;background:rgba(255,255,255,.95);color:var(--ink2);min-width:44px;text-align:center}
.stagebar .state.rec{background:#E85D48;color:#fff}
.char .mouth{transform-box:fill-box;transform-origin:center;transform:scaleY(.5)}
.stage.speaking .char.main .mouth{animation:talk .32s infinite alternate ease-in-out}
@keyframes talk{from{transform:scaleY(.35)}to{transform:scaleY(1.6)}}
.char .eyes{transform-box:fill-box;transform-origin:center;animation:blink 5.2s infinite}
@keyframes blink{0%,96%,100%{transform:scaleY(1)}98%{transform:scaleY(.08)}}
.stage.speaking .char.main{animation:bob 2.2s infinite ease-in-out}
@keyframes bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}
.stage.listening .char.main{animation:lean 3s infinite ease-in-out}
@keyframes lean{0%,100%{transform:rotate(0)}50%{transform:rotate(-1.2deg)}}
@media (prefers-reduced-motion:reduce){.stage .char,.stage.speaking .char.main .mouth,.char .eyes{animation:none!important}}

.scroll{flex:1;min-height:0;overflow:auto;-webkit-overflow-scrolling:touch;padding-top:16px}
.body{flex:none;padding:18px 16px 16px;display:flex;flex-direction:column;gap:18px}
.body>*{flex:none}
.dlg{flex:none;padding:0 16px 2px;position:relative;z-index:1}
.card{position:relative;background:var(--surface);border-radius:18px;padding:18px 16px 14px;box-shadow:var(--shadow)}
.card .tag{position:absolute;top:-13px;left:14px;background:var(--accent);color:var(--accent-ink);border-radius:9px;padding:2px 12px;font-size:14px;font-weight:800}
.card .badge{position:absolute;top:-13px;right:14px;border-radius:999px;padding:3px 14px;font-size:14px;font-weight:800;color:#fff;background:var(--good)}
.card .badge.warn{background:var(--warn)}.card .badge.bad{background:var(--bad)}
.card.theirs{margin-top:0;z-index:1}
.card.theirs::before{content:"";position:absolute;top:-10px;left:50%;margin-left:-10px;border:10px solid transparent;border-top:0;border-bottom-color:var(--surface)}
.card .txt{font-size:23px;line-height:1.4;padding-top:4px;font-weight:600}
.card .ja{display:block;font-size:15px;color:var(--ink2);margin-top:8px;border-top:1px dashed var(--line);padding-top:8px}
.tapja-host{cursor:pointer}
.correct .ja{display:block;font-size:14px;color:rgba(255,255,255,.85);margin-top:6px;border-top:1px dashed rgba(255,255,255,.3);padding-top:6px;font-family:"M PLUS Rounded 1c","Hiragino Maru Gothic ProN",system-ui,sans-serif}
.card .tools{display:flex;gap:8px;justify-content:flex-end;margin-top:10px;flex-wrap:wrap}
.card.script .txt{color:var(--ink)}
.blur{filter:blur(7px);user-select:none}
.ibtn.txt{width:auto;padding:0 14px;border-radius:999px;font-size:14px;font-weight:800;color:var(--ink2)}
.card.said .txt{font-size:23px;font-weight:600;line-height:1.35;min-height:32px}
.card.said{background:var(--sky-soft)}
.card.said .tag{background:var(--navy)}
/* realtime: the partner's line stays pinned at the top while the child's lines pile up below, newest at the bottom */
#scrLesson.talk .dlg{position:sticky;top:0;z-index:3;background:var(--lesson-bg);padding-top:12px;margin-top:-16px;padding-bottom:6px}
/* realtime: only the newest line shows. while the child is talking the partner's text steps aside, the tools stay */
#scrLesson.talk .card.theirs.stale{background:transparent;box-shadow:none;padding:0}
#scrLesson.talk .card.theirs.stale::before,#scrLesson.talk .card.theirs.stale>.tag,#scrLesson.talk .card.theirs.stale>.txt,#scrLesson.talk .card.theirs.stale>.ja{display:none}
#scrLesson.talk .card.theirs.stale .tools{margin-top:0;justify-content:flex-end}
#scrLesson.talk .card.said{margin-top:14px}
/* realtime: the dock's right side is just the end button. no hint, no status label */
.talkend{display:none;height:52px;padding:0 22px;border-radius:999px;background:var(--surface);color:var(--ink);font-size:16px;font-weight:800;box-shadow:var(--shadow)}
.talkend:hover{background:var(--surface2)}
#scrLesson.talk #btnHint,#scrLesson.talk #micLbl{display:none}
#scrLesson.talk .talkend{display:inline-flex;align-items:center}
/* talk: the timer, the mic and the end button sit in the middle with the same gap between them */
#scrLesson.talk .dock{display:flex;justify-content:center;align-items:center;gap:44px}
/* 会話シナリオの準備画面。相手の画像の下に白いカードを 1 枚置き、読み終えてから会話を始める。
   画像を小さくしてカードの場所を空け、まだ使わないマイクと吹き出しは隠す。残り時間だけ選んだ長さで出す */
#scrLesson.prep .stage{height:clamp(150px,22dvh,260px)}
#scrLesson.prep .dlg{display:none}
#scrLesson.prep .dock{grid-template-columns:1fr;padding-top:4px}
#scrLesson.prep .dock .mic,#scrLesson.prep .dock .right{display:none}
.prep{background:var(--surface);border-radius:18px;padding:18px 16px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:12px}
.prep h3{margin:0;font-size:21px;font-weight:800;line-height:1.3}
.prep h4{margin:4px 0 0;font-size:13px;letter-spacing:.08em;color:var(--ink3);font-weight:800}
.prep p{margin:0}
.prep .meta{font-size:14px;color:var(--ink2);font-weight:700}
.prep .sit{font-size:16px;line-height:1.6}
.prep ol,.prep ul{margin:0;padding-left:1.4em;display:flex;flex-direction:column;gap:6px}
.prep .goals li{font-size:15px;line-height:1.5}
.prep .hints{list-style:none;padding-left:0}
.prep .hints li{background:var(--surface2);border-radius:12px;padding:8px 12px}
.prep .hints b{display:block;font-size:16px;font-weight:700;line-height:1.4}
.prep .hints span{display:block;font-size:13px;color:var(--ink2);margin-top:2px}
.prep .note{font-size:13px;color:var(--ink3);line-height:1.5;margin-top:2px}
.prep .btn{flex:none;margin-top:4px}
.prep .cancel{align-self:center;background:none;color:var(--ink2);font-size:15px;font-weight:700;text-decoration:underline;padding:4px 12px}
/* 残り分数が足りないときに準備画面の下へ出す買い置きの枠。設定の「プラン」のカードと同じ形にそろえる */
/* 準備画面の始めるところ。ボタンと、その下の残り分数の 1 行。プランが無い人には加入の案内 */
.prepact{display:flex;flex-direction:column;gap:8px;margin-top:4px}
.prepact .btn{margin-top:0}
.prepact .startnote{text-align:center;margin:0}
.prepact .plannote{margin:0}
.prepact .snote{margin:0;font-size:13px;font-weight:700;line-height:1.5;color:var(--ink2)}
.prepact .snote.bad{color:var(--bad)}
/* eiken: no partner picture. only the top bar (close, dots, count) stays */
#scrLesson.nostage{display:flex;flex-direction:column}
#scrLesson.nostage .stage{height:auto;min-height:0;background:transparent;flex:none}
#scrLesson.nostage .stage>*:not(.stagebar){display:none}
#scrLesson.nostage .stagebar{position:static;background:none;padding:10px 14px 4px}
#scrLesson.nostage .stagebar .back{background:var(--surface);box-shadow:var(--shadow)}
#scrLesson.nostage .scroll{width:min(760px,100%);margin:0 auto}
/* choice quizzes: no mic, no hint. the timer stays for the mock exam */
#scrLesson.quiz .dock .mic,#scrLesson.quiz .dock .right{display:none}
#scrLesson.quiz .dock{grid-template-columns:1fr;padding-top:4px;padding-bottom:calc(4px + env(safe-area-inset-bottom))}
/* feedback after an answer: the stage and the dock go away, the question and the feedback fill the screen */
#scrLesson.fb{display:flex;flex-direction:column}
#scrLesson.fb .stage,#scrLesson.fb .dock{display:none}
#scrLesson.fb .scroll{flex:1;width:min(760px,100%);margin:0 auto;padding-top:0}
#scrLesson.fb .dlg{position:static;margin-top:0;padding-top:0}
#scrLesson.fb .fbhead{padding-bottom:14px} /* ✕ が問題カードの札にかぶらないように */
/* realtime report: the stage, the dock and the bubble go away. the report has the whole screen */
#scrLesson.report{display:flex;flex-direction:column}
#scrLesson.report .stage,#scrLesson.report .dock,#scrLesson.report .dlg{display:none}
#scrLesson.report .scroll{flex:1;width:min(760px,100%);margin:0 auto;padding-top:0}
/* text off: the whole bubble goes, only the small tools stay */
.card.theirs.veil{background:transparent;box-shadow:none;padding:0}
.card.theirs.veil::before,.card.theirs.veil>.tag,.card.theirs.veil>.txt,.card.theirs.veil>.ja{display:none}
.card.theirs.veil .tools{margin-top:0;justify-content:flex-end}
.card.theirs.veil .ibtn{background:rgba(255,255,255,.6);border-color:transparent}
.w{padding:0 1px}
.w.ok{color:var(--good)}
.w.p1{color:var(--good)}.w.p2{color:var(--warn)}.w.p3{color:var(--bad);text-decoration:underline dotted}
.w.om{color:var(--ink3);text-decoration:line-through}
.w[data-pi]{cursor:pointer;border-radius:4px}.w[data-pi]:hover{background:var(--surface2)}
.phs{display:flex;flex-wrap:wrap;gap:6px}
.ph{border-radius:8px;padding:3px 9px;font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:15px;background:var(--surface2);color:var(--ink2)}
.ph b{font-weight:800;margin-left:4px;color:var(--ink)}
.ph.warn{background:var(--warn-soft);color:var(--warn)}.ph.warn b{color:var(--warn)}
.ph.bad{background:var(--bad-soft);color:var(--bad)}.ph.bad b{color:var(--bad)}
.legend{font-size:13px;color:var(--ink3)}
.w.extra{color:var(--warn)}
.w.miss{color:var(--warn)}
.interim{opacity:.55}
/* 聞き取れなかったときなどの案内は、発話ではないので本文と同じ大きさにする */
.card.said.msg .txt{font-size:17px;font-weight:500;line-height:1.5;color:var(--ink2)}
.card.said.msg .interim{opacity:.9}
.correct{position:relative;background:var(--navy);color:var(--navy-ink);border-radius:16px;padding:14px 16px;font-size:20px;line-height:1.45;margin-top:-2px;display:flex;gap:10px;align-items:flex-start}
.correct::before{content:"";position:absolute;top:-9px;left:50%;margin-left:-9px;border:9px solid transparent;border-top:0;border-bottom-color:var(--navy)}
.correct .t{flex:1}
.correct .hl{color:#FFC700;font-weight:700}
.correct .sp.fav{font-size:21px;color:rgba(255,255,255,.75)}
.correct .sp.fav.on{color:#FFC700;background:rgba(255,199,0,.2)}
.correct .btns{display:flex;flex-direction:column;gap:6px;flex:none}
.correct .sp{width:42px;height:42px;border-radius:50%;background:rgba(255,255,255,.14);display:grid;place-items:center;color:#fff;flex:none;font-size:18px}
.correct .lbl{display:block;font-size:12px;font-weight:800;letter-spacing:.08em;opacity:.8;margin-bottom:2px;font-family:"M PLUS Rounded 1c",system-ui,sans-serif}
.note{font-size:14px;color:var(--ink2);margin-top:6px}
.thinking{display:inline-flex;gap:4px;align-items:center;color:var(--ink3);font-size:15px}
.thinking i{width:6px;height:6px;border-radius:50%;background:var(--ink3);animation:blinkdot 1.2s infinite}
.thinking i:nth-child(2){animation-delay:.2s}.thinking i:nth-child(3){animation-delay:.4s}
@keyframes blinkdot{0%,80%,100%{opacity:.25}40%{opacity:1}}
/* detail card */
.detail{background:var(--surface);border-radius:18px;padding:16px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:10px}
.detail h4{margin:0;font-size:13px;letter-spacing:.08em;color:var(--ink3);font-weight:800}
.subs{display:flex;flex-direction:column;gap:6px}
.sub{display:grid;grid-template-columns:70px 1fr 46px;align-items:center;gap:8px;font-size:14px;color:var(--ink2);font-weight:700}
.sub .bar{height:10px;background:var(--surface2);border-radius:5px;overflow:hidden}
.sub .bar i{display:block;height:100%;width:0;border-radius:5px;background:var(--accent);transition:width .6s}
.sub.good .bar i{background:var(--good)}.sub.warn .bar i{background:var(--warn)}.sub.bad .bar i{background:var(--bad)}
.sub .n{text-align:right}
.verdict{font-size:17px;line-height:1.6}
/* 無料の人の講評に出す、発音の採点の案内。押すとプランのカードが開く */
.subs .paup{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:2px;padding:9px 12px;border-radius:12px;background:var(--surface2);color:var(--ink2);font-size:13px;line-height:1.4;text-align:left}
.subs .paup b{flex:none;color:var(--accent);font-weight:800;white-space:nowrap}
.subs .paup:hover{background:var(--accent-soft)}
.pron{display:flex;flex-direction:column;gap:6px}
.pron div{display:grid;grid-template-columns:auto auto 1fr;gap:8px;align-items:baseline;font-size:15px}
.pron .heard{color:var(--bad);text-decoration:line-through}
.pron .meant{color:var(--good);font-weight:800}
.pron .tip{color:var(--ink2);font-size:14px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
/* dock */
.dock{flex:none;padding:12px 18px calc(12px + env(safe-area-inset-bottom));display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:8px}
.dock .left,.dock .right{display:flex;flex-direction:column;align-items:center;gap:2px}
.dock .lbl{font-size:14px;color:var(--ink);opacity:.85;font-weight:700;text-align:center}
.dock .timer{font-size:21px;color:var(--ink)}
.dock .timer.over{color:#C9491E}
.mic{width:86px;height:86px;border-radius:50%;background:var(--accent);color:#fff;display:grid;place-items:center;box-shadow:0 0 0 8px rgba(255,255,255,.45),0 6px 18px rgba(0,0,0,.18);transition:transform .15s,background .2s;margin:4px 0}
.mic:active{transform:scale(.95)}
.mic.rec{background:var(--rec);animation:pulse 1.4s infinite}
.mic:disabled{background:var(--ink3);box-shadow:none;animation:none}
@keyframes pulse{0%{box-shadow:0 0 0 8px rgba(255,255,255,.45),0 0 0 8px rgba(232,93,72,.4)}100%{box-shadow:0 0 0 8px rgba(255,255,255,.45),0 0 0 24px rgba(232,93,72,0)}}
@media (prefers-reduced-motion:reduce){.mic.rec{animation:none}}
.mic svg{width:34px;height:34px}
.mic .stop{display:none;width:28px;height:28px;border-radius:7px;background:#fff}
.mic.rec svg{display:none}.mic.rec .stop{display:block}
.side{width:50px;height:50px;border-radius:50%;display:grid;place-items:center;background:rgba(255,255,255,.55);color:var(--ink);font-size:20px}
.side:disabled{opacity:.4}
.mic.rt{background:var(--good)}
.mic.rt.muted{background:var(--ink3);animation:none}
.mic.rt .stop{display:none}.mic.rt svg{display:block}
/* iPad landscape: stage on the left, conversation on the right */
@media (min-width:900px){
  #scrLesson{display:grid;grid-template-columns:minmax(340px,42%) 1fr;grid-template-rows:1fr auto}
  #scrLesson .stage{grid-row:1;grid-column:1;height:auto;min-height:0}
  #scrLesson .scroll{grid-row:1/3;grid-column:2;padding-top:20px}
  #scrLesson .dock{grid-row:2;grid-column:1}
  .dlg{padding:0 22px 2px}
  .body{padding:20px 22px 22px}
  /* realtime on a wide screen: one column, the partner in the middle, the newest line right under them */
  #scrLesson.talk{display:flex;flex-direction:column}
  #scrLesson.talk .stage{width:min(680px,calc(100% - 32px));height:clamp(280px,50dvh,470px);margin:14px auto 0;border-radius:24px;box-shadow:var(--shadow)}
  #scrLesson.talk .scroll{width:min(680px,100%);margin:0 auto;padding-top:26px}
  #scrLesson.talk .dlg{margin-top:0;padding-top:0}
}
/* eiken quiz */
.quiz-q{font-size:20px;font-weight:700;line-height:1.4}
.pic{display:flex;justify-content:center}
.preview .choice{padding:8px 12px;font-size:16px;opacity:.85}.preview .choice .n{width:26px;height:26px;font-size:13px}
.picsvg{width:100%;max-width:420px;height:auto;display:block;border-radius:16px;box-shadow:inset 0 0 0 3px var(--line)}
.choices{display:flex;flex-direction:column;gap:10px}
.choice{display:flex;align-items:center;gap:12px;text-align:left;background:var(--surface2);border:3px solid transparent;border-radius:16px;padding:14px 14px;font-size:20px;font-weight:600;line-height:1.35}
.choice .n{width:34px;height:34px;border-radius:50%;background:var(--surface);display:grid;place-items:center;font-size:16px;font-weight:800;color:var(--ink2);flex:none}
.choice .ct{flex:1}
.choice .sp{width:38px;height:38px;border-radius:50%;background:var(--surface);display:grid;place-items:center;font-size:16px;flex:none}
.choice:disabled{opacity:1;cursor:default}
.choice.ok{border-color:var(--good);background:var(--good-soft)}
.choice.ng{border-color:var(--bad);background:var(--bad-soft)}
.okmark{color:var(--good);font-size:22px}.ngmark{color:var(--bad);font-size:22px}
.orderline{min-height:52px;background:var(--surface2);border-radius:14px;padding:10px 12px;font-size:20px;font-weight:600;display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.orderline .ph-slot{color:var(--ink3)}
.orderline .blank{display:inline-block;min-width:74px;padding:4px 8px;border-bottom:3px solid var(--ink3);text-align:center;font-size:13px;color:var(--ink3);font-family:"M PLUS Rounded 1c",system-ui,sans-serif}
.orderline .full{color:var(--good)}
.chips.bank .chip.word.used{opacity:.35}
.orderline .blank.ask{border-bottom-color:var(--accent);color:var(--accent);font-weight:800}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip.word{font-family:"Nunito",system-ui,sans-serif;font-size:19px;font-weight:700;color:var(--ink);padding:10px 16px;background:var(--surface);border:2px solid var(--line)}
.chip.word:disabled{opacity:.5}
.chip.on{background:var(--accent-soft);border-color:var(--accent);color:var(--ink);font-family:"Nunito",system-ui,sans-serif;font-weight:700;font-size:19px;padding:6px 12px}
.mic.quiz{background:var(--ink3);box-shadow:none}
.sheet.intro{align-items:center}
.sheet.intro .panel{border-radius:24px;max-width:560px;margin:0 16px}
.sheet.intro .ih{display:flex;align-items:center;justify-content:space-between;gap:10px}
.sheet.intro .verdict{font-size:18px;line-height:1.7;white-space:pre-line}
.choice.picked{border-color:var(--navy);background:var(--accent-soft)}
.card .txt.pre{white-space:pre-line}

/* ===== phone: everything one size smaller ===== */
@media (max-width:560px){
  .card{padding:14px 12px 12px;border-radius:16px}
  .card .txt{font-size:19px}
  .card .ja{font-size:13.5px}
  .card .tag{font-size:12px;padding:2px 10px}
  .card .badge{font-size:12px;padding:2px 10px}
  .card.said .txt{font-size:19px}
  .correct{font-size:17px;padding:12px 14px}
  .detail{padding:12px}
  .detail .verdict{font-size:15px}
  .card.said.msg .txt{font-size:15px}
  /* マイクは小さめにして、講評や吹き出しの領域を広く取る。相手の画像の高さも抑える */
  .dock{padding:6px 12px calc(6px + env(safe-area-inset-bottom));gap:6px}
  .mic{width:60px;height:60px;box-shadow:0 0 0 5px rgba(255,255,255,.45),0 4px 12px rgba(0,0,0,.18)}
  .mic svg{width:26px;height:26px}
  /* 相手の画像は画面の半分ほど取る。お手本は SpeakBuddy の会話画面。画像が出るのは 音声1問1答 と英会話レッスンだけ */
  .stage{height:clamp(320px,56dvh,560px)}
  #scrLesson.talk .stage{height:clamp(320px,56dvh,560px)}
  .dock .timer{font-size:18px}
  .dock .lbl{font-size:12px}
  .choice{font-size:16px;padding:10px 12px}
  .sheet.intro .verdict{font-size:16px}
}
