:root {
  --blue: #2456a6;
  --blue-deep: #17376b;
  --sky: #dcecff;
  --yellow: #ffd95a;
  --coral: #f46f61;
  --mint: #73d2b2;
  --paper: #fffef9;
  --ink: #17213a;
  --muted: #68738a;
  --line: #d9e0eb;
  --shadow: 0 18px 50px rgba(23, 55, 107, 0.16);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--sky);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 9% 10%, rgba(255,255,255,.6) 0 3px, transparent 4px),
    radial-gradient(circle at 86% 22%, rgba(255,255,255,.5) 0 4px, transparent 5px),
    var(--sky);
  background-size: 42px 42px, 58px 58px, auto;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; }

.topbar {
  height: 76px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--blue);
  color: white;
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 21px; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--yellow); color: var(--blue-deep); transform: rotate(-4deg); }
.brand-mark::after { content: "✎"; font-size: 24px; }

.quiet-button, .back-button {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 10px;
}
.quiet-button:hover, .quiet-button:focus-visible { background: rgba(255,255,255,.12); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.role-chip { padding: 6px 10px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }

.welcome-grid {
  min-height: calc(100vh - 76px);
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(44px, 8vw, 96px) 24px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  align-items: center;
  gap: clamp(46px, 7vw, 100px);
}

.eyebrow { font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--blue); }
.hero h1 { margin: 14px 0 18px; max-width: 700px; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: clamp(47px, 7vw, 88px); line-height: .98; letter-spacing: -.055em; color: var(--blue-deep); }
.hero h1 span { position: relative; white-space: nowrap; }
.hero h1 span::after { content: ""; position: absolute; height: 13px; left: 2px; right: 0; bottom: 3px; background: var(--yellow); z-index: -1; transform: rotate(-1.5deg); border-radius: 9px; }
.hero-copy { max-width: 560px; margin: 0; color: #44516b; font-size: clamp(17px, 2vw, 20px); line-height: 1.6; }
.subject-pills { display: flex; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.subject-pills span { background: rgba(255,255,255,.68); border: 1px solid rgba(36,86,166,.15); padding: 9px 13px; border-radius: 999px; font-weight: 800; font-size: 13px; }

.paper-stack { position: relative; }
.paper-stack::before, .paper-stack::after { content: ""; position: absolute; inset: 18px 8px -10px 8px; background: #c3dcf9; border-radius: 24px; transform: rotate(3deg); z-index: -2; }
.paper-stack::after { inset: 10px 14px -4px 2px; background: #fff3b8; transform: rotate(-3deg); z-index: -1; }

.card { background: rgba(255,254,249,.98); border: 1px solid rgba(23,55,107,.1); border-radius: 24px; box-shadow: var(--shadow); }
.login-card { padding: clamp(25px, 5vw, 42px); }
.login-card h2 { margin: 8px 0 7px; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: 30px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 26px; color: var(--muted); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: #edf2f8; border-radius: 13px; margin-bottom: 25px; }
.tabs-three { grid-template-columns: 1fr 1fr .72fr; }
.tab { padding: 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 800; }
.tab.active { color: var(--blue-deep); background: white; box-shadow: 0 3px 10px rgba(23,55,107,.1); }
.admin-login { border-top: 5px solid var(--yellow); }

.form-grid { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
label { display: grid; gap: 7px; color: #3e4960; font-size: 13px; font-weight: 800; }
input, select { width: 100%; border: 1.5px solid var(--line); background: white; padding: 13px 14px; border-radius: 12px; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36,86,166,.1); }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 13px;
  padding: 13px 18px;
  font-weight: 900;
  transition: transform .16s ease, box-shadow .16s ease;
}
.primary-button { background: var(--blue); color: white; box-shadow: 0 6px 0 var(--blue-deep); }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--blue-deep); }
.primary-button:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--blue-deep); }
.primary-button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.secondary-button { color: var(--blue-deep); background: white; border: 1.5px solid #b9c9df; }
.form-grid .primary-button { margin-top: 6px; }
.form-error { min-height: 18px; margin: 0; color: #b5322d; font-size: 13px; font-weight: 700; }
.privacy-note { margin-top: 18px !important; font-size: 12px; line-height: 1.45; }

.dashboard { max-width: 1180px; margin: 0 auto; padding: 42px 24px 80px; }
.dashboard-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 32px; }
.dashboard-heading h1 { margin: 6px 0 0; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: clamp(36px, 5vw, 58px); letter-spacing: -.04em; color: var(--blue-deep); }
.date-chip { background: rgba(255,255,255,.7); padding: 11px 14px; border-radius: 12px; color: var(--blue-deep); font-size: 13px; font-weight: 800; }

.progress-strip { background: var(--blue-deep); color: white; border-radius: 20px; padding: 20px 23px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; margin-bottom: 28px; box-shadow: 0 12px 30px rgba(23,55,107,.18); }
.streak-badge { width: 50px; height: 50px; display: grid; place-items: center; background: var(--yellow); color: var(--blue-deep); border-radius: 15px; font-size: 25px; transform: rotate(-3deg); }
.progress-strip strong { display: block; font-size: 17px; }
.progress-strip p { margin: 3px 0 0; color: #c5d6f4; font-size: 13px; }
.level-tag { font: 800 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: 8px 11px; }

.subject-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.subject-card { position: relative; overflow: hidden; padding: 28px; min-height: 265px; display: flex; flex-direction: column; align-items: flex-start; }
.subject-card::after { position: absolute; right: -12px; bottom: -35px; font-family: Georgia, serif; font-size: 155px; line-height: 1; opacity: .1; transform: rotate(-8deg); }
.subject-card.maths::after { content: "7"; color: var(--blue); }
.subject-card.english::after { content: "Aa"; color: #9b312c; }
.subject-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; font-size: 24px; margin-bottom: 24px; }
.maths .subject-icon { background: #dbe8ff; }
.english .subject-icon { background: #ffe1dd; }
.subject-card h2 { margin: 0; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: 28px; }
.subject-card p { margin: 8px 0 24px; max-width: 360px; color: var(--muted); line-height: 1.5; }
.subject-card .primary-button { margin-top: auto; z-index: 1; }

.assignment-page { max-width: 1250px; margin: 0 auto; padding: 30px 24px 70px; }
.assignment-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.back-button { color: var(--blue-deep); padding-left: 0; }
.toolbar-actions { display: flex; align-items: end; gap: 11px; }
.difficulty-control { display: grid; gap: 4px; font-size: 11px; font-weight: 900; color: var(--blue-deep); text-transform: uppercase; letter-spacing: .08em; }
.difficulty-control select { min-width: 145px; padding: 9px 11px; background: rgba(255,255,255,.82); }

.assignment-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; align-items: start; }
.worksheet-wrap { position: relative; }
.worksheet-wrap::after { content: ""; position: absolute; inset: 13px -9px -10px 13px; background: #bfd5ef; border-radius: 7px; z-index: -1; transform: rotate(1.2deg); }
.worksheet { width: 100%; min-height: 960px; background: white; padding: clamp(28px, 5vw, 58px); box-shadow: var(--shadow); border-radius: 6px; }
.worksheet-header { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 3px solid var(--ink); }
.worksheet-kicker { font: 800 11px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); }
.worksheet h1 { margin: 6px 0 0; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: 34px; letter-spacing: -.03em; }
.worksheet-meta { text-align: right; font-size: 12px; line-height: 1.7; color: #455066; white-space: nowrap; }
.name-line { display: grid; grid-template-columns: 1fr 180px; gap: 28px; margin: 22px 0 28px; font-size: 13px; font-weight: 800; }
.blank-line { display: inline-block; width: 100%; border-bottom: 1px solid #7e8798; padding-bottom: 3px; font-weight: 500; }
.instructions { background: #f3f7fc; padding: 12px 15px; border-left: 4px solid var(--blue); margin-bottom: 27px; font-size: 13px; line-height: 1.5; }
.questions { display: grid; grid-template-columns: 1fr 1fr; gap: 23px 34px; counter-reset: question; }
.question { position: relative; min-height: 74px; padding-left: 29px; font-family: Georgia, serif; font-size: 17px; line-height: 1.55; break-inside: avoid; }
.question::before { counter-increment: question; content: counter(question) "."; position: absolute; left: 0; top: 0; font-family: "Avenir Next", sans-serif; font-size: 13px; font-weight: 900; color: var(--blue); }
.answer-space { display: block; min-height: 30px; margin-top: 8px; border-bottom: 1px dashed #a9afbb; }
.answer-space.tall { min-height: 61px; background: repeating-linear-gradient(to bottom, transparent 0 29px, #d8dce3 30px); border: 0; }
.worksheet-footer { margin-top: 40px; padding-top: 13px; border-top: 1px solid #cfd4dc; display: flex; justify-content: space-between; font-size: 10px; color: #6e7685; }
.answer-key { display: none; margin-top: 34px; border-top: 2px dashed #8f98a8; padding-top: 24px; break-before: page; }
.answer-key.visible { display: block; }
.answer-key h2 { font-size: 24px; margin: 0 0 16px; }
.answer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 20px; font-size: 13px; }

.assignment-sidebar { display: grid; gap: 16px; }
.info-card { padding: 20px; border-radius: 18px; background: rgba(255,255,255,.75); border: 1px solid rgba(36,86,166,.12); }
.info-card h3 { margin: 0 0 8px; font-size: 15px; }
.info-card p { margin: 0; font-size: 13px; color: #59657b; line-height: 1.5; }
.mini-progress { display: flex; gap: 5px; margin-top: 14px; }
.mini-progress span { height: 7px; flex: 1; border-radius: 99px; background: #ccd8e7; }
.mini-progress span.filled { background: var(--mint); }
.answer-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { width: 45px; height: 25px; border: 0; border-radius: 99px; background: #bdc8d6; padding: 3px; }
.switch::after { content: ""; display: block; width: 19px; height: 19px; border-radius: 50%; background: white; transition: transform .2s ease; }
.switch.on { background: var(--blue); }
.switch.on::after { transform: translateX(20px); }

.admin-page { max-width: 1180px; margin: 0 auto; padding: 42px 24px 80px; }
.admin-page .dashboard-heading { margin-bottom: 26px; }
.admin-page .dashboard-heading h1 { font-size: clamp(38px, 5vw, 56px); }
.admin-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 22px; align-items: start; }
.admin-card { min-width: 0; padding: 28px; border-radius: 20px; box-shadow: 0 12px 35px rgba(23,55,107,.11); }
.admin-card:nth-child(2) { grid-row: span 2; }
.compact-card { grid-column: 1; }
.section-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0 0 3px; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: 22px; letter-spacing: -.025em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.admin-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: #dbe8ff; color: var(--blue-deep); font-size: 20px; }
.admin-icon.coral { background: #ffe1dd; color: #9b312c; }
.admin-icon.mint { background: #d9f4eb; color: #176b53; }
.check-row { grid-template-columns: auto 1fr; align-items: start; padding: 14px; background: #f3f7fc; border-radius: 12px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--blue); }
.check-row strong, .check-row small { display: block; }
.check-row small { margin-top: 3px; color: var(--muted); font-weight: 500; line-height: 1.4; }
.learner-list { display: grid; gap: 10px; }
.learner-admin-form { display: grid; grid-template-columns: minmax(115px, 1.3fr) minmax(80px, .9fr) minmax(65px, .7fr) minmax(90px, 1fr) auto; gap: 9px; align-items: end; padding: 13px; background: #f6f8fb; border: 1px solid #e2e7ee; border-radius: 14px; }
.learner-admin-form label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.learner-admin-form input, .learner-admin-form select { padding: 9px 10px; font-size: 12px; }
.learner-admin-form .secondary-button { padding: 10px 13px; }
.learner-identity { display: flex; align-items: center; gap: 10px; align-self: center; }
.learner-identity > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--yellow); color: var(--blue-deep); font-weight: 900; }
.learner-identity strong, .learner-identity small { display: block; }
.learner-identity small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.empty-state { padding: 30px; text-align: center; color: var(--muted); background: #f6f8fb; border-radius: 14px; }

.toast { position: fixed; left: 50%; bottom: 25px; transform: translateX(-50%); background: var(--ink); color: white; padding: 12px 18px; border-radius: 11px; font-size: 13px; font-weight: 800; box-shadow: var(--shadow); animation: toast-in .25s ease; z-index: 10; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

@media (max-width: 850px) {
  .welcome-grid { grid-template-columns: 1fr; padding-top: 48px; }
  .hero h1 { max-width: 650px; }
  .paper-stack { max-width: 540px; width: 100%; }
  .assignment-layout { grid-template-columns: 1fr; }
  .assignment-sidebar { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-card:nth-child(2) { grid-row: auto; }
  .compact-card { grid-column: auto; }
  .learner-admin-form { grid-template-columns: 1fr 1fr; }
  .learner-identity { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .topbar { height: 66px; padding: 0 18px; }
  .welcome-grid { min-height: auto; padding: 36px 18px 60px; gap: 38px; }
  .hero h1 { font-size: 49px; }
  .dashboard, .assignment-page { padding-left: 16px; padding-right: 16px; }
  .dashboard-heading { align-items: start; flex-direction: column; gap: 14px; }
  .progress-strip { grid-template-columns: auto 1fr; }
  .level-tag { display: none; }
  .subject-grid { grid-template-columns: 1fr; }
  .assignment-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { flex-wrap: wrap; }
  .difficulty-control { flex: 1; }
  .questions { grid-template-columns: 1fr; }
  .worksheet { padding: 28px 22px; }
  .worksheet-header { flex-direction: column; }
  .worksheet-meta { text-align: left; }
  .name-line { grid-template-columns: 1fr; gap: 12px; }
  .assignment-sidebar { grid-template-columns: 1fr; }
  .tabs-three { grid-template-columns: 1fr; }
  .form-row, .inline-form { grid-template-columns: 1fr; }
  .admin-page { padding: 32px 16px 60px; }
  .admin-card { padding: 22px 18px; }
  .learner-admin-form { grid-template-columns: 1fr; }
  .learner-identity { grid-column: auto; }
}

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

@page { size: A4; margin: 12mm; }
@media print {
  body { background: white; }
  .topbar, .assignment-toolbar, .assignment-sidebar, .toast { display: none !important; }
  .assignment-page { max-width: none; margin: 0; padding: 0; }
  .assignment-layout { display: block; }
  .worksheet-wrap::after { display: none; }
  .worksheet { min-height: auto; padding: 0; box-shadow: none; border-radius: 0; }
  .question { font-size: 15px; }
  .questions { gap: 17px 28px; }
  .worksheet-header, .name-line, .instructions { break-inside: avoid; }
  .answer-key.visible { display: block; }
}
