/* =========================================================================
 * Phòng phát âm (#/speak): hồ sơ điểm, album âm, trang một âm, từ điển, thẻ luyện nói kiểu ELSA, màn luyện.
 * Màu mức điểm: chuẩn = --ok, khá = --warn, cần luyện = --bad, chưa đo = --faint. Màu thanh = --t1…--t6.
 * ========================================================================= */
.b-good { --band: var(--ok); }
.b-ok { --band: var(--warn); }
.b-weak { --band: var(--bad); }
.b-none { --band: var(--faint, var(--border)); }
.spk-legend span { color: var(--band); }

/* vòng điểm */
.spk-ring { --sz: 64px; position: relative; display: inline-grid; place-items: center; width: var(--sz); height: var(--sz); flex: 0 0 auto; }
.spk-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.spk-ring circle { fill: none; }
.spk-ring .rg-bg { stroke: var(--surface-3); }
.spk-ring .rg-fg { stroke: var(--band); stroke-linecap: round; transition: stroke-dashoffset .6s ease-out; }
.spk-ring b { position: relative; font-size: calc(var(--sz) * .3); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.spk-ring small { position: absolute; bottom: 18%; font-size: calc(var(--sz) * .12); color: var(--muted); }

/* hub: hồ sơ */
.spk-profile { display: grid; gap: 14px; }
.spk-prof-main { display: flex; gap: 18px; align-items: center; }
.spk-prof-bars { flex: 1; min-width: 0; display: grid; gap: 8px; }
.spk-bar { display: grid; grid-template-columns: 64px 1fr 30px; gap: 8px; align-items: center; font-size: .88rem; }
.spk-bar b { text-align: right; font-variant-numeric: tabular-nums; }
.spk-bar-t { height: 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.spk-bar-t i { display: block; height: 100%; background: var(--band); border-radius: inherit; }
.spk-days { display: flex; align-items: flex-end; gap: 4px; height: 44px; padding: 0 2px; }
.spk-days span { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.spk-days i { display: block; width: 100%; background: var(--band); border-radius: 4px 4px 0 0; opacity: .8; }
.spk-cta { gap: 8px; }
.spk-cta .btn.big { flex: 1 1 240px; justify-content: center; }
.spk-weak { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.spk-weak .chip { color: var(--band); border-color: color-mix(in srgb, var(--band) 45%, transparent); background: color-mix(in srgb, var(--band) 10%, transparent); text-decoration: none; font-weight: 700; }

/* ô tra từ */
.spk-search { display: flex; align-items: center; gap: 8px; margin: 16px 0 4px; padding: 6px 6px 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); }
.spk-search > span { color: var(--muted); display: grid; }
.spk-search > span svg { width: 20px; height: 20px; }
.spk-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 8px 0; font-size: 1rem; color: var(--text); outline: none; box-shadow: none; }
.spk-search .btn { border-radius: 999px; }
.spk-try { margin: 8px 2px 0; gap: 6px; }
.spk-try .chip { text-decoration: none; }

/* album */
.spk-album-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.spk-album-h small { font-weight: 500; }
.spk-album .seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; }
.spk-album .seg-b { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; padding: 9px 6px; border-radius: 9px; cursor: pointer; min-height: 40px; }
.spk-album .seg-b small { display: block; font-weight: 500; opacity: .75; font-variant-numeric: tabular-nums; }   /* dòng riêng: "Thanh điệu 5/6" không vừa một dòng ở 375px */
.spk-album .seg-b.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.spk-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
.spk-grid.tones { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.spk-fam + .spk-fam { margin-top: 12px; }
.spk-fam-h { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin: 0 2px 6px; }
.spk-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 12px; min-height: 86px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 3px solid color-mix(in srgb, var(--band) 70%, var(--border)); color: var(--text); text-decoration: none !important; text-align: center; transition: transform .1s; overflow: hidden; }
.spk-tile:hover { border-color: color-mix(in srgb, var(--band) 60%, var(--border)); }
.spk-tile:active { transform: translateY(2px); }
.spk-tile .st-sym { font-size: 1.45rem; font-weight: 800; line-height: 1.15; letter-spacing: .01em; }
.spk-tile .st-sub { font-size: .7rem; color: var(--muted); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.spk-tile .st-bar { position: absolute; left: 8px; right: 8px; bottom: 5px; height: 4px; border-radius: 9px; background: var(--surface-3); }
/* ô đã có điểm: nền nhạt theo mức, số điểm ở góc (kiểu bảng chữ cái có tiến độ) */
.spk-tile:not(.b-none) { background: color-mix(in srgb, var(--band) 8%, var(--surface)); }
.spk-tile .st-v { position: absolute; top: 5px; right: 7px; font-size: .7rem; font-weight: 800; line-height: 1; color: var(--band); font-variant-numeric: tabular-nums; }
.spk-tile .st-bar i { display: block; height: 100%; background: var(--band); border-radius: inherit; }
.spk-tile.tone { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 12px; text-align: left; min-height: 64px; }
.spk-tile.tone .st-tn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-size: 1.35rem; color: var(--surface); background: currentColor; }
.spk-tile.tone .st-sym { color: var(--tone); }
.spk-tile.tone .st-tn { background: var(--tone); color: var(--hk-cream, #fff); }
.spk-tile.tone.t1 { --tone: var(--t1); } .spk-tile.tone.t2 { --tone: var(--t2); } .spk-tile.tone.t3 { --tone: var(--t3); }
.spk-tile.tone.t4 { --tone: var(--t4); } .spk-tile.tone.t5 { --tone: var(--t5); } .spk-tile.tone.t6 { --tone: var(--t6); }
.spk-tile.tone .st-sub { font-size: .85rem; font-weight: 600; color: var(--text); -webkit-line-clamp: 1; }
.spk-tile.tone .st-sub { flex: 1; min-width: 0; -webkit-line-clamp: 2; }
.spk-tile.tone .st-v { position: static; order: 2; margin-left: auto; padding-left: 4px; font-size: .95rem; }   /* ô thanh nằm ngang: số đứng cuối hàng, không đè tên thanh */
.spk-legend { font-size: .8rem; margin: 10px 2px 0; }
/* tóm tắt một nhóm âm: đã đo bao nhiêu, thanh chia mức, nút luyện âm yếu nhất */
.spk-gsum { display: grid; gap: 8px; margin-bottom: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.spk-gsum-t { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.spk-gsum-bar { display: flex; gap: 2px; height: 8px; border-radius: 99px; overflow: hidden; }
.spk-gsum-bar i { display: block; min-width: 4px; background: var(--band); }
.spk-gsum-bar i.b-none { background: var(--surface-3); }
.spk-gsum-go { justify-self: start; }
.spk-gsum .spk-legend { margin: 0; }   /* chú thích ngay dưới thanh, trong cùng thẻ */
.spk-gsum-how { font-size: .78rem; line-height: 1.4; }
.spk-gsum.is-empty p { margin: 0; font-size: .85rem; }
.spk-credit { font-size: .78rem; margin-top: 18px; }

/* âm tiết thu giọng thật */
.spk-syl { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; min-width: 58px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; }
.spk-syl:hover { background: var(--surface-3); }
.spk-syl:active { transform: scale(.96); }
.spk-syl .z { font-family: var(--font-zh); font-size: 1.3rem; line-height: 1.2; }
.spk-syl .jp { font-size: .9rem; }
.spk-syl small { font-size: .7rem; color: var(--muted); }
.spk-syl.big { min-width: 74px; padding: 8px 12px; }
.spk-syl.big .z { font-size: 1.8rem; }
.spk-syl.big .jp { font-size: 1rem; }
.spk-hear { gap: 8px; }

/* trang một âm */
.spk-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.spk-hero-sym { display: grid; place-items: center; min-width: 92px; height: 92px; padding: 0 12px; border-radius: 18px; background: color-mix(in srgb, var(--accent-2) 12%, var(--surface-2)); border: 2px solid var(--ink-line, var(--border)); }
.spk-hero-sym > span { font-size: 2.3rem; font-weight: 800; line-height: 1; }
.spk-hero-sym[class*=" t"] { position: relative; }
.spk-hero-sym.t1 { --tone: var(--t1); } .spk-hero-sym.t2 { --tone: var(--t2); } .spk-hero-sym.t3 { --tone: var(--t3); }
.spk-hero-sym.t4 { --tone: var(--t4); } .spk-hero-sym.t5 { --tone: var(--t5); } .spk-hero-sym.t6 { --tone: var(--t6); }
.spk-hero-sym[class*=" t"] > span { position: absolute; right: 8px; bottom: 6px; font-size: 1.2rem; color: var(--tone); }
.spk-hero-tx h1 { margin: 6px 0 2px; font-size: 1.35rem; line-height: 1.25; }
.spk-hero-vi { margin: 0; color: var(--muted); }
.spk-hero-score { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.spk-hero-score small { font-size: .72rem; }
.spk-contour { width: 100px; height: 68px; }
.spk-contour line { stroke: var(--border); stroke-width: 1; }
.spk-contour path { stroke-width: 7; stroke-linecap: round; fill: none; }
.spk-how ul { margin: 0; padding-left: 20px; }
.spk-how li + li { margin-top: 4px; }
.spk-check { margin: 10px 0 0; }
.spk-check .ic { color: var(--accent-2); vertical-align: -3px; }
.spk-tnote { margin-bottom: 12px; }
.notice.warn { background: color-mix(in srgb, var(--bad) 8%, transparent); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.spk-nb { margin-top: 16px; }
@media (max-width: 560px) {
  .spk-hero { grid-template-columns: auto minmax(0, 1fr); }
  .spk-hero-score { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; }
  .spk-hero-sym { min-width: 72px; height: 72px; }
  .spk-hero-sym > span { font-size: 1.8rem; }
  .spk-contour { width: 76px; height: 52px; }
}

/* nghe phân biệt */
.spk-pq-q { display: grid; gap: 12px; justify-items: start; }
.spk-pq-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.spk-pq-o { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; min-height: 76px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 1.15rem; cursor: pointer; }
.spk-pq-o .z { font-family: var(--font-zh); font-size: 1.5rem; }
.spk-pq-o:hover { border-color: var(--accent-2); }
.spk-pq-o.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.spk-pq-o.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.spk-pq-o.dim { opacity: .55; }
.spk-pq-fb { min-height: 1.4em; }
.spk-pq-end { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Jyutping tách phần */
.jp-p { white-space: nowrap; }
.jp-p.t1 { color: var(--t1); } .jp-p.t2 { color: var(--t2); } .jp-p.t3 { color: var(--t3); }
.jp-p.t4 { color: var(--t4); } .jp-p.t5 { color: var(--t5); } .jp-p.t6 { color: var(--t6); }
.jp-p .fx { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }

/* danh sách từ */
.spk-list { list-style: none; margin: 0; padding: 0; }
.spk-list.card { padding: 4px 14px; }
.spk-list li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); }
.spk-list li:first-child { border-top: 0; }
.spk-list a { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; padding: 10px 0; color: var(--text); text-decoration: none; }
.spk-list .zh { font-family: var(--font-zh); font-size: 1.45rem; line-height: 1.25; overflow-wrap: anywhere; }
.spk-list .spk-l-jp { min-width: 0; }
.spk-list small { flex-basis: 100%; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spk-l-jp { font-size: .92rem; }
.spk-l-jp b { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.spk-l-jp b.t1 { color: var(--t1); } .spk-l-jp b.t2 { color: var(--t2); } .spk-l-jp b.t3 { color: var(--t3); }
.spk-l-jp b.t4 { color: var(--t4); } .spk-l-jp b.t5 { color: var(--t5); } .spk-l-jp b.t6 { color: var(--t6); }
.spk-sent { padding: 10px 0; border-top: 1px solid var(--border); }
.spk-sent:first-of-type { border-top: 0; }
.spk-sent .row { margin-top: 4px; }

/* trang từ: từng âm */
.spk-word .spk-card { margin: -4px 0 8px; }
.spk-auto { font-size: .85rem; }
.spk-break-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.spk-break-row:first-of-type { border-top: 0; }
.spk-break-p { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.spk-break-p .chip { text-decoration: none; color: var(--text); }
.spk-break-p .chip.t1 b { color: var(--t1); } .spk-break-p .chip.t2 b { color: var(--t2); } .spk-break-p .chip.t3 b { color: var(--t3); }
.spk-break-p .chip.t4 b { color: var(--t4); } .spk-break-p .chip.t5 b { color: var(--t5); } .spk-break-p .chip.t6 b { color: var(--t6); }
.spk-break-p small { flex-basis: 100%; }

/* ===== thẻ luyện nói ===== */
.spk-card { display: grid; gap: 14px; justify-items: center; text-align: center; }
.spk-target { display: grid; gap: 6px; justify-items: center; }
.spk-zh { font-family: var(--font-zh-serif, var(--font-zh)); font-weight: 700; font-size: clamp(2.2rem, 9vw, 3.4rem); line-height: 1.15; letter-spacing: .04em; overflow-wrap: anywhere; }
.spk-zh .spk-c { transition: color .3s; }
.spk-zh .st-ok { color: var(--ok); }
.spk-zh .st-tone { color: var(--warn); }
.spk-zh .st-part, .spk-zh .st-miss { color: var(--bad); }
.spk-jp { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.spk-s { border: 1px solid transparent; background: transparent; padding: 3px 7px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 1.15rem; font-weight: 600; color: var(--text); }
.spk-s:hover { background: var(--surface-2); border-color: var(--border); }
.spk-s.scored .jp-p { color: var(--text); }
.spk-s .ok { color: var(--ok); }
.spk-s .bad { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 4px; }
.spk-vi { color: var(--muted); font-size: 1rem; }
.spk-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.spk-mic-zone { display: flex; align-items: center; justify-content: center; gap: 22px; margin-top: 4px; }
.spk-side { display: grid; justify-items: center; gap: 2px; width: 64px; padding: 8px 0; border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; border-radius: 12px; }
.spk-side svg { width: 24px; height: 24px; padding: 10px; box-sizing: content-box; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); }
.spk-side small { font-size: .72rem; color: var(--muted); }
.spk-side:disabled { opacity: .4; cursor: default; }
.spk-mic { position: relative; width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--ink-line, transparent); background: var(--minibus-red, var(--accent)); color: var(--on-accent, #fff); display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 0 color-mix(in srgb, var(--minibus-red, var(--accent)) 55%, #000); transition: transform .1s; }
.spk-mic svg { width: 36px; height: 36px; position: relative; z-index: 1; }
.spk-mic:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--minibus-red, var(--accent)) 55%, #000); }
.spk-mic .spk-lv { --lv: 0; position: absolute; inset: -6px; border-radius: 50%; border: 4px solid color-mix(in srgb, var(--minibus-red, var(--accent)) 45%, transparent); transform: scale(calc(1 + var(--lv) * .35)); opacity: 0; transition: transform .08s linear; pointer-events: none; }
.spk-mic.on .spk-lv { opacity: 1; }
:root:not([data-fx="less"]) .spk-mic.on { animation: spk-pulse 1.4s ease-in-out infinite; }
@keyframes spk-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--minibus-red, var(--accent)) 40%, transparent); } 50% { box-shadow: 0 0 0 14px transparent; } }
.spk-hint { min-height: 1.4em; color: var(--muted); font-size: .9rem; max-width: 46ch; }
.spk-out { width: 100%; text-align: left; }
.spk-res { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.spk-res-head { display: flex; gap: 14px; align-items: center; }
.spk-break { font-size: .84rem; }
.spk-heard { font-size: .82rem; }
.spk-tips { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.spk-tk { display: block; font-weight: 700; font-size: .82rem; color: var(--bad); }
.spk-tip-act { gap: 6px; margin-top: 4px; }
.spk-perfect { margin: 0; color: var(--ok); font-weight: 700; }
.spk-self .btn.on { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 14%, var(--surface)); }

/* ===== màn luyện ===== */
.spk-ses .ses-top { padding-bottom: 6px; }
.spk-ses-n { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: .9rem; }
.spk-ses-stage { flex: 1; padding: 18px 0 170px; }
.spk-intro { text-align: center; display: grid; gap: 10px; justify-items: center; max-width: 560px; margin: 20px auto 0; }
.spk-intro-ic { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--minibus-red, var(--accent)) 14%, var(--surface)); color: var(--minibus-red, var(--accent)); border: 3px solid currentColor; }
.spk-intro-ic svg { width: 38px; height: 38px; }
.spk-intro h1 { margin: 4px 0 0; }
.spk-intro p { margin: 0; }
.spk-intro ul { text-align: left; margin: 0; padding-left: 20px; font-size: .9rem; }
.spk-intro-focus { justify-content: center; gap: 6px; }
.spk-sum { list-style: none; margin: 8px 0 0; padding: 0; width: 100%; max-width: 520px; text-align: left; }
.spk-sum li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.spk-sum-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.spk-sum li .zh { font-family: var(--font-zh); font-size: 1.2rem; line-height: 1.3; overflow-wrap: anywhere; }
.spk-sum li .spk-l-jp { font-size: .84rem; overflow-wrap: anywhere; }
.spk-sum li.skip { opacity: .6; }
.spk-test-res { width: 100%; max-width: 520px; display: grid; gap: 10px; text-align: center; }
.spk-test-rings { justify-content: center; gap: 22px; }
.spk-test-rings > span { display: grid; justify-items: center; gap: 4px; font-size: .82rem; color: var(--muted); }
.spk-test-res .chip { text-decoration: none; font-weight: 700; color: var(--band); }

/* ô lớn ở trang Luyện tập */
.spk-hub-hero { border-left: 4px solid var(--l-purple); }
.spk-hub-hero .hh-ring { flex: 0 0 auto; }
