/*//// -- Dad School
   Two moods from one sheet: [data-mode="kid"] is big, warm and tappable;
   [data-mode="adult"] is a dense admin tool. */

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e4e7ee;
  --brand: #4f7cff;
  --brand-ink: #ffffff;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-mode="kid"] {
  --bg: #fffaf3;
  --panel: #ffffff;
  --brand: #ff7a45;
  --radius: 22px;
}

* { box-sizing: border-box; }

/* `display: grid/flex` beats the hidden attribute, so make hidden actually hide. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

[data-mode="kid"] body { font-size: 18px; }

a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code { background: #eef1f7; padding: .1em .35em; border-radius: 5px; font-size: .9em; }

/*//// -- Layout */
.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 5rem; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.section-h { margin: 2rem 0 .75rem; font-size: 1.15rem; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 180px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.back { display: inline-block; margin-bottom: .75rem; text-decoration: none; font-size: .9rem; }
.big-emoji { font-size: 3.5rem; margin: 0 0 .25rem; line-height: 1; }
.empty { color: var(--muted); padding: 1rem 0; }

/*//// -- Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .75rem 1.25rem; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.05rem; white-space: nowrap; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: .4rem .7rem; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-size: .925rem;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--brand); color: var(--brand-ink); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.who { font-size: .9rem; white-space: nowrap; }
.ava { font-size: 1.15em; }
.ava.big { font-size: 1.8rem; display: inline-grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; }

/*//// -- Cards, forms, buttons */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem; box-shadow: var(--shadow); margin-bottom: 1.1rem;
}
.card h2 { font-size: 1.05rem; margin-bottom: .75rem; }

label.stack { display: block; margin-bottom: .85rem; font-size: .9rem; color: var(--muted); }
label.stack > input, label.stack > textarea, label.stack > select { margin-top: .3rem; }
label.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .95rem; color: var(--ink); }

input[type=text], input[type=password], input[type=number], input:not([type]), textarea, select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; font-size: .95rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
input.tiny { max-width: 7rem; }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #cbd2e0; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: .35rem .6rem; font-size: .85rem; }
.btn.big { padding: .9rem 1.5rem; font-size: 1.05rem; border-radius: 14px; }
.btn.block { display: block; width: 100%; text-align: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.details { border: 1px dashed var(--line); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .85rem; }
.details summary { cursor: pointer; font-size: .9rem; color: var(--muted); }
.details > label { margin-top: .75rem; }

.notice {
  background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a;
  padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1.1rem; font-size: .925rem;
}

/*//// -- Tables */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .93rem; }
.table th { text-align: left; padding: .65rem .8rem; background: #fafbfe; border-bottom: 1px solid var(--line); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table td { padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table.compact td { padding: .4rem .5rem; font-size: .875rem; }

.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: #eef1f7; color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.score { font-weight: 700; }
.score.pass { color: var(--ok); }
.score.fail { color: var(--bad); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .9rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.stat .n { display: block; font-size: 2rem; font-weight: 700; line-height: 1; }
.stat .l { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }

/*//// -- Flash */
.flash {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 12px;
  box-shadow: var(--shadow); z-index: 50; max-width: min(90vw, 520px); font-size: .93rem;
  animation: rise .25s ease-out;
}
.flash.error { background: var(--bad); }
.flash.ok { background: var(--ok); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/*//// -- Login */
.login-wrap { max-width: 620px; margin: 0 auto; padding: 3rem 1.25rem; text-align: center; }
.login-title { font-size: 2rem; margin-bottom: .25rem; }
.login-sub { color: var(--muted); margin-bottom: 1.75rem; }
.login-error { background: var(--bad-bg); color: var(--bad); padding: .7rem 1rem; border-radius: 10px; }
.login-switch { margin-top: 2rem; font-size: .9rem; }
.adult-login { text-align: left; }

.face-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.face {
  background: var(--panel); border: 3px solid var(--line); border-radius: 22px;
  padding: 1.5rem .75rem; cursor: pointer; font: inherit; display: grid; gap: .5rem;
  transition: transform .12s ease, border-color .12s ease;
}
.face:hover, .face:focus-visible { transform: translateY(-3px); border-color: var(--kid, var(--brand)); outline: none; }
.face-ava { font-size: 3.25rem; line-height: 1; }
.face-name { font-weight: 700; font-size: 1.1rem; }

.pin-panel { max-width: 340px; margin: 0 auto; }
.pin-who { font-size: 1.15rem; }
.pin-dots { display: flex; gap: .8rem; justify-content: center; margin: 1.25rem 0; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: #fff; }
.pin-dots i.filled { background: var(--brand); border-color: var(--brand); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.key {
  padding: 1.1rem 0; font-size: 1.6rem; font-weight: 600; font-family: inherit;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel); cursor: pointer;
}
.key:active { background: var(--bg); transform: scale(.97); }
.key.wide { font-size: 1.05rem; }

/*//// -- Kid dashboard */
.hello { font-size: 1.9rem; margin-bottom: 1rem; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.1rem; }
.lesson-grid.small { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.lesson-card {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.lesson-card:hover { transform: translateY(-3px); }
.lesson-card.done { opacity: .85; }
.lesson-body { padding: 1rem; }
.lesson-body h3 { font-size: 1.1rem; }
.lesson-body p { font-size: .95rem; color: var(--muted); }
.lesson-body .meta { font-size: .85rem; }
.thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #eee; border-radius: 10px; }
.thumb.placeholder { display: grid; place-items: center; font-size: 2.5rem; }
.tick { font-size: 1.4rem; }
.all-done { padding: 2.5rem 1.25rem; }

/*//// -- Subject grouping */
.subject-group { margin-bottom: 2rem; }
.subject-heading {
  display: flex; align-items: center; gap: .6rem; margin: 0 0 .85rem;
  font-size: 1.15rem; padding-left: .7rem; border-left: 5px solid var(--chip, var(--brand));
}
.subject-emoji { font-size: 1.4rem; }
.subject-count {
  margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); padding: .15rem .6rem; border-radius: 999px;
}
.chip {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: color-mix(in srgb, var(--chip, var(--brand)) 15%, #fff);
  color: color-mix(in srgb, var(--chip, var(--brand)) 75%, #000);
}
.subject-card { border-left: 5px solid var(--chip, var(--brand)); }
.subject-lessons { list-style: none; margin: .9rem 0 0; padding: .9rem 0 0; border-top: 1px solid var(--line); display: grid; gap: .45rem; }
.subject-lessons li { display: flex; align-items: center; gap: .5rem; font-size: .93rem; flex-wrap: wrap; }
.no-lessons { margin: .9rem 0 0; padding-top: .9rem; border-top: 1px solid var(--line); }

/*//// -- Lesson + video */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 1.1rem; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lead { color: var(--muted); font-size: 1.05rem; }
.watch-done { text-align: center; }
.watch-done .btn { margin-top: .5rem; }

/*//// -- Quiz */
.quiz-page { padding-top: 1rem; }
.progress { height: 10px; background: #eceff5; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .3s ease; }
.progress-label { text-align: center; color: var(--muted); font-size: .9rem; margin: .5rem 0 1.25rem; }
.card.question { padding: 1.5rem; }
.card.question h2 { font-size: 1.35rem; margin-bottom: 1.1rem; }
.choices { display: grid; gap: .7rem; }
.choice {
  display: flex; align-items: center; gap: .85rem; width: 100%; text-align: left;
  padding: 1rem; border: 2px solid var(--line); border-radius: 14px; background: #fff;
  font: inherit; font-size: 1.05rem; cursor: pointer; transition: border-color .1s ease, background .1s ease;
}
.choice:hover { border-color: var(--brand); }
.choice.picked { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, #fff); }
.choice .letter {
  flex: none; width: 2rem; height: 2rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--bg); font-weight: 700; font-size: .95rem;
}
.choice.picked .letter { background: var(--brand); color: #fff; }
.quiz-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; }
.quiz-nav .btn.primary { margin-left: auto; }

/*//// -- Result */
.result-hero { padding: 2rem 1.25rem; }
.result-hero h1 { font-size: 2rem; }
.result-hero .pct { font-size: 3rem; font-weight: 800; margin: 0; line-height: 1; }
.result-hero.pass .pct { color: var(--ok); }
.result-hero.fail .pct { color: var(--bad); }
.result-hero .verdict { margin-top: .75rem; color: var(--muted); }
.takeaways { margin: 0; padding-left: 1.2rem; }
.takeaways li { margin-bottom: .4rem; }
.review .review-q { font-weight: 600; }
.review-mark { margin-right: .35rem; }
.review-opts { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .35rem; }
.review-opts li { padding: .5rem .7rem; border-radius: 10px; background: var(--bg); font-size: .95rem; }
.review-opts li.correct { background: var(--ok-bg); }
.review-opts li.chosen-wrong { background: var(--bad-bg); }
.tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: var(--ok); margin-left: .4rem; }
.tag.warn { color: var(--bad); }
.why { font-size: .93rem; color: var(--muted); margin: 0; }

.stars { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.star { flex: 1 1 80px; text-align: center; cursor: pointer; padding: .7rem .3rem; border: 2px solid var(--line); border-radius: 14px; }
.star input { position: absolute; opacity: 0; width: 0; height: 0; }
.star span { display: block; font-size: 1.9rem; line-height: 1.2; }
.star small { color: var(--muted); font-size: .78rem; }
.star:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, #fff); }

/*//// -- Admin bits */
.kid-row .kid-head { display: flex; align-items: flex-end; gap: .85rem; margin-bottom: .75rem; }
.assign-list { display: grid; gap: .5rem; margin-bottom: .9rem; }
.q-edit { border: 1px solid var(--line); border-radius: 12px; padding: .9rem; margin-bottom: .9rem; background: #fcfdff; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .75rem; }
@media (max-width: 620px) { .opts { grid-template-columns: 1fr; } }
.opt { display: flex; align-items: center; gap: .5rem; }
.opt input[type=radio] { flex: none; width: 1.1rem; height: 1.1rem; }
.comment-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.comment .quote { font-size: 1.02rem; }
