:root {
  --ink: #172033;
  --muted: #667085;
  --paper: #ffffff;
  --wash: #f4f7fb;
  --line: #dce3ed;
  --blue: #2855d9;
  --blue-dark: #1f3fa3;
  --green: #13795b;
  --orange: #b54708;
  --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--wash); font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--blue); }
.shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { padding: 28px 20px; color: white; background: #111b35; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 30px; font-size: 19px; font-weight: 750; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(135deg, #6ea8ff, #9b8cff); }
.nav a { display: block; margin: 7px 0; padding: 11px 13px; border-radius: 12px; color: #dce6ff; text-decoration: none; }
.nav a:hover, .nav a.active { background: #23345e; color: white; }
.main { padding: 34px clamp(20px, 4vw, 58px) 70px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 28px; }
h1, h2, h3 { line-height: 1.15; }
h1 { margin: 0 0 7px; font-size: clamp(28px, 4vw, 42px); }
.muted { color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 8px 30px rgba(30, 47, 82, .05); }
.card h2, .card h3 { margin-top: 0; }
.stat { font-size: 34px; font-weight: 800; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #eaf0ff; color: var(--blue-dark); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.badge.green { background: #e8f7f1; color: var(--green); }
.badge.orange { background: #fff1e8; color: var(--orange); }
.button, button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 42px; padding: 9px 15px; border: 0; border-radius: 11px; color: white; background: var(--blue); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.button:hover, button:hover { background: var(--blue-dark); }
.button.secondary { color: var(--ink); background: #e8edf5; }
.button.danger { background: #b42318; }
.button.danger:hover { background: #8f1b13; }
.button.ghost { color: var(--blue); background: transparent; }
.stack > * + * { margin-top: 15px; }
label { display: block; margin-bottom: 6px; font-weight: 700; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: white; color: var(--ink); font: inherit; }
textarea { min-height: 140px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.full { grid-column: 1 / -1; }
.assignment { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 17px 0; border-bottom: 1px solid var(--line); }
.assignment:last-child { border-bottom: 0; }
.assignment h3 { margin: 5px 0; }
.flash { margin-bottom: 16px; padding: 13px 16px; border-radius: 12px; background: #e8f7f1; color: #075b43; }
.flash.error { background: #ffebee; color: #9b1c1c; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 10%, #dbeafe, transparent 35%), radial-gradient(circle at 90% 80%, #ede9fe, transparent 40%), #f8fafc; }
.login-card { width: min(460px, 100%); padding: 35px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 25px 70px rgba(30, 47, 82, .12); }
.login-card h1 { font-size: 32px; }
.quiz-option { display: flex; gap: 10px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 10px; }
.quiz-option input { width: auto; }
.challenge { --challenge: #5b57e8; --challenge-soft: #efefff; position: relative; padding: 22px; border-radius: 22px; background: linear-gradient(145deg, #f8f8ff, #fff); border: 1px solid #dedcff; overflow: hidden; }
.challenge[data-theme="play"] { --challenge: #e85d3f; --challenge-soft: #fff0e9; }
.challenge[data-theme="level-up"] { --challenge: #087f78; --challenge-soft: #e7f8f5; }
.challenge[data-theme="focus"] { --challenge: #3e4c86; --challenge-soft: #edf0fb; }
.challenge::before { content: ""; position: absolute; width: 170px; height: 170px; right: -70px; top: -80px; border-radius: 50%; background: var(--challenge-soft); }
.challenge-hud { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; margin-bottom: 26px; }
.challenge-kicker { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.progress-track { height: 10px; border-radius: 99px; background: #e5e7ef; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--challenge), #8d7eff); transition: width .35s ease; }
.score-pill { position: relative; padding: 10px 14px; border-radius: 99px; color: var(--challenge); background: var(--challenge-soft); font-weight: 800; white-space: nowrap; }
.challenge-question { min-width: 0; margin: 0; padding: 0; border: 0; }
.challenge-question legend { width: 100%; margin-bottom: 20px; font-size: clamp(21px, 3vw, 28px); font-weight: 800; line-height: 1.3; }
.question-number { display: inline-grid; place-items: center; width: 36px; height: 36px; margin-right: 12px; border-radius: 12px; color: white; background: var(--challenge); font-size: 16px; vertical-align: middle; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.challenge .quiz-option { position: relative; min-height: 62px; margin: 0; padding: 15px 17px; border: 2px solid #dfe3ec; border-radius: 15px; background: #fff; font-weight: 750; cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.challenge .quiz-option:hover { transform: translateY(-2px); border-color: var(--challenge); }
.challenge .quiz-option input { position: absolute; opacity: 0; pointer-events: none; }
.challenge .quiz-option.correct { border-color: #16a56f; background: #eafaf3; color: #08734d; }
.challenge .quiz-option.wrong { animation: nudge .25s ease; border-color: #dc4c64; background: #fff0f3; color: #9f2138; }
.challenge-feedback { display: grid; gap: 2px; min-height: 48px; margin-top: 16px; padding: 0; }
.challenge-feedback.success, .challenge-feedback.error { padding: 12px 14px; border-radius: 12px; }
.challenge-feedback.success { background: #eafaf3; color: #08734d; }
.challenge-feedback.error { background: #fff0f3; color: #9f2138; }
.challenge-feedback span { font-size: 14px; }
.challenge-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.challenge-actions button:not(.secondary) { background: var(--challenge); }
.challenge-actions button:disabled { opacity: .4; cursor: not-allowed; }
.hint-box { margin-top: 14px; padding: 13px 15px; border-left: 4px solid #f0aa24; border-radius: 8px; background: #fff8df; color: #744f05; }
.challenge-finish { position: relative; padding: 22px 10px 10px; text-align: center; }
.challenge-finish h2 { font-size: 30px; }
.finish-icon { font-size: 62px; animation: pop .45s ease; }
.parent-preview { padding-top: 10px; border-top: 1px solid var(--line); }
.parent-preview li { margin: 12px 0; padding-left: 5px; }
.preview-label { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; padding: 11px 14px; border-radius: 12px; background: #fff8df; color: #744f05; }
.preview-label span { font-size: 14px; }
.password-card { padding: 0; overflow: hidden; }
.password-card summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; cursor: pointer; list-style: none; }
.password-card summary::-webkit-details-marker { display: none; }
.password-card summary span:first-child { display: grid; }
.password-card summary small { color: var(--muted); font-weight: 500; }
.password-card[open] summary { border-bottom: 1px solid var(--line); }
.password-card form { padding: 20px 22px 22px; }
.share-card { display: grid; gap: 14px; margin-bottom: 20px; border-color: #bddfd2; background: linear-gradient(145deg, #f4fcf8, #fff); }
.share-card h2 { margin: 9px 0 5px; }
.share-card p { margin: 0; }
.share-card form { margin: 0; }
.share-link-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.share-link-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.assignment-management { display: grid; gap: 14px; margin-bottom: 20px; }
.assignment-management h2 { margin: 9px 0 5px; }
.assignment-management p, .assignment-management form { margin: 0; }
.language-switcher { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 20px; }
.language-switcher a { padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: white; font-weight: 700; text-decoration: none; }
.language-switcher a:hover, .language-switcher a.active { border-color: var(--blue); color: white; background: var(--blue); }
.studio-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.studio-intro h2 { margin: 9px 0 5px; }
.studio-intro p { margin: 0; }
.studio-help { position: sticky; top: 24px; }
.studio-help li + li { margin-top: 9px; }
.check-row { display: flex; align-items: flex-start; gap: 10px; font-weight: 650; }
.check-row input { width: auto; margin-top: 5px; }
.privacy-note { display: grid; gap: 2px; padding: 13px 15px; border-radius: 12px; background: #edf7ff; color: #284a68; }
.privacy-note span { font-size: 14px; }
.draft-preview { margin-top: 22px; }
.draft-questions li { margin: 14px 0; }
.answer-key { margin-top: 4px; color: var(--green); font-weight: 700; }
button:disabled { opacity: .5; cursor: not-allowed; }
.result-score { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding: 15px; border-radius: 14px; background: #edf7ff; }
.result-score > span { display: grid; place-items: center; min-width: 62px; height: 62px; border-radius: 50%; color: white; background: var(--blue); font-size: 20px; font-weight: 850; }
@keyframes nudge { 50% { transform: translateX(6px); } }
@keyframes pop { 0% { transform: scale(.6) rotate(-8deg); } 70% { transform: scale(1.12) rotate(4deg); } }
.handwriting-sheet { background: white; color: #222; }
.writing-practice { display: grid; gap: 22px; margin-top: 8px; }
.writing-practice-row { padding: 10px 16px 12px; border: 1px solid #d9e2ee; border-radius: 14px; background: repeating-linear-gradient(to bottom, transparent 0, transparent 39px, #c9d8ec 40px, transparent 41px, transparent 78px, #7fa3cf 79px, #7fa3cf 80px); }
.trace { min-height: 72px; font-family: "Noteworthy", "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive; font-size: 42px; font-weight: 500; line-height: 1.65; letter-spacing: 2px; color: transparent; -webkit-text-stroke: 1.15px #7d8797; text-shadow: 0 0 0 rgba(125,135,151,.15); }
.copy-line { height: 72px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 16px; }
  .brand { margin-bottom: 10px; }
  .nav { display: flex; gap: 5px; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .main { padding: 24px 16px 50px; }
  .topbar, .assignment { grid-template-columns: 1fr; display: grid; }
  .form-grid { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
  .studio-layout { grid-template-columns: 1fr; }
  .studio-help { position: static; }
  .challenge { padding: 17px; }
  .challenge-hud { grid-template-columns: 1fr; gap: 10px; }
  .share-link-row { grid-template-columns: 1fr; }
  .score-pill { justify-self: start; }
}
@media print {
  .sidebar, .topbar, .no-print, .flash { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { border: 0; box-shadow: none; }
}

