/* Keep the established screens and mode links; add the four kid destinations. */
.rail[hidden] { display: none; }
.rail {
  position: fixed;
  inset: 80px auto auto 8px;
  width: 104px;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  z-index: 100;
}
.rail .rail-btn {
  min-height: 56px;
  padding: 8px 4px;
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid transparent;
}
.rail-btn[aria-current="page"] { border-color: var(--blue); font-weight: 700; }
/* The class is synchronized by kid-shell.js, including browsers without :has. */
body.has-kid-rail { padding-left: 128px; }
.hint-ladder { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hint-ladder button { flex: 1 1 140px; min-height: 56px; margin: 0; }
.hint-ladder[hidden], #hint-ladder-status[hidden] { display: none; }
.touch-keypad { display: none; margin: 12px 0; }
/* Closed details must remove keypad controls from layout as well as paint. */
.touch-keypad:not([open]) > :not(summary) { display: none; }
.touch-keypad summary { min-height: 56px; padding: 16px; cursor: pointer; font-weight: 600; }
.math-keys { display: grid; grid-template-columns: repeat(4, minmax(56px, 1fr)); gap: 8px; }
#kid-assignments { margin-block: 16px; padding: 16px; border: 1px solid var(--primary); border-radius: 12px; }
.kid-assignment-card { padding-block: 8px; }
#kid-assignments form { display: grid; gap: 12px; }
#kid-assignments input { width: 100%; min-height: 48px; box-sizing: border-box; }
#kid-assignment-badge { margin-left: 6px; font-weight: bold; }
.soft-break { padding: 16px; border: 1px solid var(--primary); border-radius: 12px; margin-block: 16px; }
.soft-break-actions { display: flex; gap: 12px; }
.soft-break-actions button { flex: 1; min-height: 48px; }
.kid-celebration { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2000; padding: 14px 22px; border-radius: 24px; background: var(--surface); color: var(--ink); border: 2px solid var(--primary); pointer-events: none; }
.celebrate-motion { animation: kid-celebrate var(--motion-celebrate, 1200ms) ease-out; }
@keyframes kid-celebrate {
  0% { transform: translateX(-50%) scale(.85); opacity: 0; }
  20%, 80% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(1.03); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .celebrate-motion { animation: none; }
}
#math-keys button { min-width: 56px; min-height: 56px; margin: 0; padding: 8px; font-size: 20px; }
.fraction-stack { display: inline-flex; flex-direction: column; text-align: center; vertical-align: middle; margin: 0 6px; }
.fraction-stack > span:first-child { border-bottom: 2px solid currentColor; }
.kid-manipulative-panel[hidden] { display: none; }
.kid-manipulative-panel > summary { min-height: 48px; padding: 12px; cursor: pointer; }
html[data-age-band="k2"] #mode-learn { font-size: 20px; line-height: 1.6; }
html[data-age-band="k2"] #mode-learn :is(button, input, summary),
html[data-age-band="k2"] .rail-btn { min-height: 56px; font-size: 20px; }
html[data-age-band="k2"] #mode-learn button { min-width: 56px; }
html[data-age-band="k2"] :is(.btn-read-aloud, .kid-read-aloud) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 2px solid var(--primary);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}
html[data-age-band="k2"] #btn-read-aloud { min-height: 56px !important; }
html[data-age-band="k2"] .touch-keypad,
html[data-age-band="g35"] .touch-keypad { display: block; }
html[data-age-band="g35"] #mode-learn { font-size: 18px; line-height: 1.5; }
html[data-age-band="g35"] #math-keys [data-action="fraction"] { border: 2px solid var(--primary); font-weight: 700; }
html[data-age-band="g912"] #mode-learn { font-size: 16px; line-height: 1.4; }
html[data-age-band="g912"] .hint-ladder { gap: 6px; margin-top: 8px; }
html[data-age-band="g912"] .hint-ladder button { min-height: 44px; padding: 8px; }
html[data-age-band="g912"] .question-body { padding-block: 8px; }
html[data-age-band="g912"] .kid-manipulative-panel > summary { min-height: 44px; padding: 8px; }
@media (max-width: 1024px), (pointer: coarse) {
  .touch-keypad { display: block; }
  .answer-area { scroll-margin-block: 90px; }
}
@media (max-width: 599px) {
  /* Keep the real value and caret visible while a child uses lower keypad
     rows. This stays in flow and needs no animation or focus changes. */
  #screen-question:has(#touch-keypad[open]:not([hidden])) .answer-area {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    padding-block: 8px;
  }
  body.has-kid-rail { padding-left: 0; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .rail {
    inset: auto 0 0;
    width: auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  body.focus-mode .rail { display: none; }
  body.focus-mode.has-kid-rail { padding-bottom: 16px; }
}
.topic-review-label {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.8em;
}
