/* chapter-tools.css — Lesson Plan + Revision tools injected on every chapter page.
   Self-contained (no dependence on per-page CSS vars). Prefix: .ct- */
.ct-bar{display:flex;flex-wrap:wrap;gap:.6rem;align-items:center;background:#fff;border:1.5px solid #e0edf8;
  border-left:4px solid #0ea5e9;border-radius:10px;padding:.8rem 1rem;margin:0 0 1.4rem;
  box-shadow:0 1px 3px rgba(14,165,233,.08),0 1px 2px rgba(0,0,0,.04)}
.ct-bar-label{font-weight:800;color:#0f172a;font-size:.86rem;margin-right:.3rem}
.ct-bar-label small{display:block;font-weight:600;color:#64748b;font-size:.72rem}
.ct-btn{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;border:none;cursor:pointer;font-family:inherit;
  font-weight:800;font-size:.82rem;border-radius:8px;padding:.55rem .9rem;min-height:44px;color:#fff;background:#0ea5e9;transition:background .15s}
.ct-btn:hover{background:#0284c7}
.ct-btn.ct-rev{background:#16a34a}.ct-btn.ct-rev:hover{background:#15803d}
.ct-btn-ghost{background:#f1f5f9;color:#0f172a}.ct-btn-ghost:hover{background:#e2e8f0}

/* Modal */
.ct-overlay{position:fixed;inset:0;background:rgba(15,23,42,.55);z-index:9000;display:none;
  align-items:flex-start;justify-content:center;overflow-y:auto;padding:2.5rem 1rem}
.ct-overlay.ct-open{display:flex}
.ct-modal{background:#f8faff;width:100%;max-width:820px;border-radius:14px;box-shadow:0 20px 60px rgba(0,0,0,.3);
  overflow:hidden;margin-bottom:2rem}
.ct-modal-head{display:flex;align-items:center;gap:.7rem;background:#fff;border-bottom:1.5px solid #e0edf8;padding:1rem 1.3rem;position:sticky;top:0;z-index:2}
.ct-modal-head h2{font-family:Nunito,sans-serif;font-size:1.2rem;font-weight:900;color:#0284c7;margin:0;flex:1}
.ct-x{border:none;background:#f1f5f9;border-radius:8px;width:44px;height:44px;cursor:pointer;font-size:1.1rem;color:#475569;font-weight:800}
.ct-x:hover{background:#e2e8f0}
.ct-controls{background:#fff;border-bottom:1.5px solid #e0edf8;padding:.9rem 1.3rem;display:flex;flex-wrap:wrap;gap:1rem}
.ct-ctl{display:flex;flex-direction:column;gap:.35rem}
.ct-ctl > span{font-size:.68rem;font-weight:900;text-transform:uppercase;letter-spacing:.06em;color:#64748b}
.ct-chips{display:flex;flex-wrap:wrap;gap:.35rem}
.ct-chip{font-size:.76rem;font-weight:700;border:1.5px solid #e0edf8;background:#fff;color:#334155;border-radius:100px;
  padding:.5rem .8rem;min-height:38px;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent}
.ct-chip.ct-on{background:#e0f2fe;border-color:#7dd3fc;color:#0369a1}
.ct-chip.ct-on.ct-rev-on{background:#dcfce7;border-color:#86efac;color:#15803d}
.ct-gen{margin-left:auto;align-self:flex-end}
.ct-body{padding:1.3rem 1.5rem 2rem}

/* Output document */
.ct-doc{background:#fff;border:1.5px solid #e0edf8;border-radius:10px;padding:1.4rem 1.6rem;color:#1e293b;font-size:.9rem;line-height:1.7}
.ct-doc h3{font-family:Nunito,sans-serif;font-size:1.05rem;color:#0f172a;margin:1.4rem 0 .5rem;padding-bottom:.3rem;border-bottom:2px solid #e0f2fe}
.ct-doc h3:first-child{margin-top:0}
.ct-doc h4{font-size:.86rem;color:#0284c7;margin:.9rem 0 .3rem;font-weight:800}
.ct-doc ul,.ct-doc ol{margin:.3rem 0 .3rem 1.2rem}.ct-doc li{margin:.25rem 0}
.ct-doc table{width:100%;border-collapse:collapse;margin:.5rem 0;font-size:.84rem}
.ct-doc th,.ct-doc td{border:1px solid #e2e8f0;padding:.4rem .55rem;text-align:left;vertical-align:top}
.ct-doc th{background:#f0f9ff;font-weight:800;color:#0369a1}
.ct-meta-grid{display:grid;grid-template-columns:1fr 1fr;gap:.3rem .9rem;font-size:.84rem;margin:.4rem 0}
.ct-meta-grid b{color:#0369a1}
.ct-q{margin:.2rem 0}.ct-a{color:#166534;margin:.1rem 0 .5rem}
.ct-tag{display:inline-block;font-size:.6rem;font-weight:900;text-transform:uppercase;letter-spacing:.05em;
  background:#e0f2fe;color:#0369a1;border-radius:4px;padding:.08rem .35rem;margin-right:.35rem}
.ct-check{list-style:none;margin-left:0}.ct-check li{display:flex;gap:.5rem;align-items:flex-start}
.ct-check input{margin-top:.35rem}

/* Flashcards */
.ct-fc{perspective:1000px;margin:.6rem auto;max-width:480px}
.ct-fc-card{position:relative;min-height:170px;cursor:pointer}
.ct-fc-face{border:1.5px solid #e0edf8;border-radius:12px;padding:1.3rem;background:#fff;min-height:170px;
  display:flex;align-items:center;justify-content:center;text-align:center;font-size:.95rem}
.ct-fc-face.ct-back{background:#f0fdf4;color:#166534;border-color:#bbf7d0;display:none}
.ct-fc.ct-flip .ct-front{display:none}.ct-fc.ct-flip .ct-back{display:flex}
.ct-fc-nav{display:flex;justify-content:space-between;align-items:center;gap:.5rem;margin-top:.7rem;font-size:.82rem;color:#64748b}
.ct-fc-q{font-weight:700;line-height:1.5}
.ct-fc-opts{margin-top:.7rem;display:flex;flex-direction:column;gap:.25rem;font-size:.82rem;color:#475569;font-weight:600;text-align:left;align-self:stretch}
.ct-fc-a{line-height:1.6}
.ct-fc-rate{display:flex;gap:.6rem;justify-content:center;flex-wrap:wrap;margin-top:.7rem}
.ct-fc-know{background:#16a34a}.ct-fc-know:hover{background:#15803d}
.ct-fc-pos{text-align:center}
.ct-fc-pos .ct-k{color:#15803d}.ct-fc-pos .ct-r{color:#b45309;margin-left:.45rem}
.ct-fc-card.ct-rated-know .ct-fc-face{outline:2px solid #86efac;outline-offset:-2px}
.ct-fc-card.ct-rated-review .ct-fc-face{outline:2px solid #fcd34d;outline-offset:-2px}
.ct-fc-done{margin-top:.85rem;text-align:center;font-weight:700;color:#0369a1;display:flex;gap:.5rem;align-items:center;justify-content:center;flex-wrap:wrap}
.ct-we{background:#f0f9ff;border:1px solid #e0edf8;border-left:3px solid #0ea5e9;border-radius:8px;padding:.6rem .9rem;margin:.3rem 0}
.ct-we p{margin:.3rem 0}

/* Self-test */
.ct-quiz-q{border:1.5px solid #e0edf8;border-radius:10px;padding:1rem 1.1rem;margin:.6rem 0;background:#fff}
.ct-quiz-q .ct-opt{display:block;width:100%;text-align:left;border:1.5px solid #e0edf8;background:#f8faff;border-radius:7px;
  padding:.6rem .7rem;min-height:44px;margin:.3rem 0;cursor:pointer;font:inherit;color:#334155;-webkit-tap-highlight-color:transparent}
.ct-retry-btn{margin-top:.6rem}
.ct-opt.ct-correct{background:#f0fdf4;border-color:#22c55e;color:#15803d}
.ct-opt.ct-wrong{background:#fef2f2;border-color:#ef4444;color:#b91c1c}
.ct-reveal-btn{margin-top:.5rem}
.ct-selfans{display:none;margin-top:.5rem;padding-top:.5rem;border-top:1px dashed #e2e8f0;color:#166534}
.ct-selfans.ct-show{display:block}
.ct-score{font-weight:800;color:#0369a1;text-align:center;font-size:1.05rem;margin:.6rem 0}
.ct-hint{color:#64748b;font-size:.8rem;margin:.3rem 0}
.ct-empty{color:#64748b;text-align:center;padding:2rem}

@media(max-width:640px){.ct-meta-grid{grid-template-columns:1fr}.ct-controls{gap:.7rem}.ct-modal{max-width:100%}}
/* Tight phones: keep the bar/modal within the viewport, no horizontal scroll */
@media(max-width:380px){.ct-bar{padding:.7rem .8rem}.ct-overlay{padding:1rem .5rem}.ct-body{padding:1rem .9rem 1.6rem}.ct-doc{padding:1.1rem 1rem}}

/* Low-end / accessibility: kill non-essential motion */
@media (prefers-reduced-motion: reduce){
  .ct-btn,.ct-chip,.ct-bar-fade{transition:none!important}
  .ct-fc-face,.ct-bar i{transition:none!important}
}

/* Print: show only the generated document */
@media print{
  body{background:#fff}
  body.ct-printing > *{visibility:hidden}
  body.ct-printing .ct-overlay,body.ct-printing .ct-overlay *{visibility:visible}
  body.ct-printing .ct-overlay{position:absolute;inset:0;padding:0;background:#fff;display:block;overflow:visible}
  body.ct-printing .ct-modal{box-shadow:none;max-width:100%;margin:0}
  body.ct-printing .ct-modal-head,body.ct-printing .ct-controls,body.ct-printing .ct-doc-actions{display:none}
  .ct-fc-face.ct-back{display:flex!important}.ct-fc .ct-front{display:flex!important}
  .ct-selfans{display:block!important}
}

/* Responsive answer tables — chapter pages style .answer-table inline with
   width:100% but no wrap rule, so wide 3+ column tables overflow the viewport
   on narrow phones / FB in-app browsers (reported ui_layout_issue). This shared
   file loads AFTER the inline <style>; table.answer-table out-specifies the
   inline .answer-table, so these win. table-layout:fixed + wrapping keeps every
   table inside the page width without a horizontal scrollbar. */
table.answer-table{table-layout:fixed;width:100%;max-width:100%}
table.answer-table th,table.answer-table td{overflow-wrap:anywhere;word-break:break-word}
@media(max-width:480px){
  table.answer-table{font-size:.8rem}
  table.answer-table th,table.answer-table td{padding:.5rem .55rem}
}
