/*
 * Quizzard design system: "arcane scholar".
 * An old observatory and library: parchment by day, midnight by night.
 * Propshaft serves this file as-is (no preprocessing).
 */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  /* Parchment (light) */
  --bg: #f2ead9;
  --surface: #fbf5ea;
  --ink: #241d33;
  --muted: #6a6280;
  --line: #e0d5bf;
  --gold: #a9771f;
  --gold-soft: #c79a3e;
  --indigo: #3b2f6e;
  --violet: #6b4ea8;
  --teal: #2f7d7a;
  --good: #2f7d5b;
  --good-bg: #e4f1e8;
  --bad: #b3432e;
  --bad-bg: #f7e7e2;

  /* Derived */
  --on-accent: #fbf5ea;
  --shadow: 0 1px 2px rgb(36 29 51 / 0.06), 0 6px 20px rgb(36 29 51 / 0.07);

  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --measure: 720px;
}

/* Midnight (dark): follow the OS unless the user picked a theme explicitly. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0f1e;
    --surface: #191634;
    --ink: #ece7f6;
    --muted: #9b94b8;
    --line: #2c2850;
    --gold: #e2b65a;
    --gold-soft: #f0cd84;
    --indigo: #8f7ce0;
    --violet: #a98fe0;
    --teal: #5fc7c0;
    --good: #5fd39e;
    --good-bg: #15342a;
    --bad: #ff8a7a;
    --bad-bg: #3a1f1c;
    --on-accent: #0e0f1e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f1e;
  --surface: #191634;
  --ink: #ece7f6;
  --muted: #9b94b8;
  --line: #2c2850;
  --gold: #e2b65a;
  --gold-soft: #f0cd84;
  --indigo: #8f7ce0;
  --violet: #a98fe0;
  --teal: #5fc7c0;
  --good: #5fd39e;
  --good-bg: #15342a;
  --bad: #ff8a7a;
  --bad-bg: #3a1f1c;
  --on-accent: #0e0f1e;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-x: hidden;
  /* A faint scatter of stars: cheap, static, tasteful. */
  background-image:
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--gold-soft) 22%, transparent) 0 1.5px, transparent 2px),
    radial-gradient(circle at 78% 10%, color-mix(in srgb, var(--violet) 18%, transparent) 0 1.5px, transparent 2px),
    radial-gradient(circle at 90% 62%, color-mix(in srgb, var(--gold-soft) 18%, transparent) 0 1px, transparent 1.5px),
    radial-gradient(circle at 24% 80%, color-mix(in srgb, var(--violet) 16%, transparent) 0 1px, transparent 1.5px);
  background-attachment: fixed;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  color: var(--ink);
}
h1 { font-size: clamp(1.9rem, 5vw + 0.5rem, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3vw + 0.6rem, 1.8rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }

p { margin: 0 0 1em; }

a {
  color: var(--violet);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease;
}
a:hover { color: var(--indigo); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: color-mix(in srgb, var(--gold-soft) 45%, transparent); }

.muted { color: var(--muted); }

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before { content: "\2726\00a0"; color: var(--gold); }

.lede { font-size: 1.15rem; color: var(--ink); max-width: 38ch; }

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  background: var(--indigo);
  color: var(--on-accent);
  border-radius: var(--radius-sm);
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main.container {
  flex: 1;
  padding-block: 2rem 3rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  max-width: var(--measure);
  margin-inline: auto;
  padding: 0.6rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.site-header__user {
  font-size: 0.875rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14ch;
}
@media (max-width: 479px) {
  .site-header__user { display: none; }
}
@media (min-width: 560px) {
  .site-header__user { max-width: 26ch; }
}
.inline-form { display: inline-block; margin: 0; }
/* A4d (#128): the header switcher on one line: label, select, button. */
.kid-switcher { display: inline-flex; align-items: center; gap: 0.4rem; }
.kid-switcher label { margin: 0; }
.kid-switcher select { width: auto; margin: 0; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--indigo);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.wordmark:hover { color: var(--violet); }
.wordmark__mark { flex: none; color: var(--gold); }
.wordmark__star { transform-origin: 16px 16px; animation: twinkle 5s ease-in-out infinite; }

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 1.25rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.site-footer p { margin: 0; font-style: italic; }
.site-footer p::before,
.site-footer p::after { content: "\2726"; color: var(--gold); margin-inline: 0.6em; font-style: normal; }

.site-footer nav { margin-top: 0.5rem; }

/* ---------- Components ---------- */
.legal { max-width: var(--measure); margin-inline: auto; }
.legal h2 { margin-top: 1.5rem; }
.legal li { margin-bottom: 0.4rem; }
.legal blockquote { margin-inline: 0; padding-left: 1rem; border-left: 3px solid var(--gold); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-danger { border-color: var(--bad); }
.card-danger summary { cursor: pointer; font-weight: 700; color: var(--bad); }
/* #166: each kid on the family page, with its actions as small buttons. */
.kid-rows { list-style: none; margin: 0 0 1rem; padding: 0; }
.kid-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.kid-row__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.hero { padding-block: 1rem 2rem; }

.auth-card { max-width: 440px; margin-inline: auto; }

/* Buttons */
.btn,
button,
input[type="submit"] {
  font: inherit;
}

.btn,
input[type="submit"].btn,
.button_to button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-primary {
  background: var(--indigo);
  color: var(--on-accent);
  border-color: var(--indigo);
  box-shadow: inset 0 -2px 0 var(--gold-soft);
}
.btn-primary:hover { background: var(--violet); border-color: var(--violet); color: var(--on-accent); }
/* button_to wraps its button in .button_to, whose ghost rule below would otherwise outrank .btn-primary. */
.button_to button.btn-primary { background: var(--indigo); color: var(--on-accent); border-color: var(--indigo); }
.button_to button.btn-primary:hover { background: var(--violet); border-color: var(--violet); color: var(--on-accent); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost,
.button_to button {
  background: transparent;
  color: var(--indigo);
  border-color: var(--line);
}
.btn-ghost:hover,
.button_to button:hover { border-color: var(--violet); color: var(--violet); background: color-mix(in srgb, var(--violet) 8%, transparent); }

/* A6-2: destructive actions, like "Delete our family". */
.btn-danger {
  background: var(--bad);
  color: var(--on-accent);
  border-color: var(--bad);
}
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 85%, black); border-color: var(--bad); color: var(--on-accent); }
.btn-danger:active { transform: translateY(1px); }

.btn-sm { min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.9rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--gold);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.3s ease;
}
.icon-btn:hover { border-color: var(--gold); transform: rotate(18deg); }

/* Forms (also styles Devise's default markup) */
form { margin: 0; }
.field { margin-bottom: 1.1rem; }
.field p { margin: 0; }

/* A8-4: the page list under the files input */
.material-pages { list-style: none; margin: 0.5rem 0; padding: 0; display: grid; gap: 0.35rem; }
.material-pages li { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.material-pages li span { overflow-wrap: anywhere; }

label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.hint, form em { display: block; margin-bottom: 0.35rem; font-size: 0.875rem; font-style: normal; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 35%, transparent);
}

.field--check { display: flex; align-items: center; gap: 0.6rem; }
.field--check label { margin: 0; font-weight: 400; }
/* #166: a radio sits on one line with its label (the upload forms and the class picker); .field--check rows already do */
fieldset.field > div:not(.field--check):has(> input[type="radio"]) { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; }
fieldset.field > div:not(.field--check):has(> input[type="radio"]) label { margin: 0; font-weight: 400; }
input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--indigo);
  flex: none;
}

.actions { margin-top: 1.5rem; }
.actions .btn { width: 100%; }
/* #178: the answer feedback's Next and "Help me with this" stack with a gap, one full-width button each */
.actions--stack { display: flex; flex-direction: column; gap: 0.6rem; }
.actions--stack .inline-form, .actions--stack .button_to { display: block; margin: 0; }

.auth-links { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.95rem; }
.auth-links p { margin: 0 0 0.4rem; }

/* Alerts */
.alert {
  margin: 0 0 1.25rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  font-size: 0.95rem;
}
.alert h2 { font-family: var(--font-body); font-size: 1rem; font-weight: 700; margin: 0 0 0.25rem; color: inherit; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-notice { background: var(--good-bg); color: var(--good); }
.alert-error { background: var(--bad-bg); color: var(--bad); }

/* ---------- Motion ---------- */
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.92); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .icon-btn:hover { transform: none; }
}

/* The class pages: a wider measure, a title row with its actions, and a reading column with a side column. */
.page--wide { --measure: 1080px; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 0.5rem 1.5rem;
}
.page-head h1 { margin: 0; }
.page-head .muted { margin: 0.5rem 0 0; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.back-link { margin: 0 0 0.5rem; font-size: 0.95rem; }

.page-grid { display: grid; gap: 1.25rem; align-items: start; }
.page-grid > * { min-width: 0; display: grid; gap: 1.25rem; }
.page-grid .card { margin: 0; }
@media (min-width: 900px) { .page-grid { grid-template-columns: minmax(0, 1fr) 320px; } }

/* Class tiles */
.class-tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1.25rem;
}
.class-tile {
  margin: 0;
  padding: 1.1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 4px solid var(--tile-accent, var(--gold));
}
.class-tile--accent-0 { --tile-accent: var(--violet); }
.class-tile--accent-1 { --tile-accent: var(--teal); }
.class-tile--accent-2 { --tile-accent: var(--gold); }
.class-tile--accent-3 { --tile-accent: var(--indigo); }
.class-tile p { margin: 0; }
.class-tile__name { margin: 0; font-size: 1.4rem; }
.class-tile__name a { color: var(--ink); text-decoration: none; }
.class-tile__name a:hover { color: var(--violet); text-decoration: underline; }
.class-tile__skills { display: grid; gap: 0.35rem; }
.class-tile__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; padding-top: 0.25rem; }

.skill-meter { display: block; width: 100%; height: 0.5rem; border-radius: 999px; overflow: hidden; background: var(--line); }
.skill-meter__strong { fill: var(--good); }
.skill-meter__developing { fill: var(--gold); }
.skill-meter__weak { fill: var(--bad); }
.skill-meter__new { fill: var(--line); }

/* The class page: strong out of all, the bar to fill, then the groups side by side. */
.course-progress { display: grid; gap: 0.5rem; margin-bottom: 1rem; padding: 1rem; border-radius: var(--radius-sm); background: var(--bg); }
.course-progress__big { margin: 0; font-size: 1rem; color: var(--muted); }
.course-progress__big strong { font-family: var(--font-display); font-size: 2.4rem; line-height: 1; color: var(--good); }
.course-progress__big span { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: var(--ink); margin-right: 0.35rem; }
.course-progress .skill-meter { height: 0.75rem; }
.course-progress__legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.9rem; }
.course-progress__practice { margin: 0; font-size: 0.95rem; }
.skill-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 0 1.5rem; }
.skill-groups .skill-group__heading { margin-top: 0.75rem; }

/* A path that unlocks: the step to take now glows, the rest wait behind a lock. */
.quest__steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.quest__step { display: grid; grid-template-columns: auto 1fr; gap: 0.9rem; align-items: start; padding: 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); }
.quest__step h3 { margin: 0.15rem 0 0.2rem; }
.quest__step p { margin: 0 0 0.75rem; }
.quest__step p:last-child { margin-bottom: 0; }
.quest__marker { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; font-weight: 800; font-size: 1.1rem; background: var(--line); }
.quest__step--now { border: 2px solid var(--gold); background: color-mix(in srgb, var(--gold-soft) 14%, var(--surface)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold-soft) 18%, transparent); }
.quest__step--now .quest__marker { background: var(--gold); color: var(--on-accent); animation: pulse 2.4s ease-in-out infinite; }
.quest__step--locked { opacity: 0.6; border-style: dashed; }
.quest__step--locked .quest__marker { font-size: 0.95rem; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 45%, transparent); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

.btn-lg { min-height: 52px; padding: 0.7rem 1.5rem; font-size: 1.1rem; }

/* The classes page: this week in numbers, and the one next step. */
.progress-stats { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 0.75rem; }
.progress-stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon n" "icon label" "hint hint";
  column-gap: 0.75rem;
  align-items: center;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.progress-stat__icon { grid-area: icon; font-size: 1.8rem; line-height: 1; color: var(--gold); }
.progress-stat__n { grid-area: n; font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1.05; }
.progress-stat__of { font-size: 1.1rem; color: var(--muted); }
.progress-stat__label { grid-area: label; font-weight: 700; font-size: 0.95rem; }
.progress-stat__hint { grid-area: hint; margin-top: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.progress-stat .skill-meter { grid-area: hint; margin-top: 0.6rem; }
/* A phone keeps the three side by side: icon over number over label. */
@media (max-width: 599px) {
  .progress-stats { gap: 0.5rem; }
  .progress-stat { grid-template-columns: 1fr; grid-template-areas: "icon" "n" "label" "hint"; padding: 0.7rem; text-align: center; }
  .progress-stat__icon { font-size: 1.4rem; }
  .progress-stat__n { font-size: 1.6rem; }
  .progress-stat__label { font-size: 0.8rem; line-height: 1.25; }
  .progress-stat__hint { font-size: 0.75rem; }
}
.progress-stat--streak:not(.progress-stat--lit) .progress-stat__icon { filter: grayscale(1); opacity: 0.5; }
.progress-stat--lit { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }

.next-step {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  background: linear-gradient(120deg, color-mix(in srgb, var(--gold-soft) 22%, var(--surface)), var(--surface) 60%);
  box-shadow: var(--shadow);
}
.next-step h2 { margin: 0 0 0.2rem; }
.next-step p { margin: 0; }
.next-step__eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.next-step__eyebrow::before { content: "\2726\00a0"; }

.class-tile__practice { font-size: 0.9rem; font-weight: 700; }
.class-tile__drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 5.5rem;
  border: 2px dashed color-mix(in srgb, var(--violet) 45%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--violet) 5%, var(--bg));
  color: var(--violet);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.class-tile__drop:hover { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 12%, var(--bg)); text-decoration: none; }
.class-tile__actions a:not(.btn) { font-size: 0.9rem; }

.miss-quizzes { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.miss-quizzes li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.unit-name { margin: 1rem 0 0.35rem; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-family: var(--font-body); font-weight: 700; }
.unit-name:first-of-type { margin-top: 0; }
.section-links { list-style: none; margin: 0; padding: 0; }
.section-links li { display: flex; justify-content: space-between; gap: 0.5rem; padding-block: 0.4rem; border-top: 1px solid var(--line); }
.section-links li:first-child { border-top: 0; }
.section-links .muted { font-size: 0.875rem; white-space: nowrap; }

/* The section page */
.empty-state { padding: 0.9rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.empty-state p:last-child { margin-bottom: 0; }
.page-grid__side h2 { font-size: 1.3rem; }
.skill-group--compact { gap: 0; }
.skill-group--compact li { padding-block: 0.5rem; border-top: 1px solid var(--line); }
.skill-group--compact li:first-child { border-top: 0; padding-top: 0; }
.skill-group--compact .skill-group__name { font-weight: 700; }
.skill-group--compact .skill-status { font-size: 0.85rem; }
.skill-group--compact .muted { display: block; font-size: 0.9rem; }
.skill-group--compact .button_to { margin-top: 0.35rem; }
.add-material--inline { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
#add_material .actions { margin-top: 1rem; }
@media (min-width: 900px) { #add_material .actions .btn { width: auto; } }

/* Breadcrumb */
.breadcrumb { color: var(--muted); font-size: 0.95rem; margin-bottom: 1rem; }
.breadcrumb [aria-hidden] { color: var(--gold); margin: 0 0.35rem; }

/* SP-1: the creating family's "Kind of class" control on the class page */
.class-kind { margin-bottom: 1rem; }
.class-kind > summary { cursor: pointer; font-weight: 700; color: var(--muted); }

/* Study guide */
.study-guide-older { margin-top: 1rem; }
.study-guide-older > summary { cursor: pointer; font-weight: 700; }
.study-guide__pending {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.25rem;
  font-weight: 700;
  color: var(--indigo);
}
.study-guide__spinner { display: inline-flex; gap: 0.25rem; }
.study-guide__spinner span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--gold);
  animation: twinkle 1.2s ease-in-out infinite;
}
.study-guide__spinner span:nth-child(2) { animation-delay: 0.2s; }
.study-guide__spinner span:nth-child(3) { animation-delay: 0.4s; }

.study-guide__intro {
  font-style: italic;
  color: color-mix(in srgb, var(--gold) 55%, var(--ink));
  border-left: 3px solid var(--gold-soft);
  padding-left: 0.9rem;
}
.study-guide h4 { margin-top: 1.25rem; font-weight: 600; font-size: 1.05rem; }
.study-guide h5 { margin: 1.1rem 0 0.4rem; font-family: var(--font-display); font-size: 1rem; font-weight: 600; }
.study-guide__skill {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.study-guide__skill .sg-skill__name { margin: 0 0 0.25rem; font-size: 1.2rem; }

/* Study guide presentation (SG-1): each part in its own form. Status is never colour alone: labels and icons too. */
.sg-label { margin: 0 0 0.2rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }

.sg-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.sg-table th, .sg-table td { text-align: left; vertical-align: top; padding: 0.5rem 0.6rem; border-top: 1px solid var(--line); }
.sg-table th[scope="row"] { width: 38%; font-weight: 700; }
.sg-table thead th { border-top: 0; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* SG-2: flip cards (key_terms_controller) and one step at a time (worked_example_controller). */
.sg-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 1.25rem 0 0.6rem; }
.sg-toolbar h4 { margin: 0; }
.sg-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); gap: 0.6rem; }
.sg-cards li { display: flex; }
.sg-card {
  width: 100%;
  height: 8.5rem;
  overflow-y: auto;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.sg-card:hover { border-color: var(--violet); }
.sg-card__term { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.sg-card__hint { font-size: 0.8rem; color: var(--muted); }
.sg-card--flipped { justify-content: flex-start; text-align: left; border-color: var(--violet); background: color-mix(in srgb, var(--violet) 10%, var(--bg)); }
.sg-card--flipped .sg-card__term { font-size: 0.85rem; color: var(--violet); }
.sg-card__definition { font-size: 0.95rem; line-height: 1.4; }

.sg-example__progress { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--muted); }
.sg-example__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.4rem; }
.sg-example__turn {
  margin: 0 0 0.8rem;
  padding: 0.55rem 0.8rem;
  border-left: 3px solid var(--gold);
  background: color-mix(in srgb, var(--gold-soft) 12%, transparent);
  font-weight: 700;
}

/* SG-3: one skill at a time (guide_skills_controller). The tabs scroll sideways on a phone. */
.sg-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 1.5rem 0 1rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) left / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, transparent) right / 2.5rem 100% no-repeat local,
    linear-gradient(to right, color-mix(in srgb, var(--ink) 22%, transparent), transparent) left / 1rem 100% no-repeat scroll,
    linear-gradient(to left, color-mix(in srgb, var(--ink) 22%, transparent), transparent) right / 1rem 100% no-repeat scroll;
}
/* #172: on a laptop the tabs wrap, so no skill hides off the edge. */
@media (min-width: 900px) { .sg-tabs { flex-wrap: wrap; overflow-x: visible; } }
.sg-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.sg-tab:hover { color: var(--ink); }
.sg-tab[aria-selected="true"] { color: var(--ink); background: var(--bg); border-color: var(--line); box-shadow: inset 0 3px 0 var(--gold); }
.sg-tab__n {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink);
  font-size: 0.8rem;
}
.sg-tab[aria-selected="true"] .sg-tab__n { background: var(--gold); color: var(--on-accent); }
.sg-skills--tabs .study-guide__skill { margin-top: 0; padding-top: 0; border-top: 0; }
.sg-next { display: flex; justify-content: flex-end; margin-top: 1rem; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); background: var(--bg); }
.sg-next .btn { white-space: normal; text-align: left; }

.sg-big-idea {
  position: relative;
  margin: 1rem 0;
  padding: 0.9rem 1.1rem 0.9rem 3rem;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--gold-soft) 16%, var(--surface));
}
.sg-big-idea::before { content: "\2726"; position: absolute; left: 0.95rem; top: 0.75rem; font-size: 1.4rem; color: var(--gold); }
.sg-big-idea__label { color: color-mix(in srgb, var(--gold) 65%, var(--ink)); }
.sg-big-idea__text { margin: 0; font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; line-height: 1.3; }

.sg-points { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.5rem; }
.sg-points li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: start;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.sg-points__n,
.sg-steps__n {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
}
.sg-points__n { background: var(--indigo); color: var(--on-accent); }
@media (min-width: 600px) {
  .sg-points { grid-template-columns: 1fr 1fr; }
  .sg-points li:last-child:nth-child(odd) { grid-column: 1 / -1; } /* #172: an odd last tile spans both columns */
}

.sg-example { margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); overflow: hidden; }
.sg-example__problem { padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.sg-example__label { color: var(--violet); }
.sg-example__question { margin: 0; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.35; }
.sg-example__body { padding: 0.9rem 1rem; }
.sg-steps { list-style: none; margin: 0 0 0.8rem; padding: 0; display: grid; gap: 0.5rem; }
.sg-steps li { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start; }
.sg-steps__n { border: 2px solid var(--violet); color: var(--violet); }
.sg-answer summary { cursor: pointer; font-weight: 700; color: var(--violet); }
.sg-answer__text {
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--good);
  border-radius: var(--radius-sm);
  background: var(--good-bg);
}
.sg-answer__text strong { color: var(--good); }

.sg-moves__title { color: var(--teal); }
.sg-moves { list-style: none; margin: 0 0 0.9rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.sg-move {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--teal);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
}
.sg-move__n { font-weight: 700; color: var(--teal); }

.sg-warnings { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.5rem; }
.sg-warning {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--bad);
  border-left-width: 6px;
  border-radius: var(--radius-sm);
  background: var(--bad-bg);
}
.sg-warning__icon { font-size: 1.2rem; line-height: 1.3; color: var(--bad); }
.sg-warning__label { display: block; color: var(--bad); }

/* Quizzes and the quiz runner (the global reduced-motion rule already stills the transitions) */
.quiz { padding-block: 0.75rem; border-top: 1px solid var(--line); }
.quiz:first-child { border-top: 0; padding-top: 0; }
.quiz__pending { margin: 0; font-weight: 700; color: var(--indigo); }
.quiz h3 { margin-bottom: 0.15em; }

.quiz-progress { font-size: 0.9rem; margin-bottom: 1rem; }
/* SP-4: a reading passage sits above its question, like a quoted page */
.quiz-passage { margin: 0 0 1rem; padding: 0.75rem 1rem; border-left: 3px solid var(--gold); background: var(--surface); font-family: var(--font-body); }
.quiz-passage p { margin: 0 0 0.5rem; }
.quiz-passage p:last-child { margin-bottom: 0; }
.quiz-prompt { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; line-height: 1.3; }
label.quiz-prompt { margin-bottom: 0.6rem; }

.quiz-fieldset { margin: 0 0 1.25rem; padding: 0; border: 0; min-width: 0; }
.quiz-fieldset legend { padding: 0; margin-bottom: 0.75rem; }

.quiz-choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.9rem;
  min-height: 44px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.quiz-choice:hover { border-color: var(--violet); }
.quiz-choice:has(input:checked) {
  border-color: var(--violet);
  background: color-mix(in srgb, var(--violet) 10%, var(--bg));
}
.quiz-choice:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 2px; }
.quiz-choice input { flex: none; width: 1.25rem; height: 1.25rem; accent-color: var(--indigo); }
.quiz-choice label { flex: 1; margin: 0; padding-block: 0.25rem; font-weight: 400; cursor: pointer; }

.quiz-numeric { display: flex; align-items: center; gap: 0.6rem; }
.quiz-numeric input { flex: 0 1 12rem; }
.quiz-unit { font-weight: 700; color: var(--muted); }
#reads_as:not(:empty) { display: block; margin-top: 0.35rem; font-size: 0.9rem; }

.quiz-hint,
.quiz-steps { margin-bottom: 1rem; padding: 0.6rem 0.9rem; background: var(--bg); border-radius: var(--radius-sm); }
.quiz-hint summary,
.quiz-steps summary { cursor: pointer; font-weight: 700; color: var(--violet); }
.quiz-hint p { margin: 0.5rem 0 0; }
.quiz-steps ol { margin: 0.5rem 0 0; padding-left: 1.4rem; }
.quiz-help { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }

/* Right and wrong are never colour alone: each state also has an icon and a text heading. */
.quiz-feedback {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.quiz-feedback__status { margin: 0 0 0.5rem; font-size: 1.3rem; }
.quiz-feedback h3 { margin: 0.75rem 0 0.25rem; font-size: 1rem; }
.quiz-feedback p:last-child { margin-bottom: 0; }
.quiz-feedback--correct { border-color: var(--good); background: var(--good-bg); }
.quiz-feedback--correct .quiz-feedback__status { color: var(--good); }
.quiz-feedback--partial { border-color: var(--gold); }
.quiz-feedback--partial .quiz-feedback__status { color: var(--gold); }
.quiz-feedback--wrong { border-color: var(--bad); background: var(--bad-bg); }
.quiz-feedback--wrong .quiz-feedback__status { color: var(--bad); }
.quiz-coach { margin-top: 0.75rem; font-weight: 700; }
/* SP-5: an explain-and-cite answer gets feedback, never a grade: no right or wrong colour. */
.quiz-feedback--pending { border-color: var(--violet); }
.quiz-feedback--pending .quiz-feedback__status { color: var(--violet); }
.quiz-criteria, .rubric-criteria { margin: 0 0 1rem; padding-left: 1.25rem; }
.rubric-criteria { list-style: none; padding-left: 0; display: grid; gap: 0.3rem; }
.rubric-criteria__mark { display: inline-block; width: 1.2rem; font-weight: 700; }
.rubric-criteria__item--met .rubric-criteria__mark { color: var(--good); }
.quiz-open-response textarea { width: 100%; }

.quiz-score { font-size: 1.1rem; }
.quiz-score strong { font-family: var(--font-display); font-size: 2.2rem; color: var(--indigo); }

.quiz-skills { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.quiz-skills li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding-block: 0.5rem;
  border-top: 1px solid var(--line);
}
.quiz-skills__name { flex: 1 1 12rem; font-weight: 700; }
.quiz-skills meter { flex: 0 1 8rem; width: 8rem; height: 0.8rem; }
.quiz-skills__label { flex: 0 0 7rem; font-weight: 700; }

.quiz-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }

/* A4a: skill status (icon plus words, never color alone), skill groups, coverage. */
.skill-status { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 700; }
.skill-status--weak { color: var(--bad); }
.skill-status--developing { color: var(--gold); }
.skill-status--strong { color: var(--good); }
.skill-status--new { color: var(--muted); }
.skill-group { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.skill-group__heading { margin-top: 1rem; }
.coverage, .skill-summary { color: var(--muted); font-size: 0.9rem; }

/* A4b: the family home. */
.kid-card h2 { margin-top: 0; }
.kid-card h3 { margin: 1.25rem 0 0.5rem; font-size: 1.05rem; }
.kid-card h4 { margin: 0.75rem 0 0.35rem; font-size: 0.95rem; color: var(--muted); }
.kid-card .button_to { margin-top: 1.25rem; }
.kid-card__classes { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.35rem; }
.kid-card__classes .coverage { display: block; }
.focus-list { margin: 0; padding-left: 1.5rem; display: grid; gap: 0.4rem; }
.focus-list li { display: list-item; }
.focus-list .muted { margin-left: 0.4rem; }
.tag-new {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 700;
}
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { padding-block: 0.45rem; border-top: 1px solid var(--line); }
.activity li:first-child { border-top: 0; }
.activity time { margin-left: 0.4rem; font-size: 0.85rem; }

/* A4c: a guardian's review of a finished round. */
.round-review { margin: 0; padding-left: 1.5rem; display: grid; gap: 1rem; }
.round-review__item { padding-top: 0.75rem; border-top: 1px solid var(--line); }
.round-review__item:first-child { border-top: 0; padding-top: 0; }
.round-review__item p { margin: 0.25rem 0; }
.round-review__result { font-weight: 700; }
.round-review__result .muted { font-weight: 400; }
.round-review__result--correct { color: var(--good); }
.round-review__result--partial { color: var(--gold); }
.round-review__result--wrong { color: var(--bad); }
.round-review__result--pending { color: var(--violet); }

/* A7a-1: the tutor chat. */
.tutor-messages { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; gap: 0.75rem; }
.tutor-message { padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); background: var(--bg); }
.tutor-message--user { border-left: 3px solid var(--violet); }
.tutor-message--assistant { border-left: 3px solid var(--gold); }
.tutor-message p { margin: 0.25rem 0; }
.tutor-message__role { font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.tutor-composer__starters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.tutor-composer__done { font-weight: 700; }
.tutor-chats { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.tutor-chats .muted { margin-left: 0.4rem; }

/* The upload fields: pages first, in a drop zone. Dropping files on the input works natively. */
.dropzone {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 1.25rem 1rem;
  border: 2px dashed color-mix(in srgb, var(--violet) 45%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--violet) 5%, var(--bg));
  color: var(--violet);
  text-align: center;
}
.dropzone label { margin: 0; font-size: 1.1rem; color: var(--ink); }
.dropzone input[type="file"] { max-width: 100%; color: var(--muted); font: inherit; font-size: 0.9rem; }
.dropzone input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  min-height: 44px;
  padding: 0.55rem 1.25rem;
  border: 1px solid var(--indigo);
  border-radius: var(--radius-sm);
  background: var(--indigo);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.dropzone .material-pages { justify-self: stretch; text-align: left; }
.dropzone p { margin: 0; }
.dropzone__hint { font-size: 0.875rem; }

/* An empty section: a faded preview of the guide to come. */
.guide-ghost { position: relative; padding: 1rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.guide-ghost__preview { display: grid; gap: 0.5rem; opacity: 0.55; }
.guide-ghost__label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.guide-ghost__cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.guide-ghost__cards span, .guide-ghost__bar { display: block; height: 2.6rem; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--line), color-mix(in srgb, var(--line) 40%, var(--bg)), var(--line)); background-size: 200% 100%; animation: shimmer 2.5s linear infinite; }
.guide-ghost__bar { height: 1.4rem; }
.guide-ghost__bar--short { width: 65%; }
.guide-ghost__caption { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; padding: 0.4rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; color: var(--ink); white-space: nowrap; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }

.conjure--locked .btn { opacity: 0.55; cursor: not-allowed; }
.conjure p { margin: 0.5rem 0 0; font-size: 0.9rem; }
.quiz__best { font-weight: 700; color: var(--gold); }
.quiz__best--top { color: var(--good); }
