/* In bài tập tô — phiếu tập tô để in (công cụ cho ba mẹ) */
body[data-scene="in-bai"] { --sky1: #8FA3C7; --sky2: #EEF2FA; }

/* ---------- bảng chọn ---------- */
.tp-controls { display: grid; gap: 12px; padding: 14px; border-radius: 24px; background: rgba(255, 255, 255, .93); box-shadow: 0 5px 0 rgba(30, 42, 94, .12); }
.tp-hint { font-size: 1rem; }
.tp-label { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-chip { min-width: 44px; height: 44px; padding: 0 6px; border-radius: 12px; background: #fff; border: 2px solid #C5CEE0;
  font-family: var(--font-letter); font-weight: 700; font-size: 1.35rem; line-height: 1; color: var(--navy); }
.tp-chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.tp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tp-actions .plain { min-height: 46px; padding: 6px 16px; font-size: .95rem; border: 2px solid #C5CEE0; box-shadow: 0 4px 0 rgba(30, 42, 94, .15); }
.tp-print { margin-left: auto; min-height: 60px; }
.tp-print:disabled { opacity: .45; cursor: default; }
.tp-count { font-size: .95rem; opacity: .8; }
.tp-empty { width: 100%; padding: 24px 16px; border-radius: 14px; background: #fff; text-align: center; }

/* ---------- phiếu (xem trước trên thẻ trắng) ---------- */
.tp-sheets { display: grid; gap: 16px; justify-items: center; min-width: 0; }
.tp-sheet { width: 100%; max-width: 760px; min-width: 0; padding: clamp(10px, 3vw, 28px); border-radius: 14px; background: #fff; color: #111;
  box-shadow: 0 6px 18px rgba(30, 42, 94, .18); container-type: inline-size; }
.tp-block { padding: 4px 0 12px; font-size: clamp(30px, 9.5vw, 72px); font-size: min(10.5cqi, 76px); }
.tp-head { display: flex; align-items: center; gap: .6em; font-size: .48em; line-height: 1.25; font-weight: 800; }
.tp-big { font-family: var(--font-letter); font-weight: 700; font-size: 1.35em; }
.tp-word { display: inline-flex; align-items: center; gap: .3em; color: #444; }
.tp-pic { font-size: 1.3em; }
.tp-row { display: flex; align-items: baseline; font-family: var(--font-letter); font-weight: 700; line-height: 1.5; white-space: nowrap; }
.tp-row > span { flex: 1 1 0; min-width: 0; text-align: center; }
.tp-ex { color: #111; }
.tp-g { color: #C6CAD2; }
/* 4 dòng kẻ bám theo chân chữ: đỉnh, giữa (nét đứt), chân chữ (đậm), đáy — vẽ bằng viền để luôn in được */
.tp-lines { flex: none; width: 100%; margin-right: -100%; height: 0; position: relative; }
.tp-lines::before, .tp-lines::after { content: ""; position: absolute; left: 0; right: 0; box-sizing: border-box; pointer-events: none; }
.tp-lines::before { bottom: -.26em; height: 1.02em; border-top: 1px solid #A9B0BE; border-bottom: 1px solid #A9B0BE; }
.tp-lines::after { bottom: 0; height: .52em; border-top: 1px dashed #A9B0BE; border-bottom: 2px solid #6B7385; }
.tp-foot { margin-top: 4px; text-align: center; font-size: 12px; font-weight: 600; color: #777; }

/* ---------- khi in: chỉ còn các phiếu, giấy A4 dọc ---------- */
@page { size: A4 portrait; margin: 12mm; }
@media print {
  body[data-scene="in-bai"] { background: #fff !important; color: #000; padding: 0 !important; min-height: 0; }
  body[data-scene="in-bai"] > :not(main),
  body[data-scene="in-bai"] .scene, body[data-scene="in-bai"] .bar, body[data-scene="in-bai"] #fx,
  body[data-scene="in-bai"] .ask, body[data-scene="in-bai"] .tp-controls { display: none !important; }
  body[data-scene="in-bai"] main { display: block; max-width: none; margin: 0; padding: 0; }
  .tp-sheets { display: block; }
  .tp-sheet { max-width: none; padding: 0; border-radius: 0; box-shadow: none; background: #fff; color: #000; container-type: normal;
    break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tp-sheet:last-child { break-after: auto; page-break-after: auto; }
  .tp-block { font-size: 15mm; padding: 0 0 5mm; break-inside: avoid; page-break-inside: avoid; }
  .tp-word { color: #333; }
  .tp-pic { filter: grayscale(1); }
  .tp-ex { color: #000; }
  .tp-g { color: #BFBFBF; }
  .tp-lines::before { border-color: #999; }
  .tp-lines::after { border-top-color: #999; border-bottom-color: #555; }
  .tp-foot { margin-top: 2mm; font-size: 9pt; color: #666; }
  .tp-empty { display: none; }
}

/* ---------- wave 6: compat (trình duyệt cũ) ---------- */
/* Bản dự phòng cho máy cũ của các luật phía trên (giải thích ở cuối css/style.css); sửa luật gốc thì sửa luôn dòng tương ứng ở đây. */
/* chưa có đơn vị cqw/cqh, @container */
@supports not (width: 1cqw) {
  .tp-sheet { --cq: inline-size; }
  .tp-block { font-size: min(calc(10.5 * var(--cqw)), 76px); }
  @media print { .tp-sheet { --cq: none; contain: none; } }
  @media print { .tp-block { font-size: 15mm; } }
}
