:root {
  color-scheme: only light;
  --sje-primary: #034ea2;
  --sje-primary-hover: #063e80;
  --sje-primary-deep: #0b2c5f;
  --sje-primary-soft: #eaf3ff;
  --sje-brand-yellow: #ffc20f;
  --sje-brand-yellow-soft: #fff8d6;
  --sje-ink: #0f172a;
  --sje-ink-soft: #334155;
  --sje-muted: #53657c;
  --sje-bg: #f4f7fc;
  --sje-surface: #ffffff;
  --sje-line: #d8e2ef;
  --sje-shadow-sm: 0 4px 14px rgba(15, 38, 71, .06);
  --sje-shadow-md: 0 16px 40px rgba(15, 38, 71, .14);
  --sje-radius: 16px;
  --sje-focus: 0 0 0 3px rgba(255, 194, 15, .82), 0 0 0 5px rgba(3, 78, 162, .42);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  color: var(--sje-ink);
  background: radial-gradient(circle at 100% 0, rgba(3, 78, 162, .07), transparent 26rem), var(--sje-bg);
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; }
a { -webkit-tap-highlight-color: transparent; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding-inline: 16px; }
.reading-wrap { max-width: 900px; }

/* Shared public shell */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid rgba(216, 226, 239, .9);
  backdrop-filter: blur(12px);
}
.site-header .wrap {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
}
.wordmark {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  color: var(--sje-primary);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
}
.wordmark .dot {
  width: 13px;
  height: 13px;
  flex: none;
  border-radius: 50%;
  background: var(--sje-brand-yellow);
  box-shadow: 0 0 0 5px var(--sje-brand-yellow-soft);
}
.btn, .btn-login {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  color: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease;
}
.btn-primary {
  color: #fff;
  background: var(--sje-primary);
  box-shadow: 0 8px 18px rgba(3, 78, 162, .2);
}
.btn-primary:hover { background: var(--sje-primary-hover); }
.btn-login {
  color: var(--sje-primary);
  background: #fff;
  border-color: #b9cbe0;
}
.btn-login:hover {
  color: var(--sje-primary-deep);
  background: var(--sje-primary-soft);
  border-color: var(--sje-primary);
}
.btn:active, .btn-login:active { transform: translateY(1px); }

/* Introduction */
.crumbs { padding-top: 16px; color: var(--sje-muted); font-size: 13px; overflow-wrap: anywhere; }
.crumbs a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-inline: -5px;
  padding-inline: 5px;
  color: var(--sje-muted);
  text-underline-offset: 3px;
}
.crumbs a:hover { color: var(--sje-primary); }
.page-hero { padding: 17px 0 10px; }
.hero-kicker {
  color: var(--sje-primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .085em;
  text-transform: uppercase;
}
.page-hero h1 {
  max-width: 760px;
  color: var(--sje-ink);
  font-size: clamp(27px, 7vw, 42px);
  line-height: 1.12;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}
.hero-kicker + h1 { margin-top: 7px; }
.page-hero > p:not(.hero-kicker) {
  max-width: 740px;
  margin-top: 10px;
  color: var(--sje-muted);
  font-size: 15px;
}
.family-total {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  margin-top: 15px;
  padding: 5px 11px;
  color: var(--sje-primary);
  background: var(--sje-primary-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

/* Level selector */
.level-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 18px 0 40px;
}
.level-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 190px;
  flex-direction: column;
  overflow: hidden;
  padding: 18px;
  color: inherit;
  text-decoration: none;
  background: var(--sje-surface);
  border: 1px solid var(--sje-line);
  border-radius: var(--sje-radius);
  box-shadow: var(--sje-shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.level-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--sje-primary);
  content: "";
}
.level-card.active { border-color: #b8cbe2; }
.level-card.active:hover {
  border-color: #86acd6;
  box-shadow: 0 13px 28px rgba(15, 38, 71, .12);
  transform: translateY(-2px);
}
.level-card.locked { background: rgba(255, 255, 255, .7); box-shadow: none; }
.level-card.locked::before { background: #aebed1; }
.level-code {
  display: inline-flex;
  width: fit-content;
  min-width: 46px;
  min-height: 31px;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  padding: 5px 10px;
  color: var(--sje-primary);
  background: var(--sje-primary-soft);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 900;
}
.locked .level-code { color: var(--sje-muted); background: #edf1f6; }
.level-card h2 { font-size: 18px; line-height: 1.28; letter-spacing: -.015em; }
.level-card p { margin-top: 7px; color: var(--sje-muted); font-size: 13px; }
.badge-soon {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 4px 9px;
  color: var(--sje-muted);
  background: #edf1f6;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.badge-count {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  margin-top: 12px;
  padding: 4px 10px;
  color: var(--sje-primary);
  background: var(--sje-primary-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.locked .badge-count { color: var(--sje-muted); background: #edf1f6; }
.level-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 14px;
  color: var(--sje-primary);
  font-size: 13px;
  font-weight: 800;
}

/* A1 family directory */
.family-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 11px;
  margin: 18px 0 42px;
}
.family-card {
  display: grid;
  min-width: 0;
  min-height: 100px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 16px;
  color: inherit;
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--sje-line);
  border-radius: var(--sje-radius);
  box-shadow: var(--sje-shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.family-card:hover {
  border-color: #86acd6;
  box-shadow: 0 13px 28px rgba(15, 38, 71, .12);
  transform: translateY(-2px);
}
.family-order, .concept-number {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  color: var(--sje-primary);
  background: var(--sje-primary-soft);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 900;
}
.family-card-copy { min-width: 0; }
.family-card-copy h2 { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.family-card-copy > span { display: block; margin-top: 4px; color: var(--sje-muted); font-size: 12px; font-weight: 700; }
.family-card-arrow { color: var(--sje-primary); font-size: 22px; font-weight: 800; }

/* Static concept notebook */
.family-hero { padding-bottom: 18px; }
.concept-list { display: grid; gap: 14px; }
.concept-card {
  min-width: 0;
  scroll-margin-top: 82px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--sje-line);
  border-radius: 18px;
  box-shadow: var(--sje-shadow-sm);
}
.concept-heading { display: flex; align-items: flex-start; gap: 13px; }
.concept-heading > div { min-width: 0; }
.concept-number { width: 38px; height: 38px; flex-basis: 38px; border-radius: 11px; }
.cefr-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  color: var(--sje-primary);
  background: var(--sje-primary-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}
.concept-heading h2 {
  margin-top: 7px;
  font-size: clamp(19px, 5vw, 24px);
  line-height: 1.25;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.concept-en-name {
  margin-top: 4px;
  color: var(--sje-primary);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.concept-explanation {
  margin-top: 17px;
  color: var(--sje-ink-soft);
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}
.concept-note {
  margin-top: 15px;
  padding: 14px;
  color: var(--sje-ink-soft);
  background: var(--sje-brand-yellow-soft);
  border: 1px solid #f0d16b;
  border-left: 4px solid var(--sje-brand-yellow);
  border-radius: 12px;
}
.concept-note strong { display: block; color: #654900; font-size: 13px; }
.concept-note p { margin-top: 4px; font-size: 14px; line-height: 1.62; overflow-wrap: anywhere; }
.concept-example {
  margin-top: 15px;
  padding: 15px;
  background: var(--sje-primary-soft);
  border-radius: 13px;
}
.example-label {
  display: block;
  margin-bottom: 7px;
  color: var(--sje-primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.example-en {
  color: var(--sje-primary-deep);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.example-vi { margin-top: 7px; color: var(--sje-muted); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.placement-cta {
  position: relative;
  display: grid;
  gap: 17px;
  margin: 24px 0 44px;
  overflow: hidden;
  padding: 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--sje-primary-deep), var(--sje-primary));
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(3, 78, 162, .22);
}
.placement-cta::after {
  position: absolute;
  width: 180px;
  height: 180px;
  top: -110px;
  right: -70px;
  border: 27px solid rgba(255, 194, 15, .17);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}
.placement-cta > * { position: relative; z-index: 1; }
.placement-cta h2 { font-size: clamp(20px, 5.5vw, 26px); line-height: 1.22; }
.placement-cta p { max-width: 560px; margin-top: 6px; color: #dcecff; font-size: 14px; }
.placement-cta .btn-primary {
  width: 100%;
  color: var(--sje-primary-deep);
  background: var(--sje-brand-yellow);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
}
.placement-cta .btn-primary:hover { background: #ffcf3f; }

/* Keyboard accessibility and footer */
:where(a, button, input, [tabindex]):focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--sje-focus);
}
.level-card:focus-visible, .family-card:focus-visible { z-index: 2; border-color: var(--sje-primary); }
.site-footer {
  margin-top: 20px;
  padding: 26px 0 calc(26px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--sje-line);
}
.site-footer .wrap { color: var(--sje-muted); font-size: 13px; }
.site-footer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--sje-primary);
  text-underline-offset: 3px;
}

@media (min-width: 560px) {
  .wrap { padding-inline: 22px; }
  .level-grid, .family-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .concept-card { padding: 22px; }
  .placement-cta { padding: 26px; }
}

@media (min-width: 820px) {
  .level-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
  .page-hero { padding-top: 22px; }
  .concept-card { padding: 26px; }
  .placement-cta { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .placement-cta .btn-primary { width: auto; }
}

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

/* Free Learning refresh: shared shell, clearer reading rhythm and practice states. */
body {
  color: var(--sje-ink);
  background:
    radial-gradient(circle at 92% 5%, rgba(3, 78, 162, .08), transparent 25rem),
    linear-gradient(180deg, #f8faff 0, var(--sje-bg) 31rem);
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1160px; padding-inline: 18px; }
.reading-wrap { max-width: 980px; }
.site-header .wrap {
  display: grid;
  min-height: 70px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand login" "nav nav";
  align-items: center;
  gap: 0 14px;
}
.wordmark { grid-area: brand; }
.learning-nav { grid-area: nav; }
.btn-login { grid-area: login; justify-self: end; }
.page-hero h1 { font-size: clamp(30px, 7vw, 48px); line-height: 1.08; letter-spacing: -.045em; }
.page-hero > p:not(.hero-kicker) { max-width: 760px; line-height: 1.65; }
.level-card { min-height: 205px; padding: 20px; border-radius: var(--sje-radius); }
.level-card h2 { font-size: 19px; }
.family-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.family-meta .family-total { margin-top: 0; }
.family-total-exercises { color: var(--sje-primary-deep); background: #fff; border: 1px solid var(--sje-line); }

.grammar-session-card {
  display: grid;
  gap: 18px;
  margin: 14px 0 16px;
  overflow: hidden;
  padding: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--sje-primary-deep), var(--sje-primary));
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 22px;
  box-shadow: 0 18px 40px rgba(3, 78, 162, .2);
}
.grammar-session-copy { min-width: 0; }
.grammar-session-card .session-eyebrow { color: #c7e5ff; }
.grammar-session-card h2 { margin-top: 5px; font-size: clamp(21px, 5vw, 27px); line-height: 1.2; letter-spacing: -.025em; }
.grammar-session-card p:last-child { max-width: 620px; margin-top: 7px; color: #dcecff; font-size: 14px; }
.grammar-session-card .btn-primary { width: 100%; color: var(--sje-primary); background: #fff; box-shadow: 0 8px 18px rgba(0, 0, 0, .16); }
.grammar-session-card .btn-primary:hover { background: var(--sje-primary-soft); }
.grammar-progress-panel { margin-bottom: 22px; }
.grammar-progress-detail { margin-top: 8px; color: var(--sje-muted); font-size: 12px; }

.concept-list { gap: 18px; }
.concept-card {
  position: relative;
  padding: clamp(20px, 4vw, 30px);
  border-radius: 22px;
  box-shadow: var(--sje-shadow-sm);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.concept-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #bfd0e3;
  border-radius: 22px 0 0 22px;
  content: "";
}
.concept-card.is-review::before { background: #db8a3c; }
.concept-card.is-mastered::before { background: #3d9b62; }
.concept-heading h2 { font-size: clamp(21px, 5vw, 27px); }
.concept-explanation { max-width: 76ch; color: var(--sje-ink-soft); font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 1.78; }
.concept-example { padding: 17px 18px; background: #f0f6fd; border: 1px solid #d5e4f4; }
.example-en, .example-vi { font-family: Georgia, "Times New Roman", serif; }
.example-en { font-size: 17px; line-height: 1.7; }
.example-vi { font-size: 15px; line-height: 1.65; }
.concept-practice {
  display: block;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--sje-line);
  scroll-margin-top: 116px;
}
.concept-practice-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 8px 16px;
}
.practice-kicker {
  color: var(--sje-primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .09em;
}
.concept-practice-heading h3 { margin-top: 3px; font-size: 19px; line-height: 1.25; }
.concept-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 10px;
  color: var(--sje-muted);
  background: #edf2f8;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}
.is-review .concept-status { color: var(--sje-review); background: #fff4e8; }
.is-mastered .concept-status { color: var(--sje-ok); background: var(--sje-ok-soft); }

.grammar-exercise-list { display: grid; gap: 14px; margin-top: 16px; }
.grammar-exercise {
  min-width: 0;
  padding: 16px;
  background: #fbfcfe;
  border: 1px solid #dbe4ee;
  border-radius: 16px;
}
.grammar-exercise-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  color: var(--sje-primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.grammar-exercise-status { color: var(--sje-muted); letter-spacing: 0; text-transform: none; }
.grammar-exercise[data-exercise-state="completed"] .grammar-exercise-status { color: var(--sje-ok); }
.grammar-exercise-prompt { margin-top: 14px; color: var(--sje-ink-soft); font-size: 14px; font-weight: 750; line-height: 1.55; }
.grammar-exercise-sentence,
.grammar-error-sentence {
  margin-top: 9px;
  color: var(--sje-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 4.8vw, 21px);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.grammar-choice-list { display: grid; gap: 9px; margin-top: 14px; }
.grammar-choice,
.grammar-error-fragment {
  min-width: 0;
  min-height: 46px;
  color: var(--sje-ink-soft);
  background: #fff;
  border: 1px solid #c8d5e3;
  border-radius: 12px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.grammar-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}
.grammar-choice:hover,
.grammar-error-fragment:hover { border-color: var(--sje-primary); background: var(--sje-primary-soft); }
.grammar-choice:active,
.grammar-error-fragment:active { transform: translateY(1px); }
.grammar-choice .option-marker { flex: 0 0 auto; }
.grammar-error-sentence {
  padding: 13px 14px;
  background: #fff;
  border: 1px solid #d7e1ec;
  border-radius: 13px;
  line-height: 2.35;
}
.grammar-error-fragment {
  display: inline-flex;
  align-items: center;
  margin: 2px 3px;
  padding: 6px 9px;
  font-family: inherit;
  font-size: .92em;
  line-height: 1.25;
  vertical-align: middle;
}
.grammar-choice:disabled,
.grammar-error-fragment:disabled { opacity: 1; cursor: default; transform: none; }
.grammar-choice.correct,
.grammar-error-fragment.correct { color: #176338; background: var(--sje-ok-soft); border-color: #6eb78b; box-shadow: 0 0 0 2px rgba(61, 155, 98, .1); }
.grammar-choice.wrong,
.grammar-error-fragment.wrong { color: #9f2c2c; background: var(--sje-danger-soft); border-color: #e09292; }
.grammar-choice.is-retry-answer:not(:disabled),
.grammar-error-fragment.is-retry-answer:not(:disabled) { box-shadow: 0 0 0 3px rgba(61, 155, 98, .16); }

.grammar-exercise-feedback {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--sje-ink-soft);
  font-size: 13px;
  line-height: 1.55;
}
.grammar-exercise-feedback[hidden] { display: none; }
.grammar-exercise-feedback.ok { background: var(--sje-ok-soft); border-color: #a9d7bb; }
.grammar-exercise-feedback.bad { background: var(--sje-danger-soft); border-color: #edb6b6; }
.grammar-exercise-feedback > .feedback-icon { margin-top: 1px; }
.grammar-exercise-feedback.ok > .feedback-icon { background: var(--sje-ok); }
.grammar-exercise-feedback.bad > .feedback-icon { background: var(--sje-danger); }
.grammar-exercise-feedback strong { color: var(--sje-ink); }
.grammar-exercise-feedback p { margin-top: 3px; }
.grammar-feedback-explanation { padding-top: 7px; border-top: 1px solid rgba(52, 75, 100, .14); }
.grammar-loading { margin-top: 14px; color: var(--sje-muted); font-size: 13px; }
.grammar-loading.error { padding: 12px; color: #8f2c2c; background: var(--sje-danger-soft); border-radius: 12px; }
.placement-cta .btn-primary { color: var(--sje-primary); background: #fff; }
.placement-cta .btn-primary:hover { background: var(--sje-primary-soft); }

@media (min-width: 620px) {
  .wrap { padding-inline: 24px; }
  .site-header .wrap { grid-template-columns: auto minmax(260px, 360px) 1fr; grid-template-areas: "brand nav login"; gap: 24px; }
  .learning-nav { margin: 0; }
  .grammar-session-card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 24px; }
  .grammar-session-card .btn-primary { width: auto; min-width: 205px; }
  .concept-practice { scroll-margin-top: 84px; }
  .grammar-choice-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
