/* ---------- Page header ---------- */
.page-head { margin-bottom: var(--s3); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--s0);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-teal);
  letter-spacing: 0.01em;
}
.lead { font-size: var(--fs-md); color: var(--c-text-muted); max-width: 60ch; }
.muted { color: var(--c-text-muted); }
.small { font-size: var(--fs-sm); }
.stack > * + * { margin-top: var(--s2); }
.stack-sm > * + * { margin-top: var(--s1); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s0) var(--s1); }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s1); }
.grid { display: grid; gap: var(--s2); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Cards ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--s2);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-lavender { background: var(--c-lavender); border-color: transparent; }
.card-teal { background: var(--c-teal-tint); border-color: transparent; }
.card-amber { background: var(--c-amber-tint); border-color: transparent; }
.card h2, .card h3 { margin-bottom: var(--s0); }
.card > :last-child { margin-bottom: 0; }

.hero {
  padding: var(--s3) var(--s2);
  border-radius: var(--radius-lg);
  background: var(--c-lavender);
}
@media (min-width: 720px) { .hero { padding: var(--s4); } }
.hero h1 { font-size: var(--fs-2xl); }
@media (max-width: 420px) { .hero h1 { font-size: var(--fs-xl); } }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: var(--fs-xl); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--fs-sm); color: var(--c-text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s0);
  min-height: var(--tap);
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { background: var(--c-primary-hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-teal { background: var(--c-teal); color: #fff; }
:root[data-theme="dark"] .btn-teal { color: #10221F; }
.btn-teal:hover { background: var(--c-teal-soft); }
.btn-ghost { background: transparent; color: var(--c-text); border-color: var(--c-border); }
.btn-ghost:hover { background: var(--c-surface-2); }
.btn-danger { background: transparent; color: var(--c-danger); border-color: currentColor; }
.btn-danger:hover { background: var(--c-danger-tint); }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--c-teal); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
  min-height: auto;
}

/* ---------- Progress ---------- */
.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--c-surface-2);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--c-teal-soft);
  transition: width 400ms var(--ease);
}
.card-lavender .progress { background: rgba(255, 255, 255, 0.7); }
:root[data-theme="dark"] .card-lavender .progress { background: rgba(0, 0, 0, 0.25); }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  white-space: nowrap;
}
.pill-teal { background: var(--c-teal-tint); color: var(--c-teal); }
.pill-amber { background: var(--c-amber-tint); color: var(--c-amber-text); }
.pill-lavender { background: var(--c-lavender); color: var(--c-lavender-text); }
.pill-success { background: var(--c-success-tint); color: var(--c-success); }

/* ---------- Lesson list ---------- */
.unit { margin-bottom: var(--s4); }
.unit-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s0); margin-bottom: var(--s1); }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s0); }
.lesson-list li + li { margin-top: 0; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: 14px var(--s1);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  text-decoration: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.lesson-item:hover { border-color: var(--c-teal-soft); box-shadow: var(--shadow); }
.lesson-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--c-surface-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lesson-item.is-done .lesson-num { background: var(--c-teal-tint); color: var(--c-teal); }
.lesson-body { flex: 1; min-width: 0; }
.lesson-title { display: block; font-weight: 600; line-height: 1.35; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; font-size: var(--fs-sm); color: var(--c-text-muted); }
.lesson-meta .row { gap: 4px; }

/* ---------- Lesson reading ---------- */
.lesson-sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: calc(-1 * var(--s2)) calc(-1 * var(--s1)) var(--s2);
  padding: var(--s0) var(--s1);
  background: color-mix(in srgb, var(--c-bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--c-border);
}
@media (min-width: 960px) {
  .lesson-sticky { margin: calc(-1 * var(--s4)) 0 var(--s3); padding: var(--s1) 0; }
}
.steps-nav { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; overflow-x: auto; }
.steps-nav li + li { margin-top: 0; }
.steps-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 4px 12px;
  border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--c-text-muted); text-decoration: none; white-space: nowrap;
}
.steps-nav a[aria-current="step"] { background: var(--c-lavender); color: var(--c-lavender-text); }
.steps-nav a.is-done { color: var(--c-teal); }

.prose { font-size: 1.0625rem; }
.prose h2 { margin-top: var(--s3); }
.prose p { max-width: 68ch; }

.goal {
  display: flex; gap: var(--s1); align-items: flex-start;
  padding: var(--s1) var(--s2);
  border-left: 4px solid var(--c-amber);
  background: var(--c-amber-tint);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.goal p { margin: 0; }

.example { border-left: 4px solid var(--c-teal-soft); }
.recap-list { list-style: none; padding: 0; margin: 0; }
.recap-list li { display: flex; gap: var(--s0); align-items: flex-start; }
.recap-list li .icon { margin-top: 3px; color: var(--c-teal); }

.notice {
  display: flex; gap: var(--s0); align-items: flex-start;
  padding: 12px var(--s1);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}
.notice .icon { margin-top: 2px; }
.notice p { margin: 0; }

/* ---------- Practice ---------- */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s0); }
.checklist li + li { margin-top: 0; }
.check-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px var(--s1);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  cursor: pointer;
  font-weight: 400;
}
.check-row input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--c-teal); }
.check-row:has(input:checked) { background: var(--c-teal-tint); border-color: transparent; }

.prompt-box textarea { font-family: var(--font-mono); font-size: 0.92rem; min-height: 110px; }
.sample {
  white-space: pre-wrap;
  padding: var(--s1) var(--s2);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border);
  font-size: 0.97rem;
}

/* ---------- Quiz ---------- */
.quiz-item { border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--s2); background: var(--c-surface); }
.quiz-item fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.quiz-item legend { font-weight: 650; font-size: var(--fs-md); margin-bottom: var(--s1); padding: 0; }
.options { display: grid; gap: var(--s0); }
.option {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px var(--s1);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 450;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.option:hover { border-color: var(--c-teal-soft); }
.option input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--c-teal); }
.option:has(input:checked) { border-color: var(--c-teal); background: var(--c-teal-tint); }
.option.is-correct, .option.is-correct:has(input:checked) { border-color: var(--c-success); background: var(--c-success-tint); }
.option.is-wrong, .option.is-wrong:has(input:checked) { border-color: var(--c-danger); background: var(--c-danger-tint); }
.option:has(input:disabled) { cursor: default; }
.feedback { margin-top: var(--s1); padding: 12px var(--s1); border-radius: var(--radius-sm); }
.feedback p { margin: 0; }
.feedback-good { background: var(--c-success-tint); color: var(--c-text); }
.feedback-try { background: var(--c-amber-tint); color: var(--c-text); }
.feedback strong { display: block; margin-bottom: 4px; }
.result-card { text-align: center; }
.result-score { font-size: 3rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Onboarding ---------- */
.choice-group { display: flex; flex-wrap: wrap; gap: var(--s0); border: 0; margin: 0; padding: 0; }
.choice-group legend { font-weight: 650; margin-bottom: var(--s0); padding: 0; width: 100%; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); min-width: 72px; padding: 8px 18px;
  border: 1.5px solid var(--c-border); border-radius: 999px;
  background: var(--c-surface); font-weight: 600;
}
.choice input:checked + span { border-color: var(--c-teal); background: var(--c-teal-tint); color: var(--c-teal); }
.choice input:focus-visible + span { outline: 3px solid var(--c-focus); outline-offset: 2px; }

.switch-row { display: flex; gap: var(--s1); align-items: flex-start; justify-content: space-between; }
.switch { position: relative; flex: none; width: 52px; height: 30px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--c-border); transition: background var(--dur) var(--ease); }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + span { background: var(--c-teal); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--c-focus); outline-offset: 2px; }

/* ---------- Rating ---------- */
.rating { display: flex; gap: var(--s0); flex-wrap: wrap; border: 0; padding: 0; margin: 0; }
.rating legend { padding: 0; margin-bottom: var(--s0); font-weight: 650; width: 100%; }
.rating .choice span { min-width: 52px; }

/* ---------- Glossary ---------- */
.glossary-list { display: grid; gap: var(--s1); margin: 0; }
.glossary-list dt { font-weight: 700; font-size: var(--fs-md); }
.glossary-list dd { margin: 4px 0 0; }
.term { padding: var(--s1) var(--s2); }
.alpha-nav { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Tables (lead worksheet) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--c-border); vertical-align: top; }
th { background: var(--c-surface-2); font-weight: 650; }
tr:last-child td { border-bottom: 0; }

/* ---------- Details / accordions ---------- */
details.card { padding: 0; }
details.card > summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s1);
  padding: var(--s1) var(--s2);
  min-height: var(--tap);
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--c-text-muted); }
details.card[open] > summary::after { content: "–"; }
details.card > .details-body { padding: 0 var(--s2) var(--s2); }

/* ---------- States ---------- */
.state-loading, .state-empty, .state-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1);
  min-height: 40vh; text-align: center; color: var(--c-text-muted); padding: var(--s3) var(--s1);
}
.state-error h1 { color: var(--c-text); }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--c-border); border-top-color: var(--c-teal);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-h) + var(--s2) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-weight: 550;
  box-shadow: var(--shadow);
  animation: toast-in 200ms var(--ease);
}
@media (min-width: 960px) { .toast { bottom: var(--s3); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.view-enter { animation: view-in 220ms var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.divider { border: 0; border-top: 1px solid var(--c-border); margin: var(--s3) 0; }
.kbd-hint { font-size: var(--fs-sm); color: var(--c-text-muted); }

/* ---------- Language switch ---------- */
.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  margin-bottom: var(--s1);
}
.lang-switch button {
  min-width: 44px;
  min-height: 36px;
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--c-text-muted);
  font-weight: 650;
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lang-switch button:hover { color: var(--c-text); }
.lang-switch button[aria-pressed="true"] { background: var(--c-primary); color: var(--c-on-primary); }
.sidebar #lang-switch { margin-top: auto; }
.sidebar #lang-switch .lang-switch { margin-bottom: 0; }
.sidebar #lang-switch + .sidebar-foot { margin-top: 0; }

/* Longer translations must never widen list tracks past the viewport. */
.lesson-list { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 420px) {
  .lesson-item .pill { white-space: normal; text-align: center; max-width: 7.5rem; }
}

/* ---------- Sign-in & sync ---------- */
body.is-locked .sidebar, body.is-locked .bottom-nav { display: none; }
body.is-locked .main-col { margin-left: 0; padding-bottom: var(--s3); }
.login-wrap { min-height: 80vh; min-height: 80dvh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 420px; padding: var(--s3); }
.login-card .lang-switch { justify-self: end; align-self: flex-end; margin-bottom: 0; }
.login-mark { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 50%; background: var(--c-rose-tint, #FDEBEF); color: var(--c-rose, #C23D5C); }
.login-card h1 { margin-bottom: 0; }
.sync-status { margin: var(--s0) 0 0; font-size: var(--fs-sm); color: var(--c-text-muted); min-height: 1.4em; }
.sync-status[data-status="saved"]::before { content: "✓ "; color: var(--c-success); }
.sync-status[data-status="offline"], .sync-status[data-status="error"] { color: var(--c-amber-text); }
