:root {
  --background: #f3f1f8;
  --panel: #ffffff;
  --panel-border: #d8d3e4;
  --text: #1f2430;
  --muted: #616675;
  --accent: #4f2d7f;
  --accent-dark: #39205d;
  --accent-soft: #ede6f7;
  --gray-soft: #f5f5f8;
  --gray-strong: #6d7280;
  --correct: #2c8a57;
  --incorrect: #c34b4b;
  --shadow: 0 18px 40px rgba(57, 32, 93, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79, 45, 127, 0.14), transparent 30%),
    linear-gradient(180deg, #f8f7fb 0%, var(--background) 100%);
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 18px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero {
  width: 100%;
  max-width: 760px;
  margin-bottom: 24px;
  text-align: center;
}

.hero-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  margin-bottom: 12px;
  text-align: left;
}

.hero-logo {
  display: block;
  width: clamp(120px, 18vw, 156px);
  max-width: 100%;
  height: auto;
  flex-shrink: 0;
  object-fit: contain;
}

.hero-copy {
  min-width: 0;
}

.hero-copy h1 {
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.intro,
.panel-text,
.progress-text,
.explanation-text,
.message,
.section-note {
  color: var(--muted);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.hero-logout {
  max-width: 180px;
  margin: 16px auto 0;
}

.hero-chooser {
  max-width: 200px;
  margin: 16px auto 0;
}

.hero-stat {
  margin-bottom: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.panel,
.question-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.panel {
  width: 100%;
  max-width: 760px;
  padding: 28px;
}

.login-stack {
  width: 100%;
  max-width: 760px;
}

.question-card {
  padding: 24px;
}

.study-actions {
  display: grid;
  gap: 14px;
  margin: 22px 0 28px;
}

.track-selection {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.track-button {
  min-height: 72px;
}

.review-header {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.review-header .secondary-button {
  max-width: 240px;
}

.review-list {
  display: grid;
  gap: 18px;
}

.review-card {
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--gray-soft);
}

.review-topic {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 700;
}

.review-question {
  margin-bottom: 14px;
}

.review-choices {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.review-choice {
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: #ffffff;
}

.review-choice.correct {
  border-color: rgba(44, 138, 87, 0.35);
  background: rgba(44, 138, 87, 0.12);
  color: var(--correct);
  font-weight: 700;
}

.review-choice.correct::after {
  content: " Correct answer";
  font-weight: 700;
}

.review-explanation {
  margin-bottom: 0;
}

.review-empty {
  padding: 20px;
  border: 1px dashed var(--panel-border);
  border-radius: 18px;
  background: #faf9fc;
}

.review-empty-title {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 20px;
  margin-bottom: 14px;
}

.login-note {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: #faf9fc;
}

.login-note-title,
.login-note-text {
  margin-bottom: 0;
}

.login-note-title {
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 700;
}

.login-note-text {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.input-group {
  display: grid;
  gap: 8px;
  color: var(--accent-dark);
  font-weight: 700;
}

.input-group input {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 18px;
  font: inherit;
  font-size: 1rem;
  background: #faf9fc;
  color: var(--text);
}

.input-group input:focus {
  outline: 2px solid rgba(79, 45, 127, 0.2);
  border-color: var(--accent);
}

.welcome-badge {
  display: inline-block;
  margin-bottom: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

.welcome-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}

.welcome-logo {
  display: block;
  width: clamp(112px, 20vw, 144px);
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.welcome-message {
  max-width: 560px;
  margin: 10px auto 24px;
  display: grid;
  gap: 10px;
  text-align: left;
}

.welcome-message-lead,
.welcome-message-body {
  margin: 0;
}

.welcome-message-lead {
  color: var(--accent-dark);
  font-size: 1.08rem;
  font-weight: 700;
}

.welcome-message-body {
  color: var(--muted);
  line-height: 1.6;
}

.study-section + .study-section {
  margin-top: 28px;
}

.section-header {
  margin-bottom: 14px;
}

.section-header h3,
.section-note {
  margin-bottom: 6px;
}

.report-card {
  margin: 16px 0;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--gray-soft);
  border: 1px solid var(--panel-border);
}

.report-label {
  margin-bottom: 6px;
  color: var(--gray-strong);
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-value {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 700;
}

.progress-panel {
  margin-bottom: 18px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.score-text,
.xp-text {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.progress-bar {
  height: 14px;
  background: #e6e0f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5d35a0 0%, #7d59b8 100%);
  transition: width 0.25s ease;
}

.mastery-panel {
  margin-top: 16px;
}

.mastery-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mastery-text {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 700;
}

.mastery-bar {
  height: 10px;
  background: #ece6f5;
  border-radius: 999px;
  overflow: hidden;
}

.mastery-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2c8a57 0%, #66be86 100%);
  transition: width 0.25s ease;
}

.quiz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.quiz-heading {
  margin-bottom: 18px;
}

.difficulty-text,
.review-text {
  margin-bottom: 10px;
  color: var(--gray-strong);
  font-size: 0.9rem;
}

.assessment-notice {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 700;
}

.review-text {
  color: var(--accent-dark);
  font-weight: 700;
}

.encouragement-text {
  min-height: 24px;
  margin-bottom: 10px;
  color: var(--accent);
  font-weight: 700;
}

.topic-list,
.answer-list,
.complete-actions,
.question-actions {
  display: grid;
  gap: 14px;
}

.study-plan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
  align-items: stretch;
}

.study-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--gray-soft);
}

.practice-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.recommended-row .practice-card {
  border-color: rgba(79, 45, 127, 0.22);
  background: linear-gradient(180deg, #f6f1fd 0%, #faf9fc 100%);
}

.study-card-label {
  margin-bottom: 8px;
  color: var(--gray-strong);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.study-card-title {
  margin-bottom: 10px;
  color: var(--accent-dark);
  font-size: 1rem;
}

.study-card-text {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.study-card-subtitle {
  margin: 14px 0 8px;
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 700;
}

.study-guide-summary {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.study-guide-links {
  display: grid;
  gap: 8px;
}

.study-guide-link {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.study-guide-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(31, 36, 48, 0.08);
  border-color: rgba(79, 45, 127, 0.28);
}

.practice-button {
  margin-top: auto;
}

.dont-know-button {
  margin-top: 14px;
}

.topic-button,
.answer-button,
.primary-button,
.secondary-button {
  width: 100%;
  border-radius: 18px;
  padding: 18px 20px;
  font: inherit;
  font-size: 1.03rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.topic-button,
.answer-button {
  text-align: left;
}

.topic-button,
.primary-button {
  border: none;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(79, 45, 127, 0.22);
}

.answer-button,
.secondary-button {
  border: 1px solid var(--panel-border);
  background: #faf9fc;
  color: var(--text);
}

.topic-button:hover,
.answer-button:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-2px);
}

.answer-button:hover,
.secondary-button:hover {
  box-shadow: 0 10px 22px rgba(31, 36, 48, 0.08);
}

.answer-button:disabled,
.secondary-button:disabled,
.primary-button:disabled {
  cursor: default;
  opacity: 0.9;
}

.answer-button.correct {
  background: rgba(44, 138, 87, 0.14);
  border-color: rgba(44, 138, 87, 0.35);
}

.answer-button.incorrect {
  background: rgba(195, 75, 75, 0.14);
  border-color: rgba(195, 75, 75, 0.35);
}

.answer-button.correct::after {
  content: " ✓";
  font-weight: 700;
  color: var(--correct);
}

.recommended {
  position: relative;
  overflow: hidden;
}

.recommended::after {
  content: "Recommended";
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.78rem;
  font-weight: 700;
}

.topic-meta {
  display: block;
  margin-top: 6px;
  font-size: 0.88rem;
  opacity: 0.9;
}

.feedback-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: var(--gray-soft);
  border: 1px solid var(--panel-border);
}

.question-card.correct-flash {
  animation: cardCorrect 0.45s ease;
}

.question-card.incorrect-flash {
  animation: cardIncorrect 0.45s ease, cardShake 0.3s ease;
}

.feedback-text {
  margin-bottom: 8px;
  font-weight: 700;
}

.feedback-text.correct {
  color: var(--correct);
}

.feedback-text.incorrect {
  color: var(--incorrect);
}

.complete-stats {
  margin: 18px 0;
  display: grid;
  gap: 10px;
}

.complete-stat {
  margin-bottom: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.flash-correct {
  animation: flashCorrect 0.45s ease;
}

.flash-incorrect {
  animation: flashIncorrect 0.45s ease;
}

.hidden {
  display: none;
}

.error {
  margin-top: 18px;
  color: var(--incorrect);
}

@keyframes flashCorrect {
  0% {
    background: #ddf5e6;
  }
  100% {
    background: transparent;
  }
}

@keyframes flashIncorrect {
  0% {
    background: #fde3e3;
  }
  100% {
    background: transparent;
  }
}

@keyframes cardCorrect {
  0% {
    box-shadow: 0 0 0 0 rgba(44, 138, 87, 0.28);
    background: #effbf4;
  }
  100% {
    box-shadow: var(--shadow);
    background: var(--panel);
  }
}

@keyframes cardIncorrect {
  0% {
    background: #fff0f0;
  }
  100% {
    background: var(--panel);
  }
}

@keyframes cardShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 24px 14px 36px;
  }

  .hero-brand {
    gap: 12px;
    align-items: flex-start;
    text-align: left;
  }

  .hero-logo {
    width: clamp(112px, 32vw, 132px);
  }

  .welcome-logo {
    width: clamp(104px, 34vw, 132px);
  }

  .panel {
    padding: 22px;
  }

  .progress-header,
  .quiz-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .study-plan-row {
    grid-template-columns: 1fr;
  }
}
