:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #6a737d;
  --border: #e1e4e8;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --correct: #1a7f37;
  --correct-bg: #dafbe1;
  --wrong: #cf222e;
  --wrong-bg: #ffebe9;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, 'Noto Sans Hebrew', sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

body { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow);
}
.header-title { font-weight: 600; flex: 0 1 auto; }
.header-stats { margin-inline-start: auto; color: var(--muted); font-size: 14px; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 4px 8px;
}
.link-btn:hover { text-decoration: underline; }

main { max-width: 920px; margin: 0 auto; padding: 24px 20px 80px; }

/* ---------- Home ---------- */
.intro h1 { margin: 0 0 8px; font-size: 26px; }
.intro p { margin: 0 0 24px; color: var(--muted); }

.exam-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.exam-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exam-card h3 { margin: 0; font-size: 18px; }
.exam-card .sub { color: var(--muted); font-size: 13px; }

.progress-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.progress-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.progress-fill.correct { background: var(--correct); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #fff; color: var(--wrong); border: 1px solid var(--border); }
.btn:disabled { opacity: .5; cursor: default; }

/* Mix builder */
.mix-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.mix-subjects { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.mix-subjects label {
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  background: #fff;
}
.mix-subjects input { margin-inline-end: 6px; }
.mix-subjects label.active { background: var(--accent-soft); border-color: var(--accent); }
.mix-options { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 14px; }
.mix-options label { font-size: 14px; color: var(--muted); }

/* ---------- Quiz ---------- */
.quiz-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); margin-bottom: 12px;
}

.qbox {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.qstem {
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.qfig {
  margin: 0 0 18px;
  text-align: center;
}
.qfig img {
  max-width: 100%;
  max-height: 420px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
  cursor: zoom-in;
}

.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.opt-btn {
  display: block;
  width: 100%;
  text-align: start;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font: inherit;
  line-height: 1.6;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: pre-wrap;
}
.opt-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.opt-btn:disabled { cursor: default; }
.opt-btn.picked-correct { background: var(--correct-bg); border-color: var(--correct); color: #04321b; }
.opt-btn.picked-wrong   { background: var(--wrong-bg);   border-color: var(--wrong);   color: #4d0a0e; }
.opt-btn.reveal-correct {
  border-color: var(--correct);
  background: linear-gradient(180deg, #fff, #eafff0);
}

.explanation {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.explanation h4 { margin: 0 0 10px; font-size: 16px; color: var(--accent); }
.explanation p { margin: 0 0 10px; }
.exp-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.actions {
  display: flex; gap: 10px; justify-content: space-between; margin-top: 22px; flex-wrap: wrap;
}
.actions .left, .actions .right { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  cursor: zoom-out;
}
.lightbox img { max-width: 95vw; max-height: 95vh; }

/* English/Latin terms inline within Hebrew should stay LTR-ish; the source already embeds bidi marks. */

@media (max-width: 600px) {
  main { padding: 14px 12px 60px; }
  .qbox { padding: 16px; }
}
