:root {
  --bg: #CFFFDC;
  --card: #ffffff;
  --ink: #1f2340;
  --muted: #4b6b57;
  --brand: #68BA7F;
  --brand-dark: #2E6F40;
  --rec: #e11d48;
  --line: #a9e6bb;
  /* the two headers (home and the slim one on every other page) have their own colour: change these two lines to try another */
  --header: #3D8BFD;
  --header-dark: #2563C7;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
.top {
  background: var(--header);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.fun-only { display: none; }   /* shown only in the Fun theme (css/fun.css) */
.settings-btn {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; font-size: 1.3rem; line-height: 1;
  background: #fff;
}
.settings-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.settings-overlay[hidden] { display: none; }
.settings-box { background: var(--card); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.settings-box h2 { margin: 0 0 12px; font-size: 1.2rem; }
.settings-label { margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.theme-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.theme-opt {
  font: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px;
  border-radius: 14px; border: 3px solid var(--line); background: #fff; color: var(--ink);
}
.theme-opt small { color: var(--muted); }
.theme-opt.active { border-color: var(--brand); background: var(--bg); }
.theme-sw { width: 64px; height: 40px; border-radius: 10px; margin-bottom: 4px; }
.sw-classic { background: linear-gradient(#68BA7F 45%, #CFFFDC 45%); border: 2px solid #a9e6bb; }
.sw-fun { background: linear-gradient(#2EC4B6 45%, #FFF4DC 45%); border: 2px solid #2b2140; box-shadow: 0 3px 0 #FF9F43; }

.top h1 { margin: 0; font-size: 1.25rem; }
.env { margin: 4px 0 0; font-size: 1rem; font-weight: 700; opacity: 1; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
.panel { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: 0 2px 8px rgba(40, 40, 100, .08); }
.panel[hidden] { display: none; }
.placeholder { color: var(--muted); text-align: center; padding: 24px 8px; margin: 0; }

label { display: block; font-weight: 600; margin: 10px 0 6px; }
textarea, select {
  width: 100%; font: inherit; font-size: 1.1rem; padding: 12px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
textarea:focus, select:focus { outline: none; border-color: var(--brand); }
input[type=range] { width: 100%; }

.row { display: flex; gap: 12px; margin-top: 14px; }
.btn {
  flex: 1; font: inherit; font-size: 1.1rem; font-weight: 700; padding: 14px;
  border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink);
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn:disabled { opacity: .5; }

.opts { margin-top: 14px; color: var(--muted); }
.opts summary { cursor: pointer; padding: 6px 0; }

.badge { display: inline-block; margin-left: 8px; padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; background: #e5e7f5; color: var(--ink); vertical-align: middle; }
.badge[hidden] { display: none; }
.badge.child { background: #dcfce7; color: #166534; }
.badge.parent { background: #dbeafe; color: #1e40af; }
.badge.unsure { background: #fef3c7; color: #92400e; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; color: var(--ink); }
label.check input { width: 22px; height: 22px; }
.perm { margin-top: 16px; padding: 14px; border-radius: 12px; background: #fff7e6; border: 2px solid #f5c26b; }
.perm[hidden] { display: none; }
.perm.blocked { background: #ffecef; border-color: #f4a3b1; }
.perm.checking { background: var(--bg); border-color: var(--line); }
.perm p { margin: 0 0 10px; line-height: 1.45; }
.perm ol { margin: 0 0 10px; padding-left: 20px; line-height: 1.5; }
.perm .btn { width: 100%; }
.hint { color: var(--muted); margin: 12px 0 0; font-size: .95rem; }

.status { min-height: 1.4em; margin: 14px 0 0; font-size: .95rem; color: var(--muted); }
.status.err { display: none; } /* errors are shown in the modal popup (alert.js); class is kept for logic checks */
.status.ok { color: #15803d; }

/* ---- Homework ---- */
.hw-title { margin: 0 0 4px; font-size: 1.15rem; }
.hw-meta { display: grid; gap: 10px; margin: 14px 0 4px; }
.hw-meta > div { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.hw-meta dt { margin: 0; font-weight: 600; color: var(--muted); }
.hw-meta dd { margin: 0; font-weight: 700; }
.hw-meta dd.hw-loading { color: var(--muted); font-weight: 500; }

.spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: hw-spin .7s linear infinite;
}
@keyframes hw-spin { to { transform: rotate(360deg); } }

/* Full-screen modal: covers the whole viewport, including the app header/nav.
   No close button — the only way out is Submit on the last question. */
.hw-runner[hidden] { display: none; }
.hw-runner {
  position: fixed; inset: 0; z-index: 100; background: var(--card);
  display: flex; flex-direction: column;
}
.hw-runner-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--header); color: #fff;
}
.hw-exit {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .18); color: #fff; font-size: 1.05rem; line-height: 1;
}

.hw-runner-body { flex: 1; overflow-y: auto; padding: 20px 16px; max-width: 640px; margin: 0 auto; width: 100%; }
.hw-qtitle { margin: 0 0 14px; font-size: 1.3rem; line-height: 1.35; }
.hw-qtext-row { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 18px; }
.hw-qtext { margin: 0; font-size: 1.25rem; line-height: 1.5; color: #000; font-weight: 800; flex: 1; }
.hw-qtext strong { color: var(--brand-dark); font-weight: 800; }
/* Text highlight, not a background box: guaranteed, the phrase being read turns grey. Bonus
   (only where the phone's voice reports word boundaries): the exact word also turns bold. */
.hw-seg.seg-active { color: #6b7280; }
.hw-word.word-active { color: #6b7280; font-weight: 800; }
.hw-speak-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line);
  background: #fff; color: var(--brand-dark); font-size: 1.1rem; line-height: 1;
}
.hw-speak-btn[hidden] { display: none; }
.hw-speak-btn.playing { background: var(--brand); border-color: var(--brand); color: #fff; }

.hw-options { display: grid; gap: 12px; }
.hw-options[hidden], .hw-explain[hidden] { display: none; }
.hw-opt {
  text-align: left; font: inherit; font-size: 1.05rem; padding: 14px 16px;
  border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink);
}
.hw-opt.selected { background: #e3eeff; border-color: #2563eb; color: #1d4ed8; font-weight: 700; } /* blue, so a chosen answer is not mistaken for the correct (green) one */
.hw-opt.correct { background: #dcfce7; border-color: #16a34a; color: #15803d; font-weight: 700; }
.hw-opt.wrong { background: #ffecef; border-color: var(--rec); color: var(--rec); font-weight: 700; }

.hw-obj-feedback {
  margin-top: 14px; padding: 14px; border-radius: 12px; line-height: 1.5;
  background: #ffecef; border: 2px solid #f4a3b1; color: #7a1f2b;
}
.hw-obj-feedback[hidden] { display: none; }
.hw-obj-feedback.correct { background: #dcfce7; border-color: #86e0ab; }
.hw-obj-feedback p { margin: 0; color: #000; }

.hw-media { margin-bottom: 16px; }

/* Fixed height, proportionate width, excess clipped — same box for a lone image or a gallery
   slide, so every question's picture reads at a consistent size regardless of its own shape. */
.hw-img-slide {
  height: 260px; overflow: hidden; border-radius: 12px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center; background: #fff; position: relative;
}
.hw-img-slide[hidden] { display: none; }
.hw-img { height: 100%; width: auto; max-width: none; display: block; cursor: zoom-in; }
.hw-img[hidden] { display: none; }
.hw-media-loading {
  margin: 0; padding: 0 16px; text-align: center; color: var(--muted);
}

.hw-gallery { position: relative; margin-bottom: 10px; }
.hw-gallery .hw-img-slide { margin-bottom: 0; }
.hw-gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0;
  background: rgba(207, 255, 220, .9); color: var(--brand-dark); font-size: 1.3rem; line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.hw-gallery-nav:active { background: var(--bg); }
.hw-gallery-nav.prev { left: 10px; }
.hw-gallery-nav.next { right: 10px; }

/* Image lightbox: pinch/drag/double-tap zoom scoped to the popup only (js/homework.js) —
   the page itself has native zoom disabled (see the viewport meta), so it stays put. */
.hw-lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center;
}
.hw-lightbox[hidden] { display: none; }
.hw-lightbox-stage {
  width: 100%; height: 100%; overflow: hidden; touch-action: none;
  display: flex; align-items: center; justify-content: center;
}
.hw-lightbox-img {
  max-width: 100%; max-height: 100%; touch-action: none; -webkit-user-select: none; user-select: none;
  cursor: zoom-in;
}
.hw-lightbox-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .18); color: #fff; font-size: 1.2rem;
}

/* Celebration after every question — right or wrong, effort gets encouraged. Confetti burst +
   pop-in card, everything drawn in CSS so there's no image/audio asset to ship. */
.hw-cheer {
  position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, .35);
  display: flex; align-items: center; justify-content: center;
}
.hw-cheer[hidden] { display: none; }
.hw-cheer-card {
  position: relative; z-index: 1; background: #fff; border-radius: 20px; padding: 28px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  animation: hw-cheer-pop .45s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes hw-cheer-pop {
  0% { transform: scale(.4); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.hw-cheer-icon { font-size: 3rem; line-height: 1; animation: hw-cheer-bounce .6s ease .2s 1; }
@keyframes hw-cheer-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.hw-cheer-msg { font-size: 1.3rem; font-weight: 800; color: var(--brand-dark); }

.hw-cheer-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hw-cheer-shockwave {
  position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; border: 4px solid rgba(255, 255, 255, .9);
  animation: hw-shockwave .5s ease-out forwards;
}
@keyframes hw-shockwave {
  0% { transform: scale(0); opacity: .9; }
  100% { transform: scale(9); opacity: 0; }
}
.hw-confetti {
  position: absolute; top: 50%; left: 50%; border-radius: 2px;
  /* fast start, easing out — a real explosion, not a slow drift */
  animation-name: hw-confetti-burst;
  animation-timing-function: cubic-bezier(.15, .75, .35, 1);
  animation-fill-mode: forwards;
}
.hw-confetti.round { border-radius: 50%; }
@keyframes hw-confetti-burst {
  0% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.3); opacity: 0; }
}

.hw-video { width: 100%; aspect-ratio: 16/9; border-radius: 12px; border: 0; display: block; }
.hw-media-fallback {
  margin: 0; padding: 40px 16px; text-align: center; color: var(--muted);
  background: var(--bg); border-radius: 12px; border: 2px dashed var(--line);
}

/* Tap-to-record bar: small toggle button + wave, left-aligned, sitting outside the scrolling
   body so it's always reachable, right above the Reset/Done/Next row. */
.hw-record-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line);
}
.hw-record-bar[hidden] { display: none; }
.hw-record-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; font-size: 1.15rem; line-height: 1;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.hw-record-btn.recording { background: var(--rec); }
.hw-record-btn:disabled { background: #b8bbd6; }
.hw-wave { display: flex; align-items: center; gap: 3px; height: 24px; }
.hw-wave span {
  width: 3px; height: 6px; border-radius: 2px; background: var(--line); transition: background .2s;
}
.hw-record-bar.recording .hw-wave span {
  background: var(--rec); animation: hw-wave-bounce .9s ease-in-out infinite;
}
.hw-record-bar.recording .hw-wave span:nth-child(1) { animation-delay: 0s; }
.hw-record-bar.recording .hw-wave span:nth-child(2) { animation-delay: .1s; }
.hw-record-bar.recording .hw-wave span:nth-child(3) { animation-delay: .2s; }
.hw-record-bar.recording .hw-wave span:nth-child(4) { animation-delay: .1s; }
.hw-record-bar.recording .hw-wave span:nth-child(5) { animation-delay: 0s; }
@keyframes hw-wave-bounce { 0%, 100% { height: 6px; } 50% { height: 22px; } }
/* AI Processed recording: the bars follow the live loudness (heights set from voicerec's level) instead of bouncing on their own */
.hw-record-bar.recording.live .hw-wave span { animation: none; transition: height .09s linear; min-height: 4px; }
.hw-record-hint { color: var(--muted); font-size: .85rem; }

.hw-runner-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.hw-runner-nav .btn { flex: 1; }
.hw-runner-nav .hw-reset-btn { flex: none; padding: 10px 18px; font-size: .95rem; }
.hw-runner-nav .hw-reset-btn[hidden] { display: none; }
#hw-answer-text[readonly] { background: var(--bg); cursor: default; }
.hw-explain label { font-size: 1.15rem; font-weight: 800; }
#hw-answer-text { font-size: 1.2rem; line-height: 1.5; }

/* Error modal popup */
.alert-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, .5); }
.alert-overlay[hidden] { display: none; }
.alert-box { background: var(--card); border-radius: 16px; padding: 22px 20px 18px; max-width: 340px; width: 100%; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); animation: alert-pop .18s ease-out; }
.alert-icon { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%; background: var(--rec); color: #fff; font-size: 1.6rem; font-weight: 700; line-height: 44px; }
.alert-msg { margin: 0 0 16px; font-size: 1.05rem; font-weight: 600; white-space: pre-line; }
.alert-ok { min-width: 110px; padding: 10px 24px; border: 0; border-radius: 10px; background: var(--rec); color: #fff; font-size: 1rem; font-weight: 600; }
@keyframes alert-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Story / paragraph: long text in its own scrollable box, questions follow below it */
.hw-story { }
.hw-story-body { border: 2px solid #f0b429; border-radius: 14px; background: #fff; position: relative; max-height: 42vh; overflow-y: auto; padding: 12px 14px; font-size: 1.35rem; line-height: 1.7; white-space: pre-line; -webkit-overflow-scrolling: touch; }
.hw-story-body strong { color: var(--brand-dark); font-weight: 800; }
/* stronger highlight inside the story so the phrase being read stands out: grey + underline */
.hw-story-body .hw-seg.seg-active {
  color: #6b7280; text-decoration: underline; text-decoration-color: var(--brand);
  text-decoration-thickness: 3px; text-underline-offset: 6px; text-decoration-skip-ink: none;
}
.hw-story-body .hw-word.word-active { color: #6b7280; font-weight: 800; }
.hw-title-row { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; }
.hw-title-row .hw-qtitle { margin: 0; flex: 1; }

/* ---- Homework list (today + previous days) ---- */
.hw-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.hw-list.locked { opacity: .55; }
.hw-list-loading { color: var(--muted); text-align: center; padding: 16px 0; }
.hw-item {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; font: inherit;
  padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink);
}
.hw-item.scored { background-image: linear-gradient(90deg, #bbf7d0 var(--score), transparent var(--score)); }
.hw-item:active { border-color: var(--brand); }
.hw-item:disabled { opacity: .6; }
.hw-item-day { flex: none; width: 88px; font-weight: 700; display: flex; flex-direction: column; }
.hw-item-day small { font-weight: 500; color: var(--muted); font-size: .8rem; }
.hw-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hw-item-main span { color: var(--muted); font-size: .9rem; }
.hw-item-status { flex: none; font-size: .8rem; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: #fff; color: var(--muted); }
.hw-item-status.done { background: #dcfce7; color: #15803d; font-size: 1rem; padding: 4px 10px; }
.hw-item-status.progress { background: #fef3c7; color: #92400e; }

/* ---- App home: two big tiles ---- */
.app-home[hidden] { display: none; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.tile {
  font: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 170px; padding: 16px 8px; border-radius: 18px; border: 2px solid var(--line);
  background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(40, 40, 100, .08);
}
.tile:active { border-color: var(--brand); }
.tile-icon { font-size: 3rem; line-height: 1; }
.tile-label { font-size: 1.1rem; font-weight: 800; text-align: center; }
.hw-back { font: inherit; font-weight: 700; padding: 6px 12px; margin: 0 0 8px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--brand-dark); }

/* ---- font icons (feather / themify) ---- */
i[class^="icon-"], i[class^="ti-"] { font-style: normal; line-height: 1; vertical-align: -.1em; }
.btn i, .hw-back i { margin-right: 6px; }
.hw-runner-nav .btn:has(.icon-arrow-right) i { margin: 0 0 0 6px; }
.settings-btn, .hw-exit, .hw-speak-btn, .hw-record-btn, .hw-gallery-nav, .hw-lightbox-close { display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.settings-btn i { font-size: 1.35rem; color: var(--brand-dark); }
.hw-exit i, .hw-lightbox-close i { font-size: 1.2rem; }
.hw-speak-btn i, .hw-record-btn i, .hw-gallery-nav i { font-size: 1.2rem; }
.hw-item-status i { margin-right: 4px; }
.settings-box h2 i { color: var(--brand-dark); }
.tile-icon { color: var(--brand-dark); }

/* ---- "Opening your homework…" loading overlay ---- */
.hw-loading { position: fixed; inset: 0; z-index: 300; background: rgba(255, 255, 255, .8); display: flex; align-items: center; justify-content: center; }
.hw-loading[hidden] { display: none; }
.hw-loading-box { background: var(--card); border-radius: 18px; padding: 24px 30px; text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); }
.hw-loading-box p { margin: 14px 0 0; font-weight: 800; }
.hw-loading-ring { width: 44px; height: 44px; margin: 0 auto; border: 5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: hw-spin .8s linear infinite; }

.sfx-row { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-weight: 600; }
.sfx-row input { width: 22px; height: 22px; }
.sfx-row small { color: var(--muted); font-weight: 500; }

/* YouTube question: wrapper goes full screen, with our own Minimize button on top */
.hw-video-wrap { position: relative; }
.hw-video-wrap .hw-video { width: 100%; }
.hw-video-exit {
  display: none; position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 5;
  align-items: center; gap: 6px; font: inherit; font-weight: 800; padding: 10px 14px; border-radius: 999px;
  border: 0; background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
.hw-video-wrap:fullscreen { background: #000; display: flex; align-items: center; justify-content: center; }
.hw-video-wrap:fullscreen .hw-video { height: 100%; aspect-ratio: auto; border-radius: 0; }
.hw-video-wrap:fullscreen .hw-video-exit { display: inline-flex; }
.hw-video-wrap:-webkit-full-screen { background: #000; display: flex; align-items: center; justify-content: center; }
.hw-video-wrap:-webkit-full-screen .hw-video { height: 100%; aspect-ratio: auto; border-radius: 0; }
.hw-video-wrap:-webkit-full-screen .hw-video-exit { display: inline-flex; }

.ico-svg { width: 1em; height: 1em; display: inline-block; vertical-align: -.12em; }

/* icon-only round buttons: the icon sits dead centre, both ways */
.settings-btn i, .hw-exit i, .hw-speak-btn i, .hw-record-btn i, .hw-gallery-nav i, .hw-lightbox-close i { display: block; margin: 0; vertical-align: baseline; }
/* the icon font's glyphs sit a touch low in their box: nudge them up so they look centred */
.settings-btn i, .hw-exit i, .hw-speak-btn i, .hw-record-btn i, .hw-gallery-nav i, .hw-lightbox-close i, .tile-icon i, .hw-item-icon i { position: relative; top: -.057em; }

/* Settings: reading voice */
.settings-box { max-height: 90vh; overflow-y: auto; }
.voice-box { margin: 0 0 16px; }
.voice-box[hidden] { display: none; }
.voice-box select { margin-bottom: 8px; }
.voice-speed { display: block; margin: 6px 0 10px; font-weight: 600; }
.voice-note { margin: 8px 0 0; color: var(--muted); font-size: .85rem; }

/* ---- student login + header actions ---- */
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.top-actions [hidden] { display: none; }
.logged-out main, .logged-out .top-actions { visibility: hidden; }
.login-overlay { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.login-overlay[hidden] { display: none; }
.login-box { background: var(--card); width: 100%; max-width: 380px; border-radius: 20px; padding: 22px 18px; box-shadow: 0 6px 24px rgba(0,0,0,.12); text-align: center; }
.login-box h2 { margin: 6px 0 2px; }
.login-face { width: 84px; height: 84px; margin: 0 auto; }
.login-face svg { width: 100%; height: 100%; }
.login-sub { margin: 0 0 14px; color: var(--muted); }
.login-box label { display: block; text-align: left; font-weight: 700; margin: 10px 0 4px; }
.login-box input { width: 100%; font: inherit; font-size: 1.15rem; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.login-box input:focus { outline: 0; border-color: var(--brand-dark); }
.login-err { min-height: 1.4em; margin: 10px 0 4px; color: var(--rec); font-weight: 600; }
.login-go { width: 100%; }
.student-card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; margin-bottom: 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.student-card small { color: var(--muted); }
/* nothing is drawn until the session check finishes, so the dashboard never flashes before the login */
body.auth-checking { visibility: hidden; }

/* confirm popup (SclAlert.confirm) */
.alert-icon.confirm-icon { background: var(--brand-dark); }
.alert-actions { display: flex; gap: 10px; justify-content: center; }
.alert-actions .alert-ok { min-width: 0; flex: 1; background: var(--line); color: var(--ink); }
.alert-actions .alert-yes { background: var(--brand-dark); color: #fff; }

/* story phase: only the story shows while it is being read; afterwards it collapses above the questions */
.hw-story-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.hw-story-bar .story-toggle { flex: none; margin-left: auto; padding: 8px 12px; font-size: .95rem; }
.hw-story .story-start { display: none; width: 100%; margin-top: 12px; }
.hw-runner.story-reading .hw-story .story-start { display: block; }
.hw-runner.story-reading .hw-story-bar .story-toggle { display: none; }
.hw-story.collapsed .hw-story-body { max-height: 5.4rem; }
.hw-runner.story-reading .hw-qtext-row, .hw-runner.story-reading .hw-options, .hw-runner.story-reading .hw-explain,
.hw-runner.story-reading .hw-obj-feedback, .hw-runner.story-reading .hw-record-bar, .hw-runner.story-reading .hw-runner-nav,
.hw-runner.story-reading .hw-coach { display: none !important; }

/* ---- start-up splash ---- */
.splash {
  position: fixed; inset: 0; z-index: 2000; visibility: visible; /* shows even while the page waits for the session check */
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(circle at 50% 38%, #E9FFEF 0%, #CFFFDC 55%, #B5F5C8 100%);
  overflow: hidden; transition: opacity .4s ease;
}
.splash.leaving { opacity: 0; }
.splash-face { width: 120px; height: 120px; animation: splash-hop 1s ease-in-out infinite; }
.splash-face svg { width: 100%; height: 100%; display: block; }
.splash-title {
  font-family: 'Chewy', 'Nunito', system-ui, sans-serif; font-weight: 400; font-size: clamp(3.2rem, 17vw, 5.2rem);
  line-height: 1.05; letter-spacing: 2px; display: flex; justify-content: center; white-space: nowrap; margin-top: 6px;
}
.splash-title span {
  display: inline-block; color: var(--c, #2E6F40);
  -webkit-text-stroke: 3px #1f3d2b; paint-order: stroke fill; text-shadow: 0 5px 0 rgba(31, 61, 43, .35);
  opacity: 0; transform: translateY(-40px) scale(.3) rotate(-18deg);
  animation: splash-pop .6s cubic-bezier(.34, 1.56, .64, 1) forwards, splash-wave 1.3s ease-in-out infinite;
  animation-delay: calc(var(--i) * .09s), calc(.9s + var(--i) * .09s);
}
.splash-title span.sp { width: .35em; }
.splash-title span:nth-child(4n+1) { --c: #2E6F40; }
.splash-title span:nth-child(4n+2) { --c: #FF7A59; }
.splash-title span:nth-child(4n+3) { --c: #FFC933; }
.splash-title span:nth-child(4n)   { --c: #2EC4B6; }
.splash-tag { margin: 12px 0 0; font-weight: 800; color: #2E6F40; letter-spacing: .5px; opacity: 0; animation: splash-fade .6s ease 1.2s forwards; }
.sp-star { position: absolute; width: 26px; height: 26px; background: #FFC933; opacity: 0; animation: splash-twinkle 1.6s ease-in-out infinite;
  clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }
.sp-star.s1 { top: 14%; left: 12%; animation-delay: .1s; }
.sp-star.s2 { top: 22%; right: 10%; width: 34px; height: 34px; animation-delay: .5s; }
.sp-star.s3 { bottom: 20%; left: 16%; width: 32px; height: 32px; animation-delay: .9s; }
.sp-star.s4 { bottom: 14%; right: 18%; animation-delay: .3s; }
.sp-star.s5 { top: 48%; left: 6%; width: 18px; height: 18px; animation-delay: 1.2s; }
@keyframes splash-pop { to { opacity: 1; transform: none; } }
@keyframes splash-wave { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-9px) rotate(3deg); } }
@keyframes splash-hop { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-14px) scale(1.04, .97); } }
@keyframes splash-fade { to { opacity: 1; } }
@keyframes splash-twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(25deg); } }
@media (prefers-reduced-motion: reduce) {
  .splash-title span { animation: splash-pop .01s forwards; animation-delay: 0s; }
  .splash-face, .sp-star { animation: none; }
  .sp-star { opacity: .7; }
}
.splash-sound { position: absolute; bottom: calc(28px + env(safe-area-inset-bottom)); margin: 0; padding: 8px 16px; border-radius: 999px; background: rgba(255, 255, 255, .85);
  color: #2E6F40; font-weight: 800; font-size: .95rem; animation: splash-fade .4s ease both, splash-nudge 1.2s ease-in-out .4s infinite; }
.splash-sound[hidden] { display: none; }
.splash-sound i { margin-right: 4px; }
@keyframes splash-nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

/* tapping a word in the story: highlight + meaning bubble */
.hw-story-body .hw-word { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.hw-story-body .hw-word.word-picked { background: #FFE58A; border-radius: 6px; box-shadow: 0 0 0 3px #FFE58A; color: var(--ink); }
.word-bubble {
  position: fixed; z-index: 120; width: min(300px, calc(100vw - 16px)); padding: 10px 12px 12px; border-radius: 14px;
  background: #fff; border: 3px solid var(--brand-dark); color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.word-bubble::before {
  content: ''; position: absolute; top: -10px; left: calc(var(--arrow, 24px) - 8px); width: 14px; height: 14px; background: #fff;
  border-left: 3px solid var(--brand-dark); border-top: 3px solid var(--brand-dark); transform: rotate(45deg);
}
.word-bubble.above::before { top: auto; bottom: -10px; transform: rotate(225deg); }
.wb-head { display: flex; align-items: center; gap: 8px; }
.wb-word { font-size: 1.25rem; color: var(--brand-dark); }
.wb-pos { flex: 1; color: var(--muted); font-style: italic; font-size: .9rem; }
.wb-speak, .wb-close { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); background: #fff; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: 1.05rem; }
.wb-speak i, .wb-close i { display: block; margin: 0; }
.wb-meaning { margin: 8px 0 0; font-size: 1.05rem; line-height: 1.4; }
.no-splash .splash { display: none; }
.hw-title-row[hidden] { display: none; }

/* "Press back again to exit" */
.nav-toast { position: fixed; left: 50%; bottom: calc(40px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 1100; padding: 10px 18px; border-radius: 999px;
  background: rgba(31, 35, 64, .92); color: #fff; font-weight: 700; font-size: .95rem; opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; }
.nav-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* "Install app" (js/install.js): a yellow box, inside the login page above Roll No and on the home page between the header and the tiles */
.install-btn[hidden] { display: none; }
.install-bar { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 10px 14px; border: 2px solid #2b2140; border-radius: 14px;
  background: linear-gradient(180deg, #ffd84a, #ffb400); color: #2b2140; box-shadow: 0 3px 0 rgba(43, 33, 64, .35); font: inherit; font-weight: 900; font-size: 1.1rem; cursor: pointer; }
.install-bar i { font-size: 2rem; flex: none; }
.install-text { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.25; }
.install-text b { font-size: 1.45rem; }
.install-text small { font-size: .92rem; font-weight: 800; color: #4a3500; }
#install-top { width: calc(100% - 32px); max-width: 608px; margin: 14px auto 0; }
.login-box .install-bar { margin: 14px 0 4px; }
body:has(#app-home[hidden]) #install-top { display: none; } /* home page only */

/* dashboard tiles stay locked until the microphone is on */
.tile.locked { opacity: .55; filter: grayscale(.7); cursor: not-allowed; }
.tile.locked:active { transform: none; border-color: var(--line); }
.app-home .perm { margin: 0 0 16px; }

/* question screen header: Back on the left, the stars badge (Fun look) at the right end */
.hw-runner-top .hw-exit { width: auto; height: 38px; padding: 0 14px 0 10px; border-radius: 999px; gap: 6px; font: inherit; font-weight: 800; font-size: 1rem; }
.hw-runner-top .hw-exit i { font-size: 1.15rem; }
.hw-runner-top .hw-score { margin-left: auto; }

/* long school name in the header may wrap onto two lines on narrow phones */
.top h1 { font-size: clamp(1.05rem, 5.2vw, 1.3rem); line-height: 1.15; }
.top-text { min-width: 0; }

/* splash title: two lines, "K. KAMARAJAR" over "School" */
.splash-title { flex-direction: column; align-items: center; font-size: clamp(2.3rem, 11.5vw, 3.8rem); line-height: 1.1; }
.splash-line { display: flex; justify-content: center; white-space: nowrap; }

/* Cartoon fox (Pip) switched off: add/remove class "no-mascot" on <html> (index.html) to hide/show every fox picture */
html.no-mascot .greet-face, html.no-mascot .coach-face, html.no-mascot .login-face, html.no-mascot .splash-face,
html.no-mascot .hw-loading-face, html.no-mascot .hw-result-face, html.no-mascot .hw-cheer-icon .fun-only { display: none !important; }
html.no-mascot[data-theme="fun"] .hw-cheer-icon { display: none; }
html.no-mascot .greet-say::before, html.no-mascot .coach-say::before { display: none !important; }
html.no-mascot .greet-say, html.no-mascot .coach-say { flex: 1; }
.settings-version { margin: 12px 0 0; text-align: center; font-size: .8rem; color: var(--muted); }
/* the Student label on the left, the app version on the right of the same line */
.settings-head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 8px; }
.settings-head-row .settings-label, .settings-head-row .settings-version { margin: 0; }
.settings-head-row .settings-version { text-align: right; }

/* reading sound toggle in the question header, just before the stars badge. It is a .hw-speak-btn, so it looks exactly
   like the other speaker buttons (white, dark border, coloured icon) in both looks. */
.hw-runner-top .hw-mute { margin-left: 0; width: 40px; height: 40px; }
.hw-runner-top .hw-mute i { display: block; margin: 0; }
.hw-runner-top .hw-exit { margin-right: auto; } /* Back stays left; the toggle and the stars badge stay right, even when the toggle is hidden */
.hw-runner-top .hw-score { margin-left: 0; }
/* muted: no speaker buttons anywhere in the question screen (the toggle itself and the story's Top button stay) */
.hw-runner.reading-muted .hw-speak-btn:not(.hw-story-top):not(.hw-mute), .hw-runner.reading-muted .wb-speak { display: none !important; }

/* Story layout: the box is as tall as the text (no scrollbar inside it; the page scrolls), and the Top / speaker /
   Show-story controls sit at the right end of the heading line. */
.hw-story-body { max-height: none; overflow: visible; }
.hw-story.collapsed .hw-story-body { max-height: 5.4rem; overflow: hidden; }
.hw-title-row .hw-story-bar { margin: 0; flex: none; align-self: center; }

/* story: the Show / Hide story button is off for now (the story is never minimised); words are not text-selectable
   so a double tap shows the meaning instead of selecting the word; extra room under a story question so the question
   can be scrolled up to the top of the screen. */
.story-toggle { display: none !important; }
.hw-story-body { -webkit-user-select: none; user-select: none; }
/* A spacer, not padding: padding sets a minimum height for the box and pushed the Reset / Done row off the screen. */
.hw-runner.has-story .hw-runner-body::after { content: ''; display: block; height: 100vh; }

/* The hint / encouragement bubble above each question is switched off: add/remove class "no-coach" on <html> (index.html) */
html.no-coach .hw-coach { display: none !important; }

/* Record button: one big centred button right under the question (not a bar at the bottom of the screen) */
.hw-record-bar { flex-direction: column; justify-content: center; gap: 8px; margin: 4px 0 18px; padding: 0; background: none; border: 0; }
.hw-record-bar .hw-record-btn { width: 96px; height: 96px; font-size: 2.6rem; }
.hw-record-bar .hw-record-btn i { font-size: 2.6rem; }
.hw-record-bar .hw-wave { height: 30px; }
.hw-record-bar .hw-record-hint { font-size: 1rem; font-weight: 700; }

/* The spoken-answer box is read-only (it is filled by the microphone), so it looks greyed out */
#hw-answer-text { background: #eceff1; color: #4b5560; border-color: #c5ccd3; cursor: default; }

/* While the student is recording a spoken answer: no speaker, Top or mute buttons, so nothing distracts or starts a reading */
.hw-runner.is-recording .hw-speak-btn, .hw-runner.is-recording .hw-story-bar, .hw-runner.is-recording .wb-speak { display: none !important; }

/* School logo (icons/logo.webp, a small 84x94 image, so it is never scaled up much) */
.splash-logo { display: block; height: 104px; width: auto; animation: splash-hop 1s ease-in-out infinite; }
.login-logo { display: block; height: 94px; width: auto; margin: 0 auto 4px; }
.top-logo { flex: none; height: 52px; width: auto; border-radius: 6px; background: #fff; padding: 2px; margin-right: 10px; }
.top { align-items: center; }
@media (prefers-reduced-motion: reduce) { .splash-logo { animation: none; } }
.top-text { flex: 1; }

/* homework list header: title on the left, Home button on the right, one row */
.hw-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.hw-head .hw-title { margin: 0; }
.hw-head .hw-back { margin: 0; flex: none; }

/* a new line typed in the admin shows as a new line (like <br>) in questions, titles, options and feedback text */
.hw-qtext, .hw-qtitle, .hw-opt, #hw-obj-feedback-text, .hw-explain-text, .hw-story-body { white-space: pre-line; }

/* The record button is a fixed band above the Reset / Done row (it does not scroll); the question and story above scroll */
.hw-record-bar { flex: none; margin: 0; padding: 8px 16px 6px; background: var(--card); border-top: 1px solid var(--line); gap: 4px; }
.hw-record-bar .hw-record-btn { width: 76px; height: 76px; font-size: 2.1rem; }
.hw-record-bar .hw-record-btn i { font-size: 2.1rem; }
.hw-record-bar .hw-wave { height: 18px; }
.hw-record-bar .hw-record-hint { font-size: .9rem; }
/* The Reset / Next row takes no space (and shows no empty band) until a button in it is showing, and it stays out of the
   way while a recording is running */
.hw-runner-nav:not(:has(> :not([hidden]))) { display: none; }
.hw-runner.is-recording .hw-runner-nav { display: none; }

/* Change PIN (settings sheet) */
.pin-box { margin: 0 0 16px; }
.pin-toggle { width: 100%; }
.pin-form { margin-top: 10px; }
.pin-form[hidden] { display: none; }
.pin-form label { display: block; margin: 8px 0 4px; font-weight: 700; font-size: .9rem; }
.pin-form input { width: 100%; }
.pin-msg { min-height: 1.2em; margin: 8px 0; font-size: .9rem; font-weight: 600; }
.pin-msg.ok { color: #15803d; }
.pin-msg.err { color: #c0243b; }
/* the settings sheet can be taller than a small screen once the PIN form is open: it scrolls inside */
.settings-box { max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; padding-left: 0; padding-right: 0; }
.settings-box h2 { flex: none; margin: 0; padding: 0 16px 12px; border-bottom: 1px solid var(--line); } /* Settings title stays at the top */
.settings-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; -webkit-overflow-scrolling: touch; } /* only this part scrolls */
.settings-foot { flex: none; padding: 10px 16px 0; border-top: 1px solid var(--line); } /* Done stays at the bottom */
.settings-foot .settings-version { margin: 8px 0 0; }
.pin-form input { padding: 11px 14px; font: inherit; font-size: 1.15rem; letter-spacing: .3em; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.pin-form input:focus { outline: none; border-color: var(--brand); }
.settings-foot .settings-close, .pin-form .btn.primary { width: 100%; }


/* login: password box with a show / hide eye */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-eye { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 1.35rem; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.pw-eye i { display: block; margin: 0; position: relative; }
.pw-eye.on { color: var(--brand-dark); }
.pw-eye.on i::after { content: ''; position: absolute; left: -2px; right: -2px; top: 50%; height: 2.5px; background: currentColor; border-radius: 2px; transform: rotate(-35deg); } /* slash = "hide" */

/* header: the previous sign-in, a little quieter than the class line */
.env-login { margin-top: 2px; font-size: .85rem; font-weight: 600; opacity: .9; }
.env-login[hidden] { display: none; }


/* A password box that is a plain text field shown as dots: Chrome's password manager (breach warnings, "save password?")
   only looks at type="password" fields. The eye adds .show to reveal the text. */
.pw-mask { -webkit-text-security: disc; text-security: disc; }
.pw-mask.show { -webkit-text-security: none; text-security: none; }

/* past its due date: cannot be attended */
.hw-item-status.overdue { background: #fee2e2; color: #b91c1c; }
.hw-item-status.submitted { background: #e0f2fe; color: #0369a1; }

/* the question's own text, above the picture / video */
.hw-media-text { margin: 0 0 12px; font-size: 1.25rem; line-height: 1.5; font-weight: 800; color: #000; white-space: pre-line; }
.hw-media-text strong { color: var(--brand-dark); }

/* video: thumbnail with a big Play button; the player only goes full screen when it is tapped */
.hw-video-wrap { border-radius: 12px; overflow: hidden; background: #111; }
.hw-video-thumb { background: #111 center / cover no-repeat; }
.hw-video-play {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: rgba(0, 0, 0, .28); color: #fff; cursor: pointer; font: inherit; font-weight: 800;
}
.hw-video-play-icon {
  width: 72px; height: 72px; border-radius: 50%; background: #fff; color: var(--brand-dark); font-size: 2rem;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); padding-left: 4px;
}
.hw-video-play-icon i { display: block; margin: 0; }
.hw-video-play-label { text-shadow: 0 1px 4px rgba(0, 0, 0, .7); }
.hw-video-wrap.playing .hw-video-play { display: none; }
.hw-video-wrap:fullscreen .hw-video-thumb, .hw-video-wrap:-webkit-full-screen .hw-video-thumb { display: none; }

/* picture still loading: a clear spinner + text in the box */
.hw-media-loading { font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.hw-media-loading .spinner { width: 22px; height: 22px; margin: 0; border-width: 3px; }

/* picture zoom inside its own box */
.hw-img-slide { touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.hw-img { cursor: default; transform-origin: 50% 50%; will-change: transform; -webkit-user-drag: none; user-select: none; touch-action: inherit; }
.hw-img-slide.zoomed { cursor: grab; }

/* the school's own logo is shown once it has loaded (js/auth.js adds brand-ready): the built-in one never flashes first */
.login-logo { visibility: hidden; }
body.brand-ready .login-logo { visibility: visible; }

/* Result page of a scored homework (opened from the list) */
.hw-res-head { margin-bottom: 16px; }
.hw-res-head h3 { margin: 0 0 2px; font-size: 1.3rem; line-height: 1.3; }
.hw-res-head small { color: var(--muted); font-weight: 600; }
.hw-res-totals { display: flex; gap: 10px; margin-top: 12px; }
.hw-res-total { flex: 1; text-align: center; padding: 10px 8px; border-radius: 12px; background: #dcfce7; color: #15803d; font-weight: 700; }
.hw-res-total b { display: block; font-size: 1.35rem; color: var(--ink); }
.hw-res-list { list-style: none; margin: 0; padding: 0 0 24px; display: flex; flex-direction: column; gap: 12px; }
.hw-res-q { padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); border-left-width: 6px; }
.hw-res-q.ok { border-left-color: #22c55e; }
.hw-res-q.part { border-left-color: #f59e0b; }
.hw-res-q.bad { border-left-color: #ef4444; }
.hw-res-qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.hw-res-mark { font-weight: 700; font-size: .9rem; color: var(--muted); }
.hw-res-qtext { margin: 0 0 8px; font-weight: 600; }
.hw-res-ans { margin: 0 0 6px; padding: 8px 10px; border-radius: 8px; background: #dcfce7; color: #14532d; white-space: pre-line; overflow-wrap: anywhere; }
.hw-res-ans.mine { background: #f1f5f9; color: var(--ink); margin-bottom: 0; }
.hw-res-ans small { display: block; font-size: .75rem; font-weight: 700; opacity: .7; text-transform: uppercase; letter-spacing: .03em; }
.hw-res-score { margin: 8px 2px 0; font-weight: 700; color: var(--muted); }
.hw-res-score b { color: var(--ink); }
.hw-res-q.ok .hw-res-score b { color: #15803d; }
.hw-res-q.bad .hw-res-score b { color: #b91c1c; }
.hw-res-opts { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hw-res-opts li { display: flex; gap: 8px; align-items: baseline; }
.hw-res-opt-key { flex: none; font-weight: 700; opacity: .7; min-width: 1.2em; }
.hw-res-ans > b, .hw-res-ans b { font-weight: 800; }
/* result page header: "eHomework" + date on the left, Back on the right */
.hw-result-page .hw-res-title { margin-right: auto; display: flex; flex-direction: column; line-height: 1.2; }
.hw-result-page .hw-res-title h3 { margin: 0; font-size: 1.25rem; color: #fff; }
.hw-result-page .hw-res-title small { font-weight: 600; opacity: .9; }
.hw-result-page .hw-runner-top .hw-exit { margin-right: 0; }
.hw-res-head { margin-bottom: 16px; }
.hw-res-totals { margin-top: 0; }

/* ---- Weekly Toppers ---- */
.tile-toppers { background: linear-gradient(160deg, #8b6bff, #6a45f0); color: #fff; border-color: #5a37d6; }
.tile-toppers .tile-icon { color: #f5b301; background: #fff; border-radius: 50%; width: 84px; height: 84px; display: inline-flex; align-items: center; justify-content: center; }
.tp-page[hidden] { display: none; }
.tp-week { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.tp-week-label { flex: 1; text-align: center; display: flex; flex-direction: column; line-height: 1.25; }
.tp-week-label b { font-size: 1.1rem; }
.tp-week-label small { color: var(--muted); font-weight: 700; min-height: 1.1em; }
.tp-nav { font: inherit; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: #fff; color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tp-nav i { font-size: 1.2rem; }
.tp-nav:disabled { opacity: .35; }
.tp-nav:active:not(:disabled) { border-color: var(--brand); }
.tp-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.tp-row { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); }
.tp-row.top1 { background: linear-gradient(90deg, #fff3bf, var(--card)); border-color: #f5b301; }
.tp-row.top2 { background: linear-gradient(90deg, #eceff4, var(--card)); border-color: #aab4c3; }
.tp-row.top3 { background: linear-gradient(90deg, #fde3cf, var(--card)); border-color: #d98a4e; }
.tp-row.me { box-shadow: 0 0 0 3px #7c5cfc, 0 6px 16px rgba(124, 92, 252, .35); animation: tp-shake 5s ease-in-out 1s infinite; } /* your own row: purple frame, shakes once every 5 seconds */
.tp-row.me:not(.top1):not(.top2):not(.top3) { background: #efe8ff; }
.tp-row.me { position: relative; isolation: isolate; }
.tp-award { flex: none; width: 72px; height: 72px; border-radius: 50%; background: #fff; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 2.7rem; line-height: 1; }
.tp-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
.tp-name { display: block; font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* the name has a whole row and never wraps */
.tp-sub { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tp-sub small { flex: 1; min-width: 0; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-pts { flex: none; white-space: nowrap; text-align: right; }
.tp-pts b { font-size: 1.15rem; }
.tp-pts b em { font-size: .8rem; font-style: normal; font-weight: 700; color: var(--muted); }
.tp-me { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: #efe9ff; text-align: center; font-size: 1.25rem; font-weight: 700; line-height: 1.3; }
.tp-me[hidden] { display: none; }

/* ---- Parents Feedback ---- */
.tile-feedback { background: linear-gradient(160deg, #ff7a8a, #ef4a63); color: #fff; border-color: #d83a54; }
.tile-feedback .tile-icon { color: #ef4a63; background: #fff; border-radius: 50%; width: 84px; height: 84px; display: inline-flex; align-items: center; justify-content: center; }
.fb-page[hidden] { display: none; }
.fb-form label { display: block; font-weight: 800; margin: 4px 0 8px; }
.fb-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink); resize: vertical; min-height: 120px; }
.fb-form textarea:focus, .fb-form select:focus { outline: none; border-color: var(--brand); }
.fb-form select { width: 100%; box-sizing: border-box; font: inherit; padding: 12px; margin-bottom: 12px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink); }
.fb-form [hidden] { display: none; }
.fb-item .fb-to { margin: 0 0 4px; font-weight: 800; color: var(--brand-dark); }
.fb-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.fb-foot small { color: var(--muted); font-weight: 700; }
.fb-sub { margin: 22px 0 8px; font-size: 1.05rem; }
.fb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.fb-item { padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); }
.fb-item p { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-item small { color: var(--muted); font-weight: 700; }
.fb-state.seen { color: #15803d; }
.fb-empty { color: var(--muted); text-align: center; padding: 12px 0; }

/* ---- Treasure chest popup (a finished eHomework opens with it, see js/chest.js) ---- */
.chest-overlay, .chest-overlay * { box-sizing: border-box; }
.chest-overlay { position: fixed; inset: 0; z-index: 250; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(30, 18, 60, .72); animation: chest-fade .3s ease both; }
@keyframes chest-fade { from { opacity: 0; } to { opacity: 1; } }
.chest-card { position: relative; width: min(340px, 100%); padding: 18px 16px 20px; border-radius: 28px; background: linear-gradient(180deg, #fff6d6, #ffe7a1); border: 4px solid #2b2140; box-shadow: 0 8px 0 rgba(43, 33, 64, .35); text-align: center; overflow: hidden; animation: chest-card-in .5s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes chest-card-in { from { transform: scale(.6) translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.chest-title { margin: 0 0 10px; font-size: 1.5rem; font-weight: 900; color: #7c5cfc; position: relative; z-index: 3; }
.chest-stage { position: relative; height: 320px; display: flex; align-items: flex-end; justify-content: center; }
.chest-rays { position: absolute; left: 50%; bottom: 40px; width: 420px; height: 420px; margin-left: -210px; border-radius: 50%; opacity: 0; transform: scale(.3) rotate(0);
  background: repeating-conic-gradient(from 0deg, rgba(255, 213, 74, .85) 0deg 10deg, rgba(255, 213, 74, 0) 10deg 24deg);
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 68%); mask-image: radial-gradient(circle, #000 18%, transparent 68%); pointer-events: none; }
.chest-glow { position: absolute; left: 50%; bottom: 62px; width: 220px; height: 220px; margin-left: -110px; border-radius: 50%; opacity: 0; transform: scale(.3);
  background: radial-gradient(circle, rgba(255, 244, 170, .95) 0%, rgba(255, 213, 74, .55) 40%, rgba(255, 213, 74, 0) 70%); pointer-events: none; }
.chest-btn { position: relative; z-index: 2; width: 220px; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; animation: chest-wiggle 1.1s ease-in-out 1; transform-origin: 50% 90%; }
.chest-btn:disabled { cursor: default; animation: none; }
.chest-svg { display: block; width: 100%; height: auto; overflow: visible; }
@keyframes chest-wiggle { 0%, 100% { transform: rotate(0) translateY(0); } 15% { transform: rotate(-6deg) translateY(-4px); } 30% { transform: rotate(6deg) translateY(-6px); } 45% { transform: rotate(-4deg); } 60% { transform: rotate(3deg); } 75% { transform: rotate(0); } }
.chest-lid { transform-box: fill-box; transform-origin: 8% 100%; }
.chest-mouth, .chest-gold { opacity: 0; }
.chest-stage.opened .chest-lid { animation: chest-lid-open .55s cubic-bezier(.3, 1.6, .5, 1) forwards; }
@keyframes chest-lid-open { 0% { transform: none; } 100% { transform: translate(-10px, -52px) rotate(-38deg); } }
.chest-stage.opened .chest-lock { animation: chest-lock-drop .45s ease-in forwards; }
@keyframes chest-lock-drop { 0% { transform: none; opacity: 1; } 100% { transform: translateY(30px) rotate(25deg); opacity: 0; } }
.chest-stage.opened .chest-mouth, .chest-stage.opened .chest-gold { opacity: 1; transition: opacity .25s .1s; }
.chest-stage.opened .chest-gold { animation: chest-gold 1.1s ease-in-out infinite alternate; }
@keyframes chest-gold { from { fill: #FFD54A; } to { fill: #FFF2A0; } }
.chest-stage.opened .chest-btn { animation: chest-hop .5s ease .05s 1; }
@keyframes chest-hop { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-14px) scale(1.06, .94); } 100% { transform: translateY(0) scale(1); } }
.chest-stage.opened .chest-rays { opacity: 1; animation: chest-rays-in .7s ease-out forwards, chest-spin 14s linear .7s infinite; }
@keyframes chest-rays-in { from { opacity: 0; transform: scale(.3) rotate(0); } to { opacity: 1; transform: scale(1) rotate(60deg); } }
@keyframes chest-spin { from { transform: scale(1) rotate(60deg); } to { transform: scale(1) rotate(420deg); } }
.chest-stage.opened .chest-glow { animation: chest-glow-in .6s ease-out forwards; }
@keyframes chest-glow-in { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
.chest-burst { position: absolute; left: 50%; bottom: 112px; width: 0; height: 0; z-index: 3; pointer-events: none; }
.chest-flyer { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; opacity: 0; animation: chest-fly 1.25s cubic-bezier(.2, .8, .3, 1) forwards; }
.chest-flyer.big { width: 44px; height: 44px; left: -22px; top: -22px; }
.chest-flyer svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 0 rgba(43, 33, 64, .35)); }
@keyframes chest-fly { 0% { opacity: 0; transform: translate(0, 0) scale(.2) rotate(0); } 15% { opacity: 1; } 55% { opacity: 1; transform: translate(var(--x), var(--y)) scale(1.1) rotate(var(--r)); } 100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 70px)) scale(.6) rotate(calc(var(--r) * 1.4)); } }
.chest-sparkle { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; background: #fff; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); opacity: 0; animation: chest-sparkle 1s ease-out forwards; }
@keyframes chest-sparkle { 0% { opacity: 0; transform: translate(0, 0) scale(.2); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(1.6) rotate(120deg); } }
.chest-count { position: absolute; left: 50%; top: 0; z-index: 4; display: flex; align-items: center; gap: 6px; padding: 4px 16px 4px 10px; border-radius: 999px; background: #fff; border: 3px solid #2b2140; box-shadow: 0 4px 0 rgba(43, 33, 64, .3); font-weight: 900; font-size: 2rem; color: #2b2140; opacity: 0; transform: translate(-50%, 40px) scale(.4); }
.chest-count-star { width: 36px; height: 36px; display: inline-block; }
.chest-count-star svg { display: block; width: 100%; height: 100%; }
.chest-stage.opened .chest-count { animation: chest-count-in .5s cubic-bezier(.34, 1.56, .64, 1) .55s forwards; }
@keyframes chest-count-in { to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.chest-stage.counted .chest-count { animation: chest-count-in .01s forwards, chest-count-pop .6s ease; }
@keyframes chest-count-pop { 0% { transform: translate(-50%, 0) scale(1); } 40% { transform: translate(-50%, -6px) scale(1.25); } 100% { transform: translate(-50%, 0) scale(1); } }
.chest-msg { margin: 6px 0 0; min-height: 1.6em; font-weight: 800; color: #6b5a8e; position: relative; z-index: 3; }
.chest-msg.big { font-size: 1.25rem; font-weight: 900; color: #7c5cfc; animation: none; }
.chest-done { margin-top: 12px; position: relative; z-index: 3; animation: chest-done-in .4s ease both; }
@keyframes chest-done-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.chest-done[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .chest-btn, .chest-msg, .chest-rays, .chest-stage.opened .chest-gold { animation: none !important; }
  .chest-stage.opened .chest-lid { animation: none; transform: translate(-10px, -52px) rotate(-38deg); }
  .chest-stage.opened .chest-count { animation: none; opacity: 1; transform: translate(-50%, 0); }
  .chest-stage.opened .chest-rays { opacity: 1; transform: scale(1); }
  .chest-stage.opened .chest-glow { animation: none; opacity: 1; transform: scale(1); }
}

/* today's homework: bigger, light purple; the status badge on the title line, the message on a full-width row under it (see renderList in js/homework.js) */
.hw-item.today { background-color: #efe8ff; border-color: #7c5cfc; padding-top: 18px; padding-bottom: 16px; flex-wrap: wrap; align-items: flex-start; }
.hw-item.today .hw-item-day { width: auto; flex: 1; min-width: 0; font-size: 1.5rem; line-height: 1.15; }
.hw-item.today .hw-item-day small { font-size: .85rem; margin-top: 2px; }
.hw-item-note { flex: 0 0 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding-top: 10px; border-top: 2px dashed rgba(124, 92, 252, .35); font-size: 1.2rem; font-weight: 800; line-height: 1.2; color: #5b3fd1; text-align: center; }
.hw-item-note-ico { font-size: 1.7rem; line-height: 1; }

/* ---- Slim header: every page except the home page ---- */
.top-mini { display: none; }
body:has(#app-home[hidden]) header.top { display: none; }
body:has(#app-home[hidden]) .top-mini { display: flex; }
.hw-head { display: none; } /* the page title and the Home button live in the slim header now (more room for the page) */
.top-mini .hw-res-title { margin: 0; flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.top-mini .hw-res-title h3 { margin: 0; font-size: 1.25rem; color: #fff; }
.hw-runner-top.top-mini .hw-exit { margin-left: auto; margin-right: 0; }
.top-mini .mini-stars { display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; font-size: .95rem; font-weight: 700; color: #fff; }
.top-mini .mini-stars[hidden] { display: none; }
.top-mini .mini-stars .js-star-icon { display: inline-flex; width: 1.2em; height: 1.2em; }
.top-mini .mini-stars .js-star-icon svg { width: 100%; height: 100%; display: block; }
.top-mini .mini-stars b { font-weight: 900; }

/* result page, objective questions: every option is a box; the student's answer is marked in the same list (green = right, red = wrong) */
.hw-res-boxes { list-style: none; margin: 8px 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hw-res-box { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 2px solid var(--line); background: #fff; color: var(--ink); }
.hw-res-box .hw-res-opt-key { flex: none; }
.hw-res-box-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.hw-res-box.right { background: #dcfce7; border-color: #22c55e; color: #14532d; font-weight: 800; }
.hw-res-box.wrong { background: #fee2e2; border-color: #ef4444; color: #7f1d1d; font-weight: 800; }
.hw-res-tag { flex: none; margin-left: auto; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.hw-res-none { margin: 0 0 6px; font-size: .9rem; font-weight: 700; color: var(--muted); }
/* today's homework once it is scored: no purple (it does not go with the green score bar) */
.hw-item.today.scored { background-color: var(--bg); border-color: var(--line); }

.tp-namerow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tp-namerow .tp-name { flex: 1; min-width: 0; }
.tp-you { flex: none; padding: 2px 10px; border-radius: 999px; background: #7c5cfc; color: #fff; font-size: .75rem; font-weight: 900; letter-spacing: .03em; text-transform: uppercase; }
@keyframes tp-shake { 0%, 14%, 100% { transform: translateX(0) rotate(0); } 2% { transform: translateX(-7px) rotate(-1.2deg); } 5% { transform: translateX(7px) rotate(1.2deg); } 8% { transform: translateX(-5px) rotate(-.8deg); } 11% { transform: translateX(4px) rotate(.6deg); } }
@media (prefers-reduced-motion: reduce) { .tp-row.me { animation: none; } }

/* party confetti behind your own row, bursting in time with its shake (same 5 s cycle) */
.tp-confetti { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: -1; pointer-events: none; }
.tp-confetti i { position: absolute; left: -4px; top: -6px; width: var(--w, 8px); height: calc(var(--w, 8px) * 1.5); background: var(--c); border-radius: 2px; opacity: 0;
  animation: tp-confetti 5s ease-out infinite; animation-delay: calc(1s + var(--d, 0s)); }
@keyframes tp-confetti {
  0% { opacity: 0; transform: translate(0, 0) rotate(0) scale(.3); }
  3% { opacity: 1; }
  22% { opacity: 1; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1); }
  42%, 100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 70px)) rotate(calc(var(--r) * 1.6)) scale(.8); }
}
@media (prefers-reduced-motion: reduce) { .tp-confetti { display: none; } }
.tp-me-line { display: block; margin-top: 8px; font-size: 1.05rem; font-weight: 800; color: #5b3fd1; }

.fb-label-note { font-weight: 600; font-size: .82rem; color: var(--muted); }
.fb-center { text-align: center; margin: 16px 0 6px; }
.fb-center[hidden], .fb-sub[hidden], .fb-list[hidden] { display: none; }

/* ---- Message to School: the chat ---- */
.tile { position: relative; }
.tile-badge { position: absolute; top: 8px; right: 8px; min-width: 26px; height: 26px; padding: 0 7px; box-sizing: border-box; border-radius: 999px; background: #ffd43b; color: #2b2140; border: 3px solid #2b2140; font-size: .95rem; font-weight: 900; line-height: 20px; text-align: center; text-shadow: none; animation: fb-badge-pop .5s cubic-bezier(.34, 1.56, .64, 1); }
.tile-badge[hidden] { display: none; }
@keyframes fb-badge-pop { from { transform: scale(.3); } to { transform: scale(1); } }
.fb-item[data-id] { cursor: pointer; }
.fb-item[data-id]:active { border-color: var(--brand); }
.fb-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.fb-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; background: #e6f6f4; color: var(--brand-dark); font-size: .8rem; font-weight: 800; }
.fb-chip.new { background: #ffd43b; color: #2b2140; }
.fb-thread[hidden], .fb-thread-to[hidden] { display: none; }
.fb-thread-to { margin: 0 0 10px; font-weight: 800; color: var(--brand-dark); }
.fb-chat { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 12px; }
.fb-bubble { max-width: 86%; padding: 9px 12px; border-radius: 16px; border: 2px solid var(--line); background: #fff; overflow-wrap: anywhere; }
.fb-bubble p { margin: 2px 0; white-space: pre-wrap; line-height: 1.35; }
.fb-bubble .fb-who { display: block; font-size: .78rem; font-weight: 900; color: var(--brand-dark); }
.fb-bubble small { display: block; margin-top: 2px; font-size: .72rem; font-weight: 700; color: var(--muted); }
.fb-bubble.me { align-self: flex-end; background: #c9f2ec; border-color: #7fd6cb; border-bottom-right-radius: 4px; }
.fb-bubble.them { align-self: flex-start; border-bottom-left-radius: 4px; }
.fb-bubble.me small { text-align: right; }
.fb-chat-empty { text-align: center; color: var(--muted); padding: 10px 0; }
.fb-reply { display: flex; align-items: flex-end; gap: 8px; position: sticky; bottom: 0; padding: 8px 0 4px; background: var(--card); }
.fb-reply textarea { flex: 1; min-width: 0; box-sizing: border-box; font: inherit; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink); resize: none; max-height: 140px; }
.fb-reply textarea:focus { outline: none; border-color: var(--brand); }
.fb-reply .btn { flex: none; width: 52px; height: 48px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.fb-reply .btn i { margin: 0; font-size: 1.2rem; }

/* "Your answer" as a recording (wings set to AI Processed): the player replaces the text box */
.hw-answer-audio { margin-top: 6px; }
.hw-answer-audio { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--card); border: 2px solid var(--line); border-radius: 18px; }
.hw-answer-audio[hidden] { display: none; }
.hw-answer-audio audio { display: none; }
.hw-player-btn { flex: none; width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; padding: 0; display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation; }
.hw-player-btn i, .hw-player-btn i:before { font-size: 2.4rem; line-height: 1; margin: 0; padding: 0; }
/* the icon font's glyphs sit low in their box; the play triangle also looks left-heavy, so it gets a nudge right */
.hw-player-btn i { transform: translateY(-.086em); }
.hw-player-btn i.icon-play { transform: translate(.03em, -.086em); }
.hw-player-btn i { display: flex; align-items: center; justify-content: center; width: 1em; height: 1em; position: static; top: 0; }
.hw-player-bar { flex: 1; height: 14px; border-radius: 7px; background: var(--line); overflow: hidden; min-width: 0; }
.hw-player-bar span { display: block; height: 100%; width: 0; background: var(--brand-dark); border-radius: 7px; transition: width .2s linear; }
.hw-player-bar span.unknown { opacity: .55; }
.hw-player-time { flex: none; min-width: 3.4em; text-align: right; font-size: 1.15rem; font-weight: 700; color: var(--muted); }
#hw-answer-text[hidden] { display: none; }

/* an announcement from the school in the Messages list: one-way, so it is not tappable */
.fb-item.fb-ann { background: #fff7e0; border-color: #f5c24b; }
.fb-item.fb-ann .fb-to { color: #8a5a00; }

/* Flash message for a new announcement (js/feedback.js): the card slides down from under the header over the tiles and back up again.
   The box clips it, so it seems to come out of the header; js sets `top` to the header's bottom edge. */
.ann-flash { position: fixed; left: 0; right: 0; z-index: 40; overflow: hidden; pointer-events: none; padding: 0 12px 10px; }
.ann-flash[hidden] { display: none; }
.ann-flash-card { pointer-events: auto; cursor: pointer; touch-action: none; user-select: none; transform: translateY(-115%); transition: transform .45s ease; background: #fff7e0; color: var(--ink);
  border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 18px 18px; padding: 10px 14px 12px; box-shadow: 0 6px 0 rgba(0, 0, 0, .18); }
.ann-flash.show .ann-flash-card { transform: translateY(0); }
.ann-flash-card p { margin: 0; overflow-wrap: anywhere; }
.ann-flash-title { font-weight: 800; color: #8a5a00; margin-bottom: 2px !important; }
.ann-flash-text { font-weight: 600; }

/* the mic while the recorder / recogniser is getting ready: it fades out and in until the red stop button can come */
.hw-record-btn.preparing { animation: rec-prep .75s ease-in-out infinite alternate; }
@keyframes rec-prep { from { opacity: 1; } to { opacity: .2; } }

/* result page: the Teacher's Answer of a spoken question with its speaker button on the right */
.hw-res-ans-say { display: flex; align-items: center; gap: 10px; }
.hw-res-ans-body { flex: 1; min-width: 0; }
.hw-res-say { width: 44px; height: 44px; background: #fff; }

/* ---- the three-dots menu in the home header (My Profile, Change Password, Settings | Logout) ---- */
.menu-wrap { position: relative; flex: none; }
.settings-btn svg { display: block; color: var(--brand-dark); }
.menu { position: absolute; right: 0; top: calc(100% + 10px); z-index: 60; min-width: 220px; padding: 6px; background: var(--card); color: var(--ink, #1f2547);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); }
.menu[hidden], .menu [hidden] { display: none; }
.menu button { display: flex; align-items: center; width: 100%; min-height: 48px; padding: 0 14px; border: 0; border-radius: 10px; background: none;
  color: inherit; font: inherit; font-size: 1.05rem; font-weight: 700; text-align: left; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { outline: none; background: var(--bg); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.menu #logout-btn { color: #c0243b; }

/* My Profile / Change Password pages */
.pf-page .student-card { margin-bottom: 12px; }
.pf-form label { display: block; margin: 8px 0 4px; font-weight: 700; font-size: .9rem; }
.pf-form input[type="email"], .pf-form input[type="tel"] { width: 100%; padding: 11px 14px; font: inherit; font-size: 1.05rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; letter-spacing: normal; }
.pf-form input:focus { outline: none; border-color: var(--brand); }
.pf-form .pw-mask { letter-spacing: .3em; }
.st-page .voice-try { width: 100%; }

/* The microphone popup of the eHomework page (js/homework.js): it cannot be dismissed until the microphone is on */
.mic-gate .alert-icon i { display: block; font-size: 1.5rem; line-height: 44px; }
.mic-gate-body { margin: 0 0 16px; font-weight: 600; line-height: 1.45; }
.mic-gate-body.blocked { text-align: left; }
.mic-gate-body ol { margin: 8px 0 0; padding-left: 20px; line-height: 1.5; }
.mic-gate .alert-actions { flex-direction: column-reverse; }
.mic-gate .alert-ok { flex: none; width: 100%; }

/* "Signing out…" popup (js/auth.js): centred over any page, above everything */
.signout-overlay { z-index: 1200; }
.signout-overlay .alert-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 28px; max-width: 260px; }
.signout-overlay .alert-msg { margin: 0; }

/* An earlier day's submitted homework: the same "submitted" line under the row, smaller and blue (today's row has its own bigger look) */
.hw-item.with-note { flex-wrap: wrap; }
.hw-item.with-note .hw-item-day { flex: 1; width: auto; min-width: 0; }
.hw-item.with-note .hw-item-note { padding-top: 8px; border-top-color: rgba(3, 105, 161, .3); font-size: 1rem; color: #0369a1; }
.hw-item.with-note .hw-item-note-ico { font-size: 1.3rem; }

/* "Change your password" notice on the home page (js/pwnotice.js): a bold amber card above the tiles - tap it to change the password; the dark "Later" side hides it for the day. */
.pw-notice { display: flex; align-items: stretch; margin: 0 0 14px; background: #ff8a1f; color: #1a1020; border: 3px solid #2a2140; border-radius: 18px; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); overflow: hidden; }
.pw-notice-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 12px 6px 12px 12px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pw-notice-ico { flex: none; display: flex; line-height: 0; }
.pw-notice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 1rem; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
.pw-notice-text b { font-weight: 900; font-size: 1.15rem; color: #1a1020; }
.pw-notice-later { flex: none; align-self: center; margin: 0 8px 0 0; padding: 10px 13px; background: #000; border: 2px solid #fff; border-radius: 12px; color: #fff; font: inherit; font-weight: 900; font-size: 1.05rem; box-shadow: 0 3px 0 rgba(0, 0, 0, .35); cursor: pointer; }
.pw-notice-main:focus-visible, .pw-notice-later:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }

.pw-case-note { margin:0 0 12px; padding:10px 12px; background:#fff3c4; color:#1a1020; border:2px solid #2a2140; border-radius:12px; font-size:1rem; font-weight:700; line-height:1.35 }

/* Forgot password (sign-in screen) */
.login-forgot { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--brand-dark); font: inherit; font-weight: 700; cursor: pointer; padding: 6px 8px; }
.login-err.ok { color: var(--brand-dark); }
#forgot-form[hidden], .login-forgot[hidden] { display: none; }

/* A teacher's preview of an eHomework (opened from the teacher app): a thin strip on top, with Close preview */
.preview-bar { position: fixed; top: 0; left: 0; right: 0; height: 32px; z-index: 1100; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 12px; background: #1f2547; color: #fff; font: 700 13px/1 system-ui, sans-serif; }
.preview-bar button { border: 1px solid #fff; background: transparent; color: #fff; border-radius: 999px; padding: 5px 12px; font: inherit; cursor: pointer; }
body.previewing { padding-top: 32px; }
body.previewing .hw-runner { top: 32px; }

/* "A new version is available" (js/update.js): shown on the home page only */
.update-bar[hidden] { display: none; }
.update-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 300; max-width: 440px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 2px solid #2b2140; border-radius: 14px; background: linear-gradient(180deg, #ffd84a, #ffb400); color: #2b2140; box-shadow: 0 4px 0 rgba(43, 33, 64, .35), 0 8px 22px rgba(0, 0, 0, .25); }
.update-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.update-text b { font-size: 1.05rem; }
.update-text small { font-size: .85rem; font-weight: 700; color: #4a3500; }
.update-go { flex: none; padding: 9px 16px; border: 2px solid #2b2140; border-radius: 10px; background: #2b2140; color: #fff; font: inherit; font-weight: 900; cursor: pointer; }
.update-later { flex: none; padding: 6px 4px; border: 0; background: none; color: #2b2140; font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; }
