* {
  box-sizing: border-box;
}

:root {
  --bg: #f7f2ea;
  --card: #ffffff;
  --ink: #142033;
  --muted: #5f6f84;
  --line: #e8dccb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e9f1ff;
  --success: #1f8a4c;
  --success-soft: #ecf8f0;
  --danger: #c43d3d;
  --danger-soft: #fff1f1;
  --warning-soft: #fff7dc;
  --shadow: 0 18px 45px rgba(49, 35, 16, 0.09);
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background:
    radial-gradient(circle at top left, #fff0cf 0, transparent 34%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #f9fafb 100%);
  color: var(--ink);
  line-height: 1.45;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(232, 241, 255, 0.92)),
    var(--card);
  border: 1px solid rgba(190, 210, 240, 0.8);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.1rem);
  letter-spacing: -0.04em;
  line-height: 1;
}

h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 560px;
}

.badgeRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.modeBadge {
  display: inline-block;
  margin: 0;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid #bdd4ff;
  color: #174ea6;
  font-size: 0.85rem;
  font-weight: 700;
}

.softBadge {
  background: #fff7dc;
  border-color: #f4d984;
  color: #775900;
}

.smallBadge {
  margin-top: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 10px 28px rgba(49, 35, 16, 0.06);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

label {
  font-weight: 700;
  color: #24324a;
}

select {
  min-width: 180px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid #c9d5e6;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
  box-shadow: 0 6px 14px rgba(25, 64, 120, 0.08);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(25, 64, 120, 0.13);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.secondary {
  background: var(--primary-soft);
  color: #173b76;
}

.danger {
  background: var(--danger);
  color: #fff;
}

.hidden {
  display: none;
}

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

.meta {
  margin: 0;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f3f6fb;
  font-size: 0.9rem;
  font-weight: 700;
  color: #40546e;
}

#questionText {
  margin-top: 14px;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.25;
}

.answers {
  list-style: none;
  padding: 0;
  margin: 18px 0;
}

.answers li {
  margin-bottom: 12px;
}

.answerOption {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 2px solid #e4ebf4;
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  font-size: 1.04rem;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.answerOption:hover {
  border-color: #b7cdf6;
  background: #fbfdff;
  transform: translateX(2px);
}

.answerOption input {
  margin-top: 4px;
}

.answerOption.correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.answerOption.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.quizActions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feedback {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: #f6f9ff;
  border: 1px solid #cfe0fb;
  color: #24324a;
}

.feedback p {
  margin: 6px 0;
}

.historyHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.small {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
}

th,
td {
  border-bottom: 1px solid #edf1f7;
  text-align: left;
  padding: 10px 8px;
  font-size: 0.92rem;
}

th {
  color: #43556e;
  background: #f8fafc;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: none;
}

.completedTestsActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.importLabel {
  cursor: pointer;
  display: inline-block;
  margin: 0;
  font-weight: normal;
}

.completedTestsTable button.linkish {
  background: none;
  border: none;
  color: #1e73d8;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 35, 55, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  overflow-y: auto;
  z-index: 50;
}

.modalBackdrop.hidden {
  display: none;
}

.modal {
  background: #fff;
  border-radius: 22px;
  border: 1px solid var(--line);
  max-width: 720px;
  width: 100%;
  padding: 16px;
  margin: 24px auto;
  box-shadow: 0 20px 60px rgba(15, 30, 55, 0.18);
}

.modalHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modalHeader h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modalMeta {
  margin: 12px 0;
  font-size: 0.92rem;
  color: #3f5876;
}

.modalLegacy {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warning-soft);
  border: 1px solid #f0d090;
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.modalLegacy.hidden {
  display: none;
}

.toggleRow {
  margin-bottom: 12px;
}

.toggleRow.hidden {
  display: none;
}

.toggleLabel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.modalQuestions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
  padding-right: 4px;
}

.reviewBlock {
  border: 1px solid #e3ebf7;
  border-radius: 16px;
  padding: 12px;
  background: #fafcff;
}

.reviewBlock.wrongOnly {
  border-color: #f0c4c4;
  background: var(--danger-soft);
}

.reviewPrompt {
  font-weight: 700;
  margin: 0 0 8px;
}

.reviewTopic {
  font-size: 0.85rem;
  color: #5a6f88;
  margin: 0 0 8px;
}

.reviewAnswers {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.reviewExplanation {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid #e3ebf7;
  font-size: 0.92rem;
  color: #2c3d55;
}

.legacyPill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff0cc;
  color: #7a5a00;
  margin-left: 6px;
  vertical-align: middle;
}

.rowBlock {
  margin-top: 14px;
  flex-wrap: wrap;
}

.tightTop {
  margin-top: 4px;
}

.h3like {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.focusPracticePanel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #d8e6ff;
  border-radius: 18px;
  background: linear-gradient(180deg, #f7fbff, #eef5ff);
}

.focusBtns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.teachSection .teachHeading {
  margin-bottom: 10px;
}

.teachSection {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 253, 255, 0.96)),
    var(--card);
}

.teachDetails {
  border: 1px solid #dbe4f0;
  border-radius: 16px;
  padding: 0 14px;
  margin-bottom: 10px;
  background: #fafcff;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.teachDetails:hover {
  border-color: #b7cdf6;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.07);
}

.teachDetails[open] {
  background: #fff;
  border-color: #b7cdf6;
}

.teachDetails summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 700;
  color: #173b76;
  list-style-position: outside;
}

.teachBody {
  padding: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #2c3d55;
}

.teachBody p {
  margin: 0 0 10px;
}

.teachBody p:last-child {
  margin-bottom: 0;
}

.teachBody code {
  font-size: 0.9em;
  padding: 1px 5px;
  border-radius: 4px;
  background: #eef2f8;
  border: 1px solid #dbe4f0;
}

.nowrap {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .app {
    padding: 14px 10px 28px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    border-radius: 20px;
  }

  .historyHeader {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .card {
    padding: 18px;
    border-radius: 18px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .focusBtns,
  .quizActions,
  .completedTestsActions {
    width: 100%;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .modal {
    margin: 0 auto;
    border-radius: 18px;
  }
}
