/* Reteach Lesson Builder: calm classroom palette, readable type (Atkinson Hyperlegible) */
:root {
  --bg: #f6f4ee; --paper: #ffffff; --ink: #1f2a36; --muted: #5d6b7a; --line: #dcd6c8;
  --brand: #1f5f8b; --brand-ink: #ffffff; --accent: #e0a526; --ido: #1f5f8b; --wedo: #2e7d5b; --youdo: #8a4fb0; --check: #c2542d;
  --radius: 12px;
}
* { box-sizing: border-box; min-width: 0; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 "Atkinson Hyperlegible", system-ui, sans-serif; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 24px; }
h3 { font-size: 19px; font-family: inherit; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; }
.top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; padding: 14px max(4vw, 16px); background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand small { display: block; color: var(--muted); font-size: 13px; }
.mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: Fraunces, serif; font-size: 22px; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); }
nav a.on { background: var(--brand); color: var(--brand-ink); }
.who { font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.who input { width: 170px; }
main { max-width: 1100px; margin: 0 auto; padding: 28px max(4vw, 16px) 80px; }
.banner { background: #fff3d6; border-bottom: 1px solid #ecd49a; padding: 10px max(4vw, 16px); font-size: 15px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 15px; }
label.f span.hint { font-weight: 400; color: var(--muted); font-size: 14px; }
input, select, textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 44px; font-size: 16px; }
textarea { min-height: 90px; width: 100%; }
input:focus, select:focus, textarea:focus, [contenteditable]:focus, button:focus-visible { outline: 3px solid #9cc3e0; outline-offset: 1px; }
.btn { border: 0; border-radius: 10px; padding: 12px 18px; min-height: 44px; background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.warn { background: transparent; color: #a03222; border: 1px solid #a03222; }
.btn:disabled { opacity: .55; cursor: wait; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.std-text { background: #f1efe7; border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; margin-top: 10px; }
.build-standard-controls { grid-template-columns: minmax(90px, 1fr) minmax(0, 3fr); }
.build-standard-discovery { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.standard-search-controls { grid-template-columns: minmax(0, 2fr) minmax(160px, 1fr); }
.search-help { margin: 8px 0; font-size: 14px; }
.standard-results { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.standard-results:empty { display: none; }
.standard-result { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; overflow-wrap: anywhere; }
.standard-result:last-child { border-bottom: 0; }
.standard-result strong, .standard-result span { display: block; }
.standard-result:hover, .standard-result.active { background: #e8eef4; outline: 2px solid var(--brand); outline-offset: -2px; }
.standard-result[aria-selected="true"] { border-left: 5px solid var(--brand); background: #eef5fa; }
.standard-result[aria-selected="true"] strong::after { content: " (selected)"; }
.standard-wording { margin: 0 0 10px; overflow-wrap: anywhere; white-space: pre-wrap; }
mark { background: #ffe49a; color: var(--ink); }
@media (max-width: 900px) {
  .build-standard-discovery { grid-template-columns: 1fr; }
}
.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 14px; }
.idea { border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.idea h3 { margin: 0; }
.idea .tag { font-size: 13px; color: var(--muted); }
.idea .btn { margin-top: auto; }
.other-version { margin-bottom: 16px; }
.other-version p { margin: 0 0 8px; }
.other-version .btn { display: block; }
.lesson-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start; }
.pill { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #e8eef4; color: var(--brand); font-weight: 700; }
.phase { border-left: 6px solid var(--brand); }
.phase.ido { border-color: var(--ido); } .phase.wedo { border-color: var(--wedo); } .phase.youdo { border-color: var(--youdo); } .phase.check { border-color: var(--check); }
.phase h2 .min { font-family: "Atkinson Hyperlegible", sans-serif; font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.passage { background: #fbfaf6; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; font-size: 18px; line-height: 1.7; }
.passage h3 { font-family: Fraunces, serif; }
.passage p { margin: 0 0 .8em; }
.passage p[data-paragraph]::before { content: attr(data-paragraph) ". "; font-weight: 700; }
[contenteditable="true"] { border-radius: 4px; }
[contenteditable="true"]:hover { background: #fff8e1; }
ol.script li, ul.plain li { margin-bottom: 6px; }
.q { margin-bottom: 14px; }
.q .choices { list-style: none; padding-left: 0; margin: 6px 0; }
.q .choices li { padding: 2px 0; }
.key { font-size: 15px; color: var(--muted); }
.key strong { color: var(--ink); }
table.lib { width: 100%; border-collapse: collapse; }
table.lib th, table.lib td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lib th { font-size: 14px; color: var(--muted); }
.std-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.std-row textarea { min-height: 60px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid #cfdbe6; border-top-color: var(--brand); border-radius: 50%; animation: spin 0.9s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@media (max-width: 600px) {
  .build-standard-controls, .standard-search-controls { grid-template-columns: 1fr; }
  .std-row { grid-template-columns: 1fr; }
  table.lib thead { display: none; }
  table.lib tr { display: grid; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.lib td { border: 0; padding: 2px 0; }
}

/* ---------- Printing ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 0.6in; }
  body { background: #fff; font-size: 13pt; }
  .no-print, .top, .banner, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; margin: 0 0 14pt; }
  .print-only { display: block; }
  [contenteditable] { background: none !important; }
  body.p-teacher .student-only, body.p-teacher .followup-sec { display: none !important; }
  body.p-student .teacher-only, body.p-student .followup-sec { display: none !important; }
  body.p-followup .teacher-only, body.p-followup .student-only:not(.followup-sec) { display: none !important; }
  body.p-student .page-break, body.p-followup .page-break { break-before: page; }
  .passage { border: 1px solid #999; font-size: 14pt; }
  .q { break-inside: avoid; }
}

/* ---------- accounts, classes, tracker, quiz ---------- */
.who { gap: 12px; }
.who .btn { padding: 8px 12px; min-height: 36px; }
.signin { max-width: 520px; margin: 8vh auto; text-align: center; }
.gbtn { display: inline-flex; gap: 10px; align-items: center; background: #fff; color: #1f2a36; border: 1px solid #c9ced6; border-radius: 10px; padding: 12px 18px; font-weight: 700; text-decoration: none; min-height: 48px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.modal { position: fixed; inset: 0; background: rgba(20, 30, 40, .45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 22px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; margin: 10px 0; }
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; min-height: 36px; }
.checks input { min-height: auto; width: 20px; height: 20px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: clamp(34px, 6vw, 54px); letter-spacing: .12em; font-weight: 700; color: var(--brand); }
.scoregrid { width: 100%; border-collapse: collapse; }
.scoregrid th, .scoregrid td { border-bottom: 1px solid var(--line); padding: 10px 6px; text-align: left; vertical-align: middle; }
.scoregrid th { font-size: 14px; color: var(--muted); }
.scoregrid input { width: 64px; min-height: 40px; padding: 6px 8px; text-align: right; }
.frac { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.pctv { display: inline-block; min-width: 46px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.src { font-size: 12px; color: var(--muted); }
.tracker-wrap { overflow-x: auto; }
table.tracker { border-collapse: collapse; min-width: 100%; font-size: 15px; }
table.tracker th, table.tracker td { border: 1px solid var(--line); padding: 8px; vertical-align: top; text-align: left; }
table.tracker th { background: #f1efe7; font-size: 13px; }
table.tracker td.n { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.tracker .lbl { color: var(--muted); font-size: 12px; display: inline-block; width: 34px; }
.empty { color: var(--muted); }
.list-row { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.inactive { opacity: .5; }
.modal[hidden], [hidden] { display: none !important; }
