/* res.pov.sg — Calculations page (calc.html) and cheat sheets (cheatsheet.html).
   Builds on app.css tokens. Owned by the CALC+SHEETS agent. */

/* ================= Calculations ================= */
.cx-hero { padding: 44px 0 20px; }
.cx-hero h1 { font-size: clamp(1.9rem, 4.8vw, 3rem); max-width: 18ch; }
.cx-lede { max-width: 66ch; color: var(--ink-2); font-size: 1.05rem; }
.cx-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.cx-badges .pill { white-space: normal; line-height: 1.3; }
/* Cheat-sheet page header: Officer Stamp approves the verified sheets (31 Oct 2026) */
.cx-hero--cast .wrap { position: relative; }
.cx-hero__cast { position: absolute; right: var(--gut); bottom: -6px; width: 79px; height: auto; pointer-events: none; }
@media (min-width: 900px) { .cx-hero__cast { width: 108px; right: calc(var(--gut) + 24px); } }
@media (max-width: 640px) { .cx-hero__cast { position: static; display: block; float: right; width: 58px; margin: 0 0 4px 10px; } }
.cx-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; align-items: start; padding-bottom: 48px; }
.cx-main { min-width: 0; }
.cx-index { position: sticky; top: calc(var(--header-h) + 12px); max-height: calc(100vh - var(--header-h) - 24px); overflow: auto; padding: 4px 4px 12px 0; }
.cx-index__top { display: flex; justify-content: space-between; align-items: baseline; }
.cx-index ul { list-style: none; margin: 0 0 12px; padding: 0; }
.cx-index li a { display: flex; align-items: center; gap: 6px; padding: 5px 8px; margin-left: -8px; border-radius: 7px; color: var(--ink); text-decoration: none; font-size: .92rem; }
.cx-index li a:hover { background: #e8e8e4; }
.idx-h { font: 600 .7rem/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mut); margin: 10px 0 4px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--lime-deep); flex: none; }
.cx-index__key { font-size: .8rem; color: var(--mut); display: flex; align-items: center; gap: 6px; }
.btn-link { background: none; border: 0; padding: 6px 2px; font: 600 .85rem/1.2 var(--f-body); color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.btn-link:hover { color: var(--ink); }

.grp-h { font-size: 1.05rem; font: 600 .78rem/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mut); margin: 26px 0 10px; }
.grp-h:first-child { margin-top: 0; }
.mod { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; box-shadow: var(--shadow); scroll-margin-top: calc(var(--header-h) + 12px); }
.mod > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-radius: var(--r); }
.mod > summary::-webkit-details-marker { display: none; }
.mod > summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); flex: none; margin-top: -4px; transition: transform .15s; }
.mod[open] > summary::after { transform: rotate(225deg); margin-top: 4px; }
.mod > summary:hover { background: #fafaf8; }
.mod-h { display: flex; flex-direction: column; min-width: 0; }
.mod-title { font: 600 1.15rem/1.25 var(--f-head); }
.mod-sub { font-size: .88rem; color: var(--mut); }
.mod-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-left: auto; }
.tag { font: 600 .68rem/1 var(--f-mono); letter-spacing: .04em; text-transform: uppercase; padding: 5px 7px; border-radius: 99px; background: #eeeeea; color: var(--ink-2); white-space: nowrap; }
.tag-try { background: var(--lime); color: var(--ink); }
.mod-body { padding: 0 18px 18px; border-top: 1px solid var(--line); }
.mod-when { margin: 16px 0 4px; }
.mod-sec { margin-top: 22px; }
.mod-sec h3 { font-size: 1rem; margin: 0 0 8px; }
.mod-sec > p { margin: 0 0 10px; color: var(--ink-2); }

/* rule tables */
.rt { margin: 12px 0 14px; }
.rt figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; }
.rt-title { font-weight: 600; font-size: .92rem; }
.rt-meta { font-size: .78rem; color: var(--mut); }
.rt-meta a { color: var(--ink-2); }
.fid { font-family: var(--f-mono); font-size: .72rem; }
.rt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r-sm); }
.rt table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.rt th, .rt td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rt thead th { background: #f6f6f3; font: 600 .74rem/1.3 var(--f-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.rt tbody th { font-weight: 500; }
.rt td { font-family: var(--f-mono); font-size: .84rem; }
.rt tbody tr:last-child th, .rt tbody tr:last-child td { border-bottom: 0; }
.rt-note { font-size: .82rem; color: var(--ink-2); margin: 6px 0 0; }

.formula { display: flex; gap: 10px; align-items: baseline; background: var(--lime-soft); border: 1px solid #dcefa5; border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 10px; }
.formula span { font: 600 .68rem/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); flex: none; }
.formula code { font: 500 .86rem/1.5 var(--f-mono); white-space: normal; overflow-wrap: anywhere; }
.method { margin: 0; padding-left: 1.3em; }
.method li { margin: 0 0 7px; padding-left: 2px; }
.method li.speed { background: #fafaf6; border-left: 3px solid var(--lime-deep); padding: 6px 8px; margin-left: -8px; list-style-position: inside; border-radius: 0 6px 6px 0; }
.speed-tag { font: 600 .66rem/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; background: var(--ink); color: #fff; padding: 3px 6px; border-radius: 5px; vertical-align: 1px; }

/* worked examples */
.ex { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 10px; background: #fcfcfb; }
.ex-h { font: 600 .72rem/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--mut); margin: 0 0 4px; }
.ex-q { margin: 0 0 8px; font-weight: 500; }
.ex-steps { margin: 0 0 6px; padding-left: 1.4em; font-family: var(--f-mono); font-size: .86rem; }
.ex-steps li { margin-bottom: 4px; }
.ex-steps li.fresh { animation: cxIn .25s ease; }
@keyframes cxIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.ex-a { margin: 6px 0 8px; font-weight: 600; }
.ex-a span { font: 600 .68rem/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; background: var(--up-soft); color: #13724a; padding: 4px 6px; border-radius: 5px; margin-right: 6px; vertical-align: 2px; }
.ex-ctl { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.traps ul { margin: 0; padding-left: 1.2em; }
.traps li { margin-bottom: 6px; }
.traps li::marker { color: var(--down); }

/* try it */
.tryit { background: #f6f6f2; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; }
.try-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; }
.try-in { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fld { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fld span { font-size: .78rem; color: var(--ink-2); font-weight: 500; }
.fld input, .fld select { width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font: 500 .95rem/1.2 var(--f-mono); color: var(--ink); }
.fld select { font-family: var(--f-body); font-size: .9rem; }
.fld input:focus, .fld select:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
.fld input:disabled { background: #eee; color: var(--mut); }
.chk { display: flex; gap: 8px; align-items: center; font-size: .9rem; min-height: 36px; }
.chk input { width: 18px; height: 18px; }
.work { background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; min-width: 0; }
.work-h { font: 600 .7rem/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--mut); margin: 0 0 6px; }
.work ol { margin: 0; padding-left: 1.3em; font: 400 .84rem/1.5 var(--f-mono); }
.work ol li { margin-bottom: 4px; overflow-wrap: anywhere; }
.work-a { margin: 10px 0 0; padding-top: 10px; border-top: 1px dashed var(--line-2); font-size: .95rem; }
.work-a b { font-family: var(--f-mono); background: var(--lime); padding: 1px 5px; border-radius: 4px; }
.work-note { font-size: .82rem; color: var(--ink-2); margin: 8px 0 0; }
.work-err { color: var(--down-ink); }
.work-err p { margin: 0; }
/* practise this calculation: summary pill + in-module CTA */
.mod-prac { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 6px 10px 6px 12px; border-radius: 99px; background: var(--ink); color: #fff; font: 600 .8rem/1.1 var(--f-body); text-decoration: none; white-space: nowrap; }
.mod-prac svg { color: var(--lime); flex: none; width: 14px; height: 14px; }
.mod-prac:hover { background: #26292d; }
.mod-prac:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 4px var(--lime); }
.prac-cta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 18px; margin-top: 22px; padding: 16px 18px; border-radius: var(--r-sm); background: var(--lime-soft); border: 1px solid #dcefa5; border-left: 4px solid var(--lime-deep); }
.prac-cta__t { flex: 1 1 260px; min-width: 0; }
.prac-cta__h { margin: 0; font: 600 1.05rem/1.3 var(--f-head); color: var(--ink); }
.prac-cta__s { margin: 3px 0 0; font-size: .86rem; color: var(--ink-2); }
.prac-cta__btn { white-space: normal; text-align: left; }
.prac-cta__btn svg { color: var(--lime); flex: none; }
.cx-practise-note { margin: 12px 0 0; font-size: .95rem; color: var(--ink-2); max-width: 66ch; }
.cx-practise-note b { color: var(--ink); }
.mod-foot { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.mod-src { margin: 0; font-size: .78rem; color: var(--mut); flex: 1 1 260px; }
.mod-src a { color: var(--ink-2); }
.cx-next { margin-top: 26px; }
.cx-next h2 { font-size: 1.3rem; }
.cx-disc { margin-top: 18px; }
.load-err { color: var(--down-ink); }

@media (max-width: 900px) {
  .cx-layout { grid-template-columns: 1fr; }
  .cx-index { position: static; max-height: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
  #calc-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 14px; }
  .try-form { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .mod > summary { padding: 14px; }
  .mod-body { padding: 0 14px 14px; }
  .mod-tags .tag:not(.tag-try) { display: none; }
  .mod > summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "h chev" "tags tags"; gap: 10px 12px; }
  .mod > summary .mod-h { grid-area: h; }
  .mod > summary::after { grid-area: chev; align-self: center; }
  .mod-tags { grid-area: tags; justify-content: flex-start; margin-left: 0; align-items: center; }
  .prac-cta { padding: 14px; }
  .prac-cta__btn { width: 100%; justify-content: center; text-align: center; }
  .row2 { gap: 6px; }
  .tryit { padding: 10px; margin-left: -4px; margin-right: -4px; }
}
@media print {
  .cx-index, .tryit, .ex-ctl, .cx-next, .mod-prac, .prac-cta { display: none !important; }
  .mod { box-shadow: none; break-inside: avoid-page; }
  .ex-steps li[hidden], .ex-a[hidden] { display: list-item !important; }
}
@media (max-width: 359px) { .row2 { grid-template-columns: 1fr; } }

/* ================= Cheat sheets ================= */
.cs-wrap { padding-bottom: 48px; }
.cs-tabs { display: flex; gap: 8px; margin: 8px 0 16px; flex-wrap: wrap; }
.cs-tabs [role=tab] { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 52px; padding: 9px 16px; border: 1px solid var(--line-2); background: var(--card); border-radius: 11px; font: 600 1rem/1.2 var(--f-head); color: var(--ink); cursor: pointer; text-align: left; }
.cs-tabs [role=tab] span { font: 500 .8rem/1.2 var(--f-body); color: var(--mut); }
.cs-tabs [role=tab][aria-selected=true] { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: inset 0 -3px 0 var(--lime); }
.cs-tabs [role=tab][aria-selected=true] span { color: #c9ccd0; }
.cs-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 14px; }
.cs-bar h2 { font-size: 1.3rem; margin: 0 0 2px; }
.cs-bar p { margin: 0; }
.cs-bar__act { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 400px; }
.cs-msg { text-align: right; }
.cs-bar__row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.cs-view { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line-2); border-radius: 11px; background: var(--card); }
.cs-view[hidden] { display: none; }
.cs-view button { min-height: 36px; padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--mut); font: 600 .85rem/1 var(--f-body); cursor: pointer; }
.cs-view button:hover { color: var(--ink); }
.cs-view button[aria-pressed=true] { background: var(--ink); color: #fff; }
/* On-screen preview tray. sheet.js scales .cs-doc (true-A4 pages) to fill the tray's inner width:
   2 pages side by side when the tray is >= 1100px wide (and the "2 pages" view is on), otherwise 1 page.
   Packing is always measured unscaled; print/PDF resets all of this (see @media print). */
.cs-stage { position: relative; overflow: hidden; width: 100%; background: #e2e2dc; border-radius: var(--r); padding: 14px; }
.cs-doc { transform-origin: top left; width: 210mm; }
.cs-stage .cs-page { box-shadow: 0 1px 2px rgba(20, 22, 25, .10), 0 6px 18px rgba(20, 22, 25, .07); }
.cs-doc--grid2 { display: grid; grid-template-columns: repeat(2, 210mm); gap: 6mm; width: calc(420mm + 6mm); align-items: start; }
.cs-src { margin: 14px 0 0; font-size: .85rem; }
.cs-src summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.cs-src ul { padding-left: 1.1em; max-height: 360px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 10px 10px 26px; }
.cs-src li { margin-bottom: 6px; color: var(--ink-2); }
.cs-src code { font: 600 .75rem var(--f-mono); color: var(--ink); }

/* ---- the A4 page (sizes in mm/pt so screen, print and the build-time PDF agree) ----
   Two columns, as many pages as the content needs. Each section is a rounded panel with its own hue
   (.cs-sec--c0 … --c7, assigned by sheet.js in section order). Colour is decoration only: every hue is
   dark enough to read as a solid grey bar with white text in black-and-white print, and all text is
   >= 8.5pt. tools/build_sheet_pdfs.mjs prints these exact pages to the static PDFs. */
.cs-page { width: 210mm; height: 297mm; box-sizing: border-box; padding: 8mm 9mm 0; background: #fff; color: #15181b; display: flex; flex-direction: column; overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif; font-size: var(--cs-fs, 9pt); line-height: 1.32; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cs-stage .cs-page + .cs-page { margin-top: 6mm; }
.cs-stage .cs-doc--grid2 .cs-page + .cs-page { margin-top: 0; }
.cs-head { position: relative; display: flex; align-items: center; gap: 3.5mm; padding-bottom: 2.4mm; margin-bottom: 4mm; flex: none; }
.cs-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.1mm; border-radius: .6mm;
  background: linear-gradient(90deg, #2459c9 0 12.5%, #1d7f46 12.5% 25%, #c2551a 25% 37.5%, #6b3fc4 37.5% 50%, #c0313a 50% 62.5%, #0e7c86 62.5% 75%, #a86a00 75% 87.5%, #bf2f7a 87.5% 100%); }
.cs-logo { height: 4.4mm; width: auto; }
.cs-head__t { min-width: 0; }
.cs-title { margin: 0; font: 700 12.5pt/1.15 'Space Grotesk', sans-serif; letter-spacing: -.01em; }
.cs-sub { margin: .5mm 0 0; font-size: 8.5pt; color: #4d5359; }
.cs-ver { margin: 0 0 0 auto; flex: none; background: #c8f24b; color: #101214; font: 600 8.5pt/1 'JetBrains Mono', monospace; padding: 1.5mm 2.4mm; border-radius: 1.4mm; white-space: nowrap; border: .6pt solid #9ed321; }
.cs-page:not([data-page="1"]) .cs-head { padding-bottom: 2mm; margin-bottom: 3.4mm; }
.cs-page:not([data-page="1"]) .cs-sub { display: none; }
.cs-cols { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5mm; }
.cs-col { position: relative; min-width: 0; min-height: 0; overflow: hidden; }

/* section hues: --c bar, --cd dark ink for key terms, --cl rules, --ct panel tint, --cth table-head tint */
.cs-sec, .cs-sec--c0 { --c: #2459c9; --cd: #163d8f; --cl: #cbd8f3; --ct: #f5f8fe; --cth: #e2eafa; }
.cs-sec--c1 { --c: #1d7f46; --cd: #135a31; --cl: #c6e4d1; --ct: #f4faf6; --cth: #ddf0e3; }
.cs-sec--c2 { --c: #c2551a; --cd: #8a3a10; --cl: #f1d3c1; --ct: #fef7f3; --cth: #fbe5d8; }
.cs-sec--c3 { --c: #6b3fc4; --cd: #4a2a8c; --cl: #dbcff2; --ct: #f9f6fe; --cth: #ebe3fa; }
.cs-sec--c4 { --c: #c0313a; --cd: #8c1f26; --cl: #f0cacd; --ct: #fef5f5; --cth: #f9e0e2; }
.cs-sec--c5 { --c: #0e7c86; --cd: #0a5a61; --cl: #c1e2e5; --ct: #f3fafb; --cth: #dbeff1; }
.cs-sec--c6 { --c: #93600a; --cd: #714700; --cl: #ecdab5; --ct: #fefaf1; --cth: #f7ebd0; }
.cs-sec--c7 { --c: #bf2f7a; --cd: #8a2057; --cl: #f0c8dd; --ct: #fef5f9; --cth: #f9dfec; }

.cs-sec { border: .7pt solid var(--cl); border-radius: 2.4mm; margin: 0 0 3.2mm; overflow: hidden; background: var(--ct); break-inside: avoid; }
.cs-sec h3 { display: flex; align-items: center; gap: 2mm; margin: 0; padding: 1.25mm 2.4mm 1.25mm 1.6mm; background: var(--c); color: #fff; font: 700 9.5pt/1.2 'Space Grotesk', sans-serif; letter-spacing: .02em; text-transform: uppercase; }
.cs-sec h3 .cs-h { min-width: 0; }
.cs-sec h3 .cs-cont { font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .85; }
.cs-n { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 5.4mm; height: 5.4mm; padding: 0 .9mm; box-sizing: border-box; border-radius: 2.7mm; background: #fff; color: var(--cd); font: 700 8.5pt/1 'JetBrains Mono', monospace; letter-spacing: 0; }
.cs-sec--alert { --c: #c8f24b; --cd: #101214; --cl: #a9d63a; --ct: #f7fde6; --cth: #e9f7c0; border-width: 1pt; }
.cs-sec--alert h3 { color: #101214; }
.cs-sec--alert .cs-n { background: #101214; color: #c8f24b; }
.cs-sec--key { border: 1.1pt solid var(--c); }
.cs-sec--formula .cs-l { font-family: 'JetBrains Mono', monospace; font-size: 8.6pt; }
.cs-l { margin: 0; padding: .95mm 2.4mm 1mm; border-top: .5pt solid var(--cl); }
.cs-sec h3 + .cs-l, .cs-sec h3 + .cs-t { border-top: 0; }
.cs-l b { font-weight: 700; color: var(--cd); }
.cs-t { padding: 1.1mm 2mm 1.4mm; border-top: .5pt solid var(--cl); }
.cs-tt { margin: 0 .4mm .8mm; font-weight: 700; color: var(--cd); }
.cs-t table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: inherit; line-height: 1.26; background: #fff; border: .5pt solid var(--cl); border-radius: 1.4mm; overflow: hidden; }
.cs-t th { text-align: left; font-weight: 700; color: var(--cd); background: var(--cth); padding: .6mm 1.3mm; border-bottom: .6pt solid var(--cl); }
.cs-t td { padding: .55mm 1.3mm; border-bottom: .4pt solid #ececea; vertical-align: top; overflow-wrap: break-word; }
.cs-t tr:last-child td { border-bottom: 0; }
.cs-t--kv td:first-child { font-weight: 600; }
.cs-t--num td + td { white-space: nowrap; }
.cs-t--ehg td:nth-child(3), .cs-t--ehg th:nth-child(3) { border-left: .5pt solid var(--cl); }
.cs-tn { margin: .8mm .4mm 0; color: #33383d; }

/* ---- diagrams (.cs-d): built by sheet.js from {t:'diagram'} items. Panel hue tokens only (--c, --cd, --cl,
   --ct, --cth); every value is printed as text so greyscale print loses nothing; text >= 8pt; one block. ---- */
.cs-d { margin: 0; padding: 1.2mm 2.2mm 1.5mm; border-top: .5pt solid var(--cl); break-inside: avoid; page-break-inside: avoid; font-size: 8.4pt; line-height: 1.25; }
.cs-sec h3 + .cs-d { border-top: 0; }
.cs-dt { margin: 0 0 1mm; font-weight: 700; color: var(--cd); font-size: 8.8pt; }
.cs-df { margin: 1.4mm 0 0; color: #33383d; font-size: 8.2pt; }
.cs-d p { margin: 0; }
/* legend */
.cs-dk { display: flex; flex-wrap: wrap; gap: .6mm 3.2mm; margin: 0 0 1mm; font-size: 8.2pt; color: #33383d; }
.cs-dk__i { display: inline-flex; align-items: center; gap: 1.2mm; }
.cs-dk__sw { display: inline-block; width: 3.2mm; height: 2.4mm; border-radius: .5mm; }
.cs-dk__sw--0, .cs-db .cs-db__bar--s0, .cs-dc .cs-dc__bar--s0 { background: var(--c); }
.cs-dk__sw--1, .cs-db .cs-db__bar--s1, .cs-dc .cs-dc__bar--s1 { background: repeating-linear-gradient(135deg, var(--cth) 0 .55mm, #fff .55mm 1.1mm); box-shadow: inset 0 0 0 .7pt var(--cd); }
/* horizontal bars */
.cs-db { display: grid; gap: .9mm; background: #fff; border: .5pt solid var(--cl); border-radius: 1.4mm; padding: 1.2mm 1.6mm; }
.cs-db__r { display: grid; grid-template-columns: 25mm minmax(0, 1fr); gap: 1.6mm; align-items: start; }
.cs-db__l { font-weight: 600; color: #15181b; padding-top: .3mm; }
.cs-db__r--hl .cs-db__l { color: var(--cd); font-weight: 700; }
.cs-db__tr { min-width: 0; display: grid; gap: .5mm; }
.cs-db__row { display: flex; align-items: center; gap: 1.2mm; min-height: 3.8mm; }
.cs-db__bar { flex: none; display: flex; align-items: center; justify-content: flex-end; height: 3.6mm; min-width: .8mm; border-radius: .6mm; background: var(--cl); box-sizing: border-box; }
.cs-db .cs-db__bar--hl { background: var(--c); }
.cs-db__v { font: 600 8.2pt/1 'JetBrains Mono', monospace; color: #15181b; white-space: nowrap; }
.cs-db__row--in .cs-db__v { padding: 0 1.2mm; }
.cs-db__row--in .cs-db__bar--hl .cs-db__v, .cs-db__row--in .cs-db__bar--s0 .cs-db__v { color: #fff; }
.cs-db__row--in .cs-db__bar--s1 .cs-db__v { background: #fff; border-radius: .5mm; padding: .3mm .8mm; margin-right: .5mm; }
.cs-db__cap { color: #33383d; font-size: 8.2pt; }
.cs-db__nv { color: #15181b; font-style: italic; padding: .3mm 0; }
/* vertical step columns */
.cs-dc { --dc-h: 17mm; background: #fff; border: .5pt solid var(--cl); border-radius: 1.4mm; padding: 1.2mm 1.6mm 1mm; }
.cs-dc__plot { display: flex; align-items: flex-end; gap: 2mm; border-bottom: .8pt solid #15181b; }
.cs-dc__g, .cs-dc__x span { flex: 1 1 0; min-width: 0; }
.cs-dc__g { display: flex; align-items: flex-end; justify-content: center; gap: .6mm; }
.cs-dc__b { flex: 1 1 0; max-width: 7mm; display: flex; flex-direction: column; align-items: stretch; }
.cs-dc__v { text-align: center; font: 600 8pt/1 'JetBrains Mono', monospace; color: #15181b; margin-bottom: .5mm; white-space: nowrap; }
.cs-dc__v--0 { color: #6a7076; }
.cs-dc__bar { display: block; border-radius: .6mm .6mm 0 0; }
.cs-dc__x { display: flex; gap: 2mm; margin-top: .7mm; }
.cs-dc__x span { text-align: center; font-weight: 600; font-size: 8.2pt; white-space: nowrap; }
/* grid: heat (cs-dg--h0..h4) or marks (yes / no / part / na) */
.cs-dg { width: 100%; border-collapse: separate; border-spacing: .6mm; background: #fff; border: .5pt solid var(--cl); border-radius: 1.4mm; table-layout: fixed; }
.cs-dg th { font-weight: 700; color: var(--cd); text-align: center; padding: .3mm .4mm; font-size: 8.2pt; vertical-align: bottom; }
.cs-dg thead th:first-child { width: 31%; }
.cs-dg tbody th { text-align: left; color: #15181b; font-weight: 600; vertical-align: middle; font-size: 8.2pt; line-height: 1.2; }
.cs-dg td { text-align: center; vertical-align: middle; padding: .7mm .6mm; border-radius: .7mm; font: 600 8.2pt/1.15 'JetBrains Mono', monospace; }
.cs-dg--h0 { background: #fff; box-shadow: inset 0 0 0 .5pt var(--cl); color: #15181b; }
.cs-dg--h1 { background: var(--cth); color: #15181b; }
.cs-dg--h2 { background: var(--cl); color: #15181b; }
.cs-dg--h3 { background: color-mix(in srgb, var(--c) 62%, #fff); color: #fff; }
.cs-dg--h4 { background: var(--cd); color: #fff; }
.cs-dg td.cs-dg--yes { background: #fff; box-shadow: inset 0 0 0 1pt #1d7f46; color: #135a31; font-family: 'Inter', sans-serif; font-weight: 700; }
.cs-dg td.cs-dg--no { background: #c0313a; color: #fff; font-family: 'Inter', sans-serif; font-weight: 700; }
.cs-dg td.cs-dg--part { background: #f7ebd0; color: #714700; font: 600 8pt/1.15 'Inter', sans-serif; }
.cs-dg td.cs-dg--na { color: #8a9096; font-weight: 400; }
/* vertical timeline */
.cs-dl { list-style: none; margin: 0; padding: 1mm 1.6mm 1mm 1.2mm; background: #fff; border: .5pt solid var(--cl); border-radius: 1.4mm; }
.cs-dl__r { display: grid; grid-template-columns: 21mm 3.6mm minmax(0, 1fr); column-gap: .8mm; }
.cs-dl__w { text-align: right; font: 600 8pt/1.2 'JetBrains Mono', monospace; color: var(--cd); padding: .45mm 0 .9mm; }
.cs-dl__rail { position: relative; }
.cs-dl__rail::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: .8pt; margin-left: -.4pt; background: var(--c); }
.cs-dl__r:first-child .cs-dl__rail::before { top: 1.6mm; }
.cs-dl__r:last-child .cs-dl__rail::before { bottom: auto; height: 1.6mm; }
.cs-dl__rail::after { content: ""; position: absolute; left: 50%; top: .9mm; width: 2.2mm; height: 2.2mm; margin-left: -1.1mm; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 .9pt var(--c); box-sizing: border-box; }
.cs-dl__r:first-child .cs-dl__rail::after, .cs-dl__r:last-child .cs-dl__rail::after { background: var(--c); }
.cs-dl__t { padding: .3mm 0 .9mm; }
.cs-dl__t b { color: #15181b; }
/* one-level decision tree */
.cs-dtq { position: relative; text-align: center; font-weight: 700; background: #fff; border: .9pt solid var(--c); border-radius: 1.4mm; padding: .9mm 2mm; color: #15181b; }
.cs-dtb { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 2mm; padding-top: 4.4mm; }
.cs-dtb::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 4.4mm; border: .9pt solid var(--c); border-bottom: 0; box-sizing: border-box; }
.cs-dtb__b { position: relative; background: #fff; border: .7pt solid var(--cl); border-radius: 1.4mm; padding: 2.2mm 1.6mm 1.2mm; }
.cs-dtb__b--0 { border-color: var(--c); box-shadow: inset 0 .9mm 0 var(--cth); }
.cs-dtb__a { position: absolute; top: -1.9mm; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 700 8pt/1 'Inter', sans-serif; padding: .6mm 1.6mm; border-radius: 1.6mm; background: var(--c); color: #fff; }
.cs-dtb__b--1 .cs-dtb__a { background: #fff; color: var(--cd); box-shadow: inset 0 0 0 .8pt var(--cd); }
.cs-dtb__h { text-align: center; font: 700 8.8pt/1.2 'Space Grotesk', sans-serif; color: var(--cd); letter-spacing: .02em; margin: 0 0 .5mm !important; }
.cs-dtb__t { color: #15181b; }
.cs-dtb__m { width: 100%; border-collapse: collapse; }
.cs-dtb__m td { padding: .25mm .4mm; border-top: .4pt solid #ececea; white-space: nowrap; }
.cs-dtb__m tr:first-child td { border-top: 0; }
.cs-dtb__m td:nth-child(2) { font: 700 8.6pt/1.2 'JetBrains Mono', monospace; color: var(--cd); text-align: right; }
.cs-dtb__m td:nth-child(3) { font-size: 8pt; color: #33383d; text-align: right; }
.cs-doc--tight .cs-d { padding-top: .9mm; padding-bottom: 1.1mm; }
/* ✓ / ✗ marks (inline SVG from sheet.js) */
.cs-mk { display: inline-block; width: 2.6mm; height: 2.6mm; vertical-align: -.45mm; margin-right: .7mm; flex: none; }
.cs-mk--yes { color: #1d7f46; }
.cs-mk--no { color: #c0313a; }
.cs-dg td.cs-dg--no .cs-mk { color: #fff; }
/* chips: compact tiles, 1-4 per row */
.cs-dp { display: grid; gap: 1mm; }
.cs-dp--1 { grid-template-columns: minmax(0, 1fr); }
.cs-dp--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cs-dp--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cs-dp--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cs-dp__i { background: #fff; border: .5pt solid var(--cl); border-left: 1.1mm solid var(--c); border-radius: 1.2mm; padding: .7mm 1.3mm .8mm 1.4mm; min-width: 0; }
.cs-dp__i--hl { background: var(--cth); }
.cs-dp__i--yes { border-left-color: #1d7f46; }
.cs-dp__i--no { border-left-color: #c0313a; background: #fef5f5; }
.cs-dp__h { display: flex; align-items: baseline; font-weight: 700; color: var(--cd); line-height: 1.2; }
.cs-dp__i--no .cs-dp__h { color: #8c1f26; }
.cs-dp__i--yes .cs-dp__h { color: #135a31; }
.cs-dp__h .cs-mk { align-self: flex-start; margin-top: .3mm; }
.cs-dp__t { color: #15181b; font-size: 8.2pt; line-height: 1.22; margin-top: .2mm !important; }
/* vs: two things compared row by row */
.cs-dv { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: .5pt solid var(--cl); border-radius: 1.4mm; overflow: hidden; table-layout: fixed; }
.cs-dv th, .cs-dv td { padding: .55mm 1.2mm; vertical-align: top; border-top: .4pt solid #ececea; text-align: left; line-height: 1.22; }
.cs-dv thead th { border-top: 0; font: 700 8.6pt/1.15 'Space Grotesk', sans-serif; letter-spacing: .02em; text-transform: uppercase; padding-top: .8mm; padding-bottom: .7mm; }
.cs-dv thead th:first-child { width: 24%; }
.cs-dv__a { background: var(--c); color: #fff; }
.cs-dv__b { background: var(--cth); color: var(--cd); box-shadow: inset .5pt 0 0 var(--cl); }
.cs-dv tbody th { font-weight: 600; color: var(--cd); font-size: 8.2pt; }
.cs-dv tbody td + td { box-shadow: inset .5pt 0 0 var(--cl); }
.cs-dv td.cs-dv--no { background: #fef5f5; }
/* group tag in the section header (colour-coded groups) */
.cs-grp { margin-left: auto; flex: none; font: 600 8pt/1 'JetBrains Mono', monospace; letter-spacing: .02em; text-transform: uppercase; background: rgba(255,255,255,.92); color: var(--cd); padding: .55mm 1.2mm .5mm; border-radius: .8mm; }
.cs-sec--alert .cs-grp { background: #101214; color: #c8f24b; }
/* ---- "Common traps" sub-box (.cs-x): built by sheet.js from {t:'traps'} items. Fixed amber tokens (not the
   panel hue) so it reads as the same kind of box in every panel; the dashed border, the warning triangle and
   the bold "Trap:" / "actually" words carry it in greyscale. Never split (one block in the packer). */
.cs-x { margin: 1mm 1.6mm 1.5mm; padding: .9mm 1.8mm 1mm; border: 1pt dashed #a86a00; border-radius: 1.6mm; background: #fffaf0;
  break-inside: avoid; page-break-inside: avoid; font-size: 8.6pt; line-height: 1.26; color: #15181b; }
.cs-sec h3 + .cs-x { margin-top: 1.5mm; }
.cs-x__h { display: flex; align-items: center; gap: 1.2mm; margin: 0 0 .5mm; }
.cs-x__ic { width: 3.4mm; height: 3.4mm; flex: none; color: #a86a00; display: block; }
.cs-x__lab { font: 700 8.5pt/1 'JetBrains Mono', monospace; letter-spacing: .1em; color: #fff; background: #714700; padding: .55mm 1.3mm .5mm; border-radius: .8mm; }
.cs-x__sub { font: 600 8.5pt/1 'Inter', sans-serif; color: #714700; }
.cs-x__l { list-style: none; margin: 0; padding: 0; }
.cs-x__l li { margin: 0; padding: .45mm 0 .5mm; border-top: .5pt dotted #d9bf8a; }
.cs-x__l li:first-child { border-top: 0; }
.cs-x__t { font-weight: 700; color: #714700; }
.cs-x__a { font-weight: 700; color: #15181b; white-space: nowrap; }
.cs-doc--tight .cs-x { margin-top: .8mm; margin-bottom: 1.2mm; padding-top: .7mm; padding-bottom: .8mm; }
.cs-doc--tight .cs-x__l li { padding-top: .3mm; padding-bottom: .35mm; }

/* tight density: chosen by sheet.js only when it saves a nearly empty last page (text size unchanged) */
.cs-doc--tight .cs-page { line-height: 1.27; }
.cs-doc--tight .cs-sec { margin-bottom: 2.4mm; }
.cs-doc--tight .cs-sec h3 { padding-top: 1mm; padding-bottom: 1mm; }
.cs-doc--tight .cs-l { padding-top: .65mm; padding-bottom: .7mm; }
.cs-doc--tight .cs-t { padding-top: .8mm; padding-bottom: 1mm; }
.cs-doc--tight .cs-t th, .cs-doc--tight .cs-t td { padding-top: .4mm; padding-bottom: .4mm; }
/* "Must remember" band: top of page 1, across both columns. Ink header + lime accent (brand), heavier
   border and a star badge, so it reads apart from the coloured numbered panels and the lime "alert" panel. */
.cs-must-slot { flex: none; }
.cs-sec--must { --c: #101214; --cd: #101214; --cl: #a9d63a; --ct: #f7fde6; border: 1.6pt solid #101214; border-radius: 2.6mm; margin: 0 0 3.6mm;
  box-shadow: inset 0 0 0 .9mm #c8f24b; background: var(--ct); }
.cs-sec--must h3 { background: #101214; color: #c8f24b; font-size: 10.5pt; letter-spacing: .08em; padding: 1.5mm 2.6mm 1.5mm 1.8mm; }
.cs-sec--must .cs-n--star { background: #c8f24b; color: #101214; min-width: 6mm; height: 6mm; border-radius: 3mm; }
.cs-star { width: 3.9mm; height: 3.9mm; fill: currentColor; display: block; }
.cs-must__tag { margin-left: auto; font: 600 8.5pt/1 'JetBrains Mono', monospace; letter-spacing: 0; text-transform: none; color: #c9ccd0; }
.cs-must__grid { column-count: 2; column-gap: 5mm; column-rule: .6pt solid #a9d63a; padding: 1mm 1.4mm 1.2mm; }
.cs-must__grid .cs-l { break-inside: avoid; page-break-inside: avoid; position: relative; padding: .8mm 1.6mm .85mm 4.4mm; border-top: 0; border-bottom: .5pt solid #dcefaa; }
.cs-must__grid .cs-l::before { content: ""; position: absolute; left: 1.3mm; top: 1.95mm; width: 1.7mm; height: 1.7mm; border-radius: .4mm; background: #101214; box-shadow: inset 0 0 0 .45mm #c8f24b; }
.cs-must__grid .cs-l b { color: #101214; }
.cs-doc--tight .cs-sec--must { margin-bottom: 2.8mm; }
.cs-doc--tight .cs-must__grid .cs-l { padding-top: .6mm; padding-bottom: .65mm; }
.cs-doc--tight .cs-must__grid .cs-l::before { top: 1.75mm; }
.cs-foot-slot { flex: none; }
.cs-foot { border-top: 1pt solid #101214; margin-top: 1.2mm; padding: 1.5mm 0 6mm; font-size: 8.5pt; line-height: 1.32; color: #33383d; }
.cs-foot p { margin: 0; }
/* the "Shared by" line is always exactly one line tall (empty in the build-time PDF, where the
   download stamps the visitor's associate into this slot), so the packing never depends on it */
.cs-foot__who { height: 1.32em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-foot__who b, .cs-foot__meta b { color: #101214; }
.cs-foot__meta { position: relative; padding-right: 11mm; }
.cs-foot__pg { position: absolute; right: 0; top: 0; font: 600 8.5pt 'JetBrains Mono', monospace; color: #101214; }

@media (max-width: 640px) {
  .cs-bar { align-items: stretch; }
  .cs-bar__act { align-items: stretch; max-width: none; width: 100%; }
  .cs-msg { text-align: left; }
  .cs-tabs [role=tab] { flex: 1 1 140px; }
  .cs-bar__row { justify-content: stretch; }
  .cs-bar__row .btn { flex: 1 1 auto; }
  .cs-stage { padding: 8px; }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  body[data-page="cheatsheet"] { background: #fff !important; display: block; min-height: 0; }
  body[data-page="cheatsheet"] > *:not(main), body[data-page="cheatsheet"] .cx-hero, body[data-page="cheatsheet"] .cs-tabs,
  body[data-page="cheatsheet"] .cs-bar, body[data-page="cheatsheet"] .cx-next, body[data-page="cheatsheet"] .cx-disc,
  body[data-page="cheatsheet"] .cs-src, body[data-page="cheatsheet"] .site-footer { display: none !important; }
  body[data-page="cheatsheet"] .wrap { max-width: none; padding: 0; }
  body[data-page="cheatsheet"] .cs-stage { background: none; border-radius: 0; height: auto !important; overflow: visible; padding: 0 !important; box-shadow: none !important; }
  body[data-page="cheatsheet"] .cs-doc { transform: none !important; display: block !important; width: 210mm !important; }
  body[data-page="cheatsheet"] .cs-page { box-shadow: none !important; }
  body[data-page="cheatsheet"] .cs-page { break-after: page; page-break-after: always; margin: 0 !important; }
  body[data-page="cheatsheet"] .cs-page:last-child { break-after: auto; page-break-after: auto; }
  body[data-print="p1"] #panel-p2, body[data-print="p2"] #panel-p1 { display: none !important; }
  body[data-print="p1"] #panel-p1, body[data-print="p2"] #panel-p2 { display: block !important; }
}

/* ---------- dark theme (see THEME in app.css). The A4 .cs-page keeps the light tokens. ---------- */
@media screen {
  [data-theme="dark"] .cx-index li a:hover { background: var(--tint); }
  [data-theme="dark"] .mod > summary:hover { background: var(--raise); }
  [data-theme="dark"] .tag { background: var(--tint); }
  [data-theme="dark"] .tag-try { background: var(--lime); color: var(--on-lime); }
  [data-theme="dark"] .rt thead th, [data-theme="dark"] .method li.speed, [data-theme="dark"] .ex, [data-theme="dark"] .tryit { background: var(--sunk); }
  [data-theme="dark"] .formula, [data-theme="dark"] .prac-cta { border-color: #3a4a1c; }
  [data-theme="dark"] .prac-cta { border-left-color: var(--lime-deep); }
  [data-theme="dark"] .speed-tag { background: var(--inv); color: var(--on-inv); }
  [data-theme="dark"] .ex-a span { color: var(--up-ink); }
  [data-theme="dark"] .fld input, [data-theme="dark"] .fld select { background: var(--field); }
  [data-theme="dark"] .fld input:disabled { background: var(--tint); }
  [data-theme="dark"] .work { background: var(--card); }
  [data-theme="dark"] .work-a b { color: var(--on-lime); }
  [data-theme="dark"] .mod-prac { background: var(--chip); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
  [data-theme="dark"] .mod-prac:hover { background: #30353a; }
  [data-theme="dark"] .prac-cta__btn svg { color: #4f7d00; }
  [data-theme="dark"] .cs-tabs [role=tab][aria-selected=true] { background: var(--inv); border-color: var(--inv); color: var(--on-inv); }
  [data-theme="dark"] .cs-tabs [role=tab][aria-selected=true] span { color: #4d5359; }
  [data-theme="dark"] .cs-stage { background: #0b0c0e; box-shadow: inset 0 0 0 1px var(--line); }
  [data-theme="dark"] .cs-stage .cs-page { box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 8px 24px rgba(0, 0, 0, .45); }
  [data-theme="dark"] .cs-view button[aria-pressed=true] { background: var(--inv); color: var(--on-inv); }
}
