/* =============================================================
   AI cho Trẻ em vùng cao — giao diện
   Thiết kế lại: hiện đại, thân thiện máy tính bảng trong lớp học.
   - Chữ lớn, nút lớn, đọc được trong ánh sáng yếu.
   - Không dùng phông chữ ngoài (phần mềm chạy ngoại tuyến).
   - Nhẹ nhàng: bo góc to, đổ bóng mềm, chuyển động ngắn.
   - Kính trọng ai cần ít chuyển động (prefers-reduced-motion).
   ============================================================= */

:root {
  --green-950: #07271c;
  --green-900: #0b3d2c;
  --green-800: #0f5132;
  --green-700: #146c43;
  --green-600: #1b8255;
  --green-100: #e4f1ea;
  --green-50: #f2f8f4;
  --ink: #17251f;
  --ink-soft: #4a5a52;
  --paper: #ffffff;
  --bg: #f2f6f3;
  --line: #dbe5de;
  --amber-900: #92400e;
  --amber-100: #fef3c7;
  --red-700: #b42318;
  --red-100: #fee2e2;
  --blue-600: #2563eb;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(11, 61, 44, .08), 0 2px 8px rgba(11, 61, 44, .05);
  --shadow: 0 2px 6px rgba(11, 61, 44, .07), 0 10px 28px rgba(11, 61, 44, .09);
  --shadow-lg: 0 4px 12px rgba(11, 61, 44, .10), 0 22px 44px rgba(11, 61, 44, .12);
  --focus: #fbbf24;
  --grad-green: linear-gradient(135deg, var(--green-600), var(--green-800));
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 480px at 85% -10%, #e9f4ee 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
a { color: var(--green-700); }
::selection { background: #cdeedb; }

/* ---------------- header + điều hướng ---------------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, var(--green-950), var(--green-900));
  color: #fff;
  box-shadow: 0 2px 10px rgba(7, 39, 28, .35);
  padding-bottom: 0;
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  background: #fff;
  padding: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.brand-text h1 { font-size: 1.22rem; margin: 0; letter-spacing: .2px; }
.tagline { margin: 2px 0 0; font-size: .84rem; opacity: .88; }

.main-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 0 0;
}

.nav-btn {
  appearance: none;
  border: 1.5px solid transparent;
  background: rgba(255, 255, 255, .10);
  color: rgba(255, 255, 255, .92);
  font: inherit;
  font-weight: 700;
  font-size: .98rem;
  padding: 10px 18px;
  min-height: 46px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .1s ease;
}
.nav-btn:hover { background: rgba(255, 255, 255, .20); color: #fff; }
.nav-btn:active { transform: scale(.97); }
.nav-btn.is-active {
  background: #fff;
  color: var(--green-900);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .22);
}

/* ---------------- banner cảnh báo ---------------- */

.banner {
  margin: 14px auto 0;
  max-width: 1180px;
  width: calc(100% - 32px);
  background: var(--amber-100);
  color: var(--amber-900);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .95rem;
}

/* ---------------- khung trang ---------------- */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.view { display: none; }
.view.is-active {
  display: block;
  animation: view-in .26s ease both;
}

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

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.panel-title { font-size: 1.08rem; color: var(--green-900); }
.panel-subtitle { font-size: .96rem; color: var(--green-800); margin: 14px 0 6px; }

.hint { color: var(--ink-soft); font-size: .92rem; margin: 8px 0 0; }
.hint.tiny { font-size: .84rem; }
.hint.center { text-align: center; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------------- nút ---------------- */

.btn {
  appearance: none;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--green-700);
  background: var(--paper);
  color: var(--green-800);
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease,
              transform .08s ease, border-color .15s ease;
}
.btn:hover {
  background: var(--green-100);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0) scale(.99); }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.btn.primary {
  background: var(--grad-green);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(20, 108, 67, .35);
}
.btn.primary:hover { background: linear-gradient(135deg, var(--green-700), var(--green-900)); box-shadow: 0 6px 18px rgba(20, 108, 67, .4); }

.btn.secondary { background: var(--green-100); }
.btn.ghost { border-color: var(--line); background: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: #eef2ef; }

.btn.danger { border-color: #f3b3ad; color: var(--red-700); background: #fff5f4; }
.btn.danger:hover { background: #fdecea; }

.btn.small { min-height: 42px; padding: 6px 15px; font-size: .92rem; }
.btn.big { min-height: 64px; font-size: 1.25rem; padding: 12px 34px; border-radius: 14px; }
.btn.nav { min-width: 160px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }

/* =================== 1. BẢNG THẺ TỪ =================== */

.status-panel .status-line { font-size: 1.02rem; font-weight: 700; color: var(--green-900); }

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.group-card {
  appearance: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-height: 128px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.group-card:hover {
  border-color: var(--green-700);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, var(--green-50), var(--paper));
}
.group-card:active { transform: translateY(-1px); }

.g-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  font-size: 1.5rem;
  border-radius: 14px;
  background: var(--green-100);
  margin-bottom: 8px;
}
.group-card .g-name { display: block; font-size: 1.12rem; font-weight: 800; color: var(--green-900); }
.group-card .g-count { display: block; font-size: .88rem; color: var(--ink-soft); margin-top: 4px; }

.tag-pending {
  align-self: flex-start;
  margin-top: 10px;
  background: var(--amber-100);
  color: var(--amber-900);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  padding: 3px 11px;
}

/* ---- sân khấu thẻ ---- */

.stage-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.stage-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stage-group { font-weight: 800; color: var(--green-900); }
.stage-progress { color: var(--ink-soft); font-size: .92rem; }

.stage-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--green-100);
  overflow: hidden;
  margin: 0 0 18px;
}
.stage-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--grad-green);
  transition: width .3s ease;
}

.flashcard {
  display: grid;
  grid-template-columns: minmax(250px, 360px) 1fr;
  gap: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.photo-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background:
    repeating-linear-gradient(45deg, #f3f7f4, #f3f7f4 12px, #eef3ef 12px, #eef3ef 24px);
  border: 2px dashed #c9d8cf;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}
.photo-placeholder { text-align: center; color: var(--ink-soft); font-size: .94rem; padding: 12px; }
.photo-placeholder small { font-size: .8rem; opacity: .8; }
.photo-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.card-stt {
  display: inline-block;
  background: var(--green-100);
  color: var(--green-900);
  font-weight: 800;
  font-size: .88rem;
  padding: 4px 13px;
  border-radius: 999px;
}

.card-word {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--green-900);
  margin: 12px 0 6px;
}

.card-meta { margin: 10px 0 4px; }
.meta-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.meta-row dt { flex: 0 0 160px; color: var(--ink-soft); font-size: .92rem; }
.meta-row dd { margin: 0; font-weight: 600; }

.pending-tag {
  display: inline-block;
  background: var(--amber-100);
  color: var(--amber-900);
  border: 1px dashed #e8b23c;
  border-radius: 8px;
  padding: 2px 10px;
  font-size: .88rem;
  font-weight: 700;
}

.stage-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }

/* =================== 2. BẢNG CHẤM BÀI NÓI =================== */

.speak-layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) 1fr;
  gap: 18px;
  align-items: start;
}

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-btn {
  appearance: none;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s ease, transform .08s ease;
}
.chip-btn:hover { background: var(--green-100); }
.chip-btn:active { transform: scale(.97); }
.chip-btn.is-active { background: var(--grad-green); border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(20, 108, 67, .3); }

.sentence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.sentence-list li { display: flex; background: var(--paper); border-bottom: 1px solid var(--line); }
.sentence-list li:last-child { border-bottom: 0; }
.sentence-item {
  flex: 1;
  text-align: left;
  font: inherit;
  font-size: .98rem;
  background: transparent;
  border: 0;
  padding: 13px 14px;
  min-height: 54px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: baseline;
  transition: background .12s ease;
}
.del-sent {
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--red-700);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 14px;
}
.del-sent:hover { background: #fdecea; }
.sentence-item:hover { background: var(--green-50); }
.sentence-item.is-active {
  background: var(--green-100);
  box-shadow: inset 4px 0 0 var(--green-700);
  font-weight: 700;
}
.sentence-item .lv {
  flex: 0 0 auto;
  font-size: .72rem;
  font-weight: 800;
  border-radius: 6px;
  padding: 1px 7px;
  background: #eef2ef;
  color: var(--ink-soft);
}
.sentence-item .lv.de { background: #dcfce7; color: #166534; }
.sentence-item .lv.via { background: #e0f2fe; color: #075985; }
.sentence-item .lv.kho { background: var(--amber-100); color: var(--amber-900); }
.sentence-item .src { margin-left: auto; font-size: .72rem; color: var(--ink-soft); }
.sentence-item .del { margin-left: auto; border: 0; background: none; color: var(--red-700); cursor: pointer; font-size: .9rem; padding: 0 4px; }

.custom-details { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.custom-details summary { cursor: pointer; font-weight: 700; color: var(--green-900); }
.custom-details textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  resize: vertical;
  background: var(--green-50);
}
.custom-details textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.custom-row { display: flex; gap: 8px; margin-top: 8px; }
.custom-row select {
  font: inherit;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 44px;
  background: var(--paper);
}

.radio-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .93rem;
}
.radio-row:hover { background: #f6f9f7; }
.radio-row input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--green-700); }

.endpoint-box { margin-top: 6px; padding: 14px; background: #f6f9f7; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.field-label { display: block; font-size: .86rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.endpoint-row { display: flex; gap: 8px; flex-wrap: wrap; }
.endpoint-row input {
  flex: 1 1 220px;
  font: inherit;
  font-size: .92rem;
  padding: 9px 11px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 44px;
  background: var(--paper);
}
.msg-ok { color: var(--green-700); font-weight: 600; }
.msg-err { color: var(--red-700); font-weight: 600; }

.practice-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.badge {
  background: var(--green-100);
  color: var(--green-900);
  font-weight: 800;
  font-size: .86rem;
  border-radius: 999px;
  padding: 6px 15px;
}

.sentence {
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.5;
  margin: 14px 0;
  color: var(--ink);
  padding: 18px 20px;
  background: var(--green-50);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.word {
  appearance: none;
  font: inherit;
  font-weight: inherit;
  background: transparent;
  border: 0;
  border-bottom: 4px solid transparent;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  padding: 2px 5px;
  transition: background .12s ease;
}
.word:hover { background: var(--green-100); }
.word.on {
  background: #dcfce7;
  border-bottom-color: var(--green-700);
  color: var(--green-900);
}
.word:focus-visible { outline: 3px solid var(--focus); }

.record-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--green-50);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.record-status { font-size: .92rem; color: var(--ink-soft); }
.record-status.is-live { color: var(--red-700); font-weight: 700; }

.result-line { min-height: 1.4em; font-size: .95rem; color: var(--green-900); font-weight: 600; margin: 10px 0; }

.decision-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.session-list { list-style: none; margin: 8px 0; padding: 0; }
.session-list li {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: .93rem;
  align-items: baseline;
}
.session-list .t { color: var(--ink-soft); font-variant-numeric: tabular-nums; flex: 0 0 52px; }
.session-list .c { flex: 1; }
.session-list .d { margin-left: auto; font-size: .82rem; color: var(--green-800); font-weight: 700; }

/* =================== 3. VỀ DỰ ÁN =================== */

.table-wrap { overflow-x: auto; }
.report-table { border-collapse: collapse; width: 100%; font-size: .93rem; }
.report-table th, .report-table td { border: 1px solid var(--line); padding: 9px 11px; text-align: left; vertical-align: top; }
.report-table th { background: var(--green-100); color: var(--green-900); font-size: .88rem; }
.report-table tr:nth-child(even) td { background: #fafcfb; }

.state { display: inline-block; font-size: .78rem; font-weight: 800; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.state.ok { background: #dcfce7; color: #166534; }
.state.warn { background: var(--amber-100); color: var(--amber-900); }
.state.off { background: var(--red-100); color: var(--red-700); }

.principles { padding-left: 22px; }
.principles li { margin-bottom: 8px; }
.principles .note { display: block; color: var(--ink-soft); font-size: .88rem; }

.stop-list li { margin-bottom: 8px; }

/* =================== chân trang =================== */

.app-footer {
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 14px 20px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: .86rem;
}

.net-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.net-status .dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; }
.net-status.is-off .dot { background: var(--green-700); }
.net-status.is-on .dot { background: var(--blue-600); }

/* =================== 4. GIA SƯ BỎ TÚI + KHO TÀNG BẢN LÀNG =================== */

/* danh sách câu hỏi */
.sentence-item .q-txt { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.sentence-item .lv.mon { background: #e6f0ea; color: var(--green-800); }

/* khối thêm câu hỏi của thầy/cô */
.practice-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.custom-details input {
  width: 100%;
  font: inherit;
  padding: 9px 12px;
  margin-top: 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--green-50);
}
.custom-details input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.custom-details select {
  font: inherit;
  padding: 7px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 44px;
  width: 100%;
  background: var(--paper);
}
.practice-add-grid .field-label { margin-bottom: 0; }

/* màn hình làm bài */
.q-options { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.q-opt {
  appearance: none;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 700;
  text-align: left;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.q-opt:hover { border-color: var(--green-700); background: var(--green-50); }
.q-opt:active { transform: scale(.99); }
.q-opt.is-correct { background: #dcfce7; border-color: var(--green-700); color: var(--green-900); }
.q-opt.is-wrong { background: #fdecea; border-color: var(--red-400); color: var(--red-700); }

.hint-box { margin: 8px 0; }
.hint-step {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  margin: 6px 0;
  background: var(--amber-100);
  border-left: 4px solid #e8b23c;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .98rem;
  color: var(--amber-900);
  align-items: baseline;
}
.hint.tiny { font-size: .88rem; color: var(--ink-soft); }

/* truyện */
.story-card { min-height: 120px; }
.story-art {
  background: var(--green-50);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 12px 0;
}
.story-art svg { display: block; width: 100%; height: auto; max-height: 320px; }
.story-art svg rect, .story-art svg circle, .story-art svg path, .story-art svg polygon,
.story-art svg line { shape-rendering: geometricPrecision; }

/* =================== in ấn (đường phi kĩ thuật số) =================== */

#print-area { display: none; }

@media print {
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; font-family: Arial, sans-serif; color: #000; }

  .p-head { font-size: 14pt; margin-bottom: 4mm; }
  .p-note { font-size: 9pt; color: #333; margin-bottom: 5mm; }
  .p-group-title { font-size: 13pt; margin: 6mm 0 3mm; break-after: avoid; }

  .p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; }
  .p-card {
    border: 1.2pt solid #000;
    border-radius: 3mm;
    padding: 4mm;
    break-inside: avoid;
    display: flex;
    gap: 4mm;
    align-items: center;
  }
  .p-card img { width: 24mm; height: 18mm; object-fit: contain; border: .6pt solid #999; }
  .p-card .n { font-size: 9pt; color: #333; }
  .p-card .w { font-size: 20pt; font-weight: 700; margin: 1mm 0; }
  .p-card .e { font-size: 9pt; }
  .p-sent-group { margin-bottom: 6mm; break-inside: avoid; }
  .p-sent-group h3 { font-size: 12pt; margin-bottom: 2mm; }
  .p-sent-group ol { font-size: 12pt; line-height: 1.7; padding-left: 6mm; }

  /* phiếu luyện tập (Gia Sư Bỏ Túi) */
  .p-question { margin-bottom: 4mm; break-inside: avoid; padding: 3mm; border: .8pt solid #999; border-radius: 2mm; }
  .p-question .n { font-size: 10pt; font-weight: 700; }
  .p-question .w { font-size: 13pt; margin: 1.5mm 0; line-height: 1.5; }
  .p-question .e { font-size: 10pt; color: #222; margin-bottom: 2mm; }
  .p-question .ans { font-size: 10pt; margin-top: 1.5mm; }

  /* truyện (Kho Tàng Bản Làng) */
  .p-story-page { margin-bottom: 5mm; break-inside: avoid; border: .8pt solid #999; border-radius: 2mm; padding: 3mm; }
  .p-story-page .art { margin-bottom: 2mm; }
  .p-story-page .art svg { display: block; width: 100%; height: auto; max-height: 60mm; }
  .p-story-page .txt { font-size: 12pt; line-height: 1.6; }
  @page { margin: 12mm; }
}

/* =================== responsive =================== */

@media (max-width: 900px) {
  .flashcard { grid-template-columns: 1fr; }
  .speak-layout { grid-template-columns: 1fr; }
  .meta-row dt { flex-basis: 130px; }
  .btn.nav { min-width: 0; flex: 1; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .header-inner { padding: 10px 14px 0; }
  .main-nav { width: 100%; padding-bottom: 10px; }
  .nav-btn { flex: 1 1 auto; justify-content: center; padding: 10px 8px; font-size: .92rem; min-height: 44px; }
  .card-word { font-size: 2.4rem; }
  .stage-nav { flex-direction: column; }
  .stage-nav .btn { width: 100%; }
}

/* Kính trọng người cần ít chuyển động */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}