/* PlaitoMaths learning page — landscape two-panel, tablet/stylus first. */
html, body { height: 100%; }
body { overflow: hidden; }            /* panels manage their own scroll */
.muted { color: var(--ink-2); }

/* ── top bar ── */
.topbar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 8px var(--sp-4); height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand span { color: var(--brand); }
.navbar { display: flex; flex: 1; flex-wrap: nowrap; gap: 5px; align-items: center; overflow-x: auto; }
.nav-group-label { font-size: .65rem; font-weight: 800; text-transform: uppercase; color: var(--ink-3); margin: 0 4px 0 10px; white-space: nowrap; }
.nav-pill { flex: none; width: 28px; height: 28px; border-radius: var(--r-sm); border: 1.5px solid var(--border-2);
  background: var(--surface); font-weight: 700; font-size: .78rem; color: var(--ink-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; }
.nav-pill.done { background: #e8f6ee; border-color: var(--ok); color: var(--ok); }
.nav-pill.current { background: var(--brand); border-color: var(--brand); color: #fff; }
.help-group { display: flex; gap: 6px; }
.hbtn { appearance: none; border: 1.5px solid var(--border-2); background: var(--surface); border-radius: var(--r-pill);
  padding: 7px 14px; font: inherit; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); cursor: pointer; white-space: nowrap; }
.hbtn:hover { background: var(--surface-2); border-color: var(--brand); }

/* ── panels ── */
.panels { display: grid; grid-template-columns: 40% 60%; height: calc(100vh - 52px); }
.lhs { border-right: 2px solid var(--border); padding: var(--sp-5) var(--sp-5) var(--sp-6); overflow-y: auto; background: var(--surface-2); }
.rhs { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }

.qtag { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.section-chip { font-size: var(--fs-sm); font-weight: 800; padding: 4px 12px; border-radius: var(--r-pill); }
.section-chip.maths { background: var(--brand-50); color: var(--brand-700); }
.section-chip.thinking { background: #d7f4f0; color: #0b6b62; }
.section-chip.reading { background: #fdecd2; color: #9a5a05; }
.qcounter { color: var(--ink-3); font-size: var(--fs-sm); font-weight: 600; }
.qprompt { font-size: 1.05rem; line-height: 1.5; white-space: pre-wrap; }
.passage-d { margin-top: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 12px; background: var(--surface); }
.passage-d summary { cursor: pointer; font-weight: 700; font-size: var(--fs-sm); color: var(--c-reading); }
.passage-d .pimg { max-width: 100%; border: 1px solid var(--border); border-radius: var(--r-sm); margin-top: var(--sp-2); }
.passage-d .qprompt { font-size: .95rem; margin-top: var(--sp-2); }
.qimages img { max-width: 100%; border: 1px solid var(--border); border-radius: var(--r-sm); margin-top: var(--sp-3); background: #fff; }

.lhs-options { display: grid; gap: 8px; margin-top: var(--sp-5); }
.lhs-options .opt { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border: 2px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); cursor: pointer; font-size: .98rem; }
.lhs-options .opt:hover { border-color: #bcc7e8; }
.lhs-options .opt.selected { border-color: var(--brand); background: linear-gradient(135deg,#eef0fe,#fff); font-weight: 600; color: var(--brand-700); }
.lhs-options .opt .l { width: 28px; height: 28px; flex: none; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; background: var(--surface-2); font-weight: 800; font-size: .85rem; }
.lhs-options .opt.selected .l { background: var(--brand); color: #fff; }

/* ── toolbar ── */
.toolbar { display: flex; align-items: center; gap: var(--sp-4); padding: 8px var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tool-group { display: flex; gap: 6px; align-items: center; }
.tool { appearance: none; border: 1.5px solid var(--border-2); background: var(--surface); width: 40px; height: 40px;
  border-radius: var(--r-md); font-size: 1.15rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tool:hover { border-color: var(--brand); }
.tool.active { background: var(--brand-50); border-color: var(--brand); }
.swatches .sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--border-2); cursor: pointer; }
.swatches .sw.active { box-shadow: 0 0 0 2.5px var(--brand); transform: scale(1.12); }
.tool-spacer { flex: 1; }
.save-status { font-size: var(--fs-sm); color: var(--ink-3); }

/* ── annotatable workspace ── */
.work-scroll { flex: 1; overflow-y: auto; min-height: 0; background:
  repeating-linear-gradient(180deg, transparent, transparent 33px, #eef1f8 33px, #eef1f8 34px); }
.work-wrap { position: relative; min-height: 100%; }
.work-content { position: relative; z-index: 1; padding: var(--sp-5) var(--sp-6); }
.work-q { border: 1px dashed var(--border-2); border-radius: var(--r-md); padding: var(--sp-4); background: rgba(255,255,255,.75); }
.work-q .qprompt { font-size: 1.02rem; }
.work-q img { max-width: 100%; border-radius: var(--r-sm); margin-top: var(--sp-2); }
.work-solution { margin-top: var(--sp-4); min-height: 620px; }
.sol-label { font-size: var(--fs-sm); font-weight: 700; color: var(--brand-700); margin-bottom: var(--sp-2); }
canvas.annotation { position: absolute; top: 0; left: 0; z-index: 2; touch-action: none; cursor: crosshair; }

/* ── rhs footer ── */
.rhs-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: 10px var(--sp-5); border-top: 1px solid var(--border); background: var(--surface); }
.footer-note { color: var(--ink-3); font-size: var(--fs-sm); }

/* ── completion ── */
.screen.done { display: grid; place-items: center; height: 100vh; padding: var(--sp-6); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md); }
.done-card { max-width: 640px; padding: var(--sp-7); text-align: center; }
.done-list { display: grid; gap: 8px; margin: var(--sp-5) 0; text-align: left; }
.done-list .row { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--surface-2); border-radius: var(--r-sm); font-size: var(--fs-sm); }
.done-list .row .tx { color: var(--ink-2); }
.done-actions { display: flex; gap: var(--sp-3); justify-content: center; }

/* ── modal ── */
.modal-back { position: fixed; inset: 0; background: rgba(20,30,55,.45); display: grid; place-items: center; z-index: 100; padding: var(--sp-5); }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: min(640px, 100%); max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); font-weight: 800; }
.modal-x { appearance: none; border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; color: var(--ink-2); }
.modal-body { padding: var(--sp-5); overflow-y: auto; line-height: 1.55; white-space: pre-wrap; }
.modal-body .latex { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--surface-2); padding: var(--sp-3); border-radius: var(--r-sm); white-space: pre-wrap; }
.modal-foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-3); }

@media (max-width: 760px) {
  .panels { grid-template-columns: 1fr; }   /* stack if forced portrait */
}
