/* Series Toán tư duy lớp 1 đến 5. Độ đậm tối đa 700 (CLAUDE.md). */
.ttd { color: #333; }
.ttd [hidden] { display: none !important; }
.ttd-intro { font-size: 17px; line-height: 1.6; margin: 0 0 10px; }
.ttd-lead { margin: 0 0 10px; color: #555; line-height: 1.6; }
.ttd h2.ttd-h2 { font-size: 21px; color: #1d4e7a; margin: 26px 0 10px; padding-left: 10px; border-left: 4px solid #2f78b7; line-height: 1.35; text-transform: none; }
.ttd-stage { margin: 0 0 6px; color: #7a5a24; font-size: 14px; }

.ttd-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.ttd-sum div { border: 1px solid #cfe0ef; border-radius: 12px; background: #f3f8fc; padding: 10px; text-align: center; }
.ttd-sum b { display: block; font-size: 24px; color: #1d4e7a; line-height: 1.2; }
.ttd-sum span { font-size: 13px; color: #555; }

.ttd-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.ttd-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 18px; border: 1px solid #2f78b7; border-radius: 10px; background: #fff; color: #1d4e7a; font-size: 16px; font-weight: 700; line-height: 1.3; cursor: pointer; }
.ttd-btn:hover, .ttd-btn:focus { background: #e6f0f9; color: #1d4e7a; text-decoration: none; }
.ttd-btn.is-main { background: #2f78b7; color: #fff; }
.ttd-btn.is-main:hover, .ttd-btn.is-main:focus { background: #1d4e7a; color: #fff; }

.ttd-progress { margin: 0 0 12px; }
.ttd-progress p { margin: 0 0 6px; }
.ttd-bar { height: 10px; border-radius: 5px; background: #e4ebf1; overflow: hidden; }
.ttd-bar i { display: block; height: 100%; width: 0; background: #2f78b7; }

.ttd-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.ttd-pills a { display: inline-block; padding: 7px 13px; border: 1px solid #cfe0ef; border-radius: 18px; background: #fff; color: #1d4e7a; line-height: 1.35; }
.ttd-pills a:hover, .ttd-pills a:focus { background: #2f78b7; color: #fff; text-decoration: none; }

.ttd-sheets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ttd-sheet { display: flex; gap: 10px; border: 1px solid #dbe7f1; border-radius: 14px; padding: 12px; background: #fff; color: #444; }
.ttd-sheet:hover, .ttd-sheet:focus { border-color: #2f78b7; color: #444; text-decoration: none; }
.ttd-sheet.is-done { background: #f3faf5; border-color: #8cc4a1; }
.ttd-num { flex: 0 0 42px; height: 42px; line-height: 42px; border-radius: 50%; background: #2f78b7; color: #fff; text-align: center; font-size: 18px; font-weight: 700; }
.ttd-sheet.is-done .ttd-num { background: #1d7a46; }
.ttd-sheet-body { min-width: 0; }
.ttd-sheet-body b { display: block; color: #1d4e7a; font-size: 16px; line-height: 1.35; margin: 0 0 3px; }
.ttd-sheet-body span { display: block; font-size: 14px; line-height: 1.5; }
.ttd-sheet-body em { display: block; font-style: normal; font-size: 13px; color: #1d7a46; }

.ttd-guide, .ttd-parent { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ttd-parent { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ttd-guide > div, .ttd-parent > div { border: 1px solid #dbe7f1; border-radius: 12px; padding: 12px; background: #fff; }
.ttd-guide b, .ttd-parent b { display: block; color: #1d4e7a; margin: 0 0 4px; }
.ttd-guide p, .ttd-parent p { margin: 0; line-height: 1.55; }

.ttd-steps { margin: 0 0 10px; padding-left: 22px; }
.ttd-steps li { list-style: decimal; font-size: 16px; line-height: 1.6; }
.ttd-example { border-left: 4px solid #e0a82e; border-radius: 0 12px 12px 0; background: #fff8e6; padding: 10px 14px; }
.ttd-example b { display: block; line-height: 1.5; }
.ttd-example p { margin: 4px 0 0; line-height: 1.55; }

.ttd-tool { border: 1px solid #cfe0ef; border-radius: 16px; background: #f3f8fc; padding: 6px 16px 10px; }
.ttd h3.ttd-level { font-size: 17px; color: #7a5a24; margin: 14px 0 8px; text-transform: none; }
.ttd-q { border: 1px solid #dbe7f1; border-radius: 12px; background: #fff; padding: 12px; margin: 0 0 10px; }
.ttd-q.is-right { border-color: #1d7a46; background: #f3faf5; }
.ttd-q.is-wrong { border-color: #d98b80; background: #fdf6f5; }
.ttd-q-text { font-size: 18px; line-height: 1.6; margin: 0 0 8px; }
.ttd-q-text b { color: #1d4e7a; }
.ttd-fig { margin: 0 0 10px; }
.ttd-svg { display: block; max-width: 100%; height: auto; font-family: inherit; }
.ttd-options { display: flex; flex-wrap: wrap; gap: 8px; }
.ttd-options label { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; margin: 0; padding: 4px 14px; border: 1px solid #bfd3e5; border-radius: 22px; background: #fff; font-size: 17px; font-weight: 400; line-height: 1.35; cursor: pointer; }
/* CSS chung đẩy ô chọn xuống 4px. */
.ttd-options label input { margin: 0; position: relative; top: 0; }
.ttd-art svg { width: 30px; height: 30px; }
.ttd-fill { margin: 0; display: flex; align-items: center; gap: 8px; }
.ttd-fill label { margin: 0; font-weight: 400; }
.ttd-fill input { width: 88px; height: 44px; margin: 0; top: 0; border: 2px solid #9fb9d0; border-radius: 10px; background: #fff; text-align: center; font-size: 22px; }
/* Lớp 4: ô nhập cho số lớp triệu, phân số tử trên mẫu. */
.ttd-fill input.is-long { width: 160px; max-width: 100%; font-size: 20px; }
.ttd .ttd-frac { display: inline-flex; flex-direction: column; align-items: stretch; vertical-align: middle; margin: 0 2px; font-size: 0.92em; line-height: 1.15; text-align: center; }
.ttd .ttd-frac > span { display: block; margin: 0; padding: 0 3px; font-size: inherit; line-height: inherit; color: inherit; }
/* Dấu gạch chéo ẩn trong vạch ngang để sao chép vẫn ra 3/4. */
.ttd .ttd-frac > .ttd-frac-bar { height: 0; padding: 0; border-top: 1.5px solid currentColor; overflow: hidden; }
.ttd-feedback { margin: 8px 0 0; font-size: 15px; color: #7a5a24; }
.ttd-q.is-right .ttd-feedback { color: #1d5f3a; }
.ttd-q.is-wrong .ttd-feedback { color: #a3362b; }
.ttd-result { padding: 10px 14px; border-radius: 10px; background: #fff8e6; font-size: 18px; line-height: 1.5; }

.ttd-details { border: 1px solid #dbe7f1; border-radius: 12px; margin: 10px 0; background: #fff; }
.ttd-details[open] { background: #f8fbfe; }
.ttd-details summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; cursor: pointer; }
.ttd-details summary::-webkit-details-marker { display: none; }
.ttd-details summary h2, .ttd-details summary h3 { margin: 0; font-size: 16px; font-weight: 700; color: #1d4e7a; line-height: 1.4; text-transform: none; }
.ttd-details summary::after { content: '+'; flex: 0 0 26px; height: 26px; line-height: 24px; border: 1px solid #2f78b7; border-radius: 50%; text-align: center; color: #2f78b7; font-size: 18px; }
.ttd-details[open] summary::after { content: '\2212'; }
.ttd-details > p { margin: 0; padding: 0 14px 12px; line-height: 1.6; }
.ttd-key ol { margin: 0; padding: 0 14px 12px 36px; }
.ttd-key li { list-style: decimal; line-height: 1.55; margin: 0 0 6px; }
.ttd-key li b { margin-right: 8px; color: #1d5f3a; }

.ttd-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; margin: 24px 0 0; }
.ttd-nav > a, .ttd-nav > span { display: block; border: 1px solid #cfe0ef; border-radius: 12px; padding: 10px 12px; background: #fff; color: #1d4e7a; line-height: 1.4; }
.ttd-nav > span { color: #777; background: #fafafa; }
.ttd-nav small { display: block; color: #777; font-size: 12px; }
.ttd-nav .is-next { text-align: right; }
.ttd-nav .is-hub { display: flex; align-items: center; justify-content: center; }
.ttd-print-only { display: none; }

@media (max-width: 767px) {
  .ttd h2.ttd-h2 { font-size: 19px; }
  .ttd-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ttd-sheets, .ttd-guide, .ttd-parent { grid-template-columns: minmax(0, 1fr); }
  .ttd-tool { border: 0; border-radius: 0; background: none; padding: 0; }
  .ttd-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ttd-nav .is-hub { grid-column: 1 / -1; grid-row: 2; }
}

@media print {
  #menu, #footer, footer, .hdbar, #button-back-to-top, .ttd-no-print, .ttd-feedback, .ttd-h2#bai-tap { display: none !important; }
  .page-body { display: block !important; }
  .container { width: auto !important; }
  body, .content-padding { padding: 0 !important; margin: 0 !important; }
  .ttd h1.detail-title { font-size: 20px; }
  /* Chrome làm tròn bề ngang trang khi in: khung sát mép vùng in sẽ mất viền phải nếu không chừa chỗ. */
  .ttd { padding-right: 2px; }
  .ttd-print-only { display: block; }
  .ttd-name-line { margin: 10px 0 12px; }
  .ttd-tool { border: 0; background: none; padding: 0; }
  .ttd h3.ttd-level { margin: 8px 0 4px; break-after: avoid; }
  .ttd-q, .ttd-q.is-right, .ttd-q.is-wrong { border-color: #bbb; background: none; padding: 7px 9px; margin: 0 0 6px; break-inside: avoid; page-break-inside: avoid; }
  .ttd-q-text { font-size: 15px; margin: 0 0 4px; }
  .ttd-fig { margin: 0 0 4px; }
  .ttd-fig .ttd-svg { max-height: 120px; width: auto; max-width: 100%; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ttd-options label { min-height: 30px; font-size: 14px; }
  .ttd-options input { display: none; }
  .ttd-fill input { height: 30px; color: transparent; }
  /* In thu gọn: hình nằm cạnh đề, ô trả lời ngay dưới đề. Hình giữ nguyên cỡ. */
  .ttd.is-compact .ttd-q { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 1fr; padding: 5px 9px; margin: 0 0 5px; }
  .ttd.is-compact .ttd-q-text { grid-column: 1; grid-row: 1; line-height: 1.38; }
  .ttd.is-compact .ttd-fig { grid-column: 2; grid-row: 1 / 3; margin: 0 0 0 10px; }
  .ttd.is-compact .ttd-fill, .ttd.is-compact .ttd-options { grid-column: 1; grid-row: 2; align-self: start; }
  .ttd.is-compact .ttd-options label { min-height: 26px; padding-top: 2px; padding-bottom: 2px; }
  .ttd.is-compact h3.ttd-level { margin: 5px 0 3px; }
  /* Lớp 5: đề dài nên ô trả lời và hình thấp hơn một chút. */
  .ttd.is-dense .ttd-fill input { height: 25px; }
  .ttd.is-dense .ttd-fig .ttd-svg { max-height: 104px; }
  /* Phiếu kín hình: hai cột báo, đọc hết cột trái rồi sang cột phải. Tên phần vẫn đứng trước bài của nó. */
  .ttd.is-columns .ttd-tool { column-count: 2; column-gap: 8px; }
  .ttd.is-columns .ttd-q { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; }
  .ttd.is-columns .ttd-q-text { flex: 0 0 100%; }
  .ttd.is-columns .ttd-fig { flex: 0 0 auto; max-width: 100%; margin: 0 0 3px; }
  .ttd.is-columns .ttd-fill { flex: 1 1 150px; align-self: center; white-space: nowrap; }
  .ttd.is-columns .ttd-options { flex: 1 1 150px; align-self: center; }
  /* Quá nhiều lựa chọn có hình (lớp 1 phiếu 46): bản in chỉ giữ hình để khoanh. */
  .ttd.is-icon-options .ttd-options { gap: 4px; }
  .ttd.is-icon-options .ttd-options label { padding: 1px 4px; }
  .ttd.is-icon-options .ttd-options label > span:not(.ttd-art) { display: none; }
  .ttd-key { display: none; }
  .ttd.is-print-key .ttd-key { display: block; border: 0; break-before: page; page-break-before: always; }
  .ttd-details summary::after { display: none; }
  a[href]::after { content: none !important; }
}
