/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --brand-blue:    #005f73;
  --brand-blue-dk: #003d47;
  --brand-green:   #2a9d8f;
  --brand-green-dk:#1a6b61;
  --brand-orange:  #e9c46a;
  --brand-red:     #d90429;
  --bg:            #f4f7f6;
  --bg-card:       #ffffff;
  --bg-accent:     #e8f7f4;
  --text:          #222;
  --text-muted:    #666;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,.09);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
button { cursor: pointer; border: none; background: none; font: inherit; }
a { color: var(--brand-green); }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--brand-blue);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.app-header img { height: 36px; }
.app-header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: .01em; flex: 1; }
.header-copyright { font-size: .75rem; opacity: .65; white-space: nowrap; }

.screen { display: none; }
.screen.active { display: block; }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

/* ── Start Screen ───────────────────────────────────────────────────────────── */
.start-intro { font-size: .95rem; color: var(--text-muted); margin-bottom: 20px; }
.start-intro strong { color: var(--brand-blue); }

.section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.module-toggle {
  padding: 8px 10px;
  border-radius: 6px;
  border: 2px solid #ddd;
  background: #fafafa;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  transition: all .15s;
}
.module-toggle .mod-num { font-size: .68rem; color: var(--text-muted); display: block; }
.module-toggle.selected {
  border-color: var(--brand-blue);
  background: var(--bg-accent);
  color: var(--brand-blue);
}
.module-toggle.selected .mod-num { color: var(--brand-green); }

.select-controls { display: flex; gap: 8px; margin-bottom: 20px; }
.btn-text {
  font-size: .78rem;
  color: var(--brand-green);
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
}

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.mode-card {
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  border: 2px solid transparent;
  transition: all .15s;
  cursor: pointer;
}
.mode-card:disabled { opacity: .45; cursor: not-allowed; }
.mode-card-learn { background: var(--bg-accent); border-color: var(--brand-green); }
.mode-card-exam  { background: #fff8e6; border-color: var(--brand-orange); }
.mode-card:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.mode-icon  { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.mode-title { font-size: 1rem; font-weight: 700; color: var(--brand-blue); display: block; }
.mode-desc  { font-size: .8rem; color: var(--text-muted); margin-top: 4px; display: block; }

/* ── Quiz Screen ────────────────────────────────────────────────────────────── */
.quiz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.progress-wrap { flex: 1; }
.progress-label { font-size: .78rem; color: var(--text-muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.progress-track { height: 6px; background: #e0e0e0; border-radius: 3px; overflow: hidden; }
.progress-fill  { height: 100%; background: var(--brand-blue); border-radius: 3px; transition: width .3s; }

.mode-badge {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 4px 10px; border-radius: 20px;
}
.badge-learn { background: var(--bg-accent); color: var(--brand-green-dk); }
.badge-exam  { background: #fff8e6; color: #7a5500; }

.question-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.module-badge {
  font-size: .72rem; font-weight: 700; background: var(--brand-blue); color: #fff;
  padding: 3px 9px; border-radius: 20px;
}
.multi-hint {
  font-size: .78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 20px; border: 1px solid;
}
.hint-multi  { color: var(--brand-green-dk); background: var(--bg-accent); border-color: var(--brand-green); }
.hint-single { color: var(--brand-blue);     background: #eaf2f4;          border-color: var(--brand-blue); }

#question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--brand-blue-dk);
  margin-bottom: 18px;
  line-height: 1.55;
}
.negative-highlight {
  background: #ffe0e0; color: var(--brand-red);
  padding: 0 3px; border-radius: 3px; font-weight: 800;
}

/* ── Answers ────────────────────────────────────────────────────────────────── */
#answers-container { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }

.answer-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  background: #fafafa;
  cursor: pointer;
  transition: all .14s;
}
.answer-item:hover { border-color: var(--brand-blue); background: var(--bg-accent); }
.answer-item.selected-answer { border-color: var(--brand-blue); background: var(--bg-accent); }
.answer-item.correct  { border-color: var(--brand-green); background: #e8f7f0; pointer-events: none; }
.answer-item.wrong    { border-color: var(--brand-red);   background: #fde8ec; pointer-events: none; }
.answer-item.neutral  { opacity: .6; pointer-events: none; }

.answer-badge {
  min-width: 26px; height: 26px;
  background: var(--brand-blue); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0;
}
.answer-item.correct  .answer-badge { background: var(--brand-green); }
.answer-item.wrong    .answer-badge { background: var(--brand-red); }
.answer-item.neutral  .answer-badge { background: #aaa; }
.answer-text { font-size: .9rem; line-height: 1.5; }

/* ── Explanation ────────────────────────────────────────────────────────────── */
.explanation-box {
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border-left: 4px solid;
}
.exp-correct { background: #e8f7f0; border-color: var(--brand-green); }
.exp-wrong   { background: #fde8ec; border-color: var(--brand-red); }
.exp-header  { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; font-size: .9rem; }
.exp-correct .exp-header { color: var(--brand-green-dk); }
.exp-wrong   .exp-header { color: var(--brand-red); }
#exp-icon { font-size: 1.1rem; }
#explanation-text { font-size: .88rem; line-height: 1.55; color: var(--text); }
#explanation-ref  { font-size: .75rem; color: var(--text-muted); margin-top: 8px; font-style: italic; }

/* ── Quiz action buttons ─────────────────────────────────────────────────────── */
.quiz-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }

.btn-primary {
  background: var(--brand-blue); color: #fff;
  padding: 10px 22px; border-radius: 6px; font-weight: 700; font-size: .9rem;
  transition: background .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { background: var(--brand-blue-dk); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-accent); color: var(--brand-blue);
  padding: 10px 18px; border-radius: 6px; font-weight: 600; font-size: .88rem;
  border: 2px solid var(--brand-blue); transition: background .15s;
}
.btn-secondary:hover { background: #d0eee9; }

.btn-submit-exam {
  background: #e9c46a; color: #5a3800;
  padding: 10px 22px; border-radius: 6px; font-weight: 700; font-size: .9rem;
}
.btn-submit-exam:hover { background: #d4b054; }

.nav-pair { display: flex; gap: 8px; }

/* ── Exam nav dots ───────────────────────────────────────────────────────────── */
#exam-nav {
  display: flex; flex-wrap: wrap; gap: 6px;
  background: var(--bg-card); border-radius: var(--radius);
  padding: 12px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.nav-dot {
  width: 30px; height: 30px; border-radius: 50%;
  font-size: .75rem; font-weight: 700;
  background: #eee; color: var(--text-muted);
  border: 2px solid transparent; transition: all .12s;
}
.nav-dot.answered { background: var(--bg-accent); color: var(--brand-blue); border-color: var(--brand-blue); }
.nav-dot.active   { background: var(--brand-blue); color: #fff; border-color: var(--brand-blue-dk); }

/* ── Result Screen ───────────────────────────────────────────────────────────── */
.result-hero {
  text-align: center;
  padding: 28px 20px 20px;
}
.score-ring { display: block; margin: 0 auto 16px; }
.score-ring-bg   { fill: none; stroke: #e0e0e0; stroke-width: 8; }
.score-ring-fill { fill: none; stroke-width: 8; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset .6s ease, stroke .4s ease; }
.score-center { font-size: 1.5rem; font-weight: 800; fill: var(--brand-blue); }
.result-score-text { font-size: 2rem; font-weight: 800; color: var(--brand-blue); display: block; }
.result-pct-text   { font-size: 1.1rem; color: var(--text-muted); display: block; margin-bottom: 8px; }
.result-message    { font-size: .95rem; color: var(--brand-green-dk); font-weight: 600; }

.breakdown-title { font-size: .9rem; font-weight: 700; color: var(--brand-blue); margin-bottom: 12px; }
.breakdown-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.breakdown-label { width: 60px; font-size: .8rem; font-weight: 600; flex-shrink: 0; }
.breakdown-bar-wrap { flex: 1; background: #e0e0e0; border-radius: 4px; height: 10px; overflow: hidden; }
.breakdown-bar { height: 100%; border-radius: 4px; transition: width .4s; }
.breakdown-pct { font-size: .78rem; color: var(--text-muted); width: 80px; text-align: right; flex-shrink: 0; }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }

/* ── Details Screen ──────────────────────────────────────────────────────────── */
.details-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.details-topbar h2 { font-size: 1.1rem; color: var(--brand-blue); }

.detail-card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
  border-left: 4px solid;
}
.card-correct { border-color: var(--brand-green); }
.card-wrong   { border-color: var(--brand-red); }

.detail-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.detail-num    { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-blue); color: #fff; font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.detail-module { font-size: .72rem; font-weight: 700; background: var(--brand-blue); color: #fff; padding: 2px 8px; border-radius: 20px; }
.detail-status { margin-left: auto; font-size: .82rem; font-weight: 700; }
.card-correct .detail-status { color: var(--brand-green-dk); }
.card-wrong   .detail-status { color: var(--brand-red); }

.multi-hint-small { font-size: .75rem; color: var(--brand-green-dk); font-weight: 600; margin-bottom: 6px; }
.detail-question { font-size: .95rem; font-weight: 600; color: var(--brand-blue-dk); margin-bottom: 12px; line-height: 1.5; }

.detail-answers { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.detail-answer {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 8px 11px; border-radius: 6px; font-size: .85rem;
  background: #f5f5f5;
}
.d-correct { background: #e8f7f0; }
.d-wrong   { background: #fde8ec; }
.d-correct .answer-badge { background: var(--brand-green); }
.d-wrong   .answer-badge { background: var(--brand-red); }

.detail-explanation {
  font-size: .85rem; line-height: 1.55; color: var(--text);
  background: #f9f9f9; padding: 10px 12px; border-radius: 6px;
}
.detail-ref { font-size: .75rem; color: var(--text-muted); margin-top: 6px; font-style: italic; }
.no-errors { text-align: center; color: var(--brand-green-dk); font-weight: 700; padding: 30px 0; font-size: 1.1rem; }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center; font-size: .7rem; color: var(--text-muted);
  padding: 12px; border-top: 1px solid #e0e0e0; margin-top: 20px;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .mode-cards { grid-template-columns: 1fr; }
  .quiz-actions { flex-direction: column; }
  .result-actions { flex-direction: column; align-items: stretch; }
  .result-actions .btn-primary, .result-actions .btn-secondary { text-align: center; justify-content: center; }
}
