/* ==========================================================================
   മലയാള പാഠാവലി — Malayala Pataavali: the Kerala textbook, the printed page beside the page to tap
   (uses the school-book page styles .pp-* from book.css; its own classes are .pt-*)
   ========================================================================== */
.field-hint { display: block; margin-top: 2px; font-size: .8rem; font-weight: 400; color: var(--ink-3); }
.ax-pv { margin-left: 6px; font-size: .78rem; }
.rail-link[href="#/pataavali"] .icon { color: var(--leaf); }

/* ---- Home and contents ------------------------------------------------- */
.pt-cover { background: linear-gradient(90deg, rgba(0,0,0,.18) 0 7px, transparent 7px), linear-gradient(160deg, var(--leaf), #1E5426); box-shadow: inset 0 -10px 0 var(--gold), 0 8px 18px rgba(20,43,22,.18); }
.pt-card.is-mine { border-color: var(--leaf); box-shadow: 0 6px 0 var(--leaf-soft), var(--shadow-1); }
.pt-current { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .9rem; color: var(--ink-2); }
.pt-current .icon { width: 18px; height: 18px; color: var(--gold-deep); }
.pt-legal { margin-top: 6px; font-size: .8rem; color: var(--ink-3); }
.pt-off { margin: 12px 0; }
.pt-tasks { margin-top: 8px; }
.pt-task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pt-task { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; min-height: 56px; border-radius: 16px; background: var(--gold-soft); border: 1.5px solid var(--gold); color: var(--ink); text-decoration: none; }
.pt-task:hover { border-color: var(--teal); }
.pt-task.is-done { background: var(--leaf-soft); border-color: var(--leaf); }
.pt-task-ico .icon { width: 22px; height: 22px; color: var(--gold-deep); }
.pt-task.is-done .pt-task-ico .icon { color: var(--leaf); }
.pt-task-body { display: grid; gap: 2px; min-width: 0; }
.pt-task-body .ml { font-family: var(--f-ml); }
.pt-task-note { font-size: .85rem; color: var(--ink-2); font-style: italic; }
.pt-task-due { font-size: .82rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 480px) { .pt-task { grid-template-columns: auto 1fr; } .pt-task-due { grid-column: 2; } }

.pt-unit { margin-top: 34px; }
.pt-unit-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.pt-unit-n { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--leaf); color: #fff; font: 700 .85rem var(--f-ui); }
.pt-unit-title .en { font: 600 1rem var(--f-ui); color: var(--ink-2); }
.pt-unit-title .toc-pages { margin-left: auto; }
.pt-about { margin: -4px 0 14px; max-width: 70ch; color: var(--ink-2); line-height: 1.55; }
.pt-kind { font: 600 .78rem var(--f-ui); color: var(--ink-3); }
.pt-ch.is-current { border: 2px solid var(--gold); }
.pt-ch.is-closed { opacity: .72; background: var(--surface-2); }
.pt-ch.is-closed .week-main { cursor: default; }
.pt-ch .week-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pt-ch .chip { font-size: .72rem; padding: 1px 8px; min-height: 0; }
.pt-pct { color: var(--teal-deep); font-weight: 700; }

/* ---- A page: printed page | page to tap ---------------------------------- */
.pt-seg { display: none; }
.pt-wrap { display: grid; gap: 18px; align-items: start; }
.pt-original { margin: 0; display: grid; gap: 6px; }
.pt-original img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line-2); box-shadow: var(--shadow-1); background: #fff; }
.pt-original figcaption, .pt-original .pp-noimg { font-size: .82rem; color: var(--ink-3); text-align: center; }
.pt-side { display: grid; gap: 12px; min-width: 0; }
/* Wide screens: side by side (the printed page on the left, like an open book), or the tap page alone */
@media (min-width: 900px) {
  .pt-wrap.with-img { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
  .pt-wrap.with-img .pt-original { position: sticky; top: calc(var(--top-h) + 12px); max-height: calc(100vh - var(--top-h) - 24px); }
  .pt-wrap.with-img .pt-original img { max-height: calc(100vh - var(--top-h) - 56px); object-fit: contain; width: auto; max-width: 100%; margin-inline: auto; }
  .pt-wrap:not(.with-img) .pt-original { display: none; }
  .pt-wrap .pt-side .pp-sheet { padding-inline: clamp(16px, 2.4vw, 36px); }
}
/* Phones and small tablets: one at a time, switched with "Tap & learn | Book page" */
@media (max-width: 899.98px) {
  .pt-wide-only { display: none !important; }
  .pt-seg { display: inline-flex; margin: 0 0 12px; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; }
  .pt-seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: none; color: var(--ink-2); font: 600 .9rem var(--f-ui); cursor: pointer; }
  .pt-seg button .icon { width: 18px; height: 18px; }
  .pt-seg button[aria-pressed="true"] { background: var(--surface); color: var(--leaf); box-shadow: var(--shadow-1); }
  .pt-wrap.ph-lesson .pt-original { display: none; }
  .pt-wrap.ph-page .pt-side { display: none; }
}

/* The word card: pops up at the bottom of the screen when a word is tapped (× or Esc closes it; it also closes by itself) */
.pt-meaning-hint { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .88rem; color: var(--ink-2); }
.pt-meaning-hint .icon { width: 18px; height: 18px; color: var(--leaf); flex: none; }
.pt-meaning { position: fixed; z-index: 61; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: min(560px, calc(100vw - 32px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 44px 12px 16px; border-radius: 18px; background: var(--surface); border: 2px solid var(--leaf); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.pt-meaning[hidden] { display: none; }
@media (max-width: 899.98px) { .pt-meaning { bottom: calc(var(--tabbar-h, 72px) + 12px + env(safe-area-inset-bottom, 0px)); } }
body.has-kb-dock .pt-meaning { bottom: calc(var(--kb-dock-h, 300px) + 12px); }
.pt-meaning-x { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); cursor: pointer; }
.pt-meaning-x .icon { width: 16px; height: 16px; }
.pt-meaning-w { font: 800 1.35rem/1.3 var(--f-display); color: var(--red); }
.pt-meaning-tr { font: 600 .95rem var(--f-ui); font-style: italic; color: var(--gold-deep); }
.pt-meaning-en { flex: 1 1 100%; font-weight: 600; color: var(--teal-deep); min-width: 0; }
.pt-meaning-en .ml { font-family: var(--f-ml); }
.pt-meaning-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.pt-tr { margin: 0; font-size: .9rem; font-style: italic; font-weight: 600; color: var(--gold-deep); }
.pp-head-block:has(.pp-h1) .pt-tr { text-align: center; }
.pt-word-tr { font-size: .78rem; font-style: italic; color: var(--gold-deep); }
.pt-sheet .pp-word { grid-template-rows: auto auto auto; }
.pt-sheet .pp-word .icon { grid-row: 1 / span 3; }

/* Poem */
.pt-poem .pp-song-line .rt-translit { font-size: .85rem; }
.pt-by { margin-top: 8px; text-align: right; font-weight: 700; color: var(--ink-2); }

/* Activity done on paper / in class */
.pt-act { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--sky-soft, var(--surface-2)); border: 1.5px dashed var(--teal); }
.pt-act-ico { font-size: 1.8rem; line-height: 1; }
.pt-act > div { display: grid; gap: 4px; min-width: 0; justify-items: start; }
.pt-act .chip { font-size: .75rem; }
.pt-tip { margin: 2px 0 0; font-size: .85rem; color: var(--ink-2); }

/* Letters */
.pt-letters { display: grid; gap: 10px; padding: 14px; border-radius: 18px; background: var(--gold-soft); border: 1px solid var(--line); }
.pt-letter-row { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pt-letter { min-width: 56px; min-height: 56px; padding: 4px 10px; border-radius: 16px; border: 2px solid var(--gold); background: var(--surface); color: var(--red); font: 800 1.7rem/1 var(--f-display); cursor: pointer; }
.pt-letter:hover { border-color: var(--teal); }
.pt-letters-task { display: grid; gap: 6px; }

/* A picture on the printed page, described */
.pt-img { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 6px 10px; border-radius: 12px; border: 1px dashed var(--line-2); color: var(--ink-3); font-size: .85rem; line-height: 1.45; }
.pt-img-ico .icon { width: 18px; height: 18px; color: var(--leaf); margin-top: 2px; }
.pt-img .ml { font-family: var(--f-ml); color: var(--ink); font-size: 1rem; }
.pt-cell-blank { color: var(--ink-3); letter-spacing: .1em; }

/* Join the matching ones */
.pt-m-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.pt-m-col { display: grid; gap: 8px; align-content: start; }
.pt-m { display: grid; gap: 2px; min-height: 52px; padding: 8px 12px; border-radius: 14px; border: 2px solid var(--line-2); background: var(--surface); color: var(--ink); font: 700 1.1rem var(--f-ml); text-align: left; cursor: pointer; }
.pt-m .pp-en { margin: 0; font-family: var(--f-ui); font-weight: 500; }
.pt-m:hover { border-color: var(--teal); }
.pt-m.is-picked { border-color: var(--teal); background: var(--teal-soft); }
.pt-m.is-right { border-color: var(--leaf); background: var(--leaf-soft); cursor: default; }
.pt-m.is-wrong { border-color: var(--red); animation: pt-shake .3s; }
@keyframes pt-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
[data-motion="reduced"] .pt-m.is-wrong { animation: none; }

/* Words on this page; chapter goals and end */
.pt-gloss { margin-top: 22px; padding-top: 14px; border-top: 2px dashed var(--line-2); }
.pt-gloss summary { display: flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; font-weight: 700; color: var(--leaf); }
.pt-gloss summary .icon { width: 20px; height: 20px; }
.pt-gloss .pp-word-grid { margin-top: 8px; }
.pt-goals { margin: 0 0 14px; padding: 10px 16px; border-radius: 16px; background: var(--leaf-soft); border: 1px solid var(--line); }
.pt-goals summary { display: flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer; font-weight: 700; }
.pt-goals summary .icon { width: 18px; height: 18px; color: var(--gold-deep); flex: none; }
.pt-goals ul, .pt-goal-list { margin: 6px 0 4px; padding-left: 1.3em; display: grid; gap: 4px; color: var(--ink-2); }
.pt-chend { margin-top: 18px; padding: 16px; border-radius: 18px; background: var(--gold-soft); border: 1.5px solid var(--gold); display: grid; gap: 10px; }
.pt-chend p { margin: 0; }
.pt-chend .ml { font-family: var(--f-ml); }

/* Say it aloud */
.pt-speak { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.pt-speak-row { display: grid; gap: 10px; padding: 14px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.pt-speak-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pt-speak-run .feedback { margin-top: 12px; }

/* ---- Teachers ------------------------------------------------------------ */
.pt-booksel { max-width: 340px; margin-top: 10px; }
.pt-track p { margin: 6px 0; }
.pt-plan .pt-unit-row th { background: var(--leaf-soft); text-align: left; font-weight: 700; }
.pt-plan .ml { font-family: var(--f-ml); font-weight: 700; }
.pt-plan td { vertical-align: middle; }
.pt-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.pt-form select, .pt-form input { width: 100%; }
.pt-who { margin: 14px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.pt-who legend { font-weight: 700; padding: 0 6px; }
.pt-picks { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.pt-picks[hidden] { display: none; }
.pt-assigned { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pt-assigned-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.pt-assigned-row > span:first-child { flex: 1 1 280px; min-width: 0; }
.pt-assigned-row .ml { font-family: var(--f-ml); }
.pt-strip { display: flex; flex-wrap: wrap; gap: 3px; min-width: 120px; max-width: 360px; }
.pt-cell { display: inline-block; width: 12px; height: 16px; border-radius: 3px; background: var(--line); vertical-align: middle; }
.pt-cell.l1 { background: var(--gold); }
.pt-cell.l2 { background: var(--teal); }
.pt-cell.l3 { background: var(--leaf); }
.pt-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .82rem; color: var(--ink-2); }
@media print { .pt-meaning, .pt-seg, .pp-tools, .pp-nav, .pt-original { display: none !important; } }
/* .pp-lines is also an overlay class elsewhere in app.css: on book pages it is a plain block of writing lines */
.pp-body .pp-lines { position: static; inset: auto; pointer-events: auto; }
.pt-home .pb-source { margin-top: 14px; }

/* ---- More to do: stars, today's word, tracing, the memory game, dictation -------------------- */
.pt-star-total { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 2px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-deep); font-weight: 700; font-size: .85rem; }
.pt-star-total .icon { width: 16px; height: 16px; }
.pt-ch .week-prac .stars .icon { width: 14px; height: 14px; }
.pt-today { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 14px; margin: 14px 0; padding: 14px 18px; border-radius: 20px; background: linear-gradient(120deg, var(--gold-soft), var(--surface) 70%); border: 1.5px solid var(--gold); }
.pt-today-tag { grid-column: 1 / -1; font-size: .85rem; font-weight: 700; color: var(--gold-deep); }
.pt-today-word { display: flex; align-items: center; gap: 8px; }
.pt-today-word b { font: 800 clamp(1.7rem, 1.4rem + 1.2vw, 2.3rem)/1.2 var(--f-display); color: var(--red); }
.pt-today-tr { font-style: italic; font-weight: 600; color: var(--gold-deep); }
.pt-today-en { grid-column: 1 / -1; font-weight: 700; color: var(--teal-deep); }
.pt-today-from { grid-column: 1 / -1; font-size: .85rem; color: var(--ink-3); }
.pt-today-from .ml { font-family: var(--f-ml); }
@media (max-width: 480px) { .pt-today { grid-template-columns: 1fr; } }
.pt-trace { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.pt-trace-l { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; padding: 0 8px; border-radius: 12px; border: 1.5px dashed var(--leaf); color: var(--leaf); font: 800 1.2rem var(--f-display); text-decoration: none; }
.pt-trace-l:hover { background: var(--leaf-soft); }
.pt-mem-run .feedback { min-height: 1.6em; }
.pt-mem { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 720px; }
@media (max-width: 560px) { .pt-mem { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pt-mem-card { display: grid; place-items: center; min-height: 92px; padding: 8px; border-radius: 18px; border: 2px solid var(--leaf); background: var(--leaf); color: #fff; cursor: pointer; text-align: center; transition: transform .15s; }
.pt-mem-card:hover { transform: translateY(-2px); }
.pt-mem-card.is-up { background: var(--surface); color: var(--ink); border-color: var(--teal); }
.pt-mem-card.is-found { background: var(--leaf-soft); border-color: var(--leaf); cursor: default; }
.pt-mem-back { font-size: 1.8rem; }
.pt-mem-ml { font: 800 1.25rem/1.3 var(--f-display); color: var(--red); overflow-wrap: anywhere; }
.pt-mem-en { font: 700 .95rem/1.3 var(--f-ui); color: var(--teal-deep); overflow-wrap: anywhere; }
[data-motion="reduced"] .pt-mem-card { transition: none; }
.pt-dict { display: grid; gap: 12px; justify-items: start; }
.pt-dict .fill-box { width: 100%; max-width: 560px; }
.pt-dict-res .dict-word { font: 800 1.8rem var(--f-display); color: var(--teal-deep); margin: 4px 0; }

/* 💡 Example answers under the book's questions */
.pt-help { border-radius: 16px; border: 1.5px solid var(--gold); background: linear-gradient(160deg, var(--gold-soft), var(--surface) 75%); overflow: hidden; }
.pt-help > summary { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; cursor: pointer; list-style: none; }
.pt-help > summary::-webkit-details-marker { display: none; }
.pt-help > summary::after { content: '▾'; margin-left: auto; color: var(--gold-deep); transition: transform .15s; }
.pt-help[open] > summary::after { transform: rotate(180deg); }
.pt-help-ico { font-size: 1.3rem; }
.pt-help-q { color: var(--ink-2); font-size: .9rem; }
.pt-help-n { min-width: 26px; padding: 1px 8px; border-radius: 999px; background: var(--gold); color: #3B2600; font-weight: 800; font-size: .8rem; text-align: center; }
.pt-help-body { display: grid; gap: 10px; padding: 0 16px 14px; }
.pt-help-how { display: flex; gap: 6px; margin: 0; font-size: .9rem; color: var(--ink-2); }
.pt-help-how .icon { width: 18px; height: 18px; flex: none; color: var(--gold-deep); margin-top: 2px; }
.pt-help-list { margin: 0; padding-left: 1.5em; display: grid; gap: 8px; }
.pt-help-list li::marker { color: var(--gold-deep); font-weight: 800; }
.pt-help-line { display: flex; align-items: flex-start; gap: 6px; }
.pt-help-line .rt { flex: 1; min-width: 0; }
.pt-help-list .pp-en { margin: 0; }
.pt-help-words { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .9rem; }
.pt-help-word { padding: 4px 10px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; font: 500 .88rem var(--f-ui); }
.pt-help-word .ml { font-family: var(--f-ml); font-weight: 700; }
.pt-help-word:hover { border-color: var(--teal); }
.pt-help-note { margin: 0; font-size: .82rem; color: var(--ink-3); font-style: italic; }
[data-motion="reduced"] .pt-help > summary::after { transition: none; }
/* 🚀 Think more (advanced learners) */
.pt-adv { margin-top: 16px; border-radius: 18px; border: 1.5px solid var(--teal); background: linear-gradient(160deg, var(--teal-soft), var(--surface) 70%); }
.pt-adv > summary { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; cursor: pointer; list-style: none; }
.pt-adv > summary::-webkit-details-marker { display: none; }
.pt-adv > summary::after { content: '▾'; margin-left: auto; color: var(--teal-deep); }
.pt-adv[open] > summary::after { transform: rotate(180deg); }
.pt-adv > summary .ml { font-family: var(--f-ml); }
.pt-adv-body { display: grid; gap: 10px; padding: 0 12px 12px; }
.pt-adv .pt-help { border-color: var(--line-2); background: var(--surface); }
.pt-think-q { display: grid; gap: 2px; min-width: 0; }
.pt-think-q .ml { font-family: var(--f-ml); font-size: 1.02rem; }
.pt-think-ask { display: flex; align-items: flex-start; gap: 6px; padding: 8px 10px; border-radius: 12px; background: var(--teal-soft); }
.pt-think-ask .rt { flex: 1; min-width: 0; }

/* Books for different levels (Kerala Padavali, Kanikkonna): level chip and the printed page number */
.pt-level { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); font-weight: 700; }
.pp-printed { color: var(--ink-3); font-size: .85rem; font-weight: 600; margin-left: 4px; }
.pp-fill { grid-template-columns: minmax(0, 1fr); }
.pp-fill-prompt { grid-template-columns: minmax(0, 1fr); }
.pp-fill-prompt > * { max-width: 100%; min-width: 0; }
/* A table of single letters (an alphabet chart) fits a phone without sideways scrolling */
.pp-table--letters td { min-width: 0; padding: 6px 4px; text-align: center; font-size: 1.25rem; }
/* Long riddles and sentences in "Join them" wrap instead of pushing the page wider */
.pt-m-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pt-m-col, .pt-m { min-width: 0; }
.pt-m { overflow-wrap: break-word; }
@media (max-width: 480px) { .pt-m-cols { gap: 8px 8px; } .pt-m { padding: 8px; font-size: 1rem; } }
.pt-cover .pb-cover-t { max-width: 100%; padding: 0 4px; text-align: center; font-size: .78rem; line-height: 1.2; overflow-wrap: anywhere; }

/* Tablets held upright (iPad 744–899px wide): the printed page and the tap page side by side, like on a laptop.
   "Side by side | Tap & learn | Book page" switches; phones (under 700px) keep one at a time. */
@media (min-width: 700px) and (max-width: 899.98px) {
  .pt-wrap.ph-both { grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 12px; }
  .pt-wrap.ph-both .pt-original { position: sticky; top: calc(var(--top-h, 64px) + 8px); }
  .pt-wrap.ph-both .pt-original img { width: auto; max-width: 100%; margin-inline: auto; object-fit: contain;
    max-height: calc(100vh - var(--top-h, 64px) - var(--tabbar-h, 72px) - 48px); max-height: calc(100dvh - var(--top-h, 64px) - var(--tabbar-h, 72px) - 48px); }
  .pt-wrap.ph-both .pt-side .pp-sheet { padding-inline: 14px; }
  .pt-wrap.ph-both .pt-original figcaption { font-size: .75rem; }
}
/* Phones (iPhone, Android): "Both" — the printed page stays pinned under the top bar while the tap page scrolls
   beneath it. "Bigger picture" gives the page more of the screen; tapping the page opens it full screen. */
@media (max-width: 699.98px) {
  .pt-wrap.ph-both { display: block; }
  .pt-wrap.ph-both .pt-original { position: sticky; top: calc(var(--top-h, 64px) + env(safe-area-inset-top, 0px)); z-index: 5; display: grid;
    margin: 0 -16px 12px; padding: 6px 16px 4px; background: var(--ground); box-shadow: 0 8px 10px -8px rgba(0,0,0,.35); }
  .pt-wrap.ph-both .pt-original img { width: auto; max-width: 100%; margin-inline: auto; object-fit: contain; height: 36vh; height: 36dvh; }
  .pt-wrap.ph-both.pt-tall .pt-original img { height: 54vh; height: 54dvh; }
  .pt-wrap.ph-both .pt-original figcaption { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: .72rem; }
  .pt-wrap.ph-both .pt-side .reader { position: static; }
  .pt-lbl-wide { display: none; }
}
@media (min-width: 700px) { .pt-lbl-narrow, .pt-phone-only { display: none !important; } }
.pt-wrap:not(.ph-both) .pt-phone-only { display: none; }
.pt-size { min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 600 .75rem var(--f-ui); cursor: pointer; }
/* Safari and Chrome on iPad: size the sticky page to the visible screen (the address bar comes and goes) */
@supports (height: 100dvh) {
  @media (min-width: 900px) {
    .pt-wrap.with-img .pt-original { max-height: calc(100dvh - var(--top-h) - 24px); }
    .pt-wrap.with-img .pt-original img { max-height: calc(100dvh - var(--top-h) - 56px); }
  }
}
.pt-original img { cursor: zoom-in; }
/* The printed page full screen (pinch to zoom on a tablet) */
.pt-zoom { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(0,0,0,.92); overflow: auto; touch-action: pinch-zoom pan-x pan-y; }
.pt-zoom::backdrop { background: rgba(0,0,0,.6); }
.pt-zoom img { display: block; width: min(100%, 1100px); height: auto; margin: 0 auto; background: #fff; }
.pt-zoom-x { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 2; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-1); }
/* Reading room (Pataavali pages): the side menu folds away so the printed page and the tap page get the width */
.pt-rail-only { display: none !important; }
@media (min-width: 960px) {
  .pt-rail-only { display: inline-flex !important; }
  html.pt-focus .shell:not(.shell--guest) { grid-template-columns: 1fr; }
  html.pt-focus .shell:not(.shell--guest) > .rail { display: none; }
}
/* "Read the page" at the top of the tap side: let its buttons wrap in the narrower column */
.pt-side > .reader, .pt-side > [class*="reader"] { min-width: 0; }
/* Grown-ups: which classes a book is for, and who has it */
.pt-forclasses { display: grid; gap: 2px; margin: 4px 0 8px; font-size: .9rem; }
.pt-forclasses p { margin: 0; display: flex; gap: 6px; align-items: flex-start; }
.pt-forclasses .icon { width: 18px; height: 18px; flex: none; color: var(--leaf); margin-top: 2px; }

/* 🧩 Joined words: a long word taken apart into the words it is made of */
.pt-split { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; flex-basis: 100%; }
.pt-split-k { font: 700 .82rem var(--f-ui); color: var(--ink-3); margin-right: 2px; }
.pt-split-part { min-height: 36px; padding: 2px 10px; border-radius: 10px; border: 1.5px solid var(--leaf); background: var(--leaf-soft, var(--surface-2)); color: var(--ink); font: 700 1.05rem var(--f-ml); cursor: pointer; }
.pt-split-part:hover { background: var(--surface); }
.pt-split-plus, .pt-split-eq { color: var(--ink-3); font-weight: 800; }
.pt-joined { margin-top: 18px; padding-top: 12px; border-top: 2px dashed var(--line-2); }
.pt-joined summary { display: flex; align-items: center; gap: 4px; min-height: 44px; cursor: pointer; font-weight: 700; color: var(--leaf); }
.pt-joined-tip { font-size: .85rem; margin: 2px 0 8px; }
.pt-joined-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pt-joined-list > li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.pt-joined-list .pt-split { flex-basis: auto; }
.pt-joined-w { border: 0; background: none; padding: 0; font: 800 1.12rem var(--f-ml); color: var(--red); cursor: pointer; }
.pt-joined-edit { margin-left: auto; }
.pt-split-prev { min-height: 40px; }
.pt-practice .pt-joined { margin: 0 0 16px; border-top: 0; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.pt-joined-list .pt-split-k { display: none; }
/* Children: "My books | Explore other books" */
.pt-home-tabs { margin: 8px 0 14px; }
.pt-explore-tip, .pt-exploring { margin: 0 0 12px; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--line-2); font-size: .92rem; }

/* ---- ✏️ Page editor (teachers): edit the tap-and-learn page beside the book ---------------------------- */
.btn.pt-edit-btn { background: var(--surface); border-color: var(--leaf); color: var(--ink); }
.btn.pt-edit-btn .icon { color: var(--leaf); }
.pt-edited { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: .85rem; color: var(--ink-3); }
.pt-edited .icon { width: 16px; height: 16px; color: var(--leaf); }
.pe-bar { position: sticky; top: calc(var(--top-h, 64px) + env(safe-area-inset-top, 0px)); z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin: 0 0 14px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.pe-status { margin-left: auto; font-size: .85rem; color: var(--ink-3); }
.pe-status.is-dirty { color: var(--red); font-weight: 700; }
.pe-draft { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--red); }
.pe-grid { display: grid; gap: 18px; align-items: start; }
@media (min-width: 1100px) { .pe-grid { grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); } .pe-book { position: sticky; top: calc(var(--top-h, 64px) + 80px); } .pe-book img { max-height: calc(100vh - var(--top-h, 64px) - 120px); width: auto; max-width: 100%; margin-inline: auto; } }
@media (max-width: 1099.98px) { .pe-book { max-width: 420px; } }
.pe-main { display: grid; gap: 16px; min-width: 0; }
@media (min-width: 1500px) { .pe-main { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); align-items: start; } .pe-preview { position: sticky; top: calc(var(--top-h, 64px) + 80px); max-height: calc(100vh - var(--top-h, 64px) - 100px); overflow: auto; } }
.pe-list { display: grid; gap: 6px; min-width: 0; }
.pe-block { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.pe-block-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.pe-block-n { font: 800 .8rem var(--f-ui); color: var(--ink-3); min-width: 1.4em; }
.pe-block-btns { margin-left: auto; display: flex; gap: 2px; }
.pe-del:hover { color: var(--red); }
.pe-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px 14px; padding: 12px; }
.pe-field { min-width: 0; }
.pe-field.span-2, .pe-fields > .pe-rows { grid-column: 1 / -1; }
.pe-fields textarea { min-height: 3.2em; resize: vertical; }
.pe-rows { display: grid; gap: 8px; }
.pe-rows-label { margin: 0; font-weight: 700; font-size: .9rem; }
.pe-row { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)) auto; gap: 8px; align-items: end; padding: 8px; border-radius: 12px; background: var(--surface-2); }
@media (max-width: 700px) { .pe-row { grid-template-columns: minmax(0, 1fr) auto; } .pe-row > .pe-field { grid-column: 1; } .pe-row-btns { grid-column: 2; grid-row: 1; } }
.pe-row-btns { display: flex; gap: 2px; }
.pe-add { display: grid; justify-items: center; }
.pe-add-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 12px; border: 1px dashed var(--line-2); border-radius: 999px; background: none; color: var(--ink-3); font: 600 .78rem var(--f-ui); cursor: pointer; opacity: .75; }
.pe-add-btn:hover, .pe-add-btn[aria-expanded="true"] { opacity: 1; color: var(--leaf); border-color: var(--leaf); }
.pe-add-btn .icon { width: 14px; height: 14px; }
.pe-add-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; width: 100%; margin: 6px 0; }
.pe-add.is-big { justify-items: stretch; padding: 12px; border: 2px dashed var(--line-2); border-radius: 16px; }
.pe-add-kind { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font: 600 .85rem var(--f-ui); }
.pe-add-kind:hover { border-color: var(--leaf); }
.pe-add-emoji { grid-row: 1 / 3; font-size: 1.3rem; }
.pe-add-kind .ml { font-size: .8rem; color: var(--ink-3); font-weight: 600; }
.pe-sub { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font: 700 .95rem var(--f-ui); color: var(--leaf); }
.pe-preview { padding: 14px; border-radius: 16px; border: 2px solid var(--leaf); background: var(--surface); min-width: 0; }
.pe-pic { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); margin: 4px 0 8px; }
.pe-words { padding: 10px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.pe-words summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 6px; min-height: 40px; }
.pe-versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pe-versions li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.pe-pages { display: flex; justify-content: space-between; margin-top: 18px; }
/* Teachers' styles and pictures on the page */
.pp-style-big .rt-line, .pp-style-big .pp-h2 { font-size: 1.35em; }
.pp-block.pp-style-box { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--leaf); }
.pp-style-red .rt-line, .pp-style-red .ml { color: var(--red); }
.pp-style-green .rt-line, .pp-style-green .ml { color: var(--leaf); }
.pp-style-blue .rt-line, .pp-style-blue .ml { color: var(--teal, #1f6f8b); }
.pt-pic { margin: 0; display: grid; gap: 6px; justify-items: center; }
.pt-pic img { display: block; max-width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line-2); background: #fff; cursor: zoom-in; }
.pt-pic--small img { max-width: min(100%, 220px); }
.pt-pic--medium img { max-width: min(100%, 420px); }
.pt-pic figcaption { text-align: center; }

/* ---- 📒 Homework from the book -------------------------------------------------------------------- */
.hw-card { margin: 0 0 14px; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); display: grid; gap: 10px; }
.hw-card.is-done { border-color: var(--leaf); }
.hw-card.is-late { border-color: var(--red); }
.hw-card.is-past { opacity: .85; }
.hw-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.hw-card-head > div { flex: 1 1 220px; min-width: 0; }
.hw-title { margin: 0; font-size: 1.15rem; }
.hw-due, .hw-sum { margin: 2px 0 0; font-size: .88rem; color: var(--ink-3); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.hw-due .icon { width: 16px; height: 16px; }
.hw-note { display: flex; gap: 8px; margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); font-size: .92rem; }
.hw-note .icon { flex: none; width: 18px; height: 18px; color: var(--leaf); margin-top: 2px; }
.hw-sec { display: grid; gap: 6px; }
.hw-sec-t { margin: 0; font-weight: 700; font-size: .92rem; }
.hw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hw-chip { display: inline-flex; align-items: center; gap: 2px; min-height: 34px; padding: 2px 10px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); font: 600 .85rem var(--f-ui); text-decoration: none; cursor: pointer; }
.hw-chip small { font-size: .7rem; opacity: .85; }
.hw-chip.is-done { background: var(--leaf); border-color: var(--leaf); color: var(--surface); }
.hw-chip.is-new { background: color-mix(in srgb, var(--leaf) 18%, var(--surface)); border-color: var(--leaf); color: var(--ink); }
.hw-chip.is-review { background: color-mix(in srgb, var(--gold, #d89b2b) 22%, var(--surface)); border-color: var(--gold, #d89b2b); color: var(--ink); }
.hw-chip.is-review.is-done { background: var(--gold, #d89b2b); color: #1d1a12; }
.hw-prac { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hw-prac li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.hw-extra { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.hw-yay { margin: 0; font-size: 1.05rem; }
.hw-past summary { cursor: pointer; font-weight: 700; min-height: 40px; display: flex; align-items: center; }
.hw-banner { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; padding: 8px 14px; border-radius: 999px; background: color-mix(in srgb, var(--gold, #d89b2b) 20%, var(--surface)); border: 1px solid var(--gold, #d89b2b); color: var(--ink); text-decoration: none; font-size: .9rem; }
.hc-hw a { color: inherit; }
/* Teachers' form */
.hw-form .form-grid { align-items: start; }
.hw-type { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 12px; }
.hw-pick-sum { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.hw-pages { display: grid; gap: 8px; max-height: 520px; overflow: auto; padding: 4px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.hw-unit { padding: 6px 10px; border-radius: 12px; background: var(--surface); }
.hw-unit > summary { cursor: pointer; min-height: 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.hw-chap { padding: 6px 0 8px; border-top: 1px dashed var(--line); display: grid; gap: 6px; }
.hw-chap-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: .92rem; }
.hw-chap-btns { margin-left: auto; font-size: .8rem; }
.hw-filter { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.hw-table tr.is-done th, .hw-table tr.is-done td { background: color-mix(in srgb, var(--leaf) 10%, transparent); }
.hw-extras-pick label { align-items: flex-start; }
.pe-block-head { flex-wrap: wrap; } .pe-block-head > b, .pe-block-head > .ml { min-width: 0; } @media (max-width: 480px) { .pe-block-head .ml.muted { display: none; } .pe-bar .pe-status { flex-basis: 100%; margin-left: 0; } }
/* Homework: review ticks, finishing, notes and teachers' feedback */
.hw-rev { display: inline-flex; align-items: center; gap: 2px; }
.hw-rev-tick { min-height: 34px; padding: 0 8px; border-radius: 999px; border: 1px dashed var(--line-2); background: none; color: var(--ink-3); font: 600 .75rem var(--f-ui); cursor: pointer; }
.hw-rev-tick:hover { color: var(--leaf); border-color: var(--leaf); }
.hw-fb { padding: 10px 12px; border-radius: 14px; background: color-mix(in srgb, var(--leaf) 10%, var(--surface)); border: 1px solid var(--leaf); }
.hw-fb p { margin: 2px 0; }
.hw-sticker { font-size: 1.1rem; font-weight: 700; }
.hw-said { display: flex; gap: 6px; margin: 0; font-size: .9rem; color: var(--ink-2); }
.hw-said .icon { width: 16px; height: 16px; flex: none; margin-top: 3px; }
.hw-say { width: 100%; min-height: 3em; }
.hw-fb-edit { display: grid; gap: 4px; min-width: 200px; }
.hw-note-cell { max-width: 260px; font-size: .88rem; }
.pe-grid.pe-grid--wide { grid-template-columns: minmax(0, 1fr); }

/* ---- 📚 Class library ----------------------------------------------------------------------------- */
.lib-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.lib-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); height: 100%; }
.lib-card:hover { border-color: var(--leaf); }
.lib-cover { font-size: 2.2rem; line-height: 1; }
.lib-body { display: grid; gap: 4px; justify-items: start; min-width: 0; }
.lib-body b { font-size: 1.15rem; }
.lib-sheet { margin-top: 12px; }
.lib-meta .form-grid { align-items: start; }
/* ---- 🔤 Words for each letter --------------------------------------------------------------------- */
.lw-grid { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.lw-word { width: 100%; display: grid; justify-items: center; gap: 2px; padding: 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.lw-pic { font-size: 2rem; }
.lw-ml { font: 800 1.2rem var(--f-ml); }
.lw-tr { font-size: .8rem; color: var(--ink-3); }
.lw-en { font-size: .85rem; }
.lw-word .icon { width: 16px; height: 16px; color: var(--leaf); }
.lw-edit { margin-top: 10px; padding: 10px 12px; border-radius: 14px; border: 1px dashed var(--line-2); }
.lw-edit summary { cursor: pointer; font-weight: 700; min-height: 40px; display: flex; align-items: center; gap: 6px; }
.lw-rows { display: grid; gap: 6px; margin: 8px 0; }
.lw-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 70px auto; gap: 6px; align-items: center; }
@media (max-width: 520px) { .lw-row { grid-template-columns: minmax(0, 1fr) 60px auto; } .lw-row > input:nth-child(2) { grid-column: 1 / -1; grid-row: 2; } }
.lw-extras { margin-top: 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.lw-extras-t { margin: 0 0 4px; font-weight: 700; font-size: .85rem; }
.lw-extras-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; }
.lw-extras-l { font: 800 1.3rem var(--f-ml); text-decoration: none; color: var(--red); margin-right: 4px; }
.lg-stage { display: grid; justify-items: center; gap: 14px; margin: 18px 0; }
.lg-count { margin: 0; color: var(--ink-3); font-weight: 700; }
.lg-word { display: grid; justify-items: center; gap: 4px; padding: 18px 28px; border-radius: 24px; border: 2px solid var(--leaf); background: var(--surface); cursor: pointer; color: var(--ink); }
.lg-pic { font-size: 4rem; line-height: 1; }
.lg-en { font-size: .95rem; color: var(--ink-3); }
.lg-q { margin: 0; font-weight: 700; }
.lg-opts { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.lg-opt { width: 96px; height: 96px; border-radius: 24px; border: 2px solid var(--line-2); background: var(--surface); font: 800 2.6rem var(--f-ml); color: var(--ink); cursor: pointer; }
.lg-opt.is-wrong { border-color: var(--red); opacity: .55; }
.lg-done { font-size: 1.3rem; }
/* Kalari school / other learners */
.ax-learner { margin-left: 6px; }
.ax-school { align-items: flex-start; gap: 6px; }

/* Readable in light and dark: the English part of "Read the page" on the orange button */
.rd-play .en, .rd-play .rd-txt .en { color: inherit; opacity: .9; }
/* Form boxes in the new tools (page editor, homework, attendance, letter words, library): themed for light and dark */
.field textarea, .pe-fields textarea, .hw-say, .att-note, .hw-fb-edit input, .hw-fb-edit select, .lw-row input, .pt-split-dlg input {
  font: 500 1rem/1.4 var(--f-ui); padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; min-height: 42px; }
.field textarea.ml, .pe-fields textarea.ml, .lw-row input.ml { font-family: var(--f-ml); font-size: 1.1rem; }
.field textarea:focus, .hw-say:focus, .att-note:focus, .hw-fb-edit input:focus, .hw-fb-edit select:focus, .lw-row input:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.field textarea::placeholder, .hw-say::placeholder, .att-note::placeholder, .hw-fb-edit input::placeholder, .lw-row input::placeholder { color: var(--ink-3); }
/* Practice editor: answers to choose from */
.pp-opts-edit { grid-column: 1 / -1; display: grid; gap: 6px; }
.pp-opt-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.pp-opt-row input[type=radio] { width: 22px; height: 22px; accent-color: var(--leaf); }
.pp-opt-row input.ml { font: 500 1.1rem var(--f-ml); padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); min-height: 42px; }
