:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1f2430;
  --muted: #5d6474;
  --border: #e2ddd2;
  --primary: #1d4f91;
  --primary-ink: #ffffff;
  --primary-soft: #e3ecf8;
  --accent: #c8702a;
  --ok: #1f7a4d;
  --ok-soft: #e1f3e9;
  --bad: #b3372f;
  --bad-soft: #fbe6e4;
  --warn-soft: #fdf1dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 33, .05), 0 6px 20px rgba(20, 24, 33, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171d; --surface: #1c2028; --surface-2: #242934; --text: #e8eaef; --muted: #a0a7b5;
    --border: #323846; --primary: #6fa1e6; --primary-ink: #0f1420; --primary-soft: #1f2e45;
    --accent: #e3995c; --ok: #5cc48f; --ok-soft: #173326; --bad: #f08a80; --bad-soft: #3a1f1d; --warn-soft: #3a2e17;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Heebo", "Arial Hebrew", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 17px;
}
a { color: var(--primary); }
button, input, textarea, select { font: inherit; color: inherit; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* ---------- כותרת עליונה ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .wrap > div:last-child { flex-shrink: 0; }
.brand { min-width: 0; font-weight: 800; font-size: 18px; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
}

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 8px 16px; cursor: pointer; text-decoration: none; color: var(--text); font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 4px 10px; font-size: 14px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- כרטיסים ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 24px; }

.hero { padding: 36px 0 20px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 5vw, 36px); line-height: 1.2; }
.hero p { margin: 0; color: var(--muted); }

.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s; }
.progress-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.progress-row .progress { flex: 1; }
.progress-label { font-size: 14px; color: var(--muted); white-space: nowrap; }

/* ---------- יחידות ושיעורים ---------- */
.unit { margin-bottom: 18px; overflow: hidden; }
.unit-head { padding: 18px 22px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.unit-head h2 { margin: 0; font-size: 20px; }
.unit-head p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.unit-num { color: var(--accent); font-weight: 700; font-size: 14px; }
.lesson-list { list-style: none; margin: 0; padding: 0 0 8px; }
.lesson-link {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px; text-decoration: none; color: var(--text);
  border-top: 1px solid var(--border);
}
.lesson-link:hover { background: var(--surface-2); }
.lesson-link .title { flex: 1; }
.lesson-link .meta { color: var(--muted); font-size: 14px; }
.check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.check.done { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------- שיעור ---------- */
.crumbs { font-size: 14px; color: var(--muted); padding: 20px 0 4px; }
.crumbs a { color: var(--muted); }
.lesson-title { margin: 0 0 18px; font-size: clamp(24px, 4.5vw, 32px); line-height: 1.25; }
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 22px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose h3 { margin: 18px 0 6px; font-size: 20px; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-inline-start: 22px; }
.section-title { font-size: 21px; margin: 32px 0 12px; display: flex; align-items: center; gap: 10px; }
.section-title .count { font-size: 14px; color: var(--muted); font-weight: 400; }

/* ---------- תרגילים ---------- */
.ex { padding: 20px 22px; margin-bottom: 14px; }
.ex-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.ex-tag { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }
.ex-num { font-size: 14px; color: var(--muted); }
.hint-btn { margin-inline-start: auto; color: var(--accent); border-color: var(--accent); }
.hint-box {
  margin: -4px 0 14px; padding: 12px 16px; border-radius: 10px; background: var(--warn-soft);
  border-inline-start: 4px solid var(--accent); white-space: pre-line; font-size: 16px;
}
.hint-title { display: block; color: var(--accent); margin-bottom: 2px; }
.ex-q { font-weight: 600; margin: 0 0 14px; white-space: pre-line; }
.ex-q strong, .fill-text strong { font-weight: 800; color: var(--primary); }
.options { display: grid; gap: 8px; margin-bottom: 14px; }
.option {
  text-align: start; border: 1.5px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; display: flex; gap: 10px; align-items: center;
}
.option:hover:not(:disabled) { border-color: var(--primary); }
.option .letter {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.missed { border-color: var(--ok); border-style: dashed; }
.option.multi .letter { border-radius: 6px; }
.option.multi.selected .letter, .option.multi.correct .letter { background: var(--primary); color: var(--primary-ink); }
.option:disabled { cursor: default; }
.fill-text { line-height: 2.3; margin-bottom: 14px; white-space: pre-line; }
.fill-text .blank { line-height: 1.5; margin-block: 2px; }
.sample > div, .feedback { white-space: pre-line; }
.blank {
  border: 0; border-bottom: 2px solid var(--primary); background: var(--primary-soft); border-radius: 6px 6px 0 0;
  padding: 2px 8px; width: 9em; max-width: 100%; text-align: center;
}
.blank.correct { border-color: var(--ok); background: var(--ok-soft); }
.blank.wrong { border-color: var(--bad); background: var(--bad-soft); }
.reveal { font-size: 14px; color: var(--ok); font-weight: 600; margin-inline-start: 4px; }
textarea.answer {
  width: 100%; min-height: 110px; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--surface); resize: vertical; margin-bottom: 12px;
}
.ex-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.feedback { margin-top: 14px; padding: 12px 16px; border-radius: 10px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback.info { background: var(--surface-2); }
.feedback .fb-title { display: block; margin-bottom: 2px; }
.sample { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: var(--warn-soft); border-inline-start: 4px solid var(--accent); }
.self-assess { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 15px; }

.lesson-footer { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 32px 0 60px; padding-top: 22px; border-top: 1px solid var(--border); }
.done-banner { padding: 14px 18px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 600; margin-top: 24px; }

/* ---------- כניסה ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 420px; padding: 32px 28px; text-align: center; }
.login .brand-mark { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; margin: 0 auto 14px; }
.login h1 { margin: 0 0 6px; font-size: 24px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.field { display: block; text-align: start; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.input, .field input, .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px; padding: 9px 12px; background: var(--surface);
}
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); outline: none; }
.code-input { text-align: center; letter-spacing: .2em; font-size: 20px; direction: ltr; text-transform: uppercase; }
.error { color: var(--bad); font-size: 14px; min-height: 1.4em; margin: 4px 0 10px; }
.hint { font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .card-pad, .ex { padding: 16px; }
  .unit-head, .lesson-link { padding-inline: 16px; }
}
