/* «សៀវភៅ DIGITAL» — book chapters converted from LaTeX (tools/book_tex2html.py).
   Looks like the printed book (form.cls): chapter banner, numbered section bars, coloured box tabs,
   magenta/blue circle labels, Moul titles on a Siemreap body. Builds on lesson.css (layout). */
.db-paper {
  --col1: #0c6662; --cyan: #3fc8f4; --mag: #e6007e; --blue-c: #13a8e6;
  --kt-title: "Moul", "Khmer OS Muol Light", "Kantumruy Pro", serif;
  --kt-body: "Siemreap", "Khmer OS Siemreap", "Times New Roman", Georgia, serif;
  position: relative; padding: 0 !important; overflow: hidden; background: #fff; color: #1b1b1b;
  border-right: 14px solid var(--cyan); font-family: var(--kt-body); font-size: 16.5px;
}
.db-hero { padding: 18px 0 10px; }
.db-hero h1 { font-family: "Moul", serif; font-weight: 400; }
.kb-page { padding: 22px 34px 10px; }
.db-paper p { margin: 9px 0; line-height: 1.95; }
.db-paper ul { margin: 6px 0 8px 1.3em; line-height: 1.9; }
.db-paper ul > li { margin: 4px 0; }
.db-paper b, .db-paper strong { font-weight: 700; }

/* chapter banner */
.kb-banner { position: relative; aspect-ratio: 1024 / 308; background: #2b2b2b center / 100% 100% no-repeat; }
.kb-ch { position: absolute; left: 3.4%; bottom: 7%; max-width: 72%; margin: 0; color: #fff; font: 400 clamp(26px, 5.2vw, 52px)/1.4 var(--kt-title);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, .7); }
.kb-ch::after { display: none; }
.kb-badge { position: absolute; right: 6.5%; top: 18%; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.kb-badge .lb { color: #fff; font: 400 clamp(15px, 2.6vw, 28px)/1.4 var(--kt-title); text-shadow: 2px 2px 0 rgba(0, 0, 0, .7); }
.kb-badge .ring { display: grid; place-items: center; width: clamp(48px, 10vw, 104px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle closest-side, #fff 0 54%, #ffe600 55% 70%, #1a1ab8 71% 88%, #b3171b 89% 100%, transparent 100%); box-shadow: 3px 3px 6px rgba(0, 0, 0, .5); }
.kb-badge b { color: #1717c4; font: 400 clamp(18px, 3.8vw, 40px)/1 var(--kt-title); -webkit-text-stroke: 1px #fff; }

/* section bar «១ title» and subsection «១.១ title» with the books picture */
.db-paper h2.kb-sec { border-left: 0; display: flex; align-items: center; gap: 16px; margin: 34px 0 14px; padding: 6px 10px; background: linear-gradient(90deg, #f3f3f3, #fafafa);
  color: var(--col1); font: 400 clamp(19px, 2.6vw, 25px)/1.7 var(--kt-title); }
.kb-sec .hn { flex: none; display: grid; place-items: center; min-width: 42px; height: 36px; padding: 0 8px; border-radius: 6px;
  background: var(--col1); color: #fff; font-size: .82em; }
.db-paper h3.kb-sub { display: flex; align-items: flex-end; gap: 14px; margin: 28px 0 12px; padding: 0 4px 6px; border-bottom: 7px solid #8b5a2b;
  color: #1f1f1f; font: 400 clamp(17px, 2.2vw, 21px)/1.7 var(--kt-title); }
.kb-sub .hn { color: #b3171b; }
.kb-sub .tt { flex: 1; }
.kb-books { flex: none; width: 72px; height: 36px; margin-bottom: -2px; }

/* boxes with a coloured tab (definition, general, practice, history, formula) */
.kb { position: relative; margin: 22px 0 22px; padding: 0 0 10px; background: #f5f5f5; box-shadow: 4px 4px 0 #c9c9c9; text-align: left; }
.kb-tab { position: relative; display: inline-block; margin: 0; padding: 5px 34px 5px 22px; color: #fff;
  font: 400 15.5px/1.75 var(--kt-title); clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 50%, calc(100% - 22px) 100%, 0 100%); }
.kb-b { padding: 0 18px 0 28px; }
.kb-b:first-child { padding-top: 10px; }
.kb-tab-w { position: relative; display: inline-block; margin: 0 0 12px -8px; }
.kb-tab-w::after { content: ""; position: absolute; left: 0; top: 100%; border-top: 9px solid var(--fold, #6a2a6f); border-left: 9px solid transparent; transform: scaleX(-1); }
.kb-def { --fold: #7a1d73; } .kb-gen { --fold: #8a3b00; } .kb-pro { --fold: #1c5f86; } .kb-frm { --fold: #1b4d20; } .kb-his { --fold: #005b7f; }
.kb-b > :first-child { margin-top: 2px; }
.kb-def .kb-tab { background: linear-gradient(90deg, #ff4fd8, #8e1fa6); }
.kb-gen .kb-tab { background: linear-gradient(90deg, #ff9800, #ff2a00); }
.kb-pro .kb-tab { background: linear-gradient(90deg, #00e5ff, #3a1fd6); }
.kb-frm .kb-tab { background: linear-gradient(90deg, #43a047, #1b5e20); }
.kb-his { background: #e3f6fd; border: 1px solid #d0d0d0; box-shadow: none; }
.kb-his .kb-tab { background: #00aeef; font-size: 17px; }

/* worked example: red pill «លំហាត់គំរូ» + number in a ring, body on the page */
.kb-ex { margin: 26px 0 18px; text-align: left; }
.kb-ex-h { display: flex; align-items: center; gap: 0; margin-bottom: 6px; }
.kb-ex-h .kb-pill { display: inline-block; padding: 3px 42px 5px 18px; line-height: 2.2 !important; border-radius: 999px; background: #c40c0c; color: #fff;
  font: 400 17px/1.75 var(--kt-title); }
.kb-ex-h .num { display: grid; place-items: center; width: 50px; height: 50px; margin-left: -22px; border: 3px solid #c40c0c; border-radius: 50%;
  background: #fff; color: #1b1b1b; font: 400 17px/1 var(--kt-title); }
.kb-ex-h .ttl { margin-left: 12px; color: #c40c0c; font-weight: 700; }
.db-paper .ans-lb { color: #c40c0c; font-family: var(--kt-title); font-weight: 400; }
.kb-ex-inline { margin-top: 22px; margin-bottom: 8px; }
.db-paper .lb { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 50%;
  color: #fff; font: 700 13.5px/1 var(--kt-body); vertical-align: middle; margin-right: 4px; }
.db-paper .lb.ca { background: var(--mag); }
.db-paper .lb.cn { background: var(--blue-c); }

/* lists: magenta circle letters (ក ខ គ) and blue circle numbers (១ ២ ៣), like the book */
.db-paper ol.lst { list-style: none; margin: 8px 0; padding: 0; }
.db-paper ol.lst > li { display: flex; gap: 10px; align-items: baseline; margin: 7px 0; break-inside: avoid; }
.db-paper ol.lst .lb { flex: none; display: inline-grid; place-items: center; min-width: 25px; height: 25px; padding: 0 3px; border-radius: 50%;
  color: #fff; font: 700 13.5px/1 var(--kt-body); transform: translateY(2px); }
.db-paper ol.lst .lb.ca { background: var(--mag); }
.db-paper ol.lst .lb.cn { background: var(--blue-c); }
.db-paper ol.lst .li-b { min-width: 0; flex: 1; }
.db-paper ol.lst .li-b > p:first-child { margin-top: 0; }
.db-paper ol.lst.cols2 { column-count: 2; column-gap: 28px; display: block; }
.db-paper ol.lst.cols3 { column-count: 3; column-gap: 28px; display: block; }
.db-paper ol.lst.cols4 { column-count: 4; column-gap: 28px; display: block; }
.db-paper .cols { column-gap: 28px; }
.db-paper .cols2 { column-count: 2; } .db-paper .cols3 { column-count: 3; } .db-paper .cols4 { column-count: 4; }
.db-paper .cols > * { break-inside: avoid; }

/* figures, tables, maths */
.db-paper .ctr { text-align: center; }
.db-paper figure.tikz { margin: 14px auto; text-align: center; }
.db-paper figure.tikz img { display: inline-block; max-width: 100%; height: auto; background: #fff; }
.db-paper .fig-miss { margin: 10px 0; color: #999; font-size: 14px; text-align: center; }
.db-paper .fbx { display: inline-block; padding: 1px 8px; border: 1.5px solid #333; }
.db-paper .tbl { margin: 12px 0; overflow-x: auto; }
.db-paper .tbl table { border-collapse: collapse; margin: 0 auto; }
.db-paper .tbl td { padding: 5px 12px; border: 1px solid #555; text-align: center; }
.db-paper .tbl tr:first-child td { background: #c5ddd9; font-weight: 700; }
.db-paper .tbl.tbl-box table { border: 1.5px solid var(--col1); }
.db-paper .tbl.tbl-box td { border: 0; }
.db-paper .tbl.tbl-box tr.th td { border-bottom: 1px solid #9cc7c3; }
.db-paper .tbl.tbl-plain.tbl-wide table, .db-paper .tbl.tbl-box.tbl-wide table { width: 100%; }
.db-paper .tbl.tbl-plain td { border: 0; background: transparent !important; padding: 5px 16px 5px 0; vertical-align: top; font-weight: 400; }
.db-paper .tbl.tbl-plain tr.hl td { border-top: 1.5px solid #333; padding-top: 7px; }
.db-paper .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.db-paper .katex { font-size: 1.08em; }

/* solutions part */
.db-paper .sol-h { margin-top: 56px; padding: 8px 14px; background: var(--col1); color: #fff; font: 400 24px/1.7 var(--kt-title); }
.db-paper h3.sol-t, .db-paper h4.sol-t { margin: 22px 0 8px; color: var(--col1); font: 400 18px/1.7 var(--kt-title); }
.db-paper .bx-sol-s { margin: 12px 0; padding: 10px 16px 6px; border-radius: 0; background: #fff; border: 1px solid #d6e6e4; border-left: 4px solid var(--col1); box-shadow: none; }
.db-paper .bx-sol-s .bx-h b { color: var(--col1); font-family: var(--kt-title); font-weight: 400; }

/* page footer bar «រៀបរៀងដោយ» and prev / next */
.kb-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding: 10px 34px; background: var(--cyan); color: #fff; font: 15px/1.6 var(--kt-body); }
.db-pn { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; flex-wrap: wrap; }
.db-all { display: block; margin-top: 10px; padding: 0 6px; font-weight: 700; }

/* book index: cover + info, then the contents (មាតិកា) as chapter cards */
.ls-layout.db-one { grid-template-columns: minmax(0, 1fr); max-width: 1040px; margin: 0 auto; }
.kb-intro { display: grid; grid-template-columns: minmax(200px, 330px) 1fr; gap: 34px; align-items: center; margin: 8px 0 34px; }
.kb-cov { width: 100%; height: auto; border-radius: 6px; box-shadow: 0 14px 34px rgba(0, 0, 0, .28); }
.kb-info h1 { margin: 2px 0 0; color: var(--col1); font: 400 clamp(28px, 4vw, 42px)/1.5 var(--kt-title); }
.kb-info h1::after { display: none; }
.kb-kick { margin: 0; color: #b3171b; font-weight: 700; letter-spacing: .02em; }
.kb-en { margin: 0 0 10px; color: #555; letter-spacing: .35em; font: 700 14px/1.6 Georgia, serif; }
.kb-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; padding: 0; list-style: none; }
.kb-stats li { display: flex; flex-direction: column; align-items: center; min-width: 96px; padding: 8px 14px; border-radius: 12px; background: #eef7f6; color: #444; font-size: 14px; }
.kb-stats b { color: var(--col1); font: 400 22px/1.5 var(--kt-title); }
.kb-by { margin: 6px 0 18px; }
.kb-toc-h { display: flex; align-items: center; gap: 14px; margin: 10px 0 18px; color: var(--col1); font: 400 30px/1.6 var(--kt-title); }
.kb-toc-h::before, .kb-toc-h::after { content: ""; flex: 1; height: 2px; background: linear-gradient(90deg, transparent, #9cc7c3); }
.kb-toc-h::after { background: linear-gradient(90deg, #9cc7c3, transparent); }
.kb-toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.toc-card { border: 1px solid #dfe8e7; border-radius: 14px; background: #fff; overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.toc-card:hover { border-color: var(--col1); box-shadow: 0 6px 18px rgba(12, 102, 98, .14); }
.toc-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: inherit; text-decoration: none; }
.toc-num { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--col1); color: #fff; font: 400 18px/1 var(--kt-title); }
.toc-t { display: flex; flex-direction: column; color: #1f1f1f; font: 400 16px/1.7 var(--kt-title); }
.toc-t small { color: #b3171b; font: 700 12.5px/1.4 var(--kt-body); }
.toc-card details { border-top: 1px dashed #dfe8e7; }
.toc-card summary { padding: 7px 14px; color: var(--col1); font-size: 14px; font-weight: 700; cursor: pointer; }
.toc-card details ol { margin: 0; padding: 0 14px 10px; list-style: none; }
.toc-card details li a { display: flex; gap: 10px; padding: 3px 0; color: #333; font-size: 14.5px; line-height: 1.7; text-decoration: none; }
.toc-card details li a:hover { color: var(--col1); text-decoration: underline; }
.toc-card .n { flex: none; min-width: 22px; color: var(--col1); font-weight: 700; }

@media (max-width: 760px) {
  .kb-intro { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 18px; }
  .kb-cov { max-width: 260px; }
  .kb-stats { justify-content: center; }
  .kb-page { padding: 16px 16px 8px; }
  .db-paper { border-right-width: 8px; font-size: 16px; }
  .kb-foot { padding: 8px 16px; font-size: 13.5px; }
  .kb-b { padding: 4px 12px 0 16px; }
  .db-paper .cols3, .db-paper .cols4, .db-paper ol.lst.cols3, .db-paper ol.lst.cols4 { column-count: 2; }
  .kb-books { display: none; }
  .db-paper h2.kb-chap { margin: 38px -16px 16px; border-radius: 0; }
  .kb-page > h2.kb-chap:first-child { margin-top: -16px; }
  .db-paper h2.kb-chap .kb-ch { font-size: clamp(16px, 4.4vw, 26px); bottom: 8%; }
  .db-paper h2.kb-chap .kb-badge { top: 14%; right: 6%; }
  .db-paper h2.kb-chap .kb-badge .lb { font-size: clamp(12px, 3vw, 16px); }
  .db-paper h2.kb-chap .kb-badge .ring { width: clamp(38px, 10vw, 56px); }
  .db-paper h2.kb-chap .kb-badge b { font-size: clamp(15px, 4vw, 22px); }
}
@media (max-width: 480px) {
  .db-paper .cols2, .db-paper .cols3, .db-paper .cols4, .db-paper ol.lst.cols2, .db-paper ol.lst.cols3, .db-paper ol.lst.cols4 { column-count: 1; }
}

/* solution / answer dropdown right under each exercise («មើលដំណោះស្រាយ លំហាត់ទី …») */
.db-paper details.kb-ans { margin: 10px 0 14px; border: 1px solid #dcd3ee; border-radius: 12px; background: #f4eefa; overflow: hidden; }
.db-paper details.kb-ans > summary { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: #4b2a8a; font-weight: 700;
  cursor: pointer; list-style: none; }
.db-paper details.kb-ans > summary::-webkit-details-marker { display: none; }
.db-paper details.kb-ans > summary::after { content: "▾"; margin-left: auto; color: #6a4bb0; transition: transform .15s; }
.db-paper details.kb-ans[open] > summary::after { transform: rotate(180deg); }
.db-paper details.kb-ans > summary .ic { font-size: 18px; }
.db-paper details.kb-ans .kb-ans-b { padding: 6px 18px 12px; border-top: 1px dashed #dcd3ee; background: #fff; }
.db-paper details.kb-ans .kb-ans-b > :first-child { margin-top: 4px; }
.db-paper details.kb-ans .kb-ans-b > :last-child { margin-bottom: 2px; }
.db-paper details.kb-mcq .kb-ans-b { display: flex; align-items: center; gap: 10px; }
.db-paper details.kb-mcq .lb.ca { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--mag); color: #fff; font-weight: 700; }
.db-paper details.kb-ans ol.lst { margin: 4px 0; }
.db-paper details.kb-ans ol.lst .lb { font-size: 12.5px; }
.db-paper .kb-auto { margin: 4px 0 0; color: #8a7fa6; font-size: 12.5px; text-align: right; }
.db-paper svg.kb-nl { display: block; width: 100%; max-width: 560px; height: auto; margin: 2px 0 6px; }
.db-paper details.kb-ans ol.lst > li { align-items: flex-start; }
.db-paper .tbl tr.th td { background: #c5ddd9; font-weight: 700; font-family: var(--kt-title); font-weight: 400; color: #1b1b1b; }
.db-paper .tbl tr:first-child td { background: #c5ddd9; }
.db-paper .tbl td { text-align: left; vertical-align: middle; line-height: 1.7; }
.kb-sec-nn .hn { font-size: .9em; }

/* grade 8: theorem (blue tab), hint (green), common mistake (red), prerequisites (orange) */
.kb-thm .kb-tab { background: linear-gradient(90deg, #00e5ff, #3a1fd6); }
.kb-thm { --fold: #1c5f86; background: #eef6fd; }
.kb-note { position: relative; margin: 22px 0; padding: 16px 0 8px; border: 1.5px solid; border-radius: 6px; text-align: left; }
.kb-note-t { position: absolute; top: -13px; left: 12px; padding: 1px 10px; border-radius: 3px; color: #fff; font: 400 14.5px/1.7 var(--kt-title); }
.kb-hint { background: #f1f8f1; border-color: #2e7d32; } .kb-hint .kb-note-t { background: #2e7d32; }
.kb-mist { background: #fdf0f0; border-color: #e57373; } .kb-mist .kb-note-t { background: #d32f2f; }
.kb-mist .kb-note-t::before { content: "✗ "; }
.kb-pre { background: #fff6ec; border-color: #f0a040; } .kb-pre .kb-note-t { background: #ef8f1f; }

/* grade 10: a chapter file holds several lessons; each lesson uses the chapter banner as its background */
.db-paper h2.kb-chap { margin: 54px -34px 22px; padding: 0; border-left: 0; border-radius: 0; overflow: hidden;
  scroll-margin-top: 80px; }
.kb-page > h2.kb-chap:first-child { margin-top: -22px; }
.db-paper h2.kb-chap .kb-ch { font-size: clamp(20px, 3.8vw, 42px); line-height: 1.45; }
.db-paper h2.kb-chap .kb-badge .lb { font-size: clamp(14px, 2.4vw, 26px); }
.db-paper h2.kb-chap .kb-badge .ring { width: clamp(46px, 9.2vw, 96px); }
.db-paper h2.kb-chap .kb-badge b { font-size: clamp(18px, 3.5vw, 38px); }

/* grade 7+ fixes: multi-column choice lists start at the same height; answer labels (១.ក … ១.ឃ) have equal width so the text lines up */
.db-paper ol.lst.cols2 > li, .db-paper ol.lst.cols3 > li, .db-paper ol.lst.cols4 > li { margin: 0 0 12px; }
.db-paper ol.lst.cols2, .db-paper ol.lst.cols3, .db-paper ol.lst.cols4 { margin-top: 10px; }
.db-paper details.kb-ans ol.lst .lb { min-width: 25px; border-radius: 50%; line-height: 25px; overflow: visible; white-space: nowrap; transform: none; }
.db-paper details.kb-ans ol.lst > li { align-items: baseline; }

/* choice lists (tasks) read row by row: ក ខ គ ឃ across the first row, then ង ច … (grid, not CSS columns) */
.db-paper ol.lst.tasks { column-count: auto; display: grid; column-gap: 28px; row-gap: 12px; }
.db-paper ol.lst.tasks > li { margin: 0; }
.db-paper ol.lst.tasks.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.db-paper ol.lst.tasks.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.db-paper ol.lst.tasks.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .db-paper ol.lst.tasks.cols3, .db-paper ol.lst.tasks.cols4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .db-paper ol.lst.tasks.cols2, .db-paper ol.lst.tasks.cols3, .db-paper ol.lst.tasks.cols4 { grid-template-columns: 1fr; } }
.db-paper details.kb-ans ol.lst ol.lst { margin: 6px 0 2px; }
.db-paper details.kb-ans ol.lst > li > .li-b > p:first-child { margin: 0 0 2px; font-weight: 700; }
.db-paper details.kb-ans ol.lst > li > .li-b > ol.lst:first-child { margin-top: 0; }

/* table of contents: each lesson title inside the gold Khmer frame (static/img/khmer/frame-gold.png) */
.kb-toc .toc-head { display: block; position: relative; aspect-ratio: 709 / 420; padding: 0; overflow: hidden; text-align: center;
  background: url(../img/khmer/frame-gold.png) center / 100% 100% no-repeat; }
.kb-toc .toc-head .toc-num { display: none; }
.kb-toc .toc-t { position: absolute; inset: 35.8% 25.5% 34.2%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow-wrap: break-word; font-size: 12.5px; line-height: 1.3; }
.kb-toc .toc-t small { font-size: 0.84em; line-height: 1.2; margin-bottom: 0.14em; }
.kb-toc .toc-card { border-color: #eadfbf; }
.kb-toc .toc-card:hover { border-color: #c9a227; box-shadow: 0 6px 18px rgba(170, 130, 20, .18); }
.kb-toc .toc-card details { border-top-color: #eadfbf; }

/* book cover inside the gold Khmer frame (static/img/khmer/frame-cover-kh.png, opening matched to the cover) */
.kb-cov-f { position: relative; width: 100%; aspect-ratio: 697 / 891; padding: 8.65% 7.90% 6.30% 8.35%;
  filter: drop-shadow(0 10px 18px rgba(80, 50, 10, .22)); }
.kb-cov-f::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: url(../img/khmer/frame-cover-kh.png?v=1) center / 100% 100% no-repeat; }
.kb-cov-f .kb-cov { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0; box-shadow: none; }
@media (max-width: 760px) { .kb-cov-f { max-width: 280px; margin: 0 auto; } .kb-cov-f .kb-cov { max-width: none; } }

/* book information beside the cover inside the gold corner frame (static/img/khmer/frame-info.png; corners kept, edges stretched) */
.kb-intro .kb-info { border: 46px solid transparent; border-image: url(../img/khmer/frame-info.png) 80 stretch; padding: 0 8px; }
@media (max-width: 760px) { .kb-intro .kb-info { border-width: 34px; padding: 0; } }
.kb-info a.btn-primary, .kb-info a.btn-primary:hover { color: #fff; }
