:root {
  --navy: #0b2d4d;
  --blue: #146ca4;
  --sky: #e9f5fb;
  --teal: #178477;
  --gold: #f1b849;
  --ink: #1d2b36;
  --muted: #61717e;
  --line: #d7e1e7;
  --ok: #157347;
  --bad: #b42318;
  --white: #fff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: #f5f8fa; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.55; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; color: var(--white); background: rgba(11,45,77,.97); box-shadow: 0 3px 14px rgba(12,35,53,.18); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; }
.brand img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: white; }
.back { min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 12px; text-decoration: none; }

.hero { padding: 44px 18px 34px; color: var(--white); text-align: center; background: radial-gradient(circle at 80% 0%, #2391be 0, transparent 34%), linear-gradient(135deg, var(--navy), #124e76); }
.eyebrow { margin: 0 0 8px; color: #1773aa; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; }
.hero .eyebrow { color: #bfe8fa; }
.hero h1 { margin: 0 auto 10px; max-width: 780px; font-size: clamp(2rem, 8vw, 3.6rem); line-height: 1.08; }
.hero p { max-width: 680px; margin: 0 auto; font-size: 1.05rem; color: #e7f5fc; }

.wrap { width: min(100% - 28px, 880px); margin: 0 auto; }
.landing { padding: 30px 0 52px; }
.cards { display: grid; gap: 18px; }
.level-card, .panel, .question, .result, .student-card, .admin-card, .login-card { background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 28px rgba(18,54,78,.07); }
.level-card { padding: 24px; text-decoration: none; display: block; transition: transform .18s ease, box-shadow .18s ease; }
.level-card:active { transform: scale(.99); }
.level-badge { display: inline-flex; min-width: 48px; height: 48px; align-items: center; justify-content: center; border-radius: 14px; color: white; background: var(--blue); font-weight: 900; font-size: 1.2rem; }
.level-card.a2 .level-badge { background: var(--teal); }
.level-card h2 { margin: 14px 0 6px; font-size: 1.45rem; }
.level-card p { margin: 0 0 18px; color: var(--muted); }
.start-link { font-weight: 800; color: var(--blue); }
.admin-entry { margin-top: 24px; text-align: center; }
.admin-entry a { color: var(--blue); font-weight: 800; }

.quiz-shell { padding: 22px 0 60px; }
.panel { padding: 20px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 8px; color: var(--navy); }
.panel p { margin: 6px 0; }
.notice { border-left: 5px solid var(--gold); background: #fff9ec; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { border-radius: 999px; padding: 7px 11px; color: var(--navy); background: var(--sky); font-weight: 700; font-size: .9rem; }

.student-card { padding: 22px; margin: 18px 0; border-top: 5px solid var(--blue); }
.student-card h2 { margin: 0 0 4px; color: var(--navy); }
.student-card p { margin: 4px 0 14px; color: var(--muted); }
.student-grid { display: grid; gap: 14px; }
.student-grid label, .login-card label { display: grid; gap: 6px; color: var(--navy); font-weight: 800; }
.student-grid input, .login-card input, .admin-toolbar select { width: 100%; min-height: 50px; padding: 10px 12px; border: 1px solid #bfcdd5; border-radius: 12px; background: white; color: var(--ink); }
.student-grid input:focus, .login-card input:focus, .admin-toolbar select:focus { outline: 3px solid rgba(20,108,164,.18); border-color: var(--blue); }
.privacy-note { margin-bottom: 0 !important; font-size: .86rem; }

.progress-wrap { position: sticky; top: 59px; z-index: 8; padding: 10px 0; background: #f5f8fa; }
.progress-label { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .88rem; margin-bottom: 5px; }
.progress { height: 9px; overflow: hidden; border-radius: 999px; background: #dbe8ee; }
.progress > span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--blue), #30a6ca); transition: width .25s ease; }

.reading { padding: 20px; margin: 18px 0; border-radius: 18px; background: #eef7fb; border: 1px solid #bcddeb; }
.reading h2, .audio-box h2 { margin-top: 0; color: var(--navy); }
.reading p:last-child { margin-bottom: 0; }
.audio-box { padding: 20px; margin: 18px 0; border-radius: 18px; color: var(--white); background: linear-gradient(135deg, var(--navy), #176d8f); }
.audio-box p { color: #dbf1fa; }
audio { width: 100%; margin-top: 10px; }

.question { padding: 20px; margin: 14px 0; }
.question.correct { border-color: #70c89f; background: #f0fbf5; }
.question.wrong { border-color: #ef9b94; background: #fff5f4; }
.q-number { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin-right: 8px; border-radius: 10px; color: white; background: var(--navy); font-weight: 900; vertical-align: middle; }
.question h3 { display: inline; font-size: 1.03rem; }
.options { display: grid; gap: 9px; margin-top: 16px; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option label { display: flex; gap: 10px; align-items: flex-start; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: white; cursor: pointer; }
.option label::before { content: ""; width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; border: 2px solid #78909c; border-radius: 50%; }
.option input:checked + label { border-color: var(--blue); background: var(--sky); }
.option input:checked + label::before { border: 6px solid var(--blue); }
.feedback { display: none; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 700; }
.correct .feedback, .wrong .feedback { display: block; }
.correct .feedback { color: var(--ok); }
.wrong .feedback { color: var(--bad); }
.short-answer { width: 100%; min-height: 48px; margin-top: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; }
textarea.short-answer { min-height: 130px; resize: vertical; }

.actions { display: grid; gap: 10px; margin: 24px 0; }
.btn { min-height: 52px; border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 900; cursor: pointer; }
.btn:disabled { cursor: wait; opacity: .65; }
.btn-primary { color: white; background: var(--blue); box-shadow: 0 8px 18px rgba(20,108,164,.24); }
.btn-secondary { color: var(--navy); background: white; border: 1px solid var(--line); }
.result { display: none; padding: 24px; text-align: center; margin-top: 20px; }
.result.show { display: block; }
.score { display: block; color: var(--navy); font-size: 3rem; line-height: 1; font-weight: 950; margin: 8px 0 12px; }
.result h2 { margin: 0; }
.result p { color: var(--muted); }

.admin-shell { padding: 26px 0 60px; }
.login-card { max-width: 520px; margin: 0 auto; padding: 24px; }
.login-card h2 { margin-top: 0; color: var(--navy); }
.login-card form { display: grid; gap: 16px; }
.form-message { min-height: 24px; margin: 0; color: var(--bad); font-weight: 700; }
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.admin-head h2 { margin: 0; }
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.admin-toolbar select { width: auto; min-width: 160px; }
.admin-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.summary-box { padding: 16px; border-radius: 14px; background: white; border: 1px solid var(--line); }
.summary-box span { display: block; color: var(--muted); font-size: .88rem; }
.summary-box strong { display: block; margin-top: 4px; color: var(--navy); font-size: 1.6rem; }
.results-list { display: grid; gap: 14px; }
.admin-card { padding: 20px; }
.result-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.result-card-head h3 { margin: 0; color: var(--navy); }
.result-card-head p { margin: 3px 0 0; color: var(--muted); }
.score-pill { flex: 0 0 auto; padding: 8px 12px; border-radius: 999px; color: white; background: var(--blue); font-weight: 900; }
.result-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 14px 0; color: var(--muted); font-size: .9rem; }
.error-details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.error-details summary { cursor: pointer; color: var(--blue); font-weight: 800; }
.error-item { margin-top: 10px; padding: 12px; border-radius: 12px; background: #fff5f4; border-left: 4px solid var(--bad); }
.error-item p { margin: 3px 0; }
.writing-box { margin-top: 12px; padding: 12px; border-radius: 12px; background: #f3f7f9; white-space: pre-wrap; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); background: white; border: 1px dashed #b9c9d2; border-radius: 16px; }

footer { padding: 24px 16px 38px; text-align: center; color: var(--muted); font-size: .88rem; }
[hidden] { display: none !important; }

@media (min-width: 720px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .actions { grid-template-columns: 1fr 1fr; }
  .student-grid { grid-template-columns: 1fr 1fr; }
  .student-email { grid-column: 1 / -1; }
  .admin-summary { grid-template-columns: repeat(4, 1fr); }
  .topbar { padding-inline: 24px; }
  .question, .panel, .reading, .audio-box { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
