/* ============================================================
   REVISO — design system
   Warm, calm, premium. Friendly for a 9-10 year old without
   being babyish.
   ============================================================ */

:root {
  --cream: #fffbf4;
  --paper: #ffffff;

  --ink: #1b2b44;
  --ink-soft: #4a5c75;
  --ink-faint: #8a99ae;

  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #5aa2f0;
  --brand-500: #2f7fe0;
  --brand-600: #1e5fbf;
  --brand-700: #194c99;
  --brand-800: #163e7a;

  --grass-50: #f0fbf2;
  --grass-100: #dcf5e1;
  --grass-200: #bcebc6;
  --grass-300: #8fdca0;
  --grass-500: #3eb45f;
  --grass-600: #2e9a4c;
  --grass-700: #26793e;

  --sun-50: #fffbeb;
  --sun-100: #fff3c4;
  --sun-200: #ffe699;
  --sun-400: #ffc93c;

  --berry-100: #fde7ec;
  --berry-500: #e4576f;
  --berry-600: #c93f57;

  --radius: 1.25rem;
  --radius-lg: 1.75rem;
  --shadow-soft: 0 2px 4px rgba(27, 43, 68, .04), 0 8px 24px rgba(27, 43, 68, .06);
  --shadow-lift: 0 4px 8px rgba(27, 43, 68, .06), 0 16px 40px rgba(27, 43, 68, .1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: Nunito, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(60rem 30rem at 110% -10%, rgba(95, 201, 122, .10), transparent 60%),
    radial-gradient(50rem 26rem at -10% 0%, rgba(47, 127, 224, .10), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: "Baloo 2", Nunito, system-ui, sans-serif;
  letter-spacing: -.01em;
  margin: 0;
}

a { color: inherit; }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(147, 197, 253, .6);
  border-radius: 1rem;
}

.muted { color: var(--ink-faint); font-weight: 700; font-size: .875rem; }
.soft { color: var(--ink-soft); }
.center { text-align: center; }
.stack > * + * { margin-top: 1.25rem; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.spread { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 251, 244, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0, 0, 0, .05);
}

.topbar-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  font-family: "Baloo 2", sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-600);
}

.brand img { border-radius: .9rem; }

.topbar-right { display: flex; align-items: center; gap: .75rem; }

.page { max-width: 64rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page-narrow { max-width: 42rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.admin-shell {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.sidebar { display: flex; gap: .5rem; overflow-x: auto; }
.admin-main { flex: 1 1 auto; min-width: 0; }

.sidebar a {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .875rem;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background-color .15s;
}

.sidebar a:hover { background: rgba(0, 0, 0, .05); }
.sidebar a.active { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-soft); }

@media (min-width: 768px) {
  .admin-shell { flex-direction: row; }
  .sidebar { flex-direction: column; width: 14rem; flex-shrink: 0; overflow: visible; }
}

@media (max-width: 767px) {
  .admin-shell { flex-direction: column; }
  .hide-sm { display: none; }
}

/* ---------- Card ---------- */

.card {
  background: var(--paper);
  border: 1px solid rgba(0, 0, 0, .05);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem;
}

.card + .card { margin-top: 1.25rem; }
.card-pad-0 { padding: 0; overflow: hidden; }

h1.page-title { font-size: 2rem; font-weight: 800; }
h2.card-title { font-size: 1.25rem; font-weight: 700; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  height: 3rem;
  padding: 0 1.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background-color .15s, transform .05s, border-color .15s;
  background: var(--brand-600);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn:hover { background: var(--brand-700); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .7; cursor: not-allowed; }

.btn-lg { height: 3.5rem; padding: 0 2rem; font-size: 1.125rem; }
.btn-sm { height: 2.25rem; padding: 0 1rem; font-size: .875rem; border-radius: .9rem; }
.btn-block { width: 100%; }

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--brand-100);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--brand-50); border-color: var(--brand-300); }

.btn-success { background: var(--grass-500); }
.btn-success:hover { background: var(--grass-600); }

.btn-ghost { background: transparent; color: var(--ink-soft); box-shadow: none; }
.btn-ghost:hover { background: rgba(0, 0, 0, .05); }

.btn-danger { background: var(--berry-100); color: var(--berry-600); box-shadow: none; }
.btn-danger:hover { background: #f9d2da; }

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .75rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
}

.badge-muted { background: rgba(0, 0, 0, .05); color: var(--ink-faint); }
.badge-brand { background: var(--brand-50); color: var(--brand-700); }
.badge-success { background: var(--grass-50); color: var(--grass-700); }
.badge-warn { background: var(--sun-50); color: #d4930a; }
.badge-neutral { background: rgba(27, 43, 68, .05); color: var(--ink-soft); }

/* ---------- Forms ---------- */

label.field { display: block; }
label.field > span { display: block; font-size: .875rem; font-weight: 800; color: var(--ink-soft); margin-bottom: .35rem; }

input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--brand-100);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  transition: border-color .15s;
}

input[type=text], input[type=email], input[type=password] { height: 3.5rem; }
input[type=date], select { height: 3rem; }
textarea { min-height: 4.5rem; resize: vertical; }

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-400); box-shadow: none; }
input::placeholder { font-weight: 400; color: var(--ink-faint); }

.field-sm input, .field-sm textarea, .field-sm select { border-color: rgba(0, 0, 0, .06); font-size: .9375rem; }
.field-sm input[type=text] { height: 2.75rem; }

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .875rem;
}

.alert-error { background: var(--berry-100); color: var(--berry-600); }
.alert-warn { background: var(--sun-50); border: 2px solid var(--sun-200); color: var(--ink-soft); }
.alert-info { background: var(--brand-50); color: var(--ink-soft); }

/* ---------- Progress ---------- */

.progress-row { display: flex; align-items: center; gap: .75rem; }

.progress {
  flex: 1 1 auto;
  height: .75rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .07);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(to right, var(--brand-400), var(--brand-600));
  transition: width .5s ease-out;
}

.progress-label { width: 3rem; text-align: right; font-weight: 800; font-size: .875rem; color: var(--ink-soft); }

/* ---------- Login ---------- */

.login-wrap {
  max-width: 28rem;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 1.25rem;
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { border-radius: 1.25rem; }
.login-logo h1 { font-size: 2.25rem; font-weight: 800; color: var(--brand-600); margin-top: .75rem; }
.login-logo p { margin: .25rem 0 0; font-size: .875rem; font-weight: 700; color: var(--ink-faint); }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  background: rgba(0, 0, 0, .04);
  border-radius: var(--radius);
  padding: .375rem;
}

.tabs button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 800;
  font-size: .875rem;
  color: var(--ink-faint);
  padding: .625rem;
  border-radius: .9rem;
  cursor: pointer;
}

.tabs button.active { background: #fff; color: var(--brand-700); box-shadow: var(--shadow-soft); }

.quick-logins { border-top: 1px solid rgba(0, 0, 0, .05); padding-top: 1.25rem; }
.quick-logins p { text-align: center; font-size: .75rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 .75rem; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.quick-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: 1rem;
  border: 2px solid var(--brand-100);
  border-radius: var(--radius);
  background: #fff;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}

.quick-grid button:hover { border-color: var(--brand-300); background: var(--brand-50); }
.quick-grid .emoji { font-size: 1.5rem; }

/* ---------- Student home ---------- */

.review-grid { display: grid; gap: 1.25rem; margin-top: 2rem; }
@media (min-width: 640px) { .review-grid { grid-template-columns: 1fr 1fr; } }

.review-card { display: flex; flex-direction: column; gap: 1rem; transition: box-shadow .2s; }
.review-card:hover { box-shadow: var(--shadow-lift); }
.review-card .week { font-family: "Baloo 2", sans-serif; font-size: .875rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--brand-600); }
.review-card h2 { font-size: 1.5rem; font-weight: 800; }
.review-card .subjects { font-size: .875rem; font-weight: 700; color: var(--ink-soft); margin: 0; }
.review-card .spacer { flex: 1 1 auto; }

.score-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--grass-50);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-weight: 800;
  color: var(--grass-700);
}

.empty { text-align: center; padding: 2.5rem 1.5rem; }
.empty .emoji { font-size: 3rem; }

/* ---------- Review player ---------- */

.player-head { margin-bottom: 1.5rem; }
.player-head .title { font-family: "Baloo 2", sans-serif; font-size: 1.125rem; font-weight: 800; }
.player-head .subject { font-size: .875rem; font-weight: 700; color: var(--ink-faint); }

.panel { animation: pop-in .18s ease-out; }
.panel-center { text-align: center; padding: 2rem 1.5rem; }
.panel-center .emoji { font-size: 3rem; }
.panel-center h1 { font-size: 1.875rem; font-weight: 800; margin-top: 1rem; }
.panel-center p { color: var(--ink-soft); margin: .5rem 0 0; }
.panel-center .btn { margin-top: 1.5rem; }

@keyframes pop-in { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slide-up { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes bounce-once { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

.q-subject { font-size: .875rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-600); margin-bottom: .5rem; }
.q-text { font-size: 1.5rem; font-weight: 700; line-height: 1.35; }
.q-body { margin-top: 1.5rem; display: grid; gap: .75rem; }
.q-actions { margin-top: 1.5rem; display: flex; justify-content: flex-end; gap: .75rem; }

.option {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  padding: 1rem;
  border: 2px solid rgba(0, 0, 0, .05);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}

.option:hover:not([disabled]) { border-color: var(--brand-200); background: rgba(239, 246, 255, .4); }
.option[aria-pressed="true"] { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-800); box-shadow: var(--shadow-soft); }
.option[disabled] { cursor: not-allowed; opacity: .7; }

.option .letter {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .75rem;
  background: rgba(0, 0, 0, .05);
  color: var(--ink-faint);
  font-size: .875rem;
  font-weight: 800;
}

.option[aria-pressed="true"] .letter { background: var(--brand-500); color: #fff; }

.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.tf-grid .option { justify-content: center; font-family: "Baloo 2", sans-serif; font-size: 1.25rem; font-weight: 800; padding: 1.5rem; }

.answer-input { height: 4rem !important; font-size: 1.25rem; }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.match-col { display: grid; gap: .75rem; align-content: start; }

.match-item {
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-weight: 600;
  padding: .75rem;
  border: 2px solid rgba(0, 0, 0, .05);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}

.match-item:hover:not([disabled]) { border-color: var(--brand-200); }
.match-item.active { border-color: var(--brand-500); background: var(--brand-50); box-shadow: var(--shadow-soft); }
.match-item.paired { border-color: var(--grass-300); background: var(--grass-50); }
.match-item.used { border-color: var(--grass-200); background: rgba(240, 251, 242, .6); color: var(--ink-faint); }
.match-item[disabled] { cursor: not-allowed; opacity: .75; }
.match-item .pair-note { display: block; margin-top: .25rem; font-size: .875rem; font-weight: 800; color: var(--grass-700); }

.feedback {
  margin-top: 1.5rem;
  border-radius: var(--radius);
  border: 2px solid;
  padding: 1.25rem;
  animation: slide-up .22s ease-out;
}

.feedback h3 { font-size: 1.125rem; font-weight: 700; }
.feedback p { margin: .25rem 0 0; color: var(--ink-soft); }
.feedback strong { color: var(--ink); }

.feedback-correct { background: var(--grass-50); border-color: var(--grass-200); }
.feedback-hint { background: var(--sun-50); border-color: var(--sun-200); }
.feedback-revealed { background: var(--brand-50); border-color: var(--brand-200); }

/* ---------- Results ---------- */

.result-head {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  padding: 2rem;
  text-align: center;
}

.result-head h1 { font-size: 1.5rem; font-weight: 800; }
.result-head .sub { color: rgba(255, 255, 255, .8); margin-top: .25rem; }

.score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: .25rem;
  margin-top: 1.5rem;
  padding: 1rem 2rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .15);
}

.score-badge .big { font-family: "Baloo 2", sans-serif; font-size: 3.75rem; font-weight: 800; line-height: 1; }
.score-badge .max { font-family: "Baloo 2", sans-serif; font-size: 1.5rem; font-weight: 700; color: rgba(255, 255, 255, .7); }

.subject-rows { padding: 1.5rem; display: grid; gap: .75rem; }

.subject-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, .03);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-weight: 800;
}

.encouragement { text-align: center; font-family: "Baloo 2", sans-serif; font-size: 1.125rem; font-weight: 700; color: var(--grass-700); padding-top: .5rem; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti span { position: absolute; top: 0; width: .625rem; height: .625rem; border-radius: .15rem; animation: confetti-fall linear forwards; }

@keyframes confetti-fall {
  from { transform: translateY(-10vh) rotate(0); opacity: 1; }
  to { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

/* ---------- Admin ---------- */

.stat-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }

.stat .label { font-size: .875rem; font-weight: 800; color: var(--ink-faint); }
.stat .value { font-family: "Baloo 2", sans-serif; font-size: 1.875rem; font-weight: 800; margin-top: .25rem; }
.stat .hint { font-size: .875rem; color: var(--ink-soft); margin-top: .25rem; }

table { width: 100%; border-collapse: collapse; text-align: left; }
thead tr { border-bottom: 1px solid rgba(0, 0, 0, .05); }
th { padding: 1rem 1.25rem; font-size: .875rem; font-weight: 800; color: var(--ink-faint); }
td { padding: 1rem 1.25rem; border-bottom: 1px solid rgba(0, 0, 0, .05); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0, 0, 0, .02); }
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 40rem; }

.dropzone {
  border: 2px dashed var(--brand-200);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 2.5rem;
  text-align: center;
  transition: border-color .15s, background-color .15s;
}

.dropzone.dragging { border-color: var(--brand-400); background: var(--brand-50); }
.dropzone .emoji { font-size: 2.25rem; }
.dropzone h3 { margin-top: .75rem; font-size: 1.125rem; font-weight: 700; }
.dropzone p { margin: .25rem 0 0; font-size: .875rem; color: var(--ink-faint); }
.dropzone .actions { margin-top: 1.25rem; display: flex; justify-content: center; gap: .75rem; }

.loading-panel { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; padding: 2.5rem 0; text-align: center; }
.loading-panel .ring { width: 4rem; height: 4rem; border: 4px solid var(--brand-100); border-top-color: var(--brand-500); border-radius: 50%; animation: spin .9s linear infinite; }
.loading-panel .message { font-family: "Baloo 2", sans-serif; font-size: 1.25rem; font-weight: 700; animation: slide-up .22s ease-out; }

.subject-line {
  border: 2px solid rgba(0, 0, 0, .05);
  border-radius: var(--radius);
  padding: 1rem;
}

.subject-line + .subject-line { margin-top: .75rem; }
.subject-line .head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.subject-line .name { font-weight: 800; display: inline-flex; align-items: center; gap: .5rem; }
.subject-line .points { font-size: .875rem; font-weight: 700; color: var(--ink-faint); }
.subject-line .detail { margin-top: 1rem; display: grid; gap: 1rem; }
@media (min-width: 640px) { .subject-line .detail { grid-template-columns: 1fr 1fr; } }

.question-card {
  border: 2px solid rgba(0, 0, 0, .05);
  border-radius: var(--radius);
  background: #fff;
  padding: 1.25rem;
}

.question-card + .question-card { margin-top: .75rem; }
.question-card .head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.question-card .tools { display: flex; flex-wrap: wrap; gap: .25rem; }
.question-card .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border-radius: .6rem;
  background: rgba(0, 0, 0, .05); color: var(--ink-faint);
  font-size: .75rem; font-weight: 800;
}
.question-card .body { margin-top: .75rem; display: grid; gap: .5rem; }
.question-card .prompt { font-weight: 700; margin: 0; }
.question-card ul { margin: 0; padding-left: 1.1rem; font-size: .875rem; color: var(--ink-soft); }
.question-card li.correct { font-weight: 800; color: var(--grass-700); list-style: none; margin-left: -1.1rem; }
.question-card .meta { font-size: .875rem; color: var(--ink-faint); margin: 0; }
.question-card form { margin-top: 1rem; display: grid; gap: 1rem; }

.option-edit { display: flex; align-items: center; gap: .75rem; }
.option-edit input[type=radio] { width: 1.25rem; height: 1.25rem; accent-color: var(--brand-500); flex-shrink: 0; }

.inline-form { display: inline; }

.title-input {
  font-family: "Baloo 2", sans-serif;
  font-size: 1.875rem;
  font-weight: 800;
  border: 2px solid transparent;
  background: transparent;
  padding: .25rem .5rem;
  margin-left: -.5rem;
  height: auto !important;
  border-radius: .9rem;
}

.title-input:hover { border-color: rgba(0, 0, 0, .05); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 43, 68, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 1.5rem;
  max-width: 32rem;
  width: 100%;
  animation: pop-in .18s ease-out;
}

.modal h2 { font-size: 1.25rem; font-weight: 700; }
.modal p { color: var(--ink-soft); }
.modal .actions { margin-top: 1.5rem; display: flex; justify-content: flex-end; gap: .75rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- "This week at school" intro ---------- */

.news-panel { padding: 1.75rem; }

.news-head { display: flex; align-items: center; gap: .75rem; }
.news-head .emoji { font-size: 2rem; }
.news-head h1 { font-size: 1.5rem; font-weight: 800; }

.news-summary {
  margin: 1rem 0 0;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.news-list {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: .625rem;
}

.news-list li {
  position: relative;
  padding: .75rem 1rem .75rem 2.5rem;
  border-radius: var(--radius);
  background: var(--sun-50);
  font-weight: 600;
  line-height: 1.45;
}

.news-list li::before {
  content: "📌";
  position: absolute;
  left: .9rem;
  top: .75rem;
}

/* Arabic questions: give right-to-left text room to breathe. */
[dir="rtl"], :where(.q-text, .option span, .match-item span, .answer-input)[dir="auto"] {
  line-height: 1.75;
}

/* ---------- Intro shown to the parent in the draft ---------- */

.intro-editor .news-list li { background: rgba(0, 0, 0, .03); }
.intro-editor textarea { min-height: 7rem; }

/* ============================================================
   Weekly News — the school newsletter, digested for the parent
   ============================================================ */

.news-hero {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-soft);
}

.news-kicker {
  margin: 0;
  font-size: .8125rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .75);
}

.news-hero h1 {
  margin-top: .5rem;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.3;
}

.news-intro {
  margin: .75rem 0 0;
  color: rgba(255, 255, 255, .88);
  line-height: 1.6;
}

/* ---------- Actions ---------- */

.news-actions .action-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
  border-left: 5px solid;
}

.action-now   { background: #fff1f3; border-color: var(--berry-500); }
.action-soon  { background: var(--sun-50); border-color: var(--sun-400); }
.action-later { background: var(--brand-50); border-color: var(--brand-400); }

.action-when {
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.action-now   .action-when { color: var(--berry-600); }
.action-soon  .action-when { color: #b9810a; }
.action-later .action-when { color: var(--brand-700); }

.action-card h3 { margin: .35rem 0 0; font-size: 1.125rem; font-weight: 800; }
.action-card p  { margin: .5rem 0 0; color: var(--ink-soft); line-height: 1.55; }
.action-card .btn { margin-top: .875rem; }

/* ---------- Timeline ---------- */

.timeline { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }

.timeline li {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: .25rem 1rem;
  align-items: baseline;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .03);
}

.timeline .tl-date  { font-weight: 800; font-size: .875rem; color: var(--brand-700); }
.timeline .tl-label { font-weight: 700; }
.timeline .tl-note  { grid-column: 2; font-size: .875rem; color: var(--ink-faint); }

.timeline .tl-off   { background: var(--grass-50); }
.timeline .tl-off .tl-date { color: var(--grass-700); }
.timeline .tl-alert { background: #fff1f3; }
.timeline .tl-alert .tl-date { color: var(--berry-600); }

@media (max-width: 599px) {
  .timeline li { grid-template-columns: 1fr; }
  .timeline .tl-note { grid-column: 1; }
}

/* ---------- Sections ---------- */

.news-section .news-item {
  padding: 1rem 0;
  border-top: 1px solid rgba(0, 0, 0, .06);
}

.news-section .news-item:first-of-type { border-top: none; padding-top: .5rem; }
.news-section .news-item h3 { font-size: 1.0625rem; font-weight: 800; margin: 0; }
.news-section .news-item p  { margin: .35rem 0 0; color: var(--ink-soft); line-height: 1.6; }

.news-meta {
  margin: .625rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
}

.news-meta li {
  background: rgba(0, 0, 0, .05);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-size: .8125rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.news-link { font-weight: 800; color: var(--brand-600); }

.tone-focus  { border-left: 5px solid var(--grass-500); }
.tone-money  { border-left: 5px solid var(--sun-400); }
.tone-plain  { }

.skipped-list { margin: 0; padding-left: 1.1rem; color: var(--ink-faint); line-height: 1.8; }

.issue-list { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.issue-list a {
  display: inline-block;
  padding: .4rem .9rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .05);
  font-weight: 700;
  font-size: .875rem;
  text-decoration: none;
}
.issue-list a.current { background: var(--brand-600); color: #fff; }

/* ---------- Share a Weekly News issue ---------- */

.share-box { border-left: 5px solid var(--brand-400); }

.share-row { display: flex; gap: .5rem; align-items: center; }

.share-row input {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.75rem;
  font-size: .875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border-color: rgba(0, 0, 0, .08);
  background: rgba(0, 0, 0, .03);
}

.share-row .btn { flex: 0 0 auto; }

@media (max-width: 599px) {
  .share-row { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   Spelling Bee
   ============================================================ */

.student-tabs { border-bottom: 1px solid rgba(0, 0, 0, .05); background: rgba(255, 251, 244, .7); }

.student-tabs-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: .5rem 1.25rem;
  display: flex;
  gap: .5rem;
}

.student-tabs a {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: .9375rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.student-tabs a:hover { background: rgba(0, 0, 0, .05); }
.student-tabs a.active { background: var(--brand-600); color: #fff; }

.speak-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.speak-button {
  flex: 0 0 auto;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--sun-400), #f0a500);
  color: #fff;
  font-size: 2.25rem;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .1s;
}

.speak-button:hover { transform: scale(1.04); }
.speak-button:active { transform: scale(.97); }

.speak-side { flex: 1 1 auto; min-width: 0; }

.spell-input {
  font-size: 1.5rem !important;
  letter-spacing: .06em;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.spelled {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.375rem;
  letter-spacing: .1em;
  color: var(--ink);
}

.flash-word {
  margin: 0 0 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--sun-50);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.75rem;
  letter-spacing: .1em;
  font-weight: 700;
}

.word-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: .25rem 0 .5rem; }

.word-chips span {
  background: var(--sun-50);
  border: 2px solid var(--sun-200);
  border-radius: 999px;
  padding: .3rem .85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: .9375rem;
}

@media (max-width: 520px) {
  .speak-row { flex-direction: column; text-align: center; }
  .speak-side { text-align: center; }
}

/* ---------- Spelling Bee: practice history ---------- */

.try-list { display: grid; gap: .625rem; margin-top: 1rem; }

.try-row {
  display: flex;
  align-items: center;
  gap: .875rem;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, .03);
  border-radius: var(--radius);
  padding: .75rem 1rem;
}

.try-score {
  font-family: "Baloo 2", sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  min-width: 3.75rem;
}

.try-score.is-great { color: var(--grass-700); }
.try-score.is-ok    { color: #d4930a; }
.try-score.is-low   { color: var(--berry-600); }

.try-when { font-weight: 700; font-size: .875rem; color: var(--ink-soft); min-width: 8rem; }
.try-round { font-weight: 800; font-size: .875rem; color: var(--brand-700); min-width: 5rem; }
.try-missed { display: flex; flex-wrap: wrap; gap: .375rem; flex: 1 1 auto; }

.try-missed span {
  background: #fff;
  border: 1px solid var(--sun-200);
  border-radius: 999px;
  padding: .15rem .6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8125rem;
  font-weight: 700;
}

.try-perfect { color: var(--grass-700); font-weight: 800; font-size: .875rem; }

@media (max-width: 520px) {
  .try-row { gap: .5rem; }
  .try-when, .try-round { min-width: 0; }
}

/* ---------- Move break (after every 5 questions) ---------- */
.move-kicker {
  color: var(--grass-700) !important;
  font-weight: 800;
  font-size: .8125rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.move-panel h1 { margin-top: .25rem !important; }

.move-stage {
  margin: 1.25rem auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
}

.move-figure { width: 7rem; height: 8rem; color: var(--brand-600); }
.move-figure path, .move-figure circle { transform-box: fill-box; }
.move-figure .arm-l { transform-origin: 100% 100%; }
.move-figure .arm-r { transform-origin: 0% 100%; }
.move-figure .leg-l { transform-origin: 100% 0%; }
.move-figure .leg-r { transform-origin: 0% 0%; }

.move-figure.is-jump { animation: move-jump .7s ease-in-out infinite; }
.move-figure.is-jump .arm-l { animation: move-arm-l .7s ease-in-out infinite; }
.move-figure.is-jump .arm-r { animation: move-arm-r .7s ease-in-out infinite; }
.move-figure.is-jump .leg-l { animation: move-leg-l .7s ease-in-out infinite; }
.move-figure.is-jump .leg-r { animation: move-leg-r .7s ease-in-out infinite; }
.move-figure.is-sway { animation: move-sway 1.1s ease-in-out infinite; }
.move-figure.is-stretch { animation: move-stretch 2.4s ease-in-out infinite; }
.move-figure.is-bend { animation: move-bend 1.6s ease-in-out infinite; transform-origin: 50% 70%; }
.move-figure.is-clap .arm-l { animation: move-clap-l .5s ease-in-out infinite; }
.move-figure.is-clap .arm-r { animation: move-clap-r .5s ease-in-out infinite; }

@keyframes move-jump { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes move-arm-l { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-75deg); } }
@keyframes move-arm-r { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(75deg); } }
@keyframes move-leg-l { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-12deg); } }
@keyframes move-leg-r { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(12deg); } }
@keyframes move-clap-l { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(40deg); } }
@keyframes move-clap-r { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-40deg); } }
@keyframes move-sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes move-stretch { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.08); } }
@keyframes move-bend { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(28deg); } }

.move-timer { position: relative; width: 5.5rem; height: 5.5rem; }
.move-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.move-timer circle { fill: none; stroke-width: 7; }
.move-timer .track { stroke: var(--grass-100); }
.move-timer .fill { stroke: var(--grass-500); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.move-timer span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Baloo 2", Nunito, sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--ink);
}

.move-say { font-size: 1.25rem; font-weight: 700; color: var(--ink) !important; margin-top: 1rem !important; }
.move-well { color: var(--grass-700) !important; font-weight: 700; }
.move-note { margin-top: .25rem !important; }

.link-btn {
  margin-top: .75rem;
  background: none;
  border: 0;
  padding: .25rem .5rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink-faint);
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink-soft); }

/* ---------- Practice again (new questions on the same topics) ---------- */
.practice-again {
  margin-top: .5rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  display: grid;
  gap: .75rem;
}
.practice-note { margin: 0; text-align: center; font-weight: 700; color: var(--ink-soft); }
.practice-meta { margin: 0; }
.review-card .btn-ghost { margin-top: -.5rem; }

/* ---------- Line icons ---------- */
.icon { width: 1.25rem; height: 1.25rem; flex: none; }
.student-tabs a .icon { width: 1.125rem; height: 1.125rem; }
.empty-icon { display: inline-grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: var(--grass-50); color: var(--grass-600); }
.empty-icon .icon { width: 2rem; height: 2rem; }

/* ---------- Student home: this week, gift, badges ---------- */
.section-title { font-size: 1.375rem; font-weight: 800; margin-top: 2.5rem; }
.page > .review-grid, .page > .empty { margin-top: 1rem; }

.home-top { display: grid; gap: 1.25rem; margin-top: 1.75rem; }
@media (min-width: 760px) { .home-top { grid-template-columns: 1.2fr 1fr; } }

.week-count { font-weight: 700; color: var(--ink-soft); }
.week-count strong { font-family: "Baloo 2", Nunito, sans-serif; font-size: 1.5rem; color: var(--brand-600); }

.week-days { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: .375rem; margin: 1.25rem 0 0; padding: 0; }
.week-days li { display: grid; justify-items: center; gap: .375rem; }
.week-days .dot {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper); border: 2px dashed rgba(27, 43, 68, .14); color: #fff;
}
.week-days .done .dot { background: var(--sun-400); border: 2px solid var(--sun-400); color: #fff; animation: pop-in .3s ease-out; }
.week-days .done .dot .icon { fill: #fff; stroke: #fff; width: 1.125rem; height: 1.125rem; }
.week-days .today .dot { border-color: var(--brand-400); border-style: solid; }
.week-days .future .dot { opacity: .55; }
.week-days .day { font-size: .75rem; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; }
.week-days .today .day { color: var(--brand-600); }
.week-note { margin: 1rem 0 0; }

.gift-card { display: flex; gap: 1rem; align-items: flex-start; border: 2px solid transparent; }
.gift-icon { flex: none; width: 3.25rem; height: 3.25rem; border-radius: 1rem; display: grid; place-items: center; background: rgba(27, 43, 68, .05); color: var(--ink-faint); }
.gift-icon .icon { width: 1.75rem; height: 1.75rem; }
.gift-body { flex: 1; min-width: 0; display: grid; gap: .5rem; }
.gift-kicker { margin: 0; font-size: .8125rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.gift-name { font-size: 1.375rem; font-weight: 800; overflow-wrap: anywhere; }
.gift-rule, .gift-state { margin: 0; font-weight: 700; color: var(--ink-soft); }
.gift-body .muted { margin: 0; }
.gift-card.is-earned { border-color: var(--grass-200); }
.gift-card.is-earned .gift-icon { background: var(--grass-50); color: var(--grass-600); }
.gift-card.is-open { border-color: var(--sun-200); background: var(--sun-50); }
.gift-card.is-open .gift-icon { background: var(--sun-400); color: #fff; animation: bounce-once .5s ease-out; }
.gift-card.is-open .gift-state { color: var(--ink); }


/* ---------- Parent: weekend gift form ---------- */
.rule-choices { border: 0; margin: 0; padding: 0; display: grid; gap: .5rem; }
.rule-choices legend { font-size: .875rem; font-weight: 800; color: var(--ink-soft); margin-bottom: .35rem; padding: 0; }
.rule-choice { display: flex; gap: .75rem; align-items: center; padding: .75rem 1rem; border-radius: 1rem; border: 2px solid rgba(0, 0, 0, .06); cursor: pointer; font-weight: 700; }
.rule-choice:has(input:checked) { border-color: var(--brand-400); background: var(--brand-50); }
.rule-choice input { width: 1.125rem; height: 1.125rem; accent-color: var(--brand-600); }

/* ---------- Developer pages ---------- */
.dev-banner {
  background: var(--ink); color: #fff; text-align: center;
  font-weight: 700; font-size: .875rem; padding: .6rem 1rem;
}
.dev-banner a { color: var(--sun-200); margin-left: .75rem; }
.page > .dev-banner { border-radius: var(--radius); margin-bottom: 1.5rem; }
.dev-switch {
  background: var(--ink); color: #fff; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: center; gap: .4rem; padding: .45rem 1rem; font-size: .875rem; font-weight: 700;
}
.dev-switch form { margin: 0; }
.dev-switch-label { opacity: .75; margin-right: .25rem; }
.dev-switch button {
  border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff;
  border-radius: 999px; padding: .25rem .8rem; font: inherit; cursor: pointer;
}
.dev-switch button[aria-pressed="true"] { background: #fff; color: var(--ink); border-color: #fff; }
.dev-facts { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .5rem; }
.dev-facts li { display: flex; justify-content: space-between; gap: 1rem; font-size: .9375rem; }
.dev-facts span { color: var(--ink-faint); font-weight: 700; }
.dev-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.dev-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding: .5rem; }
.dev-table td { padding: .6rem .5rem; border-top: 1px solid rgba(0, 0, 0, .05); }
.card:has(> .dev-table) { overflow-x: auto; }
.is-readonly { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ---------- Player: line icons instead of emoji ---------- */
.panel-icon {
  width: 4rem; height: 4rem; margin: 0 auto; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-600);
}
.panel-icon .icon { width: 2rem; height: 2rem; }
.panel-icon.is-good { background: var(--grass-50); color: var(--grass-600); animation: bounce-once .42s ease-out; }
.news-head .panel-icon { margin: 0; width: 3rem; height: 3rem; }
.news-head .panel-icon .icon { width: 1.5rem; height: 1.5rem; }
.feedback h3 { display: flex; align-items: center; gap: .5rem; }
.feedback h3 .icon { width: 1.25rem; height: 1.25rem; }
.feedback-correct h3 { color: var(--grass-700); }
.result-head h1 { display: block; }

/* Cards inside a grid are spaced by the grid gap, not by .card + .card. */
.review-grid > .card + .card, .home-top > .card + .card { margin-top: 0; }

/* ---------- Phones ---------- */
/* The week circles shrink to fit instead of pushing the card wider than the screen. */
.week-days { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.week-days .dot { width: 100%; max-width: 2.5rem; height: auto; aspect-ratio: 1; }

@media (max-width: 480px) {
  .card { padding: 1.15rem; }
  .page { padding-left: max(1rem, env(safe-area-inset-left, 0px)); padding-right: max(1rem, env(safe-area-inset-right, 0px)); }
  h1.page-title { font-size: 1.65rem; }
  .week-days { gap: .25rem; }
  .week-days .day { font-size: .65rem; }
  .gift-name { font-size: 1.2rem; }
}

/* Installed on the home screen: keep content clear of the notch and home bar. */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top, 0px); }
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* Parent pages on a phone: the menu becomes one row that scrolls sideways on
   its own, instead of stretching the whole page wider than the screen. */
@media (max-width: 767px) {
  .admin-shell { align-items: stretch; padding-left: max(1rem, env(safe-area-inset-left, 0px)); padding-right: max(1rem, env(safe-area-inset-right, 0px)); }
  .sidebar { max-width: 100%; margin-inline: -.25rem; padding: .25rem; scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar a { padding: .6rem .9rem; font-size: .9375rem; }
  .admin-main { width: 100%; }
}
