/* formulas.html + formulas-g<N>.html — រូបមន្តសង្ខេបគណិតវិទ្យា (built by tools/build_formulas.py) */
.fm-hero { background: linear-gradient(135deg, #2a1659 0%, #3d227d 56%, #0e7490 100%); color: #fff; padding: 28px 0 24px; }
.fm-hero h1 { color: #fff; margin: 0 0 6px; }
.fm-hero .lead { color: rgba(255,255,255,.9); margin: 0 0 10px; max-width: 860px; }
.fm-hero .crumbs { margin-bottom: 10px; color: rgba(255,255,255,.78); }
.fm-hero .crumbs a { color: #f6d77a; }
.fm-gsws { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 12px; color: rgba(255,255,255,.85); }
.fm-gsw { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35); color: #fff; text-decoration: none; font-weight: 700; }
.fm-gsw:hover { background: rgba(255,255,255,.15); }
.fm-gsw.on { background: #f6d77a; border-color: #f6d77a; color: #2a1659; }
.fm-dls { display: flex; flex-wrap: wrap; gap: 8px; }
.fm-dl small { opacity: .7; font-weight: 400; margin-left: 4px; }
.fm-hero .btn-ghost { background: #fff; color: #2a1659; border-color: #fff; }
.fm-dlnote { margin: 8px 0 0; font-size: 13px; color: rgba(255,255,255,.8); }
.fm-wrap { padding: 22px 0 44px; }
.fm-note { margin-top: 22px; font-size: 14px; opacity: .8; }

/* overview cards */
.fm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.fm-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: var(--surface); color: var(--ink); text-decoration: none; transition: transform .15s, box-shadow .15s; }
.fm-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(20, 10, 60, .14); }
.fm-card img { width: 100%; height: auto; display: block; border-bottom: 1px solid var(--line); background: #fff; }
.fm-card-t { font-size: 20px; font-weight: 700; padding: 10px 14px 2px; }
.fm-card-d { font-size: 13px; opacity: .75; padding: 0 14px 12px; }

/* ---------- grade page: the book's printed sheets (A4 landscape, 4 columns) rebuilt in HTML ---------- */
@font-face { font-family: 'FM Battambang'; src: url(../fonts/battambang-full.woff2) format('woff2'); font-weight: 400;
  unicode-range: U+1780-17FF, U+19E0-19FF, U+200B-200D, U+25CC; font-display: swap; }
@font-face { font-family: 'FM Battambang'; src: url(../fonts/battambang-full-bold.woff2) format('woff2'); font-weight: 700;
  unicode-range: U+1780-17FF, U+19E0-19FF, U+200B-200D, U+25CC; font-display: swap; }
@font-face { font-family: 'FM Muol'; src: url(../fonts/khmeros-muollight-full.woff2) format('woff2');
  unicode-range: U+1780-17FF, U+19E0-19FF, U+200B-200D, U+25CC; font-display: swap; }

.fm-wide { max-width: 1680px; margin: 0 auto; padding: 0 16px; }
.fm-toc { margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 14px; font-size: 14px; }
.fm-toc summary { font-weight: 700; cursor: pointer; }
.fm-toc ol { margin: 10px 0 2px; padding-left: 22px; columns: 260px; column-gap: 28px; }
.fm-toc li { margin: 3px 0; break-inside: avoid; }
.fm-toc a { color: var(--ink); text-decoration: none; }
.fm-toc a:hover { color: var(--primary); text-decoration: underline; }

/* the paper: white in light and dark theme, like the PDF */
.sheet { background: #fff; color: #111; border: 2px solid #d93030; padding: 18px 20px 22px; margin: 0 0 26px;
  box-shadow: 0 6px 22px rgba(20, 10, 60, .13); font-family: 'FM Battambang', 'Kantumruy Pro', 'Noto Sans Khmer', serif;
  font-size: 15px; line-height: 1.72; }
.sh-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding-bottom: 12px;
  margin-bottom: 14px; border-bottom: 1.5px solid #222; }
.sh-logos { display: flex; gap: 10px; }
.sh-logos img { width: 64px; height: 64px; object-fit: contain; }
.sh-title { text-align: center; }
.sh-t1 { font-family: 'FM Muol', 'Kantumruy Pro', serif; font-size: 27px; color: #1414d2; line-height: 1.5;
  text-shadow: 1.2px 1.2px 0 rgba(0, 0, 0, .28); }
.sh-t2 { font-size: 14.5px; color: #111; text-shadow: .6px .6px 0 rgba(0, 0, 0, .18); }
.sh-badge { font-family: 'FM Muol', 'Kantumruy Pro', serif; font-size: 30px; line-height: 1.4; background: #80ff80;
  background: linear-gradient(#86e29b, #86e29b); padding: 6px 22px; color: #111; white-space: nowrap; }
.sh-badge b { font-weight: 400; color: #e01010; }

.sheet-cols { column-count: 4; column-gap: 28px; column-rule: 1px solid #b9b9b9; }
.sheet-cols > * { break-inside: avoid; }
.fx p { margin: 0 0 .5em; }
.fx b, .fx strong { font-weight: 700; }

/* headings (names follow the book's style files) */
.fx h2, .fx h3, .fx h4 { font-family: 'FM Muol', 'Kantumruy Pro', serif; font-weight: 400; break-after: avoid; scroll-margin-top: 90px; }
.fx h2, .fx h3.ms, .fx h3.sh, .fx h3.sec { margin: 12px 0 8px; padding: 7px 12px; font-size: 15.5px; line-height: 1.6;
  color: #1010c4; background: #eef0ff; border-left: 5px solid #1010a8; }
.fx h2:first-child { margin-top: 0; }
.fx h3 { margin: 10px 0 6px; font-size: 14.5px; color: #1010c4; }
.fx h4, .fx h4.ss { margin: 8px 0 4px 10px; font-size: 14px; color: #1414d2; }
.fx h2.ms9 { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 0; font-size: 17px; color: #1414d2; }
.fx h2.ms9 .lnum { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 6px; color: #fff; font-size: 19px;
  background: linear-gradient(90deg, #1f3fff 50%, #dfe4ff 50%); box-shadow: 3px 3px 0 #bbb; }
.fx h2.ctr { display: table; margin: 12px auto 10px; border: 0; background: #fff200; color: #111; padding: 4px 16px; }
.fx h2.sec { color: #1010c4; }

/* boxes (tcolorbox of the sheets) */
.fx .bx { margin: 8px 0 12px; break-inside: avoid; }
.fx .bx-t { padding: 3px 10px; font-weight: 700; font-size: 14.5px; line-height: 1.6; }
.fx .bx-b { padding: 8px 11px; }
.fx .bx-b > :last-child { margin-bottom: 0; }
.fx .bx-sel { border: 1px solid #0000ff; background: #f2f2ff; border-radius: 4px; }
.fx .bx-sel .bx-t { background: #0000ff; color: #fff; font-family: 'FM Muol', 'Kantumruy Pro', serif; font-weight: 400; }
.fx .bx-blue { border: 2.5px solid #1414b4; background: #f2f2ff; border-radius: 16px; overflow: hidden; }
.fx .bx-blue .bx-t { background: #1414b4; color: #fff; font-weight: 400; padding: 6px 14px; }
.fx .bx-thm { border-left: 4px solid #00a023; background: #eefff1; }
.fx .bx-thm .bx-t { color: #1414d2; background: #f2f2ff; border-left: 5px solid #0000ff; margin-left: -4px;
  font-family: 'FM Muol', 'Kantumruy Pro', serif; font-weight: 400; }
.fx .bx-tip { border-left: 4px solid #00a023; background: #eefff1; }
.fx .bx-tip .bx-t { color: #00a023; font-weight: 700; }
.fx .bx-red { border: 1.8px solid #e01010; background: #fff6f6; border-radius: 9px; box-shadow: 2px 3px 0 rgba(0, 0, 0, .18); }
.fx .bx-red .bx-t { display: inline-block; margin: 6px 0 0 14px; padding: 2px 12px; border-radius: 6px; background: #e01010;
  color: #fff; font-family: 'FM Muol', 'Kantumruy Pro', serif; font-weight: 400; }

.fx .c { text-align: center; }
.fx .c .tw table { margin: 0 auto; }
.fx .blk { margin: 4px 0; }
.fx .ls { list-style: none; margin: 4px 0 8px; padding: 0 0 0 4px; }
.fx .ls > li { display: flex; gap: 8px; margin: 3px 0; }
.fx .ls > li > div { min-width: 0; flex: 1; }
.fx .ls > li > div > p:last-child { margin-bottom: 0; }
.fx .lm { flex: none; min-width: 1em; color: #111; }
.fx .tw { overflow-x: auto; margin: 6px 0 10px; }
.fx table { border-collapse: collapse; font-size: 14px; }
.fx td { border: 1px solid #999; padding: 3px 8px; vertical-align: middle; }
.fx td p { margin: 0; }
.fx .hl { background: #fff200; color: #111; padding: 0 6px; }
.fx .fr { border: 1.5px solid currentColor; padding: 0 6px; }
.fx .mx-d { display: block; margin: 6px 0; overflow-x: auto; overflow-y: hidden; }
.fx .katex { font-size: 1.06em; }
.fx .katex-display { margin: .25em 0; }
.fx img.fmfig { display: block; background: transparent; border-radius: 0; padding: 0; min-width: 0; max-width: 100%; height: auto; margin: 8px auto; }
.fx hr { border: 0; border-top: 1px solid #999; }

/* narrower screens: fewer columns (a phone cannot show 4 columns of a sheet) */
@media (max-width: 1280px) { .sheet-cols { column-count: 3; } }
@media (max-width: 1000px) { .sheet-cols { column-count: 2; } .sh-t1 { font-size: 22px; } .sh-badge { font-size: 24px; } }
@media (max-width: 700px) {
  .sheet-cols { column-count: 1; }
  .sheet { padding: 12px 12px 16px; font-size: 15.5px; }
  .sh-head { grid-template-columns: 1fr auto; }
  .sh-logos { grid-column: 1 / -1; justify-content: center; }
  .sh-logos img { width: 46px; height: 46px; }
  .sh-title { text-align: left; } .sh-t1 { font-size: 19px; } .sh-t2 { font-size: 12.5px; }
  .sh-badge { font-size: 19px; padding: 4px 12px; }
  .fm-wide { padding: 0 8px; }
}
@media print {
  .site-header, .site-footer, .fm-hero, .fm-toc { display: none !important; }
  .fm-wide { max-width: none; padding: 0; }
  .sheet { box-shadow: none; break-after: page; margin: 0; }
  .sheet-cols { column-count: 4; }
  @page { size: A4 landscape; margin: 6mm; }
}
/* grade 10 section titles, styled like grade 8's «▶ ១. …» blue headings */
.fx h3.tri { font-family: 'FM Battambang', 'Kantumruy Pro', serif; font-weight: 700; font-size: 15.5px; color: #1a3fd1;
  background: none; border: 0; padding: 0; margin: 12px 0 6px; }
.fx h3.tri .tri { font-size: .8em; margin-right: 2px; }
