:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #64707d;
  --line: #d9e0e7;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --accent: #0b6e4f;
  --accent-dark: #07553e;
  --blue: #22577a;
  --warning: #a33d2f;
  --success-bg: #e7f6ef;
  --error-bg: #fdecea;
  --shadow: 0 22px 55px rgba(23, 32, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #eef6f3 0%, #f8fafc 44%, #eef3f8 100%);
}

button,
input,
select {
  font: inherit;
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(980px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 18px;
  min-height: 520px;
  padding: 48px;
  color: #fff;
  background:
    linear-gradient(rgba(13, 37, 54, 0.1), rgba(13, 37, 54, 0.78)),
    url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=1400&q=80") center/cover;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-hero h1,
.topbar h1,
.login-panel h2,
.quiz-surface h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-hero h1 {
  max-width: 560px;
  font-size: clamp(2.4rem, 7vw, 5.7rem);
  line-height: 0.96;
}

.login-hero p {
  max-width: 510px;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.08rem;
  line-height: 1.55;
}

.login-panel,
.study-panel,
.quiz-surface {
  background: rgba(255, 255, 255, 0.92);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 42px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-panel h2 {
  font-size: 2rem;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
}

button,
.logout {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.login-panel button,
#nextButton,
.secondary-button {
  min-height: 48px;
  padding: 13px 18px;
}

.login-panel button,
#nextButton {
  color: #fff;
  background: var(--accent);
}

.login-panel button:hover,
#nextButton:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  font-size: clamp(1.6rem, 4vw, 2.7rem);
}

.logout {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  color: var(--blue);
  background: #eaf1f6;
}

.app-layout {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px);
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
}

.study-panel {
  align-self: start;
  display: grid;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(23, 32, 42, 0.08);
}

.metric-value {
  display: block;
  color: var(--blue);
  font-size: 3rem;
  line-height: 1;
  font-weight: 900;
}

.metric-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.saved-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.saved-progress div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.saved-progress strong {
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
}

.saved-progress span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.secondary-button {
  color: var(--accent);
  background: #e6f4ee;
}

.progress-box {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf0;
}

#progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.quiz-surface {
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(22px, 4vw, 40px);
  box-shadow: var(--shadow);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

#topicBadge {
  padding: 7px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  text-transform: capitalize;
}

.seen-pill {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: #e6f4ee;
}

.quiz-surface h2 {
  max-width: 850px;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  line-height: 1.18;
}

.visual-prompt {
  display: flex;
  justify-content: center;
  margin: 22px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.visual-prompt[hidden] {
  display: none;
}

.visual-prompt img {
  display: block;
  width: auto;
  max-width: min(100%, 360px);
  max-height: 300px;
  object-fit: contain;
}

.options {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.option-button {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.option-button:hover {
  border-color: var(--blue);
  box-shadow: 0 10px 24px rgba(34, 87, 122, 0.12);
}

.option-button span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: var(--blue);
  background: #edf4f8;
}

.option-button strong {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.42;
}

.option-button.correct {
  border-color: var(--accent);
  background: var(--success-bg);
}

.option-button.incorrect {
  border-color: var(--warning);
  background: var(--error-bg);
}

.feedback {
  margin-top: 24px;
  padding: 18px;
  border-radius: 8px;
  line-height: 1.5;
}

.feedback h3 {
  margin: 0 0 8px;
}

.feedback p {
  margin: 8px 0 0;
}

.feedback.is-correct {
  border: 1px solid #a9dac5;
  background: var(--success-bg);
}

.feedback.is-incorrect {
  border: 1px solid #efb5ae;
  background: var(--error-bg);
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

.session-summary {
  display: grid;
  gap: 22px;
}

.summary-score {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-score div {
  display: grid;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.summary-score strong {
  color: var(--blue);
  font-size: 1.65rem;
  line-height: 1;
}

.summary-score span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.review-item {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-item.is-correct {
  border-color: #a9dac5;
  background: var(--success-bg);
}

.review-item.is-incorrect {
  border-color: #efb5ae;
  background: var(--error-bg);
}

.review-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.review-heading span {
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
}

.review-item.is-correct .review-heading span {
  background: var(--accent);
}

.review-item.is-incorrect .review-heading span {
  background: var(--warning);
}

.review-item h3,
.review-item p {
  margin: 0;
}

.review-item h3 {
  font-size: 1rem;
  line-height: 1.35;
}

.review-item p {
  color: var(--ink);
  line-height: 1.45;
}

@media (max-width: 840px) {
  .login-shell,
  .app-layout {
    grid-template-columns: 1fr;
  }

  .app-layout {
    gap: 14px;
  }

  .quiz-surface {
    order: 1;
  }

  .study-panel {
    order: 2;
  }

  .login-hero {
    min-height: 360px;
    padding: 34px;
  }

  .login-panel {
    padding: 30px;
  }

  .study-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  body {
    background: #f7f9fb;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    padding: 12px 14px;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: 1.45rem;
  }

  .logout {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .app-layout {
    padding: 10px;
  }

  .quiz-surface,
  .study-panel {
    padding: 14px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(23, 32, 42, 0.08);
  }

  .quiz-surface {
    min-height: auto;
  }

  .question-meta {
    gap: 7px;
    margin-bottom: 12px;
    font-size: 0.72rem;
  }

  #topicBadge,
  .seen-pill {
    padding: 6px 8px;
  }

  #sourceText {
    display: none;
  }

  .quiz-surface h2 {
    font-size: 1.35rem;
    line-height: 1.22;
  }

  .options {
    gap: 10px;
    margin-top: 16px;
  }

  .visual-prompt {
    margin-top: 14px;
    padding: 12px;
  }

  .visual-prompt img {
    max-height: 190px;
  }

  .option-button {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
    min-height: 62px;
    padding: 10px;
  }

  .option-button span {
    width: 36px;
    height: 36px;
  }

  .option-button strong {
    font-size: 0.95rem;
    line-height: 1.32;
  }

  .feedback {
    margin-top: 16px;
    padding: 14px;
    font-size: 0.94rem;
  }

  .quiz-actions {
    margin-top: 16px;
  }

  #nextButton {
    width: 100%;
  }

  .study-panel {
    gap: 14px;
  }

  .session-summary {
    gap: 16px;
  }

  .summary-score {
    gap: 6px;
  }

  .summary-score div {
    padding: 10px 8px;
  }

  .summary-score strong {
    font-size: 1.28rem;
  }

  .summary-score span,
  .review-heading {
    font-size: 0.68rem;
  }

  .review-item {
    padding: 12px;
  }

  .review-item h3 {
    font-size: 0.96rem;
  }

  .review-item p {
    font-size: 0.92rem;
  }

  .metric-value {
    font-size: 2.2rem;
  }

  .saved-progress {
    gap: 6px;
  }

  .saved-progress div {
    padding: 8px 6px;
  }

  .saved-progress span {
    font-size: 0.62rem;
  }
}
