:root {
  color-scheme: light;

  --ink: #1b1a2e;
  --ink-soft: #33324a;
  --muted: #65647a;
  --line: rgba(27, 26, 46, 0.1);
  --surface: #ffffff;

  --primary: #5a35d4;
  --primary-ink: #ffffff;
  --dark: #1c1b33;
  --dark-ink: #ffffff;
  --accent-green: #0d7a58;

  --mint: #8fe0c3;
  --lavender: #cdbff0;
  --amber: #fbd27e;
  --pink: #fbb3c6;
  --mint-pale: #e0f6ec;
  --lavender-pale: #efeafb;
  --amber-pale: #fdf1d3;
  --pink-pale: #fde8ee;

  --danger: #a3233a;
  --danger-soft: #fde8ec;
  --ok: #0d6a4d;
  --ok-soft: #d3f2e4;
  --warn: #7a5200;
  --warn-soft: #fdf0cf;

  --shadow-sm: 0 2px 8px rgba(47, 38, 92, 0.08);
  --shadow-md: 0 10px 28px rgba(47, 38, 92, 0.14);
  --radius-lg: 28px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  font-family: 'Be Vietnam Pro', 'Noto Sans Lao', system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }

/* Phần tử được cuộn tới hoặc nhận focus không bị thanh điều hướng nổi che mất. */
html { scroll-padding-bottom: 7rem; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Cảm giác như app: chạm là phản hồi ngay, không phóng to khi chạm đúp, không bôi đen nhầm thanh điều hướng. */
a, button, label, select, summary { touch-action: manipulation; }
.bottom-nav, .button, .cta, .btn-sm, .icon-button, .tabs, .lang-switch { -webkit-user-select: none; user-select: none; }

/* Khi cài lên màn hình chính, không cho kéo trang nảy ra ngoài. */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }
}

/* Chuyển trang mượt, thanh điều hướng đứng yên. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; }
}

.bottom-nav { view-transition-name: app-nav; }

body {
  position: relative;
  margin: 0;
  min-height: 100dvh;
  background: #fbf7f1;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

/* Nền chuyển màu đặt ở lớp cố định: background-attachment: fixed không ổn định trên iPhone. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(90% 55% at 0% 0%, #fde6d6 0%, transparent 70%),
    radial-gradient(85% 50% at 100% 0%, #edf6cf 0%, transparent 70%),
    radial-gradient(90% 55% at 100% 100%, #e6dffb 0%, transparent 70%),
    radial-gradient(70% 45% at 0% 100%, #dff5ec 0%, transparent 70%);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
h2 { font-size: 1.125rem; font-weight: 600; line-height: 1.35; }
h3 { font-size: 1rem; font-weight: 600; }
code { font-size: 0.875rem; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Chữ Lào có dấu trên và dưới dòng, cần khoảng cách dòng rộng hơn. */
:lang(lo) h1, :lang(lo) h2, :lang(lo) .display { line-height: 1.5; }

.icon { flex: none; display: block; }
.muted { color: var(--muted); }

.page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    2rem
    max(1rem, env(safe-area-inset-left));
}

/* Chừa chỗ cho thanh điều hướng nổi. */
.page--with-nav { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }

/* Tiêu đề hai tông màu */
.display { font-size: 2rem; font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
.display span { display: block; color: var(--muted); font-weight: 400; }

/* Nút tròn chỉ có biểu tượng */
.icon-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 120ms var(--ease);
}

.icon-button:active { transform: scale(0.94); }

/* Thanh tiêu đề của trang con */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 0.5rem;
  margin: calc(-1 * max(1rem, env(safe-area-inset-top))) -1rem 1rem;
  padding: max(0.5rem, env(safe-area-inset-top)) 1rem 0.5rem;
  background: rgba(251, 247, 241, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.app-bar h1 { font-size: 1.125rem; text-align: center; }

/* Lời chào đầu trang */
.greeting { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.greeting-text { flex: 1; min-width: 0; font-size: 0.875rem; color: var(--muted); }
.greeting-text strong { display: block; color: var(--ink); font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }

.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, #7a56ea, var(--primary));
  color: #fff;
  font-weight: 600;
}

.avatar--lg { width: 88px; height: 88px; font-size: 2rem; }

/* Hộp thông tin dạng viên thuốc */
.status-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  padding: 0.625rem 1rem 0.625rem 0.625rem;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.status-pill-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--lavender-pale);
  color: var(--primary);
}

.status-pill strong { display: block; font-size: 0.9375rem; font-weight: 600; }
.status-pill p { color: var(--muted); font-size: 0.8125rem; line-height: 1.4; }

/* Thẻ hình khối bo tròn không đều */
.blob-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }

.blob {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 208px;
  padding: 1rem;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.blob::after {
  content: '';
  position: absolute;
  top: -28px;
  right: -28px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

.blob--mint { background: var(--mint); border-radius: 26px 62px 30px 44px / 26px 44px 30px 54px; }
.blob--lavender { background: var(--lavender); border-radius: 56px 26px 46px 30px / 40px 26px 58px 30px; }
.blob--amber { background: var(--amber); border-radius: 30px 46px 26px 60px / 30px 58px 26px 42px; }
.blob--pink { background: var(--pink); border-radius: 46px 30px 58px 26px / 58px 30px 42px 26px; }

.blob-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.blob-title { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.blob:lang(lo) .blob-title { line-height: 1.5; }
.blob-text { margin-top: 0.25rem; color: var(--ink-soft); font-size: 0.8125rem; line-height: 1.4; }
.blob-foot { display: flex; align-items: center; justify-content: flex-end; margin-top: auto; padding-top: 0.5rem; }

.blob-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
}

.blob-tag {
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Thẻ số liệu */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1.25rem; }
.stat { min-height: 168px; justify-content: flex-end; }
.stat strong { font-size: 2.25rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { padding-right: 2.75rem; color: var(--ink-soft); font-size: 0.875rem; }
.stat-arrow { position: absolute; right: 0.75rem; bottom: 0.75rem; }

/* Thẻ nội dung */
.card {
  margin-bottom: 0.875rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card--lavender { background: var(--lavender-pale); }
.card--mint { background: var(--mint-pale); }
.card h2 { margin-bottom: 0.5rem; }
.card h3 { margin: 1.25rem 0 0; }
.card h1 + p, .card p + p, .card-note { margin-top: 0.75rem; }
.display + .muted { margin-top: 0.5rem; }

.badges { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.badge {
  padding: 0.1875rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: rgba(255, 255, 255, 0.82); color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--line); }
.badge-draft { background: var(--amber-pale); color: var(--warn); }
.badge-published { background: var(--ok-soft); color: var(--ok); }
.badge-archived { background: #e8e7ee; color: var(--ink-soft); }
.badge-repeat { background: var(--mint-pale); color: var(--ok); }
.badge-qa { background: var(--lavender-pale); color: var(--primary); }

/* Khu vực quản trị */
.page--wide { max-width: 820px; }
.page-title { margin-bottom: 1rem; font-size: 1.75rem; }
.section-title { margin: 1.5rem 0 0.75rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] { display: none !important; }

.toast {
  max-width: 820px;
  margin: 0.75rem auto 0;
  width: calc(100% - 2rem);
  padding: 0.75rem 1rem;
  border-radius: 18px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 0.9375rem;
  font-weight: 500;
}

.toast--error { background: var(--danger-soft); color: var(--danger); }

.notice {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: 18px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.9375rem;
}

.empty {
  padding: 2rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  text-align: center;
}

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0; }
.toolbar .btn-sm { margin-left: auto; }

.search { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1rem; }
.search input { flex: 1; }

.tabs {
  display: inline-flex;
  max-width: 100%;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-sm);
}

.tabs a {
  padding: 0.625rem 1rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a[aria-current] { background: var(--primary); color: var(--primary-ink); }

.list { display: grid; gap: 0.625rem; margin: 0; padding: 0; list-style: none; }
.list--plain .list-row { padding: 0.625rem 0; border-radius: 0; background: none; box-shadow: none; }
.list--plain .list-row + .list-row { border-top: 1px solid var(--line); }

.list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.875rem 1.125rem;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.list-row--link { flex-wrap: nowrap; color: inherit; text-decoration: none; }
.list-row--link .list-main { flex: 1; }
.list-main { display: grid; gap: 0.125rem; min-width: 0; }
.list-main strong { font-weight: 600; overflow-wrap: anywhere; }
.list-main .muted { font-size: 0.875rem; overflow-wrap: anywhere; }
.list-main .badges:empty { display: none; }
.list-main .badges { margin-top: 0.25rem; }

.list-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.list-actions--start { margin-top: 1rem; }

.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.25rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.btn-danger { border-color: rgba(163, 35, 58, 0.35); color: var(--danger); }
.btn-icon { width: 44px; padding: 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-top: 1rem; }

/* Câu trong bộ nội dung */
.item-list { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.item-list .card { margin: 0; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.8125rem; }
.item-text { margin-top: 0.625rem; font-size: 1.125rem; font-weight: 500; }
.answer-list { display: grid; gap: 0.875rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
.answer-list > li { padding-left: 0.875rem; border-left: 3px solid var(--lavender); }
.item-list .audio-player { margin-top: 0.625rem; }

/* Các dòng thêm và xóa được trong biểu mẫu */
.repeat-group {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  margin: 0;
  padding: 1rem;
  border: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.6);
}

.repeat-group legend { float: left; width: 100%; margin-bottom: 0.25rem; padding: 0; font-weight: 600; }
.repeat-group legend + * { clear: both; }
[data-row-list] { display: grid; gap: 0.75rem; }

.repeat-row {
  display: grid;
  gap: 0.75rem;
  padding: 0.875rem;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.repeat-row-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; }
.repeat-row-foot label { flex: 1; }

.repeat-row--inline { grid-template-columns: 5.5rem minmax(0, 1fr) 44px; align-items: end; }
.repeat-row--inline .btn-icon { margin-bottom: 5px; }
.repeat-row--inline input, .repeat-row--inline select { padding-inline: 0.875rem; }
.repeat-row--inline select { padding-right: 2.25rem; background-position: right 0.625rem center; }

.check-list { display: grid; gap: 0.125rem; max-height: 320px; overflow-y: auto; }

.check-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-weight: 400;
  cursor: pointer;
}

.check-row input { flex: none; width: 22px; height: 22px; accent-color: var(--primary); }

/* Lịch học của nhóm */
.schedule { display: grid; gap: 0.25rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }

.schedule li {
  display: grid;
  grid-template-columns: 6.25rem 4rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
}

.schedule li[aria-current] { background: rgba(255, 255, 255, 0.86); font-weight: 600; }
.schedule-date { font-variant-numeric: tabular-nums; }

/* Bảng */
.table-wrap { overflow-x: auto; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { padding: 0.75rem 1rem; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.8125rem; font-weight: 500; white-space: nowrap; }
tbody tr { border-top: 1px solid var(--line); }
td code { font-size: 0.9375rem; user-select: all; }

/* Biểu mẫu */
.stack { display: grid; gap: 1rem; margin-top: 1rem; }

label { display: grid; gap: 0.375rem; font-size: 0.875rem; font-weight: 500; }

/* Cỡ chữ 16px để Safari trên iPhone không tự phóng to khi nhập liệu. */
input:not([type='checkbox'], [type='radio'], [type='hidden'], [type='file']), textarea, select {
  width: 100%;
  min-height: 54px;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 27px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  box-shadow: var(--shadow-sm);
}

textarea { border-radius: 22px; resize: vertical; }

select {
  appearance: none;
  padding-right: 2.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%231b1a2e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

input[type='file'] {
  width: 100%;
  padding: 0.75rem;
  border: 1px dashed rgba(27, 26, 46, 0.3);
  border-radius: 18px;
  background: var(--surface);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
}

small { font-size: 0.8125rem; font-weight: 400; }

.field-error { color: var(--danger); font-size: 0.8125rem; font-weight: 500; }

.form-grid { display: grid; gap: 1rem; }

@media (min-width: 560px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.form-grid--always { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid > label { min-width: 0; }
.form-grid input { min-width: 0; padding-inline: 0.875rem; }

.form-error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 18px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

/* Nút chính dạng viên thuốc, có vòng tròn mũi tên */
.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  padding: 0.5rem 4rem;
  border: 0;
  border-radius: 32px;
  background: var(--dark);
  color: var(--dark-ink);
  font: inherit;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 120ms var(--ease);
}

.cta:active { transform: scale(0.985); }

.cta-arrow {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--primary);
  border-radius: 24px;
  background: var(--primary);
  color: var(--primary-ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms var(--ease);
}

.button:active { transform: scale(0.97); }
.button-quiet { background: var(--surface); color: var(--primary); }
.button[aria-pressed='true'] { box-shadow: 0 0 0 4px rgba(90, 53, 212, 0.22); }

/* Chọn ngôn ngữ */
.lang-switch {
  display: inline-flex;
  gap: 0.125rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-sm);
}

.lang-switch button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.lang-switch button[aria-current] { background: var(--primary); color: var(--primary-ink); }

/* Thanh điều hướng nổi */
.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  padding: 0.25rem max(0.25rem, env(safe-area-inset-right)) calc(0.25rem + env(safe-area-inset-bottom)) max(0.25rem, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.nav-brand { display: none; }

/* Tab bar như app: các mục chia đều, icon ở trên, chữ nhỏ ở dưới, mục đang mở đổi màu. */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-width: 0;
  min-height: 54px;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 30px;
  border-radius: 15px;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease);
}

.nav-item:active .nav-icon { transform: scale(0.92); }

.nav-item[aria-current='page'] { color: var(--primary); font-weight: 600; }
.nav-item[aria-current='page'] .nav-icon { background: var(--lavender-pale); }

.nav-label {
  max-width: 100%;
  padding-inline: 0.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:lang(lo) { font-size: 0.75rem; line-height: 1.35; }

/* Màn hình nhập liệu và làm bài trên điện thoại: ẩn thanh điều hướng để tập trung. */
body:has(.form-actions) .bottom-nav, body:has(.lesson-dock) .bottom-nav { display: none; }
body:has(.form-actions) .page--with-nav { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
body:has(.lesson-dock) .page--with-nav { padding-bottom: 0; }

/* Thẻ bài học hôm nay */
.today-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  padding: 0.875rem;
  border-radius: 28px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.today-text { display: grid; flex: 1; gap: 0.25rem; min-width: 0; }
.today-text strong { font-weight: 600; overflow-wrap: anywhere; }
.today-text small { color: var(--muted); }
.today-arrow { flex: none; background: var(--lavender-pale); color: var(--primary); }

.progress { display: block; height: 6px; overflow: hidden; border-radius: 3px; background: rgba(27, 26, 46, 0.1); }
.progress > span { display: block; width: 0; height: 100%; border-radius: 3px; background: var(--primary); transition: width 250ms var(--ease); }

/* Màn hình làm bài */
.lesson-progress { display: grid; gap: 0.375rem; margin-bottom: 0.875rem; font-size: 0.8125rem; }
/* Khu vực ghi âm luôn nằm sát đáy màn hình, kể cả khi nội dung ngắn. */
.page:has(.lesson-dock) { display: flex; flex-direction: column; min-height: 100dvh; }
.lesson-layout { display: flex; flex: 1; flex-direction: column; }
.lesson-content { flex: 1; }
.eyebrow { margin-bottom: 0.5rem; color: var(--primary); font-size: 0.875rem; font-weight: 500; }
.sentence-text { font-size: 1.375rem; font-weight: 500; line-height: 1.35; }
.sentence-card .muted { margin-top: 0.5rem; }

/* Số liệu và báo cáo */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 1.25rem 0 0.625rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; margin: 0 0 1rem; }
.kpi { padding: 0.875rem 1rem; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-sm); }
.kpi dt { color: var(--muted); font-size: 0.8125rem; line-height: 1.3; }
.kpi dd { margin: 0.25rem 0 0; font-size: 1.75rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.report-counts { margin-bottom: 0.5rem; font-size: 0.875rem; }

.report-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 0.625rem; margin-bottom: 1rem; }
.report-filters .button { grid-column: 1 / -1; }
.report-filters select { min-height: 48px; padding-block: 0.5rem; padding-left: 1rem; }

.chart { margin: 0.5rem 0 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-bottom: 0.5rem; font-size: 0.8125rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.375rem; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.swatch.chart-on-time { background: #0f8a66; }
.swatch.chart-late { background: #e0a21b; }
.swatch.chart-missed { background: #c2415a; }
path.chart-on-time { fill: #0f8a66; }
path.chart-late { fill: #e0a21b; }
path.chart-missed { fill: #c2415a; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
/* Biểu đồ thu nhỏ theo màn hình nên trên điện thoại cần tăng cỡ chữ của trục để đọc được. */
@media (max-width: 560px) {
  .chart-axis { font-size: 26px; }
}
.chart-hit { fill: transparent; }
.chart-day:hover .chart-hit { fill: rgba(27, 26, 46, 0.05); }
.chart-table { margin-top: 0.5rem; font-size: 0.875rem; }
.chart-table summary { min-height: 44px; padding-block: 0.625rem; cursor: pointer; font-weight: 500; }
.chart-table .table-wrap { max-height: 280px; overflow-y: auto; box-shadow: none; }

.report-table table { min-width: 680px; }
.report-table td:first-child { min-width: 190px; }
.report-table td .badge { display: inline-block; margin-left: 0.375rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-link { color: var(--primary); font-weight: 500; }

.report-history { display: grid; gap: 0.625rem; }
.history-lesson { margin: 0; padding: 0.875rem 1.125rem; }
.history-lesson summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.625rem; min-height: 44px; cursor: pointer; }
.history-date { color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.history-step { margin-top: 0.875rem; padding-top: 0.875rem; border-top: 1px solid var(--line); }
.history-text { margin-top: 0.5rem; font-weight: 500; }
.history-attempt { margin-top: 0.625rem; padding-left: 0.75rem; border-left: 3px solid var(--lavender); font-size: 0.9375rem; }
.history-attempt .audio-player { margin-top: 0.375rem; }

/* Trang kết quả của sinh viên */
.streak-card { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.875rem; padding: 1.125rem 1.25rem; border-radius: var(--radius-lg); background: var(--amber); color: var(--ink); }
.streak-number { font-size: 3rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.streak-card h2 { margin: 0 0 0.125rem; }
.streak-card p { color: var(--ink-soft); font-size: 0.875rem; }
.day-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 0.5rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }
.day-chip { display: grid; justify-items: center; gap: 0.125rem; padding: 0.5rem 0.125rem; border-radius: 14px; background: #eeedf2; color: var(--ink-soft); }
.day-chip small { font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
.day-chip--done { background: var(--ok-soft); color: var(--ok); }
.day-chip--late { background: var(--warn-soft); color: var(--warn); }
.day-chip--missed { background: var(--danger-soft); color: var(--danger); }

/* Bật thông báo và cài app */
.push-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.625rem; }
.push-head h2 { margin: 0; }
.push-action { width: 100%; margin-top: 0.75rem; }
.push-card [data-push-state] > p + p { margin-top: 0.5rem; }
.install-steps { margin: 0.625rem 0 0; padding-left: 1.25rem; }
.install-steps li + li { margin-top: 0.375rem; }
.push-ok { margin-top: 0.75rem; padding: 0.75rem 1rem; border-radius: 18px; background: var(--ok-soft); color: var(--ok); font-size: 0.9375rem; }
.student-badges { margin-top: 0.25rem; }

.translation-status { margin-top: 0.5rem; }
.translation-note { font-size: 0.875rem; }

/* Gợi ý câu trả lời */
.hints-card h2 { margin-bottom: 0.25rem; }
.hint-slot { margin-top: 0.75rem; }
.hint-button { width: 100%; }
.hint { padding-left: 0.875rem; border-left: 3px solid var(--lavender); }
.hint-text { font-weight: 500; }
.hint .audio-player { margin-top: 0.5rem; }

/* Hàng chờ chấm tay */
.review-link { margin-top: 1rem; }
.review-list { margin-top: 1rem; }
.review-label { margin: 0.875rem 0 0.125rem; font-size: 0.8125rem; }
.review-list .item-text { margin-top: 0; }
.review-transcript { font-size: 1.0625rem; }
.review-hints { margin-top: 0.75rem; }
.review-answers { margin: 0.75rem 0; font-size: 0.9375rem; }
.review-answers summary { min-height: 44px; padding-block: 0.625rem; cursor: pointer; font-weight: 500; }
.review-answers ul { margin: 0; padding-left: 1.25rem; }
.review-button { width: 100%; }

.result-card { margin-bottom: 0.75rem; }
.own-recording { margin-top: 0.875rem; }
.attempts-left { margin-top: 0.625rem; font-size: 0.8125rem; }

.score-row { display: flex; align-items: center; gap: 1rem; }
.score-row h2 { margin: 0; }

.score-ring {
  --score: 0deg;
  --ring: var(--ok);
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: conic-gradient(var(--ring) var(--score), rgba(27, 26, 46, 0.1) 0);
}

.score-ring::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); }
.score-ring strong { position: relative; font-size: 1.625rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-ring--retry { --ring: #c77700; }
.score-ring--lg { width: 112px; height: 112px; margin-bottom: 0.75rem; }
.score-ring--lg strong { font-size: 2.25rem; }

.word-scores { display: flex; flex-wrap: wrap; gap: 0.25rem 0.375rem; margin-top: 1rem; font-size: 1.125rem; font-weight: 500; }
.word--ok { color: var(--ok); }
/* Không chỉ dựa vào màu: từ cần sửa còn được gạch chân. */
.word--weak { color: var(--danger); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.word-legend { margin-top: 0.375rem; font-size: 0.8125rem; }
.transcript { margin-top: 0.75rem; }
.summary-card { display: grid; justify-items: center; text-align: center; }

/* Khu vực ghi âm ở đáy màn hình */
.lesson-dock {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 0.375rem;
  margin: 0 -1rem;
  padding: 2.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: url('/img/wave.svg') bottom / 100% 100% no-repeat;
}

.dock-row { display: grid; justify-items: center; gap: 0.5rem; width: 100%; max-width: 560px; }
.dock-mic { display: grid; justify-items: center; gap: 0.25rem; }
.dock-next { width: 100%; }

/* Đã có kết quả: nút ghi âm nhỏ lại, nút sang câu tiếp nằm cạnh. */
.lesson-dock.has-result { padding-top: 2rem; }
.has-result .dock-row { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.875rem; }
.has-result .dock-row > :only-child, .has-result .dock-row > [hidden] + * { grid-column: 1 / -1; }
.has-result .mic-button { width: 56px; height: 56px; }
.has-result .recorder-label { max-width: 76px; font-size: 0.75rem; line-height: 1.2; text-align: center; }

/* Đang ghi âm thì tập trung vào nút dừng. */
[data-state='recording'] .dock-next, [data-state='sending'] .dock-next { display: none; }
[data-state='recording'] .dock-row, [data-state='sending'] .dock-row { grid-template-columns: 1fr; justify-items: center; }
[data-state='recording'] .recorder-label, [data-state='sending'] .recorder-label { max-width: none; }

.mic-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 120ms var(--ease), background-color 150ms var(--ease);
}

.mic-button:active { transform: scale(0.94); }
.mic-button:disabled { cursor: progress; }
.mic-icon-recording, .mic-icon-sending { display: none; }

[data-state='recording'] .mic-button { background: var(--danger); color: #fff; animation: mic-pulse 1.4s ease-out infinite; }
[data-state='recording'] .mic-icon-idle { display: none; }
[data-state='recording'] .mic-icon-recording { display: block; }
[data-state='sending'] .mic-icon-idle { display: none; }

[data-state='sending'] .mic-icon-sending {
  display: block;
  width: 30px;
  height: 30px;
  border: 3px solid var(--lavender);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(163, 35, 58, 0.45); }
  100% { box-shadow: 0 0 0 22px rgba(163, 35, 58, 0); }
}

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

.recorder-label { color: var(--ink); font-size: 0.875rem; font-weight: 500; }
.recorder-timer { color: var(--ink); font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.recorder-error {
  max-width: 480px;
  padding: 0.5rem 0.875rem;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.875rem;
  text-align: center;
}

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin: 0 -1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(251, 247, 241, 0.96) 70%, rgba(251, 247, 241, 0));
}

/* Bảng xác nhận trượt lên từ đáy */
.sheet {
  width: 100%;
  max-width: 100%;
  margin: auto 0 0;
  padding: 1.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

.sheet[open] { animation: sheet-in 220ms var(--ease); }
.sheet::backdrop { background: rgba(27, 26, 46, 0.42); }
.sheet p { font-size: 1.0625rem; line-height: 1.45; }
.sheet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; margin-top: 1.25rem; }

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

/* Màn hình đăng nhập */
.hero {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 460px;
  margin: 0 auto;
  padding:
    max(0.75rem, env(safe-area-inset-top))
    max(1.25rem, env(safe-area-inset-right))
    calc(1.5rem + env(safe-area-inset-bottom))
    max(1.25rem, env(safe-area-inset-left));
}

.hero-top { display: flex; justify-content: flex-end; margin-bottom: 0.75rem; }
.hero-art { display: block; width: min(68vw, 250px); height: auto; margin: 0.25rem auto 0.5rem; }
.hero-title { font-size: 2.5rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.015em; }
.hero-title:lang(lo) { font-size: 2.25rem; line-height: 1.4; letter-spacing: 0; }
.hero-tagline { margin-top: 0.5rem; color: var(--ink-soft); }
.hero-tagline em { color: var(--accent-green); font-style: normal; font-weight: 500; }

.hero-wave {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 34vh;
  pointer-events: none;
}

/* Thẻ căn giữa cho đổi mật khẩu và trang lỗi */
.solo-card { margin-top: 1.5rem; }

/* Trang tài khoản */
.profile-head { display: grid; justify-items: center; gap: 0.5rem; margin-bottom: 1.5rem; text-align: center; }
.profile-head h2 { overflow-wrap: anywhere; }

.row-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 56px;
  padding: 0.5rem 0.25rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.row-link span { flex: 1; }
.row-link + form .row-link, form + .row-link { border-top: 1px solid var(--line); }

/* Trình phát âm thanh */
.audio-player { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.audio-player .form-error { flex-basis: 100%; margin: 0; }
.audio-player .button { padding-inline: 0.875rem; font-size: 0.875rem; }

/* ------------------------------------------------------------------
   Thích ứng theo màn hình. Mặc định là điện thoại dọc.
   - Điện thoại xoay ngang: màn hình thấp, điều hướng thành cột icon bên trái.
   - iPad dọc: cột điều hướng có icon và chữ nhỏ.
   - iPad ngang, máy tính: thanh bên đầy đủ, nội dung dàn nhiều cột.
   ------------------------------------------------------------------ */

/* Chung cho mọi kiểu có điều hướng bên trái */
@media (min-width: 768px), (orientation: landscape) and (max-height: 520px) {
  .has-nav { padding-left: var(--nav-space); }

  .bottom-nav,
  body:has(.form-actions) .bottom-nav,
  body:has(.lesson-dock) .bottom-nav {
    top: 0.75rem;
    right: auto;
    bottom: 0.75rem;
    left: max(0.75rem, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: var(--nav-width);
    padding: 0.5rem;
    border: 0;
    border-radius: 26px;
    box-shadow: var(--shadow-md);
  }

  /* Trên cột bên trái, mục đang mở là khối tím chứa cả icon và chữ. */
  .nav-item { flex: none; min-height: 0; color: var(--ink); transition: background-color 150ms var(--ease); }
  .nav-item[aria-current='page'] { background: var(--primary); color: var(--primary-ink); }
  .nav-item[aria-current='page'] .nav-icon { background: transparent; }
  .nav-icon { width: auto; height: auto; }

  .page--with-nav, body:has(.form-actions) .page--with-nav {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }

  .form-actions { position: static; margin: 0; padding: 0; background: none; }

  /* Làm bài trên màn hình ngang và rộng: nội dung bên trái, nút ghi âm luôn thấy ở bên phải. */
  .lesson-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr); align-items: start; gap: 1rem; }
  .lesson-dock {
    position: sticky;
    top: 1rem;
    bottom: auto;
    margin: 0;
    padding: 1.5rem 1rem;
    border-radius: var(--radius-lg);
    background: var(--lavender-pale);
    box-shadow: var(--shadow-sm);
  }
  body:has(.lesson-dock) .page--with-nav { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
  .lesson-dock.has-result { padding-top: 1.5rem; }
  .has-result .dock-row { grid-template-columns: 1fr; justify-items: center; }
  .has-result .mic-button { width: 64px; height: 64px; }
  .has-result .recorder-label { max-width: none; }

  .sheet {
    width: min(420px, calc(100% - 2rem));
    margin: auto;
    padding-bottom: 1.25rem;
    border-radius: 28px;
  }

  .app-bar { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .toast { width: calc(100% - 2rem); }
}

/* Điện thoại xoay ngang */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --nav-width: 60px; --nav-space: calc(60px + 1rem + env(safe-area-inset-left)); }

  .bottom-nav, body:has(.form-actions) .bottom-nav {
    justify-content: center;
    gap: 0.25rem;
    overflow-y: auto;
  }

  .nav-item { width: 44px; height: 44px; margin-inline: auto; border-radius: 50%; }

  .nav-item[aria-current='page'] .nav-label,
  .nav-item:not([aria-current='page']) .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  /* Tận dụng chiều ngang vì chiều cao rất ít */
  .page--wide, .page { max-width: 100%; }
  .display { font-size: 1.5rem; }
  .display span { display: inline; }
  .greeting { margin-bottom: 0.75rem; }
  .status-pill { margin: 0.75rem 0; }
  .blob-grid, .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0.75rem; }
  .blob { min-height: 168px; }
  .stat { min-height: 136px; }
  .list--cards, .item-list, .content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 0.625rem; }
  .form-grid:not(.form-grid--always) { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Đăng nhập chia đôi, phần nhập liệu cuộn được khi bàn phím mở */
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    column-gap: 1.5rem;
    align-items: center;
    max-width: 100%;
  }

  .hero-top { grid-column: 2; margin: 0 0 0.25rem; }
  .hero-visual { grid-column: 1; grid-row: 1 / span 2; }
  .hero-panel { grid-column: 2; }
  .hero-art { width: min(32vw, 160px); margin: 0 0 0.25rem; }
  .hero-title { font-size: 1.75rem; }
  .hero-title:lang(lo) { font-size: 1.5rem; }
  .hero .stack { gap: 0.5rem; margin-top: 0; }
  .hero input { min-height: 46px; padding-block: 0.375rem; }
  .hero .cta { min-height: 52px; }
  .hero .cta-arrow { top: 4px; right: 4px; width: 44px; height: 44px; }
  .hero-wave { height: 24vh; }
}

/* Điện thoại nhỏ xoay ngang: 4 cột quá chật cho chữ */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 639px) {
  .blob-grid, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .blob { min-height: 150px; }
  .stat { min-height: 120px; }
}

/* iPad dọc: cột điều hướng có icon và chữ nhỏ */
@media (min-width: 768px) and (min-height: 521px) {
  :root { --nav-width: 92px; --nav-space: calc(92px + 1.5rem); }

  .bottom-nav, body:has(.form-actions) .bottom-nav { gap: 0.375rem; }

  .nav-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin: 0.25rem 0 0.75rem;
    text-decoration: none;
  }

  .nav-brand img { border-radius: 11px; }
  .nav-brand span { display: none; }

  .nav-item, .nav-item[aria-current='page'] {
    flex-direction: column;
    gap: 0.125rem;
    width: 100%;
    height: 64px;
    padding: 0 0.25rem;
    border-radius: 18px;
    font-size: 0.6875rem;
    white-space: normal;
  }

  .nav-label { width: 100%; text-align: center; white-space: normal; line-height: 1.2; overflow-wrap: anywhere; }

  .page { padding-inline: 1.5rem; }
  .app-bar { margin-inline: -1.5rem; padding-inline: 1.5rem; }

  .blob-grid { gap: 1rem; }
  .blob { min-height: 220px; padding: 1.25rem; }
  .stat-grid { gap: 1rem; }
  .stat { min-height: 180px; }
}

/* iPad ngang và máy tính: thanh bên đầy đủ, nội dung nhiều cột */
@media (min-width: 1024px) and (min-height: 521px) {
  :root { --nav-width: 232px; --nav-space: calc(232px + 1.5rem); }

  .bottom-nav, body:has(.form-actions) .bottom-nav { padding: 0.75rem; }

  .nav-brand {
    align-items: center;
    justify-content: flex-start;
    gap: 0.625rem;
    margin: 0.25rem 0.25rem 1.25rem;
    color: var(--ink);
    font-weight: 700;
    line-height: 1.25;
  }

  .nav-brand span { display: inline; }

  .nav-item, .nav-item[aria-current='page'] {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    height: 48px;
    padding: 0 0.875rem;
    border-radius: 16px;
    font-size: 0.9375rem;
    white-space: nowrap;
  }

  .nav-label { width: auto; text-align: left; white-space: nowrap; }
  .nav-item:lang(lo) { font-size: 0.9375rem; }

  .page { max-width: 640px; }
  .page--wide { max-width: 1080px; }
  .toast { max-width: 1080px; }

  .display { font-size: 2.5rem; }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .report-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .report-filters .button { grid-column: auto; }
  .blob-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .list--cards, .item-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 0.75rem; }
  .content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 0.875rem; }
  .content-grid .card { margin-bottom: 0; }
  .content-stack { display: grid; gap: 0.875rem; }
}

/* Đăng nhập trên iPad và máy tính: chia hai phần, form nằm trong thẻ */
@media (min-width: 768px) and (min-height: 521px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: clamp(2rem, 5vw, 5rem);
    align-items: center;
    max-width: 1080px;
    padding-inline: clamp(2rem, 5vw, 4rem);
  }

  .hero-top { grid-column: 1 / -1; }
  .hero-visual { grid-column: 1; }
  .hero-panel {
    grid-column: 2;
    padding: 2rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-md);
  }

  .hero-art { width: min(100%, 400px); margin: 0 0 1.5rem; }
  .hero-title { font-size: clamp(2.5rem, 5vw, 3.75rem); }
  .hero-title:lang(lo) { font-size: clamp(2.25rem, 4.5vw, 3.25rem); }
  .hero-tagline { font-size: 1.125rem; }
  .hero .stack { margin-top: 0; }
  .hero .form-error { margin: 0 0 1rem; }
}

/* Có chuột: thêm trạng thái di chuột, không ảnh hưởng màn hình cảm ứng */
@media (hover: hover) {
  .nav-item:not([aria-current='page']):hover { background: rgba(90, 53, 212, 0.09); }
  .list-row--link:hover { box-shadow: var(--shadow-md); }
  .btn-sm:hover { border-color: rgba(27, 26, 46, 0.3); }
  .button:hover, .cta:hover { filter: brightness(1.08); }
  a.blob:hover { box-shadow: var(--shadow-md); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
