:root {
  --navy: #162b4d;
  --blue: #2c62b6;
  --pale: #eef3fa;
  --green: #16855b;
  --red: #c84a4a;
  --gray: #68758a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--navy);
  background: linear-gradient(145deg, #eef3fa 0%, #fafcfe 100%);
}
button, input { font: inherit; }
.hidden { display: none !important; }
.app-shell { width: min(680px, calc(100% - 24px)); margin: 24px auto; }
.site-footer {
  padding: 16px 8px 0;
  color: var(--gray);
  font-size: 13px;
  text-align: center;
}
.card {
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 40px rgba(22,43,77,.12);
  padding: 28px;
}
.login-banner {
  display: block;
  width: 100%;
  max-height: 210px;
  margin: -28px -28px 24px;
  object-fit: cover;
  object-position: center;
  width: calc(100% + 56px);
  border-radius: 18px 18px 0 0;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  color: white; background: var(--navy); font-weight: 800; font-size: 22px;
}
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 2px 0 0; color: var(--gray); }
.brand.compact { margin: 0; }
.brand.compact h1 { font-size: 18px; max-width: 420px; line-height: 1.2; }
.brand.compact .brand-mark { width: 38px; height: 38px; border-radius: 9px; font-size: 18px; }
.topbar, .quiz-topbar { display: flex; justify-content: space-between; align-items: center; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 20px; border-bottom: 1px solid #dfe5ed; }
.tab { border: 0; background: transparent; padding: 12px; color: var(--gray); cursor: pointer; }
.tab.active { color: var(--navy); border-bottom: 3px solid var(--blue); font-weight: 700; }
form label { display: block; margin: 14px 0 7px; font-weight: 700; }
input {
  width: 100%; border: 1px solid #ccd6e3; border-radius: 10px;
  padding: 13px 14px; outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44,98,182,.12); }
.primary, .secondary {
  width: 100%; min-height: 48px; border-radius: 10px; margin-top: 16px;
  border: 0; font-weight: 800; cursor: pointer;
}
.primary { background: var(--navy); color: white; }
.secondary { background: var(--pale); color: var(--navy); }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 750; cursor: pointer; padding: 8px; }
.error { min-height: 21px; color: var(--red); margin: 12px 0 0; }
.welcome { margin: 24px 0 6px; color: var(--gray); }
h2 { margin: 8px 0; font-size: 24px; }
.subtitle { color: var(--gray); margin: 0 0 18px; }
.ai-notice {
  margin: 0 0 18px;
  padding: 13px 14px;
  border: 1px solid #e5bd65;
  border-left: 5px solid #d39c24;
  border-radius: 10px;
  color: #614714;
  background: #fff8e5;
  line-height: 1.45;
}
.ai-notice strong { display: block; margin-bottom: 3px; }
.mode-grid { display: grid; gap: 12px; }
.mode-card {
  display: grid; grid-template-columns: 54px 1fr 24px; gap: 12px; align-items: center;
  text-align: left; border: 1px solid #dde5ef; border-radius: 13px;
  background: white; padding: 15px; cursor: pointer;
}
.mode-card:hover { border-color: var(--blue); background: #f8fbff; }
.mode-card strong, .mode-card small { display: block; }
.mode-card small { color: var(--gray); margin-top: 4px; }
.mode-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 10px; background: #dce7f7; color: var(--blue); font-weight: 900; font-size: 13px; }
.mode-icon.all { background: #dff3ea; color: var(--green); }
.arrow { font-size: 30px; color: #9ba7b7; }
.quiz-card { padding: 22px 28px 28px; }
.quiz-topbar { min-height: 38px; }
.progress-track { height: 6px; margin: 12px 0 26px; border-radius: 99px; background: #edf1f6; overflow: hidden; }
#progress-bar { height: 100%; width: 5%; border-radius: 99px; background: var(--blue); transition: width .2s; }
.question-title { font-size: 21px; line-height: 1.35; margin: 0 0 18px; }
.option {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid #d9e1ec; border-radius: 11px;
  padding: 14px; margin: 9px 0; cursor: pointer;
}
.option:has(input:checked) { border-color: var(--blue); background: #f1f6fd; }
.option input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue); }
.option span { line-height: 1.35; }
.option.is-correct { border-color: var(--green); background: #edf8f3; }
.option.is-incorrect { border-color: var(--red); background: #fff1f1; }
.answer-feedback {
  display: none;
  margin-top: 14px;
  border: 1px solid #d9e1ec;
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.4;
}
.answer-feedback.visible { display: block; }
.answer-feedback.correct { border-color: #9bcdb7; background: #edf8f3; }
.answer-feedback.incorrect { border-color: #dfaaaa; background: #fff1f1; }
.answer-feedback p { margin: 7px 0; }
.answer-feedback .source { margin-top: 8px; color: var(--gray); font-size: 13px; }
.quiz-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.quiz-footer button { margin: 0; }
.result { text-align: center; padding: 28px 0 12px; }
.result-ring {
  width: 150px; height: 150px; margin: 0 auto 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--blue) var(--percent, 0%), #edf1f6 0);
  position: relative;
}
.result-ring::after { content: ""; position: absolute; width: 116px; height: 116px; border-radius: 50%; background: white; }
.result-ring strong { z-index: 1; font-size: 32px; }
.result p { color: var(--gray); }
.result.pass h2 { color: var(--green); }
#history-list { margin-top: 16px; }
.history-item { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid #edf1f6; padding: 14px 2px; }
.history-item span { color: var(--gray); }
.leaderboard-item {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px 2px;
  border-bottom: 1px solid #edf1f6;
}
.rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  background: var(--navy);
  font-weight: 800;
}
.leaderboard-item small { display: block; color: var(--gray); margin-top: 3px; }
.leaderboard-score { text-align: right; font-size: 18px; }
.leaderboard-score small { font-size: 12px; }
.leaderboard-score .passed { color: var(--green); font-weight: 700; }
@media (max-width: 520px) {
  .app-shell { width: calc(100% - 16px); margin: 8px auto; }
  .card { padding: 20px 16px; border-radius: 14px; }
  .login-banner {
    width: calc(100% + 32px);
    max-height: 150px;
    margin: -20px -16px 20px;
    border-radius: 14px 14px 0 0;
  }
  .quiz-card { padding: 16px; min-height: calc(100vh - 16px); }
  .brand { margin-bottom: 18px; }
  .mode-card { grid-template-columns: 48px 1fr 18px; padding: 12px; }
  .mode-icon { width: 48px; height: 48px; }
  .question-title { font-size: 18px; }
}
