@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;
}

/* 2026-05-06: Module pages — html bg = màu header (#6f79f6) để bounce-scroll
   ở đầu page không lộ dải trắng. */
html {
  background: #6f79f6;
}

* {
  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;
  /* 2026-05-08: sticky để đồng bộ với .module-listening .head (line 362).
     Trước đây position:relative làm header scroll cùng content trên page
     listening. Specificity html.pre-listening (0,0,2,1) > .module-listening
     (0,0,2,0) nên rule này phải khớp. */
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
}

html.pre-listening .back {
  margin: 0;
  padding: 0 4px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  position: absolute;
  left: 14px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
  display: flex;
  align-items: center;
}

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,
.module-practice,
.module-mixed {
  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,
.module-practice .page,
.module-mixed .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;
  /* 2026-05-06: sticky → header luôn hiện ở đỉnh khi user scroll xuống.
     z-index cao để overlay content. Đồng bộ với html.pre-listening .head
     (FOUC-prevention rule, sticky từ 2026-05-08). */
  position: sticky;
  top: 0;
  z-index: 50;
  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;
  padding: 0 4px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  position: absolute;
  left: 14px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
  display: flex;
  align-items: center;
}

.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;
  text-transform: uppercase;
}

.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;
  /* 2026-05-06: hidden → cho phép horizontal scroll khi 10 tabs tràn (CJK glyph
     rộng hơn font-size em-square trên iPhone <= 430px). Hide scrollbar. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #9ee2fc 0%, #c4edfb 100%);
}

.kanji-strip::-webkit-scrollbar {
  display: none;
}

/* 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;
  /* 2026-05-06: flex-basis = 10% với 10 tabs → mỗi tab chiếm 10% width.
     flex-grow:0 + flex-shrink:0 để giữ kích thước cố định 10%, không bị
     content (kanji glyph rộng hơn font) ép tab to ra → đẩy tabs cuối tràn. */
  flex: 0 0 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;
  padding: 0;
  /* Đảm bảo kanji content không overflow tab box, ép wrap nếu cần */
  overflow: hidden;
  text-align: center;
}

.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;
}

.kanji-radical-chips {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.kanji-radical-chip {
  display: flex;
  width: 100%;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border: 1px solid #dfe5ff;
  border-radius: 8px;
  background: #f7f8ff;
  color: #4056c8;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.kanji-radical-chip:hover,
.kanji-radical-chip:focus-visible {
  border-color: #9faafa;
  background: #eef1ff;
  outline: none;
}

.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;
}

/* Locked: blocks vẫn hiện, mỗi block có overlay mờ riêng (theo viền block),
   không khoá cả section. Khi audio intro phát xong → bỏ is-locked,
   filter + overlay đều fade-out smooth qua transition. */
.listening-deferred-blocks > article {
  position: relative;
  transition: filter 0.25s ease-out;
}

.listening-deferred-blocks > article::after {
  content: "";
  position: absolute;
  inset: 0;
  /* 2026-04-26: overlay trắng mờ nhẹ thay vì đen — nhìn dịu mắt, không tối */
  background: rgba(255, 255, 255, 0.45);
  border-radius: inherit;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.listening-deferred-blocks.is-locked > article {
  pointer-events: none;
  user-select: none;
  /* 2026-04-26: giảm brightness/saturate ít hơn — tránh quá tối khi audio play */
  filter: brightness(0.95) saturate(0.9);
}

.listening-deferred-blocks.is-locked > article::after {
  opacity: 1;
}

.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;
  /* 2026-05-13 (revised): Override `body.n5-p1-touch-friendly .card-side-actions`
     (specificity 0,2,1, justify-content: flex-end) — căn loa GIỮA container.
     Container có 3 dòng (label "Ví dụ N" + ja-ruby + vi-line) → center =
     ngang ja-ruby. Trước đó dùng flex-start làm loa vượt quá lên trên label. */
  justify-content: center;
  align-items: flex-end;
}

/* Câu B (kanji-conversation-b-card) — loa căn giữa card thay vì đáy.
   Default rule `.card-side-actions` line 1367 đã có justify-content: center,
   nhưng `body.n5-p1-touch-friendly .card-side-actions` line 1435 override =
   flex-end làm loa rớt xuống ngang dòng vi-line. Tăng specificity riêng cho
   card B để loa ở giữa container = ngang ja-ruby (line-mark "B" + ja-ruby +
   vi-line ≈ 3 dòng, center = giữa). 2026-05-13 fix #2. */
body.n5-p1-touch-friendly .kanji-conversation-b-card .card-side-actions {
  justify-content: center;
  align-items: flex-end;
}

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;
}

/* 2026-04-26: Loading audio state — pulse icon + dots animation bên dưới
   Báo user "đang tải âm thanh" tránh tưởng app đứng hình. */
.practice-icon-wrap.is-loading-audio {
  position: relative;
  color: #2f58db;
  animation: iconSpeakPulse 0.9s ease-in-out infinite;
}
.practice-icon-wrap.is-loading-audio::after {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 8px;
  background-image: radial-gradient(circle, #2f58db 30%, transparent 32%),
                    radial-gradient(circle, #2f58db 30%, transparent 32%),
                    radial-gradient(circle, #2f58db 30%, transparent 32%);
  background-size: 8px 8px;
  background-repeat: no-repeat;
  background-position: 0 50%, 14px 50%, 28px 50%;
  animation: practiceLoadingDots 1.2s ease-in-out infinite;
}
@keyframes practiceLoadingDots {
  0%, 100% { opacity: 0.25; }
  33%      { opacity: 0.6; }
  66%      { opacity: 1; }
}

.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;
}

/* 2026-05-03: nút "Xong" — dừng record sớm trong practice modal grammar/listening.
   Pattern giống hoithoai stop button: full-width tím, nổi bật khi đang record. */
.practice-stop-btn {
  display: none;
  margin: 12px 0 4px;
  width: 100%;
  border: none;
  background: #6f79f6;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(111, 121, 246, 0.32);
  transition: background 0.15s, transform 0.1s;
}
.practice-stop-btn.is-visible { display: block; }
.practice-stop-btn:hover { background: #5a65e0; }
.practice-stop-btn:active { transform: scale(0.98); }

.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);
}

/* 2026-05-23: pháo hoa Mixed quiz result — fixed overlay full screen, reuse particle CSS. */
.mixed-result-fireworks {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.mixed-result-fireworks .completion-firework-particle {
  top: 50%;
}
.mixed-result-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);
  min-height: calc(100dvh - 150px); /* 2026-05-30: dvh động → hết kẽ hở khi ẩn/hiện thanh URL iOS */
  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 {
  /* 2026-05-23: weight 600 (giảm từ default 700) — anh feedback "nét đậm quá". */
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 600;
}

.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 {
  /* 2026-05-23: weight 600 → 500 (anh feedback option đậm quá ở Daily quiz). */
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #d7e2f6;
  border-radius: 10px;
  background: #f8fbff;
  color: #1f3558;
  font-size: 15px;
  font-weight: 500;
}

/* 2026-06-02: trạng thái đáp án hiện ngay sau khi chọn (quiz Kanji) */
.kanji-quiz-option-btn[disabled] { cursor: default; }
.kanji-quiz-option-btn.is-correct {
  border-color: #41a35a;
  background: #e7f6ec;
  color: #1f6a33;
  font-weight: 600;
}
.kanji-quiz-option-btn.is-wrong {
  border-color: #d4595b;
  background: #fdecec;
  color: #8f2b2c;
  font-weight: 600;
}
.kanji-quiz-explain {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f7fc;
  border: 1px solid #e0e7f3;
}
.kanji-quiz-verdict { font-size: 14px; font-weight: 700; }
.kanji-quiz-verdict.is-correct { color: #1f6a33; }
.kanji-quiz-verdict.is-wrong { color: #8f2b2c; }
.kanji-quiz-explain-head { margin: 6px 0 4px; }
.kanji-quiz-explain-kanji { font-size: 25px; line-height: 1; font-weight: 700; color: #1f3558; }
/* thuật ngữ giải thích cho Ngữ pháp (cấu trúc) / Từ vựng (từ) — vừa phải, tự xuống dòng.
   2026-06-03: giảm 20px → 16px (anh feedback cấu trúc ngữ pháp dài bị to). */
.kanji-quiz-explain-term { font-size: 16px; line-height: 1.4; font-weight: 700; color: #1f3558; word-break: break-word; }
.kanji-quiz-explain-rows { display: flex; flex-direction: column; gap: 3px; }
.kanji-quiz-explain-row { font-size: 14px; color: #34465f; }
.kanji-quiz-explain-row b { color: #6f7d95; font-weight: 600; }

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

/* 2026-06-03: nút "Câu tiếp theo" sau khi hiện đáp án — nút chính nổi bật,
   full-width, tông xanh tím chủ đạo (trước đó dùng style is-next nhạt, bị chìm). */
.kanji-quiz-next-btn {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 9px rgba(79, 110, 247, 0.2);
  transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
}
.kanji-quiz-next-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 13px rgba(79, 110, 247, 0.28);
  filter: brightness(1.03);
}
.kanji-quiz-next-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 7px rgba(79, 110, 247, 0.18);
}
.kanji-quiz-next-arrow { font-size: 16px; line-height: 1; }

.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;
}

/* 2026-05-23: Daily/Mixed quiz card căn giữa-dưới viewport (anh feedback "căn xuống dưới như p1").
   2026-05-30: BỎ scope mixed-quiz-mode → áp cho MỌI quiz (kanji/grammar/vocab) để khỏi bám
   mép dưới. Dùng dvh động để hết kẽ hở khi ẩn/hiện thanh URL trên iOS. */
.kanji-quiz-wrap:not(.quiz-result-wrap) {
  min-height: calc(100vh - 120px);
  min-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 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;
  /* 2026-05-06: gap 10→6 để 10 kanji fit khít trên iPhone 15 PM (430px) +
     iPhone SE (375px). Glyph CJK rộng hơn em-square nên cần giảm gap. */
  gap: 6px;
  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;
  /* 2026-05-06: font-size 15→13.5 + bỏ letter-spacing để fit 10 chars trên iPhone */
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
}

/* 2026-04-21 → 2026-05-06: media query siêu hẹp (≤340px iPhone SE 1st gen) — giảm thêm */
@media (max-width: 340px) {
  .kanji-mini-row {
    gap: 4px;
  }
  .kanji-inline-char {
    font-size: 12px;
  }
}

/* 2026-05-06 V2 (giữ): mini-row trong list nhóm — chia đều mobile.
   (Header phụ ở trang chi tiết là `.kanji-strip` — fix riêng tại @media 720). */
@media (max-width: 600px) {
  /* 2026-05-06: mini-row mobile — gap & size ở giữa "quá xa" (gap 6 + 13.5px)
     và "quá khít" (gap 1 + 10-13px). Sweet spot: gap 3, font 11-14. */
  .kanji-mini-row {
    overflow-x: hidden;
    gap: 3px;
    justify-content: flex-start;
  }
  .kanji-inline-char {
    flex: 0 0 auto;
    min-width: 0;
    text-align: center;
    font-size: clamp(11px, 3vw, 14px);
  }
}

.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;
}

/* 2026-05-10: footer ngữ pháp ẩn nút Lặp lại → 4 nút chia đều width */
.listening-footer.is-no-repeat {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
}

/* 2026-05-10: footer ngữ pháp Prev/Next có text "Trước"/"Sau" + icon < > */
.listening-footer.has-prev-next-label .footer-action-btn.is-prev,
.listening-footer.has-prev-next-label .footer-action-btn.is-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 6px;
  font-size: 14px;
}

.listening-footer.has-prev-next-label .footer-action-label {
  font-weight: 700;
}

.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: 20px;
  }

  .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 {
  /* 2026-05-23: 4 tabs (was 5) — bỏ tab Tổng hợp, mỗi tab rộng hơn.
     Polish: bo góc to hơn, shadow rõ hơn, padding container thoáng. */
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(21, 31, 56, 0.08);
}

.practice-tab {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 12px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #6b7280;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  min-width: 0;
  position: relative;
}

/* Divider mảnh giữa các tab — KHÔNG hiện cho tab đầu/cuối + tab active liền kề */
.practice-tab + .practice-tab::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: var(--line);
  pointer-events: none;
}
.practice-tab.is-active + .practice-tab::before,
.practice-tab.is-active::before {
  display: none;
}

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

.practice-tab.is-active {
  background: linear-gradient(135deg, #5b7df8 0%, #4f6ef7 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(79, 110, 247, 0.32), 0 1px 2px rgba(79, 110, 247, 0.18);
  transform: translateY(-1px);
}

.practice-tab-icon {
  font-size: 26px;
  line-height: 1;
}

.practice-tab-label {
  /* 2026-05-23: cho phép wrap 2 dòng (vd "Quiz nhanh" trước bị cắt thành
     "Quiz nha…" trên mobile 375px). font-size giảm nhẹ + line-height tăng
     để 2 dòng vẫn vừa height. word-break keep-all giữ chữ tiếng Việt nguyên. */
  font-size: 11px;
  line-height: 1.2;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
  max-width: 100%;
  text-align: center;
  font-weight: 600;
}

/* Mobile siêu hẹp <360px: ẩn label, chỉ icon */
@media (max-width: 360px) {
  .practice-tab-label {
    display: none;
  }
  .practice-tab {
    padding: 12px 2px;
  }
  .practice-tab-icon {
    font-size: 22px;
  }
}

.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;
}

/* 2026-06-02: gợi ý "chọn nhiều phần" cạnh nhãn Nhóm (Quiz nhanh Kanji) */
.practice-field-hint {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: #8aa0bf;
}

.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;
  /* 2026-05-23: giảm padding-x 14→11 + font 14→13.5 để chip "Luyện nghe"
     không wrap 2 dòng khi cùng row với 3 chip khác trên mobile 375px. */
  padding: 8px 11px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 36px;
  white-space: nowrap;
}

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

/* 2026-05-23: Nút ">>" expand thêm group, style giống pill thường nhưng có hint */
.practice-pill-more {
  font-weight: 700;
  letter-spacing: 1px;
}
.practice-pill-more:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.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 {
  /* 2026-05-23: pill chữ nhật full-width cell, height 88px — gọn hơn vuông to.
     Width fill cell (158px mobile 375px), height 88px → ratio 1.8:1. */
  width: 100%;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  padding: 10px 8px;
}
/* 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ố count — 2026-05-23: pill chữ nhật 88px height → font 17px cân */
.saved-module-pill .practice-pill-count {
  margin-left: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.1;
  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;
}

/* 2026-05-23: Quiz Hub Nội dung pills — 5 cột 1 hàng, chip cho phép wrap text 2 dòng.
   Chip "Tổng hợp" và "Luyện nghe" sẽ tự xuống dòng "hợp" / "nghe" → tất cả 5 chip
   cùng height đồng nhất, trông vuông. */
.practice-pills:has(> [data-practice-module]) {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.practice-pills:has(> [data-practice-module]) .practice-pill {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
  font-weight: 500;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 2026-05-23: Số câu pills — 5 cột grid (same Group P1-P5), 4 chip đầu, cell 5 trống.
   → chip width = P1 chip, tự căn lề trái (anh feedback). */
.practice-pills:has(> [data-practice-count]) {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.practice-pills:has(> [data-practice-count]) .practice-pill {
  padding: 8px 0;
  text-align: center;
  width: 100%;
}

/* 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 {
  /* 2026-05-23: tăng gap 8→12px + padding-y 16→18px cho thoáng hơn (anh feedback hơi hẹp). */
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px;
}
/* 2026-05-23: dùng `p.daily-*` để bump specificity thắng `.card p` (override muted). */
p.daily-date {
  /* 2026-05-23: to bằng section-label (14px) cho đồng nhất tiêu đề card.
     Weight 600 (giảm 700→600 theo feedback "nét đậm quá"). */
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: none; /* 2026-05-30: bỏ viết hoa — anh thấy rối mắt */
  color: var(--primary);
  margin: 0;
}
p.daily-streak-line {
  font-size: 15px;
  margin: 0;
  color: var(--text);
}
p.daily-history-line {
  /* 2026-05-23: var(--muted) #6f7d95 quá nhạt trên nền card trắng → xám mờ khó đọc.
     Đổi sang #374151 (gray-700) đậm hơn, vẫn nhẹ hơn streak-line chính.
     Dùng `p.daily-*` để bump specificity (0,1,1) thắng `.card p` (0,1,1, tie → last wins). */
  font-size: 13px;
  margin: 0;
  color: #374151;
}
.daily-kotowaza-card {
  position: relative; /* 2026-05-30: cho nút loa absolute ở góc trên phải */
  cursor: pointer; /* 2026-05-30: bấm cả block để phát audio */
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border-left: 4px solid #f59e0b;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
}
/* 2026-05-23: dùng `p.daily-*` để bump specificity thắng `.card p` (đang ép --muted). */
p.daily-section-label {
  /* 2026-05-23: weight 700→600 + color var(--muted) đồng nhất 3 card (header / kotowaza / challenge). */
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: none; /* 2026-05-30: bỏ viết hoa — anh thấy rối mắt */
  color: var(--muted);
  margin: 0 0 4px 0;
}
p.daily-kotowaza-ja {
  /* 2026-05-23: giảm 22→19px theo feedback "hơi to". */
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  color: #111827;
  line-height: 1.7;
}
.daily-kotowaza-ruby {
  ruby-position: over;
}
.daily-kotowaza-ruby rt {
  font-size: 0.55em;
  font-weight: 500;
  color: #6b7280;
}
/* 2026-05-30: nút phát audio Thành ngữ — icon loa 2D (side-icon-btn) như grammar câu B,
   đặt ở GÓC TRÊN PHẢI của block (anh feedback để dưới xấu). */
.daily-kotowaza-audio {
  position: absolute;
  top: 12px;
  right: 12px;
  margin: 0;
}
p.daily-kotowaza-meaning {
  /* 2026-05-23: bỏ mũi tên ở JS, thay bằng đường kẻ mờ đứt phía trên để phân tách
     nghĩa với kana — nhìn rõ ranh giới giữa "phiên âm" và "dịch nghĩa". */
  font-size: 15px;
  color: #111827;
  margin: 8px 0 0 0;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.18);
}
.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 {
  /* 2026-05-23: padding 16px + gap 8px cho thoáng (trước revert mất padding to). */
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}
/* 2026-05-23: pill picker cấp độ N5-N1 cho Daily Challenge. */
.daily-level-pills {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 2px 0 4px;
}
.daily-level-pill {
  /* 2026-05-23: text muted đồng nhất với label/desc/note trong cùng card challenge.
     is-active vẫn dùng nền primary + chữ trắng để rõ chip đang chọn. */
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.daily-level-pill:hover {
  background: var(--accent-soft);
  border-color: var(--primary);
}
.daily-level-pill.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
p.daily-challenge-desc {
  /* 2026-05-23: xám muted đồng nhất với field-label (anh feedback) — preview-card sẽ
     nổi bật hơn vì có nền primary-soft + chữ đen. */
  font-size: 14px;
  margin: 0;
  color: var(--muted);
}
p.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-origin-tag[data-origin="kotowaza"] {
  background: #fff7ed;
  color: #c2410c;
}

.mixed-kotowaza-prompt {
  display: grid;
  gap: 10px;
}
.mixed-kotowaza-ruby-line {
  color: #111827;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.8;
  text-align: center;
}
.mixed-kotowaza-ruby {
  ruby-position: over;
}
.mixed-kotowaza-ruby rt {
  color: #6b7280;
  font-size: 0.5em;
  font-weight: 500;
}
.mixed-kotowaza-prompt h3 {
  text-align: center;
}

/* 2026-05-25: Breakdown gồm kotowaza + 4 mảng học, dùng grid responsive gọn. */
.mixed-quiz-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 20px;
  padding: 0;
}
.mixed-quiz-breakdown-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 4px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbff;
}
.mixed-quiz-breakdown-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  grid-column: 1;
}
.mixed-quiz-breakdown-score {
  font-size: 14px;
  color: var(--muted);
  grid-column: 2;
  grid-row: 1;
  text-align: right;
}
.mixed-quiz-breakdown-score strong {
  color: var(--text);
  font-size: 16px;
}
.mixed-quiz-breakdown-pct {
  grid-column: 2;
  grid-row: 2;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
  letter-spacing: 0.04em;
}
.mixed-quiz-breakdown-item.is-good {
  border-color: #b8e8c7;
  background: #f0faf3;
}
.mixed-quiz-breakdown-item.is-good .mixed-quiz-breakdown-pct { color: #1f9d4c; }
.mixed-quiz-breakdown-item.is-ok {
  border-color: #ffe2a8;
  background: #fff8ec;
}
.mixed-quiz-breakdown-item.is-ok .mixed-quiz-breakdown-pct { color: #b07a14; }
.mixed-quiz-breakdown-item.is-low {
  border-color: #f5c5c5;
  background: #fff3f3;
}
.mixed-quiz-breakdown-item.is-low .mixed-quiz-breakdown-pct { color: #c93e3e; }
.mixed-quiz-breakdown-item.is-empty {
  opacity: 0.55;
}

/* 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á) ===== */
/* 2026-04-26: Phase 1 pricing — hiển thị giá + highlight gói đang required.
   Card là <button> để clickable + accessible; reset default button style. */
/* Bonus note — ưu đãi combo 2 chiều App ↔ Thẻ cứng */
/* 2026-04-26: Contact buttons — Facebook + Zalo (2 nút bằng width) */
/* Facebook xanh đặc trưng */
/* Zalo: cyan nhạt hơn để phân biệt với Facebook */
/* 2026-04-26: Account hint — text mộc, không màu, không nền */
/* 2026-04-21: inline success feedback (register + reset password) */
/* 2026-04-21: consent line dưới auth form (link Bảo mật/Điều khoản) */
/* ===== Redeem dialog — Auth panel (step 1, copy style từ auth-modal cũ) ===== */
/* 2026-04-26: Auth tab switcher (Đăng nhập / Đăng ký) — tab active màu xanh */
/* Confirm password field — chỉ hiện khi mode = register */
/* Single submit button (full-width) thay 2 nút song song cũ */
/* ===== 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.
   Button: chữ + cờ trắng, KHÔNG nền, KHÔNG viền.
   2026-05-06: Thêm safe-area-inset-top vào top để lang button KHÔNG dán đỉnh
   viewport (cao hơn title 60+px trên iPhone có notch). Align với content area
   của .head (padding-top: 10 + safe-top), cùng đường với title. */
/* 2026-05-26 (F.6): align lang flag với center của h1 thay vì top — anh feedback
   "hơi cao lên trên" trên module/grammar pages. Measure preview: h1 center y=22,
   slot height ~22 → top = 11. Cộng safe-area-inset-top cho iOS notch. */
.lang-switcher-slot {
  position: absolute;
  top: calc(11px + env(safe-area-inset-top, 0px));
  right: 16px;
  display: flex;
  align-items: center;
}

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

/* ============================================================
   2026-05-03: MOBILE UX FIXES — module pages
   - 100vh → 100dvh (iOS Safari URL bar issue)
   - Tab strip horizontal scroll thay vì squeeze chật
   - Practice modal safe-area-bottom
   - Long word break trong card (kanji compounds)
   - Header reserve space ngắn lại để title không bị cắt
   ============================================================ */

/* Modern viewport units — 100dvh tự thích ứng URL bar mobile.
   Fallback: trình duyệt cũ ignore dvh, dùng vh ở khai báo trước. */
@supports (height: 100dvh) {
  body { min-height: 100dvh; }
  .kanji-canvas { min-height: calc(100dvh - 190px); }
  .kanji-guide-dialog { max-height: min(88dvh, 920px); }
}

@media (max-width: 720px) {
  /* 2026-05-06: rule cũ scope `.kanji-tab` (không scope qua `.kanji-tabs`)
     làm leak ra strip thật (`.kanji-strip > .kanji-tab`), override flex 10%
     thành min-width 64px → 10 tabs × 64 = 640px tràn viewport iPhone (430px),
     user chỉ thấy 7 chữ. `.kanji-tabs` (có 's') vốn không còn tồn tại trong JS
     → scope lại để rule chỉ áp khi đúng container, đồng thời ép `.kanji-strip`
     fit-trong-viewport bằng flex chia đều 10% (đã set ở base rule line 558). */
  .kanji-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .kanji-tabs::-webkit-scrollbar { display: none; }
  .kanji-tabs > .kanji-tab {
    flex: 0 0 auto;
    min-width: 64px;
    height: 44px;
    scroll-snap-align: start;
  }
  /* Strip ở trang chi tiết kanji — KHÔNG scroll, chia đều 10 tab.
     2026-05-06: thêm padding ngang 8px để 2 chữ đầu/cuối không sát mép. */
  .kanji-strip {
    overflow-x: hidden;
    padding-left: 8px;
    padding-right: 8px;
    box-sizing: border-box;
  }
  .kanji-strip > .kanji-tab {
    flex: 1 1 0;
    min-width: 0;
  }

  /* Practice modal — safe-area iPhone home indicator */
  .practice-dialog {
    padding-bottom: max(18px, calc(18px + env(safe-area-inset-bottom)));
    max-height: calc(100dvh - 32px);
  }

  /* Practice modal close — tap 44 */
  .practice-close { width: 44px; height: 44px; font-size: 20px; }

  /* Long word break trong card (kanji compounds, romaji dài) */
  .kanji-card,
  .grammar-card,
  .vocab-card,
  .listening-card {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Header title không bị cắt giữa back + lang */
  .head .title {
    padding: 0 8px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  /* Module quiz/practice CTA chính — tap 48px */
  .practice-btn,
  .quiz-cta-btn,
  .saved-review-cta {
    min-height: 48px;
  }
}

/* ===== Leaderboard Hub (P1.2.6, 2026-05-21) ===== */
.leaderboard-hub {
  padding: 0;
  /* 2026-05-30: note "Cách tính điểm" gần đáy nhưng nhấc lên khỏi mép (trước -150px đẩy
     sát đáy → cụt 3 hàng cuối iPhone 15). Tăng trừ → hub thấp hơn → note cao hơn chút. */
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 210px);
}
.leaderboard-header {
  text-align: center;
  margin-bottom: 14px;
}
.leaderboard-title {
  margin: 0 0 4px;
  font-size: 19px;
  color: #111827;
}
.leaderboard-sub {
  margin: 0;
  font-size: 12.5px;
  color: #6b7280;
}
/* 2026-05-21 (P1.3.6): 3 chip cố định — rectangle bo góc, căn giữa */
.leaderboard-chips {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 4px 8px 14px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.leaderboard-chip {
  flex: 0 1 auto;
  min-width: 110px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #374151;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
  font-family: inherit;
}
.leaderboard-chip:hover {
  border-color: #4f6ef7;
}
.leaderboard-chip:active {
  transform: scale(0.97);
}
.leaderboard-chip.is-active {
  background: #4f6ef7;
  color: #fff;
  border-color: #4f6ef7;
}
@media (max-width: 480px) {
  .leaderboard-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .leaderboard-chip {
    min-width: 0;
    padding: 9px 6px;
    font-size: 12.5px;
  }
}
/* ③ (2026-05-31) Period toggle Tuần ↔ Tích luỹ — segmented nhỏ, căn giữa dưới chips */
.leaderboard-period-toggle {
  display: flex;
  width: fit-content;
  margin: -4px auto 14px;
  padding: 3px;
  gap: 2px;
  background: #f1f3f5;
  border-radius: 999px;
}
.lb-period-btn {
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.lb-period-btn:hover { color: #374151; }
.lb-period-btn.is-active {
  background: #fff;
  color: #4f6ef7;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12);
}
.leaderboard-chip-flag {
  font-size: 16px;
}
.leaderboard-loading {
  text-align: center;
  padding: 30px 10px;
  color: #6b7280;
  font-size: 14px;
}
.leaderboard-empty {
  text-align: center;
  padding: 30px 20px;
  color: #6b7280;
}
.leaderboard-empty p {
  margin: 0 0 6px;
  font-size: 14px;
}
.leaderboard-empty-sub {
  font-size: 12.5px;
  color: #9ca3af;
}
.leaderboard-podium {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  align-items: end;
}
.leaderboard-podium-card {
  background: linear-gradient(180deg, #fef3c7 0%, #fff 100%);
  border: 1.5px solid #fbbf24;
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}
.leaderboard-podium-card.rank-1 {
  background: linear-gradient(180deg, #fde68a 0%, #fff 100%);
  border-color: #f59e0b;
  transform: translateY(-4px);
  order: 2;
}
.leaderboard-podium-card.rank-2 {
  background: linear-gradient(180deg, #e5e7eb 0%, #fff 100%);
  border-color: #9ca3af;
  order: 1;
}
.leaderboard-podium-card.rank-3 {
  background: linear-gradient(180deg, #fed7aa 0%, #fff 100%);
  border-color: #ea580c;
  order: 3;
}
.leaderboard-podium-rank {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.leaderboard-podium-name {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaderboard-podium-points {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}
.leaderboard-self {
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 14px;
  color: #1e3a8a;
  text-align: center;
}
.leaderboard-self strong {
  font-size: 16px;
  color: #1e40af;
}
.leaderboard-self-empty {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #6b7280;
  font-size: 13px;
}
/* P1.3.8 (2026-05-30): Bạn bè empty state — thành tích bản thân + nút Mời bạn */
.leaderboard-friends-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 8px 6px;
  text-align: center;
}
.leaderboard-friends-empty .lf-hint {
  margin: 0;
  max-width: 320px;
}
.lf-self-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(100%, 320px);
  margin: 0;
}
.lf-self-name { font-weight: 700; }
.lf-self-meta { color: #2563eb; font-weight: 700; white-space: nowrap; }
.lf-invite-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #5b7df8, #4f6ef7);
  cursor: pointer;
}
.lf-invite-btn:active { transform: scale(0.97); }
.leaderboard-friends-empty .lf-guest { margin: 0; font-size: 12px; }
.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}
.leaderboard-row:last-child {
  border-bottom: 0;
}
.leaderboard-row.is-self {
  background: #fef3c7;
  border-radius: 8px;
  border-bottom-color: transparent;
  font-weight: 600;
}
.leaderboard-row-rank {
  flex-shrink: 0;
  width: 38px;
  color: #6b7280;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.leaderboard-row-name {
  flex: 1;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaderboard-row-points {
  flex-shrink: 0;
  font-weight: 700;
  color: #4f6ef7;
  font-variant-numeric: tabular-nums;
}
.leaderboard-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  font-style: italic;
}

/* P1.3.9 (2026-05-30): chú thích "Cách tính điểm" — kín đáo (không khung nổi),
   chữ xám nhạt như hint cũ để không gây rối mắt. */
.leaderboard-scoring-note {
  margin: auto 0 0; /* margin-top:auto → đẩy về gần đáy hub (xem .leaderboard-hub min-height) */
  padding: 16px 0 calc(20px + env(safe-area-inset-bottom, 0px));
}
.leaderboard-scoring-note .lsn-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
}
.leaderboard-scoring-note .lsn-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
.leaderboard-scoring-note .lsn-list li {
  font-size: 12px;
  line-height: 1.4;
  color: #9ca3af;
}

/* ===== Leaderboard CTA "Chọn quốc gia" (P1.3.3, 2026-05-21) ===== */
.leaderboard-cta {
  margin: 8px 0 12px;
  text-align: center;
}
.leaderboard-cta-btn {
  background: linear-gradient(135deg, #4f6ef7 0%, #6366f1 100%);
  color: #fff;
  border: 0;
  border-radius: 22px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.leaderboard-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.4);
}
.leaderboard-cta-btn:active {
  transform: translateY(0);
}

/* ===== Leaderboard chip empty/placeholder (P1.3.5, 2026-05-21) ===== */
.leaderboard-chip.is-empty {
  opacity: 0.7;
  border-style: dashed;
  background: #f9fafb;
}
.leaderboard-chip.is-empty:hover {
  opacity: 1;
  border-color: #4f6ef7;
  background: #eff6ff;
}
.leaderboard-chip.is-empty.is-active {
  opacity: 1;
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

/* ===== Leaderboard streak chip (P1.3.7, 2026-05-21) ===== */
.leaderboard-streak {
  display: inline-flex;
  align-items: center;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.leaderboard-podium-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.leaderboard-podium-card .leaderboard-streak {
  margin-right: 2px;
}
.leaderboard-row .leaderboard-streak {
  margin: 0 6px 0 auto;
}
.leaderboard-row.is-self .leaderboard-streak {
  background: #fff;
  border-color: #fb923c;
}

/* ── Cờ ngôn ngữ = SVG inline (ui/flags.js) ────────────────────────────────
   Emoji cờ 🇻🇳🇯🇵 không có glyph trên Windows/nhiều Android → hiện "VN"/"JP".
   SVG không theo font-size nên cỡ phải đặt bằng width. */
.lang-btn .lang-flag { display: inline-flex; line-height: 0; }
.lang-btn .lang-flag svg { width: 17px; height: auto; display: block; }
.lang-option .lang-flag { display: inline-flex; line-height: 0; flex: 0 0 auto; }
.lang-option .lang-flag svg { width: 19px; height: auto; display: block; }
