/* Giao diện thân thiện 2026: màu xanh ngọc + cam, chữ to, thẻ bo tròn, thanh dưới cho điện thoại.
   Tệp này nạp sau style.css/portal.css nên chỉ ghi đè, không xoá quy tắc cũ. */
:root {
  --primary: #13636a;
  --primary-dark: #0f3b3f;
  --tint: #e6f2f1;
  --accent: #f4a300;
  --accent-tint: #fff1cc;
  --accent-text: #7a4b00;
  --ok: #1e8e5a;
  --bad: #b3261e;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(15, 59, 63, .08);
  --green: var(--primary);
  --paper: #f4f8f8;
  --ink: #1f2a2b;
  --muted: #5b6b6c;
  --line: #cfdedd;
}

body {
  font-size: 16px;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Thanh trên ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1200px;
  margin-inline: auto;
  padding: 10px 24px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 16px;
  flex-shrink: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px 12px 12px 4px;
  background: var(--primary);
  font-size: 26px;
}

.brand small {
  font-size: 8px;
  letter-spacing: 1.4px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-inline: auto;
  font-size: 13px;
  font-weight: 600;
}

.top-nav a {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--primary-dark);
}

.top-nav a:hover {
  background: var(--tint);
  text-decoration: none;
}

.top-nav a[aria-current="page"],
.top-nav a:last-child {
  color: var(--primary-dark);
}

.top-nav a[aria-current="page"] {
  background: var(--tint);
  color: var(--primary);
}

.app-bar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.lang-form {
  margin: 0;
}

.lang-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.lang-switch span {
  padding: 4px 9px;
  border-radius: 999px;
}

.lang-switch span.on {
  background: var(--primary);
  color: #fff;
}

.install-button,
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.install-button {
  border: 2px solid var(--accent);
  background: var(--accent-tint);
  color: var(--accent-text);
}

.user-chip {
  background: var(--primary);
  color: #fff;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip:hover,
.install-button:hover {
  filter: brightness(1.05);
}

.install-hint {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 84px;
  z-index: 25;
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--primary-dark);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
}

/* ---------- Thanh chọn môn ---------- */
.subject-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1200px;
  margin-inline: auto;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.subject-bar-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.subject-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.subject-chips::-webkit-scrollbar {
  display: none;
}

.subject-chips form {
  margin: 0;
  flex-shrink: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 2px solid var(--primary);
  border-radius: 999px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.chip.on {
  background: var(--primary);
  color: #fff;
}

.subject-bar .utility-links {
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- Khối nội dung chung ---------- */
main {
  padding-inline: 24px;
  padding-bottom: 48px;
}

.page-heading {
  padding-block: 28px 18px;
}

.page-heading h1 {
  font-size: clamp(26px, 3.4vw, 38px);
  letter-spacing: -1px;
}

.page-heading p:not(.eyebrow),
.hero-description,
.content-card p,
.notice p,
.home-flow-description {
  font-size: 15px;
}

.eyebrow {
  font-size: 11px;
  color: var(--primary);
  margin-bottom: 10px;
}

.notice {
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  margin-block: 16px;
}

.notice-label {
  font-size: 10px;
  color: var(--accent-text);
  background: var(--accent-tint);
  padding: 4px 8px;
  border-radius: 6px;
}

.content-card {
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 22px;
}

.content-card h2 {
  font-size: 21px;
}

.badge {
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--tint);
  color: var(--primary-dark);
}

.badge.builtin {
  background: var(--accent-tint);
  color: var(--accent-text);
}

.button,
button.button {
  min-height: 44px;
  padding: 10px 20px;
  gap: 10px;
  align-items: center;
  border-radius: 12px;
  font-size: 15px;
  background: var(--primary);
  transition: transform .12s, background .12s;
}

.button:hover,
button.button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.button.secondary,
button.button.secondary {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.button.secondary:hover {
  background: var(--tint);
}

.button.small,
button.button.small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.text-button,
.subtle-link,
td a,
.muted a {
  font-size: 14px;
}

label {
  font-size: 14px;
}

input:not([type=radio]):not([type=checkbox]):not([type=hidden]):not([type=range]),
textarea,
select {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 16px;
  border-color: var(--line);
}

.flash {
  font-size: 15px;
  border-radius: 12px;
  border-color: #bfe3d1;
  background: #e8f7ef;
}

.flash.error {
  background: #fdebe9;
  border-color: #f0b8b3;
  color: #8a1f17;
}

.teacher-bar {
  font-size: 13px;
}

.options label {
  font-size: 16px;
  min-height: 48px;
  border-radius: 12px;
}

.term-button {
  border-bottom: 3px solid var(--accent);
  background: var(--accent-tint);
  border-radius: 6px;
  padding: 0 4px;
  font-size: inherit;
}

.term-button:hover {
  background: #ffe29a;
}

.site-footer {
  font-size: 13px;
  padding-block: 24px;
}

/* ---------- Trang chủ dạng bảng điều khiển ---------- */
.dash-hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 28px;
  align-items: center;
  margin-top: 22px;
  padding: 34px 36px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary) 70%, #1d8a8f);
  color: #fff;
  box-shadow: var(--shadow);
}

.dash-hero .eyebrow {
  color: #c9efeb;
}

.dash-hero h1 {
  font-size: clamp(30px, 4vw, 46px);
  letter-spacing: -1.4px;
  margin-bottom: 14px;
}

.dash-hero h1 em {
  color: var(--accent);
  font-style: normal;
  font-family: inherit;
}

.dash-hero .hero-description {
  color: #e2f3f1;
  max-width: 560px;
  font-size: 16px;
}

.dash-hero .hero-actions {
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.dash-hero .button {
  background: var(--accent);
  color: #3b2400;
}

.dash-hero .button:hover {
  background: #ffb21a;
}

.dash-hero .button.secondary {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-color: rgba(255, 255, 255, .6);
}

.dash-hero .muted {
  color: #bfe3df;
  font-size: 13px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hero-tags span {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  font-size: 13px;
}

.hero-figure {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .1);
}

.hero-figure .figure-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  font-size: 15px;
}

.hero-figure .figure-line strong {
  color: var(--primary);
}

.hero-figure .figure-line small {
  color: var(--muted);
}

.section-heading {
  margin-top: 36px;
  margin-bottom: 14px;
  align-items: center;
}

.section-heading h2 {
  font-size: 24px;
}

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

.subject-card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 20px 16px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  text-align: left;
  color: var(--ink);
  transition: transform .12s, border-color .12s;
}

.subject-card:hover,
.subject-card.on {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.subject-card .icon {
  font-size: 30px;
  line-height: 1;
}

.subject-card strong {
  font-size: 18px;
  color: var(--primary-dark);
}

.subject-card small {
  color: var(--muted);
  font-size: 13px;
}

.subject-grid form {
  margin: 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.feature-tile {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  align-items: start;
  padding: 18px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform .12s;
}

.feature-tile:hover {
  transform: translateY(-2px);
}

.feature-tile .icon {
  display: grid;
  place-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--tint);
  color: var(--primary);
  font-size: 22px;
}

.feature-tile strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}

.feature-tile p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.role-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.role-card {
  margin: 0;
  border-top: 5px solid var(--primary);
}

.role-card.teacher {
  border-top-color: var(--accent);
}

.role-card .toolbar {
  margin-block: 14px 8px;
}

.role-card details {
  margin-top: 8px;
}

.role-card summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 650;
  font-size: 14px;
}

.step-list {
  margin: 10px 0 0;
  padding-left: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 8px;
}

.step-list li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 15px;
}

.step-list li::before {
  counter-increment: step;
  content: counter(step);
  display: grid;
  place-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--tint);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
}

.step-list a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.home-flow-feedback {
  margin-top: 28px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--accent-tint);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.home-flow-feedback p {
  margin: 0;
  font-size: 15px;
}

/* ---------- Thẻ môn, level, trò chơi dùng chung ---------- */
.cards-grid,
.level-grid,
.game-grid {
  gap: 16px;
}

.level-grid .content-card .card-index,
.card-index {
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
}

.game-card h2 {
  font-size: 19px;
}

.game-symbol {
  background: var(--tint);
  color: var(--primary);
  border-radius: 14px;
}

.lesson-steps li {
  font-size: 14px;
}

.lesson-steps li[aria-current="step"] {
  color: var(--primary);
}

/* ---------- Nghe và luyện nói ---------- */
.listen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.icon-button:hover {
  background: var(--tint);
}

.icon-button[aria-pressed="true"] {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.speak-result {
  margin: 6px 0 0;
  font-size: 14px;
  min-height: 1.4em;
}

.speak-result .meter {
  display: block;
  height: 10px;
  margin-top: 6px;
  border-radius: 5px;
  background: var(--line);
  overflow: hidden;
}

.speak-result .meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ok);
  transition: width .5s;
}

.speak-result.low .meter i {
  background: var(--accent);
}

.speak-result .heard {
  color: var(--muted);
}

.lesson-term {
  padding: 16px;
  border-radius: 14px;
  background: var(--paper);
}

.lesson-term h4 {
  font-size: 20px;
  margin: 0 0 4px;
}

/* ---------- Thanh dưới cho điện thoại ---------- */
.bottom-nav {
  display: none;
}

@media (max-width: 850px) {
  .top-nav {
    display: none;
  }

  .app-bar {
    padding: 8px 16px;
    gap: 10px;
  }

  .brand small {
    display: none;
  }

  .user-chip {
    max-width: 120px;
  }

  .subject-bar {
    padding: 8px 16px;
  }

  .subject-bar .utility-links,
  .subject-bar-label {
    display: none;
  }

  main {
    padding-inline: 16px;
    padding-bottom: 96px;
  }

  .site-footer {
    padding-bottom: 90px;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(15, 59, 63, .08);
    gap: 0;
    font-size: 11px;
  }

  .bottom-nav a {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
    text-align: center;
  }

  .bottom-nav a span {
    font-size: 20px;
    line-height: 1;
  }

  .bottom-nav a[aria-current="page"],
  .bottom-nav a:last-child[aria-current="page"] {
    color: var(--primary);
    background: var(--tint);
  }

  .bottom-nav a:last-child {
    color: var(--muted);
  }

  .dash-hero {
    grid-template-columns: 1fr;
    padding: 24px 20px;
    border-radius: 20px;
  }

  .hero-figure {
    display: none;
  }

  .subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }

  .role-cards {
    grid-template-columns: 1fr;
  }

  .level-grid,
  .game-grid,
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-hero h1 {
    font-size: 28px;
  }

  .dash-hero .button {
    width: 100%;
    justify-content: center;
  }
}

/* ---------- Icon SVG ---------- */
.svg-icon {
  flex-shrink: 0;
  vertical-align: -0.2em;
}

.chip .svg-icon,
.badge .svg-icon,
.icon-button .svg-icon,
.hero-tags .svg-icon,
.figure-line .svg-icon {
  vertical-align: -0.25em;
  margin-right: 2px;
}

.bottom-nav a .svg-icon {
  width: 22px;
  height: 22px;
}

/* Bước bài học gọn trên điện thoại */
@media (max-width: 850px) {
  .lesson-steps {
    display: flex;
    gap: 6px;
    padding: 0;
  }

  .lesson-steps li {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    display: grid;
    justify-items: center;
    gap: 4px;
  }

  .lesson-steps span {
    margin: 0;
  }
}

/* ---------- Song ngữ trong bài đọc ---------- */
.vi-line {
  display: block;
  margin: -6px 0 16px;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-tint);
  border-radius: 0 10px 10px 0;
  color: #4a3a12;
  font-size: 15px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
}

h3 .vi-line {
  display: block;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}

.vi-title {
  margin: -8px 0 12px;
  color: var(--accent-text);
  font-size: 17px;
  font-weight: 600;
}

.bilingual.hide-vi .vi-line {
  display: none;
}

.icon-button[data-toggle-vi][aria-pressed="true"] {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---------- Danh sách bài đọc kiểu mục lục ---------- */
.lesson-list {
  margin-top: 18px;
}

.lesson-list .section-title small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.lesson-rows {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
}

.lesson-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform .12s;
}

.lesson-row:hover {
  transform: translateX(3px);
}

.lesson-number {
  display: grid;
  place-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--tint);
  color: var(--primary);
  font-weight: 700;
}

.lesson-titles {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.lesson-titles strong {
  font-size: 16px;
}

.lesson-titles .vi-line {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
}

.lesson-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- Chân trang kiểu dự án ---------- */
.site-footer {
  display: block;
  padding-block: 28px 32px;
  border-top: 1px solid var(--line);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 24px;
}

.footer-brand strong {
  display: block;
  font-size: 17px;
  color: var(--primary-dark);
}

.footer-brand small {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.footer-grid p {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.footer-grid h4 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
}

.footer-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.footer-grid li small {
  color: var(--muted);
}

.footer-grid a {
  color: var(--primary);
}

.footer-copy {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 850px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .lesson-row {
    grid-template-columns: 36px 1fr;
  }

  .lesson-badges {
    grid-column: 2;
    justify-content: flex-start;
  }
}

.sentence-listen {
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  margin-right: 8px;
  justify-content: center;
  vertical-align: middle;
}

.sentence-listen::before {
  content: "▶";
  font-size: 12px;
}

/* ---------- Tab lớp và hàng bài có nút ---------- */
.grade-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 16px;
}

.grade-tabs a {
  padding: 8px 16px;
  border: 2px solid var(--primary);
  border-radius: 999px;
  color: var(--primary-dark);
  font-weight: 650;
  font-size: 14px;
}

.grade-tabs a[aria-current="page"] {
  background: var(--primary);
  color: #fff;
}

.lesson-row-static {
  cursor: default;
}

.lesson-row-static:hover {
  transform: none;
}

.lesson-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.lesson-actions form {
  margin: 0;
}

@media (max-width: 850px) {
  .lesson-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

/* V8.3: đi tiếp giữa các bài theo chương trình */
.level-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.level-switch .chip[aria-current="page"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.next-steps {
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 8px;
}
.next-steps form { margin: 0; }
.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
}
.pager .button:last-child { justify-self: end; }
.pager .button small,
.next-steps .button small {
  display: block;
  font-weight: 400;
  font-size: .78rem;
  opacity: .85;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-link { color: inherit; text-decoration: none; }
.lesson-link:hover strong { color: var(--primary); text-decoration: underline; }
@media (max-width: 620px) {
  .pager { grid-template-columns: 1fr; }
  .pager .button:last-child { justify-self: stretch; }
}
/* style.css có `nav a:last-child { color: var(--green) }` cho menu cũ: không để nó làm mất chữ nút trong .pager/.level-switch. */
.pager a.button:not(.secondary) { color: #fff; }
.level-switch .chip:not([aria-current="page"]) { color: var(--primary-dark); }

/* Nút môn là đường dẫn /subject/<mã> (trước là nút form). */
a.chip, a.subject-card { text-decoration: none; }

/* V8.5: bộ phiếu khảo sát và bài kiểm tra của đề tài */
.survey-intro p { margin: 0; }
.survey-section { margin: 16px 0; }
.survey-section h2 { font-size: 18px; margin-bottom: 4px; }
.likert-row, .choice-group {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 12px 0;
}
.likert-row legend, .choice-group legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.likert-code {
  display: inline-block;
  min-width: 34px;
  color: var(--primary);
  font-weight: 700;
}
.likert-options { display: flex; flex-wrap: wrap; gap: 8px; }
.likert-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 52px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.likert-options label:has(input:checked) { background: var(--tint); border-color: var(--primary); }
.choice-group .check-label { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
.choice-group input[type="text"] { margin-top: 6px; width: 100%; }
.survey-open { display: block; padding: 12px 0; border-top: 1px solid var(--line); font-weight: 600; }
.survey-open textarea { width: 100%; margin-top: 6px; font-weight: 400; }
.survey-auto { padding: 8px 0; border-top: 1px solid var(--line); margin: 0; }
.req { color: var(--bad); }
.code-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--accent-tint);
  color: var(--accent-text);
  font-family: ui-monospace, monospace;
  letter-spacing: .5px;
}
.survey-banner { margin: 12px 0; }

/* V8.6: Lớp học của tôi */
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.stat-grid .stat { display: grid; gap: 2px; text-align: center; padding: 16px 8px; margin: 0; }
.stat-grid .stat strong { font-size: 26px; color: var(--primary-dark); }
.stat-grid .stat span { color: var(--muted); font-size: 13px; }
@media (max-width: 620px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.subject-frames .subject-card { min-height: 190px; align-content: start; }
.subject-frames .subject-open { margin-top: auto; color: var(--primary); font-weight: 700; }
@media (max-width: 900px) { .subject-grid.subject-frames { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.badge.verify-needed { background: var(--accent-tint); color: var(--accent-text); border: 1px solid #f0c36a; }

.open-dictionary h3 { margin: 12px 0 4px; font-size: 15px; color: var(--primary); }
.open-dictionary ol { margin: 0 0 6px; padding-left: 22px; }
.lesson-titles .badge { justify-self: start; align-self: start; width: fit-content; margin-top: 4px; }

.class-directory { margin-top: 28px; }
.class-directory h3 { margin: 18px 0 8px; color: var(--primary-dark); }
/* Dòng không có ô số thứ tự (danh sách lớp, bài của lớp): hai cột tên | nút, form nhập mã xuống dòng riêng. */
.lesson-row.plain-row { grid-template-columns: minmax(0, 1fr) auto; }
.lesson-row.plain-row.is-hidden { opacity: .6; }
.class-code-form { grid-column: 1 / -1; display: grid; gap: 6px; max-width: 420px; margin-top: 6px; }
.lesson-actions form.inline { display: inline; }
@media (max-width: 640px) {
  .lesson-row.plain-row { grid-template-columns: 1fr; }
  /* Quy tắc ≤850px đặt nút vào cột 2; dòng một cột thì nút xuống dưới tên, nếu không tên bị bóp dọc từng chữ. */
  .lesson-row.plain-row .lesson-actions { grid-column: 1; justify-content: flex-start; }
}

/* Máy tính (chuột, màn hình rộng): không hiện nút "Cài thành app"; điện thoại/máy tính bảng vẫn hiện khi trình duyệt cho cài. */
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .install-button { display: none !important; }
}

/* Trang kiểm định cho giáo viên bộ môn: hai lựa chọn tách rõ, nhận xét gửi bằng nút riêng. */
.review-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.review-filter select { width: auto; max-width: 100%; min-width: 0; }
.review-filter .button { margin: 0; }
.review-progress { width: 100%; height: 10px; }
.review-item h1 { font-size: 1.6rem; margin: 4px 0; }
.review-block { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 10px 0; border-top: 1px solid var(--line, #e3e8e6); }
.review-vi { color: #4a5a57; }
.review-actions { border: 1px solid var(--line, #d9e1df); padding: clamp(24px, 5vw, 48px); }
.review-actions h2 { margin: 0 0 20px; font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 500; }
.review-ok-form { display: block; }
.review-actions .review-ok {
  width: 100%; margin: 0; justify-content: center; background: #087d5c;
  font-size: clamp(1.25rem, 3vw, 1.75rem); padding: 16px 28px;
}
.review-choice { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; margin: 28px 0; color: #7a8582; }
.review-choice::before, .review-choice::after { content: ""; height: 1px; background: var(--line, #d9e1df); }
.review-choice span { font-size: 1.25rem; }
.review-reject { display: grid; gap: 14px; max-width: none; }
.review-reject label { margin: 0; font-size: clamp(1.15rem, 2.5vw, 1.45rem); color: var(--ink, #17302f); }
.review-reject textarea { min-height: 150px; font-size: 1rem; }
.review-send-row { display: flex; justify-content: flex-end; }
.review-actions .review-no {
  margin: 0; background: #fff; color: var(--ink, #17302f); border: 1px solid var(--line, #cfd8d5);
  font-size: 1.05rem; padding: 12px 20px; justify-content: center;
}
.review-actions .review-no:hover { background: var(--tint, #edf5f2); color: var(--primary-dark, #174f55); }
.review-skip { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line, #d9e1df); }
.review-skip .text-button { font-size: 1rem; }
@media (max-width: 760px) {
  .review-block { grid-template-columns: 1fr; gap: 6px; }
  .review-filter select, .review-filter .button { width: 100%; justify-content: center; }
  .review-actions { padding: 24px 18px; }
  .review-send-row { justify-content: stretch; }
  .review-actions .review-no { width: 100%; }
}

/* Menu tài khoản thả xuống ở góc trên (học sinh, giáo viên lớp, kiểm định, quản trị), mỗi nhóm có nút đăng xuất. */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 240px; max-width: min(320px, 90vw); padding: 8px;
  background: #fff; border-radius: 14px; box-shadow: 0 12px 32px rgba(15, 40, 45, .18);
  display: grid; gap: 2px;
}
.user-menu-panel a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink, #17302f); text-decoration: none; }
.user-menu-panel a:hover { background: #eef5f3; }
.user-menu-title { margin: 8px 10px 2px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6a7c79; }
.user-menu-panel form { margin: 2px 0 6px; padding-bottom: 6px; border-bottom: 1px solid #e6ecea; }
.user-menu-panel form:last-child { border-bottom: 0; padding-bottom: 0; }
.user-menu-logout {
  width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px;
  background: #fbefec; color: #a2391f; font-weight: 650; cursor: pointer;
}
.user-menu-logout:hover { background: #f6dcd5; }

/* Nút tên trên header: tên dài cắt bằng dấu …, không đẩy header tràn ngang trên điện thoại. */
.user-menu > summary.user-chip { display: inline-flex; max-width: 180px; white-space: nowrap; overflow: hidden; }
@media (max-width: 480px) {
  .user-menu > summary.user-chip { max-width: 112px; padding: 6px 10px; }
  .brand { flex-shrink: 1; min-width: 0; }
  .brand > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Giao bài theo chương: một ô chọn chương, một nút. */
.assign-simple { display: grid; gap: 10px; max-width: 640px; }
.assign-simple details { margin-top: 4px; }

/* Hồ sơ giáo viên: ô tên + nút lưu cùng dòng (xuống dòng trên điện thoại). */
.profile-row { display: grid; gap: 6px; max-width: 640px; }
.inline-input { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-input input { flex: 1 1 220px; }

/* Trang "Có phải em không?" khi vào lớp với tên gần giống một bạn đã có. */
.join-confirm { display: grid; gap: 10px; max-width: 560px; }
.join-confirm .button { width: 100%; justify-content: center; white-space: normal; text-align: center; }

/* Gộp học sinh trùng trên trang lớp. */
.merge-card { margin-top: 18px; }
.merge-suggest { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #e6ecea; }
.merge-form { display: grid; gap: 6px; max-width: 460px; margin-top: 12px; }

/* Câu hỏi kiến thức trên trang kiểm định. */
.review-concepts > li { margin-bottom: 12px; }
.review-concepts ul { margin: 4px 0; }
.review-concepts .is-answer { color: #1f7a4d; font-weight: 700; }

/* Bài giao 2 bước: đọc bài của chương rồi làm bài. */
.assign-step { margin: 10px 0 4px; }
.assign-readings { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 6px; }
.assign-readings li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; align-items: center;
  padding: 6px 8px; border-radius: 10px; background: #f6f9f8; }
.assign-readings li.is-done { background: #e7f4ec; }
.assign-levels { display: flex; flex-wrap: wrap; gap: 4px; }

/* Tra từ trong bài đọc: mọi từ bấm được (chỉ gạch chân khi rê/chạm), thuật ngữ vẫn tô màu; nghĩa hiện trong popup. */
.word-lookup { cursor: pointer; border-radius: 3px; }
.word-lookup:hover, .word-lookup:focus { background: #eaf3f1; text-decoration: underline dotted; outline: none; }
.term-popup {
  position: absolute; z-index: 80; width: min(360px, calc(100vw - 16px)); margin: 0; padding: 14px 16px 12px;
  background: #fffdf5; border: 1px solid #e3d9b0; border-radius: 14px; box-shadow: 0 14px 36px rgba(20, 40, 40, .22);
}
.term-popup[hidden] { display: none; }
.term-popup h3 { margin: 0 28px 2px 0; font-size: 22px; }
.term-popup p { margin: 4px 0; }
.term-popup .toolbar { margin-top: 8px; gap: 6px; flex-wrap: wrap; align-items: center; }
.term-popup-close { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; font-size: 18px;
  cursor: pointer; color: #5d6f6c; padding: 4px 8px; border-radius: 8px; }
.term-popup-close:hover { background: #f1ecd6; }
.term-popup-kind { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #8a7a3a; }
.term-popup-vi { font-weight: 650; }
.term-popup-defs { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.term-popup-example { font-style: italic; color: #4a5a57; }
.term-popup.is-sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; border-radius: 18px 18px 0 0;
  max-height: 60vh; overflow: auto; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.term-popup .speak-result:empty, .term-popup [hidden] { display: none; }

/* V8.19: Soạn đề với AI — nút riêng; chưa bật AI thì nút mờ, dòng ghi chú nói rõ. */
.steps-list { padding-left: 22px; display: grid; gap: 6px; }
.ai-quiz-note { margin: 4px 0 0; }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.notice.ai-made { margin-bottom: 12px; }

/* Tiến độ lớp cho giáo viên: ô tổng quan, bộ lọc, màu tỉ lệ đúng, popup chi tiết. */
.progress-board { margin: 18px 0 8px; }
.progress-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.progress-chip { border: 1px solid #cfdcd9; background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  font-size: 13px; color: var(--ink, #17302f); }
.progress-chip b { margin-left: 4px; color: var(--primary); }
.progress-chip.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.progress-chip.is-active b { color: #fff; }
.progress-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 10px; }
.progress-filters label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.progress-filters input, .progress-filters select { min-width: 200px; }
.acc { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.acc-low { background: #fbe3dc; color: #a2391f; }
.acc-ok { background: #fff1d2; color: #8a5a00; }
.acc-high { background: #dff2e6; color: #1f7a4d; }
.tag-chua_hoc, .tag-can_ho_tro { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 700; color: #a2391f; }
.student-dialog { width: min(760px, calc(100vw - 24px)); max-height: 86vh; border: 0; border-radius: 16px; padding: 20px 22px;
  box-shadow: 0 20px 50px rgba(15, 40, 45, .3); }
.student-dialog::backdrop { background: rgba(15, 35, 38, .45); }
.student-dialog h2 { margin: 0 32px 2px 0; }
.student-dialog h3 { margin: 16px 0 6px; font-size: 16px; }
.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.detail-stats div { background: #f2f7f6; border-radius: 12px; padding: 10px; text-align: center; display: grid; }
.detail-stats b { font-size: 22px; color: var(--primary); }
.detail-stats span { font-size: 12px; color: #5d6f6c; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-table th, .detail-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #e6ecea; }
.detail-terms { margin: 0; padding-left: 18px; }
@media (max-width: 560px) { .detail-stats { grid-template-columns: repeat(2, 1fr); } }

/* Trang Vào lớp chung: hai khung Học sinh | Giáo viên; trên điện thoại xếp chồng. */
.join-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.join-role h2 { margin-top: 2px; }
.join-role.teacher { border-top: 4px solid #8a6d1f; }
.join-role:not(.teacher) { border-top: 4px solid var(--primary); }
.role-label { display: inline-block; margin: 0 0 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--primary); }
.role-label.teacher { background: #8a6d1f; }
.opened-classes { margin: 4px 0 8px; padding-left: 18px; }
.class-directory .lesson-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
@media (max-width: 760px) { .join-roles { grid-template-columns: 1fr; } }

.class-code-form .role-label { justify-self: start; }

/* Bảng thông báo hôm nay (dưới bảng tiến độ): mỗi thông báo một dòng, bấm để xem tên; một câu nhắc chép sẵn. */
.notice-board { margin: 18px 0; padding: 14px 16px; border-radius: 14px; background: #f4f8f7; border: 1px solid #d8e5e2; }
.notice-board.is-due { background: #fff6e6; border-color: #f0c770; }
.notice-board-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; justify-content: space-between; }
.notice-board-head h2 { margin: 0; font-size: 18px; }
.notice-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.notice-item { padding: 6px 10px; border-radius: 8px; background: #fff; border-left: 4px solid #9fb6b2; font-size: 15px; }
.notice-item.level-warn { border-left-color: #d9822b; }
.notice-item.level-ok { border-left-color: #2f9a64; }
.notice-item summary { cursor: pointer; }
.notice-item details p { margin: 4px 0 0; }
.notice-remind { display: flex; gap: 8px; align-items: center; }
.notice-remind textarea { flex: 1; min-width: 0; font: inherit; font-size: 14px; resize: none; overflow: hidden; }
@media (max-width: 560px) { .notice-remind { flex-direction: column; align-items: stretch; } .notice-remind textarea { flex: none; } }
.profile-notice { margin: 0 0 10px; padding: 6px 10px; border-radius: 8px; background: #f4f8f7; }
.profile-notice.is-due { background: #fff6e6; }

/* Danh sách phiếu khảo sát: chừa khoảng cách với khung bên dưới (ô nhập mã GV ở Phiếu 5). */
.survey-steps { margin-bottom: 20px; }

/* Trang Kết quả đề tài (/ket-qua): thanh chuyển trang, lọc lớp, thanh tỉ lệ, thống kê từng câu. */
.results-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.results-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.results-filter select { width: auto; min-width: 220px; max-width: 100%; }
.results-login { max-width: 460px; }
.stats-grid.results-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.results-tiles > div { padding: 12px 14px; }
.results-tiles strong { font-size: 26px; font-weight: 700; color: var(--primary); }
.results-tiles span { font-size: 13px; }
.results-table td, .results-table th { vertical-align: top; }
.results-details { margin: 10px 0 18px; }
.results-details summary { cursor: pointer; font-weight: 700; }
.results-links { padding-left: 18px; }
.results-links li { margin: 4px 0; }
.result-bar { display: inline-block; width: 120px; height: 10px; border-radius: 999px; background: #e6ecea; vertical-align: middle;
  overflow: hidden; }
.result-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.result-item { margin: 10px 0; }
.result-item h3 { margin: 0 0 6px; font-size: 16px; }
.result-scale { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.result-scale li { display: grid; grid-template-columns: 36px 160px auto; gap: 10px; align-items: center; }
.result-scale .result-label.wide { white-space: normal; }
.result-scale li:has(.wide) { grid-template-columns: minmax(140px, 320px) 160px auto; }
.result-scale .result-bar { width: 100%; }
.result-texts { margin: 0; padding-left: 18px; }
.result-texts li { margin: 4px 0; }
.result-stack { display: flex; height: 22px; border-radius: 8px; overflow: hidden; background: #e6ecea; margin: 4px 0; }
.result-stack span { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff;
  min-width: 0; overflow: hidden; }
.result-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; color: #4b5d5a; }
.result-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.level-0 { background: #9aa5a3; }
.level-1 { background: #c8553d; }
.level-2 { background: #e09f3e; }
.level-3 { background: #b9b46a; }
.level-4 { background: #4f9d79; }
.level-5 { background: #1f6f5c; }
@media (max-width: 640px) { .results-table { min-width: 560px; } }
@media (max-width: 560px) {
  .result-scale li, .result-scale li:has(.wide) { grid-template-columns: 1fr 90px; }
  .result-scale li > .small { grid-column: 1 / -1; }
}

/* Trang "Đã gửi thành công" sau khi nộp phiếu, bài kiểm tra hoặc bấm kiểm định. */
.done-card { max-width: 560px; margin: 48px auto; padding: 32px 24px; text-align: center; background: #fff; border-radius: 20px;
  border: 1px solid #d8e5e2; box-shadow: 0 12px 30px rgba(15, 40, 45, .08); }
.done-icon { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 50%; background: #2f9a64; color: #fff;
  font-size: 44px; font-weight: 700; line-height: 76px; }
.done-card h1 { margin: 0 0 8px; font-size: 28px; }
.done-card p { margin: 6px 0 12px; }
.done-code { padding: 10px 12px; border-radius: 12px; background: #fff6e6; }
.done-code strong { font-size: 22px; letter-spacing: .04em; }
