@import url('https://fonts.googleapis.com/css2?family=Yomogi&family=Klee+One:wght@400;600&family=Noto+Sans+JP:wght@300;400;500&display=swap');

:root {
  --bg: #f4f6fb;
  --surface: #fff;
  --text: #1a2233;
  --muted: #6f7d95;
  --line: #e5e9f2;
  --primary: #4f6ef7;
  --primary-soft: #eef2ff;
  --accent-soft: #f6f8ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  touch-action: manipulation;
}

/* 2026-04-21: lang=my — add Noto Sans Myanmar fallback + line-height rộng hơn
   (Myanmar có dấu trên-dưới cao hơn Latin ~30%). */
html[lang="my"] body {
  font-family: "Noto Sans Myanmar", "Nunito", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.35;
}
/* Group rows cho MY: text wrap 2 dòng OK, count nhỏ xuống tí */
html[lang="my"] .group-row .group-main h3 {
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
}
html[lang="my"] .group-row .group-main p {
  font-size: 12.5px;
  line-height: 1.35;
  word-break: break-word;
}

.page {
  max-width: 460px;
  margin: 0 auto;
  padding: 12px;
}

.head {
  margin-bottom: 12px;
}

.back {
  display: inline-block;
  text-decoration: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
}

.head h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
}

.head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.head p:empty {
  display: none;
}

.content {
  display: grid;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(21, 31, 56, 0.08);
}

.card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.kanji-intro-card h3 {
  font-size: 16px;
}

.kanji-group-card {
  cursor: pointer;
}

.kanji-group-card:focus-visible,
.kanji-group-card:active {
  outline: none;
  border-color: #cfd9ff;
  background: #f8faff;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tag {
  font-size: 11px;
  color: #4f5d7f;
  background: #edf2ff;
  border: 1px solid #dbe6ff;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}

.jp {
  font-size: 18px;
  color: #131b2f;
  line-height: 1.35;
  margin-top: 8px;
}

.kana {
  margin-top: 4px;
  color: #60708f;
  font-size: 12px;
}

.mean {
  margin-top: 4px;
  color: #5f6d86;
  font-size: 12px;
}

.list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #4f5f7c;
  font-size: 13px;
}

.empty {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 12px;
  border-radius: 10px;
  font-size: 13px;
}

/* Listening detail */
.intro-card {
  background: var(--accent-soft);
  border-color: #dce6ff;
}

.intro-card h3 {
  color: #20316a;
}

.listening-card {
  display: grid;
  gap: 10px;
}

.mode-block {
  background: #f8f9fd;
  border: 1px solid #e8ecf8;
  border-radius: 12px;
  padding: 9px;
}

.mode-title {
  margin: 0 0 8px;
  font-size: 12px;
  color: #4f5f7c;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dialog-line {
  border: 1px solid #e3e8f5;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
}

.dialog-line + .dialog-line {
  margin-top: 7px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.speaker {
  font-size: 11px;
  font-weight: 800;
  color: #47516d;
  letter-spacing: 0.3px;
}

.speak-btn {
  border: 1px solid #ced8f8;
  background: #eef3ff;
  color: #3554d9;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
}

.dialog-ja {
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.35;
}

.dialog-vi {
  margin-top: 3px;
  font-size: 12px;
  color: #61708f;
}

.speaking-note {
  margin: 0 0 7px;
  color: #556482;
  font-size: 12px;
  font-weight: 700;
}

.hint {
  margin-top: 7px;
  border-top: 1px dashed #d9e2f8;
  padding-top: 7px;
}

.hint > summary {
  cursor: pointer;
  font-size: 12px;
  color: #4560cb;
  font-weight: 700;
}

/* Pre-paint class để tránh chớp trắng trước khi JS init xong */
html.pre-listening body {
  background: #6f79f6;
}

html.pre-listening .head {
  margin: 0;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
  background: #6f79f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
}

html.pre-listening .back {
  margin: 0;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  font-weight: 400;
  position: absolute;
  left: 14px;
  top: calc(10px + env(safe-area-inset-top, 0px));
}

html.pre-listening .page {
  max-width: 100%;
  padding: 0;
  margin: 0;
  min-height: 100vh;
  background: #efefef;
}

html.pre-listening.pre-listening-group .page {
  background: #ffffff;
}

/* Listening + Kanji + Grammar list screen style (theo ảnh tham chiếu) */
.module-listening,
.module-kanji,
.module-grammar,
.module-vocabulary {
  background: #6f79f6;
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.module-listening .page,
.module-kanji .page,
.module-grammar .page,
.module-vocabulary .page {
  max-width: 100%;
  padding: 0;
  margin: 0;
  min-height: 100vh;
  background: #efefef;
}

.module-listening.listening-group-mode .page,
.module-kanji.kanji-group-mode .page,
.module-grammar.grammar-group-mode .page,
.module-vocabulary.vocabulary-group-mode .page {
  background: #ffffff;
}

.module-listening .head,
.module-kanji .head,
.module-grammar .head,
.module-vocabulary .head,
.module-practice .head,
.module-mixed .head {
  margin: 0;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
  background: #6f79f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
}

.module-listening .back,
.module-kanji .back,
.module-grammar .back,
.module-vocabulary .back,
.module-practice .back,
.module-mixed .back {
  margin: 0;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  font-weight: 400;
  position: absolute;
  left: 14px;
  top: calc(10px + env(safe-area-inset-top, 0px));
}

.module-listening .head h1,
.module-kanji .head h1,
.module-grammar .head h1,
.module-vocabulary .head h1,
.module-practice .head h1,
.module-mixed .head h1 {
  font-size: 20px;
  line-height: 1.15;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.1px;
  text-align: center;
}

.module-listening .head p,
.module-kanji .head p,
.module-grammar .head p,
.module-vocabulary .head p,
.module-practice .head p,
.module-mixed .head p {
  display: none;
}

.module-listening .content,
.module-kanji .content,
.module-grammar .content,
.module-vocabulary .content,
.module-practice .content,
.module-mixed .content {
  gap: 0;
}

.module-practice .content {
  padding: 12px;
  gap: 12px;
  display: flex;
  flex-direction: column;
}

.module-listening .content.list-mode,
.module-kanji .content.list-mode,
.module-grammar .content.list-mode,
.module-vocabulary .content.list-mode {
  display: block;
}

.module-kanji .content:not(.list-mode),
.module-grammar .content:not(.list-mode),
.module-vocabulary .content:not(.list-mode) {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.module-kanji.kanji-group-mode .content:not(.list-mode),
.module-grammar.grammar-group-mode .content:not(.list-mode),
.module-vocabulary.vocabulary-group-mode .content:not(.list-mode) {
  padding: 0;
  display: block;
  background: #ffffff;
}

.list-intro {
  margin: 8px 14px 10px;
  padding: 11px 12px;
  background: var(--accent-soft);
  color: #111111;
  border: 1px solid #dce6ff;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.42;
  font-weight: 400;
}

.module-listening .list-intro.list-intro-image,
.module-grammar .list-intro.list-intro-image,
.module-vocabulary .list-intro.list-intro-image {
  padding: 0;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1280 / 280;
  min-height: 72px;
  background: transparent;
}

.list-intro-cover-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.module-kanji .list-intro {
  padding: 8px 14px 12px;
  aspect-ratio: 1024 / 224;
  min-height: 72px;
  display: flex;
  align-items: flex-start;
  background-image: url("./assets/kanji-list-intro-bg.webp");
  background-size: cover;
  background-position: center;
  color: #0f1a31;
  font-weight: 500;
}

/* P1 detail: chỉ giữ hàng 10 chữ + khung 1 chữ */
.kanji-strip-wrap {
  padding: 0 10px;
  border-bottom: none;
  background: linear-gradient(180deg, #9ee2fc 0%, #c4edfb 100%);
}

.module-kanji.kanji-group-mode .kanji-strip-wrap,
.module-vocabulary.vocabulary-group-mode .kanji-strip-wrap {
  padding: 0;
  margin: 0;
}

.kanji-strip {
  display: flex;
  gap: 0;
  width: 100%;
  height: 42px;
  overflow: hidden;
  background: linear-gradient(180deg, #9ee2fc 0%, #c4edfb 100%);
}

/* Saved review mode: 20 chữ hiển thị cùng lúc, chia 2 hàng × 10 chữ.
   Mỗi hàng thấp hơn (32px) để tổng 2 hàng ≈ 64px, không phá design tổng. */
body.saved-review-mode .kanji-strip {
  height: auto;
  min-height: unset;
  flex-wrap: wrap;
  align-content: stretch;
  overflow: visible;
}

body.saved-review-mode .kanji-tab {
  flex: 0 0 10%;
  min-width: 0;
  height: 32px;
  font-size: 13px;
  padding: 0;
  line-height: 32px;
}

body.saved-review-mode .kanji-tab.active::after {
  bottom: 0;
  height: 2px;
}

/* Saved review mode: tab strip 2 hàng chiếm thêm chỗ → content dài hơn
   → chừa đáy đủ để footer fixed không che phần cuối card. */
body.saved-review-mode .kanji-canvas,
body.saved-review-mode .content:not(.list-mode) {
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

.kanji-tab {
  position: relative;
  flex: 1 1 10%;
  min-width: 0;
  height: 42px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #2f3f5a;
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
}

.kanji-tab.active {
  color: #df4747;
}

.module-kanji.kanji-group-mode .kanji-tab,
.module-vocabulary.vocabulary-group-mode .kanji-tab {
  font-size: 15px;
}

.kanji-tab.active::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 0;
  height: 2px;
  border-radius: 999px;
  background: #df4747;
}

.kanji-canvas {
  background: #ffffff;
  padding: 12px 14px 28px;
  min-height: calc(100vh - 190px);
}

/* Grammar page: nới khoảng cách giữa các block */
body.module-grammar .kanji-canvas > * + * {
  margin-top: 16px;
}

/* Chừa đáy đủ lớn để block mở rộng không bị footer fixed che */
body.module-grammar .kanji-canvas {
  padding-bottom: calc(136px + env(safe-area-inset-bottom, 0px));
}

.kanji-n5p1-canvas {
  background: #efefef;
  padding: 12px 12px 26px;
  display: grid;
  gap: 12px;
}

.kanji-flip-card {
  margin: 0 auto;
  width: min(336px, 100%);
  aspect-ratio: 1 / 1;
  perspective: 1600px;
  -webkit-perspective: 1600px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.kanji-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.72s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}

.kanji-flip-card.is-flipped .kanji-flip-inner {
  transform: rotateY(180deg);
}

.kanji-flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #dddddd;
  box-shadow: 0 2px 8px rgba(30, 30, 30, 0.08);
  transition: opacity 0.2s linear;
}

.kanji-flip-face.is-front {
  transform: rotateY(0deg) translateZ(0.1px);
  opacity: 1;
}

.kanji-flip-face.is-back {
  transform: rotateY(180deg) translateZ(0.1px);
  display: grid;
  place-items: center;
  background: #ffffff;
  opacity: 0;
}

.kanji-flip-card.is-flipped .kanji-flip-face.is-front {
  opacity: 0;
}

.kanji-flip-card.is-flipped .kanji-flip-face.is-back {
  opacity: 1;
}

.kanji-flip-face.is-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kanji-image-empty {
  padding: 18px;
  text-align: center;
  color: #1f3558;
  font-size: 15px;
}

.kanji-writing-board {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: #ffffff;
  overflow: hidden;
}

.kanji-guide {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  opacity: 0.42;
}

.kanji-guide-horizontal {
  left: 14px;
  right: 14px;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(
    to right,
    rgba(143, 154, 168, 0.75) 0 8px,
    rgba(143, 154, 168, 0) 8px 14px
  );
}

.kanji-guide-vertical {
  top: 14px;
  bottom: 14px;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    rgba(143, 154, 168, 0.75) 0 8px,
    rgba(143, 154, 168, 0) 8px 14px
  );
}

/* Fallback chữ nền (chỉ dùng khi writer chưa sẵn sàng/lỗi) */
.kanji-handwriting-char {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "Klee One", "Yomogi", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: clamp(223px, 50.4vw, 283px);
  line-height: 1;
  color: #1f3558;
  font-weight: 400;
  user-select: none;
}

.kanji-writer-host {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.kanji-writing-board.has-writer .kanji-handwriting-char {
  display: none;
}

.kanji-tool-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.module-kanji.kanji-group-mode .practice-divider {
  height: 1px;
  width: calc(100% - 72px);
  background: rgba(49, 63, 88, 0.16);
  margin: 14px auto 10px;
}

.module-kanji.kanji-group-mode .reflex-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 12px 14px 6px;
  min-height: 86px;
  border: 1px solid #dce2ec;
  border-radius: 12px;
  background-color: #fff;
  background-image: url("./assets/reflex-bg.webp?v=20260412-1326");
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
  cursor: pointer;
}

.module-kanji.kanji-group-mode .reflex-card h3 {
  margin: 0;
  padding-right: 48px;
  font-size: 16px;
  font-weight: 600;
  color: #1f3558;
  line-height: 1.32;
}

.module-kanji.kanji-group-mode .reflex-card .side-icon-btn {
  position: absolute;
  right: 1px;
  bottom: -1px;
  margin: 0;
  width: 42px;
  height: 42px;
  color: #ffffff;
}

.module-kanji.kanji-group-mode .reflex-card .icon-talk-people {
  width: 34px;
  height: 34px;
}

.kanji-tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #d8dce6;
  background: #ffffff;
  color: #2f3f5a;
  font-size: 22px;
  display: grid;
  place-items: center;
}

.kanji-tool-btn.is-active {
  border-color: #d8dce6;
  background: #ffffff;
}

.kanji-tool-btn[data-kanji-action="favorite"] {
  color: #2f3f5a;
}

.kanji-tool-btn[data-kanji-action="favorite"].is-active {
  color: #e0ab00;
  border-color: #d8dce6;
  background: #ffffff;
}

.kanji-hint-card p {
  margin: 0;
  font-size: 15px;
  color: #1f3558;
  line-height: 1.45;
}

.kanji-meta-card {
  border-radius: 12px;
  background: #f3f7ff;
  border-color: #d9e4f7;
}

.kanji-desc-lines {
  border: 1px solid #d3e1f8;
  border-radius: 10px;
  background: #eaf2ff;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.kanji-desc-lines p {
  margin: 0;
  color: #1f3558;
  font-size: 17px;
  line-height: 1.45;
  text-align: center;
}

.kanji-desc-lines p + p {
  margin-top: 4px;
}

.kanji-meta-grid {
  display: grid;
  gap: 8px;
}

.kanji-meta-row {
  display: grid;
  grid-template-columns: 95px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.kanji-meta-row .label {
  background: #f4f5f8;
  border: 1px solid #eceef4;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 15px;
  color: #1f3558;
  font-weight: 600;
  text-align: center;
}

.kanji-meta-row .value {
  color: #1d2940;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 600;
}

.vocab-kanji-meta-hero {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

.vocab-kanji-char-box {
  position: relative;
  border: 1px solid #d8e2f8;
  border-radius: 10px;
  background: #f8fbff;
  min-height: 154px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.vocab-kanji-char-guide {
  position: absolute;
  background: rgba(85, 111, 170, 0.18);
}

.vocab-kanji-char-guide-h {
  left: 10px;
  right: 10px;
  top: 50%;
  height: 1px;
  transform: translateY(-0.5px);
}

.vocab-kanji-char-guide-v {
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 1px;
  transform: translateX(-0.5px);
}

.vocab-kanji-writing-board {
  width: 100%;
  height: 100%;
  background: transparent;
}

.vocab-kanji-writing-board .kanji-guide-horizontal {
  left: 10px;
  right: 10px;
}

.vocab-kanji-writing-board .kanji-guide-vertical {
  top: 10px;
  bottom: 10px;
}

.vocab-kanji-handwriting-char {
  font-family: "Klee One", "Yomogi", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 113px;
  font-weight: 400;
}

.vocab-kanji-meta-lines {
  display: grid;
  gap: 6px;
}

.vocab-kanji-meta-row {
  display: block;
}

.vocab-kanji-meta-row .value {
  display: block;
  background: #f4f5f8;
  border: 1px solid #eceef4;
  border-radius: 7px;
  padding: 8px 10px;
  color: #1d2940;
  font-size: 15px;
  line-height: 1.36;
  font-weight: 600;
}

.kanji-vocab-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
  color: #1f3558;
}

.kanji-vocab-list {
  display: grid;
}

.kanji-vocab-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(49, 63, 88, 0.14);
}

.kanji-vocab-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.kanji-vocab-main {
  display: grid;
  gap: 4px;
}

.kanji-vocab-furi {
  margin: 0;
  font-size: 10px !important;
  line-height: 1;
  color: #233a63;
  font-weight: 500;
  text-align: left;
}

.kanji-vocab-inline {
  /* Cố định cột từ JP để cột nghĩa VI luôn thẳng hàng (2 chữ hay 3 chữ đều đều nhau) */
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: baseline;
  column-gap: 12px;
}

.kanji-vocab-ja {
  margin: 0;
  font-size: 18px;
  line-height: 1.28;
  color: #1b2340;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  font-weight: 500;
  text-align: left;
}

.kanji-vocab-ja.is-speaking {
  color: #2f58db;
  background: rgba(79, 110, 247, 0.08);
  border-radius: 6px;
  padding: 1px 3px;
}

.kanji-vocab-vi {
  margin: 0;
  font-size: 15px !important;
  line-height: 1.45;
  color: #233a63 !important;
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 400;
  text-align: left;
  flex: 1 1 auto;
}

.kanji-vocab-inline .kanji-vocab-ja {
  font-size: 20px;
  color: #233a63;
  min-width: 0;
}

.kanji-vocab-inline .kanji-vocab-vi {
  font-size: 15px !important;
}

@media (max-width: 420px) {
  .vocab-kanji-meta-hero {
    grid-template-columns: 106px minmax(0, 1fr);
    gap: 8px;
  }

  .vocab-kanji-char-box {
    min-height: 142px;
  }

  .vocab-kanji-handwriting-char {
    font-size: 100px;
  }

  .vocab-kanji-meta-row .value {
    font-size: 14px;
    padding: 7px 8px;
  }

  .kanji-vocab-inline {
    grid-template-columns: 132px minmax(0, 1fr);
    column-gap: 10px;
  }
}

.kanji-vocab-speak {
  width: 40px;
  height: 40px;
  justify-self: end;
}

.kanji-grammar-deep-card h3 {
  margin: 0 0 8px;
  color: #1f3558;
}

.kanji-grammar-source {
  margin: 0;
  font-size: 18px;
}

.kanji-grammar-source-vi {
  margin: 6px 0 10px;
  color: #233a63;
}

.kanji-grammar-block {
  border: 1px solid #e3e9f5;
  background: #f8fbff;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.kanji-grammar-block p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: #1f3558;
}

.kanji-grammar-block p + p {
  margin-top: 4px;
}

.kanji-grammar-examples-title {
  margin: 4px 0 8px;
  font-weight: 700;
  color: #1f3558;
}

.kanji-grammar-example-row {
  display: block;
  padding: 8px 0;
  border-bottom: 1px dashed #dbe4f2;
}

.grammar-example-interactive-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: start;
  gap: 6px;
}

.grammar-example-interactive-row .card-side-actions {
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  padding-top: 2px;
}

.grammar-example-interactive-row .side-icon-btn {
  width: 31px;
  height: 31px;
}

.grammar-example-interactive-row .side-icon-btn .icon-speaker,
.grammar-example-interactive-row .side-icon-btn .icon-mic {
  width: 18px;
  height: 18px;
}

.kanji-grammar-example-row:last-child {
  border-bottom: none;
}

.kanji-grammar-tag {
  height: 22px;
  border-radius: 999px;
  background: #e7eefc;
  color: #355a97;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.kanji-grammar-tag-inline {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: #243a63;
  white-space: nowrap;
}

.kanji-grammar-example-main .ja-ruby {
  margin: 0;
}

.grammar-example-ja-ruby {
  ruby-position: over;
  ruby-align: center;
  white-space: normal;
  line-height: 1.75;
}

.grammar-example-ja-ruby ruby {
  ruby-align: center;
}

.grammar-example-ja-ruby ruby rt {
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0;
}

.kanji-grammar-example-main .vi-line {
  margin: 4px 0 0;
}

.listening-deferred-blocks.is-hidden {
  display: none;
}

.listening-deferred-blocks.is-visible {
  animation: deferredBlocksReveal 0.28s ease-out;
}

.kanji-card {
  background: #ffffff;
  border: 1px solid #e7ebf5;
  border-radius: 12px;
  padding: 8px 12px 8px;
  margin-top: 8px;
}

.kanji-card.marked {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  column-gap: 6px;
  align-items: stretch;
}

.card-main {
  min-width: 0;
}

.kanji-card.soft {
  background: #f7f9ff;
}

.kanji-canvas .kanji-card:first-child {
  margin-top: 0;
}

.kanji-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #37486d;
}

.line-mark {
  background: transparent;
  color: #394b73;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.line-mark-hidden {
  visibility: hidden;
}

.card-side-actions {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 2px 0;
}

.card-main[data-card-speak] {
  cursor: pointer;
}

.side-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #566585;
  font-size: 17px;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
  --icon-shift-y: 0px;
  transform: translateY(var(--icon-shift-y));
}

.side-icon-btn[data-speak],
.side-icon-btn[data-mic] {
  color: #1f57be;
  font-size: 0;
}

.side-icon-btn .icon-speaker,
.side-icon-btn .icon-mic,
.side-icon-btn .icon-talk-people {
  width: 21px;
  height: 21px;
  display: block;
}

.side-icon-btn .icon-speaker path:first-child,
.side-icon-btn .icon-mic path:first-child,
.side-icon-btn .icon-talk-people circle {
  fill: currentColor;
}

.side-icon-btn.is-speaking {
  color: #2f58db;
  animation: iconSpeakPulse 0.9s ease-in-out infinite;
}

.side-icon-btn.is-recording {
  color: #1f57be;
  animation: micRecordPulse 0.75s ease-in-out infinite;
}

.side-icon-btn[data-mic] {
  --icon-shift-y: 3px;
}

.side-icon-btn:active {
  transform: translateY(var(--icon-shift-y)) scale(0.95);
}

/* N5 P1: tăng khoảng cách + vùng bấm cho icon loa/mic */
body.n5-p1-touch-friendly .card-side-actions {
  gap: 13px;
  justify-content: flex-end;
  align-items: flex-end;
  padding-bottom: 4px;
}

body.n5-p1-touch-friendly .side-icon-btn {
  width: 37px;
  height: 37px;
  touch-action: manipulation;
}

body.n5-p1-touch-friendly .side-icon-btn .icon-speaker,
body.n5-p1-touch-friendly .side-icon-btn .icon-mic,
body.n5-p1-touch-friendly .side-icon-btn .icon-talk-people {
  width: 26px;
  height: 26px;
}

body.n5-p1-touch-friendly .side-icon-btn .icon-talk-people circle {
  fill: currentColor;
}

/* Grammar examples: trả về cỡ icon theo mức trước đó */
body.n5-p1-touch-friendly .grammar-example-interactive-row .card-side-actions {
  gap: 7px;
  padding-top: 2px;
}

body.n5-p1-touch-friendly .grammar-example-interactive-row .side-icon-btn {
  width: 37px;
  height: 37px;
  color: #1f57be;
}

body.n5-p1-touch-friendly .grammar-example-interactive-row .side-icon-btn .icon-speaker,
body.n5-p1-touch-friendly .grammar-example-interactive-row .side-icon-btn .icon-mic {
  width: 22px;
  height: 22px;
}

body.n5-p1-touch-friendly .side-icon-btn[data-speak],
body.n5-p1-touch-friendly .side-icon-btn[data-mic] {
  color: #667387;
}

/* Grammar: icon A/B nhỏ hơn 10% và giữ xanh như ban đầu */
body.module-grammar.n5-p1-touch-friendly .kanji-card .side-icon-btn,
body.module-grammar.n5-p1-touch-friendly .grammar-example-interactive-row .side-icon-btn {
  width: 33px;
  height: 33px;
}

body.module-grammar.n5-p1-touch-friendly .kanji-card .side-icon-btn .icon-speaker,
body.module-grammar.n5-p1-touch-friendly .kanji-card .side-icon-btn .icon-mic {
  width: 23px;
  height: 23px;
}

body.module-grammar.n5-p1-touch-friendly .grammar-example-interactive-row .side-icon-btn .icon-speaker,
body.module-grammar.n5-p1-touch-friendly .grammar-example-interactive-row .side-icon-btn .icon-mic {
  width: 20px;
  height: 20px;
}

body.module-grammar.n5-p1-touch-friendly .side-icon-btn[data-speak],
body.module-grammar.n5-p1-touch-friendly .side-icon-btn[data-mic] {
  color: #1f57be !important;
}

/* Listening N5 P1: thu nhỏ icon loa/mic ~10% và đổi về xanh như phần ngữ pháp */
body.module-listening.n5-p1-touch-friendly .kanji-card .side-icon-btn {
  width: 33px;
  height: 33px;
}

body.module-listening.n5-p1-touch-friendly .kanji-card .side-icon-btn .icon-speaker,
body.module-listening.n5-p1-touch-friendly .kanji-card .side-icon-btn .icon-mic {
  width: 23px;
  height: 23px;
}

body.module-listening.n5-p1-touch-friendly .side-icon-btn[data-speak],
body.module-listening.n5-p1-touch-friendly .side-icon-btn[data-mic] {
  color: #1f57be !important;
}

body.n5-p1-touch-friendly .practice-divider {
  height: 1px;
  width: calc(100% - 72px);
  background: rgba(49, 63, 88, 0.16);
  margin: 18px auto;
}

body.n5-p1-touch-friendly .reflex-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 12px 14px 6px;
  min-height: 86px;
  border: 1px solid #dce2ec;
  border-radius: 12px;
  background-color: #fff;
  background-image: url("./assets/reflex-bg.webp?v=20260412-1326");
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
  cursor: pointer;
}

body.n5-p1-touch-friendly .reflex-card h3 {
  margin: 0;
  padding-right: 48px;
  font-size: 16px;
  font-weight: 600;
  color: #2d3a53;
  line-height: 1.32;
}

body.n5-p1-touch-friendly .reflex-card .side-icon-btn {
  position: absolute;
  right: 1px;
  bottom: -1px;
  margin: 0;
  width: 42px;
  height: 42px;
  color: #ffffff;
}

body.n5-p1-touch-friendly .reflex-card .icon-talk-people {
  width: 34px;
  height: 34px;
}

body.n5-p1-touch-friendly .grammar-card {
  margin-top: 12px;
  border: 1px solid #dce2ec;
  border-radius: 12px;
  background-color: #fff;
  overflow: hidden;
}

/* Listening N5 P1: khoảng cách reflex -> grammar bằng khoảng cách divider -> reflex */
body.module-listening.n5-p1-touch-friendly .grammar-card {
  margin-top: 18px;
}

body.n5-p1-touch-friendly .grammar-card-toggle {
  width: 100%;
  min-height: 86px;
  border: none;
  background-color: #fff;
  background-image: url("./assets/grammar-bg.webp?v=20260414-2328");
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px 6px;
  cursor: pointer;
}

body.n5-p1-touch-friendly .grammar-card-toggle.grammar-example-toggle {
  align-items: flex-start;
  padding-top: 8px;
}

body.n5-p1-touch-friendly .grammar-card-toggle.grammar-example-toggle {
  background-image: url("./assets/grammar-example-bg.webp?v=20260414-2356");
  background-position: center;
}

body.n5-p1-touch-friendly .grammar-title-list p {
  margin: 0;
  line-height: 1.32;
  color: #2d3a53;
  text-align: left;
}

body.n5-p1-touch-friendly .grammar-title-list .title {
  font-size: 15px;
  font-weight: 600;
}

body.n5-p1-touch-friendly .grammar-title-list .structure {
  margin-top: 3px;
  font-size: 15px;
  font-weight: 500;
  color: #2c3a56;
}

body.n5-p1-touch-friendly .grammar-title-list .summary {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #233a63;
}

body.n5-p1-touch-friendly .grammar-chevron {
  font-size: 36px;
  line-height: 1;
  color: #ffffff;
  align-self: flex-end;
  transform: translateY(2px);
  transition: transform 0.2s ease;
}

body.n5-p1-touch-friendly .grammar-card.is-open .grammar-chevron {
  transform: translateY(2px) rotate(180deg);
}

body.n5-p1-touch-friendly .grammar-details {
  border-top: 1px solid #eef2f7;
  background: #fff;
  padding: 10px 14px 12px;
  display: grid;
  gap: 13px;
}

body.n5-p1-touch-friendly .grammar-details[hidden] {
  display: none !important;
}

body.n5-p1-touch-friendly .grammar-detail-row .label {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #233a63;
}

body.n5-p1-touch-friendly .grammar-detail-row:last-child .label {
  font-weight: 600;
}

body.n5-p1-touch-friendly .grammar-detail-row .value {
  margin: 3px 0 0;
  font-size: 15px;
  color: #233a63;
  line-height: 1.45;
}

body.n5-p1-touch-friendly .grammar-usage-core {
  margin-bottom: 2px;
}

body.n5-p1-touch-friendly .grammar-usage-structure {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #1f3558;
  line-height: 1.35;
}

body.n5-p1-touch-friendly .grammar-usage-meaning {
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 400;
  color: #1f3558;
  line-height: 1.45;
}

body.n5-p1-touch-friendly .grammar-example-list {
  margin: 8px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

body.n5-p1-touch-friendly .grammar-example-list li {
  color: #24324c;
}

/* Áp dụng chung cho tất cả block "Ngữ pháp sử dụng" (Listening/Kanji/Grammar) */
.grammar-card .grammar-details .list,
.grammar-card .grammar-details .list li {
  font-size: 15px !important;
  line-height: 1.45;
}

body.n5-p1-touch-friendly .grammar-example-list .example-label {
  margin: 0;
  font-size: 15px;
  color: #233a63;
  font-weight: 600;
}

body.n5-p1-touch-friendly .grammar-example-list .example-ja {
  margin: 2px 0 0;
  font-size: 16px;
  color: #1f2c46;
  font-weight: 600;
}

body.n5-p1-touch-friendly .grammar-example-list .example-ja ruby rt {
  font-size: 10px;
  color: #6477a5;
  font-weight: 500;
}

body.n5-p1-touch-friendly .grammar-example-list .example-vi {
  margin: 1px 0 0;
  font-size: 15px;
  color: #233a63;
}

/* Grammar page: đồng bộ màu chữ đen-xanh + cỡ chữ chuẩn 15px */
.module-grammar .grammar-title-list .title,
.module-grammar .grammar-title-list .structure,
.module-grammar .grammar-title-list .summary,
.module-grammar .grammar-detail-row .label,
.module-grammar .grammar-detail-row .value,
.module-grammar .grammar-details .list li,
.module-grammar .grammar-details .grammar-example-list li {
  color: #1f3558 !important;
}

.module-grammar .grammar-title-list .title,
.module-grammar .grammar-title-list .structure,
.module-grammar .grammar-title-list .summary,
.module-grammar .grammar-detail-row .label,
.module-grammar .grammar-detail-row .value,
.module-grammar .grammar-details .list li,
.module-grammar .grammar-details .grammar-example-list li {
  font-size: 15px !important;
  line-height: 1.45;
}

.module-grammar .grammar-details .grammar-usage-head,
.grammar-card .grammar-details .grammar-usage-head {
  font-weight: 600;
}

body.n5-p1-touch-friendly .kanji-related-card {
  margin-top: 12px;
  border: 1px solid #dce2ec;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

body.n5-p1-touch-friendly .kanji-related-toggle {
  width: 100%;
  min-height: 86px;
  border: none;
  background-color: #f7f9ff;
  background-image: url("./assets/kanji-related-bg.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 6px;
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  cursor: pointer;
}

body.n5-p1-touch-friendly .kanji-related-title-list p {
  margin: 0;
  text-align: left;
  color: #2d3a53;
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body.n5-p1-touch-friendly .kanji-related-title-list .title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.32;
}

body.n5-p1-touch-friendly .reflex-card h3,
body.n5-p1-touch-friendly .grammar-title-list .title,
body.n5-p1-touch-friendly .kanji-related-title-list .title {
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: 0;
}

body.n5-p1-touch-friendly .kanji-related-title-list .summary-line {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 400;
  color: #233a63;
}

body.n5-p1-touch-friendly .kanji-related-chevron {
  font-size: 30px;
  line-height: 1;
  color: #6b7892;
  align-self: flex-end;
  transform: translateY(2px);
  transition: transform 0.2s ease;
}

body.n5-p1-touch-friendly .kanji-related-card.is-open .kanji-related-chevron {
  transform: translateY(2px) rotate(180deg);
}

body.n5-p1-touch-friendly .kanji-related-details {
  border-top: 1px solid #eef2f7;
  background: #fff;
  padding: 10px 14px 12px;
}

body.n5-p1-touch-friendly .kanji-related-details[hidden] {
  display: none !important;
}

body.n5-p1-touch-friendly .kanji-related-layout {
  display: grid;
  grid-template-columns: 35% 65%;
  gap: 10px;
  align-items: start;
}

body.n5-p1-touch-friendly .kanji-related-left {
  display: grid;
  gap: 7px;
  align-content: start;
}

body.n5-p1-touch-friendly .kanji-glyph-box {
  width: 55%;
  min-width: 92px;
  aspect-ratio: 1 / 1;
  justify-self: start;
  border: 1px solid #d5dfef;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background-color: #f7f9ff;
  background-image:
    linear-gradient(transparent calc(50% - 0.6px), rgba(180, 195, 220, 0.32) calc(50% - 0.6px), rgba(180, 195, 220, 0.32) calc(50% + 0.6px), transparent calc(50% + 0.6px)),
    linear-gradient(90deg, transparent calc(50% - 0.6px), rgba(180, 195, 220, 0.32) calc(50% - 0.6px), rgba(180, 195, 220, 0.32) calc(50% + 0.6px), transparent calc(50% + 0.6px));
}

body.n5-p1-touch-friendly .kanji-glyph {
  font-size: 60px;
  font-weight: 500;
  line-height: 1;
  font-family: "Yomogi", "Klee One", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  color: #1d2d4d;
  text-shadow: 0 0 0.45px #1d2d4d;
}

body.n5-p1-touch-friendly .kanji-meta-hanviet {
  margin: 0;
  width: 55%;
  min-width: 92px;
  justify-self: start;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: #1f3154;
}

body.n5-p1-touch-friendly .kanji-meta-meaning {
  display: grid;
  gap: 2px;
}

body.n5-p1-touch-friendly .kanji-meta-line,
body.n5-p1-touch-friendly .kanji-meta-label,
body.n5-p1-touch-friendly .kanji-meta-value,
body.n5-p1-touch-friendly .kanji-meta-value-inline {
  margin: 0;
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body.n5-p1-touch-friendly .kanji-meta-label {
  font-size: 14px;
  font-weight: 600;
  color: #20365d;
}

body.n5-p1-touch-friendly .kanji-meta-value,
body.n5-p1-touch-friendly .kanji-meta-value-inline,
body.n5-p1-touch-friendly .kanji-meta-line {
  font-size: 13px;
  font-weight: 400;
  color: #233a63;
  word-break: normal;
}

body.n5-p1-touch-friendly .kanji-meta-meaning .kanji-meta-line {
  white-space: nowrap;
}

body.n5-p1-touch-friendly .kanji-meta-value-second {
  white-space: nowrap;
}

body.n5-p1-touch-friendly .kanji-related-right {
  min-width: 0;
  display: flex;
  align-items: flex-start;
}

body.n5-p1-touch-friendly .kanji-related-image,
body.n5-p1-touch-friendly .kanji-related-image-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid #d5dfef;
  border-radius: 10px;
  background: #f7f9ff;
}

body.n5-p1-touch-friendly .kanji-related-image {
  object-fit: cover;
  display: block;
}

body.n5-p1-touch-friendly .kanji-related-image-placeholder {
  display: grid;
  place-items: center;
  color: #6f7f9f;
  font-size: 14px;
  font-weight: 600;
}

@keyframes deferredBlocksReveal {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes iconSpeakPulse {
  0% { opacity: 1; }
  50% { opacity: 0.55; }
  100% { opacity: 1; }
}

@keyframes micRecordPulse {
  0% { opacity: 1; }
  50% { opacity: 0.35; }
  100% { opacity: 1; }
}

.ja-ruby {
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
  color: #1b2340;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.ja-ruby.is-speaking {
  color: #2f58db;
  background: rgba(79, 110, 247, 0.08);
  border-radius: 6px;
  padding: 1px 3px;
}

.ja-ruby.is-recording {
  color: #1f57be;
}

.ja-ruby ruby rt {
  font-size: 10px;
  color: #6477a5;
  font-weight: 500;
}

.kana-line,
.vi-line {
  margin: 8px 0 0;
  font-size: 15px;
  color: #233a63;
  line-height: 1.45;
  font-family: "Nunito", "SF Pro Text", "Avenir Next", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 400;
}

body.practice-modal-open {
  overflow: hidden;
}

body.kanji-guide-open {
  overflow: hidden;
}

body.profile-open {
  overflow: hidden;
}

.head {
  position: relative;
}

.head-actions {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  gap: 8px;
}

.head-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid #d7deeb;
  background: #ffffff;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.profile-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(16, 22, 37, 0.52);
  z-index: 1400;
  padding: 16px;
}

.profile-modal.is-visible {
  display: flex;
}

.profile-dialog {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #d9e4f6;
  overflow: hidden;
}

.profile-cover {
  height: 92px;
  background: linear-gradient(135deg, #4f78d6, #6aa9ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.profile-main,
.profile-settings {
  padding: 12px 14px;
}

.profile-settings {
  display: grid;
  gap: 10px;
  border-top: 1px solid #edf1f7;
}

.profile-close {
  position: absolute;
  margin: 8px;
  right: 18px;
  top: 18px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #d7deeb;
  background: #f4f7fd;
}

.kanji-guide-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(16, 22, 37, 0.52);
  z-index: 1300;
  padding: 16px;
}

.kanji-guide-modal.is-visible {
  display: flex;
}

.kanji-guide-dialog {
  width: min(680px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid #d9e4f6;
  border-radius: 14px;
  padding: 16px 16px 20px;
  position: relative;
  color: #1f3558;
}

.kanji-guide-close {
  position: sticky;
  top: 0;
  float: right;
  border: 1px solid #d7deeb;
  background: #f4f7fd;
  border-radius: 8px;
  width: 30px;
  height: 30px;
}

.kanji-guide-dialog h2,
.kanji-guide-dialog h3 {
  margin: 8px 0;
}

.kanji-guide-dialog p,
.kanji-guide-dialog li {
  font-size: 15px;
  line-height: 1.5;
}

.kanji-guide-code {
  background: #f3f7ff;
  border: 1px solid #dce5f8;
  border-radius: 10px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}

.practice-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(16, 22, 37, 0.44);
  z-index: 1200;
  padding: 18px;
}

.practice-modal.is-open {
  display: flex;
}

.practice-dialog {
  position: relative;
  width: min(92vw, 360px);
  background: #fff;
  border-radius: 18px;
  padding: 16px 16px 14px;
  box-shadow: 0 20px 45px rgba(18, 36, 83, 0.24);
  overflow: hidden;
}

.practice-fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.practice-firework-particle {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 6px;
  height: 12px;
  border-radius: 999px;
  background: hsl(var(--hue) 92% 58%);
  opacity: 0;
}

.practice-fireworks.is-burst .practice-firework-particle {
  animation: fireworkBurst 900ms ease-out forwards;
  animation-delay: var(--delay, 0s);
}

.practice-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #3d4b6b;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.practice-close.is-disabled {
  opacity: 0.35;
}

.practice-icon-wrap {
  width: 74px;
  height: 74px;
  margin: 2px auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #2f58db;
}

.practice-icon-wrap.is-recording {
  color: #d11f2f;
  background: transparent;
  animation: micRecordPulseModal 0.8s ease-in-out infinite;
}

.practice-icon-wrap.is-processing {
  color: #2f58db;
  background: transparent;
  animation: iconSpeakPulse 0.9s ease-in-out infinite;
}

.practice-icon .icon-mic {
  width: 40px;
  height: 40px;
  display: block;
}

.practice-icon .icon-mic path:first-child {
  fill: currentColor;
}

.practice-timer {
  width: 66.6667%;
  height: 5px;
  border-radius: 999px;
  background: #ebeff8;
  overflow: hidden;
  margin: 2px auto 10px;
}

.practice-timer-bar {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b 0%, #d11f2f 100%);
  transform: scaleX(0);
  transform-origin: left center;
}

.practice-timer.is-active .practice-timer-bar {
  will-change: transform;
}

.practice-status-text {
  display: none !important;
}

.practice-status-text.is-hidden {
  display: none !important;
}

.practice-transcript-box {
  margin-top: 10px;
  border: 1px solid #e3e8f7;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fafcff;
}

.practice-transcript-label {
  margin: 0;
  font-size: 11px;
  color: #6a7ba4;
}

.practice-transcript-text {
  margin: 4px 0 0;
  font-size: 14px;
  color: #1d2a46;
  min-height: 20px;
  white-space: pre-line;
}

.practice-result-badge {
  margin: 10px 0 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.practice-result-badge.is-info {
  color: #365cae;
}

.practice-result-badge.is-good {
  color: #0f7c3a;
}

.practice-result-badge.is-perfect {
  color: #a149ff;
}

.practice-result-badge.is-bad {
  color: #c53030;
}

.practice-hint-text {
  margin: 6px 0 0;
  text-align: center;
  font-size: 12px;
  color: #5d6a86;
  min-height: 16px;
}

.practice-retry-btn {
  display: none;
  margin: 10px 0 0 auto;
  border: none;
  background: transparent;
  color: #2f58db;
  font-size: 14px;
  font-weight: 600;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 4px 8px;
}

.practice-retry-btn.is-visible {
  display: flex;
}

.practice-retry-btn .icon-retry {
  width: 16px;
  height: 16px;
  display: block;
  animation: retrySpin 1.2s linear infinite;
}

.practice-replay-btn {
  display: none;
  margin: 8px 0 0 auto;
  border: none;
  background: transparent;
  color: #2f58db;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 8px;
}

.practice-replay-btn.is-visible {
  display: block;
}

.practice-next-btn {
  display: none;
  margin: 10px 0 0 auto;
  border: none;
  background: transparent;
  color: #2f58db;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 8px;
}

.practice-next-btn.is-visible {
  display: block;
}

body.completion-modal-open {
  overflow: hidden;
}

.completion-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13, 22, 44, 0.5);
  z-index: 1250;
  padding: 18px;
}

.completion-modal.is-open {
  display: flex;
}

.completion-dialog {
  position: relative;
  width: min(92vw, 370px);
  background: #fff;
  border-radius: 20px;
  padding: 18px 16px 14px;
  box-shadow: 0 18px 46px rgba(22, 41, 92, 0.28);
  overflow: hidden;
  text-align: center;
}

.completion-fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.completion-firework-particle {
  position: absolute;
  left: 50%;
  top: 62%;
  width: 6px;
  height: 12px;
  border-radius: 999px;
  background: hsl(var(--hue) 90% 58%);
  opacity: 0;
}

.completion-fireworks.is-burst .completion-firework-particle {
  animation: completionFireworkBurst 1.05s ease-out forwards;
  animation-delay: var(--delay, 0s);
}

.completion-title {
  margin: 8px 0 4px;
  font-size: 22px;
  color: #1e3160;
}

.completion-message {
  margin: 8px 0 12px;
  color: #30446f;
  font-size: 15px;
  line-height: 1.45;
}

.completion-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.completion-btn {
  height: 40px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  text-align: center;
}

.completion-btn .completion-label {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  line-height: 1.1;
}

.completion-btn .completion-arrow {
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.completion-btn.is-next {
  order: 2;
  background: linear-gradient(90deg, #4f7dff 0%, #5f65ff 100%);
  color: #fff;
}

.completion-btn.is-home {
  order: 1;
  background: #eef1f7;
  color: #2f3e63;
}

@keyframes completionFireworkBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.35);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-30% + var(--y))) scale(0.95);
  }
}

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

@keyframes fireworkBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.3);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-40% + var(--y))) scale(0.95);
  }
}

@keyframes micRecordPulseModal {
  0% { opacity: 1; }
  50% { opacity: 0.35; }
  100% { opacity: 1; }
}

.module-listening .content:not(.list-mode) {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.module-listening.listening-group-mode .content:not(.list-mode) {
  padding: 0 0 calc(112px + env(safe-area-inset-bottom, 0px));
  display: block;
  background: #ffffff;
}

.module-kanji.kanji-group-mode .content:not(.list-mode),
.module-vocabulary.vocabulary-group-mode .content:not(.list-mode) {
  padding: 0 0 calc(112px + env(safe-area-inset-bottom, 0px));
  display: block;
  background: #efefef;
}

.module-kanji.kanji-quiz-mode .content.kanji-quiz-single-mode:not(.list-mode),
.module-grammar.grammar-quiz-mode .content.kanji-quiz-single-mode:not(.list-mode),
.module-vocabulary.vocabulary-quiz-mode .content.kanji-quiz-single-mode:not(.list-mode),
.module-mixed.mixed-quiz-mode .content.kanji-quiz-single-mode:not(.list-mode) {
  min-height: calc(100vh - 150px);
  display: flex;
  align-items: flex-end;
  padding: 8px 0 calc(4px + env(safe-area-inset-bottom, 0px));
  background: #efefef;
}

.kanji-quiz-wrap {
  width: 100%;
  padding: 8px 6px 0;
  display: grid;
  gap: 10px;
}

.kanji-quiz-head h2 {
  margin: 0 0 6px;
  font-size: 18px;
  color: #1f3558;
}

.kanji-quiz-single {
  width: min(86vw, 688px);
  max-width: none;
  min-height: 0;
  margin: 0 auto;
  padding-top: 18px;
  padding-bottom: 18px;
  transform-origin: center;
}

.kanji-quiz-single.is-enter {
  animation: quizPageEnter 0.24s ease-out;
}

.kanji-quiz-single.is-leave {
  animation: quizPageLeave 0.2s ease-in forwards;
}

@keyframes quizPageEnter {
  from { opacity: 0; transform: rotateY(-7deg) translateY(8px); }
  to { opacity: 1; transform: rotateY(0) translateY(0); }
}

@keyframes quizPageLeave {
  from { opacity: 1; transform: rotateY(0) translateY(0); }
  to { opacity: 0; transform: rotateY(8deg) translateY(-6px); }
}

.kanji-quiz-meta-row {
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kanji-quiz-progress {
  margin: 0;
  font-size: 13px;
  color: #50648a;
  font-weight: 700;
}

.kanji-quiz-timer {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef3ff;
  color: #28447d;
  font-size: 13px;
  font-weight: 700;
}

.kanji-quiz-timer strong.is-low,
.kanji-quiz-timer .is-low {
  color: #bf2f2f;
}

.kanji-quiz-single h3 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.4;
}

.vocab-quiz-prompt-rich {
  display: grid;
  gap: 8px;
}

.vocab-quiz-prompt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  width: 100%;
}

.vocab-quiz-prompt-word {
  flex: 1 1 auto;
  font-size: 25px;
  line-height: 1;
  color: #1f3558;
}

.vocab-quiz-prompt-audio {
  width: 36px;
  height: 36px;
  margin-left: auto;
}

.kanji-quiz-options {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  width: min(100%, 520px);
}

.kanji-quiz-option-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #d7e2f6;
  border-radius: 10px;
  background: #f8fbff;
  color: #1f3558;
  font-size: 15px;
  font-weight: 600;
}

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

.kanji-quiz-footer {
  position: sticky;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kanji-quiz-result h3 {
  margin: 0 0 8px;
}

.kanji-quiz-timeout-note {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff6ea;
  border: 1px solid #ffd8a3;
  color: #8a4e00;
  font-size: 13px;
}

.kanji-quiz-detail {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

/* ===== Shared quiz result redesign (grammar, kanji, vocabulary, listening) ===== */
.quiz-result-card {
  padding: 20px 18px 18px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(23, 42, 78, 0.05);
}

.quiz-result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef1f6;
}

.quiz-result-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #5b6b85;
  letter-spacing: 0.2px;
}

.quiz-result-score {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.quiz-result-score-main {
  font-size: 22px;
  font-weight: 700;
  color: #1d2a44;
}

.quiz-result-score-percent {
  font-size: 14px;
  font-weight: 600;
  color: #6b7a92;
}

.quiz-result-card.is-good .quiz-result-score-main { color: #1f8a3a; }
.quiz-result-card.is-ok   .quiz-result-score-main { color: #b7791f; }
.quiz-result-card.is-low  .quiz-result-score-main { color: #b42326; }

.quiz-result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.quiz-result-item {
  margin: 0;
  padding: 12px 14px 12px 16px;
  border-radius: 12px;
  border-left: 3px solid #d7dde8;
  background: #f8fafc;
  display: grid;
  gap: 6px;
}

.quiz-result-item.is-correct {
  background: #f2faf3;
  border-left-color: #57b26e;
}

.quiz-result-item.is-wrong {
  background: #fdf5f5;
  border-left-color: #d9625f;
}

.quiz-result-question {
  margin: 0 0 2px;
  font-size: 14.5px;
  line-height: 1.45;
  color: #1d2a44;
  font-weight: 500;
}

.quiz-result-badge {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 6px;
  border-radius: 999px;
  background: #e6ebf3;
  color: #3d4d6b;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.is-correct .quiz-result-badge { background: #d9f0de; color: #1f6a33; }
.is-wrong   .quiz-result-badge { background: #f6dadb; color: #8f2b2c; }

.quiz-result-row {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #3d4d6b;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quiz-result-label {
  color: #6b7a92;
  font-weight: 500;
  white-space: nowrap;
}

.quiz-result-value {
  font-weight: 500;
  color: #1d2a44;
}

.quiz-result-value.is-answer { color: #1f6a33; }
.is-wrong .quiz-result-value.is-picked { color: #8f2b2c; }
.quiz-result-value.is-picked.is-skipped { color: #8a93a6; font-style: italic; font-weight: 400; }

.listening-footer.quiz-result-footer {
  display: flex;
  gap: 12px;
  align-items: stretch;
  grid-template-columns: none;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
}

.quiz-result-footer .footer-action-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 46px;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  padding: 0 14px;
  border-radius: 12px;
}

.quiz-result-footer .footer-action-btn.is-prev {
  background: #eef1f6;
  color: #3d4d6b;
  border: 1px solid #dce2ec;
}

.quiz-result-footer .footer-action-btn.is-next {
  background: #3a6ad1;
  color: #fff;
  border: 1px solid #2f58b5;
}

.quiz-result-footer .footer-action-btn.is-next:hover {
  background: #2f58b5;
}

/* Extra bottom padding so last items don't hide under fixed footer */
.quiz-result-wrap {
  padding-bottom: 96px;
}

/* Backward compat for old grammar-specific class names */
.grammar-quiz-result-wrap { padding-bottom: 96px; }

.grammar-quiz-back-btn {
  background: #eef1f6;
  color: #3d4d6b;
  border: 1px solid #dce2ec;
}

.grammar-quiz-restart-btn {
  background: #3a6ad1;
  color: #fff;
  border: 1px solid #2f58b5;
}

.grammar-quiz-restart-btn:hover {
  background: #2f58b5;
}

.kanji-quiz-result-prompt {
  display: inline-block;
  margin: 2px 0 4px;
  color: #2b426b;
}

.group-row {
  display: grid;
  grid-template-columns: 48px 1fr 54px;
  align-items: center;
  gap: 12px;
  /* 2026-04-21: icon cách lề trái xa hơn, progress % sát phải hơn */
  padding: 16px 6px 16px 20px;
  background: #fff;
  border-bottom: 1px solid #e7e7e7;
  cursor: pointer;
}

.group-left-icon {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  display: grid;
  place-items: center;
  font-size: 34px;
  line-height: 1;
}

/* 2026-04-21: grid child cần min-width: 0 để scroll container bên trong
   (kanji-mini-row overflow-x: auto) thực sự hoạt động — ngăn grid co giãn
   đẩy cả row tràn viewport trên điện thoại nhỏ. */
.group-main {
  min-width: 0;
}

.group-main h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.28;
  color: #151515;
  font-weight: 500;
}

.group-main p {
  margin: 8px 0 0;
  font-size: 15px;
  color: #2d79b7;
  font-style: italic;
  font-weight: 500;
}

.kanji-mini-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.kanji-mini-row::-webkit-scrollbar {
  display: none;
}

.kanji-inline-char {
  flex: 0 0 auto;
  color: #2d79b7;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.2px;
}

/* 2026-04-21: trên điện thoại nhỏ (≤ 390px), 10 chữ hán với gap 10 + font 15
   sẽ tràn ~360-370px. Giảm gap + font để fit 1 dòng không cần scroll.
   Nếu vẫn tràn → overflow-x: auto (cha) sẽ cho scroll ngang thay vì phá layout. */
@media (max-width: 390px) {
  .kanji-mini-row {
    gap: 6px;
  }
  .kanji-inline-char {
    font-size: 13.5px;
    letter-spacing: 0;
  }
}

@media (max-width: 340px) {
  .kanji-mini-row {
    gap: 4px;
  }
  .kanji-inline-char {
    font-size: 12.5px;
  }
}

.group-progress {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: conic-gradient(#4e79f8 calc(var(--p) * 1%), #e7ebf6 0);
  display: grid;
  place-items: center;
}

.group-progress span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  color: #4f607f;
}

.group-row:focus-visible,
.group-row:active {
  outline: none;
  background: #f8f9ff;
}

/* 2026-04-20: .is-locked giữ nguyên layout như row thường, chỉ progress circle đổi icon 🔒. */
.group-row.is-locked { cursor: pointer; }

.listening-footer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(460px, 100vw);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #ffffff;
  border: 1px solid #e2e8f4;
  border-bottom: none;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -8px 24px rgba(23, 38, 74, 0.12);
  z-index: 60;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 52px;
  gap: 8px;
}

.footer-action-btn {
  border: 1px solid #dfe5f0;
  border-radius: 12px;
  height: 40px;
  font-size: 15px;
  font-weight: 700;
  color: #435473;
  background: #eef2f8;
}

.footer-action-btn.is-prev,
.footer-action-btn.is-next {
  background: #edf1f7;
  color: #566682;
  border-color: #d4dcea;
  display: grid;
  place-items: center;
  padding: 0;
}

.footer-arrow-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.footer-action-btn.is-save {
  background: #efeaf7;
  color: #645282;
  border-color: #d8cceb;
}

.footer-action-btn.is-repeat {
  background: #f5eed1;
  color: #6d5e34;
  border-color: #e5d8a8;
}

.footer-action-btn.is-check {
  background: #f4e6e8;
  color: #7a4d54;
  border-color: #e6c8ce;
}

.footer-action-btn.is-active {
  border-color: #b7a4da;
  background: #e8def8;
}

.footer-action-btn:disabled {
  opacity: 0.45;
}

.module-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 248, 255, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1400;
  backdrop-filter: blur(2px);
  /* 2026-04-22: Hide/show instant, KHÔNG transition opacity
     → load xong là trang mới hiện luôn, không bị "mờ dần". */
}

.module-loading-overlay.is-visible {
  display: flex;
}

.module-loading-panel {
  width: min(82vw, 320px);
  padding: 16px 14px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #dbe5f8;
  box-shadow: 0 12px 30px rgba(33, 52, 91, 0.14);
}

.module-loading-text {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #375189;
  background: linear-gradient(90deg, #375189 15%, #7fa0df 45%, #375189 75%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: loadingSheen 1.2s linear infinite;
}

.module-loading-track {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: #e8eefb;
  overflow: hidden;
}

.module-loading-bar {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f7cff, #8fb0ff);
  animation: loadingBarMove 1.1s ease-in-out infinite;
}

/* Biến thể "determinate" — thanh tiến độ chạy theo % load thật,
   không còn hiệu ứng trượt qua lại. JS set inline style="width: NN%". */
.module-loading-bar--determinate {
  animation: none;
  transition: width 0.25s ease-out;
}

@keyframes loadingBarMove {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

@keyframes loadingSheen {
  0% { background-position: -140px 0; }
  100% { background-position: 220px 0; }
}

@media (max-width: 390px) {
  .head h1 {
    font-size: 23px;
  }

  .jp {
    font-size: 16px;
  }

  .dialog-ja {
    font-size: 14px;
  }

  .module-listening .head h1 {
    font-size: 18px;
    font-weight: 600;
  }

  .module-listening .back {
    font-size: 24px;
  }

  .group-main h3 {
    font-size: 16px;
    font-weight: 500;
  }

  .group-main p {
    font-size: 14px;
    font-weight: 500;
  }

  .group-left-icon {
    width: 34px;
    height: 34px;
    font-size: 30px;
  }

  .kanji-tab {
    height: 40px;
    font-size: 13px;
  }

  .kanji-focus {
    font-size: 48px;
  }

  .ja-ruby {
    font-size: 20px;
  }

  .kanji-card.marked {
    grid-template-columns: minmax(0, 1fr) 28px;
  }

  .side-icon-btn {
    width: 26px;
    height: 26px;
    font-size: 16px;
  }
}

@media (max-width: 390px) {
  .listening-footer {
    grid-template-columns: 46px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 46px;
    gap: 6px;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .footer-action-btn {
    font-size: 13px;
    height: 38px;
  }

  .footer-arrow-icon {
    width: 18px;
    height: 18px;
  }
}

/* Quick check page (Listening) */
.quick-check-wrap {
  display: grid;
  gap: 10px;
}

.quick-check-intro p {
  margin-top: 8px;
  line-height: 1.45;
}

.quick-check-overview {
  display: grid;
  gap: 6px;
}

.quick-check-overview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: #31405d;
}

.quick-check-overview-row strong {
  color: #1b2a4b;
  font-size: 16px;
}

.quick-check-last {
  margin-top: 4px;
  font-size: 13px;
  color: #5a6a88;
}

.quick-check-table-card {
  overflow: auto;
}

.quick-check-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.quick-check-table th,
.quick-check-table td {
  border-bottom: 1px solid #e7ecf7;
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

.quick-check-table td.dialogue {
  min-width: 220px;
}

.quick-check-table .line {
  margin: 0 0 5px;
  line-height: 1.35;
  color: #2a3a58;
}

.quick-check-table .line:last-child {
  margin-bottom: 0;
}

.quick-check-table .line strong {
  color: #1b2a4b;
}

.quick-check-table .line-user .value-user {
  color: #1f3f7a;
}

.quick-check-table thead th {
  font-size: 12px;
  color: #58698a;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.quick-check-row {
  cursor: pointer;
}

.quick-check-row:active {
  transform: scale(0.998);
}

.quick-check-table tbody tr[data-outcome="running"] {
  background: #f3f6ff;
}

.quick-check-table tbody tr[data-outcome="perfect"],
.quick-check-table tbody tr[data-outcome="correct"] {
  background: #f3fff7;
}

.quick-check-table tbody tr[data-outcome="wrong"] {
  background: #fff6f6;
}

.quick-check-table td.status,
.quick-check-table td.percent {
  white-space: nowrap;
}

.quick-check-table td.percent {
  font-weight: 700;
}

.quick-check-footer {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

@media (max-width: 390px) {
  .quick-check-footer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  }
}

/* ===== Practice Hub (Phương án B) ===== */
.practice-hub {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.practice-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
}

.practice-tab {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.practice-tab:hover {
  background: var(--accent-soft);
}

.practice-tab.is-active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.practice-tab-icon {
  font-size: 20px;
}

.practice-tab-label {
  font-size: 12px;
  line-height: 1.1;
}

.practice-form-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.practice-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.practice-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.practice-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.practice-pills-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.practice-pill {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 36px;
}

.practice-pills-grid .practice-pill {
  padding: 8px 0;
  text-align: center;
}

.practice-pill:hover {
  background: var(--accent-soft);
  border-color: var(--primary);
}

.practice-pill.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}

.practice-preview-card {
  background: var(--primary-soft);
  border: 1px solid #dbe3ff;
}

.practice-preview-label {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.practice-preview-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.practice-preview-text b {
  font-weight: 700;
  color: var(--primary);
}

.practice-cta {
  appearance: none;
  border: 0;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(79, 110, 247, 0.28);
  transition: transform 0.12s, box-shadow 0.15s;
}

.practice-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(79, 110, 247, 0.35);
}

.practice-cta:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.25);
}

/* ===== Saved Hub (tab Đã lưu) ===== */
.saved-filter-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saved-total {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.saved-total b {
  color: var(--primary);
  font-weight: 700;
}

.saved-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.saved-section-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.saved-section-icon {
  font-size: 18px;
}

.saved-section-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

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

.saved-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  transition: background 0.12s, border-color 0.12s;
}

.saved-item:hover {
  background: var(--accent-soft);
  border-color: var(--primary);
}

.saved-item-label {
  font-size: 22px;
  font-weight: 700;
  font-family: "Klee One", "Noto Sans JP", sans-serif;
}

.saved-item-sub {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-item-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 2px 8px;
}

.saved-empty-hint {
  margin: 0;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  background: var(--accent-soft);
  border-radius: 10px;
  font-style: italic;
}

/* ===== Saved Hub configurator (đồng bộ Quiz nhanh) ===== */
.practice-pill .practice-pill-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--muted);
  line-height: 18px;
  min-width: 22px;
  text-align: center;
  vertical-align: middle;
}

.practice-pill.is-active .practice-pill-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.practice-pill.is-disabled,
.practice-pill[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.practice-cta[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.practice-cta[disabled]:hover {
  transform: none;
}

/* Hint nhỏ trong label của field (vd "Số thẻ ôn lại (tối đa 20/lượt)") */
.practice-hint-inline {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
  letter-spacing: normal;
  text-transform: none;
}

/* ===== Saved Hub: 4 module pills full-width grid 2×2, tall ===== */
.practice-pills:has(> [data-saved-module]) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.practice-pills:has(> [data-saved-module]) .practice-pill {
  width: 100%;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 15px;
  padding: 8px 6px;
}
/* Saved module pill: tên ở dòng 1, badge số ở dòng 2 (căn giữa) */
.saved-module-pill .saved-module-name {
  font-weight: 500;
  line-height: 1.2;
}
.saved-module-pill.is-active .saved-module-name {
  font-weight: 500;
}
/* Số to bằng nút 10/20, không nền */
.saved-module-pill .practice-pill-count {
  margin-left: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  min-width: 0;
  border-radius: 0;
}
.saved-module-pill.is-active .practice-pill-count {
  background: transparent;
  color: #fff;
}

/* Saved Hub: 10/20 count pills full-width grid 2 cột */
.practice-pills:has(> [data-saved-count]) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.practice-pills:has(> [data-saved-count]) .practice-pill {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* Quiz/Mixed Hub: Nội dung pills 4 cột 1 hàng (grid full-width) */
.practice-pills:has(> [data-practice-module]) {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.practice-pills:has(> [data-practice-module]) .practice-pill {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  font-size: 13px;
}

/* Quiz/Mixed Hub: Thứ tự pills 3 cột 1 hàng */
.practice-pills:has(> [data-practice-order]) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.practice-pills:has(> [data-practice-order]) .practice-pill {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  font-size: 13px;
  white-space: nowrap;
}

/* Quiz/Mixed Hub: Cấp độ pills 5 cột 1 hàng (chia đều 2 lề) */
.practice-pills:has(> [data-practice-level]) {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.practice-pills:has(> [data-practice-level]) .practice-pill {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  font-size: 14px;
  white-space: nowrap;
}

/* ===== DAILY CHALLENGE (tab "Thử thách ngày") ===== */
.daily-header-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.daily-date {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin: 0;
}
.daily-streak-line {
  font-size: 15px;
  margin: 0;
  color: var(--text);
}
.daily-history-line {
  font-size: 13px;
  margin: 0;
  color: var(--muted);
}
.daily-kotowaza-card {
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border-left: 4px solid #f59e0b;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
}
.daily-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #92400e;
  margin: 0 0 4px 0;
}
.daily-kotowaza-ja {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: #111827;
  line-height: 1.4;
}
.daily-kotowaza-kana {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}
.daily-kotowaza-literal {
  font-size: 14px;
  color: #374151;
  margin: 6px 0 0 0;
  font-style: italic;
}
.daily-kotowaza-meaning {
  font-size: 15px;
  color: #111827;
  margin: 0;
  font-weight: 500;
}
.daily-kotowaza-vn {
  font-size: 13px;
  color: #065f46;
  margin: 6px 0 0 0;
  padding-top: 6px;
  border-top: 1px dashed rgba(0,0,0,0.1);
}
.daily-challenge-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.daily-challenge-desc {
  font-size: 14px;
  margin: 0;
  color: var(--text);
}
.daily-challenge-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  font-style: italic;
}

/* Mobile: kotowaza ja co nhỏ để không tràn */
@media (max-width: 480px) {
  .daily-kotowaza-ja { font-size: 19px; }
  .daily-kotowaza-card { padding: 14px; }
}

/* ===== Mixed Quiz (Tổng hợp) — origin tag + breakdown ===== */
.mixed-quiz-origin-tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mixed-quiz-origin-tag[data-origin="kanji"] {
  background: #e8f0ff;
  color: #4f6ef7;
}
.mixed-quiz-origin-tag[data-origin="vocab"] {
  background: #fff3e8;
  color: #d97706;
}
.mixed-quiz-origin-tag[data-origin="grammar"] {
  background: #e8fff0;
  color: #16a34a;
}

.mixed-quiz-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0 0;
  font-size: 14px;
  color: var(--text);
}
.mixed-quiz-breakdown p { margin: 0; }

/* Mixed quiz — listening origin tag (tím) */
.mixed-quiz-origin-tag[data-origin="listening"] {
  background: #f3e8ff;
  color: #7c3aed;
}

/* Mixed quiz meta row: origin+counter trái, audio play (nếu listening) phải */
.mixed-quiz-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}
.mixed-quiz-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

/* Mixed listening MCQ — icon loa SVG đồng kích thước với listening page (B câu) */
.mixed-listening-play-top {
  appearance: none;
  border: 0;
  background: transparent;
  color: #1f57be;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  box-shadow: none;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.mixed-listening-play-top .icon-speaker {
  width: 21px;
  height: 21px;
  display: block;
}
.mixed-listening-play-top .icon-speaker path:first-child {
  fill: currentColor;
}
.mixed-listening-play-top:hover { color: var(--primary-strong, var(--primary)); transform: scale(1.08); }
.mixed-listening-play-top:active { transform: scale(0.92); }

/* ===== Group locked progress (P4-P9 khi chưa có gói): chỉ đổi progress circle thành 🔒 ===== */
.group-progress.is-locked-progress {
  background: conic-gradient(#e5e7ef 0deg 360deg);
}
.group-progress.is-locked-progress span {
  color: #8892aa;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
}

/* ===== Redeem dialog (overlay modal cho nhóm khoá) ===== */
.redeem-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.redeem-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(4px);
}
.redeem-dialog-panel {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-height: 90vh;
  overflow-y: auto;
}
.redeem-dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #6b7280;
}
.redeem-dialog-close:hover { color: #111827; }
.redeem-dialog-title {
  margin: 0 0 8px;
  font-size: 18px;
  color: #111827;
}
.redeem-dialog-sub {
  margin: 0 0 14px;
  font-size: 14px;
  color: #374151;
}
.redeem-plans-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 10px;
  font-size: 13px;
}
.redeem-plan-item b { color: var(--primary); }
.redeem-auth-hint {
  margin: 10px 0;
  padding: 8px 10px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  font-size: 13px;
  color: #78350f;
  border-radius: 6px;
}
.redeem-auth-link {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 600;
}
.redeem-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.redeem-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.redeem-input {
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.15s;
}
.redeem-input:focus { border-color: var(--primary); }
.redeem-error {
  margin: 0;
  padding: 6px 10px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 6px;
  font-size: 13px;
}
/* 2026-04-21: inline success feedback (register + reset password) */
.redeem-success {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #ecfdf5;
  color: #065f46;
  border-left: 3px solid #10b981;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.redeem-forgot-row {
  margin: 10px 0 0;
  text-align: center;
}
.redeem-forgot-link {
  color: var(--primary, #4f6ef7);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.redeem-forgot-link:hover { text-decoration: underline; }

/* 2026-04-21: consent line dưới auth form (link Bảo mật/Điều khoản) */
.redeem-consent {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: #6b7280;
  text-align: center;
  line-height: 1.5;
}
.redeem-consent a {
  color: var(--primary, #4f6ef7);
  text-decoration: none;
  font-weight: 600;
}
.redeem-consent a:hover { text-decoration: underline; }
.redeem-submit {
  margin-top: 4px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.28);
}
.redeem-submit:hover { transform: translateY(-1px); }
.redeem-submit:active { transform: translateY(0); }

/* ===== Redeem dialog — Auth panel (step 1, copy style từ auth-modal cũ) ===== */
.redeem-google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.redeem-google-btn:hover { border-color: var(--primary); background: #f9fafb; }
.redeem-google-btn:disabled { opacity: 0.6; cursor: wait; }
.redeem-google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ea4335, #fbbc05, #34a853, #4285f4);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.redeem-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: #9ca3af;
  font-size: 12px;
}
.redeem-divider::before,
.redeem-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}
.redeem-email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.redeem-email-form input {
  padding: 11px 14px;
  font-size: 15px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s;
}
.redeem-email-form input:focus { border-color: var(--primary); }
.redeem-email-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
}
.redeem-email-actions button {
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 700;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.redeem-email-actions button:hover { border-color: var(--primary); }
.redeem-email-actions button.is-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.25);
}
.redeem-email-actions button.is-primary:hover { transform: translateY(-1px); }
.redeem-email-actions button:disabled { opacity: 0.6; cursor: wait; }

/* ===== Loading skeleton (2026-04-21) ===== */
/* Shimmer animation — gradient grey trượt qua placeholder */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #e5e7ef 0%,
    #f3f4f8 50%,
    #e5e7ef 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
  border-radius: 6px;
  color: transparent !important;
  user-select: none;
}

/* Tôn trọng prefers-reduced-motion (user tắt animation) */
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: #e5e7ef; }
}

/* Skeleton group row list — giữ layout same với group-row thật */
.skeleton-group-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.skeleton-group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-bottom: 1px solid #eef0f5;
}
.skeleton-group-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 12px;
}
.skeleton-group-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.skeleton-group-title {
  height: 16px; width: 60%;
}
.skeleton-group-sub {
  height: 12px; width: 80%;
}
.skeleton-group-progress {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
}

/* Skeleton intro cover (trên cùng module list) */
.skeleton-intro-cover {
  width: 100%;
  height: 110px;
  border-radius: 14px;
  margin-bottom: 14px;
}

/* ============================================================
   Language switcher (2026-04-22) — mounted by ui/lang-switcher.js
   CSS copy từ styles.css để module/profile tận dụng được chung.
   ============================================================ */
.lang-wrap { position: relative; }
.lang-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s, transform 0.15s;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.28); }
.lang-btn:active { transform: scale(0.96); }
.lang-btn .lang-flag { font-size: 16px; line-height: 1; }
.lang-btn .lang-code { font-size: 10px; }
.lang-btn .lang-caret { font-size: 9px; opacity: 0.7; }
.lang-btn[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: max-content;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(47,55,82,0.18);
  padding: 3px;
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.lang-menu[hidden] { display: none; }

.lang-option {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #2d3a5b;
  font-size: 13px;
  text-align: left;
  width: 100%;
  white-space: nowrap;
}
.lang-option:hover { background: #fef2ec; }
.lang-option.is-active { background: #ffe8da; color: #d95a2a; font-weight: 700; }
.lang-option-label { flex: 1; }

/* Slot chứa lang-switcher trong header module/profile.
   Header là position:relative → slot absolute góc phải, sát mép trên.
   Button: chữ + cờ trắng, KHÔNG nền, KHÔNG viền. */
.lang-switcher-slot {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  align-items: center;
}

/* Trong header module: bỏ nền + viền pill, chỉ giữ chữ trắng */
.head .lang-btn {
  background: transparent;
  padding: 2px 4px;
}
.head .lang-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}
