:root {
  --navy: #17324d;
  --navy-2: #214966;
  --blue: #2f80ed;
  --blue-soft: #eaf3ff;
  --teal: #18a999;
  --green: #208b5a;
  --green-soft: #eaf8f1;
  --orange: #e89b2c;
  --orange-soft: #fff5df;
  --red: #d9534f;
  --red-soft: #fff0ef;
  --purple: #7657c7;
  --purple-soft: #f2efff;
  --ink: #1e2a36;
  --muted: #657382;
  --line: #dce4eb;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --bg: #eef3f7;
  --shadow: 0 12px 30px rgba(23, 50, 77, .08);
  --radius: 18px;
  --radius-sm: 12px;
  --focus: 0 0 0 4px rgba(47, 128, 237, .20);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }

button {
  cursor: pointer;
  border: 0;
}

button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.hidden { display: none !important; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--navy);
  text-align: left;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--navy);
  color: white;
  font-weight: 900;
}

.brand-button strong { display: block; font-size: 16px; letter-spacing: .3px; }
.brand-button strong span { color: var(--blue); }
.brand-button small { display: block; color: var(--muted); font-size: 10px; }

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link, .mobile-menu button {
  padding: 9px 13px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.nav-link:hover, .mobile-menu button:hover { background: var(--surface-2); color: var(--navy); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.student-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
}

.icon-button {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--navy);
  font-size: 20px;
}

.mobile-menu {
  position: fixed;
  right: 16px;
  top: 68px;
  z-index: 60;
  width: min(230px, calc(100% - 32px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  box-shadow: var(--shadow);
}

.mobile-menu button { display: block; width: 100%; text-align: left; }

main { min-height: calc(100vh - 72px); }

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.narrow { width: min(760px, calc(100% - 32px)); }

.hero {
  padding: clamp(26px, 5vw, 52px);
  border-radius: 26px;
  background: var(--navy);
  color: white;
  box-shadow: var(--shadow);
}

.hero h1, .hero h2 { margin: 0 0 10px; }
.hero p { max-width: 680px; color: #dce8f1; margin: 0; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.hero .eyebrow { color: #a9d0ff; }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 14px;
}

.section-head h2, .section-head h3 { margin: 0; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 5px 18px rgba(23, 50, 77, .035);
}

.card h2, .card h3, .card h4 { color: var(--navy); }
.card h3 { margin: 0 0 7px; }
.card p { color: var(--muted); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(47,128,237,.10), transparent 30%),
    radial-gradient(circle at 85% 75%, rgba(24,169,153,.09), transparent 28%),
    var(--bg);
}

.login-card {
  width: min(460px, 100%);
  padding: clamp(24px, 6vw, 42px);
  background: white;
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-brand .brand-mark { width: 48px; height: 48px; }

.form-group { margin: 17px 0; }
.form-group label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 800; color: var(--navy); }
.input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid #cbd6df;
  border-radius: 11px;
  background: white;
  color: var(--ink);
}

.input::placeholder { color: #9aa8b5; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.check-row input { width: 18px; height: 18px; }

.btn {
  min-height: 46px;
  padding: 10px 17px;
  border-radius: 11px;
  background: var(--navy);
  color: white;
  font-weight: 800;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(23,50,77,.14); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--blue); }
.btn.secondary { background: var(--surface-2); color: var(--navy); border: 1px solid var(--line); }
.btn.success { background: var(--green); }
.btn.warning { background: var(--orange); color: #3a2606; }
.btn.danger { background: var(--red); }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: 12px; }
.btn.full { width: 100%; }

.alert {
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}
.alert.error { background: var(--red-soft); color: #a72e2a; }
.alert.info { background: var(--blue-soft); color: #205ea9; }
.alert.success { background: var(--green-soft); color: #176c47; }

.grade-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 245px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.grade-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.grade-number {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 15px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 18px;
  font-weight: 900;
}

.grade-card .btn { margin-top: auto; }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 13px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.badge.good { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--orange-soft); color: #8b5a09; }
.badge.info { background: var(--blue-soft); color: #2167ba; }
.badge.purple { background: var(--purple-soft); color: var(--purple); }

.stepper {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  margin: 20px 0 24px;
}
.step {
  min-width: 0;
  position: relative;
  text-align: center;
  color: #91a0ad;
  font-size: 10px;
  font-weight: 900;
}
.step::before {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 6px;
  border-radius: 50%;
  border: 2px solid #cdd7df;
  background: white;
  line-height: 24px;
}
.step span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.active, .step.done { color: var(--blue); }
.step.active::before { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 6px white; }
.step.done::before { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 6px white; }

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebf0;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width .35s ease;
}

.kpi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kpi strong { color: var(--navy); }
.kpi-number { font-size: 26px; font-weight: 900; }

.dashboard-hero {
  display: grid;
  grid-template-columns: 1.6fr .9fr;
  gap: 18px;
  align-items: stretch;
}
.welcome-copy { display: flex; flex-direction: column; justify-content: center; }

.focus-card {
  background: #f8fbff;
  border: 1px solid #d8e7f8;
  border-radius: 16px;
  padding: 17px;
}

.subject-card .subject-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  margin-bottom: 13px;
  font-weight: 900;
  background: var(--blue-soft);
  color: var(--blue);
}

.subject-score {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin: 8px 0;
}
.subject-score strong { font-size: 25px; }
.subject-score span { color: var(--muted); font-size: 12px; }

.action-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }

.reading-layout {
  display: grid;
  grid-template-columns: 1.5fr .8fr;
  gap: 18px;
}

.reading-passage {
  max-height: 480px;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fbfcfd;
  font-size: 17px;
  line-height: 1.9;
}
.reading-passage p { color: var(--ink); }
.reading-passage .read-word {
  padding: 1px 2px;
  border-radius: 4px;
}
.reading-passage .read-word.current { background: #fff0bd; }

.record-panel {
  position: sticky;
  top: 90px;
  align-self: start;
}
.mic {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  margin: 8px auto 15px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 32px;
  box-shadow: 0 8px 20px rgba(47,128,237,.24);
}
.mic.recording { background: var(--red); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,83,79,.25); }
  50% { box-shadow: 0 0 0 15px rgba(217,83,79,0); }
}

.center { text-align: center; }

.analysis-card {
  overflow: hidden;
}
.ai-status {
  min-height: 190px;
  display: grid;
  place-items: center;
  text-align: center;
}
.ai-orb {
  width: 74px;
  height: 74px;
  margin: 0 auto 15px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 28px;
  animation: ai-breathe 1.5s infinite ease-in-out;
}
@keyframes ai-breathe {
  50% { transform: scale(1.08); }
}

.analysis-stages {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 18px;
}
.analysis-stage {
  padding: 10px 6px;
  border-radius: 10px;
  background: var(--surface-2);
  color: #94a0ab;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.analysis-stage.active { background: var(--blue-soft); color: var(--blue); }
.analysis-stage.done { background: var(--green-soft); color: var(--green); }

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.metric:last-child { border-bottom: 0; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { color: var(--navy); }

.word-list { display: grid; gap: 9px; }
.word-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.word-item strong { color: var(--navy); }
.word-item small { color: var(--muted); }

.question-card { margin-bottom: 15px; }
.question-number { color: var(--blue); font-size: 12px; font-weight: 900; }
.question-card h3 { margin: 5px 0 15px; font-size: 17px; }
.choices { display: grid; gap: 9px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.choice:hover { background: var(--surface-2); }
.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.choice input { margin-top: 3px; }

.score-ring {
  --score: 0;
  width: 170px;
  height: 170px;
  display: grid;
  place-items: center;
  margin: 5px auto 18px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) calc(var(--score) * 1%), #e5ebf0 0);
  position: relative;
}
.score-ring::after {
  content: "";
  position: absolute;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: white;
}
.score-ring .score-value {
  position: relative;
  z-index: 1;
  text-align: center;
}
.score-ring strong { display: block; font-size: 35px; color: var(--navy); }
.score-ring span { color: var(--muted); font-size: 11px; }

.feedback-box {
  padding: 18px;
  border-radius: 14px;
  background: var(--blue-soft);
  border: 1px solid #cfe2fa;
}
.feedback-box p { margin: 0; color: #285b8d; }

.list-clean { margin: 0; padding-left: 19px; }
.list-clean li { margin: 7px 0; color: var(--muted); }

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 15px;
}
.activity-question {
  padding: 18px;
  margin: 18px 0;
  border-radius: 15px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.activity-question h3 { margin: 0; }

.result-row {
  display: grid;
  grid-template-columns: 120px 1fr 55px;
  gap: 10px;
  align-items: center;
  margin: 13px 0;
}
.result-row label { font-size: 13px; font-weight: 800; color: var(--navy); }
.result-row strong { text-align: right; font-size: 13px; }

.timeline { display: grid; gap: 12px; }
.timeline-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.timeline-dot {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--blue);
}
.timeline-item strong { display: block; font-size: 13px; color: var(--navy); }
.timeline-item span { display: block; color: var(--muted); font-size: 12px; }

.empty {
  padding: 35px 20px;
  text-align: center;
  color: var(--muted);
}

.footer-note {
  margin-top: 22px;
  color: #81909c;
  font-size: 11px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: min(440px, calc(100% - 30px));
  padding: 11px 15px;
  border-radius: 11px;
  background: var(--navy);
  color: white;
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  font-size: 13px;
  font-weight: 700;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #dbe7f2;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.divider { height: 1px; background: var(--line); margin: 20px 0; }

.small-text { font-size: 12px; color: var(--muted); }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-hero, .reading-layout { grid-template-columns: 1fr; }
  .record-panel { position: static; }
}

@media (max-width: 700px) {
  .desktop-nav { display: none; }
  .icon-button { display: grid; place-items: center; }
  .student-chip span:last-child { display: none; }
  .page { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero { border-radius: 20px; padding: 24px 20px; }
  .card { padding: 17px; }
  .stepper { gap: 3px; }
  .step { font-size: 8px; }
  .step::before { width: 24px; height: 24px; }
  .analysis-stages { grid-template-columns: repeat(2, 1fr); }
  .word-item { grid-template-columns: 1fr auto; }
  .word-item small { grid-column: 1 / -1; }
  .result-row { grid-template-columns: 90px 1fr 45px; }
}

@media (max-width: 400px) {
  .topbar { padding: 10px; }
  .brand-button small { display: none; }
  .login-wrap { padding: 12px; }
  .login-card { padding: 22px 17px; }
  .step span { display: none; }
  .step::before { margin-bottom: 0; }
}

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