/* Lesson completion uses the same genuine, subject-colored levels as iOS. */
#study .lesson-completion {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  max-width: 900px;
  margin-inline: auto;
  padding: max(12px, env(safe-area-inset-top)) 24px max(12px, env(safe-area-inset-bottom));
}
#study .lesson-completion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 48px;
}
#study .completion-subject {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--subject);
  font-weight: 700;
}
#study .completion-subject .app-icon { width: 24px; height: 24px; }
#study .lesson-completion-body {
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}
#study .completion-content {
  width: 100%;
  max-width: 540px;
  margin: auto;
  padding-block: 16px;
  text-align: center;
}
#study .completion-mascot {
  position: relative;
  width: 120px;
  margin: 0 auto 6px;
  animation: completion-arrival 580ms ease-out both;
}
#study .completion-mascot img { display: block; width: 100%; height: auto; }
#study .completion-check {
  position: absolute;
  right: -2px;
  bottom: 18px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--subject-biology);
  color: var(--app-bg);
  border: 3px solid var(--app-bg);
  font-size: 1rem;
  font-weight: 800;
}
#study .lesson-completion h1 {
  font-size: clamp(1.875rem, 4vw, 2.75rem);
  margin: 0 0 10px;
}
#study .completion-concept {
  color: var(--app-secondary);
  font-size: 1rem;
  line-height: 1.45;
  margin: 0 auto 24px;
  max-width: 44ch;
  overflow-wrap: anywhere;
}
#study .completion-level {
  background: var(--app-surface);
  border: 1px solid color-mix(in srgb, var(--subject) 26%, var(--app-separator));
  border-radius: 26px;
  padding: 24px;
  text-align: left;
}
#study .completion-level-heading,
#study .completion-level-value,
#study .completion-level-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#study .completion-level-up {
  background: color-mix(in srgb, var(--subject) 12%, var(--app-surface));
  color: var(--subject);
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 700;
  font-size: .8125rem;
}
#study .completion-level-value { margin: 14px 0; align-items: baseline; }
#study .completion-level-value > div { font-size: 1.625rem; font-weight: 700; }
#study .completion-level-number { color: var(--subject); font-variant-numeric: tabular-nums; }
#study .completion-level-total { color: var(--app-secondary); font-size: .875rem; }
#study .completion-level-track {
  height: 12px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--subject) 16%, var(--app-surface));
  overflow: hidden;
}
#study .completion-level-fill {
  display: block;
  height: 100%;
  background: var(--subject);
  border-radius: inherit;
}
#study .completion-level-caption { margin-top: 8px; font-size: .8125rem; flex-wrap: wrap; }
#study .completion-level-caption > span { color: var(--app-secondary); }
#study .completion-gain { color: var(--subject); }
#study .completion-level-explainer {
  color: var(--app-secondary);
  font-size: .8125rem;
  line-height: 1.4;
  margin: 16px 0 0;
}
#study .completion-level-unavailable h2 { margin-top: 0; }
#study .completion-level-unavailable p { margin-bottom: 0; color: var(--app-secondary); }
#study .lesson-completion-actions {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding-top: 12px;
  background: var(--app-bg);
}
#study .lesson-completion-actions > .button { display: flex; width: 100%; min-height: 52px; }
#study .completion-secondary-actions { display: flex; gap: 12px 20px; flex-wrap: wrap; justify-content: center; }
#study .completion-secondary-actions .text-link { font-size: .875rem; text-align: center; display: inline-flex; align-items: center; }
@keyframes completion-arrival {
  from { opacity: 0; transform: translateY(8px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 600px) {
  #study .lesson-completion { padding-inline: 16px; }
  #study .completion-content { padding-block: 12px; }
  #study .completion-level { padding: 20px; border-radius: 22px; }
  #study .completion-level-value > div { font-size: 1.5rem; }
  #study .completion-concept { margin-bottom: 20px; }
}
@media (max-height: 720px) {
  #study .completion-mascot { width: 76px; margin-bottom: 0; }
  #study .completion-check { width: 26px; height: 26px; bottom: 8px; right: -6px; font-size: .8125rem; }
  #study .lesson-completion h1 { font-size: 1.75rem; margin-bottom: 8px; }
  #study .completion-concept { margin-bottom: 14px; }
  #study .completion-level { padding: 16px 20px; }
  #study .completion-level-value { margin-block: 8px; }
  #study .completion-level-explainer { margin-top: 10px; }
  #study .completion-content { padding-block: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  #study .completion-mascot { animation: none; }
}
