/* Trang bài học có hoạt động xen kẽ (lesson-flow.js) và các thẻ hoạt động (acts-*.js). Chỉ dùng biến màu của giao diện. */

/* ---------- thanh tiến độ dính trên cùng ---------- */
.lf { display: grid; gap: 14px; min-width: 0; }
.lf > * { min-width: 0; }
.lf section, .lf details, .lf .act { scroll-margin-top: 104px; }
.lf .card + .card { margin-top: 0; }
.lf-bar { position: sticky; top: 8px; z-index: 20; display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.lf-prog { display: flex; align-items: center; gap: 10px; flex: 1 1 200px; min-width: 0; }
.lf-prog b { font-size: .86rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lf-prog .progress { flex: 1; min-width: 60px; }
.lf-jump { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.lf-jump::-webkit-scrollbar { display: none; }
.lf-jump .tab { flex: 0 0 auto; padding: 5px 10px; font-size: .8rem; min-height: 32px; }

/* ---------- đầu bài ---------- */
.lf-top h2, .lf-part h2, #lf-sound h2, #lf-role h2, #lf-listen h2, #lf-sum h2 { font-size: 1.08rem; margin: 0 0 10px; }
.lf-goals { margin: 0 0 10px; padding-left: 20px; }
.lf-goals li { margin: 3px 0; }
.lf-scene { margin: 0 0 12px; }
.lf-hide { margin-top: 12px; gap: 6px 14px; font-size: .86rem; }
.lf-hide label { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; cursor: pointer; }
.lf-sec { font-size: 1.08rem; margin: 6px 0 0; }
#lf-grammar { display: grid; gap: 14px; }
.lf-g h3 { margin: 0 0 6px; }
.lf-note { margin: 0 0 4px; }
.lf-tools { gap: 6px; margin-top: 6px; }

/* ---------- đoạn hội thoại: nghe trước, trả lời xong mới hiện chữ ---------- */
.lf-part { display: grid; gap: 14px; }
.lf-part > * { min-width: 0; }
.lf-ph h2 { margin: 0; }
.lf.hide-zh .lf-lines .line-zh { filter: blur(9px); }
.lf.hide-jp .lf-lines rt { visibility: hidden; }
.lf.hide-vi .lf-lines .vi { display: none; }

/* ---------- từ chính của đoạn ---------- */
.lf-fh { font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.fw-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.fw { display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.fw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; color: var(--text); }
.fw-main:hover { border-color: var(--accent-2); }
.fw-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fw-main .z { font-family: var(--font-zh-serif); font-size: 1.45rem; line-height: 1.2; white-space: nowrap; }
.fw-main .m { font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.fw-main small { font-size: .74rem; }
.fw-say { align-self: center; min-width: 40px; min-height: 40px; }

/* ---------- thẻ hoạt động ---------- */
.act { position: relative; border-radius: 14px; padding: 12px 14px 14px; background: color-mix(in srgb, var(--accent-2) 5%, var(--surface)); border: 1.5px dashed color-mix(in srgb, var(--accent-2) 45%, var(--border)); min-width: 0; }
.act.is-done { border-style: solid; }
.act.ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); background: color-mix(in srgb, var(--ok) 5%, var(--surface)); }
.act.miss { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.act-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.act-st { font-size: .8rem; font-weight: 700; color: var(--muted); }
.act.ok .act-st { color: var(--ok); }
.act-again { margin-top: 10px; }
.act-q { margin: 0 0 8px; font-weight: 600; }
.act-vi { margin: 0 0 4px; font-size: 1.1rem; font-weight: 700; }
.act-hint { margin: 0 0 4px; font-size: .84rem; }
.act-word { margin: 0 0 8px; }
.act-word .z { font-family: var(--font-zh-serif); font-size: 1.7rem; margin-right: 6px; }
.act-cue { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 10px; }
.act .choice .line-zh.sm { font-size: 1.15rem; }
.act .choice:disabled { cursor: default; }
.act .choice.wrong { opacity: .6; }
.tone-opt { font-weight: 700; font-size: 1.05rem; }
.act .match-grid { align-items: start; }
.match-col { display: grid; gap: 10px; min-width: 0; }
.act .match-item { width: 100%; color: var(--text); overflow-wrap: anywhere; }
.act .match-item.done { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); cursor: default; }
.num-pad { display: grid; gap: 10px; max-width: 260px; }
.num-out { display: flex; justify-content: flex-end; min-height: 44px; }
.num-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.num-keys .btn { min-height: 46px; font-size: 1.1rem; font-weight: 700; justify-content: center; }
.say-score { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.say-score.ok { color: var(--ok); } .say-score.mid { color: var(--warn); } .say-score.low { color: var(--bad); }
.say-res p { margin: 0 0 8px; }
.say-tip { margin-top: 8px !important; font-size: .88rem; }
.say-self { gap: 6px 10px; }
.role-log { max-height: 340px; overflow-y: auto; padding-right: 2px; }
.role-log:empty { display: none; }
.role-log .bubble { max-width: 92%; }

/* ---------- khối gập, tổng kết ---------- */
.lf-fold > summary, .lf-quiz > summary { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; font-weight: 700; list-style: none; }
.lf-fold > summary::-webkit-details-marker, .lf-quiz > summary::-webkit-details-marker { display: none; }
.lf-fold > summary::after, .lf-quiz > summary::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
.lf-fold[open] > summary::after, .lf-quiz[open] > summary::after { transform: rotate(-135deg); }
.lf-fold[open] > summary, .lf-quiz[open] > summary { margin-bottom: 12px; }
.lf-can { display: grid; gap: 4px; margin: 10px 0; }
.lf-can label { display: flex; gap: 8px; align-items: flex-start; min-height: 32px; cursor: pointer; }
.lf-can input { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 2px; }
.lf-miss { display: grid; gap: 8px; margin: 10px 0; }
#lf-media:empty { display: none; }

@media (max-width: 560px) {
  .lf-bar { top: 4px; padding: 6px 10px; }
  .act { padding: 10px 10px 12px; }
  .fw-row { grid-template-columns: 1fr 1fr; }
  .fw-say { display: none; }
  .lf-wide { display: none; }
}

/* ---------- "Vì sao nói vậy?": giải thích soạn sẵn dưới câu (explain-kit.js) ---------- */
.xp { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface); display: grid; gap: 8px; min-width: 0; }
.xp-h { font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: 6px; }
.xp-words { display: flex; flex-wrap: wrap; gap: 6px; }
.xp-w { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.xp-w:hover { border-color: var(--accent); }
.xp-z { font-size: 1.05rem; line-height: 1.9; }
.xp-m { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.xp-why, .xp-hv { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }
.xp-alt { border-top: 1px solid var(--border); padding-top: 8px; }
.xp-lab { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.xp-arow { flex-wrap: nowrap; align-items: center; gap: 8px; }
.xp-atext { flex: 1; min-width: 0; }
.xp-foot { gap: 6px; align-items: center; }

/* ---------- trang bài: các bước đánh số gập / mở ---------- */
.lf-step { padding: 0; overflow: hidden; }
.lf-step + .lf-step, .lf-step + details, details + .lf-step { margin-top: 10px; }
#lf-grammar.lf-step { display: block; }
.lf-sh { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.lf-sh::-webkit-details-marker { display: none; }
.lf-step[open] > .lf-sh { border-bottom: 1px solid var(--border); background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
.lf-num { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 2px solid var(--border); color: var(--muted); }
.lf-step[open] .lf-num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.lf-st { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.lf-st b { font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.lf-st small { color: var(--muted); font-size: .8rem; }
.lf-ok { display: none; width: 26px; height: 26px; border-radius: 50%; place-items: center; background: var(--ok); color: var(--on-ok, #fff); flex: 0 0 auto; }
.lf-ok svg { width: 16px; height: 16px; }
.lf-step.is-done .lf-ok { display: grid; }
.lf-step.is-done .lf-num { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: var(--ok); color: var(--ok); }
.lf-chev { flex: 0 0 auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: -4px 4px 0; transition: transform .15s; }
.lf-step[open] .lf-chev { transform: rotate(-135deg); margin-top: 4px; }
.lf-body { padding: 14px; display: grid; gap: 14px; }
.lf-body > * { min-width: 0; }
.lf-body > .card { box-shadow: none; margin: 0; }
.lf-ph { justify-content: flex-end; }
