/* Hán Ngữ SyncPad — Stylesheet (Light & Dark Theme, iPad + Desktop responsive) */

:root {
  --bg: #e9e1cf;
  --p: #f7f2e5;
  --ink: #1c1914;
  --mut: #7b7264;
  --red: #b3281a;
  --line: #d6cbb2;
  --grid: #d9a99f;
  --card: #fffdf6;
  --pad: #fffdf6;
  --hl: #ecd9d2;
  --soft: #faf6ea;
  --asp: #f6e3dd;
  --hd: #1c1914;
  --hdt: #f7f2e5;
  --tt: #6b2a20;
  --amb: #8a5a1d;
  --ink2: #3b362d;
  --bd: #1c1914;
  --han: "Kaiti SC", "STKaiti", "Kaiti TC", "BiauKai", "Songti SC", "Noto Serif CJK SC", serif;
  color-scheme: light;
}

:root[data-t="dark"] {
  --bg: #111215;
  --p: #181a1f;
  --ink: #ece6d6;
  --mut: #9b9588;
  --red: #e4604f;
  --line: #2f333a;
  --grid: #6b5552;
  --card: #20232a;
  --pad: #1b1d22;
  --hl: #3a2b29;
  --soft: #1c1e24;
  --asp: #3b2724;
  --hd: #0b0c0e;
  --hdt: #ece6d6;
  --tt: #e6a79c;
  --amb: #d8a35a;
  --ink2: #cfc9ba;
  --bd: #4b505a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

::selection {
  background: transparent;
}

input, textarea, .sel {
  -webkit-user-select: text;
  user-select: text;
}

input::selection, textarea::selection, .sel::selection {
  background: var(--hl);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

[hidden] {
  display: none !important;
}

/* ---------- Header ---------- */
header {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 7px 12px;
  background: var(--hd);
  color: var(--hdt);
  overflow-x: auto;
}

header .seal {
  background: var(--red);
  color: #fff;
  font: 700 17px var(--han);
  padding: 2px 7px;
  border-radius: 2px;
  letter-spacing: 1px;
  flex: none;
}

select, button {
  font: inherit;
  color: var(--ink);
  background: var(--p);
  border: 1px solid var(--bd);
  border-radius: 3px;
  padding: 6px 11px;
  touch-action: manipulation;
  cursor: pointer;
}

header select {
  flex: 1;
  min-width: 110px;
  max-width: 440px;
  background: #2b2721;
  color: #f7f2e5;
  border-color: #5b5446;
}

#vs {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: 124px;
  font-weight: 600;
}

header button {
  background: transparent;
  color: var(--hdt);
  border-color: #5b5446;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

header button.on {
  background: var(--hdt);
  color: var(--hd);
}

header button svg {
  display: block;
}

#st {
  margin-left: auto;
  font-size: 12px;
  color: #b9ae98;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 24%;
}

button:active {
  transform: translateY(1px);
}

button:focus {
  outline: none;
}

button.on, button.on * {
  background: var(--ink);
  color: var(--p);
}

button.on * {
  background: none;
}

button.on small {
  color: inherit;
  opacity: .8;
}

button.red {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* ---------- Main Split Layout ---------- */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pv {
  height: var(--vh, 42%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 2px solid var(--bd);
}

.pw {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--p);
}

#dv {
  flex: 0 0 16px;
  position: relative;
  touch-action: none;
  cursor: row-resize;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

#dv i {
  display: block;
  width: 46px;
  height: 4px;
  border-radius: 2px;
  background: var(--mut);
  opacity: .7;
}

main.vcol .pv,
main.vcol #dv {
  display: none;
}

@media (orientation: landscape), (min-width: 760px) {
  main {
    flex-direction: row;
  }
  .pv {
    width: var(--vw, 41%);
    height: auto;
    border-bottom: 0;
    border-right: 0;
    flex: 0 0 auto;
  }
  #dv {
    cursor: col-resize;
  }
  #dv i {
    width: 4px;
    height: 46px;
  }
  .pw {
    flex: 1;
  }
  main.left .pv {
    order: 3;
  }
  main.left #dv {
    order: 2;
  }
  main.left .pw {
    order: 1;
  }
}

@media (orientation: portrait) and (max-width: 759px) {
  .pv {
    width: auto;
  }
}

/* ---------- Video & YouTube Panel ---------- */
.vbox {
  background: #14120f;
  aspect-ratio: 16 / 9;
  max-height: 46%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
}

video, #ytp, #ytp iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

video {
  object-fit: contain;
}

.vpick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  color: #d6cbb2;
}

.vpick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.vpick small {
  font-size: 12px;
  opacity: .8;
}

.vbar {
  display: flex;
  gap: 6px;
  padding: 7px 9px;
  flex-wrap: wrap;
  align-items: center;
}

.vbar button {
  padding: 5px 10px;
  font-size: 13px;
}

#ms {
  flex: 1;
  overflow: auto;
  padding: 2px 9px 12px;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.ts {
  display: flex;
  gap: 9px;
  align-items: baseline;
  margin-top: 11px;
  padding: 6px 8px;
  border-left: 4px solid var(--bd);
  background: var(--p);
  font-weight: 700;
  cursor: pointer;
}

.ts b {
  color: var(--red);
  font-weight: 600;
  font-size: 13px;
  min-width: 42px;
  font-variant-numeric: tabular-nums;
}

.tw {
  display: flex;
  gap: 9px;
  align-items: baseline;
  padding: 5px 8px 5px 14px;
  border-bottom: 1px dotted var(--line);
  color: var(--ink2);
  cursor: pointer;
}

.tw b {
  color: var(--mut);
  font-weight: 400;
  font-size: 12px;
  min-width: 42px;
  font-variant-numeric: tabular-nums;
}

.tw .han {
  font: 20px var(--han);
  min-width: 30px;
  color: var(--ink);
}

.tw small {
  color: var(--mut);
}

.ts.on, .tw.on {
  background: var(--hl);
  box-shadow: inset 4px 0 0 var(--red);
}

/* ---------- Navigation Tabs & Pane ---------- */
nav {
  display: flex;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  background: var(--bg);
}

nav button {
  flex: 1 0 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  padding: 11px 12px 8px;
  white-space: nowrap;
  color: var(--mut);
}

nav button.on, nav button.on * {
  background: none;
  color: var(--ink);
}

nav button.on {
  font-weight: 700;
  border-bottom-color: var(--red);
}

#pane {
  flex: 1;
  overflow: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

h3 {
  margin: 16px 0 7px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mut);
}

h3:first-child {
  margin-top: 0;
}

/* ---------- Cards & Content ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--bd);
  padding: 11px 12px;
  margin-bottom: 11px;
}

.card h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.card p {
  margin: 5px 0;
}

.tt {
  border-left: 3px solid var(--red);
  padding: 2px 0 2px 9px;
  color: var(--tt);
  font-size: 13.5px;
  font-style: italic;
}

.tt:before {
  content: "Thầy dặn · ";
  font-style: normal;
  font-weight: 700;
  color: var(--red);
  font-size: 12px;
}

.g {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 6px;
}

.c {
  text-align: left;
  padding: 7px 9px;
}

.c .han {
  font: 22px var(--han);
}

.c small {
  display: block;
  color: var(--mut);
  font-size: 11.5px;
  line-height: 1.25;
}

.c.asp {
  border-color: var(--red);
  background: var(--asp);
}

.c.tm b {
  font-size: 19px;
  display: block;
  line-height: 1.3;
}

.c.tm small {
  margin-top: 2px;
}

.g4 {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.g4 > div {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 6px;
}

.g4 .c {
  min-width: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
  align-items: center;
}

.row > b {
  min-width: 34px;
  color: var(--red);
  font-size: 17px;
}

.row > small {
  color: var(--mut);
  min-width: 84px;
}

.sy {
  padding: 6px 10px;
}

.dl {
  display: flex;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px dotted var(--line);
  cursor: pointer;
}

.dl.act {
  background: var(--hl);
}

.dl .sp {
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--ink);
  color: var(--p);
  text-align: center;
  line-height: 24px;
  font-weight: 700;
  font-size: 12px;
  flex: none;
  border-radius: 2px;
}

.dl b {
  display: block;
  font: 24px var(--han);
  font-weight: 400;
}

.dl small {
  display: block;
  color: var(--mut);
  font-size: 13.5px;
}

.dl small.pyl {
  color: var(--amb);
}

.hpy .pyl, .hvi .vil {
  visibility: hidden;
}

.hpy .pyl.show, .hvi .vil.show {
  visibility: visible;
}

.exl {
  padding: 6px 9px;
  border-left: 3px solid var(--line);
  margin: 5px 0;
  background: var(--soft);
  cursor: pointer;
}

.exl b {
  display: block;
  font: 20px var(--han);
  font-weight: 400;
}

.exl small {
  display: block;
  color: var(--mut);
}

.han {
  font-family: var(--han);
}

.seal {
  display: inline-block;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 11px;
  padding: 0 6px;
  letter-spacing: .04em;
  margin-right: 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chips button {
  min-width: 44px;
}

.chips button .han {
  font-size: 22px;
}

.chips button.d {
  border-color: var(--red);
  box-shadow: inset 0 -3px 0 var(--red);
}

.chips button.sm {
  font-size: 12.5px;
  padding: 4px 8px;
  min-width: 36px;
}

.chips button.on .han {
  color: inherit;
}

/* ---------- Writing & Dictation ---------- */
.wr {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.grid {
  position: relative;
  background: var(--pad);
  border: 2px solid var(--bd);
  touch-action: none;
}

.grid > * {
  position: relative;
  z-index: 1;
}

.grid::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: none;
  background: var(--grid);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M50 0V100M0 50H100M0 0L100 100M100 0L0 100' stroke='black' stroke-width='.7' stroke-dasharray='3 2.5' fill='none'/%3E%3C/svg%3E") 0 0 / calc(100% / var(--n, 1)) 100% repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M50 0V100M0 50H100M0 0L100 100M100 0L0 100' stroke='black' stroke-width='.7' stroke-dasharray='3 2.5' fill='none'/%3E%3C/svg%3E") 0 0 / calc(100% / var(--n, 1)) 100% repeat-x;
}

body.mz #hw::before,
body.mz .dpad .grid::before {
  display: block;
}

#hw {
  width: min(310px, 100%);
  aspect-ratio: 1;
}

#hw svg {
  touch-action: none;
  width: 100%;
  height: 100%;
}

.inf {
  flex: 1;
  min-width: 210px;
}

.inf p {
  margin: 5px 0;
}

.inf i {
  color: var(--mut);
  font-style: normal;
  font-size: 12.5px;
  margin-right: 4px;
}

.inf .big {
  font: 54px/1 var(--han);
}

canvas.pad {
  width: 100%;
  height: 240px;
  display: block;
}

.dpad {
  margin: 9px auto;
  width: min(100%, calc(var(--n, 1) * 250px));
  aspect-ratio: var(--ar, 1);
}

.dpad canvas.pad {
  height: 100%;
}

.row2 {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 9px 0;
}

.row2 button {
  flex: 1;
  min-width: 76px;
}

.ans {
  text-align: center;
  background: var(--soft);
  border: 1px dashed var(--mut);
  padding: 8px;
  margin: 9px 0;
}

.ans .big {
  font: 58px/1.1 var(--han);
}

.ansTop {
  text-align: center;
  background: var(--soft);
  border: 1px dashed var(--mut);
  padding: 6px 8px;
  margin: 0 0 9px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ansTop.off > * {
  visibility: hidden;
}

.ansTop .big {
  font: 58px/1.1 var(--han);
}

.jd {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.jd button {
  flex: 1;
  padding: 18px 10px;
  font-size: 19px;
  font-weight: 700;
}

.py {
  color: var(--red);
}

.vi {
  font-size: 16px;
}

.gray {
  color: var(--mut);
}

.tip {
  color: var(--tt);
}

/* ---------- SRS, Quiz, Match & Flashcard ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 11px;
}

.stats div {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 9px;
  text-align: center;
}

.stats b {
  display: block;
  font-size: 24px;
  color: var(--red);
}

.stats small {
  color: var(--mut);
}

.fc {
  text-align: center;
  padding: 20px 12px;
}

.fc .han {
  font-size: 76px;
  line-height: 1.1;
  border: 0;
  background: none;
}

.fc-body {
  min-height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 6px;
  cursor: pointer;
}

.fc-back {
  width: 100%;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
  margin-top: 8px;
}

.fc-rates {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.fc-rates button {
  padding: 10px 6px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.fc-rates button small {
  font-size: 11px;
  font-weight: 400;
  opacity: .85;
}

.fc-rates .r-again {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.fc-rates .r-hard {
  background: #8a5a1d;
  color: #fff;
  border-color: #8a5a1d;
}

.fc-rates .r-good {
  background: #27502c;
  color: #fff;
  border-color: #27502c;
}

.fc-rates .r-easy {
  background: #1f5578;
  color: #fff;
  border-color: #1f5578;
}

.ok {
  background: #27502c;
  color: #fff;
  border-color: #27502c;
}

.no {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.tbar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0 10px;
}

.tbar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--red);
}

.combo {
  font-weight: 800;
  color: var(--mut);
  min-width: 90px;
  text-align: right;
}

.combo.hot {
  color: var(--red);
  font-size: 20px;
}

@keyframes pop {
  0% { transform: scale(.7); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.combo:not(:empty) {
  animation: pop .35s;
}

.gq {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.gq button {
  min-height: 78px;
  padding: 14px 8px;
  font-size: 19px;
}

.gm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gm > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gm button {
  min-height: 62px;
  padding: 10px 8px;
}

.gq button.ok, .gm button.ok {
  background: #27502c;
  color: #fff;
  border-color: #27502c;
}

.gq button.no, .gm button.no {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.gq button:disabled, .gm button:disabled {
  opacity: 1;
}

.gm button.ok:disabled {
  opacity: .6;
}

/* ---------- Book Viewer & Textbook Vocab ---------- */
.bkbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.bkbar button {
  flex: 0 0 auto;
  padding: 9px 14px;
}

.bkpg {
  flex: 1;
  text-align: center;
  font-weight: 700;
}

.bkpg small {
  color: var(--mut);
  font-weight: 400;
}

.bkv {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  height: calc(100vh - 290px);
  min-height: 300px;
  background: #fff;
  border: 1px solid var(--line);
  touch-action: pan-x pan-y;
}

.bkv img {
  display: block;
  max-width: none;
  height: auto;
}

.bkv.dk img {
  filter: invert(.92) hue-rotate(180deg);
}

.bkv.dk {
  background: #161616;
}

.vw {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 4px;
  border-bottom: 1px dotted var(--line);
  cursor: pointer;
}

.vw .han {
  font-size: 30px;
  min-width: 96px;
  color: var(--ink);
}

.vw small {
  margin-left: 6px;
}

.vw .vi {
  font-size: 15px;
}

/* ---------- Grammar Tables & Pinyin Matrix ---------- */
.gtw {
  overflow-x: auto;
}

.gt {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

.gt th, .gt td {
  border: 1px solid rgba(128, 128, 128, .5);
  padding: 3px;
  text-align: center;
}

.gt thead th {
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 2;
}

.gt th small {
  display: block;
  opacity: .7;
  font-size: 11px;
}

.gt td.em {
  background: repeating-linear-gradient(135deg, rgba(128, 128, 128, .14) 0 4px, transparent 4px 8px);
}

.gt td:hover {
  background: rgba(200, 80, 60, .14);
}

.gt .sy {
  width: 100%;
  margin: 0;
}

.gt tbody th, .gt thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #202228;
}

html[data-t="light"] .gt tbody th,
html[data-t="light"] .gt thead th:first-child {
  background: #f4f0e6;
}

.fm {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 10px 0;
}

.fm span {
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(128, 128, 128, .2);
}

.fm span.k {
  background: #c9452f;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}

.fm i {
  opacity: .5;
  font-style: normal;
}

.gx {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(128, 128, 128, .25);
  cursor: pointer;
}

.gxm {
  flex: 1;
  min-width: 0;
}

.gv {
  font-size: 13.5px;
  color: var(--mut);
  margin-top: 4px;
}

.gl {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
}

.gx mark {
  background: none;
  color: #e0694f;
  font-weight: 700;
}

.gw {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  vertical-align: top;
}

.gpy {
  font: 400 12px/1.25 system-ui, -apple-system, sans-serif;
  color: var(--mut);
  white-space: nowrap;
}

.gh {
  font-size: 26px;
  line-height: 1.15;
}

.gx .gh {
  font-size: 28px;
}

.gw .gm {
  display: block;
  font: 400 11.5px/1.25 system-ui, -apple-system, sans-serif;
  color: var(--mut);
  white-space: nowrap;
  min-height: 1.25em;
}

.spk {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--mut);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: color .15s, border-color .15s, background .15s;
}

button.spk:active, .gx:active .spk {
  color: var(--red);
  border-color: var(--red);
  background: var(--hl);
}

.gtb {
  border-collapse: collapse;
  width: 100%;
}

.gtb th {
  padding: 6px 8px;
  font-size: 13px;
  background: rgba(128, 128, 128, .18);
  border: 1px solid rgba(128, 128, 128, .4);
}

.gtb th.k {
  background: #c9452f;
  color: #fff;
  font-size: 20px;
}

.gtb td {
  border: 1px solid rgba(128, 128, 128, .35);
  padding: 6px 8px 4px;
  font-size: 26px;
  text-align: center;
}

.gtb td.spc {
  width: 56px;
  padding: 4px;
}

.gtb td.k .gh {
  color: #e0694f;
  font-weight: 700;
}

.gtb tr.pv td {
  font-size: 13.5px;
  text-align: center;
  color: var(--mut);
  font-style: italic;
  border-top: 0;
  padding: 2px 8px 8px;
}

.rl {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 10px 0;
}

.rk {
  min-width: 46px;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  background: #c9452f;
  border-radius: 8px;
  padding: 2px 8px;
}

.rl small {
  opacity: .7;
}

.rt {
  min-width: 90px;
  max-width: 150px;
  font-weight: 700;
  border-left: 4px solid #c9452f;
  padding-left: 8px;
}

/* ---------- Offline Packs, Docs & Backup ---------- */
.pklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.pkrow {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  flex-wrap: wrap;
}

.pkinfo {
  flex: 1 1 180px;
  min-width: 0;
}

.pkinfo b {
  display: block;
  font-size: 14px;
}

.pkinfo small {
  display: block;
  color: var(--mut);
  font-size: 12px;
}

.pkbar {
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 5px;
}

.pkbar i {
  display: block;
  height: 100%;
  background: var(--red);
  transition: width .2s;
}

.pkact {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.pkact button {
  padding: 6px 10px;
  font-size: 13px;
}

.vlk {
  font-size: 13px;
  color: var(--mut);
  font-style: italic;
  padding: 4px 10px 6px;
}

.vlk a {
  color: var(--red);
  font-style: normal;
  text-decoration: underline;
}

.lk {
  display: block;
  text-align: center;
  padding: 11px 10px;
  border: 1px solid var(--bd);
  background: var(--p);
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  line-height: 1.25;
}

.lk small {
  display: block;
  font-weight: 400;
  color: var(--mut);
  font-size: 12px;
  margin-top: 2px;
}

.lk.sm2 {
  flex: 0 0 auto;
  font-weight: 600;
  padding: 9px 12px;
}

.dc {
  padding: 12px;
}

.dcr {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.kgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px 12px;
  margin-top: 8px;
  font-size: 13px;
}

.kgrid div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kbd {
  display: inline-block;
  padding: 2px 6px;
  font: 600 11.5px ui-monospace, SFMono-Regular, Consolas, monospace;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  min-width: 24px;
  text-align: center;
}

.dcs {
  text-align: center;
  margin-top: 12px;
}

.dcs ruby {
  font: 18px var(--han);
  ruby-align: center;
  margin: 0 2px;
  color: var(--ink);
}

.dcs rt {
  font: 400 11px system-ui, -apple-system, sans-serif;
  color: var(--mut);
}

.dcv {
  font-size: 13px;
  color: var(--mut);
  margin-top: 5px;
}

.verln {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
  color: var(--mut);
  opacity: .8;
}

/* ---------- Global Search Modal ---------- */
.smod {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .58);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 12px 16px;
}

.sbox {
  width: min(640px, 100%);
  max-height: 86vh;
  background: var(--card);
  border: 1px solid var(--bd);
  border-top: 3px solid var(--red);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
}

.shead {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--p);
  align-items: center;
}

.sinp {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 4px;
}

.sinp:focus {
  outline: 2px solid var(--red);
  outline-offset: -1px;
}

.sres {
  flex: 1;
  overflow: auto;
  padding: 6px 12px 12px;
  -webkit-overflow-scrolling: touch;
}

.sitem {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px dotted var(--line);
}

.sitem-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.sitem-han {
  font: 22px var(--han);
  color: var(--ink);
  margin-right: 6px;
}

.sitem-meta {
  font-size: 13px;
  color: var(--mut);
}

.sitem-act {
  display: flex;
  gap: 6px;
  flex: none;
}

.sitem-act button {
  padding: 5px 9px;
  font-size: 12.5px;
}

.sbadge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--mut);
  margin-right: 6px;
}

/* ============================================================================
 * Hán Ngữ SyncPad (v9.0) — Auth Gate, Cloud Sync, Streak & Pronunciation UI
 * ============================================================================ */

/* Header Controls */
.hdr-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  font-size: 13px;
  border-radius: 6px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}

.hdr-btn:hover {
  border-color: var(--red);
  background: var(--hl);
}

.hdr-streak .flame {
  font-size: 15px;
  filter: drop-shadow(0 0 2px rgba(230, 80, 50, 0.5));
}

.hdr-streak span:last-child {
  font-weight: 700;
  color: var(--red);
}

.hdr-sync {
  font-size: 12px;
}

.hdr-sync.synced #sync_icon {
  filter: hue-rotate(85deg);
}

.hdr-sync.syncing #sync_icon {
  animation: spin 1s infinite linear;
}

.hdr-sync.error {
  border-color: #e55353;
  color: #e55353;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hdr-user {
  gap: 6px;
  max-width: 130px;
}

.u-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: var(--line);
  overflow: hidden;
  flex: none;
}

.u-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.u-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Auth Gate (Bắt buộc đăng nhập) */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(10, 12, 16, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.auth-card {
  max-width: 440px;
  width: 100%;
  background: var(--p);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  text-align: center;
  position: relative;
}

.auth-brand {
  margin-bottom: 16px;
}

.auth-seal {
  font-size: 32px;
  display: inline-flex;
  width: 52px;
  height: 52px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  margin-bottom: 8px;
}

.auth-brand h2 {
  font: 26px var(--han);
  margin: 0 0 4px;
  color: var(--red);
  letter-spacing: 0.5px;
}

.auth-sub {
  margin: 0;
  font-size: 13px;
  color: var(--mut);
}

.auth-notice {
  background: var(--hl);
  border-left: 3px solid var(--red);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  text-align: left;
  margin-bottom: 20px;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 18px 0 16px;
  color: var(--mut);
  font-size: 12.5px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-divider span {
  padding: 0 10px;
}

.auth-pane {
  text-align: left;
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: all .2s ease;
}

.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.auth-hint {
  font-size: 12.5px;
  color: var(--mut);
  line-height: 1.4;
  margin: 12px 0 0;
  text-align: center;
}

.auth-field {
  margin-bottom: 14px;
}

.auth-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}

.auth-field input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  outline: none;
}

.auth-field input:focus {
  border-color: var(--red);
}

.auth-btns {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.btn-primary {
  flex: 1;
  background: var(--red);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  flex: 1;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13.5px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--hl);
}

.auth-msg {
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
}

.auth-msg.error {
  background: #fde8e8;
  color: #c81e1e;
  border: 1px solid #f8b4b4;
}

.auth-msg.success {
  background: #def7ec;
  color: #03543f;
  border: 1px solid #bcf0da;
}

.auth-footer-ver {
  margin-top: 18px;
  text-align: center;
  font-size: 11.5px;
  color: var(--mut);
  opacity: 0.8;
  letter-spacing: .3px;
}

/* Generic Modals */
.cmodal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cbox {
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--p);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}

.chead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.chead h3 {
  margin: 0;
  font-size: 17px;
  color: var(--ink);
}

.ccls {
  border: none;
  background: var(--soft);
  border: 1px solid var(--line);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mut);
  font-size: 13px;
}

.ccls:hover {
  color: var(--ink);
  background: var(--hl);
}

/* User Modal Info */
.user-card-info {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 14px;
}

.u-avatar-big {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--soft);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  overflow: hidden;
  flex: none;
}

.u-avatar-big img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sync-banner {
  background: var(--hl);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.4;
}

.sync-banner b {
  display: block;
  font-size: 14px;
  color: var(--red);
  margin: 3px 0;
}

.modal-actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-action {
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}

.btn-action:hover {
  background: var(--soft);
  border-color: var(--red);
}

.btn-action.danger {
  color: #e55353;
  margin-top: 6px;
}

.btn-action.danger:hover {
  background: #fde8e8;
  border-color: #e55353;
}

/* Streak & Heatmap Modal */
.streak-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 16px;
}

.flame-big {
  font-size: 46px;
  filter: drop-shadow(0 0 6px rgba(230, 70, 30, 0.6));
}

.streak-huge {
  font-size: 28px;
  font-weight: 800;
  color: var(--red);
  line-height: 1.1;
}

.streak-huge small {
  font-size: 14px;
  font-weight: 500;
  color: var(--mut);
}

.streak-sub {
  font-size: 13px;
  color: var(--mut);
  margin-top: 4px;
}

.streak-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}

.stat-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.stat-lbl {
  font-size: 11px;
  color: var(--mut);
  margin-top: 2px;
}

.stk-heatmap {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  background: var(--card);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}

.stk-dot {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--line);
  position: relative;
  transition: transform .1s;
}

.stk-dot:hover {
  transform: scale(1.2);
}

.stk-dot.l0 { background: var(--soft); border: 1px solid var(--line); }
.stk-dot.l1 { background: #85e89d; }
.stk-dot.l2 { background: #34d058; }
.stk-dot.l3 { background: #22863a; }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 11.5px;
  color: var(--mut);
  margin-bottom: 18px;
}

.heatmap-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.heatmap-legend .dot.l0 { background: var(--soft); border: 1px solid var(--line); }
.heatmap-legend .dot.l1 { background: #85e89d; }
.heatmap-legend .dot.l2 { background: #34d058; }
.heatmap-legend .dot.l3 { background: #22863a; }

.modal-footer-btns {
  margin-top: 14px;
}

/* Share Story Modal */
.share-cbox {
  max-width: 420px;
}

.share-preview-wrap {
  width: 100%;
  max-height: 58vh;
  overflow: hidden;
  border-radius: 12px;
  border: 2px solid var(--red);
  background: #0f141c;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.share-preview-wrap canvas {
  width: 100%;
  height: auto;
  max-height: 58vh;
  object-fit: contain;
  display: block;
}

.share-actions-row {
  display: flex;
  gap: 10px;
}

/* Pronunciation (Micro) UI */
.btn-mic {
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all .2s ease;
  flex: none;
  margin-left: 6px;
}

.btn-mic:hover {
  background: var(--hl);
  border-color: var(--red);
  transform: scale(1.05);
}

.btn-mic.listening {
  background: #fee2e2;
  border-color: #ef4444;
  color: #dc2626;
  animation: pulse-ring 1.2s infinite ease-out;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.voice-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  max-width: 380px;
  width: calc(100% - 48px);
  background: var(--p);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
  animation: slide-up .25s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.voice-toast-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}

.vt-icon {
  font-size: 24px;
  flex: none;
}

.vt-content {
  flex: 1;
  min-width: 0;
}

.vt-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 2px;
}

.vt-target {
  font: 16px var(--han);
  color: var(--red);
  margin-bottom: 4px;
}

.vt-result {
  font-size: 13px;
  color: var(--mut);
}

.vt-result .score-good {
  color: #057a55;
  font-weight: 700;
}

.vt-result .score-mid {
  color: #d97706;
  font-weight: 600;
}

.vt-result .score-bad {
  color: #e02424;
}

.vt-close {
  background: transparent;
  border: none;
  color: var(--mut);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
}

.vt-close:hover {
  color: var(--ink);
}

/* ---------- Phase 1: Quiz & Game Studio (Luyện thi 🎮) ---------- */
.quiz-hub {
  max-width: 680px;
  margin: 0 auto;
}

.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.quiz-mode-pill {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 3px;
  gap: 4px;
}

.quiz-mode-pill button {
  border: none;
  background: none;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  color: var(--mut);
  transition: all .15s;
}

.quiz-mode-pill button:hover {
  color: var(--ink);
}

.quiz-mode-pill button.on {
  background: var(--red);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(224, 60, 49, 0.3);
}

.quiz-stat-pill {
  font-size: 13px;
  color: var(--mut);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.quiz-stat-pill b {
  color: var(--ink);
}

/* Quiz Card Frame */
.quiz-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.quiz-timer-wrap {
  width: 100%;
  height: 6px;
  background: var(--soft);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.quiz-timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  transition: width 0.05s linear;
}

.quiz-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--mut);
}

.quiz-combo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 700;
  animation: bounce-in .3s ease-out;
}

@keyframes bounce-in {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.quiz-prompt-box {
  text-align: center;
  padding: 16px 10px;
  margin-bottom: 20px;
}

.quiz-prompt-han {
  font: 700 52px/1.2 var(--han);
  color: var(--ink);
  margin-bottom: 6px;
}

.quiz-prompt-vi {
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.quiz-prompt-py {
  font-size: 17px;
  color: var(--red);
  font-weight: 500;
  margin-top: 4px;
}

.quiz-prompt-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--soft);
  border: 2px solid var(--red);
  color: var(--red);
  font-size: 32px;
  cursor: pointer;
  transition: all .2s;
  margin: 10px auto;
}

.quiz-prompt-audio-btn:hover {
  transform: scale(1.08);
  background: var(--hl);
}

.quiz-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 580px) {
  .quiz-options-grid {
    grid-template-columns: 1fr;
  }
}

.quiz-opt-btn {
  background: var(--soft);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all .15s ease;
  color: var(--ink);
  font-size: 14.5px;
}

.quiz-opt-btn:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--hl);
  transform: translateY(-2px);
}

.quiz-opt-btn.correct {
  background: #d1fae5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
}

.quiz-opt-btn.wrong {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

.quiz-opt-han {
  font: 700 24px var(--han);
}

.quiz-opt-py {
  font-size: 13px;
  color: var(--red);
}

.quiz-opt-vi {
  font-size: 13.5px;
  color: var(--mut);
}

/* Sentence Scramble */
.scramble-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scramble-area {
  min-height: 84px;
  padding: 14px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--soft);
  transition: border-color .2s;
}

.scramble-area.target {
  border-color: var(--red);
  background: var(--card);
}

.scramble-area.target.correct-match {
  border-color: #10b981;
  background: #ecfdf5;
}

.scramble-chip {
  padding: 9px 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  font: 600 19px var(--han);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
}

.scramble-chip:hover {
  border-color: var(--red);
  background: var(--hl);
  transform: scale(1.05);
}

.scramble-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Result & Celebration */
.quiz-result-card {
  text-align: center;
  padding: 30px 20px;
}

.quiz-stars-row {
  font-size: 42px;
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.quiz-star {
  color: #e5e7eb;
  transition: color .3s ease;
}

.quiz-star.active {
  color: #f59e0b;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
  animation: bounce-in .4s ease-out;
}

.quiz-score-big {
  font-size: 44px;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
  margin-bottom: 6px;
}

.quiz-score-lbl {
  font-size: 13.5px;
  color: var(--mut);
  margin-bottom: 20px;
}

.quiz-stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.quiz-sum-cell {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.quiz-sum-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.quiz-sum-lbl {
  font-size: 11px;
  color: var(--mut);
  margin-top: 2px;
}

/* ---------- Phase 2: Leaderboard Community (Bảng xếp hạng 🏆) ---------- */
.hdr-ldr {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.hdr-ldr:hover {
  background: var(--hl);
  border-color: #f59e0b;
}

.ldr-cbox {
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.ldr-tabs-row {
  display: flex;
  background: var(--soft);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  margin-bottom: 14px;
}

.ldr-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--mut);
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
}

.ldr-tab-btn.on {
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Podium Top 3 */
.ldr-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 6px 4px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  max-width: 140px;
}

.podium-avatar-wrap {
  position: relative;
  margin-bottom: 6px;
}

.podium-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
}

.podium-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.podium-slot.rank-1 .podium-avatar {
  width: 62px;
  height: 62px;
  border: 3px solid #f59e0b;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.35);
}

.podium-slot.rank-2 .podium-avatar {
  border: 2.5px solid #9ca3af;
}

.podium-slot.rank-3 .podium-avatar {
  border: 2.5px solid #b45309;
}

.podium-badge {
  position: absolute;
  bottom: -6px;
  right: -4px;
  font-size: 16px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}

.podium-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score {
  font-size: 12px;
  color: var(--red);
  font-weight: 600;
  margin-top: 2px;
}

/* Leaderboard List */
.ldr-list-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
  margin-bottom: 12px;
  min-height: 140px;
  max-height: 36vh;
}

.ldr-item-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  gap: 12px;
  font-size: 13.5px;
  transition: background .15s;
}

.ldr-item-row:hover {
  background: var(--soft);
}

.ldr-item-row.is-me {
  border-color: var(--red);
  background: rgba(224, 60, 49, 0.08);
}

.ldr-rank-num {
  font-weight: 800;
  color: var(--mut);
  width: 28px;
  text-align: center;
  font-size: 13px;
}

.ldr-user-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  overflow: hidden;
  flex: none;
}

.ldr-user-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ldr-user-name {
  flex: 1;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ldr-user-val {
  font-weight: 700;
  color: var(--red);
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
}

/* My Rank Sticky Card */
.ldr-my-rank-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--soft);
  border: 1.5px solid var(--red);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  box-shadow: 0 4px 12px rgba(224, 60, 49, 0.12);
}

/* ---------- Phase 3: AI Hanzi Tutor (Gia sư AI 🤖) ---------- */
.btn-ai-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  border: 1.5px solid rgba(224, 60, 49, 0.45);
  border-radius: 36px;
  padding: 5px 16px 5px 6px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35), 0 0 16px rgba(224, 60, 49, 0.3);
  cursor: pointer;
  transition: all .25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-ai-float:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 32px rgba(224, 60, 49, 0.45), 0 0 20px rgba(224, 60, 49, 0.5);
  border-color: var(--red);
}

.ai-float-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #e03c31;
  box-shadow: 0 2px 8px rgba(224, 60, 49, 0.4);
  flex-shrink: 0;
}

.ai-float-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-float-pulse {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border: 2px solid #00e676;
  animation: call-pulse-ring 2s infinite ease-out;
  pointer-events: none;
}

.ai-float-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.ai-float-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
}

.ai-float-sub {
  font-size: 11px;
  color: #00e676;
  font-weight: 600;
}

@media (max-width: 480px) {
  .ai-float-info {
    display: none;
  }
  .btn-ai-float {
    padding: 3px;
    border-radius: 50%;
  }
  .ai-float-avatar {
    width: 46px;
    height: 46px;
  }
}

.ai-cbox {
  max-width: 580px;
  height: 88vh;
  max-height: 720px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.ai-cbox .chead {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
  background: var(--card);
}

.ai-head-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-head-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 3px 10px rgba(224, 60, 49, 0.25);
  border: 1.5px solid var(--line);
  flex-shrink: 0;
}

.ai-status-indicator {
  font-size: 11.5px;
  color: #10b981;
  font-weight: 500;
}

.ai-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mode Switcher Tabs */
.ai-mode-tabs {
  display: flex;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  padding: 6px 14px;
  gap: 8px;
  flex: none;
}

.ai-tab-btn {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--mut);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ai-tab-btn:hover {
  color: var(--ink);
  background: var(--card);
}

.ai-tab-btn.active {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ai-tab-btn[data-tab="call"].active {
  color: #00c853;
  border-color: rgba(0, 200, 83, 0.35);
  box-shadow: 0 2px 10px rgba(0, 200, 83, 0.15);
}

.ai-view-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

.ai-view-pane[hidden] {
  display: none !important;
}

.btn-quick-call {
  background: linear-gradient(135deg, #00c853, #009624);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(0, 200, 83, 0.35);
  transition: all .2s;
}

.btn-quick-call:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 14px rgba(0, 200, 83, 0.5);
}

/* Config Panel */
.ai-cfg-panel {
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  animation: slide-down .2s ease-out;
}

@keyframes slide-down {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.ai-cfg-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

/* Quick Chips */
.ai-chips-row {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  white-space: nowrap;
  flex: none;
}

.ai-chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--mut);
  cursor: pointer;
  transition: all .15s;
  flex: none;
}

.ai-chip:hover {
  background: var(--soft);
  border-color: var(--red);
  color: var(--ink);
}

/* Chat Messages */
.ai-messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

.ai-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: fade-in .2s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-msg.bot {
  align-self: flex-start;
}

.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex: none;
  border: 1px solid var(--line);
  overflow: hidden;
}

.ai-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-msg.bot .ai-msg-avatar {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.ai-msg-bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  word-break: break-word;
}

.ai-msg.user .ai-msg-bubble {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.ai-msg.user .ai-msg-bubble * {
  color: #fff;
}

.ai-msg-bubble p {
  margin: 0 0 6px;
}

.ai-msg-bubble p:last-child {
  margin-bottom: 0;
}

.ai-msg-bubble ul, .ai-msg-bubble ol {
  margin: 4px 0 6px 18px;
  padding: 0;
}

.ai-msg-bubble li {
  margin-bottom: 4px;
}

.ai-say-btn {
  border: none;
  background: var(--soft);
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--red);
  margin-left: 4px;
  vertical-align: middle;
}

.ai-say-btn:hover {
  background: var(--hl);
}

/* Typing Indicator */
.ai-typing {
  display: inline-flex;
  gap: 4px;
  padding: 8px 12px;
  align-items: center;
}

.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mut);
  animation: typing-dot 1.2s infinite ease-in-out;
}

.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes typing-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Input Bar */
.ai-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border-top: 1px solid var(--line);
  flex: none;
}

.ai-chat-input {
  flex: 1;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}

.ai-chat-input:focus {
  border-color: var(--red);
  background: var(--bg);
}

.btn-ai-send {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: transform .15s, opacity .15s;
  flex: none;
}

.btn-ai-send:hover:not(:disabled) {
  transform: scale(1.08);
}

.btn-ai-send:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ---------- Phase 4: Printable Tianzige PDF & Anki Export 🖨️ ---------- */
.print-cbox {
  max-width: 820px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.print-cbox .chead {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  margin-bottom: 0;
}

.print-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  flex: none;
}

.print-opt-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--mut);
}

.print-select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12.5px;
  color: var(--ink);
}

.print-btns-group {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.print-hint-banner {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 16px;
  font-size: 12px;
  line-height: 1.4;
  border-bottom: 1px solid #fde68a;
  flex: none;
}

.print-sheet-preview-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #525659;
  display: flex;
  justify-content: center;
}

.print-sheet-paper {
  width: 100%;
  max-width: 760px;
  background: #fff;
  color: #111827;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  padding: 30px 24px;
  box-sizing: border-box;
  border-radius: 4px;
}

/* Worksheet Content Layout */
.ps-header {
  border-bottom: 2px solid #dc2626;
  padding-bottom: 12px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.ps-title {
  font-size: 19px;
  font-weight: 800;
  color: #991b1b;
  margin: 0 0 4px;
}

.ps-sub {
  font-size: 13px;
  color: #4b5563;
  margin: 0;
}

.ps-meta {
  font-size: 12px;
  color: #6b7280;
  text-align: right;
  line-height: 1.4;
}

.ps-row {
  display: flex;
  align-items: center;
  border-bottom: 1px dashed #e5e7eb;
  padding: 8px 0;
  gap: 12px;
}

.ps-char-info {
  width: 130px;
  flex: none;
  border-right: 1.5px solid #fecaca;
  padding-right: 10px;
}

.ps-ci-han {
  font: 700 28px "STKaiti", "KaiTi", "SimSun", var(--han);
  color: #111827;
  line-height: 1;
}

.ps-ci-py {
  font-size: 13px;
  font-weight: 600;
  color: #dc2626;
  margin-top: 2px;
}

.ps-ci-vi {
  font-size: 11.5px;
  color: #4b5563;
  line-height: 1.25;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ps-grid-cells {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  align-items: center;
}

/* Tianzige Cell (Ô Chữ Điền) */
.tz-cell {
  width: 40px;
  height: 40px;
  border: 1px solid #f87171;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 28px "STKaiti", "KaiTi", "SimSun", serif;
  box-sizing: border-box;
  background: #fff;
  user-select: none;
}

/* Đường chữ thập đứt nét */
.tz-cell::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(239, 68, 68, 0.4);
}

.tz-cell::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(239, 68, 68, 0.4);
}

/* Mizige (Ô Mễ Tự) */
.tz-cell.mizige .tz-diag-1 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to top right, transparent calc(50% - 0.5px), rgba(239, 68, 68, 0.25) calc(50% - 0.5px), rgba(239, 68, 68, 0.25) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}

.tz-cell.mizige .tz-diag-2 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom right, transparent calc(50% - 0.5px), rgba(239, 68, 68, 0.25) calc(50% - 0.5px), rgba(239, 68, 68, 0.25) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}

.tz-char {
  position: relative;
  z-index: 2;
}

.tz-sample .tz-char {
  color: #111827;
  font-weight: 700;
}

.tz-trace .tz-char {
  color: rgba(17, 24, 39, 0.22);
}

.tz-blank .tz-char {
  display: none;
}

/* @media print Stylesheet */
@media screen {
  .print-only {
    display: none !important;
  }
}

@media print {
  body * {
    visibility: hidden !important;
  }
  #print_container, #print_container * {
    visibility: visible !important;
  }
  #print_container {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 10mm 12mm !important;
    background: #fff !important;
    color: #000 !important;
  }
  .print-sheet-paper {
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }
}

/* ---------- Progressive Book Unlock & Graduation Exam Styles ---------- */
.canvas-fireworks {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
}

/* Modal Quyển bị khóa */
.vol-locked-cbox {
  max-width: 440px;
  text-align: center;
}
.locked-body {
  padding: 16px 10px 8px;
}
.locked-icon-anim {
  font-size: 56px;
  margin-bottom: 12px;
  display: inline-block;
  animation: lock-wobble 2s infinite ease-in-out;
}
@keyframes lock-wobble {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-8deg) scale(1.05); }
  75% { transform: rotate(8deg) scale(1.05); }
}
.locked-actions {
  margin-top: 20px;
}

/* Banner Thử thách Vượt Quyển trong Quiz */
.grad-banner-card {
  background: linear-gradient(135deg, rgba(255, 179, 0, 0.14), rgba(230, 0, 38, 0.08));
  border: 1.5px solid rgba(255, 179, 0, 0.5);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(255, 179, 0, 0.12);
  transition: all .2s;
}
.grad-banner-card.passed {
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.12), rgba(0, 176, 255, 0.08));
  border-color: rgba(0, 230, 118, 0.45);
  box-shadow: 0 4px 16px rgba(0, 230, 118, 0.1);
}
.grad-banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}
.grad-icon {
  font-size: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.grad-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
}
.grad-desc {
  font-size: 12.5px;
  color: var(--sub);
  line-height: 1.4;
}
.btn-grad-start {
  flex-shrink: 0;
  background: linear-gradient(135deg, #ffb300, #ff8f00);
  color: #000;
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(255, 179, 0, 0.35);
  white-space: nowrap;
  transition: transform .15s, box-shadow .15s;
}
.btn-grad-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 16px rgba(255, 179, 0, 0.5);
}
.btn-grad-start.retry {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

/* Modal Thử thách Vượt Quyển */
.grad-cbox {
  max-width: 580px;
}
.grad-content {
  padding: 16px 8px 10px;
}
.grad-header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--sub);
}
.grad-prog-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  margin-bottom: 16px;
  overflow: hidden;
}
.grad-prog-bar {
  height: 100%;
  background: linear-gradient(90deg, #ffb300, #ff3d00);
  transition: width .2s;
}
.grad-question-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}
.grad-q-prompt {
  font-size: 13px;
  color: var(--sub);
  margin-bottom: 8px;
}
.grad-q-target {
  font-size: 38px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--font-han, serif);
  margin: 6px 0;
}
.grad-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-grad-opt {
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.btn-grad-opt:hover {
  border-color: var(--red);
  background: var(--soft);
}
.btn-grad-opt.correct {
  background: rgba(0, 230, 118, 0.15) !important;
  border-color: #00e676 !important;
  color: #00c853 !important;
  font-weight: 700;
}
.btn-grad-opt.wrong {
  background: rgba(230, 0, 38, 0.15) !important;
  border-color: var(--red) !important;
  color: var(--red) !important;
}

/* Bằng Chứng Nhận Tốt Nghiệp Vượt Quyển */
.grad-cert-card {
  background: linear-gradient(135deg, rgba(255, 179, 0, 0.08), rgba(255, 235, 59, 0.04));
  border: 2px dashed rgba(255, 179, 0, 0.6);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.cert-seal {
  font-size: 64px;
  margin-bottom: 10px;
  display: inline-block;
  animation: pop-in .4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.cert-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffb300;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.cert-subtitle {
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 12px;
}
.cert-score-badge {
  display: inline-block;
  background: #ffb300;
  color: #000;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
}
.cert-desc {
  font-size: 13.5px;
  color: var(--sub);
  line-height: 1.5;
  margin-bottom: 18px;
}
@keyframes pop-in {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 600px) {
  .grad-banner-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .grad-banner-left {
    flex-direction: column;
    text-align: center;
  }
  .grad-options-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- AI Voice Call Mode (Đàm thoại 2 chiều với AI 📞) ---------- */
.btn-call-float {
  position: fixed;
  bottom: 84px;
  right: 24px;
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #00c853, #009624);
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 200, 83, 0.45);
  transition: all .25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-call-float:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 10px 26px rgba(0, 200, 83, 0.6);
}

.call-pulse {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 28px;
  border: 2px solid #00e676;
  animation: call-pulse-ring 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
  pointer-events: none;
}

@keyframes call-pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 0; }
  100% { transform: scale(1.2); opacity: 0; }
}

.call-icon {
  font-size: 18px;
  animation: ring-wobble 2.5s infinite ease-in-out;
}

@keyframes ring-wobble {
  0%, 100% { transform: rotate(0deg); }
  10%, 30% { transform: rotate(-15deg); }
  20%, 40% { transform: rotate(15deg); }
  50% { transform: rotate(0deg); }
}

.ai-call-pill-btn {
  background: rgba(0, 200, 83, 0.15);
  color: #00c853;
  border: 1px solid rgba(0, 200, 83, 0.4);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .2s;
}

.ai-call-pill-btn:hover {
  background: #00c853;
  color: #fff;
}

/* Call Modal Screen */
.call-cbox {
  max-width: 480px;
  height: 90vh;
  max-height: 680px;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--p);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 1.5px solid var(--line);
}

.call-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}

.call-partner-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.call-live-dot {
  color: #00e676;
  font-size: 18px;
  line-height: 1;
  animation: live-blink 1.5s infinite;
}

@keyframes live-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}

.call-timer-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--mut);
  background: var(--card);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.call-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-tool-btn {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.call-tool-btn:hover {
  background: var(--hl);
}

.call-tool-btn.on {
  background: var(--soft);
  border-color: var(--red);
  color: var(--red);
}

/* Call Visualizer Center */
.call-visual-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 20px 10px;
  position: relative;
}

.call-scenario-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--sub);
  cursor: pointer;
  margin-bottom: 20px;
  transition: all .15s;
}

.call-scenario-tag:hover {
  border-color: var(--red);
  color: var(--ink);
  background: var(--soft);
}

/* Glowing Orb & Acoustic Ripple Waves */
.call-orb-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.call-orb {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 35px rgba(0, 230, 118, 0.45);
  position: relative;
  z-index: 2;
  overflow: hidden;
  border: 3px solid #00e676;
  transition: all .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.call-orb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s, filter .3s;
}

.call-orb-icon {
  font-size: 42px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  transition: transform .2s;
}

.call-wave-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(0, 230, 118, 0.4);
  pointer-events: none;
  opacity: 0;
}

/* State: AI Speaking */
.call-orb-wrap.speaking .call-orb {
  border-color: #00e676;
  box-shadow: 0 0 55px rgba(0, 230, 118, 0.8);
  transform: scale(1.08);
}
.call-orb-wrap.speaking .call-orb-img {
  transform: scale(1.1);
}

.call-orb-wrap.speaking .wave-1 {
  animation: orb-wave 2s infinite ease-out;
}
.call-orb-wrap.speaking .wave-2 {
  animation: orb-wave 2s infinite 0.6s ease-out;
}
.call-orb-wrap.speaking .wave-3 {
  animation: orb-wave 2s infinite 1.2s ease-out;
}

/* State: User Speaking (Listening) */
.call-orb-wrap.listening .call-orb {
  border-color: #2979ff;
  box-shadow: 0 0 50px rgba(41, 121, 255, 0.8);
  transform: scale(1.04);
}
.call-orb-wrap.listening .call-orb-img {
  filter: brightness(1.1);
}

.call-orb-wrap.listening .wave-1 {
  border-color: rgba(41, 121, 255, 0.5);
  animation: orb-wave 1.5s infinite ease-out;
}
.call-orb-wrap.listening .wave-2 {
  border-color: rgba(41, 121, 255, 0.3);
  animation: orb-wave 1.5s infinite 0.5s ease-out;
}

/* State: AI Thinking */
.call-orb-wrap.thinking .call-orb {
  border-color: #ffb300;
  box-shadow: 0 0 50px rgba(255, 179, 0, 0.8);
  animation: orb-pulse 1.2s infinite ease-in-out;
}
.call-orb-wrap.thinking .call-orb-img {
  filter: brightness(1.05);
}

@keyframes orb-wave {
  0% { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes orb-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.call-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}

.call-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00e676;
}

/* Subtitles / Transcript Area */
.call-transcript-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.call-bubble {
  border-radius: 16px;
  padding: 12px 16px;
  position: relative;
  animation: fade-slide-up .25s ease-out;
}

@keyframes fade-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-bubble {
  background: var(--soft);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  align-self: flex-start;
  max-width: 95%;
}

.user-bubble {
  background: rgba(0, 200, 83, 0.12);
  border: 1px solid rgba(0, 200, 83, 0.3);
  border-top-right-radius: 4px;
  align-self: flex-end;
  max-width: 90%;
  text-align: right;
}

.call-zh {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--font-han, serif);
  line-height: 1.4;
  margin-bottom: 4px;
}

.call-py {
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 4px;
}

.call-vi {
  font-size: 12.5px;
  color: var(--sub);
  line-height: 1.35;
}

.call-user-label {
  font-size: 11px;
  font-weight: 600;
  color: #00c853;
  margin-bottom: 2px;
}

.call-user-zh {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-han, serif);
}

.call-coach-tip {
  background: rgba(255, 179, 0, 0.12);
  border: 1px dashed rgba(255, 179, 0, 0.5);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.4;
}

/* Hidden subtitles mode */
.call-transcript-wrap.hide-sub .call-zh,
.call-transcript-wrap.hide-sub .call-py,
.call-transcript-wrap.hide-sub .call-vi,
.call-transcript-wrap.hide-sub .call-user-zh {
  filter: blur(5px);
  user-select: none;
  transition: filter .2s;
}
.call-transcript-wrap.hide-sub .call-bubble:hover .call-zh,
.call-transcript-wrap.hide-sub .call-bubble:hover .call-py,
.call-transcript-wrap.hide-sub .call-bubble:hover .call-vi,
.call-transcript-wrap.hide-sub .call-bubble:hover .call-user-zh {
  filter: none;
}

/* Call Bottom Controls */
.call-bottom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px 20px 10px;
  background: var(--soft);
  border-top: 1px solid var(--line);
}

.call-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 14px;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  transition: all .2s;
}

.call-ctrl-btn small {
  font-size: 11px;
  font-weight: 600;
}

.call-ctrl-btn:hover {
  background: var(--hl);
  transform: translateY(-2px);
}

.call-ctrl-btn.end-btn:hover {
  background: rgba(230, 0, 38, 0.15);
  border-color: var(--red);
  color: var(--red);
}

.call-mic-main {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00c853, #009624);
  color: #fff;
  border: none;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 200, 83, 0.5);
  position: relative;
  transition: all .2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.call-mic-main:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 28px rgba(0, 200, 83, 0.65);
}

.call-mic-main.recording {
  background: linear-gradient(135deg, #e03c31, #b91c1c);
  box-shadow: 0 6px 24px rgba(224, 60, 49, 0.6);
  animation: mic-pulse 1s infinite alternate;
}

@keyframes mic-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.call-text-fallback {
  display: flex;
  gap: 8px;
  padding: 8px 16px 12px;
  background: var(--soft);
}

.call-text-fallback input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
}

.call-text-fallback button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

/* Modal Kịch bản Vai trò */
.scenario-cbox {
  max-width: 480px;
}

.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  max-height: 400px;
  overflow-y: auto;
}

.scenario-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--soft);
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: all .2s;
}

.scenario-item:hover {
  border-color: #00c853;
  background: rgba(0, 200, 83, 0.08);
}

.scenario-item.active {
  border-color: #00c853;
  background: rgba(0, 200, 83, 0.12);
}

.scenario-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.scenario-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}

.scenario-desc {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.35;
}




