@font-face {
  font-family: 'Khmer OS Battambang';
  src: local('Khmer OS Battambang'), local('KhmerOS_battambang'), local('KhmerOSBattambang'), local('KhmerOS Battambang');
  font-display: swap;
}

#teach-show {
  position: fixed; inset: 0; z-index: 200;
  display: block; width: 100vw; height: 100vh;
  background: #0b1020; color: #f4f6ff;
  user-select: none;
}
#teach-show[hidden] { display: none !important; }
body.teach-show-on { overflow: hidden; }

/* Floating Tools Bar Dock: sleek Zoom-style movable pill */
.ts-bar {
  position: absolute; z-index: 100;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px;
  background: #23272e;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 99px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.52), 0 2px 8px rgba(0, 0, 0, 0.35);
  user-select: none; touch-action: none;
  font-family: 'Khmer OS Battambang', 'Kantumruy Pro', system-ui, sans-serif;
  transition: box-shadow .15s, border-color .15s;
}
.ts-bar.dragging {
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.65), 0 4px 12px rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.3);
  cursor: grabbing;
}
.ts-tgrip {
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px 0 6px; height: 28px; cursor: grab;
  color: #6f7684; touch-action: none;
}
.ts-tgrip .gl { display: grid; grid-template-columns: repeat(2, 3.5px); gap: 3.5px; }
.ts-tgrip .gl i { width: 3.5px; height: 3.5px; border-radius: 50%; background: #6f7684; display: block; }
.ts-tgrip:hover .gl i, .ts-bar.dragging .ts-tgrip .gl i { background: #ffffff; }

.ts-tsep { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.14); margin: 0 2px; flex-shrink: 0; }

.ts-tools, .ts-nav, .ts-wid { display: flex; align-items: center; gap: 4px; }
.ts-bar button {
  min-height: 0; height: 32px; padding: 0 10px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.08); color: #b0b5c1; border: 0; box-shadow: none;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: background .12s, color .12s, transform .1s;
}
.ts-bar button:hover { background: rgba(255, 255, 255, 0.16); color: #ffffff; }
.ts-bar button:active { transform: scale(0.95); }

.ts-bar .ts-clock {
  background: transparent; color: #e2e8f0; font-size: 13px; font-weight: 700;
  padding: 0 6px; font-variant-numeric: tabular-nums;
}
.ts-bar .ts-clock b { font-weight: 800; color: #ffffff; }
.ts-bar .ts-clock i { font-style: normal; font-size: 10px; margin-left: 3px; color: #94a3b8; }
.ts-bar .ts-clock:hover { background: rgba(255, 255, 255, 0.12); color: #ffffff; }
.ts-bar .ts-clock.off { opacity: 0.6; }

.ts-bar .ts-tbtn {
  background: rgba(255, 255, 255, 0.08); color: #ffffff; font-weight: 600;
}
.ts-bar .ts-tbtn:hover { background: #0e72ed; color: #ffffff; }
.ts-bar .ts-tbtn em { font-style: normal; font-size: 10px; opacity: 0.8; margin-left: 2px; }

.ts-bar .ts-dl, .ts-bar .ts-fs {
  width: 32px; height: 32px; padding: 0; font-size: 15px;
}
.ts-bar .ts-dl:hover, .ts-bar .ts-fs:hover { background: #0e72ed; color: #ffffff; }

.ts-bar .ts-exit {
  width: 32px; height: 32px; padding: 0; font-size: 14px;
  background: rgba(239, 68, 68, 0.2) !important; color: #fca5a5 !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
}
.ts-bar .ts-exit:hover {
  background: #ef4444 !important; border-color: #ef4444 !important; color: #ffffff !important;
}

.ts-col { width: 28px !important; min-width: 28px; padding: 0 !important; height: 28px; min-height: 28px !important; border-radius: 50% !important; border: 2px solid #fff !important; }
.ts-page { min-width: 64px; text-align: center; font-weight: 800; }
.ts-stage { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.ts-slide {
  position: absolute; inset: 0; padding: 36px 48px 48px;
  overflow: auto; font-size: clamp(18px, 2.4vw, 28px); line-height: 1.65;
}
.ts-slide h1 { font-size: clamp(36px, 5.5vw, 64px); margin: 8px 0 12px; color: #fff; }
.ts-slide h2 { font-size: clamp(26px, 3.4vw, 40px); margin: 0 0 16px; color: #c9d6ff; }
.ts-kicker { color: #9bb6ff; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 14px; }
.ts-sub { color: rgba(255,255,255,.72); }
.ts-eq { font-size: 1.25em; background: rgba(255,255,255,.06); border-radius: 16px; padding: 12px 18px; }
.ts-bullets, .ts-ex { margin: 0; padding-left: 1.2em; }
.ts-bullets li, .ts-ex li { margin: 8px 0; }
.ts-3, .ts-2 { display: grid; gap: 14px; margin-top: 18px; }
.ts-3 { grid-template-columns: repeat(3, 1fr); }
.ts-2 { grid-template-columns: 1fr 1fr; }
.ts-card { background: rgba(255,255,255,.08); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.ts-axis { display: flex; justify-content: space-between; margin: 28px 0; padding: 10px 8px 0; border-top: 3px solid #6ea0ff; }
.ts-axis span { position: relative; top: -22px; font-weight: 800; }
.ts-axis .z { color: #ffd56a; }
.ts-note, .ts-foot { color: rgba(255,255,255,.6); font-size: .85em; }
.ts-slide.ts-title { display: grid; place-content: center; text-align: center; }
.ts-ink { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; touch-action: none; cursor: crosshair; }
.ts-float {
  position: absolute; z-index: 8; min-width: 180px; min-height: 120px;
  background: rgba(18, 24, 48, .94); border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.4); overflow: hidden;
  display: flex; flex-direction: column;
}
.ts-float[hidden] { display: none; }
.ts-fbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px 6px 12px; background: rgba(255,255,255,.08); cursor: grab; font-size: 13px;
}
.ts-fx { min-height: 32px !important; width: 32px; padding: 0 !important; border-radius: 50% !important; background: transparent !important; color: #fff; border: 0; box-shadow: none; }
.ts-fin { flex: 1; min-height: 0; overflow: auto; padding: 8px; }
.ts-rs { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, #6ea0ff 50%); }
.ts-spin { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; }
.ts-spin canvas { width: min(100%, 100%); height: auto; aspect-ratio: 1; max-height: calc(100% - 52px); }
.ts-hub { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  width: 22%; aspect-ratio: 1; border-radius: 50%; padding: 0; font-size: 12px; font-weight: 800;
  background: var(--brand); color: #fff; border: 3px solid #fff; box-shadow: none; min-height: 0; }
.ts-spin-out { margin-top: auto; font-weight: 800; font-size: 18px; text-align: center; min-height: 28px; color: #ffd56a; }
.ts-timer { text-align: center; }
.ts-tface { font-size: 42px; font-weight: 800; letter-spacing: .06em; margin: 8px 0; }
.ts-tface.done { color: #ff8787; }
.ts-trow { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ts-trow button { min-height: 32px; padding: 4px 8px; font-size: 12px; background: #2a3358; color: #fff; border: 0; border-radius: 8px; box-shadow: none; }
.ts-timer input[type=range] { width: 100%; margin-top: 8px; }
.ts-calc input { width: 100%; text-align: right; font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.ts-ckeys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ts-ckeys button { min-height: 40px; padding: 0; background: #2a3358; color: #fff; border: 0; border-radius: 10px; box-shadow: none; font-weight: 800; }
@media (max-width: 800px) {
  .ts-slide { padding: 18px 16px 80px; }
  .ts-3, .ts-2 { grid-template-columns: 1fr; }
}

.desk-card { background: #fff; border: 1px solid rgba(28,36,51,.08); border-radius: 22px; padding: 16px; box-shadow: 0 10px 28px rgba(28,36,51,.05); }
.desk-hd { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.desk-hd h3 { margin: 0; font-size: 20px; color: #1c2433; }
.desk-hd span { color: #5c677a; font-size: 13px; font-weight: 700; }
.desk-slides { position: sticky; top: 12px; }
.slide-open { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; text-align: left; min-height: 108px; margin-bottom: 12px; padding: 16px; border-radius: 18px; }
.slide-open b { font-size: 26px; }
.slide-open-k { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }
.att-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 10px; }
.att-bar label { display: grid; gap: 4px; color: #1c2433; font-weight: 700; }
.att-period-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.att-period-lab { font-size: 13px; font-weight: 800; color: #5c677a; }
.att-periods { display: flex; flex-wrap: wrap; gap: 6px; }
.att-period { min-height: 34px; min-width: 34px; padding: 4px 8px; border-radius: 10px; background: #f3efe6; color: #1c2433; border: 0; box-shadow: none; }
.att-period.on { background: #1c2433; color: #fff; }
.att-hint, .att-empty { margin: 0 0 12px; color: #5c677a; font-size: 13.5px; }
.att-err { margin: 0 0 12px; color: #d9454f; font-weight: 700; }
.att-list { display: grid; gap: 8px; max-height: 560px; overflow: auto; padding-right: 2px; }
.att-row { display: grid; grid-template-columns: 36px minmax(120px, 1.2fr) auto minmax(120px, 1fr); gap: 10px; align-items: center;
  background: var(--bg); border-radius: 14px; padding: 8px 10px; color: #1c2433; }
.att-n { font-weight: 800; color: var(--brand); }
.att-who { display: flex; flex-direction: column; gap: 2px; }
.att-who b { color: #1c2433; }
.att-marks { display: flex; gap: 6px; }
.att-m { min-height: 36px; min-width: 42px; padding: 0 8px; border-radius: 10px; border: 0; box-shadow: none; background: #fff; color: #1c2433; font-weight: 800; }
.att-m.on.att-ok { background: #1c9a74; color: #fff; }
.att-m.on.att-A { background: #d9454f; color: #fff; }
.att-m.on.att-L { background: #b7791f; color: #fff; }
.att-note { min-height: 36px; background: #fff; color: #1c2433; }
.att-foot { position: sticky; bottom: 0; margin-top: 12px; background: linear-gradient(transparent, #fff 30%); padding-top: 8px; }
.att-save { width: 100%; min-height: 48px; font-size: 17px; }
.teach-lessons { display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.teach-lesson { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%;
  padding: 12px 14px; border-radius: 14px; background: var(--bg); color: #1c2433; border: 0; box-shadow: none; }
.teach-lesson.off { opacity: .55; }
.teach-lesson-n { font-size: 12px; font-weight: 800; color: var(--brand); }
@media (max-width: 700px) {
  .att-row { grid-template-columns: 28px 1fr; }
  .att-marks, .att-note { grid-column: 1 / -1; }
}

/* generated lesson decks (tools/make_g7_slides.py) */
.ts-pg { font-size: .55em; color: #64748b; font-weight: 600; }   /* slides are light: the old white counter was invisible */
.ts-slide p { margin: 0 0 .7em; }
.ts-slide .ts-exh { color: #ffd56a; font-weight: 800; margin-top: .4em; }
.ts-slide.ts-key { box-shadow: inset 6px 0 0 #5b8cff; }
.ts-slide.ts-ex { box-shadow: inset 6px 0 0 #ffd56a; }
.ts-slide.ts-prac { box-shadow: inset 6px 0 0 #ff8a5b; }
.ts-slide.ts-sol { box-shadow: inset 6px 0 0 #2fcf8d; }
.ts-slide.ts-sol h2 { color: #7ff0bd; }
.ts-slide.ts-prac h2 { color: #ffb594; }
.ts-slide.ts-ex h2 { color: #ffe39a; }
.ts-slide ol.ts-bullets { padding-left: 1.5em; }
.ts-slide li.lab { list-style: none; display: flex; gap: .6em; margin-left: -1.2em; }
.ts-slide li.lab .lb { font-weight: 800; color: #9bb6ff; flex: none; }
.ts-slide li.lab > div { flex: 1; min-width: 0; }
.ts-slide blockquote { margin: .6em 0; padding: .4em 1em; border-left: 4px solid #6ea0ff; background: rgba(255,255,255,.06); border-radius: 10px; }
.ts-table { border-collapse: collapse; margin: .6em 0; }
.ts-table td { border: 1px solid rgba(255,255,255,.28); padding: 6px 14px; text-align: center; }
.ts-slide .katex-display { margin: .5em 0; overflow-x: auto; overflow-y: hidden; }

/* ===== ESC lesson-deck look (white page, navy text, red headings, blue definition boxes) ===== */
#teach-show { background: #fff; }
.ts-slide {
  background: #fff; color: #0f5173;
  font-family: 'Kantumruy Pro', 'Khmer OS Battambang', system-ui, sans-serif;
}
.ts-slide h1 { color: #0f5173; font-family: 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-weight: 700; }
.ts-slide h2 { color: #ee0000; font-style: italic; font-weight: 800; padding-bottom: 8px; border-bottom: 3px solid #0f5173; }
.ts-kicker { color: #ee0000; font-family: 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-size: clamp(22px, 3vw, 34px); letter-spacing: 0; text-transform: none; font-weight: 700; }
.ts-sub, .ts-note, .ts-foot { color: #0f5173; opacity: .85; }
.ts-slide.ts-title h1::after {
  content: ''; display: block; height: 48px; margin: 18px auto 0; max-width: 520px;
  background: url('/img/esc-ornament.png') center / contain no-repeat;
}
.ts-eq, .ts-card { background: #eaf1f6; border: 2.5px solid #0f5173; border-radius: 6px; }
.ts-axis { border-top-color: #0f5173; }
.ts-axis .z { color: #ee0000; }
.ts-slide li.lab .lb, .ts-slide .ts-exh { color: #ee0000; }
.ts-slide blockquote { border-left-color: #ee0000; background: #eaf1f6; }
.ts-slide.ts-key { box-shadow: none; background: #eaf1f6; outline: 3px solid #0f5173; outline-offset: -14px; padding: 48px 56px 56px; }
.ts-slide.ts-ex, .ts-slide.ts-prac { box-shadow: none; }
.ts-slide.ts-sol { box-shadow: none; background: #f6fafc; }
.ts-slide.ts-key h2, .ts-slide.ts-ex h2, .ts-slide.ts-prac h2, .ts-slide.ts-sol h2 { color: #ee0000; }
.ts-slide table { border-collapse: collapse; }
.ts-slide th, .ts-slide td { border: 2px solid #0f5173; padding: 4px 12px; }
.ts-slide th { background: #eaf1f6; }

/* fonts: Khmer M1 titles, Khmer OS Battambang body, Times New Roman for English, Mathcad UniMath italic for maths */
.ts-slide { font-family: 'Times New Roman', 'Khmer OS Battambang', 'Kantumruy Pro', serif; }
.ts-slide h1, .ts-slide h2, .ts-kicker { font-family: 'Times New Roman', 'Khmer M1', 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; }
.ts-slide .katex, .ts-slide .katex .mathnormal, .ts-slide .katex .mord.mathit { font-family: 'Mathcad UniMath', KaTeX_Math, 'Times New Roman', serif; }
.ts-slide .katex .mathnormal { font-style: italic; }
#teach-show:fullscreen { background: #fff; }
.ts-slide.ts-cover { display: block; text-align: center; padding-top: 26px; padding-right: 100px; }
.ts-cover h1 { margin-bottom: 4px; }
.ts-cover h1::after { height: 34px !important; margin-top: 6px !important; }
.ts-cover .ts-kicker, .ts-cover .ts-sub { margin-bottom: 4px; }
.ts-obj { text-align: left; max-width: 900px; margin: 10px auto 0; background: #eaf1f6; border: 2.5px solid #0f5173; border-radius: 6px; padding: 10px 28px 12px; }
.ts-obj h3 { margin: 0 0 4px; color: #ee0000; font-style: italic; font-size: 1.05em; }
.ts-obj ol, .ts-obj ul { margin: 0; padding-left: 1.4em; }
.ts-slide { padding-right: 90px; }

/* headings scale with the slide text so shrink-to-fit works */
.ts-slide h1 { font-size: 2.3em; line-height: 1.25; margin: .15em 0 .2em; }
.ts-slide h2 { font-size: 1.5em; line-height: 1.3; margin: 0 0 .4em; }
.ts-slide .ts-kicker { font-size: 1.1em; margin: 0 0 .1em; }
.ts-slide .katex-display { margin: .3em 0; }
.ts-slide p { margin: 0 0 .5em; }

/* ===== Zoom-style Draw toolbar ===== */
.ts-pen {
  display: flex; align-items: center;
  background: #23272e;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px; overflow: visible;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.52), 0 2px 8px rgba(0, 0, 0, 0.35);
  user-select: none; z-index: 100;
  font-family: 'Khmer OS Battambang', 'Kantumruy Pro', system-ui, sans-serif;
}
.ts-pgrip {
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px 0 6px; align-self: stretch; cursor: grab;
  color: #6f7684; background: transparent;
  border-radius: 10px 0 0 10px; touch-action: none;
}
.ts-pgrip .gl { display: grid; grid-template-columns: repeat(2, 3px); gap: 3px; }
.ts-pgrip .gl i { width: 3px; height: 3px; border-radius: 50%; background: #6f7684; display: block; }
.ts-pgrip:hover .gl i { background: #b2b9c7; }
.ts-prow { display: flex; gap: 1px; padding: 2px; align-items: center; }
.ts-prow > button {
  position: relative; width: 35px; height: 34px; min-height: 0; padding: 2px 1px 1.5px; border-radius: 5px; border: 0; box-shadow: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5px;
  background: transparent; color: #b0b5c1; font-family: inherit; font-weight: 500;
  cursor: pointer; transition: background .12s, color .12s;
}
.ts-prow > button .ic { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; color: inherit; flex-shrink: 0; }
.ts-prow > button .ic svg { width: 14px; height: 14px; display: block; }
.ts-prow > button small { font-size: 8px; font-weight: 500; line-height: 1.05; color: #9ea4b2; white-space: nowrap; letter-spacing: -0.02em; }
.ts-prow > button:hover { background: rgba(255, 255, 255, 0.09); color: #ffffff; }
.ts-prow > button:hover small { color: #ffffff; }
.ts-prow > button.on { background: #0e72ed !important; color: #ffffff !important; box-shadow: 0 2px 8px rgba(14, 114, 237, 0.45); }
.ts-prow > button.on small { color: #ffffff !important; font-weight: 600; }
.ts-prow > button:disabled { opacity: .28; pointer-events: none; }
.ts-pcaret {
  position: absolute; top: 1px; right: 1px; font-style: normal; opacity: .55; color: inherit; pointer-events: none;
  display: flex; align-items: center; justify-content: center; width: 6px; height: 5px;
}
.ts-prow > button.on .ts-pcaret { opacity: .95; color: #ffffff; }

/* Group Separators */
.ts-psep { width: 1px; height: 18px; background: rgba(255, 255, 255, 0.14); margin: 0 1.5px; flex-shrink: 0; }

/* Collapse / Close red button */
.ts-pcollapse {
  width: 22px; height: 22px; min-height: 0; padding: 0; border: 1px solid rgba(239, 68, 68, 0.35); border-radius: 5px;
  background: rgba(239, 68, 68, 0.14); color: #fca5a5; font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; margin-left: 1px; transition: all .14s;
}
.ts-pcollapse:hover { background: #ef4444; border-color: #ef4444; color: #ffffff; }
.ts-pen.is-collapsed {
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.ts-pen.is-collapsed .ts-pgrip, .ts-pen.is-collapsed .ts-prow { display: none !important; }
.ts-pen-expand-btn {
  display: none;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #23272e;
  color: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: all .14s cubic-bezier(.2, .8, .2, 1);
}
.ts-pen-expand-btn .ic {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ts-pen-expand-btn .ic svg {
  width: 18px;
  height: 18px;
}
.ts-pen-expand-btn span:not(.ic) { display: none !important; }
.ts-pen-expand-btn:hover {
  background: #0e72ed;
  border-color: #0e72ed;
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(14, 114, 237, 0.5);
}
.ts-pen-expand-btn:active {
  transform: scale(0.94);
}
.ts-pen.is-collapsed .ts-pen-expand-btn { display: flex; }

/* Submenus matching Zoom Popovers */
.ts-menu {
  position: absolute; left: 40px; bottom: calc(100% + 8px);
  background: #23272e; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 10px; padding: 8px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55); display: flex; flex-direction: column; gap: 4px; min-width: 176px; z-index: 120;
  color: #f1f5f9; font-family: inherit;
}
.ts-menu.down { bottom: auto; top: calc(100% + 8px); }
.ts-menu[hidden] { display: none; }
.ts-menu-head {
  font-size: 11px; font-weight: 700; color: #cbd5e1; text-transform: uppercase;
  letter-spacing: .04em; padding: 4px 4px 2px;
}
.ts-menu button, .ts-menu .ts-menu-item {
  background: transparent; color: #e2e8f0; border: 0; box-shadow: none; text-align: left;
  padding: 7px 10px; border-radius: 6px; min-height: 0; font-weight: 500; font-size: 12.5px;
  display: flex; gap: 10px; align-items: center; cursor: pointer; transition: background .12s, color .12s;
  font-family: inherit;
}
.ts-menu button:hover, .ts-menu .ts-menu-item:hover { background: rgba(255, 255, 255, 0.1); color: #ffffff; }
.ts-menu button.on, .ts-menu .ts-menu-item.on { background: #0e72ed !important; color: #ffffff !important; }
.ts-menu .ic { width: 20px; height: 20px; display: inline-flex; justify-content: center; align-items: center; flex-shrink: 0; }
.ts-menu .ic svg { width: 17px; height: 17px; display: block; }

/* Zoom Draw Popover */
.ts-menu.m-draw { width: 184px; gap: 4px; padding: 8px; }
.ts-draw-tools { display: flex; gap: 4px; justify-content: space-between; }
.ts-draw-tool-btn {
  width: 38px; height: 38px; padding: 0; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06); color: #e2e8f0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.ts-draw-tool-btn:hover { background: rgba(255, 255, 255, 0.14); color: #ffffff; }
.ts-draw-tool-btn.on { background: #0e72ed !important; color: #ffffff !important; box-shadow: 0 2px 8px rgba(14, 114, 237, 0.4); }

.ts-draw-widths { display: flex; gap: 4px; justify-content: space-between; }
.ts-wavy-btn {
  width: 38px; height: 38px; padding: 0; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06); color: #e2e8f0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.ts-wavy-btn:hover { background: rgba(255, 255, 255, 0.14); color: #ffffff; }
.ts-wavy-btn.on { background: #0e72ed !important; color: #ffffff !important; box-shadow: 0 2px 8px rgba(14, 114, 237, 0.4); }

.ts-shapes-grid { display: grid; grid-template-columns: repeat(4, 38px); gap: 4px; }
.ts-shape-btn {
  width: 38px; height: 38px; padding: 0; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06); color: #e2e8f0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.ts-shape-btn:hover { background: rgba(255, 255, 255, 0.14); color: #ffffff; }
.ts-shape-btn.on { background: #0e72ed !important; color: #ffffff !important; box-shadow: 0 2px 8px rgba(14, 114, 237, 0.4); }

/* Stamp Popover */
.ts-menu.m-stamp { flex-direction: row; flex-wrap: wrap; width: 156px; min-width: 0; gap: 4px; padding: 6px; }
.ts-menu .stp { font-size: 18px; width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 6px; background: rgba(255, 255, 255, 0.05); }
.ts-menu .stp:hover { background: rgba(255, 255, 255, 0.15); }
.ts-menu .stp.on { background: #0e72ed !important; }

/* Zoom Format Popover (Image 4) */
.ts-menu.m-fmt { left: 140px; width: 196px; gap: 8px; padding: 10px; }
.ts-color-grid-16 {
  display: grid; grid-template-columns: repeat(5, 28px); gap: 6px; padding: 2px 0;
  justify-content: space-between;
}
.ts-zoom-col {
  width: 28px; height: 28px; padding: 0; border-radius: 6px;
  border: 1.5px solid rgba(0, 0, 0, 0.25); cursor: pointer;
  transition: transform .12s, outline .12s, box-shadow .12s;
}
.ts-zoom-col.is-white { border: 1.5px solid rgba(255, 255, 255, 0.5); }
.ts-zoom-col:hover { transform: scale(1.1); }
.ts-zoom-col.on {
  outline: 2px solid #ffffff; outline-offset: 2px;
  box-shadow: 0 0 0 3.5px #0e72ed; transform: scale(1.05);
}

.ts-slant-capsule {
  background: #2d323b; border-radius: 10px; padding: 3px; display: flex; gap: 2px;
  justify-content: space-between;
}
.ts-slant-btn {
  flex: 1; height: 32px; padding: 0; border: 0; border-radius: 7px;
  background: transparent; color: #cbd5e1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.ts-slant-btn:hover { background: rgba(255, 255, 255, 0.12); color: #ffffff; }
.ts-slant-btn.on { background: #0e72ed !important; color: #ffffff !important; }

.ts-font-row { display: flex; gap: 6px; align-items: center; }
.ts-font-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 6px; background: #2d323b;
  color: #cbd5e1; border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 13.5px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.ts-font-btn.ts-bold { font-weight: 900; }
.ts-font-btn.ts-italic { font-style: italic; font-weight: 700; }
.ts-font-btn:hover { background: rgba(255, 255, 255, 0.15); color: #ffffff; }
.ts-font-btn.on { background: #0e72ed !important; border-color: #0e72ed; color: #ffffff !important; }
.ts-font-select {
  flex: 1; height: 34px; border-radius: 6px; background: #2d323b; color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16); padding: 0 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; outline: none; font-family: inherit;
}

/* Floating context bar for Select tool */
.ts-select-bar {
  position: absolute; z-index: 105;
  display: none; align-items: center; gap: 3px; padding: 4px 6px;
  background: #23272e; border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  user-select: none; pointer-events: auto;
}
.ts-select-bar button {
  width: 28px; height: 28px; padding: 0; border: 0; background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.ts-select-bar button:hover { background: #0e72ed; color: #ffffff; }
.ts-select-bar .ts-select-del:hover { background: #ef4444 !important; color: #ffffff !important; }
.ts-select-bar .ts-select-sep { width: 1px; height: 16px; background: rgba(255, 255, 255, 0.18); margin: 0 2px; }

/* Text input inside slide */
.ts-text-input {
  position: absolute; z-index: 35; min-width: 140px; min-height: 38px; max-width: 80%;
  padding: 6px 12px; border: 2px dashed #3b82f6; border-radius: 8px;
  background: rgba(255, 255, 255, 0.96); color: #0f172a;
  font-family: 'Khmer OS Battambang', 'KhmerOS_battambang', 'KhmerOSBattambang', 'Battambang', 'Kantumruy Pro', sans-serif;
  line-height: 1.75; outline: none; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  cursor: text; white-space: pre-wrap; word-break: break-word;
}
.ts-text-input:empty:before {
  content: attr(data-placeholder); color: #94a3b8; pointer-events: none;
}

/* Palette: vertical, docking, dragging */
.ts-pen[hidden] { display: none; }
.ts-pen.vert, .ts-stage .ts-pen.vert {
  flex-direction: column !important;
  align-items: center;
  border-radius: 12px;
  width: 42px;
  max-width: 42px;
  max-height: calc(100% - 16px);
  max-height: calc(100vh - 16px);
  box-sizing: border-box;
}
.ts-pen.vert .ts-pgrip {
  flex-direction: row;
  border-radius: 12px 12px 0 0;
  justify-content: center;
  align-items: center;
  padding: 4px 0 2px;
  width: 100%;
  height: 16px;
  min-height: 16px;
  cursor: grab;
  touch-action: none;
  background: transparent;
  flex-shrink: 0;
}
.ts-pen.vert .ts-pgrip .gl { grid-template-columns: repeat(3, 3px); gap: 3px; }
.ts-pen.vert .ts-pgrip .gl i { width: 3px; height: 3px; border-radius: 50%; background: #6f7684; display: block; }
.ts-pen.vert .ts-prow {
  flex-direction: column;
  gap: 2px;
  padding: 2px 3px 4px;
  align-items: center;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.ts-pen.vert .ts-prow::-webkit-scrollbar { display: none; }
.ts-pen.vert .ts-prow > button {
  width: 34px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
  flex-shrink: 0;
}
.ts-pen.vert .ts-prow > button .ic {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ts-pen.vert .ts-prow > button .ic svg { width: 17px; height: 17px; }
.ts-pen.vert .ts-prow > button small {
  display: none !important; /* Zoom-style icon-only vertical dock */
}
.ts-pen.vert .ts-pcaret { top: 2px; right: 2px; width: 5px; height: 4px; }
.ts-pen.vert .ts-psep { width: 24px; height: 1px; margin: 2px 0; background: rgba(255, 255, 255, 0.16); flex-shrink: 0; }
.ts-pen.vert .ts-pcollapse {
  width: 26px;
  height: 22px;
  min-height: 0;
  margin: 2px 0 0;
  padding: 0;
  border-radius: 6px;
  font-size: 11px;
  flex-shrink: 0;
}
.ts-pen.vert .ts-menu {
  bottom: auto;
  max-height: calc(100vh - 30px);
  overflow-y: auto;
}
.ts-pen.vert .ts-menu[data-dir=right] { left: calc(100% + 8px); right: auto; }
.ts-pen.vert .ts-menu[data-dir=left] { left: auto; right: calc(100% + 8px); }

/* Slide padding adjustments so docked vertical bar never overlaps slide content */
.ts-stage.pen-right .ts-slide { padding-right: 80px !important; }
.ts-stage.pen-left .ts-slide { padding-left: 80px !important; }
.ts-stage.ts-theme-esc.pen-right .ts-slide { padding-right: calc(3.2cqw + 72px) !important; }
.ts-stage.ts-theme-esc.pen-left .ts-slide { padding-left: calc(3.2cqw + 72px) !important; }

@media (max-height: 640px) {
  .ts-pen.vert .ts-prow > button {
    height: 28px;
    width: 32px;
    min-height: 28px;
  }
  .ts-pen.vert .ts-prow > button .ic { height: 16px; width: 16px; }
  .ts-pen.vert .ts-prow > button .ic svg { width: 15px; height: 15px; }
}

.ts-pen.dragging { opacity: .94; box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65); cursor: grabbing; }
.ts-pen.dragging .ts-pgrip { cursor: grabbing; }
.ts-pen.glide { transition: left .2s cubic-bezier(.2, .8, .2, 1), right .2s cubic-bezier(.2, .8, .2, 1), top .2s cubic-bezier(.2, .8, .2, 1), bottom .2s cubic-bezier(.2, .8, .2, 1); }
.ts-snapzone { position: absolute; z-index: 8; border-radius: 12px; border: 2px dashed #0e72ed; background: rgba(14, 114, 237, 0.14); pointer-events: none; }
.ts-snapzone[hidden] { display: none; }

.ts-pen, .ts-stage .ts-pen {
  position: absolute; z-index: 99;
  background: #23272e;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.52), 0 2px 8px rgba(0, 0, 0, 0.35); display: flex; flex-direction: row;
}
.ts-pen .ts-menu[data-dir=down] { top: calc(100% + 8px); bottom: auto; }
.ts-pen .ts-menu[data-dir=up] { bottom: calc(100% + 8px); top: auto; }
.ts-pen .ts-menu[data-dir=right] { left: calc(100% + 8px); right: auto; top: 0; }
.ts-pen .ts-menu[data-dir=left] { left: auto; right: calc(100% + 8px); top: 0; }

/* Pen kinds */
.ts-menu .kinds { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.ts-menu .kb { flex-direction: column; gap: 0; padding: 5px 0 3px; align-items: center; justify-content: center; text-align: center; }
.ts-menu .kb span { font-size: 18px; line-height: 1.2; }
.ts-menu .kb small { font-size: 9px; opacity: .8; }
.ts-menu .kb.on { background: #2563eb; }

/* Disable distracting fake hand completely */
.ts-hand { display: none !important; }

/* pen-tip size: always-visible slider, mouse wheel and [ ] keys */
.ts-tipw { display: flex; align-items: center; gap: 5px; padding: 0 6px; color: #fff; }
.ts-tipw .tdot { width: 8px; height: 8px; border-radius: 50%; background: #fff; display: block; flex: none; }
.ts-tip { width: 76px; accent-color: #1c7ed6; cursor: pointer; }
.ts-pen.vert .ts-tipw { display: none; }
.ts-toast { position: absolute; z-index: 12; left: 50%; bottom: 74px; transform: translateX(-50%); background: rgba(15,81,115,.95); color: #fff; padding: 8px 16px; border-radius: 99px; font-weight: 800; display: flex; align-items: center; gap: 10px; opacity: 0; pointer-events: none; transition: opacity .18s; }
.ts-toast.on { opacity: 1; }
.ts-toast i { display: block; border-radius: 50%; }
@media (max-width: 720px) { .ts-tip { width: 56px; } }

/* rectangular magnifier */
.ts-lens { position: absolute; z-index: 7; overflow: hidden; border-radius: 12px; border: 4px solid #0f5173; background: #fff; box-shadow: 0 16px 40px rgba(0,0,0,.4); pointer-events: none; opacity: 0; transition: opacity .18s; }
.ts-lens.on { opacity: 1; }
.ts-lens-in { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.ts-lens-in .ts-slide { position: absolute; inset: 0; overflow: hidden; }
.ts-lens-ico { position: absolute; z-index: 8; width: 64px; height: 64px; pointer-events: none; opacity: 0; transition: opacity .18s; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); }
.ts-lens-ico.on { opacity: 1; }
.ts-prow .mi, .ts-stage .ts-prow .mi { width: 22px; height: 22px; display: block; }
.ts-lens.pin { border-color: #ee0000; box-shadow: 0 16px 40px rgba(0,0,0,.4), 0 0 0 3px rgba(238,0,0,.25); }
.ts-lens.pin { pointer-events: auto; cursor: pointer; }
.ts-prow .pdfi { font-size: 11px; font-weight: 900; letter-spacing: .02em; border: 2px solid currentColor; border-radius: 5px; padding: 0 3px; line-height: 1.25; }

/* ===== Tools drop-down + geometry instruments ===== */
.ts-dock { display: none !important; }
.ts-bar .ts-tools { position: relative; }
.ts-tbtn { min-height: 34px; padding: 4px 12px; border-radius: 10px; border: 0; background: rgba(255,255,255,.16); color: #fff; font-weight: 800; display: flex; align-items: center; gap: 6px; box-shadow: none; }
.ts-tbtn:hover { background: #ee0000; }
.ts-tbtn em { font-style: normal; font-size: 11px; }
.ts-tmenu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 250px; background: #1f2d3d; border-radius: 14px; padding: 6px; box-shadow: 0 14px 38px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 2px; }
.ts-tmenu[hidden] { display: none; }
.ts-tmenu button { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-height: 0; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: #fff; box-shadow: none; }
.ts-tmenu button:hover { background: rgba(255,255,255,.14); }
.ts-tmenu .ti { font-size: 22px; width: 28px; text-align: center; }
.ts-tmenu .tt { display: flex; flex-direction: column; flex: 1; line-height: 1.25; }
.ts-tmenu .tt b { font-size: 15px; }
.ts-tmenu .tt small { font-size: 11px; opacity: .7; font-weight: 400; }
.ts-tmenu .tick { font-style: normal; opacity: 0; color: #4cd68a; font-weight: 900; }
.ts-tmenu button.on .tick { opacity: 1; }
.ts-geo { display: flex; flex-direction: column; gap: 6px; }
.ts-geo .gh { margin: 0 0 4px; font-size: 12px; color: rgba(255,255,255,.7); line-height: 1.5; }
.ts-geo button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border: 0; border-radius: 10px; background: rgba(255,255,255,.1); color: #fff; min-height: 0; box-shadow: none; }
.ts-geo button:hover { background: rgba(255,255,255,.2); }
.ts-geo .gi { font-size: 22px; width: 28px; text-align: center; }
.ts-geo b { display: block; font-size: 14px; }
.ts-geo small { display: block; font-size: 11px; opacity: .7; font-weight: 400; }
.ts-geo .gclr { justify-content: center; background: rgba(238,0,0,.55); font-size: 13px; }
.ts-inst { position: absolute; z-index: 9; cursor: move; touch-action: none; transform-origin: 50% 50%; filter: drop-shadow(0 6px 10px rgba(0,0,0,.3)); user-select: none; }
.ts-inst svg { display: block; pointer-events: none; }
.ts-irot, .ts-ix { position: absolute; width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 50%; border: 0; background: #0f5173; color: #fff; font-size: 16px; box-shadow: 0 3px 8px rgba(0,0,0,.35); z-index: 10; transition: transform .12s, box-shadow .12s; }
.ts-irot { right: -16px; top: -54px; cursor: grab; }
.ts-ix { left: -16px; top: -54px; background: #ee0000; font-size: 13px; }
@media (max-width: 720px) { .ts-tbtn { padding: 4px 8px; } }

/* ===== Spin: wheel + pop-up + fireworks ===== */
.ts-wspin .ts-fin { padding: 0; display: flex; }
.sp { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px; container-type: size; overflow: hidden; }
.sp-bar { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.sp-bar button, .sp-bar select { min-height: 0; height: 30px; padding: 0 10px; border-radius: 8px; border: 0; background: rgba(255,255,255,.14); color: #fff; font-weight: 700; font-size: 13px; box-shadow: none; }
.sp-bar button.on { background: #ee0000; }
.sp-bar select { background: #2a3a4d; padding: 0 6px; }
.sp-chk { display: inline-flex; align-items: center; gap: 4px; color: #fff; font-size: 12px; font-weight: 700; }
.sp-chk input { accent-color: #ee0000; width: 15px; height: 15px; }
.sp-snd, .sp-rst { width: 30px; padding: 0 !important; }
.sp-wheel { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.sp-wheel canvas { height: 100%; max-width: 100%; aspect-ratio: 1 / 1; object-fit: contain; width: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); border-radius: 50%; }
.sp-ptr { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-top: 28px solid #fff; filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); z-index: 2; }
.sp-hub { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(22cqmin, 92px); aspect-ratio: 1; border-radius: 50%; padding: 0; min-height: 0; border: 4px solid #fff; background: #ee0000; color: #fff; font-weight: 900; font-size: clamp(12px, 3.6cqmin, 17px); box-shadow: 0 4px 14px rgba(0,0,0,.5); z-index: 2; }
.sp-hub:disabled { opacity: .7; }
.sp-info { text-align: center; color: rgba(255,255,255,.85); font-size: 12px; font-weight: 700; }
.sp-pop { position: absolute; inset: 12% 6%; z-index: 5; display: grid; place-items: center; animation: sp-in .38s cubic-bezier(.2,1.4,.3,1) both; }
.sp-pop[hidden] { display: none; }
@keyframes sp-in { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pp-card { width: 100%; max-height: 100%; overflow: auto; text-align: center; padding: 4cqmin 4cqw; border-radius: 3cqmin; background: linear-gradient(160deg, #fff, #eaf1f6); color: #0f5173; border: .8cqmin solid #ee0000; box-shadow: 0 16px 50px rgba(0,0,0,.55); }
.pp-k { font-weight: 800; color: #ee0000; font-size: clamp(13px, 4.4cqw, 26px); }
.pp-name { font-weight: 900; line-height: 1.25; margin: 1.5cqmin 0; font-size: clamp(24px, 11cqw, 78px); font-family: 'Khmer M1', 'Khmer OS Muol Light', 'Kantumruy Pro', serif; word-break: break-word; }
.pp-mem { list-style: none; margin: 0 0 2cqmin; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 1cqmin 2cqw; font-size: clamp(12px, 4.4cqw, 26px); font-weight: 700; }
.pp-mem li { background: #0f5173; color: #fff; padding: .4em .9em; border-radius: 99px; }
.pp-act { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pp-act button { min-height: 0; padding: .55em 1.4em; border-radius: 99px; border: 0; font-weight: 800; font-size: clamp(12px, 3.6cqw, 20px); box-shadow: none; }
.pp-ok { background: #0f5173; color: #fff; }
.pp-again { background: #ee0000; color: #fff; }
.sp-fw { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
.sp-wheel { display: flex; justify-content: center; align-items: center; }
.sp-disc { position: relative; height: 100%; aspect-ratio: 1 / 1; max-width: 100%; }
.sp-wheel canvas { position: static; width: 100%; height: 100%; max-width: none; object-fit: fill; }
.sp-ptr { top: -6px; }

/* spin button: dark teardrop with the point up, like the pointer */
.sp-hub {
  width: min(26cqmin, 112px); height: calc(min(26cqmin, 112px) * 1.08); aspect-ratio: auto; border: 0; border-radius: 0;
  top: 50%; transform: translate(-50%, -64%); padding: 28% 0 0; display: grid; place-items: center;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 108'><path d='M50 3 C50 3 11 40 11 68 a39 39 0 0 0 78 0 C89 40 50 3 50 3Z' fill='%23222'/></svg>") center / 100% 100% no-repeat;
  color: #fff; font-weight: 900; letter-spacing: .03em; font-family: 'Inter', 'Kantumruy Pro', system-ui, sans-serif; font-size: clamp(12px, 4.2cqmin, 20px);
  text-shadow: 0 2px 4px rgba(0,0,0,.6); box-shadow: none; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5));
}
.sp-hub:hover:not(:disabled) { filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)) brightness(1.25); }
.ts-rs.ts-rl { right: auto; left: 2px; background: linear-gradient(225deg, transparent 50%, #6ea0ff 50%); cursor: nesw-resize; width: 18px; height: 18px; }
.sp-hub { --hw: min(26cqmin, 112px); width: var(--hw); height: calc(var(--hw) * 1.08); padding: calc(var(--hw) * .26) 0 0 !important; box-sizing: border-box; }

/* ===== Timer: hourglass + dial ===== */
.ts-wtime .ts-fin { padding: 0; }
.tm { background: #fff; color: #235b88; padding: 8px 10px 12px; text-align: center; min-height: 100%; }
.tm-svg { width: 100%; height: auto; display: block; }
.tm-dig { font-size: 26px; font-weight: 800; letter-spacing: .08em; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.tm-prw { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; }
.tm-lab { font-weight: 700; font-size: 13px; }
.tm-pre { display: flex; gap: 5px; }
.tm-pre button { width: 38px; height: 32px; min-height: 0; padding: 0; border-radius: 9px; border: 2px solid #235b88; background: #fff; color: #235b88; font-weight: 800; box-shadow: none; }
.tm-pre button:hover { background: #235b88; color: #fff; }
.tm-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.tm-row button { min-height: 34px; padding: 4px 12px; border-radius: 10px; border: 0; background: #e3eff8; color: #235b88; font-weight: 800; box-shadow: none; }
.tm-row button.go { background: #2b73a3; color: #fff; padding: 4px 18px; }
.tm-row button.rst { width: 38px; padding: 0; }
.tm.done .tm-svg { animation: tm-pulse .5s ease-in-out 6; }
@keyframes tm-pulse { 50% { transform: scale(1.04); } }
.tm.last .tm-num { animation: tm-tick .9s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes tm-tick { 0% { transform: scale(1.35); fill: #ffd54a; } 100% { transform: scale(1); } }
.tm-prw { align-items: flex-start; }
.tm-pre { flex-wrap: wrap; justify-content: center; max-width: 250px; }
.tm-pre button { width: 40px; }
.tm-cust { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.tm-cust input { width: 70px; height: 32px; padding: 0 8px; border: 2px solid #235b88; border-radius: 9px; font-size: 15px; font-weight: 800; color: #235b88; text-align: center; background: #fff; }
.tm-cust .ok { min-height: 32px; padding: 0 12px; border: 0; border-radius: 9px; background: #2b73a3; color: #fff; font-weight: 800; box-shadow: none; }
.tm-svg { max-height: 235px; margin: 0 auto; }
.tm-cust input { width: 74px; }
.tm-cust b { font-size: 18px; }
.tm-pre button { width: 44px; font-size: 13px; }

/* real-device buttons on the stopwatch */
.tm-crown, .tm-side { cursor: pointer; }
.tm-crown, .tm-side .pb { transition: transform .06s, filter .12s; }
.tm-crown:hover, .tm-side:hover .pb { filter: brightness(1.18); }
.tm-crown.down { transform: translateY(5px); }
.tm-side.down .pb { transform: translateY(5px); }
.tm-hint { font-size: 11px; font-weight: 700; opacity: .75; margin: 2px 0 4px; line-height: 1.5; }
.tm-svg { max-height: 310px; }
.tm-more[hidden] { display: none; }
.tm-morebtn { margin-top: 8px; min-height: 28px; padding: 2px 14px; border: 0; border-radius: 99px; background: transparent; color: #2b73a3; font-weight: 800; font-size: 12px; box-shadow: none; }
.tm-more { margin-top: 6px; }
.tm-core { cursor: pointer; transition: fill .12s; }
.tm-core:hover { fill: rgba(255,255,255,.12); }
.tm-core.down { fill: rgba(0,0,0,.18); }
.tm-state { pointer-events: none; }
.tm-svg { max-height: 330px; }
.tm-morebtn { width: 34px; height: 34px; min-height: 0; padding: 0; margin: 2px auto 0; border-radius: 50%; font-size: 18px; color: #7fa3c1; display: block; }
.tm-morebtn.on, .tm-morebtn:hover { background: #e3eff8; color: #235b88; }
.tm-dig { margin: 0; }
.sp-bar[hidden] { display: none; }
.sp-gear { position: absolute; right: 8px; bottom: 6px; z-index: 4; width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #cfd8e3; font-size: 17px; box-shadow: none; }
.sp-gear:hover, .sp-gear.on { background: #ee0000; color: #fff; }
.sp-bar { padding-right: 4px; }
.sp-dvd { background: #1c7ed6 !important; }
.pp-all { max-height: 100%; overflow: auto; }
.pp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(30cqw, 1fr)); gap: 1.6cqmin; margin: 1.5cqmin 0 2cqmin; text-align: left; }
.pp-g { background: #fff; border: 2px solid #0f5173; border-radius: 10px; padding: .6em .8em; }
.pp-g b { color: #ee0000; font-size: clamp(12px, 3.8cqw, 22px); }
.pp-g ul { list-style: none; margin: .3em 0 0; padding: 0; font-size: clamp(11px, 3.3cqw, 19px); font-weight: 700; color: #0f5173; line-height: 1.5; }

/* group pop-ups: bigger names */
.pp-grid { grid-template-columns: repeat(auto-fit, minmax(38cqw, 1fr)); }
.pp-g { padding: .7em .9em; }
.pp-g b { font-size: clamp(16px, 5.4cqw, 32px); }
.pp-g ul { font-size: clamp(16px, 5cqw, 30px); line-height: 1.55; }
.pp-g li { overflow-wrap: anywhere; }
.pp-mem { gap: 1.4cqmin 2.2cqw; font-size: clamp(16px, 6cqw, 36px); }
.pp-mem li { padding: .35em .9em; }
.pp-all .pp-k { font-size: clamp(16px, 5cqw, 30px); }

/* group pop-up in the khmermath.org name-wheel style */
.pp-card.pp-all { padding: 0 0 3cqmin; background: linear-gradient(180deg, #eaf5f2, #fdf6e8); border: .8cqmin solid #1f6f66; overflow: auto; }
.pp-ban { background: linear-gradient(100deg, #1f6f66, #2d8f7e 60%, #3aa68f); color: #fff; padding: 2.4cqmin 3cqw; display: flex; flex-direction: column; gap: .3em; }
.pp-ban b { font-size: clamp(18px, 6.4cqw, 38px); font-weight: 800; }
.pp-ban small { font-size: clamp(12px, 3.6cqw, 20px); opacity: .92; font-weight: 600; }
.pp-all .pp-grid { padding: 0 3cqw; margin: 2cqmin 0; }
.pp-g { border: 0; border-radius: 14px; padding: 0; overflow: hidden; background: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.14); }
.pp-gh { display: flex; justify-content: space-between; align-items: center; padding: .55em .9em; background: var(--c, #1f6f66); color: #fff; }
.pp-gh b { color: #fff; font-size: clamp(16px, 5.2cqw, 30px); }
.pp-gh span { font-size: clamp(12px, 3.6cqw, 20px); opacity: .92; font-weight: 600; }
.pp-g ol { margin: 0; padding: .5em .8em .6em 2.2em; font-size: clamp(16px, 5cqw, 30px); font-weight: 700; color: #1b2733; line-height: 1.6; }
.pp-g ol li::marker { color: var(--c, #1f6f66); font-weight: 800; }
.pp-brand { text-align: center; color: #1f6f66; font-weight: 800; font-size: clamp(11px, 3cqw, 17px); margin-bottom: 1.5cqmin; }
.pp-all .pp-act { padding: 0 3cqw; }
.pp-png { background: #1f6f66; color: #fff; }
.pp-copy { background: #1c7ed6; color: #fff; }
.pp-card:not(.pp-all) .pp-act button.pp-png, .pp-card:not(.pp-all) .pp-act button.pp-copy { font-size: clamp(11px, 3.3cqw, 18px); }
.sp-pop.big { inset: 3%; }
.pp-card.pp-all { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.pp-all .pp-grid { overflow: auto; flex: 1; min-height: 0; align-content: start; }
.pp-all .pp-ban, .pp-all .pp-brand, .pp-all .pp-act { flex: none; }
.pp-all .pp-act { gap: 6px; }
.pp-all .pp-act button { font-size: clamp(11px, 2.9cqw, 16px); padding: .45em 1em; }
.pp-ban b { font-size: clamp(16px, 5cqw, 30px); }
.pp-ban { padding: 1.6cqmin 3cqw; }
.pp-all .pp-brand { display: none; }
.pp-all .pp-grid { grid-auto-rows: max-content; }
.pp-grid.count-1 { grid-template-columns: minmax(0, 360px); justify-content: center; }
.pp-grid.count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pp-grid.count-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pp-grid.count-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pp-grid.count-5 { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.6cqmin; }
.pp-grid.count-5 > .pp-g { flex: 0 1 calc(33.333% - 1.2cqmin); min-width: 220px; }
.pp-grid.count-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pp-grid.count-7 { display: flex; flex-wrap: wrap; justify-content: center; }
.pp-grid.count-7 > .pp-g { flex: 0 1 calc(25% - 1.2cqmin); min-width: 220px; }
.pp-grid.count-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pp-grid.count-9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pp-grid.count-10 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pp-grid.count-11 { display: flex; flex-wrap: wrap; justify-content: center; }
.pp-grid.count-11 > .pp-g { flex: 0 1 calc(25% - 1.2cqmin); min-width: 200px; }
.pp-grid.count-12 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* group reveal animation + full screen */
.pp-g.wait { opacity: .4; transform: scale(.97); }
.pp-g { transition: opacity .3s, transform .3s, box-shadow .3s; }
.pp-g.active { opacity: 1; transform: scale(1.03); box-shadow: 0 0 0 4px var(--c), 0 12px 28px rgba(0,0,0,.3); }
.pp-g.active li { animation: pp-flick .12s steps(2) infinite; }
@keyframes pp-flick { 50% { opacity: .55; } }
.pp-g.done { animation: pp-lock .5s cubic-bezier(.2,1.6,.3,1); }
@keyframes pp-lock { from { transform: scale(1.1); } to { transform: scale(1); } }
.pp-g li.ph { list-style: none; color: #b3bcc6; letter-spacing: 3px; }
.pp-ban { position: relative; }
.pp-fs { position: absolute; right: 2cqw; top: 1.6cqmin; width: 40px; height: 36px; min-height: 0; padding: 0; border-radius: 10px; border: 0; background: rgba(255,255,255,.22); color: #fff; font-size: 20px; box-shadow: none; }
.pp-fs:hover { background: rgba(255,255,255,.4); }
.pp-skip { background: #ee0000; color: #fff; }
.ts-float:fullscreen { left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; border-radius: 0 !important; max-width: none; }
.ts-float:fullscreen .ts-fbar, .ts-float:fullscreen .ts-rs { display: none; }
.ts-float:fullscreen .ts-fin { height: 100%; }
.ts-float:-webkit-full-screen { left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; border-radius: 0 !important; }
/* group pop-up full screen (separate from the Spin window) */
.sp-fsroot { position: fixed; inset: 0; z-index: 400; background: #0b2230; container-type: size; }
.sp-fsroot .sp-pop { inset: 2.5%; }
.sp-fsroot .pp-card.pp-all { height: 100%; }
.sp-fsroot .sp-fw { position: absolute; inset: 0; width: 100%; height: 100%; }

/* vanishIn / vanishOut for the pop-ups */
.sp-pop { animation: none; }
.vin { animation: tsVanishIn .5s ease-out backwards; }
.vout { animation: tsVanishOut .42s ease-in forwards; }
@keyframes tsVanishIn { 0% { opacity: 0; transform: scale(2); filter: blur(36px); } 100% { opacity: 1; transform: scale(1); filter: blur(0); } }
@keyframes tsVanishOut { 0% { opacity: 1; transform: scale(1); filter: blur(0); } 100% { opacity: 0; transform: scale(2); filter: blur(36px); } }
@media (prefers-reduced-motion: reduce) { .vin, .vout { animation: none; } }

/* ===== Calculator ===== */
.ts-wcalc .ts-fin { padding: 0; }
.cl { background: linear-gradient(160deg, #3f93bd, #21588a); padding: 10px; outline: none; color: #fff; }
.cl-screen { background: #eaf3f9; color: #12324d; border-radius: 12px; padding: 8px 12px; text-align: right; min-height: 78px; display: flex; flex-direction: column; justify-content: flex-end; box-shadow: inset 0 3px 8px rgba(0,0,0,.18); overflow: hidden; }
.cl-expr { font-size: 15px; opacity: .7; min-height: 20px; word-break: break-all; line-height: 1.3; }
.cl-res { font-size: 34px; font-weight: 800; line-height: 1.2; overflow-x: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cl-res.err { color: #c92a2a; font-size: 24px; }
.cl-mode { display: flex; gap: 6px; margin: 8px 0 2px; }
.cl button { min-height: 0; border: 0; box-shadow: none; font-weight: 800; color: #12324d; background: #fff; border-radius: 12px; font-size: 20px; height: 46px; padding: 0; transition: transform .05s, filter .12s; }
.cl button:hover { filter: brightness(.93); } .cl button:active { transform: translateY(2px); }
.cl-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 8px; }
.cl-pad .fn { background: #cfe3f1; } .cl-pad .op { background: #2a6b99; color: #fff; } .cl-pad .eq { background: #f0a30a; color: #fff; }
.cl-sci { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.cl-sci[hidden] { display: none; }
.cl-sci button { height: 38px; font-size: 16px; background: #dcebf6; }
.cl-mode .tg { height: 30px; width: auto; padding: 0 14px; font-size: 13px; background: rgba(255,255,255,.2); color: #fff; }
.cl-mode .tg.on { background: #fff; color: #235b88; }
.cl-pad .op { background: #0f4468; color: #fff; font-size: 24px; }

/* calculator scales with its window: drag a corner and the keys and numbers zoom with it */
.ts-wcalc .ts-fin { container-type: inline-size; }
.cl { font-size: 5.33cqw; padding: .625em; }
.cl-screen { border-radius: .75em; padding: .5em .75em; min-height: 4.9em; }
.cl-expr { font-size: .94em; min-height: 1.25em; }
.cl-res { font-size: 2.1em; }
.cl-res.err { font-size: 1.5em; }
.cl-mode { gap: .4em; margin: .5em 0 .15em; }
.cl button { font-size: 1.25em; height: 2.3em; border-radius: .6em; }
.cl-pad { gap: .45em; margin-top: .5em; }
.cl-pad .op { font-size: 1.5em; }
.cl-sci { gap: .4em; margin-top: .5em; }
.cl-sci button { height: 2.1em; font-size: 1em; }
.cl-mode .tg { height: 1.9em; padding: 0 .9em; font-size: .82em; }

/* geometry: move / rotate / zoom handles and draw-along-edge */
.ts-inst button { transform: scale(var(--inv, 1)); transform-origin: center; }
.ts-imv, .ts-isc, .ts-ied { position: absolute; width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 50%; border: 0; background: #0f5173; color: #fff; font-size: 15px; box-shadow: 0 3px 8px rgba(0,0,0,.35); z-index: 10; transition: transform .12s, box-shadow .12s; }
.ts-imv { left: 50%; top: -54px; margin-left: -15px; cursor: move; }
.ts-isc { right: -16px; bottom: -54px; cursor: nwse-resize; }
.ts-ied { left: -16px; bottom: -54px; background: #2b73a3; }
.ts-inst.edge .ts-ied { background: #ee0000; }
.ts-inst.edge { cursor: crosshair; }

/* Geometry: pen row, protractor readout, compass */
.gpen { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.ts-geo .gt { flex: 1 1 auto; justify-content: center; padding: 7px 10px; font-size: 13px; font-weight: 800; }
.ts-geo .gt.on { background: #ee0000; }
.gcol { display: flex; gap: 6px; flex: 1 0 100%; }
.ts-geo .gc { width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%; border: 2px solid #fff; flex: none; }
.gpen input[type=range] { flex: 1 0 100%; accent-color: #1c7ed6; }
.ts-ibadge { position: absolute; z-index: 5; pointer-events: none; background: #0f5173; color: #fff; font-weight: 800; font-size: 16px; padding: 2px 10px; border-radius: 99px; box-shadow: 0 3px 8px rgba(0,0,0,.35); white-space: nowrap; }
.ts-ibadge[hidden] { display: none; }
.ts-cmp { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
.ts-cmp svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.ts-ch { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; min-height: 0; padding: 0; border-radius: 50%; border: 3px solid #fff; background: #0f5173; color: #fff; font-size: 16px; font-weight: 800; box-shadow: 0 3px 8px rgba(0,0,0,.4); pointer-events: auto; touch-action: none; cursor: grab; }
.ts-ch.q { background: #ee0000; }
.ts-ch.h { background: #2b73a3; }
.ts-ch.x { background: #6b7a89; width: 26px; height: 26px; margin: -13px 0 0 -13px; font-size: 12px; }
.gpen .gl { flex: 1 0 100%; font-size: 12px; font-weight: 800; color: #9fd0f5; }
.ts-geo .gc.on { outline: 3px solid #fff; outline-offset: 1px; }

/* small clock in the corner of the slide */
.ts-clock { position: absolute; left: 12px; top: 12px; z-index: 7; min-height: 0; height: 34px; padding: 0 12px; border: 0; border-radius: 99px; background: rgba(15,81,115,.88); color: #fff; font-size: 17px; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.28); cursor: pointer; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.ts-clock b { font-weight: 800; letter-spacing: .04em; }
.ts-clock.off { width: 34px; padding: 0; background: rgba(15,81,115,.35); font-size: 16px; }
.ts-clock:hover { background: #ee0000; }
.ts-clock i { font-style: normal; font-size: 12px; font-weight: 800; margin-left: 5px; opacity: .85; }

/* ===== key slides (ជាទូទៅ, និយមន័យ, សម្គាល់, ចំណាំ, រូបមន្ត, ទ្រឹស្តីបទ…): dark rounded card with a gold title ===== */
.ts-slide.ts-key { background: #fff; outline: none; box-shadow: none; padding: 36px 48px 48px 48px; }
.ts-card { background: linear-gradient(120deg, #1d2f48 0%, #264a5d 55%, #2f5a64 100%); color: #fff; border-radius: 30px; padding: .9em 1.3em 1em; box-shadow: 0 18px 36px rgba(20,40,60,.28); }
.ts-card-h { display: flex; align-items: center; gap: .7em; margin-bottom: .55em; }
.ts-card-h span { color: #ffd98a; font-family: 'Times New Roman', 'Khmer M1', 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-weight: 800; font-size: 1.25em; line-height: 1.3; white-space: nowrap; }
.ts-card-h i { flex: 1; height: 2px; background: linear-gradient(90deg, rgba(214,186,120,.95), rgba(214,186,120,0)); border-radius: 2px; }
.ts-card-b { color: #fff; font-size: 1em; }
.ts-card-b p { margin: 0 0 .5em; }
.ts-card-b li::marker { color: #ffd98a; }
.ts-card-b th, .ts-card-b td { border-color: rgba(255,255,255,.45); }
.ts-card-b th { background: rgba(255,255,255,.12); }
.ts-card-b blockquote { background: rgba(255,255,255,.1); border-left-color: #ffd98a; }
.ts-card-b .katex { color: #fff; }
.ts-card-b blockquote { background: none; border: 0; padding: 0; margin: 0 0 .4em; border-radius: 0; }
.ts-card-h span { font-family: 'Kantumruy Pro', 'Noto Sans Khmer', sans-serif; font-weight: 800; letter-spacing: 0; }

/* all slide headings use the same rounded Kantumruy Pro bold */
.ts-slide h1, .ts-slide h2, .ts-slide .ts-kicker, .ts-slide .ts-exh { font-family: 'Kantumruy Pro', 'Noto Sans Khmer', sans-serif; font-weight: 800; }
/* part title above the dark card: same deep teal-navy as the card */
.ts-slide .ts-kicker { color: #22475c; }
.ts-slide.ts-title .ts-kicker { color: #22475c; }

/* the term being defined: gold, bold, glowing pill */
.ts-card-b mark.term, .ts-card-b b { background: linear-gradient(180deg, rgba(255,217,138,.10), rgba(255,217,138,.28)); color: #ffd98a; font-weight: 800; padding: .02em .32em .06em; margin: 0 .08em; border-radius: .42em; border-bottom: .12em solid #ffd98a; }
.ts-card-b mark.term { animation: none; }   /* no glow / pulse ring on the defined term */
@keyframes tsTerm { 0% { box-shadow: 0 0 0 0 rgba(255,217,138,.9); } 70% { box-shadow: 0 0 0 .5em rgba(255,217,138,0); } 100% { box-shadow: 0 0 0 1px rgba(255,217,138,.25); } }
@media (prefers-reduced-motion: reduce) { .ts-card-b mark.term { animation: none; } }

/* ===== hand-designed lesson slides: figures, column arithmetic, tables, chips ===== */
.ts-slide .fig { margin: .4em auto .5em; text-align: center; }
.ts-slide .fig > svg { width: 100%; height: auto; display: block; margin: 0 auto; }   /* direct child only: the maths inside a picture has its own svg (radical sign) */
.ts-slide .cap { font-size: .7em; color: #4a6477; font-weight: 700; margin-top: .15em; }
.ts-slide .dm { margin: .2em 0; }
.ts-slide .chip { display: inline-block; padding: .08em .6em; border-radius: 99px; font-weight: 800; }
.ts-slide .ok { color: #2f9e44; font-weight: 800; } .ts-slide .no { color: #e03131; font-weight: 800; }
.ts-slide table.col { margin: .3em auto; border-collapse: collapse; font-size: 1.5em; font-variant-numeric: tabular-nums; }
.ts-slide table.col td { border: 0; padding: .02em .28em; text-align: center; min-width: 1.05em; line-height: 1.15; }
.ts-slide table.col td.op { color: #e03131; font-weight: 800; }
.ts-slide table.col tr.carry td { font-size: .55em; color: #e03131; font-weight: 800; height: 1.1em; padding-bottom: 0; }
.ts-slide table.col tr.carry td.bw { color: #1c7ed6; }
.ts-slide table.col tr.sum td { border-top: 3px solid #1f4a5f; color: #2f9e44; font-weight: 800; }
.ts-slide table.pv { margin: .2em auto; border-collapse: collapse; font-size: 1em; }
.ts-slide table.pv th { background: #1f4a5f; color: #fff; padding: .1em .55em; font-size: .62em; border: 2px solid #fff; }
.ts-slide table.pv td { border: 3px solid #1f4a5f; padding: .05em .5em; font-size: 1.5em; text-align: center; font-weight: 800; background: #fff; }
.ts-slide table.tbl { margin: .4em auto; border-collapse: collapse; }
.ts-slide table.tbl th { background: #1f4a5f; color: #fff; padding: .25em .8em; border: 2px solid #1f4a5f; }
.ts-slide table.tbl td { border: 2px solid #1f4a5f; padding: .2em .8em; text-align: center; }
.ts-slide table.tbl.sm td:first-child { text-align: left; font-weight: 800; color: #1f4a5f; }
.ts-slide table.tbl.sm td { text-align: left; font-size: .9em; }
.ts-slide .rr { display: flex; align-items: center; gap: 1em; margin: .35em 0; flex-wrap: wrap; }
.ts-slide .rr .rt { flex: 1; min-width: 14em; }
.ts-slide .keys { margin: .3em 0 .5em; display: flex; flex-wrap: wrap; gap: .25em; }
.ts-slide .keys .k { background: #eaf1f6; border: 2px solid #1f4a5f; border-bottom-width: 5px; border-radius: .35em; padding: 0 .55em; min-width: 1.6em; text-align: center; font-weight: 800; color: #1f4a5f; }
.ts-slide .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); gap: .8em; align-items: start; }
.ts-card-b .fig .cap { color: #cfe3f0; }
.ts-card-b b, .ts-card-b mark.term { color: #ffd98a !important; }
.ts-card-b table.tbl th { background: rgba(255,255,255,.16); color: #ffd98a; border-color: rgba(255,255,255,.4); }
.ts-card-b table.tbl td { border-color: rgba(255,255,255,.4); color: #fff; }
.ts-card-b table.tbl.sm td:first-child { color: #ffd98a; }

/* ---- step-by-step reveal (data-step / data-until, see teachshow.js) ---- */
.ts-slide [data-step], .ts-slide [data-until] { transition: opacity .45s ease, transform .45s ease; }
.ts-slide .rv-hide { opacity: 0 !important; visibility: hidden; pointer-events: none; }
.ts-slide div.rv:not(.rv-hide) { animation: tsRise .45s ease both; }
@keyframes tsRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ts-slide [data-step], .ts-slide [data-until] { transition: none; } .ts-slide div.rv:not(.rv-hide) { animation: none; } }
/* drawing animations inside the pictures (the pencil that draws a line, the pencil that makes a point): they start the moment their step is revealed */
@keyframes penDraw { from { stroke-dashoffset: var(--len, 600); } to { stroke-dashoffset: 0; } }
@keyframes penMove { from { transform: translate(0, 0); } to { transform: translate(var(--dx, 600px), var(--dy, 0px)); } }
@keyframes penDown { from { transform: translate(0, var(--dy, -120px)); } to { transform: translate(0, 0); } }
@keyframes dotPop { 0%, 78% { transform: scale(0); } 100% { transform: scale(1); } }
.ts-slide .rv-hide [class*="pen-"] { animation: none !important; }          /* while hidden nothing runs, so the animation begins again each time the step appears */
@keyframes penPop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes penLate { from { opacity: 0; } to { opacity: 1; } }
@keyframes penIn { from { transform: translate(var(--dx, 0px), var(--dy, 0px)); } to { transform: translate(0, 0); } }
@keyframes penSpin { from { transform: rotate(0deg); } to { transform: rotate(var(--rot, 360deg)); } }
@keyframes penTwinkle { from { opacity: .25; } to { opacity: 1; } }
@keyframes penWave { from { transform: translateX(-6px); } to { transform: translateX(6px); } }
@keyframes penSlide { from { transform: translateX(0); } to { transform: translateX(70px); } }
.ts-slide .pen-slide { animation: penSlide 2.4s ease-in-out infinite alternate; }
.ts-slide .pen-pop { transform-box: fill-box; transform-origin: center; animation: penPop .4s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--d, .4s); }
.ts-slide .pen-spin { transform-box: fill-box; transform-origin: center; }
.ts-slide .pen-twinkle { animation: penTwinkle 2.2s ease-in-out infinite alternate; }
.ts-slide .pen-wave { animation: penWave 2.6s ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) { .ts-slide [class*="pen-"] { animation: none !important; stroke-dashoffset: 0 !important; transform: none !important; } }
/* reveal chips for the new Section 4 pictures */
.ts-slide .stepcard { display: inline-block; margin: .2em .35em; padding: .25em .8em; border-radius: .6em; font-weight: 800; }
.ts-slide .stepcard.a { background: #dbeafe; color: #1f4a5f; border: 2px solid #1c7ed6; }
.ts-slide .stepcard.b { background: #fff3cf; color: #7a4a00; border: 2px solid #f0a30a; }
.ts-slide .stepcard.ok { background: #d3f9d8; color: #14532d; border: 2px solid #2f9e44; }
.ts-slide .stepcard.no { background: #ffe3e3; color: #7f1d1d; border: 2px solid #e03131; }
.ts-slide .capstack { display: grid; margin-top: .3em; text-align: center; font-weight: 700; }
.ts-slide .capstack > div { grid-area: 1 / 1; align-self: center; animation: none; }

/* page counter and slide pointer navigation capsule: bottom-right corner */
.ts-stage .ts-nav {
  position: absolute; right: 14px; bottom: 14px; z-index: 100;
  display: flex; align-items: center; flex-wrap: nowrap; gap: 4px; padding: 4px 6px;
  border-radius: 99px; background: rgba(30, 41, 59, 0.90);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42), 0 2px 6px rgba(0, 0, 0, 0.25);
  color: #fff; opacity: 0.92;
  transition: opacity .18s cubic-bezier(.2, .8, .2, 1), transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .15s;
  user-select: none; touch-action: none;
}
.ts-stage .ts-nav.dragging {
  opacity: 1; transform: scale(1.04);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
  cursor: grabbing;
}
.ts-nav-grip {
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px 0 2px; height: 26px; cursor: grab;
  color: #6f7684; touch-action: none;
}
.ts-nav-grip .gl { display: grid; grid-template-columns: repeat(2, 3px); gap: 3px; }
.ts-nav-grip .gl i { width: 3px; height: 3px; border-radius: 50%; background: #6f7684; display: block; }
.ts-nav-grip:hover .gl i, .ts-nav.dragging .ts-nav-grip .gl i { background: #ffffff; }
.ts-stage .ts-nav:hover, .ts-stage .ts-nav:focus-within { opacity: 1; }
.ts-stage .ts-nav button {
  min-height: 0; width: 44px; height: 38px; padding: 0; border: 0;
  border-radius: 99px; background: rgba(255, 255, 255, 0.12); color: #fff;
  font-size: 20px; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, transform .1s, box-shadow .12s;
}
.ts-stage .ts-nav button:hover {
  background: #0e72ed; color: #fff; box-shadow: 0 2px 8px rgba(14, 114, 237, 0.5); transform: scale(1.08);
}
.ts-stage .ts-nav button:active { background: #0b5ecc; transform: scale(0.92); }
.ts-stage .ts-nav .ts-page {
  min-width: 0; padding: 0 10px; font-size: 15px; font-weight: 700;
  white-space: nowrap; letter-spacing: 0.02em; color: #f1f5f9; cursor: pointer;
}
.ts-stage .ts-nav .ts-page:hover { color: #60a5fa; }

/* the column being added / subtracted is tinted while its step shows */
.ts-slide table.col td.rv-on { background: #fff3cf; border-radius: .25em; }

/* live marbles widget (slide: 5.2 practice) */
.ts-slide .mb-wrap { min-height: 38vh; }
.ts-slide .mb-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .35em; margin-bottom: .4em; }
.ts-slide .mb-chip { min-height: 0; padding: .1em .7em; border-radius: 99px; border: 2px solid #1c7ed6; background: #fff; color: #1c7ed6; font: 800 .8em/1.5 inherit; cursor: pointer; }
.ts-slide .mb-chip.on { background: #1c7ed6; color: #fff; }
.ts-slide .mb-body { display: flex; align-items: center; justify-content: center; gap: 1.2em; flex-wrap: wrap; }
.ts-slide .mb-cv { width: min(38vh, 330px); height: min(38vh, 330px); aspect-ratio: 1; }
.ts-slide .mb-side { text-align: left; font-size: .8em; line-height: 1.6; min-width: 12em; }
.ts-slide .mb-side b { color: #1f4a5f; }
.ts-slide .mb-v { margin-top: .2em; padding: .1em .6em; border-radius: .6em; font-weight: 800; display: inline-block; }
.ts-slide .mb-v.ok { background: #d3f9d8; color: #14532d; border: 2px solid #2f9e44; }
.ts-slide .mb-v.no { background: #ffe3e3; color: #7f1d1d; border: 2px solid #e03131; }
.ts-slide .mb-ctl { display: flex; gap: .5em; margin-top: .5em; flex-wrap: wrap; }
.ts-slide .mb-btn { min-height: 0; padding: .15em .8em; border-radius: .6em; border: 0; background: #1f4a5f; color: #fff; font: 800 .85em/1.5 inherit; cursor: pointer; }
.ts-slide .mb-btn.go { background: #2f9e44; }
.ts-slide .mb-btn.go.on { background: #e03131; }

/* "≠" / \not signs are drawn from a private-use glyph (U+E020) of KaTeX_Main; 'Mathcad UniMath' has another glyph there (a box) */
.ts-slide .katex .thinbox, .ts-slide .katex .thinbox *, .ts-slide .katex .mrel:has(.thinbox), .ts-slide .katex .mrel:has(.thinbox) * { font-family: KaTeX_Main, 'Times New Roman', serif; }

/* merged slides: a later part (an extra example, or a key card) rises in below the first part */
.ts-slide .mg { margin-top: .5em; }
.ts-slide .mg-h { margin: 0 0 .3em; color: #ee0000; font-weight: 800; font-size: 1.05em; border-top: 2px dashed rgba(15,81,115,.35); padding-top: .35em; }
.ts-slide.ts-key .mg-h { color: #ffd98a; border-top-color: rgba(255,255,255,.4); }
.ts-slide .mg > .ts-card { font-size: .92em; }

/* calculator: pink, no title bar (drag it by its body; Tools → Calculator or leaving the slide puts it away) */
.ts-wcalc { background: transparent; border: 0; border-radius: 22px; box-shadow: 0 14px 34px rgba(150, 20, 80, .35); cursor: grab; }
.ts-wcalc .ts-fbar { display: none; }
.cl { background: linear-gradient(160deg, #ff9ec4, #e0457b); }
.cl-screen { background: #fff1f7; color: #5a1030; box-shadow: inset 0 3px 8px rgba(120, 10, 60, .2); }
.cl button { color: #5a1030; background: #fff; cursor: pointer; }
.cl-pad .fn { background: #ffd3e4; }
.cl-pad .op { background: #c2255c; color: #fff; }
.cl-pad .eq { background: #7b1246; color: #fff; }
.cl-sci button { background: #ffe3ee; }
.cl-mode .tg { background: rgba(255,255,255,.3); color: #fff; }
.cl-mode .tg.on { background: #fff; color: #c2255c; }
.ts-wcalc .ts-rs { background: linear-gradient(135deg, transparent 50%, #fff 50%); opacity: .8; }
.ts-stage { overscroll-behavior: contain; }

/* a table inside a dark key card keeps its dark look when the mouse is over a row (it went white-on-white) */
.ts-card-b table tr:hover, .ts-card-b table tr:hover td, .ts-card-b table tr:hover th { background: rgba(255,255,255,.14) !important; color: inherit; }

/* worked answers written one step per line: the label (ក. ខ. ...) sits beside the working, equals signs line up, left-aligned */
.ts-slide ul.ts-bullets > li:has(> .cl-lab) { display: flex; gap: .6em; align-items: flex-start; margin: .35em 0; }
.ts-slide ul.ts-bullets > li > .cl-lab { flex: none; font-weight: 800; padding-top: .25em; }
.ts-slide ul.ts-bullets > li > .dm { margin: 0; flex: 1; text-align: left; }
.ts-slide ul.ts-bullets > li > .dm .katex-display { margin: 0; text-align: left; }
.ts-slide ul.ts-bullets > li > .dm .katex-display > .katex { text-align: left; }

/* calculator, softer: pale pink, a slim header (to drag it by, with a ✕), body still draggable */
.ts-wcalc { box-shadow: 0 12px 30px rgba(120, 50, 80, .22); }
.ts-wcalc .ts-fbar { display: flex; padding: 2px 4px 2px 12px; min-height: 0; background: #f6c9d9; color: #7a2c4a; cursor: grab; }
.ts-wcalc .ts-fbar b { display: none; }
.ts-wcalc .ts-fbar::before { content: '⋮⋮'; letter-spacing: -2px; font-weight: 800; opacity: .55; }
.ts-wcalc .ts-fx { min-height: 28px !important; width: 28px; color: #7a2c4a; font-size: 16px; }
.ts-wcalc .ts-fx:hover { background: rgba(255,255,255,.6) !important; }
.cl { background: linear-gradient(160deg, #fdeaf1, #f4c1d3); color: #4a1d33; }
.cl-screen { background: #fff; color: #4a1d33; box-shadow: inset 0 2px 6px rgba(120, 50, 80, .12); }
.cl button { color: #4a1d33; background: #fff; }
.cl-pad .fn { background: #fbdce8; }
.cl-pad .op { background: #d98aa8; color: #fff; }
.cl-pad .eq { background: #b85c82; color: #fff; }
.cl-sci button { background: #fdeaf2; }
.cl-mode .tg { background: rgba(255,255,255,.65); color: #8a3a5d; }
.cl-mode .tg.on { background: #fff; color: #b85c82; }
/* the two corner resize handles stay (cursor + hit area) but draw nothing: the wedge was clipped by the rounded corner and looked like a glitch */
.ts-wcalc .ts-rs, .ts-wcalc .ts-rl { background: none; width: 22px; height: 22px; right: 0; bottom: 0; }
.ts-wcalc .ts-rl { left: 0; right: auto; }
.ts-wcalc .ts-fx { color: #5a1030; font-size: 20px; font-weight: 800; opacity: 1; }
.ts-wcalc .ts-fbar::before { opacity: .8; color: #7a2c4a; }

/* ---- cover slide of a lesson: school logo + name on top, teacher / class / school year at the bottom ---- */
.ts-cover .cv-brand { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 0 0 8px; margin: 0 auto 8px; border-bottom: 3px solid #0f5173; }
.ts-cover .cv-logo { width: clamp(52px, 8vh, 84px); height: clamp(52px, 8vh, 84px); flex: none; }
.ts-cover .cv-school { text-align: left; line-height: 1.35; }
.ts-cover .cv-school b { display: block; color: #0f5173; font-family: 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-size: 1.12em; font-weight: 700; }
.ts-cover .cv-school span { display: block; color: #ee0000; font-weight: 800; font-size: .86em; }
.ts-cover .cv-foot { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 12px auto 0; }
.ts-cover .cv-foot > div { background: #0f5173; color: #fff; border-radius: 12px; padding: 5px 20px 6px; text-align: left; min-width: 9em; }
.ts-cover .cv-foot small { display: block; font-size: .6em; opacity: .8; line-height: 1.2; }
.ts-cover .cv-foot b { font-size: .95em; color: #fff; font-weight: 800; }

/* ---- slide 1 of a lesson: the school, the teacher, the class and the school year ---- */
.ts-slide.ts-brand { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-right: 48px; }
.ts-brand .bd-logo { width: clamp(130px, 30vh, 250px); height: auto; margin-bottom: 14px; }
.ts-brand .bd-name { color: #0f5173; font-family: 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-size: clamp(30px, 4.6vw, 58px); font-weight: 700; line-height: 1.35; }
.ts-brand .bd-sub { color: #ee0000; font-weight: 800; font-size: clamp(20px, 2.8vw, 34px); margin-top: 2px; }
.ts-brand .bd-info { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: clamp(16px, 4vh, 36px); }
.ts-brand .bd-info > div { background: #0f5173; color: #fff; border-radius: 14px; padding: 8px 26px 10px; text-align: left; min-width: 10em; }
.ts-brand .bd-info small { display: block; font-size: .62em; opacity: .8; line-height: 1.2; }
.ts-brand .bd-info b { font-size: 1em; color: #fff; font-weight: 800; }

/* last slide: "thank you" */
.ts-slide .th-you { margin-top: .45em; color: #ee0000; font-family: 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-size: clamp(40px, 7vw, 90px); font-weight: 700; line-height: 1.35; }

/* ---- Problem card (Tools -> កាតលំហាត់): a card over the slide to write a new problem on ---- */
.ts-wcard { background: #fffdf6; border: 4px solid #f0a30a; color: #1f2933; border-radius: 20px; box-shadow: 0 18px 44px rgba(0,0,0,.35); z-index: 9; }
.ts-wcard .ts-fbar { background: #f0a30a; color: #fff; }
.ts-wcard .ts-fin { padding: 0; display: flex; overflow: hidden; }
.ts-wcard.full { left: 2% !important; top: 2% !important; width: 96% !important; height: 96% !important; }
.cd { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; padding: 10px 16px 12px; gap: 8px; }
.cd-title { border: 0; border-bottom: 3px solid #ee0000; background: transparent; color: #ee0000; font: 800 30px/1.35 'Kantumruy Pro', 'Khmer OS Muol Light', serif; padding: 2px 4px; outline: none; width: 100%; }
.cd-edit, .cd-view { flex: 1; min-height: 0; width: 100%; border: 0; outline: none; resize: none; background: transparent; color: #0f2a3a; font-family: 'Times New Roman', 'Kantumruy Pro', serif; line-height: 1.6; padding: 4px; overflow: auto; white-space: pre-wrap; }
.cd-edit[hidden], .cd-view[hidden] { display: none; }
.cd-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.cd-btn { min-height: 0; padding: 4px 12px; border-radius: 10px; border: 0; background: #0f5173; color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.cd-btn:hover { background: #ee0000; }

/* the card's own fields must not take the page's default input look */
.ts-wcard .cd-title { border: 0 !important; border-bottom: 3px solid #ee0000 !important; border-radius: 0 !important; background: transparent !important; color: #ee0000 !important; font-size: 30px !important; font-weight: 800 !important; box-shadow: none !important; height: auto !important; min-height: 0 !important; padding: 2px 4px !important; }
.ts-wcard .cd-edit { border: 0 !important; box-shadow: none !important; background: transparent !important; color: #0f2a3a !important; }

/* ---- download dialog ---- */
.ts-exp { position: fixed; inset: 0; z-index: 70; background: rgba(15, 40, 60, .55); display: grid; place-items: center; }
.ts-exp-card { background: #fff; color: #0f2a3a; border-radius: 18px; padding: 20px 26px 22px; width: min(560px, 92vw); box-shadow: 0 24px 60px rgba(0,0,0,.4); font-family: 'Kantumruy Pro', 'Khmer OS Battambang', system-ui, sans-serif; font-size: 16px; line-height: 1.5; }
.ts-exp-card h3 { margin: 0 0 8px; color: #ee0000; font-size: 1.5em; }
.ts-exp-l { display: block; font-weight: 800; margin: 12px 0 4px; color: #0f5173; }
.ts-exp-sel { width: 100%; padding: 8px 10px; border: 2px solid #0f5173; border-radius: 10px; font-size: 1em; background: #fff; color: #0f2a3a; }
.ts-exp-fmt { display: flex; gap: 20px; flex-wrap: wrap; }
.ts-exp-fmt label, .ts-exp-ink { font-weight: 700; cursor: pointer; }
.ts-exp-ink { display: block; margin-top: 10px; }
.ts-exp-note { margin: 8px 0 0; font-size: .85em; opacity: .75; }
.ts-exp-status { min-height: 1.5em; margin: 10px 0 4px; font-weight: 800; color: #0f5173; }
.ts-exp-bar { height: 8px; background: #dbe6ee; border-radius: 6px; overflow: hidden; }
.ts-exp-bar i { display: block; height: 100%; width: 0; background: #2f9e44; transition: width .2s; }
.ts-exp-row { display: flex; gap: 10px; margin-top: 14px; justify-content: flex-end; }
.ts-exp-go, .ts-exp-close { min-height: 0; padding: 8px 20px; border: 0; border-radius: 12px; font-weight: 800; font-size: 1em; cursor: pointer; }
.ts-exp-go { background: #2f9e44; color: #fff; }
.ts-exp-go:disabled { opacity: .5; cursor: default; }
.ts-exp-close { background: #e5edf3; color: #0f2a3a; }

/* site label, bottom-left of every slide (the page counter is bottom-right, the clock top-left) */
.ts-stage .ts-wm { position: absolute; left: 20px; bottom: 12px; z-index: 6; pointer-events: none; color: #0f5173; font: 700 19px/1 'Times New Roman', serif; letter-spacing: .02em; opacity: .8; }

/* =====================================================================================================================
   "purple" lesson look (lesson 2): the teacher's own "Properties of Numbers" deck - a cream card with a thin border over a lavender band,
   bold blue headings, blue rounded boxes for rules, blue numbers. Switched on per lesson in LESSON_THEMES (teachshow.js).
   ===================================================================================================================== */
.ts-theme-purple { --pp: #1414d2; --pp-band: #9b72c0; --pp-cream: #fcfaf7; }
.ts-theme-purple .ts-slide, .ts-theme-purple .ts-slide.ts-key, .ts-theme-purple .ts-slide.ts-ex, .ts-theme-purple .ts-slide.ts-prac,
.ts-theme-purple .ts-slide.ts-sol, .ts-theme-purple .ts-slide.ts-title, .ts-theme-purple .ts-slide.ts-cover {
  background: linear-gradient(180deg, var(--pp-cream) 0, var(--pp-cream) 73.5%, var(--pp-band) 73.5%, var(--pp-band) 100%);
  color: #111; outline: none; box-shadow: none; isolation: isolate; padding: 46px 66px 66px 66px;
}
.ts-theme-purple .ts-slide::before { content: ''; position: absolute; inset: 3.4% 3.6% 5.8% 3.6%; border: 1.5px solid #2b2b2b; border-radius: 8px; background: var(--pp-cream); z-index: 0; }
.ts-theme-purple .ts-slide > * { position: relative; z-index: 1; }   /* the content sits above the card (no negative z-index: the PDF/PowerPoint picture-maker would lose the card) */
.ts-theme-purple .ts-slide .ts-kicker { color: var(--pp); font-weight: 800; font-size: 1.22em; margin: 0 0 .2em; }
.ts-theme-purple .ts-slide h1 { color: var(--pp); }
.ts-theme-purple .ts-slide h2 { color: var(--pp); border-bottom: 0; padding-bottom: 0; font-size: 1.12em; text-decoration: underline; text-underline-offset: .18em; margin: .1em 0 .45em; }
.ts-theme-purple .ts-slide.ts-title h1::after { display: none; }
.ts-theme-purple .ts-slide .ts-sub { color: #444; opacity: 1; }
.ts-theme-purple .ts-slide .ts-exh, .ts-theme-purple .ts-slide li.lab .lb { color: var(--pp); }
.ts-theme-purple .ts-slide .katex { color: var(--pp); }
.ts-theme-purple .ts-slide .ts-obj { background: transparent; border: 2px solid var(--pp); border-radius: 16px; }
.ts-theme-purple .ts-slide .ts-obj h3 { color: var(--pp); text-decoration: underline; }
.ts-theme-purple .ts-slide th, .ts-theme-purple .ts-slide td { border-color: var(--pp); }
.ts-theme-purple .ts-slide th { background: #ece8fa; }
.ts-theme-purple .ts-slide blockquote { background: #eeeaff; border-left-color: var(--pp); }
.ts-theme-purple .ts-slide .cap { color: #444; }
/* rules ("ជាទូទៅ", "និយមន័យ" ...): a blue rounded outline instead of the dark card */
.ts-theme-purple .ts-card { background: transparent; border: 2px solid var(--pp); border-radius: 16px; box-shadow: none; color: var(--pp); padding: .6em 1.1em .7em; }
.ts-theme-purple .ts-card-h { margin-bottom: .3em; }
.ts-theme-purple .ts-card-h span { color: var(--pp); font-style: italic; text-decoration: underline; text-underline-offset: .18em; font-size: 1.1em; }
.ts-theme-purple .ts-card-h i { display: none; }
.ts-theme-purple .ts-card-b, .ts-theme-purple .ts-card-b .katex, .ts-theme-purple .ts-card-b li::marker { color: var(--pp) !important; }
.ts-theme-purple .ts-card-b b, .ts-theme-purple .ts-card-b mark.term { color: #b00000 !important; background: none; border: 0; box-shadow: none; text-shadow: none; padding: 0; margin: 0; animation: none; }
.ts-theme-purple .ts-card-b th, .ts-theme-purple .ts-card-b td { border-color: var(--pp); color: #111; }
.ts-theme-purple .ts-card-b th { background: #ece8fa; }
.ts-theme-purple .ts-wm { color: #fff; opacity: .95; }
/* the branded cover in front of the lesson */
.ts-theme-purple .ts-slide.ts-pp-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 34px 60px 70px; }
.ts-pp-cover .pp-deco { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.ts-pp-cover > *:not(.pp-deco) { position: relative; z-index: 1; }
.ts-pp-cover .pp-top { display: flex; align-items: center; justify-content: center; gap: 16px; }
.ts-pp-cover .pp-logo { width: clamp(54px, 9vh, 92px); height: auto; flex: none; }
.ts-pp-cover .pp-school { color: var(--pp); font-family: 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-weight: 700; font-size: 1.02em; line-height: 1.45; text-align: left; }
.ts-pp-cover .pp-school span { font-size: .82em; }
.ts-pp-cover .pp-pill { margin: .45em 0 .15em; background: #ffd84a; color: var(--pp); border-radius: 999px; padding: .05em 1.8em; font: 800 1.35em/1.5 Arial, 'Times New Roman', sans-serif; border: 2px solid #2b2b2b; }
.ts-pp-cover .pp-title { color: var(--pp); font-family: 'Khmer OS Muol Light', 'Moul', 'Kantumruy Pro', serif; font-weight: 700; font-size: 2.7em; line-height: 1.35; margin-top: .05em; }
.ts-pp-cover .pp-en { color: var(--pp); font: 800 1.5em/1.3 Arial, 'Times New Roman', sans-serif; letter-spacing: .02em; }
.ts-pp-cover .pp-by { margin-top: .8em; color: var(--pp); font-weight: 800; font-size: 1.1em; }
.ts-pp-cover .pp-meta { margin-top: .1em; color: #333; font-size: .95em; }
.ts-pp-cover .pp-meta b { color: var(--pp); }
.ts-theme-purple .ts-slide .ts-exh { font-style: italic; text-decoration: underline; text-underline-offset: .18em; }

/* ===== Spin, in the look of the name-wheel tab: cream card, white ring, dark pointer, glossy blue button ===== */
.ts-wspin .sp { background: linear-gradient(165deg, #fbfaf6, #eaf0fb); }
.sp-cls { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; color: #1f2547; }
.sp-cls select { flex: 1; min-width: 0; height: 34px; padding: 0 8px; border-radius: 10px; border: 1.5px solid #d6d0c0; background: #fff; color: #1f2547; font-weight: 700; font-size: 14px; box-shadow: none; }
.sp .sp-bar button, .sp .sp-bar select { background: rgba(31, 37, 71, .08); color: #1f2547; }
.sp .sp-bar button.on { background: var(--brand); color: #fff; }
.sp .sp-chk { color: #1f2547; }
.sp .sp-info { color: #4b5563; }
.sp .sp-wheel canvas { box-sizing: border-box; border: 6px solid #fff; border-radius: 50%; filter: none; box-shadow: 0 10px 28px rgba(31, 37, 71, .3); }
.sp .sp-ptr { display: none; }   /* no separate triangle: the teardrop's tip points at the winner */
/* the dark teardrop button, glossier: a lit gradient body, a white rim line, a highlight, a soft glow that breathes while it waits */
.sp .sp-hub {
  --hw: min(28cqmin, 120px); width: var(--hw); height: calc(var(--hw) * 1.1); padding: calc(var(--hw) * .27) 0 0 !important; box-sizing: border-box;
  border: 0; border-radius: 0; background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 110'><defs><linearGradient id='g' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23505766'/><stop offset='.55' stop-color='%23262a35'/><stop offset='1' stop-color='%23101319'/></linearGradient><radialGradient id='h' cx='.32' cy='.3' r='.5'><stop offset='0' stop-color='white' stop-opacity='.55'/><stop offset='1' stop-color='white' stop-opacity='0'/></radialGradient></defs><path d='M50 3 C50 3 10 41 10 70 a40 40 0 0 0 80 0 C90 41 50 3 50 3Z' fill='url(%23g)' stroke='white' stroke-width='3.2'/><path d='M50 3 C50 3 10 41 10 70 a40 40 0 0 0 80 0 C90 41 50 3 50 3Z' fill='url(%23h)'/></svg>") center / 100% 100% no-repeat;
  transform: translate(-50%, -64%); color: #fff; font-family: 'Inter', 'Kantumruy Pro', system-ui, sans-serif; font-weight: 900; letter-spacing: .06em; font-size: clamp(13px, 4.4cqmin, 21px);
  text-shadow: 0 2px 5px rgba(0, 0, 0, .7); box-shadow: none; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)); animation: sp-breathe 2.4s ease-in-out infinite;
}
.sp .sp-hub:hover:not(:disabled) { filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)) brightness(1.2); }
.sp .sp-hub:disabled { animation: none; }
@keyframes sp-breathe { 0%, 100% { filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)); } 50% { filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)) drop-shadow(0 0 10px rgba(255, 255, 255, .55)); } }
@media (prefers-reduced-motion: reduce) { .sp .sp-hub { animation: none; } }
.sp .sp-gear { color: #1f2547; }

/* Spin, kept simple: class + wheel + one row (mode, divide, absent); the rest is behind the gear */
.sp .sp-bar { position: absolute; left: 8px; bottom: 40px; z-index: 4; padding: 6px; border-radius: 12px; background: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.sp-modes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sp-modes button, .sp-modes select { min-height: 0; height: 32px; padding: 0 12px; border-radius: 99px; border: 1.5px solid #d6d0c0; background: #fff; color: #1f2547; font-weight: 800; font-size: 13px; box-shadow: none; }
.sp-modes button.on { background: #1f2547; border-color: #1f2547; color: #fff; }
.sp-modes .sp-dvd { background: var(--brand); border-color: var(--brand); color: #fff; }
.sp-modes .sp-ab { margin-left: auto; border-color: #e03131; color: #c92a2a; }
.sp-roster { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: #fbfaf6; }
.sp-roster[hidden] { display: none; }
.sp-rh { display: flex; justify-content: space-between; align-items: center; color: #1f2547; font-size: 14px; }
.sp-rc { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; }
.sp-chip { min-height: 0; padding: 6px 12px; border-radius: 99px; border: 1.5px solid var(--brand); background: #fff; color: #1f2547; font-weight: 700; font-size: 14px; box-shadow: none; }
.sp-chip.off { border-color: #e03131; background: #fff1f1; color: #c92a2a; text-decoration: line-through; opacity: .85; }
.sp-rok { min-height: 0; height: 38px; border-radius: 99px; border: 0; background: var(--brand); color: #fff; font-weight: 800; box-shadow: none; }
.pp-abs { background: #fff1f1; color: #c92a2a; border: 1.5px solid #e03131 !important; }

/* the groups that were dealt stay listed under the wheel after the banner is closed */
.sp-dealt { max-height: 34%; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.sp-dealt[hidden] { display: none; }
.sp-dg { padding: 4px 10px; border-radius: 10px; border-left: 6px solid var(--c); background: #fff; color: #1f2547; font-size: 13px; line-height: 1.5; }
.sp-dg b { color: var(--c); }

/* Lesson 2: the division ladder used to break a number into prime factors (30 | 2 / 15 | 3 / 5 | 5 / 1) */
.ts-slide .ladder { display: inline-block; font-size: 1.55em; font-variant-numeric: tabular-nums; margin: .15em .6em; text-align: left; }
.ts-slide .ladder .lr { display: grid; grid-template-columns: 3.4em 2.2em; line-height: 1.25; }
.ts-slide .ladder .lv { text-align: right; padding-right: .55em; border-right: 3px solid #1f4a5f; color: #1f4a5f; font-weight: 700; }
.ts-slide .ladder .lp { text-align: left; padding-left: .55em; color: #e03131; font-weight: 800; }

/* classic teaching room: the timetable on the period buttons */
.att-period { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; padding: 4px 8px; }
.att-period small { font-size: 10px; font-weight: 600; opacity: .8; white-space: nowrap; }
.att-period.live { box-shadow: 0 0 0 2px rgba(47, 158, 68, .45); }

/* projector size: ~40px body text at 1920 wide, for decks that were audited at this size (only 9-1 so far) */
.ts-slide.ts-big { font-size: clamp(20px, 2.7vw, 40px); line-height: 1.6; }
/* left margin 2 cm (CSS cm = 96 dpi: 2 cm on a laptop screen, scales with the projected image) */
.ts-slide.ts-big { padding-left: 2cm; }

/* smooth motion for the projector decks (ts-big): pictures and their pieces fade in; nothing draws itself, pops or bounces */
@keyframes tsFade { from { opacity: 0; } to { opacity: 1; } }
.ts-slide.ts-big .fig > svg { animation: tsFade .8s ease both; }
.ts-slide.ts-big svg .rv { transition: opacity .7s ease; }
.ts-slide.ts-big div.rv:not(.rv-hide) { animation: tsRise .7s ease-out both; }
@media (prefers-reduced-motion: reduce) { .ts-slide.ts-big .fig > svg, .ts-slide.ts-big div.rv:not(.rv-hide) { animation: none; } }

/* heading + maths type for the projector decks (ts-big): label = Khmer Battambang bold italic in the slide red; the rest of the heading = Khmer Battambang, plain; maths = Mathcad-style italic */
.ts-slide.ts-big h2 { font-family: 'Khmer OS Battambang', 'Kantumruy Pro', 'Times New Roman', serif; font-style: normal; font-weight: 400; }
.ts-slide.ts-big h2 .h-lab { font-style: italic; font-weight: 800; }
.ts-slide.ts-big h2 .h-txt { font-style: normal; font-weight: 400; }
.ts-slide.ts-big h2 .katex { font-size: 1.05em; }
.ts-slide.ts-big .katex, .ts-slide.ts-big .katex .mord, .ts-slide.ts-big .katex .mbin, .ts-slide.ts-big .katex .mrel, .ts-slide.ts-big .katex .mopen, .ts-slide.ts-big .katex .mclose, .ts-slide.ts-big .katex .mpunct, .ts-slide.ts-big .katex .mop {
  font-family: 'Mathcad UniMath', 'Mathcad UniMath Italic', 'Times New Roman', 'STIX Two Text', serif; }
.ts-slide.ts-big .katex .mathnormal, .ts-slide.ts-big .katex .mathit { font-style: italic; }
.ts-slide.ts-big .katex .mathrm, .ts-slide.ts-big .katex .mord.mathrm { font-style: normal; }

/* heading: the slide blue, same size as the section tag above it (ts-big decks) */
.ts-slide.ts-big h2, .ts-slide.ts-big.ts-key h2, .ts-slide.ts-big.ts-ex h2, .ts-slide.ts-big.ts-prac h2, .ts-slide.ts-big.ts-sol h2 { color: #0f5173; font-size: 1.1em; }

/* no rule under the heading (ts-big decks) */
.ts-slide.ts-big h2 { border-bottom: 0; padding-bottom: 0; }

/* "≠" is drawn from a private-use glyph of KaTeX_Main: keep that font for it inside the Mathcad-style decks (otherwise it shows as a box) */
.ts-slide.ts-big .katex .mrel:has(.thinbox), .ts-slide.ts-big .katex .mrel:has(.thinbox) *, .ts-slide.ts-big .katex .thinbox, .ts-slide.ts-big .katex .thinbox * { font-family: KaTeX_Main, 'Times New Roman', serif; font-style: normal; }

/* ====================================================================================================================================
   ESC theme — the look of the author's class slides (ESC_មេរៀនទី១២-02.pptx): navy header band with the book icon and the E-School logo,
   the lesson title in white Khmer M1, grid paper, red bold-italic labels, grey rounded boxes with a navy outline, cards with a navy header strip.
   Only lessons listed in ESC_LESSONS (teachshow.js) get it. Sizes follow the slide (cqw / cqh), so it looks the same on every screen.
   ==================================================================================================================================== */
.ts-stage.ts-theme-esc { background: #fff; }
.ts-stage.ts-theme-esc .ts-slide {
  container-type: size; background: #fff url(/img/esc/grid.png) 0 0 / 100% 100% no-repeat; color: #0f5173;
  padding: 0 3.2cqw 5cqh; font-size: clamp(18px, 2.35cqw, 44px); line-height: 1.5;
  font-family: 'Khmer OS Battambang', 'Kantumruy Pro', system-ui, sans-serif;
}
.ts-stage.ts-theme-esc .ts-slide::after {            /* the footer of the template */
  content: 'E-SCHOOL CAMBODIA'; position: absolute; left: 0; right: 0; bottom: 1.2cqh; text-align: center;
  font: 400 1.5cqh/1 'Kantumruy Pro', system-ui, sans-serif; letter-spacing: .02em; color: #8a8f94; pointer-events: none;
}
/* the title band = the slide's kicker */
.ts-theme-esc .ts-slide > .ts-kicker {
  display: flex; align-items: center; box-sizing: border-box; margin: 0 -3.2cqw 2cqh; width: calc(100% + 6.4cqw); height: 12.5cqh; padding: 0 10cqw 0 8.6cqw;
  background: url(/img/esc/book.svg) 1.4cqw 50% / auto 70% no-repeat, var(--esc-logo, url(/img/esc/logo.png)) calc(100% - 1cqw) 50% / auto 84% no-repeat, url(/img/esc/band.png) 0 0 / 100% 100% no-repeat;
  color: #fff; font: 700 2.5cqw/1.2 'Khmer M1', 'Khmer OS Muol Light', 'Moul', serif; letter-spacing: 0; text-transform: none;
}
.ts-theme-esc .esc-sec { margin: 0 0 .1em; font-weight: 800; font-size: 1.04em; color: #0f5173; }
.ts-theme-esc .ts-slide h2 { color: #0f5173; font-style: normal; font-weight: 800; border: 0; padding: 0; margin: 0 0 .45em; font-size: 1.04em; line-height: 1.45; }
.ts-theme-esc .ts-slide h2 .h-lab { color: #ee0000; font-style: italic; font-weight: 800; }
.ts-theme-esc .ts-slide h2 .h-txt { color: #0f5173; font-style: normal; font-weight: 400; }
.ts-theme-esc .ts-slide p { margin: .25em 0; }
.ts-theme-esc .ts-slide .katex { color: inherit; }
.ts-theme-esc .ts-card { background: #f2f2f2; border: .22cqw solid #0f5173; border-radius: 1.3cqw; }
.ts-theme-esc .ts-card-h { background: transparent; color: #ee0000; }
.ts-theme-esc .ts-slide .ts-bullets > li::marker { color: #ee0000; }
.ts-theme-esc .ts-slide mark.term { background: none; color: #ee0000; font-weight: 800; }
.ts-theme-esc .esc-chip { position: absolute; left: 3.2cqw; bottom: 7.5cqh; background: #0f5173; color: #fff; font-weight: 800; padding: .15em 1.1em; border-radius: 99px; font-size: .9em; }
.ts-theme-esc table.sumtab th { background: #0f5173; color: #fff; }
.ts-theme-esc table.sumtab td, .ts-theme-esc table.sumtab th { border-color: #0f5173; }

/* divider (template slide 4): a navy block on top, a white framed box with the name in dark red, the ornament */
.ts-theme-esc .ts-slide.ts-title { padding: 0; }
.ts-theme-esc .ts-slide.ts-title > .esc-div { position: absolute; inset: 0; }
.ts-theme-esc .esc-div-top { position: absolute; left: 0; right: 0; top: 0; height: 51%; background: #0f5174; color: #fff; text-align: center; padding-top: 15%;
  font: 400 4.2cqw/1.3 'Khmer OS Muol Light', 'Moul', serif; }
.ts-theme-esc .esc-div-box { position: absolute; left: 21%; width: 58%; top: 41%; min-height: 19%; display: flex; align-items: center; justify-content: center; text-align: center;
  background: #fff; border: .4cqw solid #2f6fb0; padding: .6cqw 1.5cqw; box-sizing: border-box; }
.ts-theme-esc .esc-div-box h1 { margin: 0; color: #931e21; font: 400 3.6cqw/1.35 'Khmer OS Muol Light', 'Moul', serif; }
.ts-theme-esc .ts-slide.ts-title .esc-div-box h1::after { display: none; }
.ts-theme-esc .esc-orn { position: absolute; left: 50%; transform: translateX(-50%); top: 70%; width: 22%; }
.ts-theme-esc .esc-div-sub { position: absolute; left: 10%; right: 10%; top: 78%; text-align: center; font-size: 2cqw; color: #0f5173; }

/* teacher profile (template slide 1) */
.ts-theme-esc .ts-slide.ts-esc-profile { padding: 0; background: #fff url(/img/esc/profile.jpg) 0 0 / 100% 100% no-repeat; }
.ts-theme-esc .ts-esc-profile::after { display: none; }
.ts-theme-esc .ts-esc-profile .pf-name { position: absolute; left: 6.8%; top: 67.2%; width: 23.2%; text-align: center; color: #fff; font-family: 'Khmer M1', 'Khmer OS Muol Light', serif; font-weight: 400; font-size: 2.2cqw; line-height: 1.2; }
.ts-theme-esc .ts-esc-profile .pf-t { position: absolute; left: 44.8%; top: 12.5%; font: 400 3cqw/1.2 'Khmer M1', serif; color: #0f5173; }
.ts-theme-esc .ts-esc-profile .pf-r { position: absolute; left: 44.8%; width: 53%; display: flex; font-size: 1.85cqw; font-weight: 400; font-family: 'Khmer M1', 'Khmer OS Muol Light', serif; color: #0f5173; text-align: left; line-height: 1.2; }
.ts-theme-esc .ts-esc-profile .pf-r span:first-child { width: 25cqw; } .ts-theme-esc .ts-esc-profile .pf-r span:nth-child(2) { width: 4cqw; }

/* textbook slide (template slide 2) */
.ts-theme-esc .esc-book { display: grid; grid-template-columns: 38% 1fr; gap: 4cqw; align-items: center; height: 70cqh; }
.ts-theme-esc .esc-book img { width: 74%; justify-self: end; box-shadow: .4cqw .4cqw 1.4cqw rgba(0,0,0,.35); }
.ts-theme-esc .esc-book .bk-t { text-align: center; font-size: 2.9cqw; line-height: 2; }
.ts-theme-esc .esc-book .bk-t b { color: #ee0000; font-weight: 400; }

/* thank you / end */
.ts-theme-esc .ts-slide.ts-title.ts-esc-end { padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ts-theme-esc .ts-esc-end h1 { color: #0f5173; font: 400 7cqw/1.3 'Khmer OS Muol Light', 'Moul', serif; margin: 0; }
.ts-theme-esc .ts-esc-end h1::after { display: none; }
.ts-theme-esc .ts-esc-end .esc-div-sub { position: static; margin-top: 3cqh; }
.ts-theme-esc .ts-slide .fig > svg { max-height: 46cqh !important; }
.ts-theme-esc .ts-slide .ts-card-b .fig > svg, .ts-theme-esc .ts-slide .fig .fig > svg { max-height: 34cqh !important; }

/* objectives (template slide 5): «label : text» with the wrapped lines hanging under the text, and more room between the lines */
.ts-theme-esc .esc-obj { margin-top: .4em; }
.ts-theme-esc .esc-obj .ob { margin: .5em 0; line-height: 1.95; padding-left: 17.5cqw; text-indent: -17.5cqw; }
.ts-theme-esc .esc-obj .ob-l { display: inline-block; width: 16cqw; text-indent: 0; color: #ee0000; font-weight: 800; }

/* a line of a solution: the equality, then its reason in a column (as the textbook sets it) */
.ts-slide p.rs { display: grid; grid-template-columns: minmax(9.5em, max-content) 1fr; column-gap: 1em; align-items: baseline; }
.ts-slide p.rs .rs-r { color: #595959; }

/* the way the class slides write maths: Cambria Math italic, navy; reasons in plain navy brackets; a conclusion in a grey box with a navy outline */
.ts-theme-esc .katex .mathnormal, .ts-theme-esc .katex .mathit { font-family: 'Mathcad UniMath Italic', 'Mathcad UniMath', KaTeX_Math, 'Times New Roman', serif; }   /* variables: Mathcad UniMath italic (digits and signs keep KaTeX's own font) */
.ts-theme-esc .katex .mathnormal, .ts-theme-esc .katex .mathit { font-style: italic; }
.ts-theme-esc .katex { font-size: 1.04em; }
.ts-theme-esc .ts-slide p.rs .rs-r { color: #0f5173; }
.ts-theme-esc .ts-slide p.sq { font-weight: 700; margin-top: .5em; }
.ts-theme-esc .ts-slide p.sq .katex { font-weight: 400; }
.ts-theme-esc .ts-slide p.concl { display: inline-block; background: #f2f2f2; border: .22cqw solid #0f5173; border-radius: 1cqw; padding: .12em .9em; margin: .35em 0 .35em 1.2em; font-weight: 700; }
.ts-theme-esc .ts-slide p.concl b { font-weight: 800; }
.ts-theme-esc .ts-slide p.concl.fin { display: block; width: fit-content; margin: .5em auto; padding: .2em 1.6em; font-size: 1.06em; }
.ts-theme-esc .ts-slide .bigfig .fig > svg { max-height: 48cqh !important; }
.ts-theme-esc .esc-sec { font-weight: 800; -webkit-text-stroke: .03em currentColor; }

/* moving pieces of a picture: sit still until their step, then slide (--dx, --dy). Used by the cut-out copy, the protractor, the overlay. */
.ts-slide .mvg { transition: transform var(--ms, 1.8s) cubic-bezier(.45, 0, .2, 1); }
.ts-slide .mvg.rv-hide { opacity: 1 !important; visibility: visible !important; transform: none; }
.ts-slide .mvg:not(.rv-hide) { transform: translate(var(--dx), var(--dy)); }
.ts-slide .rv.late:not(.rv-hide) { animation-delay: 1.8s !important; }
/* a question for the pupils and its answer */
.ts-slide .ask { border-left: .5cqw solid #ee0000; background: #fff4d6; border-radius: .6cqw; padding: .2em .8em; margin: .4em 0; color: #0f5173; }
.ts-slide .ask.ans { border-left-color: #2f9e44; background: #e8f6ec; font-weight: 700; }
/* summary: numbered steps */
.ts-theme-esc .esc-steps { display: grid; grid-template-columns: 54% 1fr; gap: 2.4cqw; align-items: start; }
.ts-theme-esc .esc-step { display: flex; align-items: center; gap: 1.6cqw; margin: .55em 0; font-weight: 700; }
.ts-theme-esc .esc-step .num { flex: none; width: 3.6cqw; height: 3.6cqw; border-radius: 50%; background: #0f5173; color: #fff; display: grid; place-items: center; font-weight: 800; }
.ts-theme-esc .esc-exit { border: .22cqw solid #0f5173; background: #fff; }
.ts-theme-esc .esc-exit .hd { background: #0f5173; color: #fff; text-align: center; font-weight: 800; padding: .25em; }
.ts-theme-esc .esc-exit .bd { padding: .3em .8em; }
.ts-theme-esc .esc-exit .q { margin: .25em 0; }

/* definition slide (class slide 9): big grey box, two marked triangles, a red double arrow, the equalities in a framed box */
.ts-theme-esc .defbox { border: .3cqw solid #0f5173; border-radius: 1.6cqw; background: #f2f2f2; padding: .9em 1.2em; margin: .3em 0 .5em; text-align: center; font-size: 1.12em; font-weight: 700; }
.ts-theme-esc .defrow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.6cqw; align-items: center; }
.ts-theme-esc .deffig .fig > svg { max-height: 46cqh !important; }
.ts-theme-esc .defrow { margin-top: 3cqh; }
.ts-theme-esc .defarrow { width: 7cqw; }
.ts-theme-esc .defeq { font-size: 1.15em; padding: .9em .6em; }
.ts-theme-esc .defcap { text-align: center; }

.ts-theme-esc .defeq { border: .22cqw solid #0f5173; background: #fff; padding: .5em .6em; text-align: center; }

/* corresponding parts slide (class slide 8): table of angles and sides on the left, the two marked triangles on the right, a grey result box */
.ts-theme-esc .cmgrid { display: grid; grid-template-columns: 44% 1fr; gap: 3cqw; align-items: center; margin-top: 1.5cqh; }
.ts-theme-esc .cmtab { border-top: .25cqw solid #0f5173; border-bottom: .25cqw solid #0f5173; }
.ts-theme-esc .cmhead, .ts-theme-esc .cmrow { display: grid; grid-template-columns: 1fr 1fr; text-align: center; padding: .35em 0; }
.ts-theme-esc .cmhead { font-weight: 800; border-bottom: .2cqw solid #0f5173; }
.ts-theme-esc .cmrow { border-bottom: .1cqw solid #d0d0d0; }
.ts-theme-esc .cmrow:last-child { border-bottom: 0; }
.ts-theme-esc .cmfig .fig > svg { max-height: 46cqh !important; }
.ts-theme-esc .cmcap { text-align: center; color: #595959; font-size: .85em; }
.ts-theme-esc .cmbox { border: .3cqw solid #0f5173; border-radius: 1.6cqw; background: #f2f2f2; padding: .55em 1em; margin-top: 2cqh; text-align: center; font-weight: 800; font-size: 1.1em; }

/* worked-question slide with a figure on the right (class slide 10) */
.ts-theme-esc .sqgrid { display: grid; grid-template-columns: 46% 1fr; gap: 2cqw; align-items: center; margin-top: 2cqh; }
.ts-theme-esc .solh { margin: .5em 0 .2em; }
.ts-theme-esc p.bul { margin: .45em 0 .45em 1.2cqw; }
.ts-theme-esc p.bul .dia { color: #ee0000; margin-right: .8em; }
.ts-theme-esc .sqfig .fig > svg { max-height: 40cqh !important; }

/* practice slide with two figures and an answer box (class slide 11) */
.ts-theme-esc .esc-chip.tr { top: 14.4cqh; bottom: auto; left: auto; right: 3.2cqw; }
.ts-theme-esc .pfig .fig > svg { max-height: 58cqh !important; }
.ts-theme-esc .ansbox { border: .3cqw solid #0f5173; border-radius: 1.6cqw; background: #f2f2f2; padding: .8em 1em; margin-top: 2cqh; text-align: center; font-weight: 700; font-size: 1.08em; }
.ts-theme-esc .plain { font-family: 'Mathcad UniMath Italic', 'Mathcad UniMath', serif; font-style: italic; }

/* the three conditions (class slide 12) */
.ts-theme-esc .ovc { position: relative; border: .22cqw solid #0f5173; background: #fff; text-align: center; padding-bottom: 2.2em; }
.ts-theme-esc .ovh { color: #fff; font-weight: 800; padding: .25em; }
.ts-theme-esc .ovf .fig { margin: .3em auto; width: 80%; }
.ts-theme-esc .ovf .fig > svg { max-height: 26cqh !important; }
.ts-theme-esc .ovt { padding: 0 .4em; font-weight: 700; }
.ts-theme-esc .ovg { position: absolute; right: .6em; bottom: .25em; font-size: .78em; font-weight: 800; }
.ts-theme-esc .ovgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6cqw; margin-top: 1.5cqh; }
.ts-theme-esc .ovgrid > .rv { display: flex; }
.ts-theme-esc .ovc { width: 100%; }
.ts-theme-esc .ovt { font-size: .9em; }

/* construction slide (class slide 13): numbered steps on the left, the figure with its tools on the right */
.ts-theme-esc .h-lab { color: #ee0000; font-style: italic; font-weight: 800; }
.ts-theme-esc .cgrid { display: grid; grid-template-columns: 38% 1fr; gap: 2cqw; align-items: center; margin-top: 2cqh; }
.ts-theme-esc .cgrid .esc-step { margin: 1.1em 0; font-weight: 400; }
.ts-theme-esc .cfig .fig > svg { max-height: 56cqh !important; }
.ts-theme-esc .okmid { color: #d9291c; font-weight: 800; text-align: center; }
.ts-theme-esc .cmbox .katex { color: #d9291c; font-weight: 800; }
.ts-theme-esc .katex { white-space: nowrap; }

/* theorem slide (class slide 16) */
.ts-theme-esc .throw { display: grid; grid-template-columns: 1fr 38%; gap: 3cqw; align-items: center; margin-top: 2.5cqh; }
.ts-theme-esc .thfig .fig > svg { max-height: 36cqh !important; }
.ts-theme-esc .thcard { border: .3cqw solid #0f5173; background: #0f5173; padding: 0 .9cqw .9cqw; }
.ts-theme-esc .thh { color: #fff; text-align: center; font-weight: 800; padding: .3em 0; }
.ts-theme-esc .thb { background: #fff; padding: .8em .9em; line-height: 1.7; min-height: 9em; display: flex; align-items: center; }

/* practice / extra exercise slides (class slides 20-21) */
.ts-theme-esc .esc-chip.br { left: auto; right: 9cqw; bottom: 8cqh; top: auto; }
.ts-theme-esc .subq { margin: .2em 0 .4em 2.5cqw; }
.ts-theme-esc .subq p { margin: .1em 0; }
.ts-theme-esc p.pc { margin: .3em 0 .3em 1.2cqw; font-weight: 700; }
/* «ត្រួតស៊ីគ្នា ✓» at the right-centre, between the two pictures */
.ts-theme-esc .cfig { position: relative; }
.ts-theme-esc .okmid { position: absolute; right: -2%; top: 46%; color: #d9291c; font-weight: 800; text-align: right; white-space: nowrap; }
/* the «គិត ២ នាទី» chip is a button: click to count down */
.ts-theme-esc .esc-chip { cursor: pointer; user-select: none; z-index: 6; }
.ts-theme-esc .esc-chip.run { background: #2f9e44; }
.ts-theme-esc .esc-chip.done { background: #ee0000; animation: chipBlink .5s ease-in-out 6; }
@keyframes chipBlink { 50% { opacity: .35; } }

/* pictures can be redrawn by a click: while it plays, parts hidden by a step are still allowed to show (the script controls each part) */
.ts-slide svg.drawfig { cursor: pointer; }
.ts-slide svg.replay .rv-hide { visibility: visible !important; opacity: 1 !important; }
.ts-slide .drawhint { text-align: center; color: #595959; font-size: .62em; margin-top: .1em; opacity: .8; }

/* teacher profile: every text can be edited and the photo / school logo can be replaced (saved in this browser) */
.ts-theme-esc .ts-esc-profile [data-edit] { outline: none; border-radius: .5cqw; cursor: text; }
.ts-theme-esc .ts-esc-profile .pf-t, .ts-theme-esc .ts-esc-profile .pf-name, .ts-theme-esc .ts-esc-profile .pf-r { z-index: 5; }
.ts-theme-esc .ts-esc-profile [data-edit]:hover { background: rgba(15,81,115,.08); }
.ts-theme-esc .ts-esc-profile .pf-name[data-edit]:hover { background: rgba(255,255,255,.14); }
.ts-theme-esc .ts-esc-profile [data-edit]:focus { background: rgba(255,238,170,.55); box-shadow: 0 0 0 .2cqw #f0a800; color: #0f5173; }
.ts-theme-esc .ts-esc-profile .pf-name:focus { color: #0f5173; }
.ts-theme-esc .ts-esc-profile .pf-img { position: absolute; z-index: 5; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; background-size: cover; background-position: center; }
.ts-theme-esc .ts-esc-profile .pf-img span { opacity: 0; transition: opacity .15s; font: 400 1.5cqw/1 'Khmer M1', serif; background: rgba(15,81,115,.88); color: #fff; padding: .5cqw 1.2cqw; border-radius: 1cqw; margin-bottom: 1cqw; }
.ts-theme-esc .ts-esc-profile .pf-img:hover span { opacity: 1; }
.ts-theme-esc .ts-esc-profile .pf-photo { left: 6.7%; top: 20.3%; width: 23.3%; height: 41.2%; border-radius: 4cqw; }
.ts-theme-esc .ts-esc-profile .pf-photo.has { border: .35cqw solid #5f8fa8; box-sizing: border-box; background-color: #f4f6f8; }
.ts-theme-esc .ts-esc-profile .pf-logo { z-index: 1; left: 58.8%; top: 40%; width: 20.5%; height: 36.4%; }
.ts-theme-esc .ts-esc-profile .pf-logo.has { background-color: #fafafa; background-image: none !important; }
.ts-theme-esc .ts-esc-profile .pf-logo.has::before { content: ''; position: absolute; inset: 0; background: var(--img) center / contain no-repeat; opacity: .22; }
.ts-theme-esc .ts-esc-profile .pf-hint { position: absolute; left: 40%; bottom: 1.5%; font: 400 1.25cqw/1 'Khmer OS Battambang', sans-serif; color: #7a8a96; z-index: 5; }
.ts-theme-esc .ts-esc-profile .pf-hint button { font: inherit; color: #0f5173; background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0; }

/* measuring tools laid on a figure come in when the click reaches their step: the ruler slides in, then the protractor drops onto the corner */
@keyframes toolR { from { opacity: 0; transform: translateY(46px); } to { opacity: 1; transform: none; } }
@keyframes toolP { from { opacity: 0; transform: translateY(-46px); } to { opacity: 1; transform: none; } }
.ts-slide .rv:not(.rv-hide) .tool-r { animation: toolR .9s ease-out both; }
.ts-slide .rv:not(.rv-hide) .tool-p { animation: toolP .9s ease-out .7s both; }
.ts-slide .rv-hide .tool-r, .ts-slide .rv-hide .tool-p { animation: none; }
@media (prefers-reduced-motion: reduce) { .ts-slide .rv .tool-r, .ts-slide .rv .tool-p { animation: none !important; } }



/* logo picker: a small row of round school logos that opens at the bottom of the logo while the mouse is over it */
.ts-theme-esc .ts-esc-profile .pf-logo:hover { z-index: 7; }
.ts-theme-esc .ts-esc-profile .pf-logo > span { display: none; }
.ts-theme-esc .ts-esc-profile .pf-logos { position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); display: none; flex-direction: row; gap: .5cqw; padding: .6cqw .8cqw; background: rgba(255,255,255,.96); border: .12cqw solid #c9d8e0; border-radius: 99px; box-shadow: 0 .3cqw 1.2cqw rgba(15,81,115,.22); }
.ts-theme-esc .ts-esc-profile .pf-logo:hover .pf-logos { display: flex; }
.ts-theme-esc .ts-esc-profile .pf-logos button { display: flex; flex-direction: column; align-items: center; gap: .15cqw; width: 3.6cqw; padding: .3cqw 0; font: 400 .85cqw/1 'Khmer M1', sans-serif; color: #0f5173; background: none; border: .15cqw solid transparent; border-radius: 1cqw; cursor: pointer; }
.ts-theme-esc .ts-esc-profile .pf-logos button img { width: 2.6cqw; height: 2.6cqw; border-radius: 50%; object-fit: cover; }
.ts-theme-esc .ts-esc-profile .pf-logos button b { display: flex; align-items: center; justify-content: center; width: 2.6cqw; height: 2.6cqw; border-radius: 50%; background: #eaf1f5; font: 400 1.6cqw/1 sans-serif; }
.ts-theme-esc .ts-esc-profile .pf-logos button i { font-style: normal; white-space: nowrap; }
.ts-theme-esc .ts-esc-profile .pf-logos button:hover { background: #eaf1f5; }
.ts-theme-esc .ts-esc-profile .pf-logos button.on { border-color: #0f5173; background: #eaf1f5; font-weight: 700; }
.ts-theme-esc .ts-esc-profile .pf-logo.has::before { opacity: .3; }
.ts-theme-esc .ts-esc-profile .pf-hint { opacity: 0; pointer-events: none; }
.ts-theme-esc .ts-esc-profile .pf-hint:hover, .ts-theme-esc .ts-esc-profile .pf-logo:hover ~ .pf-hint { opacity: 1; pointer-events: auto; }

/* ===== DeckCraft (.pptx) Integration ===== */
.ts-stage.ts-stage-deckcraft {
  background: #111;
}
.ts-deck-frame {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; z-index: 1; background: #000; display: block;
}
.ts-stage.ts-stage-deckcraft .ts-ink {
  pointer-events: none;
}
.ts-stage.ts-stage-deckcraft.pen-active .ts-ink {
  pointer-events: auto !important;
  cursor: crosshair;
}

/* DeckCraft Fullscreen/Modal Editor */
.dc-editor-modal {
  position: fixed; inset: 0; z-index: 350;
  display: flex; flex-direction: column;
  background: #1e1e24; color: #f1f5f9;
  font-family: 'Khmer OS Battambang', 'Kantumruy Pro', system-ui, sans-serif;
  user-select: none;
}
.dc-modal-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: #23272e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14); gap: 12px;
  flex-shrink: 0;
}
.dc-modal-left {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.dc-modal-logo {
  font-weight: 800; font-size: 15px; color: #60a5fa; white-space: nowrap;
}
.dc-modal-name {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff; padding: 5px 12px; border-radius: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  width: min(340px, 40vw); outline: none;
}
.dc-modal-name:focus {
  border-color: #0e72ed;
  box-shadow: 0 0 0 2px rgba(14, 114, 237, 0.3);
}
.dc-modal-status {
  font-size: 12px; color: #94a3b8; white-space: nowrap;
}
.dc-modal-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.dc-btn {
  padding: 6px 14px; border-radius: 6px; border: 0; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
  transition: all .12s cubic-bezier(.2, .8, .2, 1);
  display: inline-flex; align-items: center; gap: 5px;
}
.dc-btn-save { background: #0e72ed; color: #ffffff; }
.dc-btn-save:hover { background: #1d4ed8; }
.dc-btn-dl { background: rgba(255, 255, 255, 0.1); color: #e2e8f0; }
.dc-btn-dl:hover { background: rgba(255, 255, 255, 0.18); color: #ffffff; }
.dc-btn-present { background: #16a34a; color: #ffffff; }
.dc-btn-present:hover { background: #15803d; }
.dc-btn-close {
  background: rgba(239, 68, 68, 0.2); color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.dc-btn-close:hover { background: #ef4444; color: #ffffff; }
.dc-modal-body {
  flex: 1; min-height: 0; position: relative; width: 100%; height: 100%;
}
#dc-editor-frame {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}

/* ============================================================
   Native PowerPoint Slide & Math Editor (SlideCraft)
   Complete MS PowerPoint-style editor with Latin Modern Math Italic
   ============================================================ */
.pe-modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column;
  background: #181920; color: #f1f5f9;
  font-family: 'Khmer OS Battambang', 'Kantumruy Pro', system-ui, sans-serif;
  user-select: none;
}
.pe-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px; background: #22252e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  gap: 10px; flex-shrink: 0;
}
.pe-bar-left {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.pe-bar-logo {
  font-weight: 800; font-size: 15px; color: #60a5fa; display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.pe-bar-name {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff; padding: 5px 12px; border-radius: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  width: min(320px, 35vw); outline: none;
}
.pe-bar-name:focus {
  border-color: #0e72ed; box-shadow: 0 0 0 2px rgba(14, 114, 237, 0.3);
}
.pe-bar-status {
  font-size: 12px; color: #94a3b8; white-space: nowrap;
}
.pe-bar-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.pe-btn {
  padding: 6px 13px; border-radius: 6px; border: 0; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all .12s ease;
}
.pe-btn-upload { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.4); }
.pe-btn-upload:hover { background: #3b82f6; color: #ffffff; }
.pe-btn-save { background: #0e72ed; color: #ffffff; }
.pe-btn-save:hover { background: #1d4ed8; }
.pe-btn-dl { background: rgba(255, 255, 255, 0.1); color: #e2e8f0; }
.pe-btn-dl:hover { background: rgba(255, 255, 255, 0.18); color: #ffffff; }
.pe-btn-present { background: #16a34a; color: #ffffff; }
.pe-btn-present:hover { background: #15803d; }
.pe-btn-close { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }
.pe-btn-close:hover { background: #ef4444; color: #ffffff; }

/* Ribbon Toolbar */
.pe-ribbon {
  display: flex; align-items: center; gap: 6px; padding: 6px 14px;
  background: #2a2d37; border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto; flex-shrink: 0;
}
.pe-rib-group {
  display: flex; align-items: center; gap: 4px; padding: 0 6px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}
.pe-rib-group:last-child { border-right: none; }
.pe-rib-btn {
  height: 30px; padding: 0 10px; border-radius: 5px; border: 0;
  background: rgba(255, 255, 255, 0.08); color: #e2e8f0;
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  white-space: nowrap; transition: background .1s, color .1s;
}
.pe-rib-btn:hover { background: rgba(255, 255, 255, 0.18); color: #ffffff; }
.pe-rib-btn.on { background: #0e72ed; color: #ffffff; }
.pe-rib-btn.special-math {
  background: #4f46e5; color: #ffffff; font-weight: 700;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}
.pe-rib-btn.special-math:hover { background: #4338ca; }
.pe-rib-select {
  height: 30px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08); color: #ffffff;
  padding: 0 8px; font-family: inherit; font-size: 12.5px; outline: none;
}
.pe-rib-select option { background: #22252e; color: #ffffff; }

/* Editor Workspace Body */
.pe-body {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
.pe-sidebar {
  width: 220px; background: #1a1c23; border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.pe-side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px; font-weight: 700; color: #cbd5e1;
}
.pe-side-add {
  background: #0e72ed; color: #ffffff; border: 0; border-radius: 5px;
  padding: 4px 8px; font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.pe-side-add:hover { background: #1d4ed8; }
.pe-thumbs {
  flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px;
}
.pe-thumb-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.04);
  border: 2px solid transparent; cursor: pointer; transition: all .12s;
}
.pe-thumb-card:hover { background: rgba(255, 255, 255, 0.08); }
.pe-thumb-card.active {
  border-color: #0e72ed; background: rgba(14, 114, 237, 0.12);
}
.pe-thumb-header {
  display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #94a3b8;
}
.pe-thumb-actions { display: flex; gap: 2px; }
.pe-thumb-actions button {
  background: transparent; border: 0; color: #94a3b8; font-size: 10px;
  padding: 2px 4px; border-radius: 3px; cursor: pointer;
}
.pe-thumb-actions button:hover { background: rgba(255,255,255,0.15); color: #fff; }
.pe-thumb-preview {
  width: 100%; aspect-ratio: 16/9; background: #ffffff; border-radius: 4px;
  padding: 6px; box-sizing: border-box; overflow: hidden; pointer-events: none;
  font-size: 6.5px; color: #0f172a; line-height: 1.25;
}
.pe-thumb-preview b { display: block; font-size: 8px; color: #0f172a; margin-bottom: 2px; }

/* Stage & Canvas */
.pe-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #0d0e12; overflow: auto; padding: 30px; position: relative;
}
.pe-canvas-container {
  width: 960px; max-width: 100%; aspect-ratio: 16/9;
  background: #ffffff; color: #0f172a;
  border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  padding: 44px 56px; box-sizing: border-box; position: relative;
  display: flex; flex-direction: column; overflow: hidden;
  font-family: 'Khmer OS Battambang', 'Kantumruy Pro', sans-serif;
}
.pe-block {
  border: 1.5px dashed transparent; border-radius: 6px;
  padding: 4px 8px; margin-bottom: 8px; transition: border-color .15s, background .15s;
  outline: none; cursor: text;
}
.pe-block:hover { border-color: rgba(14, 114, 237, 0.35); }
.pe-block.focused {
  border-color: #0e72ed !important;
  background: rgba(14, 114, 237, 0.04);
}
.pe-kicker {
  font-size: 15px; font-weight: 800; color: #2563eb; text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 4px;
}
.pe-title {
  font-size: 30px; font-weight: 800; color: inherit; line-height: 1.35;
  margin-bottom: 12px;
}
.pe-body-text {
  font-size: 19px; line-height: 1.7; color: inherit; margin-bottom: 10px;
}
.pe-bullets {
  margin: 0 0 12px; padding-left: 1.4em; font-size: 19px; line-height: 1.7; color: inherit;
}
.pe-bullets li { margin-bottom: 6px; }

/* Math Equation Blocks (Latin Modern Math Italic) */
.pe-math-block {
  display: block; text-align: center; margin: 16px 0; padding: 12px 18px;
  background: #f8fafc; color: #0f172a; border: 1.5px dashed #cbd5e1; border-radius: 10px;
  cursor: pointer; transition: all .15s;
}
.pe-math-block:hover {
  border-color: #4f46e5; background: #eef2ff;
}
.pe-math-block .katex, .pe-math-preview-card .katex {
  font-family: 'KaTeX_Math', 'Latin Modern Math', 'Cambria Math', serif !important;
  font-style: italic !important;
  font-size: 1.35em;
}
.pe-math-block .katex .mathnormal, .pe-math-preview-card .katex .mathnormal {
  font-style: italic !important;
}

/* Math Equation Editor Dialog (Matching User Image 2) */
.pe-math-backdrop {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.pe-math-dialog {
  width: min(720px, 94vw); background: #ffffff; color: #0f172a;
  border-radius: 18px; box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: 'Khmer OS Battambang', 'Kantumruy Pro', sans-serif;
  animation: pePop .15s cubic-bezier(.2, .8, .2, 1);
}
@keyframes pePop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pe-math-dhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.pe-math-dhead h3 { margin: 0; font-size: 16px; font-weight: 800; color: #1e293b; display: flex; align-items: center; gap: 8px; }
.pe-math-dhead button {
  background: transparent; border: 0; font-size: 18px; color: #64748b; cursor: pointer;
}
.pe-math-dhead button:hover { color: #ef4444; }

.pe-math-tabs {
  display: flex; gap: 4px; padding: 10px 18px 4px; background: #ffffff;
  border-bottom: 1px solid #f1f5f9; overflow-x: auto;
}
.pe-math-tab-btn {
  padding: 6px 12px; border-radius: 99px; border: 1px solid #e2e8f0;
  background: #f8fafc; color: #475569; font-size: 12.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: all .1s;
}
.pe-math-tab-btn:hover { background: #edf2f7; color: #0f172a; }
.pe-math-tab-btn.on {
  background: #0e72ed; color: #ffffff; border-color: #0e72ed;
}

.pe-math-palette {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px;
  background: #fafbfd; border-bottom: 1px solid #e2e8f0; max-height: 140px; overflow-y: auto;
}
.pe-math-sym-btn {
  min-width: 42px; height: 38px; padding: 2px 8px; border-radius: 8px;
  border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a;
  font-size: 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .1s; font-family: 'KaTeX_Math', 'Latin Modern Math', serif;
  font-style: italic;
}
.pe-math-sym-btn:hover {
  background: #eff6ff; border-color: #3b82f6; transform: translateY(-1px);
}

.pe-math-preview-card {
  padding: 16px 20px; background: #ffffff; text-align: center;
  min-height: 80px; display: flex; align-items: center; justify-content: center;
  overflow-x: auto; border-bottom: 1px solid #e2e8f0;
}
.pe-math-input-area {
  padding: 12px 18px; display: flex; flex-direction: column; gap: 6px; background: #f8fafc;
}
.pe-math-input-area label { font-size: 12px; font-weight: 700; color: #64748b; }
.pe-math-input-area textarea {
  width: 100%; height: 50px; border: 1px solid #cbd5e1; border-radius: 8px;
  padding: 8px 12px; font-family: monospace; font-size: 14px; color: #0f172a;
  outline: none; box-sizing: border-box; resize: none;
}
.pe-math-input-area textarea:focus { border-color: #0e72ed; box-shadow: 0 0 0 2px rgba(14,114,237,0.2); }

.pe-math-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; background: #ffffff;
}
.pe-math-actions .btn-ok {
  background: #16a34a; color: #ffffff; border: 0; padding: 8px 18px;
  border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer;
}
.pe-math-actions .btn-ok:hover { background: #15803d; }
.pe-math-actions .btn-cancel {
  background: #f1f5f9; color: #475569; border: 0; padding: 8px 16px;
  border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.pe-math-actions .btn-cancel:hover { background: #e2e8f0; color: #0f172a; }


/* ===== Edit slide (DeckCraft tools inside the slideshow) ===== */
.ts-tmenu .ts-tm-edit { background: linear-gradient(135deg, rgba(77,163,255,.22), rgba(124,92,255,.22)); }
.ts-tmenu .ts-tm-edit:hover { background: linear-gradient(135deg, rgba(77,163,255,.36), rgba(124,92,255,.36)); }
.ts-tmenu .ts-tm-edit u { text-decoration: none; margin-left: 6px; padding: 1px 7px; border-radius: 99px; background: #4da3ff; color: #06223f; font-size: 10px; font-weight: 800; letter-spacing: .04em; vertical-align: 2px; }
.ts-tmenu .ts-tm-div { height: 1px; margin: 4px 8px; background: rgba(255,255,255,.14); }


/* pictures (typeset equations, drawings) coming from a DeckCraft file */
.ts-picrow { text-align: center; margin: 10px 0; }
.ts-pic { height: auto; object-fit: contain; }

/* a slide that came with a dark background: keep its text light */
.ts-slide.ts-dk h1, .ts-slide.ts-dk h2, .ts-slide.ts-dk p, .ts-slide.ts-dk li { color: #f1f5f9 !important; }
.ts-slide.ts-dk .ts-kicker { color: #38bdf8 !important; }
