/* ===========================================================
   styles.css — עיצוב האפליקציה (RTL, רספונסיבי)
   =========================================================== */
:root {
  --bg: #f4f2ff;
  --bg2: #eef7ff;
  --card: #ffffff;
  --ink: #1e1b3a;
  --muted: #6b6890;
  --line: #e6e3f5;
  --primary: #6d4aff;
  --primary-2: #8f6bff;
  --primary-soft: #efeaff;
  --good: #16a34a;
  --good-soft: #e7f8ee;
  --bad: #e11d48;
  --bad-soft: #fdecef;
  --easy: #10b981;
  --medium: #f59e0b;
  --hard: #ef4444;
  --radius: 20px;
  --shadow: 0 6px 24px rgba(60, 40, 160, .08), 0 1px 3px rgba(60, 40, 160, .06);
  --shadow-lg: 0 14px 40px rgba(60, 40, 160, .16);
  --font: 'Rubik', 'Heebo', 'Segoe UI', Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14122a; --bg2: #101a2c; --card: #1f1c3b; --ink: #f1efff; --muted: #a8a4cf; --line: #34305a;
    --primary-soft: #2c2558; --good-soft: #12321f; --bad-soft: #3a1420;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 14px 40px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #14122a; --bg2: #101a2c; --card: #1f1c3b; --ink: #f1efff; --muted: #a8a4cf; --line: #34305a;
  --primary-soft: #2c2558; --good-soft: #12321f; --bad-soft: #3a1420;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); font-size: 18px; line-height: 1.6;
  background: radial-gradient(1200px 600px at 100% -10%, #e3dcff 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 20%, #dff4ff 0%, transparent 55%), var(--bg);
  background-attachment: fixed; min-height: 100vh; display: flex; flex-direction: column;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body { background: radial-gradient(1200px 600px at 100% -10%, #2a2160 0%, transparent 60%), var(--bg); }
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; margin: 24px 0; }
.grow { flex: 1; min-width: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- סרגל עליון ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; white-space: nowrap; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary), #ec4899); box-shadow: 0 4px 14px rgba(109, 74, 255, .4); }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a { position: relative; display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; font-weight: 500; color: var(--muted); transition: .2s; }
.nav a:hover { background: var(--primary-soft); color: var(--ink); }
.nav a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(109, 74, 255, .35); }
.badge { background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 999px; min-width: 20px; height: 20px; display: inline-grid; place-items: center; padding: 0 5px; }
.badge[hidden] { display: none; }
.sound-btn { border: 1px solid var(--line); background: var(--card); width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; transition: .2s; flex-shrink: 0; }
.sound-btn:hover { transform: scale(1.08); box-shadow: var(--shadow); }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 16px 40px; flex: 1; }
.footer { text-align: center; padding: 22px 16px; color: var(--muted); font-weight: 500; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--card) 70%, transparent); }

/* ---------- כרטיסים וכפתורים ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; border: 1px solid var(--line); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 11px 22px; font-weight: 600; cursor: pointer; transition: transform .15s, box-shadow .2s, background .2s; text-align: center; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px rgba(109, 74, 255, .3); }
.btn.primary:hover { box-shadow: 0 10px 24px rgba(109, 74, 255, .4); transform: translateY(-1px); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.ghost { color: #c8b9ff; } }
.btn.ghost:hover { background: color-mix(in srgb, var(--primary) 18%, var(--card)); }
.btn.danger-ghost { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn.big { font-size: 1.1rem; padding: 14px 28px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar.big { height: 16px; margin-top: 10px; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22c55e, #6d4aff); transition: width .8s cubic-bezier(.2, .8, .2, 1); }

/* ---------- דף הבית ---------- */
.hero { position: relative; overflow: hidden; display: flex; align-items: center; gap: 20px; padding: 32px 28px; border-radius: 28px; color: #fff; margin-bottom: 20px;
  background: linear-gradient(120deg, #6d4aff 0%, #9b5cff 45%, #ec4899 100%); box-shadow: var(--shadow-lg); }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; }
.hero p { margin: 0; opacity: .95; font-size: 1.05rem; max-width: 560px; }
.hero-text { flex: 1; position: relative; z-index: 1; }
.hero-art { display: grid; grid-template-columns: repeat(2, 64px); gap: 12px; }
.hero-art span { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; background: rgba(255, 255, 255, .18); backdrop-filter: blur(4px); animation: float 4s ease-in-out infinite; }
.hero-art span:nth-child(2) { animation-delay: .5s; } .hero-art span:nth-child(3) { animation-delay: 1s; } .hero-art span:nth-child(4) { animation-delay: 1.5s; }
@keyframes float { 50% { transform: translateY(-8px) rotate(4deg); } }
.exam-pill { display: inline-block; background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .35); padding: 6px 14px; border-radius: 999px; font-size: .9rem; margin-bottom: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); text-align: center; position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; }
.stat.c1::before { background: #6d4aff; } .stat.c2::before { background: #22c55e; } .stat.c3::before { background: #f59e0b; } .stat.c4::before { background: #ec4899; }
.stat-icon { font-size: 1.5rem; }
.stat-val { font-size: 1.9rem; font-weight: 800; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: .9rem; }

.diff-pick { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.diff-pick-title { font-weight: 600; }
.diff-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.diff-btn { border: 2px solid var(--line); background: var(--card); padding: 10px 20px; border-radius: 999px; font-weight: 600; cursor: pointer; transition: .2s; }
.diff-btn:hover { transform: translateY(-2px); }
.diff-btn.easy.selected { background: var(--easy); border-color: var(--easy); color: #fff; }
.diff-btn.medium.selected { background: var(--medium); border-color: var(--medium); color: #fff; }
.diff-btn.hard.selected { background: var(--hard); border-color: var(--hard); color: #fff; }

.mistakes-cta { display: flex; align-items: center; gap: 14px; border-inline-start: 6px solid var(--bad); transition: .2s; }
.mistakes-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.cta-icon { font-size: 1.8rem; }
.cta-arrow { margin-inline-start: auto; font-size: 1.3rem; color: var(--muted); }

.group-title { font-size: 1.3rem; margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; }
.group-title::after { content: ''; flex: 1; height: 2px; background: linear-gradient(90deg, var(--line), transparent); }
[dir="rtl"] .group-title::after { background: linear-gradient(270deg, var(--line), transparent); }

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.topic-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; transition: transform .2s, box-shadow .2s; border-top: 5px solid hsl(var(--hue) 75% 58%); }
.topic-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.topic-head { display: flex; gap: 12px; align-items: flex-start; }
.topic-icon { width: 52px; height: 52px; flex-shrink: 0; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; background: hsl(var(--hue) 90% 94%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topic-icon { background: hsl(var(--hue) 40% 25%); } }
.topic-icon.big { width: 72px; height: 72px; font-size: 2.2rem; }
.topic-title { display: block; font-weight: 700; font-size: 1.12rem; }
.topic-desc { display: block; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.topic-stats { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); }
.topic-card .bar-fill { background: linear-gradient(90deg, hsl(var(--hue) 80% 60%), hsl(calc(var(--hue) + 40) 80% 55%)); }
.topic-actions { display: flex; gap: 8px; margin-top: auto; }
.topic-actions .primary { flex: 1; }

.tips h3 { margin-bottom: 8px; }
.tips ul, .help ul { margin: 0; padding-inline-start: 22px; }
.tips li, .help li { margin: 4px 0; }

/* ---------- רשימת נושאים ---------- */
.page-title { font-size: clamp(1.5rem, 3.5vw, 2rem); }
.page-sub { color: var(--muted); margin-top: -4px; }
.topic-list { display: flex; flex-direction: column; gap: 12px; }
.topic-row { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); border-inline-start: 6px solid hsl(var(--hue) 75% 58%); transition: .2s; }
a.topic-row:hover { transform: translateX(-4px); box-shadow: var(--shadow-lg); }
.topic-row .bar { margin-top: 6px; height: 7px; }
.topic-row .bar-fill { background: hsl(var(--hue) 75% 55%); }
.row-pct { font-weight: 700; color: hsl(var(--hue) 70% 45%); }

/* ---------- מסך נושא ---------- */
.topic-hero { background: var(--card); border-radius: 28px; padding: 22px 24px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 8px; background-image: linear-gradient(135deg, hsl(var(--hue) 90% 96%), transparent 60%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topic-hero { background-image: linear-gradient(135deg, hsl(var(--hue) 40% 22%), transparent 60%); } }
.back { color: var(--primary); font-weight: 600; font-size: .95rem; }
.topic-hero-main { display: flex; align-items: center; gap: 16px; margin: 12px 0; }
.topic-hero h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.1rem); }
.topic-hero p { margin: 0; color: var(--muted); }
.syllabus { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 8px 0 0; list-style: none; }
.syllabus li { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-size: .88rem; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.level-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); text-align: center; display: flex; flex-direction: column; gap: 8px; transition: .2s; position: relative; overflow: hidden; }
.level-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.level-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 6px; }
.level-card.easy::before { background: var(--easy); } .level-card.medium::before { background: var(--medium); } .level-card.hard::before { background: var(--hard); }
.level-icon { font-size: 2.4rem; }
.level-card h3 { font-size: 1.4rem; margin: 0; }
.level-card p { margin: 0; color: var(--muted); font-size: .95rem; flex: 1; }
.level-stats { display: flex; justify-content: center; gap: 12px; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }
.level-card.easy .bar-fill { background: var(--easy); } .level-card.medium .bar-fill { background: var(--medium); } .level-card.hard .bar-fill { background: var(--hard); }
.level-card .btn { margin-top: 6px; }

/* ---------- בוחן ---------- */
.quiz { max-width: 820px; margin: 0 auto; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--card); border: 1px solid var(--line); }
.diff-chip.easy { background: var(--easy); color: #fff; border-color: transparent; }
.diff-chip.medium { background: var(--medium); color: #fff; border-color: transparent; }
.diff-chip.hard { background: var(--hard); color: #fff; border-color: transparent; }
.review-chip { background: var(--bad-soft); color: var(--bad); }
.q-count { font-weight: 500; color: var(--muted); }
.q-count b { color: var(--ink); font-size: 1.15em; }
.quiz-bar { margin-bottom: 16px; height: 12px; }
.quiz-bar .bar-fill { background: linear-gradient(90deg, hsl(var(--hue) 80% 60%), #ec4899); }
.q-card { background: var(--card); border-radius: 26px; padding: 26px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.q-type { display: inline-block; font-size: .82rem; font-weight: 700; padding: 3px 12px; border-radius: 999px; margin-bottom: 12px; }
.q-type.mc { background: #e0f2fe; color: #0369a1; }
.q-type.open { background: #fef3c7; color: #a16207; }
.q-prompt { font-size: 1.2rem; font-weight: 500; line-height: 1.8; }
.q-figure { display: flex; justify-content: center; margin: 14px 0 4px; }
.eq { text-align: center; font-size: 1.45rem; margin: 14px 0 6px; padding: 12px; background: var(--primary-soft); border-radius: 16px; overflow-x: auto; }
.eq .math { font-weight: 600; }
.proof { background: var(--primary-soft); border-radius: 16px; padding: 12px 16px; margin-bottom: 10px; }
.formula-box { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 8px 12px; margin: 6px 0; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.choice { display: flex; align-items: center; gap: 12px; text-align: start; padding: 14px 16px; border-radius: 18px; border: 2px solid var(--line); background: var(--card); cursor: pointer; font-size: 1.12rem; transition: transform .15s, border-color .2s, background .2s, box-shadow .2s; min-height: 64px; }
.choice:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.choice:disabled { cursor: default; }
.ltr-badge { flex-shrink: 0; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.choice-body { flex: 1; min-width: 0; overflow-x: auto; }
.choice.right { border-color: var(--good); background: var(--good-soft); animation: pop .45s; }
.choice.right .ltr-badge { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.wrong .ltr-badge { background: var(--bad); color: #fff; }
.choice.dim { opacity: .5; }

.open-area { margin-top: 18px; }
.hint { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.open-row { display: flex; gap: 10px; }
.answer-input { flex: 1; min-width: 0; font-family: var(--font); font-size: 1.3rem; padding: 12px 18px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); color: var(--ink); outline: none; transition: .2s; text-align: left; }
.answer-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.answer-input.right { border-color: var(--good); background: var(--good-soft); }
.answer-input.wrong { border-color: var(--bad); background: var(--bad-soft); }
.keypad { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; direction: ltr; justify-content: flex-end; }
.key { min-width: 46px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--primary-soft); font-weight: 600; cursor: pointer; font-size: 1rem; transition: .15s; }
.key:hover:not(:disabled) { background: var(--primary); color: #fff; }
.key:disabled { opacity: .4; }
.note { display: none; margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: #fff7ed; color: #9a3412; font-size: .95rem; }
.note.show { display: block; animation: fadeIn .3s; }

.feedback:empty { display: none; }
.fb { margin-top: 20px; padding: 16px 18px; border-radius: 18px; animation: slideUp .35s ease-out; }
.fb.right { background: var(--good-soft); border: 2px solid var(--good); }
.fb.wrong { background: var(--bad-soft); border: 2px solid var(--bad); }
.fb-title { font-weight: 700; font-size: 1.15rem; }
.fb.right .fb-title { color: var(--good); }
.fb.wrong .fb-title { color: var(--bad); }
.fb-ans { margin-top: 6px; font-size: 1.1rem; }
.expl { margin-top: 10px; background: var(--card); border-radius: 14px; padding: 10px 14px; }
.expl summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.expl-title { font-weight: 700; margin-bottom: 4px; }
.steps { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.step { line-height: 1.8; overflow-x: auto; }
.quiz-controls { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

/* ---------- ביטויים מתמטיים ---------- */
.math { direction: ltr; unicode-bidi: isolate; display: inline-block; white-space: nowrap; font-variant-numeric: lining-nums; max-width: 100%; vertical-align: middle; }
.math sup { font-size: .68em; line-height: 0; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .86em; line-height: 1.15; margin: 0 .12em; }
.frac .fn { border-bottom: 2px solid currentColor; padding: 0 .25em .05em; }
.frac .fd { padding: .05em .25em 0; }
.or { color: var(--muted); font-weight: 500; margin: 0 .3em; }
.blank { display: inline-block; min-width: 1.6em; padding: 0 .3em; border-radius: 8px; background: #fde68a; color: #92400e; font-weight: 700; }

/* ---------- שרטוטים ---------- */
.fig { direction: ltr; width: 100%; max-width: 360px; height: auto; background: var(--card); border-radius: 16px; border: 1px solid var(--line); }
.fig.grid { max-width: 340px; }
.fig-poly { fill: color-mix(in srgb, var(--primary) 10%, transparent); stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
.fig-seg { stroke: var(--primary); stroke-width: 2; }
.fig-seg.dash { stroke-dasharray: 6 5; stroke: #ec4899; }
.fig-tick { stroke: #f59e0b; stroke-width: 2.5; stroke-linecap: round; }
.fig-right { fill: none; stroke: #ec4899; stroke-width: 1.8; }
.fig-arc { fill: none; stroke: #10b981; stroke-width: 2; }
.fig-angle { font: 600 13px var(--font); fill: #059669; }
.fig-side { font: 600 13px var(--font); fill: var(--ink); }
.fig-label { font: 700 16px var(--font); fill: var(--ink); }
.fig-dot { fill: var(--ink); }
.g-line { stroke: var(--line); stroke-width: 1; }
.g-axis { stroke: var(--muted); stroke-width: 1.6; }
.g-num { font: 10px var(--font); fill: var(--muted); }
.g-ax { font: italic 700 13px var(--font); fill: var(--muted); }
.g-dot { fill: #ec4899; }
.g-label { font: 700 14px var(--font); fill: var(--ink); }
.g-poly { stroke-width: 2; }

/* ---------- תוצאות ---------- */
.results { max-width: 640px; margin: 0 auto; text-align: center; background: var(--card); border-radius: 28px; padding: 32px 24px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.res-emoji { font-size: 4rem; animation: pop .6s; }
.results h1 { font-size: 2rem; margin-bottom: 4px; }
.res-msg { color: var(--muted); margin-top: 0; }
.ring-wrap { position: relative; width: 180px; height: 180px; margin: 18px auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 12; }
.ring-fg { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.2, .8, .2, 1); }
.ring-fg.good { stroke: var(--good); } .ring-fg.low { stroke: var(--medium); }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; }
.ring-text b { font-size: 2.2rem; line-height: 1; direction: ltr; }
.ring-text span { color: var(--muted); font-size: .9rem; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 22px; }
.res-stat { background: var(--primary-soft); border-radius: 16px; padding: 12px 6px; }
.res-stat b { display: block; font-size: 1.6rem; }
.res-stat span { font-size: .85rem; color: var(--muted); }
.res-stat.right { background: var(--good-soft); } .res-stat.right b { color: var(--good); }
.res-stat.wrong { background: var(--bad-soft); } .res-stat.wrong b { color: var(--bad); }
.res-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; max-width: 380px; margin: 0 auto; }

/* ---------- טעויות והגדרות ---------- */
.review-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 3rem; }
.mistake-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mistake { background: var(--card); border-radius: 16px; padding: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .95rem; }
.mistake-head { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.mistake-q .eq { font-size: 1.1rem; padding: 6px; margin: 6px 0; }
.mistake-q .proof { padding: 8px 10px; }
.mistake-a { margin-top: 6px; color: var(--good); font-weight: 600; }
.settings { padding: 6px 20px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; }
.seg { display: inline-flex; background: var(--primary-soft); border-radius: 999px; padding: 4px; gap: 2px; }
.seg-btn { border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg-btn.selected { background: var(--primary); color: #fff; }
.switch { position: relative; width: 56px; height: 32px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: .25s; }
.slider::before { content: ''; position: absolute; width: 24px; height: 24px; top: 4px; right: 4px; background: #fff; border-radius: 50%; transition: .25s; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
.switch input:checked + .slider { background: var(--good); }
.switch input:checked + .slider::before { transform: translateX(-24px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- אנימציות ---------- */
.fade-in { animation: fadeIn .4s ease-out both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.05); } 100% { transform: scale(1); } }
.q-card.pop { animation: pop .45s; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
.burst i { position: absolute; width: 9px; height: 9px; border-radius: 2px; animation: burst .95s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- בוחרי רמה וסוג שאלות ---------- */
.btn.sm { padding: 7px 14px; font-size: .9rem; }
.picker-card { display: flex; flex-direction: column; gap: 12px; }
.picker-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.picker-title { font-weight: 600; }
.qtype-seg { flex-wrap: wrap; }
.lessons-link { margin-top: 14px; }
.center-row { justify-content: center; margin-top: 12px; }

/* ---------- שיעורים ---------- */
.lessons-cta { display: flex; align-items: center; gap: 14px; border-inline-start: 6px solid #0ea5e9; transition: .2s; background-image: linear-gradient(135deg, color-mix(in srgb, #0ea5e9 9%, transparent), transparent 60%); }
.lessons-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lessons-cta .bar { margin-top: 8px; height: 7px; }
.lesson-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.lesson-topic { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 5px solid hsl(var(--hue) 75% 58%); padding: 16px; margin-bottom: 16px; }
.lesson-topics .lesson-topic { margin-bottom: 0; }
.lesson-topic-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.lesson-topic-head .bar { margin-top: 6px; height: 7px; }
.lesson-topic-head .bar-fill { background: hsl(var(--hue) 75% 55%); }
.lesson-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.lesson-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 14px; background: var(--primary-soft); transition: .15s; }
.lesson-row:hover { transform: translateX(-3px); background: color-mix(in srgb, hsl(var(--hue) 80% 60%) 16%, var(--card)); }
.lesson-num { width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--card); color: hsl(var(--hue) 70% 45%); border: 2px solid hsl(var(--hue) 70% 60%); }
.lesson-row.done .lesson-num { background: var(--good); border-color: var(--good); color: #fff; }

.lesson { max-width: 860px; margin: 0 auto; }
.lesson-head { display: flex; align-items: center; gap: 14px; margin: 12px 0; }
.lesson-head h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.1rem); }
.done-chip { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.lesson-dots { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--card); border: 2px solid var(--line); color: var(--muted); transition: .15s; }
.dot.done { background: var(--good); border-color: var(--good); color: #fff; }
.dot.cur { border-color: hsl(var(--hue) 75% 55%); box-shadow: 0 0 0 4px color-mix(in srgb, hsl(var(--hue) 75% 55%) 25%, transparent); color: var(--ink); }
.lesson-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; font-size: 1.08rem; }
.l-p { margin: 0; line-height: 1.9; }
.lesson-body .l-p .math, .lesson-body .l-step .math, .lesson-body .l-rule-body .math, .lesson-body .l-list .math { white-space: normal; }
.l-rule { border-radius: 18px; padding: 14px 18px; background: color-mix(in srgb, hsl(var(--hue) 85% 60%) 12%, var(--card)); border: 2px solid color-mix(in srgb, hsl(var(--hue) 75% 55%) 45%, transparent); }
.l-rule-title { font-weight: 700; margin-bottom: 6px; color: hsl(var(--hue) 65% 40%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .l-rule-title { color: hsl(var(--hue) 80% 75%); } }
.l-rule-body { font-size: 1.15rem; line-height: 2; }
.l-tip, .l-warn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 16px; line-height: 1.8; }
.l-tip { background: #ecfeff; border: 1px solid #a5f3fc; color: #155e75; }
.l-warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .l-tip { background: #0b2e35; border-color: #155e75; color: #a5f3fc; } :root:not([data-theme="light"]) .l-warn { background: #3a1d0b; border-color: #9a3412; color: #fed7aa; } }
.l-ic { font-size: 1.3rem; line-height: 1.5; }
.l-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.l-fig figcaption { color: var(--muted); font-size: .92rem; }
.l-list { margin: 0; padding-inline-start: 26px; line-height: 1.9; }
.l-list li { margin: 4px 0; }
.l-ex { border: 2px dashed var(--line); border-radius: 18px; padding: 14px 16px; }
.l-ex-title { font-weight: 700; color: var(--primary); margin-bottom: 4px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .l-ex-title { color: #c8b9ff; } }
.l-ex-q .eq { margin: 6px 0; }
.l-ex-steps { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.l-step { display: flex; gap: 10px; align-items: center; background: var(--primary-soft); border-radius: 12px; padding: 8px 12px; overflow-x: auto; }
.l-step-n { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: .82rem; font-weight: 700; }
.l-ex-btns { margin-top: 10px; }
.l-proof { border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; background: var(--primary-soft); overflow-x: auto; }
.l-proof table { width: 100%; border-collapse: collapse; margin-top: 10px; background: var(--card); border-radius: 12px; overflow: hidden; }
.l-proof th, .l-proof td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.l-proof th { background: color-mix(in srgb, var(--primary) 12%, var(--card)); font-weight: 700; }
.l-proof td:first-child, .l-proof th:first-child { width: 36px; text-align: center; color: var(--muted); }
.check-card { border-inline-start: 6px solid var(--medium); }
.check-card h3 { margin: 0; }
.check-card .q-prompt { margin-top: 10px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0; flex-wrap: wrap; }

/* ---------- לשוניות והיסטוריית טעויות ---------- */
.tabs { display: flex; gap: 8px; margin: 6px 0 18px; flex-wrap: wrap; }
.tab { padding: 10px 18px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 14px rgba(109, 74, 255, .3); }
.tab-n { background: rgba(0, 0, 0, .08); border-radius: 999px; padding: 0 8px; font-size: .82rem; }
.tab.active .tab-n { background: rgba(255, 255, 255, .25); }
.hist-stats .stat-val { font-size: 1.35rem; }
.hist-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hist-tools label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.hist-tools select { font-family: inherit; font-size: .95rem; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.hist-tools .btn-row { margin-inline-start: auto; }
.hist-day { font-size: 1rem; color: var(--muted); margin: 18px 0 8px; }
.h-item { background: var(--card); border-radius: 16px; padding: 12px 14px; border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 10px; border-inline-start: 5px solid var(--bad); }
.h-item.fixed { border-inline-start-color: var(--good); }
.h-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; }
.h-topic { font-weight: 600; }
.h-time { color: var(--muted); }
.h-status { margin-inline-start: auto; font-weight: 700; color: var(--bad); }
.h-item.fixed .h-status { color: var(--good); }
.h-q { margin: 8px 0; }
.h-q summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .92rem; }
.h-q .mistake-q { margin-top: 6px; }
.h-ans { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 10px; font-size: .98rem; }
.h-your { color: var(--bad); }
.h-right { color: var(--good); font-weight: 600; }
.mistake .btn { margin-top: 8px; }

/* ---------- חלון אישור ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--ink) 45%, transparent); animation: fadeIn .2s; }
.modal { background: var(--card); color: var(--ink); border-radius: 22px; padding: 22px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.modal p { margin: 0 0 16px; font-size: 1.1rem; font-weight: 500; }
.modal-btns { justify-content: flex-start; }
.btn.danger { background: var(--bad); color: #fff; }

/* ---------- רספונסיבי ---------- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .level-grid { grid-template-columns: 1fr; }
  .hero-art { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  .topbar-inner { gap: 8px; padding: 8px 12px; }
  .brand-text { display: none; }
  .nav { margin-inline-start: 0; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 0; padding: 4px 6px; font-size: .7rem; border-radius: 14px; }
  .brand-logo { width: 34px; height: 34px; font-size: 1.15rem; }
  .lesson-topics { grid-template-columns: 1fr; }
  .lesson-body { padding: 16px; font-size: 1rem; }
  .lesson-head .topic-icon.big { width: 56px; height: 56px; font-size: 1.7rem; }
  .lesson-nav .btn { flex: 1; }
  .picker-row { flex-direction: column; align-items: stretch; }
  .qtype-seg { justify-content: space-between; }
  .qtype-seg .seg-btn { flex: 1; padding: 7px 6px; }
  .hist-tools .btn-row { margin-inline-start: 0; }
  .nav-ic { font-size: 1.15rem; }
  .badge { position: absolute; top: -2px; left: 2px; }
  .sound-btn { width: 40px; height: 40px; }
  .hero { padding: 22px 18px; border-radius: 22px; }
  .stat { padding: 12px; } .stat-val { font-size: 1.5rem; }
  .choices { grid-template-columns: 1fr; }
  .q-card { padding: 18px 16px; border-radius: 22px; }
  .q-prompt { font-size: 1.08rem; }
  .eq { font-size: 1.2rem; }
  .open-row { flex-direction: column; }
  .quiz-controls .btn { flex: 1; padding: 11px 12px; }
  .diff-pick { flex-direction: column; align-items: stretch; }
  .diff-buttons { justify-content: space-between; }
  .diff-btn { flex: 1; padding: 10px 8px; }
  .topic-grid, .mistake-list { grid-template-columns: 1fr; }
  .res-stat b { font-size: 1.3rem; }
}
