/* LuyenNoi — design system "Mực & Trúc" + §LuyenNoi Airy Refresh (context/ui-context.md).
   1 light theme (không dark). Option 1 "Tĩnh": trắng chủ đạo, xanh làm điểm nhấn, KHÔNG viền. */
:root {
  /* Colors (ui-context §Colors, light) */
  --page-bg: #E8F2EA;
  --ink: #F2FAF4;
  --ink-2: #FFFFFF;      /* card */
  --ink-3: #E8F5EB;
  --ink-4: #C8E6CC;      /* divider cấu trúc + outline ô nhập (KHÔNG dùng vẽ hình khối) */
  --amber: #1A7A35;      /* primary accent (xanh lá) */
  --amber-dim: rgba(26,122,53,0.10);
  --jade: #2A7050;
  --coral: #e05a5a;      /* error / wrong */
  --text: #1B2B25;
  --text-dim: #5A7268;
  --text-muted: #6B8581;
  --warn-text: #8a6000;
  --success-text: #1f6040;
  --overlay-dark: rgba(0,0,0,0.55);
  /* Elevation (no border on cards; ui-context §Nổi khối) */
  --elevation-1: 0 1px 2px rgba(27,43,37,.05);
  --elevation-2: 0 1px 2px rgba(27,43,37,.05), 0 6px 16px rgba(27,43,37,.08);
  --elevation-3: 0 2px 4px rgba(27,43,37,.06), 0 12px 28px rgba(27,43,37,.12);
  /* Airy Refresh (ui-context §LuyenNoi Airy Refresh) */
  --elevation-soft: 0 2px 8px rgba(27,43,37,.04), 0 12px 32px rgba(27,43,37,.06);
  --page-grad: linear-gradient(180deg, #FFFFFF 0%, #F2FAF4 38%, #E8F2EA 100%);
  --pastel: rgba(26,122,53,.10);
  /* Radius (ui-context §Border Radius) */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Alias cho lib/dict-popup.css (component vendored — đọc token host qua tên riêng) */
  --line: var(--ink-4);
  --muted: var(--text-muted);
  --ink-1: var(--ink);
  --jade-dim: var(--amber-dim);
  --jade-soft: var(--ink-3);
  --e3: var(--elevation-3);
  --r: var(--radius-xl);
  --r-sm: var(--radius-md);
  --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 36px;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  /* Nền gradient + 1 blob mờ góc trên-phải (ui-context §Airy Refresh) */
  background:
    radial-gradient(circle at calc(50% + 190px) -40px, rgba(26,122,53,.10), transparent 70%),
    var(--page-grad);
  background-attachment: fixed;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 12px 16px 32px; }
h1 { font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; margin: 6px 0 5px; }
.sub { color: var(--text-dim); margin: 0 0 20px; font-size: 15px; line-height: 1.65; }

.han { font-family: "Noto Serif SC", "Songti SC", "SimSun", serif; }

.card {
  background: var(--ink-2); border-radius: var(--radius-xl); box-shadow: var(--elevation-soft);
  padding: 24px 20px; margin-bottom: 16px;   /* KHÔNG border (elevation lo depth) */
}
.status { color: var(--text-dim); font-size: 13px; min-height: 20px; }

/* Tiêu đề khu vực — thay đường kẻ ngang cũ */
.sec-h {
  font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 10px; line-height: 1.3;
}

.hanzi {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: 72px; line-height: 1.15; text-align: center; margin: 6px 0 2px; color: var(--text);
}
.pinyin { text-align: center; color: var(--amber); font-size: 17px; font-style: italic; margin: 0; }
.pinyin.hidden { visibility: hidden; }

/* Buttons (ui-context §Airy Refresh: pill, KHÔNG viền, 44px touch, focus ring bắt buộc) */
.btn {
  appearance: none; min-height: 44px; padding: 0 20px; font-size: 13px; font-weight: 700;
  border: 0; border-radius: var(--radius-full); cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit;
  /* default = Secondary */
  background: var(--ink-2); color: var(--text); box-shadow: var(--elevation-1);
}
.btn:hover { box-shadow: var(--elevation-2); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--amber); color: #fff; box-shadow: 0 4px 14px rgba(26,122,53,.26); }
.btn-primary:hover { opacity: .92; box-shadow: 0 6px 18px rgba(26,122,53,.30); }
.btn-primary:active { transform: scale(.97); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--amber); font-weight: 600; padding: 0 12px; }
.btn-ghost:hover { background: var(--amber-dim); box-shadow: none; }
.btn:focus-visible, .tab:focus-visible, .grid-item:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4);
}
.row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; justify-content: center; }
.toolbar { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 14px; }

/* Mức âm micro — 32 cột theo onLevel của recorder.js.
   Lúc nghỉ cột vẫn nằm (cao 6%) chứ không ẩn → bấm Đọc không đội layout. */
.wave { display: flex; align-items: center; justify-content: center; gap: 3px; height: 44px; margin: 16px 0 0; }
.wave i { display: block; width: 4px; border-radius: 99px; background: var(--ink-4);
  height: var(--h, 6%); min-height: 4px; transition: height .09s linear, background .18s; }
.wave.live i { background: var(--amber-dim); }
.wave.live i.hot { background: var(--amber); }
.wave-state { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 8px;
  font-size: 13px; color: var(--text-dim); min-height: 20px; }
.wave-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); flex: 0 0 8px;
  animation: wave-pulse 1.1s ease-in-out infinite; }
.wave-t { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12.5px; }
@keyframes wave-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }
@media (prefers-reduced-motion: reduce) {
  .wave i { transition: none; }
  .wave-dot { animation: none; }
}

/* Banner / alert — bỏ viền, chỉ nền tint */
.banner { background: rgba(180,120,0,.09); border: 0;
  color: var(--warn-text); border-radius: var(--radius-md); padding: 11px 13px;
  font-size: 13px; line-height: 1.55; margin: 14px 0 0; }
.banner.maint { background: rgba(224,90,90,.09); color: #b03a3a; }

/* ── Kết quả ─────────────────────────────────────────────────────────
   1 ĐIỂM THẬT trong vòng tròn. Không thêm vòng/thẻ số thứ hai,
   không sparkline/streak (project-overview §Success Criteria #4). */
.ring-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring-wrap > div:last-child { flex: 1; min-width: 150px; }
.ring { position: relative; width: 118px; height: 118px; flex: 0 0 118px; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .track { fill: none; stroke: var(--ink-3); stroke-width: 9; }
.ring .bar { fill: none; stroke: var(--amber); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 339.3; transition: stroke-dashoffset .5s ease; }
/* Màu vòng + chip theo band — luôn đi kèm icon + nhãn chữ (WCAG 1.4.1) */
.ring.warn .bar { stroke: var(--warn-text); }
.ring.bad .bar { stroke: var(--coral); }
.ring .val { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.ring .num { font-size: 32px; font-weight: 800; line-height: 1; letter-spacing: -.02em;
  color: var(--text); font-variant-numeric: tabular-nums; }
.ring .den { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.band { display: inline-flex; align-items: center; gap: 5px; background: var(--pastel);
  color: var(--amber); font-size: 12px; font-weight: 700; border-radius: var(--radius-full); padding: 5px 12px; }
.band.warn { background: rgba(180,120,0,.12); color: var(--warn-text); }
.band.bad { background: rgba(224,90,90,.12); color: var(--coral); }
.rm-h { font-size: 16px; font-weight: 700; margin: 9px 0 2px; letter-spacing: -.01em; }
.rm-p { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; margin: 0; }

.chars { text-align: center; font-size: 42px;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif; margin: 16px 0 2px; }
.chars .c { position: relative; margin: 0 6px; cursor: pointer; }
.c-green { color: var(--success-text); }
.c-orange { color: var(--warn-text); }
.c-red { color: var(--coral); }
.c .ic { font-size: 14px; vertical-align: super; }

/* Hàng chi tiết từng chữ — KHÔNG số/thanh % (API không trả điểm per-char) */
.stat { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.stat + .stat { border-top: 1px solid rgba(200,230,204,.6); }
.stat .ico { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; background: var(--pastel);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--success-text); }
.stat.warn .ico { background: rgba(180,120,0,.12); color: var(--warn-text); }
.stat.bad .ico { background: rgba(224,90,90,.12); color: var(--coral); }
.stat .body { flex: 1; min-width: 0; }
.stat .t { font-size: 15px; font-weight: 600; line-height: 1.3; }
.stat .t .han { font-size: 19px; }
.stat .s { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

.notes { margin-top: 18px; }
.notes ul { margin: 0; padding-left: 18px; color: var(--text); font-size: 13.5px; line-height: 1.7; }

/* Tap-để-tra + audio mẫu */
.hanzi.tappable { cursor: pointer; }
.hanzi.tappable:hover { color: var(--amber); }
.tap-hint { text-align: center; color: var(--text-muted); font-size: 12px; margin: 9px 0 0; }

/* Popup từ điển (legacy fallback — popup thật ở lib/dict-popup.css) */
.dict-overlay {
  position: fixed; inset: 0; background: var(--overlay-dark); display: none;
  align-items: flex-end; justify-content: center; z-index: 50;
}
.dict-overlay.open { display: flex; }
.dict-card {
  background: var(--ink-2); width: 100%; max-width: 640px; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px; max-height: 80vh; overflow-y: auto; position: relative; box-shadow: var(--elevation-3);
}
@media (min-width: 640px) { .dict-overlay { align-items: center; } .dict-card { border-radius: var(--radius-xl); } }
.dict-close { position: absolute; top: 12px; right: 12px; border: none; background: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.dict-load { color: var(--text-dim); padding: 12px 0; }
.dict-head { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.dict-hz { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 40px; }
.dict-py { color: var(--amber); font-size: 18px; font-style: italic; }
.dict-hv { color: var(--text-dim); font-size: 14px; }
.dict-audio { margin-top: 8px; padding: 6px 14px; }
.dict-sec { border-top: 1px solid var(--ink-4); margin-top: 14px; padding-top: 10px; }
.dict-sec h4 { font-size: 13px; color: var(--text-dim); margin: 0 0 6px; font-weight: 700; }
.dict-ex { margin-bottom: 8px; }
.dx-cn { font-family: "Noto Serif SC", serif; font-size: 16px; }
.dx-py { color: var(--amber); font-size: 13px; font-style: italic; }
.dx-vi { color: var(--text-dim); font-size: 13px; }

/* Luyện đọc trong popup */
.dpop-practice { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dpop-pstate { color: var(--text-dim); font-size: 13px; min-height: 18px; }
.dpop-pnum { font-size: 40px; font-weight: 800; color: var(--amber); text-align: center;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dpop-pscore .chars { font-size: 32px; margin: 6px 0; }
.dpop-pscore:empty { display: none; }
/* Ghi chú nguồn audio (mp3 mẫu / giọng máy / chưa có) — trung thực, không giả vờ đã phát */
.dpop-anote { color: var(--text-dim); font-size: 12px; margin-top: 6px; }
.dpop-anote:empty { display: none; }
/* CTA sang màn luyện đầy đủ: 1 nút to, liệt kê thẳng những gì màn đó chấm */
.dpop-drill {
  appearance: none; border: 0; width: 100%; margin-top: 8px; padding: 13px 15px; cursor: pointer;
  background: var(--ink-2); border-radius: var(--radius-md); box-shadow: var(--elevation-1);
  font-family: inherit; text-align: left; transition: box-shadow .15s;
}
.dpop-drill:hover { box-shadow: var(--elevation-2); }
.dpop-drill:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4); }
.dd-h { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 700; color: var(--amber); }
.dd-go { font-size: 16px; }
.dd-l { display: grid; gap: 3px; margin-top: 8px; }
.dd-i { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.dd-i::before { content: "· "; color: var(--amber); }

/* Nav module (tabs) — pill, KHÔNG viền */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  appearance: none; cursor: pointer; background: var(--ink-2); border: 0; box-shadow: var(--elevation-1);
  border-radius: var(--radius-full); padding: 10px 19px; font-size: 14px; font-weight: 600;
  color: var(--text-dim); font-family: inherit; min-height: 44px; transition: all .15s;
}
.tab:hover { box-shadow: var(--elevation-2); }
.tab.active { background: var(--amber); color: #fff; font-weight: 700;
  box-shadow: 0 4px 14px rgba(26,122,53,.26); }

/* Danh sách chữ — KHÔNG viền, hover chỉ đổi bóng */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; margin-top: 14px; }
.grid-item {
  appearance: none; cursor: pointer; position: relative; min-height: 68px;
  background: var(--ink-2); border: 0; box-shadow: var(--elevation-1);
  border-radius: var(--radius-md); padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif; font-size: 28px; color: var(--text); transition: all .15s;
}
.grid-item:hover { box-shadow: var(--elevation-2); }
.grid-item .gp { font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: 12px; font-style: italic; color: var(--text-dim); }
/* HSK badge (ui-context --radius-xs micro chip) — ghi đủ "HSK 1", không viết tắt "H1" */
.hsk-badge {
  position: absolute; top: 4px; right: 4px; font-family: "Be Vietnam Pro", sans-serif;
  font-size: 10px; font-weight: 700; font-style: normal; line-height: 1; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 5px; background: var(--amber-dim); color: var(--amber);
  white-space: nowrap;
}

/* ---- Trang chủ (F14) — trình bày theo home app gốc, palette Mực & Trúc (xanh) ---- */
/* Section header = tên đậm + phụ đề xám cùng dòng (như 训练营 · 难点突破 của gốc). */
.home-sec { display: flex; align-items: baseline; gap: 10px; margin: 22px 2px 12px; flex-wrap: wrap; }
.hs-t { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.hs-s { font-size: 12.5px; color: var(--text-muted); }

/* Hero Âm khó = card 训练营 tâm điểm gốc: nền xanh-nhạt, watermark CJK mờ, nội dung. */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--ink-3) 0%, rgba(26,122,53,.10) 100%);
  box-shadow: var(--elevation-soft); padding: 20px 18px; margin-top: 4px;
}
/* Hero = nút thật (bàn phím tới được), reset mặc định của <button>. */
.hero { display: block; width: 100%; text-align: left; font-family: inherit; border: 0; cursor: pointer; }
.hero:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4); }
.hero-wm {
  position: absolute; right: -8px; top: -18px; font-family: "Noto Serif SC", serif;
  font-size: 128px; line-height: 1; font-weight: 700; color: rgba(26,122,53,.07);
  pointer-events: none; user-select: none;
}
.hero-body { position: relative; }
.hero-kick { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--amber); }
.hero-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 5px 0 0;
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.hero-title .han, .hero-wm { font-family: "Noto Serif SC", "Songti SC", serif; }
.hero-badge { font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--ink-2); border-radius: var(--radius-full); padding: 3px 10px; }
.hero-desc { font-size: 13.5px; color: var(--text-dim); line-height: 1.55; margin: 8px 0 0; max-width: 34em; }
.hero-feats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.hero-feats .hf { font-size: 12px; font-weight: 700; color: var(--success-text);
  background: var(--ink-2); border-radius: var(--radius-full); padding: 6px 12px; box-shadow: var(--elevation-1); }
.hero-pairs { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
/* Cặp âm = pinyin → Be Vietnam Pro nghiêng (KHÔNG Noto Serif SC — font đó chỉ cho chữ Hán). */
.hero-pairs .hp { font-size: 15px; font-weight: 700; font-style: italic; color: var(--amber);
  background: var(--amber-dim); border-radius: var(--radius-md); padding: 5px 11px; }

/* Card mô tả — icon trái + (tên + 1 dòng mô tả) như sub-card gốc. */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  appearance: none; cursor: pointer; text-align: left; font-family: inherit;
  background: var(--ink-2); border: 0; border-radius: var(--radius-xl); box-shadow: var(--elevation-soft);
  padding: 16px 15px; min-height: 112px; display: flex; flex-direction: column; gap: 11px;
  color: var(--text); transition: transform .12s, box-shadow .12s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--elevation-3); }
.tile:active { transform: scale(.98); }
.tile:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4); }
/* Icon block chứa SVG line-icon riêng — accent xanh (svg dùng currentColor). */
.tile-ic {
  width: 46px; height: 46px; border-radius: var(--radius-md); background: var(--pastel);
  display: flex; align-items: center; justify-content: center; flex: 0 0 46px; color: var(--amber);
}
.tile-ic svg { width: 25px; height: 25px; }
.tile.locked .tile-ic, .tile.soon .tile-ic { color: var(--jade); }
.tile-main { display: flex; flex-direction: column; gap: 3px; }
.tile-lb { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.tile-de { font-size: 12px; color: var(--text-dim); line-height: 1.45; }
.tile-ch {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--ink-3); border-radius: var(--radius-full); padding: 3px 9px; align-self: flex-start;
}
.tile-ch.lock { color: var(--amber); background: var(--amber-dim); }
/* "Sắp có": mờ + không nhấc; giữ shadow phẳng để thấy khối. */
.tile.soon { cursor: default; opacity: .6; }
.tile.soon:hover { transform: none; box-shadow: var(--elevation-1); }
/* "Cần đăng nhập": bấm được (mở modal), nhấn nhẹ ring pastel. */
.tile.locked { box-shadow: var(--elevation-soft), inset 0 0 0 1.5px var(--amber-dim); }

/* ---- F13 Âm khó — danh sách bài (13 cặp âm, 2 tab) ---- */
.snd-list { display: flex; flex-direction: column; gap: 12px; }
.snd-row {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  background: var(--ink-2); border: 0; border-radius: var(--radius-xl); padding: 12px;
  box-shadow: var(--elevation-soft); font-family: inherit; cursor: pointer; transition: box-shadow .15s;
}
.snd-row:hover { box-shadow: var(--elevation-3); }
.snd-row:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4); }
/* Poster thật là PORTRAIT (1280×2276 ≈ 9:16 — JS gán biến --ratio = widthPx/heightPx thật của
   TỪNG bài, không hardcode). Neo theo CHIỀU CAO thay vì chiều rộng: neo theo width (như phác thảo
   ban đầu) đẩy ảnh cao ~150px, đè bẹp hàng danh sách gọn; neo height 96/116px giữ hàng thấp mà
   ảnh vẫn đủ để nhận khung hình — xem task-13-report.md. */
.snd-thumb {
  height: 96px; width: calc(96px * var(--ratio, 0.5625)); flex: 0 0 auto;
  border-radius: var(--radius-md); background: var(--ink-3); object-fit: cover; display: block;
}
/* Chưa trích poster (server: posterReady=false) → ô giữ chỗ đúng khung, không bắn <img> để 404. */
.snd-thumb.ph { display: block; }
.snd-main { flex: 1 1 auto; min-width: 0; }
/* titleVi là PINYIN ("z – zh", "ie – üe") → Be Vietnam Pro nghiêng, không phải font chữ Hán. */
.snd-pair { font-size: 19px; font-weight: 700; font-style: italic; display: block; }
.snd-tag { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; display: block; }
.snd-meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; display: block; }
.snd-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700;
  border-radius: var(--radius-full); padding: 3px 9px; margin-top: 8px;
  background: var(--ink-3); color: var(--text-dim);
}
.snd-badge.done { background: rgba(31,96,64,.12); color: var(--success-text); }
.snd-badge.warn { background: rgba(180,120,0,.12); color: var(--warn-text); }

/* ---- F13 Âm khó — màn bài học 3 bước (Task 14: bước 1 video; Task 15: bước 2/3 + tổng kết) ---- */
.snd-steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 14px; }
.snd-steps li { flex: 1; font-size: 12px; font-weight: 700; color: var(--text-dim);
  background: var(--ink-2); border-radius: var(--radius-full); padding: 8px 10px; text-align: center;
  box-shadow: var(--elevation-1); }
.snd-steps li[aria-current="step"] { background: var(--amber); color: #fff; }
/* Bước đã qua = nút quay lại (li chỉ còn là ô chứa → nhả hết bề mặt cho nút, không 2 lớp nền). */
.snd-steps li.done { background: none; box-shadow: none; padding: 0; }
.snd-stepbtn { appearance: none; border: 0; cursor: pointer; font-family: inherit; width: 100%;
  font-size: 12px; font-weight: 700; color: var(--text-dim); background: var(--ink-2);
  border-radius: var(--radius-full); padding: 8px 10px; box-shadow: var(--elevation-1); }
.snd-stepbtn:hover { color: var(--text); box-shadow: var(--elevation-3); }
/* Vòng focus BẮT BUỘC: li[aria-current] chỉ nhận focus theo lệnh (focusStepHeading) nên dùng
   :focus — có báo cho trình đọc màn hình mà người dùng bàn phím sáng mắt không thấy gì là hỏng. */
.snd-steps li:focus, .snd-stepbtn:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4);
}
/* Video PORTRAIT thật (1280×2276 hôm nay) — aspect-ratio lấy từ widthPx/heightPx của TỪNG bài
   (xem videoHtml() trong sounds.js), không hardcode 9/16: bản quay lại sẽ đổi tỉ lệ.
   width:auto + max-width/max-height (KHÔNG width:100%): đo bằng headless thấy width:100% cùng
   max-height:62vh clamp riêng từng trục — khi 62vh nhỏ hơn chiều cao suy ra từ width, hộp bị lệch
   tỉ lệ thật (đo được ratio .608 thay vì .562 ở viewport 390×844) và <video> (object-fit mặc định
   fill) kéo méo hình. auto+max cho trình duyệt tự chọn trục bị giới hạn, giữ đúng aspect-ratio. */
.snd-video { width: auto; max-width: 100%; max-height: 62vh; border-radius: var(--radius-xl);
  background: var(--ink-3); display: block; margin: 0 auto; }
.snd-novid { border-radius: var(--radius-xl); background: var(--ink-3); color: var(--text-dim);
  padding: 28px 16px; text-align: center; font-size: 13.5px; }
.snd-tips { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .snd-tips { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
.snd-tip { background: var(--ink-3); border-radius: var(--radius-md); padding: 10px 12px; }
/* Nhãn âm ("z", "üe") = pinyin → Be Vietnam Pro nghiêng, không dùng font chữ Hán. */
.snd-tip b { font-size: 17px; font-style: italic; display: block; margin-bottom: 4px; }
/* hookVi — câu dẫn "vì sao phải quan tâm" của từng bài (1 đoạn, nằm ngoài card). */
.snd-hook { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0 0 14px; }
.snd-ul { margin: 6px 0 0; padding-left: 18px; }
.snd-ul li { font-size: 13.5px; line-height: 1.6; margin-bottom: 4px; }
/* Tổng kết bước 3 (Task 15) — mỗi chữ 1 pill; màu LUÔN kèm icon (✓/△/✗), không truyền tin chỉ
   bằng màu (WCAG 1.4.1) — icon do sounds.js chèn qua A.iconFor(). */
.snd-sum { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.snd-word { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 16px;
  background: var(--ink-3); border-radius: var(--radius-full); padding: 5px 12px; }
.snd-word.warn { background: rgba(180,120,0,.12); color: var(--warn-text); }
.snd-word.bad { background: rgba(224,90,90,.10); color: var(--coral); }
/* Ghi chú "n từ chấm hỏng" — nói rõ vì sao mẫu số nhỏ hơn tổng số từ. */
.snd-note { font-size: 12.5px; color: var(--warn-text); margin: 10px 0 0; }
/* Kết luận của LƯỢT vừa rồi. Màu luôn đi kèm icon (✓ / △) do sounds.js chèn — WCAG 1.4.1.
   Không kết luận được (chưa đủ từ) = không màu, chỉ chữ. */
.snd-verdict { font-size: 15px; font-weight: 700; margin-top: 10px; }
.snd-verdict.ok { color: var(--success-text); }
.snd-verdict.warn { color: var(--warn-text); }

/* ---- App-shell: topbar + bottom nav + account sheet (đồng bộ mọi màn) ---- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  max-width: 680px; margin: 0 auto; padding: 10px 16px; min-height: 56px;
  background: rgba(242,250,244,.82); backdrop-filter: saturate(1.3) blur(10px);
}
/* Wordmark: ấn triện 聲 (Noto Serif SC) + "Luyện Nói" (Be Vietnam Pro 800) */
.tb-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; cursor: pointer; }
.tb-seal { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; background: var(--amber); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 21px; font-weight: 700; line-height: 1;
  box-shadow: 0 2px 8px rgba(26,122,53,.28), inset 0 1px 0 rgba(255,255,255,.25); }
.tb-word { font-size: 19px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.tb-brand:focus-visible { outline: none; border-radius: 10px; box-shadow: 0 0 0 3px rgba(26,122,53,.35); }

.tb-nav { display: none; margin-left: auto; gap: 6px; }   /* mobile: ẩn — dùng bottom nav */
/* Header-nav item — CHỮ + nét mực active (không pill tô đặc). Nét mực = chữ ký thị giác Mực & Trúc */
.tb-navitem { appearance: none; border: 0; background: none; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 700; color: var(--text-dim); padding: 9px 8px 11px; position: relative;
  transition: color .15s; }
.tb-navitem::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: 3px;
  width: 0; height: 3px; border-radius: 99px; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--amber) 22%, var(--amber) 78%, transparent);
  transition: width .18s ease, opacity .18s ease; }
.tb-navitem:hover { color: var(--text); }
.tb-navitem:hover::after { width: 16px; opacity: .5; }
.tb-navitem.active { color: var(--text); }
.tb-navitem.active::after { width: calc(100% - 6px); opacity: 1; }
.tb-navitem:focus-visible { outline: none; border-radius: 8px; box-shadow: 0 0 0 3px rgba(26,122,53,.35); }
.tb-back {
  appearance: none; border: 0; background: var(--ink-2); box-shadow: var(--elevation-1);
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: var(--radius-full); cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--text); transition: box-shadow .12s;
}
.tb-back svg { width: 20px; height: 20px; }
.tb-back:hover { box-shadow: var(--elevation-2); }
.tb-back:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4); }
.tb-lead { width: 38px; height: 38px; flex: 0 0 38px; }   /* giữ chỗ → tiêu đề căn cùng vị trí mọi màn */
.tb-title { font-size: 18px; font-weight: 800; letter-spacing: -.01em; margin: 0; }

.bottomnav {
  position: sticky; bottom: 0; z-index: 40;
  display: flex; gap: 4px; max-width: 680px; margin: 0 auto;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  box-shadow: 0 -1px 0 rgba(200,230,204,.7), 0 -8px 24px rgba(27,43,37,.05);
}
.bn-item {
  appearance: none; border: 0; background: none; cursor: pointer; flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 10px;
  color: var(--text-muted); font-family: inherit; font-size: 11px; font-weight: 700; border-radius: var(--radius-md);
}
.bn-ic { display: flex; }
.bn-ic svg { width: 23px; height: 23px; }
.bn-item.active { color: var(--amber); }
/* nét mực dưới chân mục active — cùng chữ ký với header */
.bn-item.active::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: 2px;
  width: 22px; height: 3px; border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--amber) 22%, var(--amber) 78%, transparent); }
.bn-item:hover { color: var(--text-dim); }
.bn-item.active:hover { color: var(--amber); }
.bn-item:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(26,122,53,.35); }

/* ======== Desktop (≥900px): dáng WEB — header trên cùng + nav phải, nội dung rộng ======== */
@media (min-width: 900px) {
  /* Khung fluid: bám bề ngang cửa sổ, trần 1440. Bề rộng đọc được lo ở CẤP PHẦN TỬ
     (.auth-in, .rm-p) — KHÔNG kẹp #root, vì kẹp cả trang là thứ làm web trông như mobile. */
  .wrap { max-width: none; width: min(1440px, 100% - 96px); padding: 20px 0 48px; }
  .topbar { max-width: none; width: min(1440px, 100% - 96px); padding: 12px 0; min-height: 66px; gap: 16px;
    box-shadow: 0 1px 0 rgba(200,230,204,.6); }
  .tb-title { font-size: 21px; }
  .bottomnav { display: none; }                      /* desktop: nav ở header, không bottom */
  .tb-nav { display: flex; align-items: center; }    /* nav chữ + nét mực (.tb-navitem) */

  /* Âm khó ở khung rộng — KHÔNG kẹp #root (kẹp cả trang đã bỏ ở 989ffa4). Đúng idiom side A:
     measure áp ở CẤP PHẦN TỬ cho phần chữ, còn danh sách thì trải thành cột như .tiles thay vì
     kéo một hàng ngang 1344px. */
  .snd-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
  .snd-steps { max-width: 560px; }
  .snd-hook, .snd-ul, .snd-novid, .snd-sum, .snd-note, .snd-verdict { max-width: 62ch; }
  .snd-video { max-height: 70vh; }
  /* Lưới nội dung: nhiều cột, lấp bề ngang */
  .tiles { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
  .prem-grid { grid-template-columns: repeat(4, 1fr); }
  .hero { padding: 30px 30px; }
  .hero-wm { font-size: 168px; top: -26px; right: 6px; }
  .hero-title { font-size: 26px; }
  .home-sub { font-size: 15px; }
  /* Hàng rộng hơn ở desktop → poster lớn hơn theo cùng tỉ lệ (giữ neo theo height). */
  .snd-thumb { height: 116px; width: calc(116px * var(--ratio, 0.5625)); }
}
@media (min-width: 900px) and (max-width: 1160px) {
  .prem-grid { grid-template-columns: repeat(2, 1fr); }   /* trung gian: 2 cột giá */
}

/* ======== ≥1024: hai cột — rail (danh sách) + pane (luyện / từ điển) ======== */
@media (min-width: 1024px) {
  body[data-view="list"] #root, body[data-view="drill"] #root {
    display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 24px; align-items: start;
  }
  /* .rail dính chỗ; CHỈ .rail-list cuộn → tiêu đề cột không mờ theo mask */
  .rail { display: flex; flex-direction: column; position: sticky; top: 86px; max-height: calc(100vh - 110px); }
  .rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 10px; }
  .rail-head .sec-h { margin: 0; }
  .rail-cnt { font-size: 12px; color: var(--text-muted); }
  .rail-list {
    flex: 1; min-height: 0; overflow-y: auto; padding-right: 6px;
    display: flex; flex-direction: column; gap: 6px;
    scrollbar-width: thin; scrollbar-color: var(--ink-4) transparent;
    mask-image: linear-gradient(180deg, #000 calc(100% - 26px), transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 26px), transparent 100%);
  }
  .rail-list::-webkit-scrollbar { width: 6px; }
  .rail-list::-webkit-scrollbar-track { background: transparent; }
  .rail-list::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 99px; }
  .rail-list:hover::-webkit-scrollbar-thumb { background: rgba(26,122,53,.35); }
}

/* Hàng chữ trong rail — KHÔNG viền; active = nét mực DỌC (cùng chữ ký với nav) */
.rail-grp {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline;
  padding: 7px 12px 7px 2px; margin-top: 8px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--amber);
  background: linear-gradient(180deg, var(--ink) 84%, rgba(242,250,244,0)); backdrop-filter: blur(8px);
}
.rail-grp:first-child { margin-top: 0; }
.rail-item {
  appearance: none; border: 0; cursor: pointer; font-family: inherit; position: relative; width: 100%;
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 9px 12px 9px 14px;
  background: var(--ink-2); box-shadow: var(--elevation-1); border-radius: var(--radius-md);
  color: var(--text); transition: box-shadow .12s, background .12s;
}
.rail-item:hover { box-shadow: var(--elevation-2); }
.rail-item:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4); }
.rail-hz { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 32px; line-height: 1.1; flex: 0 0 auto; min-width: 38px; }
.rail-py { flex: 1; min-width: 0; font-size: 13.5px; font-style: italic; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-hsk { font-size: 10px; font-weight: 700; letter-spacing: .02em; padding: 2px 7px; border-radius: 5px;
  background: var(--amber-dim); color: var(--amber); flex: 0 0 auto; white-space: nowrap; }
.rail-item.active { background: var(--ink-3); }
.rail-item.active::before {
  content: ""; position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 24px; border-radius: 99px;
  background: linear-gradient(180deg, transparent, var(--amber) 22%, var(--amber) 78%, transparent);
}
.rail-item.active .rail-py { color: var(--amber); }

/* Home intro (dời từ h1 tĩnh cũ) + toolbar căn phải khi chỉ có 1 nút */
.home-sub { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin: 2px 2px 6px; }
.toolbar-end { justify-content: flex-end; }

/* Màn Tài khoản (view) — identity + đổi/đặt mật khẩu + logout */
.card.acct-id { display: flex; align-items: center; gap: 16px; }
.acct-av {
  width: 60px; height: 60px; flex: 0 0 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--amber); color: #fff; font-size: 24px; font-weight: 800;
}
.acct-idbody { min-width: 0; }
.acct-nm { font-size: 19px; font-weight: 800; line-height: 1.2; text-transform: capitalize; }
.acct-em { font-size: 13px; color: var(--text-dim); word-break: break-all; }
.acct-pwstate { margin-bottom: 2px; }
.pw-badge { display: inline-flex; align-items: center; border-radius: var(--radius-full);
  padding: 4px 12px; font-size: 12px; font-weight: 700; }
.pw-badge.on { color: var(--amber); background: var(--amber-dim); }
.pw-badge.neu { color: var(--text-dim); background: var(--ink-3); }
.auth-err.ok { color: var(--success-text); }
.ac-logout { width: 100%; color: var(--coral); }
.ac-logout:hover { background: rgba(224,90,90,.08); }
#ac-pwbtn { width: 100%; margin-top: 4px; }

/* Card gói (Tài khoản) */
.acct-plan { display: flex; flex-direction: column; gap: 4px; }
.acct-planrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; }
.acct-plk { font-size: 13px; color: var(--text-dim); }
.acct-plv { font-size: 14px; font-weight: 600; }
.plan-badge { display: inline-flex; align-items: center; border-radius: var(--radius-full);
  padding: 4px 12px; font-size: 12px; font-weight: 700; }
.plan-badge.free { color: var(--text-dim); background: var(--ink-3); }
.plan-badge.prem { color: var(--amber); background: var(--amber-dim); }
.plan-badge.exp { color: var(--coral); background: rgba(224,90,90,.12); }
.acct-upg { width: 100%; margin-top: 8px; color: var(--amber); }
.acct-upg:hover { background: var(--amber-dim); }

/* ---- Màn Premium (scaffold — bám sát premium.html HskMock, palette Mực & Trúc) ---- */
.prem-head { margin: 2px 2px 4px; }
.prem-eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--amber); }
.prem-h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 5px 0 5px; }
.prem-lead { font-size: 14px; color: var(--text-dim); line-height: 1.55; margin: 0; }
.banner.prem-banner { background: var(--amber-dim); color: var(--success-text); margin: 16px 0 18px; }
.prem-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prem-card {
  position: relative; background: var(--ink-2); border-radius: var(--radius-xl); box-shadow: var(--elevation-soft);
  padding: 20px 16px 16px; display: flex; flex-direction: column; gap: 6px;
}
.prem-card.hero { box-shadow: var(--elevation-2), 0 0 0 2px var(--amber); }
.prem-card.value { box-shadow: var(--elevation-2), inset 0 0 0 1.5px var(--amber-dim); }
.prem-ribbon { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 10px; font-weight: 800; letter-spacing: .03em; padding: 4px 11px; border-radius: var(--radius-full);
  text-transform: uppercase; color: #fff; }
.prem-ribbon.hot { background: var(--amber); }
.prem-ribbon.save { background: var(--jade); }
.prem-dur { font-size: 14px; font-weight: 800; }
.prem-dur span { display: block; font-weight: 500; color: var(--text-dim); font-size: 11px; margin-top: 3px; min-height: 28px; line-height: 1.3; }
.prem-price { display: flex; align-items: baseline; gap: 3px; margin: 8px 0 0; }
.pp-big { font-size: 34px; font-weight: 700; line-height: 1; color: var(--text); }
.pp-u { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.prem-tot { font-size: 12px; color: var(--text-dim); }
.prem-tot b { color: var(--text); font-weight: 700; }
.prem-savechip { align-self: flex-start; font-size: 11px; font-weight: 700; color: var(--success-text);
  background: var(--amber-dim); border-radius: var(--radius-sm); padding: 2px 8px; margin-top: 2px; }
.prem-savechip.ph { visibility: hidden; }
.prem-buy { width: 100%; margin-top: 10px; }
.prem-skel { height: 190px; border-radius: var(--radius-xl); background: var(--ink-3); animation: prem-pulse 1.2s infinite; }
@keyframes prem-pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
@media (prefers-reduced-motion: reduce) { .prem-skel { animation: none; } }

/* ---- Account bar (F08 — cũ, không còn dùng sau app-shell) ---- */
.account-bar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 4px; }
.acc-email { color: var(--text-dim); font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-btn { min-height: 36px; padding: 0 14px; }

/* Gate B CTA (trong danh sách) */
.banner.gate {
  background: var(--amber-dim); color: var(--success-text);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.banner.gate .btn-primary { min-height: 36px; padding: 0 16px; }

/* ---- Auth modal (F08) ---- */
.auth-overlay {
  position: fixed; inset: 0; background: var(--overlay-dark); display: none;
  align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
.auth-overlay.open { display: flex; }
.auth-card {
  background: var(--ink-2); width: 100%; max-width: 380px; border-radius: var(--radius-xl);
  box-shadow: var(--elevation-3); padding: 26px 22px; position: relative;
  display: flex; flex-direction: column; gap: 12px;
}
.auth-close { position: absolute; top: 12px; right: 12px; border: none; background: none; font-size: 16px; cursor: pointer; color: var(--text-muted); }
.auth-title { font-size: 20px; font-weight: 800; letter-spacing: -.015em; margin: 0 4px 0 0; }
.auth-google { width: 100%; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--ink-4); }
.auth-lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); font-weight: 700; }
/* Ô nhập GIỮ viền — outline form field là ngoại lệ được phép (ui-context §Airy Refresh) */
.auth-in {
  appearance: none; font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--ink); border: 1px solid var(--ink-4); border-radius: var(--radius-md);
  padding: 10px 12px; min-height: 44px;
}
.auth-in:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px rgba(26,122,53,.4); border-color: var(--amber); }
/* Measure đọc được áp ở CẤP PHẦN TỬ, không kẹp cả trang (spec 2026-07-22 §7) */
.auth-in { max-width: 42ch; }
.rm-p { max-width: 34em; }
.auth-hint { color: var(--text-muted); font-size: 12px; margin-top: -4px; }
.auth-err { color: var(--coral); font-size: 13px; min-height: 18px; }
.auth-submit { width: 100%; }
.auth-switch { width: 100%; }
