/* Math Garden: calm, paper-like, touch-first. One muted green accent; no saturated colors. */
:root {
  --paper: #f6f3ec; --card: #fffdf8; --ink: #2f3a33; --soft: #6b756d; --line: #e4dfd3;
  --leaf: #6f9a7a; --leaf-deep: #4f7a5c; --leaf-wash: #e6efe6; --sun: #efe3c4; --warn: #b7793d; --warn-wash: #f6ead9;
  --r: 22px; --tap: 60px; --shadow: 0 1px 2px rgba(47,58,51,.06), 0 8px 24px rgba(47,58,51,.06);
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--paper);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body { -webkit-text-size-adjust: 100%; font-size: 18px; line-height: 1.45; }
a { color: var(--leaf-deep); }
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 3px; border-radius: 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 20px 10px; background: rgba(246,243,236,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 20px; }
.leaf { width: 30px; height: 30px; }
.who { display: flex; gap: 8px; align-items: center; }
.who a, .who button { min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: 16px; font-weight: 700; text-decoration: none; cursor: pointer; }

main { max-width: 980px; margin: 0 auto; padding: 24px 20px 96px; outline: none; }
h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.15; margin: 8px 0 18px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 22px; margin: 0 0 12px; font-weight: 800; }
.section-title { margin: 34px 0 14px; }
.hint { color: var(--soft); margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; }

/* Keep going: the one obvious next step for a child */
.keep { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; text-decoration: none; color: var(--ink);
  background: linear-gradient(135deg, var(--leaf-wash), var(--card) 70%); border: 1px solid #d6e3d6; border-radius: 28px;
  padding: 26px 26px; box-shadow: var(--shadow); min-height: 132px; transition: transform .15s ease; }
.keep:active { transform: scale(.99); }
.keep .label { font-size: 16px; font-weight: 800; color: var(--leaf-deep); text-transform: none; }
.keep .what { font-size: clamp(24px, 4vw, 30px); font-weight: 800; margin: 2px 0; }
.keep .where { color: var(--soft); }
.go { width: 76px; height: 76px; border-radius: 50%; background: var(--leaf); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(79,122,92,.25); }
.go svg { width: 34px; height: 34px; }

/* Books */
.books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.book { min-height: 96px; border-radius: var(--r); border: 2px solid var(--line); background: var(--card); font: inherit;
  font-size: 22px; font-weight: 800; color: var(--ink); cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-align: left; }
.book .spine { width: 16px; align-self: stretch; border-radius: 8px; background: var(--sun); }
.book[aria-selected="true"] { border-color: var(--leaf); background: var(--leaf-wash); }
.book[aria-selected="true"] .spine { background: var(--leaf); }
.book small { display: block; font-size: 15px; font-weight: 600; color: var(--soft); }

/* Pages and questions */
.page { margin-top: 22px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 10px; }
.page-head h3 { margin: 0; font-size: 20px; font-weight: 800; }
.page-head span { color: var(--soft); font-size: 15px; }
.shelf-summary { margin: 18px 0 10px; color: var(--soft); font-weight: 700; }
.page-jumps { display: flex; flex-wrap: wrap; gap: 8px; }
.page-jumps button { min-height: 44px; min-width: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.page-jumps button:focus-visible, [data-page-heading]:focus { outline: 3px solid var(--leaf); outline-offset: 3px; }
[data-page-heading] { scroll-margin-top: 96px; }
.questions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.q { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 92px; padding: 14px 16px;
  border-radius: 18px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.q b { font-size: 20px; font-weight: 800; }
.q span { font-size: 14px; color: var(--soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q.done { background: #f3f7f1; }
.q.done::after { content: ""; position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--leaf) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; }
.q.new::before { content: "From your photo"; position: absolute; top: -9px; left: 12px; font-size: 12px; font-weight: 800;
  background: var(--sun); padding: 1px 8px; border-radius: 999px; color: #6a5a2f; }
.empty { color: var(--soft); padding: 18px; border: 1px dashed var(--line); border-radius: var(--r); text-align: center; }

/* Forms */
.auth { max-width: 520px; margin: 10px auto; }
.tabs { display: flex; gap: 6px; background: var(--paper); padding: 5px; border-radius: 999px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { flex: 1; min-height: 46px; border: 0; border-radius: 999px; background: transparent; font: inherit; font-size: 16px; font-weight: 700; color: var(--soft); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 700; font-size: 16px; }
.form input, .form textarea, .form select { font: inherit; font-size: 18px; min-height: 54px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); }
.opt { font-weight: 500; color: var(--soft); }
button.primary, button.secondary, button.ghost { min-height: var(--tap); border-radius: 16px; font: inherit; font-size: 18px; font-weight: 800; cursor: pointer; }
button.primary { background: var(--leaf-deep); color: #fff; border: 0; }
button.primary:disabled { opacity: .55; }
button.secondary { background: var(--card); color: var(--leaf-deep); border: 2px solid var(--leaf); }
button.ghost { background: transparent; border: 1px dashed var(--line); color: var(--leaf-deep); min-height: 48px; }
.kids { border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: grid; gap: 10px; }
.kids legend { font-weight: 800; padding: 0 6px; }
.kid-row { display: grid; grid-template-columns: 1fr 130px; gap: 8px; }
.msg { min-height: 1.4em; margin: 6px 0 0; font-weight: 700; }
.msg.bad { color: var(--warn); } .msg.good { color: var(--leaf-deep); }
.recover summary { cursor: pointer; color: var(--leaf-deep); font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.recover { display: grid; gap: 12px; }

.choice { display: flex; gap: 10px; flex-wrap: wrap; }
.choice label { flex: 1; min-width: 140px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: flex; align-items: center; justify-content: center; min-height: 56px; border-radius: 16px; border: 2px solid var(--line); background: #fff; font-weight: 800; }
.choice input:checked + span { border-color: var(--leaf); background: var(--leaf-wash); }
.choice input:focus-visible + span { outline: 3px solid var(--leaf); outline-offset: 2px; }
.photo-drop { position: relative; display: grid !important; place-items: center; text-align: center; min-height: 120px; border: 2px dashed #cfd9cf;
  border-radius: 18px; background: #fbfaf5; padding: 16px; color: var(--soft); font-weight: 700 !important; cursor: pointer; }
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

/* Upload progress */
.requests { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.req { display: grid; grid-template-columns: 14px 1fr; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); }
.req .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 6px; background: var(--line); }
.req.working .dot, .req.paused .dot { background: var(--sun); } .req.ready .dot { background: var(--leaf); } .req.action .dot { background: var(--warn); }
.req h3 { margin: 0; font-size: 18px; }
.req p { margin: 4px 0 0; color: var(--soft); }
.req.action p.do { color: var(--warn); font-weight: 700; }
.req .open { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.req .open a { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 12px; background: var(--leaf-wash); text-decoration: none; font-weight: 800; }
.more .links { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.more a { min-height: 44px; display: inline-flex; align-items: center; }

.preview-note { position: fixed; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; }

@media (max-width: 560px) {
  body { font-size: 17px; } main { padding: 18px 16px 90px; }
  .keep { grid-template-columns: 1fr; } .go { display: none; }
  .questions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kid-row { grid-template-columns: 1fr; }
  .brand span { font-size: 18px; }
}

/* Mobile header and preview banner fixes (verified at 375px) */
.brand span, .who a, .who button { white-space: nowrap; }
.preview-note { position: static; transform: none; display: block; width: fit-content; margin: 0 auto 12px; }
@media (max-width: 420px) {
  .bar { padding-left: 14px; padding-right: 14px; }
  .brand span { font-size: 17px; } .leaf { width: 26px; height: 26px; }
  .who a, .who button { padding: 8px 12px; font-size: 15px; }
}

/* Integration pass: child picker, recovery key, children list, started tag, unknown status */
.kids-pick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -6px 0 16px; }
.kids-pick:empty { display: none; }
.who-label { color: var(--soft); font-weight: 700; margin-right: 4px; }
.kid { min-height: 48px; padding: 8px 18px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); font: inherit; font-weight: 800; color: var(--ink); cursor: pointer; }
.kid.on { border-color: var(--leaf); background: var(--leaf-wash); }
.q .started { position: absolute; bottom: 8px; right: 10px; font-style: normal; font-size: 12px; font-weight: 800; color: var(--soft); }
.note { color: var(--soft); margin: 0 0 10px; }
.key { display: block; font-size: 20px; font-weight: 800; letter-spacing: .04em; padding: 14px; border-radius: 14px; background: var(--leaf-wash); word-break: break-all; user-select: all; }
.kid-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px; box-shadow: var(--shadow); }
.kid-card span { display: block; color: var(--soft); font-size: 15px; }
.kid-card button.secondary { min-height: 48px; padding: 0 16px; font-size: 16px; }
.kid-card .report-out { grid-column: 1 / -1; }
.kid-card .report-out:empty { display: none; }
.kid-card .open { display: flex; flex-wrap: wrap; gap: 8px; }
.kid-card .open button { padding: 0 14px; font-size: 16px; }
.req.unknown .dot { background: var(--line); }
/* Three header buttons (Lessons, Grown-ups, Sign out) don't fit beside the brand name at phone width: keep the leaf only */
@media (max-width: 480px) { .brand span { display: none; } .who { gap: 6px; } .who a, .who button { padding: 8px 11px; } }
.brand { min-height: 44px; }
/* Compatibility pass: waiting/history tones, child settings form, earlier homework */
.req.waiting .dot { background: var(--sun); } .req.history .dot { background: var(--line); }
.kid-form { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 14px; }
.kid-card .history { grid-column: 1 / -1; color: var(--soft); }
.kid-card .history summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--leaf-deep); }
.kid-card .history ul { margin: 0; padding-left: 20px; }

/* Hidden state must override component display:grid/flex/block. */
[hidden] { display: none !important; }

/* School worksheets shelf and source evidence (worksheet release) */
.book.school .spine { background: #e8dcc6; }
.book.school[aria-selected="true"] .spine { background: var(--leaf); }
.req .source-note { font-size: 15px; color: var(--soft); }

/* Keep child settings within narrow phone cards. */
.kid-form { min-width: 0; grid-template-columns: minmax(0, 1fr); }
.kid-form label, .kid-form input, .kid-form select { min-width: 0; width: 100%; }

/* Account setup and recovery remain usable on narrow phones. */
.kid-row input, .kid-row select { min-width: 0; width: 100%; }
.kid-row [data-remove-kid] { grid-column: 1 / -1; justify-self: end; padding: 0 16px; }
.setup-link { display: inline-flex; align-items: center; min-height: 48px; padding: 8px 16px; background: var(--leaf-wash); color: var(--leaf-deep); border-radius: 14px; font-weight: 800; text-decoration: none; }
.family-welcome { margin-bottom: 20px; }
.family-welcome .ghost { margin-left: 10px; padding: 0 16px; }
@media (max-width: 560px) { .kid-card { grid-template-columns: minmax(0, 1fr); } }

/* Specific upload notes; native details remains keyboard accessible. */
.upload-lesson{display:flex;flex-direction:column;gap:.4rem;max-width:38rem}.pilot-note{font-size:.95rem;line-height:1.5;margin:.4rem 0;padding:.6rem .8rem;border:1px solid #cad8d4;border-radius:.6rem;background:#f7faf8;color:#243b34}.pilot-note summary{cursor:pointer;min-height:2rem;font-weight:600}.pilot-note ul{padding-left:1.3rem;margin:.5rem 0}.pilot-note-attention{margin:.5rem 0 0}
