:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1b2530;
  --ink-soft: #52606d;
  --line: #dde3e9;
  --brand: #0f3d4c;
  --brand-2: #17657a;
  --accent: #e0a526;
  --ok: #1d7a46;
  --ok-bg: #e5f5ec;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --warn-bg: #fff6dd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 42, 56, .06), 0 4px 16px rgba(16, 42, 56, .06);
  --font: system-ui, -apple-system, "Segoe UI", "Arial Hebrew", Arial, "Noto Sans Hebrew", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.6; font-size: 17px; }
a { color: var(--brand-2); }
button { font: inherit; }
.skip-link { position: absolute; right: -9999px; }
.skip-link:focus { right: 12px; top: 12px; z-index: 50; background: #fff; padding: 8px 12px; border-radius: 8px; }

/* Top bar */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.mainnav { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.mainnav a { color: #d8e7ec; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: .95rem; }
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mainnav a.active { background: #fff; color: var(--brand); font-weight: 600; }
.disclaimer { background: var(--warn-bg); color: #5c4400; text-align: center; font-size: .9rem; padding: 6px 12px; border-bottom: 1px solid #f0dfa8; }

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 40px; outline: none; }
.footer { max-width: 1040px; margin: 0 auto; padding: 0 16px 32px; color: var(--ink-soft); font-size: .85rem; }

h1 { font-size: 1.7rem; margin: 0 0 6px; line-height: 1.3; }
h2 { font-size: 1.25rem; margin: 28px 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
.lead { color: var(--ink-soft); margin: 0 0 18px; }
.muted { color: var(--ink-soft); }
.small { font-size: .88rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 1rem; transition: background .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-2); color: #fff; }
.btn-primary:hover { background: var(--brand); }
.btn-secondary { background: #fff; color: var(--brand); border-color: var(--line); }
.btn-secondary:hover { background: #eef4f6; }
.btn-danger { background: #fff; color: var(--bad); border-color: #efc4bf; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ghost { background: transparent; color: var(--brand-2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Hero */
.hero { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.hero h1 { color: #fff; }
.hero p { color: #d8e7ec; margin: 0 0 18px; max-width: 640px; }
.hero .btn-secondary { border-color: transparent; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .num { font-size: 1.6rem; font-weight: 700; color: var(--brand); line-height: 1.2; }
.stat .lbl { color: var(--ink-soft); font-size: .9rem; }

/* Topic list */
.topic-card { display: flex; flex-direction: column; gap: 10px; }
.topic-card h3 { font-size: 1rem; }
.topic-meta { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: .85rem; }
.bar { height: 8px; background: #e7ecf0; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.bar.acc > span { background: var(--ok); }
.bar.acc.low > span { background: var(--bad); }
.bar.acc.mid > span { background: var(--accent); }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: #e8f0f3; color: var(--brand); font-weight: 600; }
.tag.final { background: #fdf0d2; color: #7a5300; }
.tag.weak { background: var(--bad-bg); color: var(--bad); }

/* Question */
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; color: var(--ink-soft); font-size: .92rem; }
.q-text { font-size: 1.18rem; font-weight: 600; margin: 4px 0 18px; white-space: pre-line; }
.options { display: grid; gap: 10px; }
.option { display: flex; gap: 12px; align-items: flex-start; text-align: start; width: 100%; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; color: var(--ink); font-size: 1.02rem; line-height: 1.5; transition: border-color .12s, background .12s; }
.option:hover:not([disabled]) { border-color: var(--brand-2); background: #f3f8fa; }
.option .letter { flex: 0 0 30px; height: 30px; border-radius: 50%; background: #eef2f5; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--brand); }
.option.selected { border-color: var(--brand-2); background: #eaf4f7; }
.option.selected .letter { background: var(--brand-2); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.correct .letter { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .letter { background: var(--bad); color: #fff; }
.option[disabled] { cursor: default; }
.option .opt-text { direction: rtl; unicode-bidi: plaintext; }

.feedback { margin-top: 18px; border-radius: 12px; padding: 16px; border: 1px solid var(--line); background: #fafcfd; }
.feedback .verdict { font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.bad .verdict { color: var(--bad); }
.feedback .source { margin-top: 10px; font-size: .9rem; color: var(--ink-soft); border-top: 1px dashed var(--line); padding-top: 8px; }
.lowconf { margin-top: 10px; background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; font-size: .88rem; color: #5c4400; }
.q-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }

/* Selector rows */
.choice-list { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: center; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--brand-2); background: #eaf4f7; }
.choice input { accent-color: var(--brand-2); width: 18px; height: 18px; }
.choice .c-title { font-weight: 600; }
.choice .c-note { color: var(--ink-soft); font-size: .88rem; }
select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; width: 100%; max-width: 520px; }
label.field { display: block; font-weight: 600; margin: 16px 0 6px; }

/* Exam */
.exam-bar { position: sticky; top: 56px; z-index: 10; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; box-shadow: var(--shadow); flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.2rem; color: var(--brand); direction: ltr; }
.timer.low { color: var(--bad); }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.palette button { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; color: var(--ink-soft); position: relative; }
.palette button.answered { background: #dcecf1; color: var(--brand); border-color: #b9d6df; }
.palette button.current { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.palette button.flagged::after { content: ""; position: absolute; top: 3px; left: 3px; width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
.flag-btn.on { background: #fdf0d2; border-color: #f0d48a; color: #7a5300; }

/* Results */
.score-ring { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.score-num { font-size: 3rem; font-weight: 800; line-height: 1; }
.score-num.pass { color: var(--ok); }
.score-num.fail { color: var(--bad); }
.badge { display: inline-block; padding: 4px 12px; border-radius: 99px; font-weight: 700; }
.badge.pass { background: var(--ok-bg); color: var(--ok); }
.badge.fail { background: var(--bad-bg); color: var(--bad); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: start; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; font-size: .85rem; }
.table-wrap { overflow-x: auto; }
details.review { border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 8px; }
details.review summary { cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: baseline; list-style: none; }
details.review summary::-webkit-details-marker { display: none; }
details.review .mark { font-weight: 800; }
details.review .mark.ok { color: var(--ok); }
details.review .mark.bad { color: var(--bad); }
details.review .body { padding: 0 14px 14px; }

.empty { text-align: center; padding: 30px 16px; color: var(--ink-soft); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 25, 35, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal { background: #fff; border-radius: 16px; max-width: 440px; width: 100%; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h2 { margin-top: 0; }

.info-list li { margin-bottom: 6px; }
.noscript { padding: 20px; text-align: center; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .topbar-inner { padding: 8px 12px; gap: 8px; }
  .mainnav { margin-inline-start: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .mainnav a { white-space: nowrap; padding: 5px 10px; }
  .exam-bar { top: 92px; }
  h1 { font-size: 1.4rem; }
  .card { padding: 16px; }
  .q-text { font-size: 1.08rem; }
  .hero { padding: 22px 18px; }
}
@media print {
  .topbar, .disclaimer, .footer, .btn { display: none !important; }
}

[data-app-shell][hidden] { display: none; }
.access-gate { width: min(100% - 2rem, 28rem); margin: 3rem auto; }
.access-gate label { display: block; font-weight: 700; margin-top: 1rem; }
.access-gate input { width: 100%; padding: .6rem; font: inherit; border: 1px solid #64777e; border-radius: 6px; }
#access-error { color: #982f27; }
