/* =========================================================
   English All Alone – Design system
   ========================================================= */
:root {
  --bg: #f4f6fc;
  --bg-2: #eaeefa;
  --surface: #ffffff;
  --surface-2: #f7f8fd;
  --border: #e3e7f3;
  --text: #1d2140;
  --text-2: #5b6285;
  --text-3: #8d93b0;
  --primary: #6c4cff;
  --primary-2: #8f6bff;
  --primary-soft: #efeaff;
  --accent: #ff7a59;
  --pink: #ff5fa2;
  --yellow: #ffc83d;
  --teal: #19c3b1;
  --blue: #3b8bff;
  --green: #22c55e;
  --green-soft: #e3f9eb;
  --red: #ef4444;
  --red-soft: #fde8e8;
  --shadow-sm: 0 2px 6px rgba(40, 45, 100, .06);
  --shadow: 0 8px 24px rgba(40, 45, 100, .08);
  --shadow-lg: 0 18px 50px rgba(40, 45, 100, .14);
  --radius: 20px;
  --radius-sm: 12px;
  --sidebar-w: 270px;
  --grad: linear-gradient(135deg, #6c4cff 0%, #a35bff 45%, #ff5fa2 100%);
  --grad-warm: linear-gradient(135deg, #ff9a3d 0%, #ff5fa2 100%);
  --grad-cool: linear-gradient(135deg, #19c3b1 0%, #3b8bff 100%);
  font-size: 16px;
}
[data-theme="dark"] {
  --bg: #0f1226;
  --bg-2: #151936;
  --surface: #1a1f3d;
  --surface-2: #20264a;
  --border: #2c3360;
  --text: #eef0ff;
  --text-2: #b4b9dc;
  --text-3: #7f86b3;
  --primary: #8f73ff;
  --primary-2: #a98fff;
  --primary-soft: #2a2560;
  --green-soft: #12351f;
  --red-soft: #3e1820;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .3);
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Rubik", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
button, input, select, textarea { font-family: inherit; font-size: 1rem; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
p { margin: 0 0 .8em; }

/* English text always LTR */
.en, [lang="en"] {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: "Rubik", "Segoe UI", Arial, sans-serif;
}
.en-block { direction: ltr; text-align: left; unicode-bidi: isolate; }
.he { direction: rtl; unicode-bidi: isolate; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 0 0 auto; width: var(--sidebar-w);
  background: var(--surface); border-inline-start: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 12px;
  z-index: 50; overflow-y: auto; transition: transform .3s ease, background .3s;
}
.main-wrap { flex: 1; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.main { flex: 1; padding: 24px 32px 40px; max-width: 1200px; width: 100%; margin: 0 auto; outline: none; }
.footer {
  text-align: center; padding: 18px; color: var(--text-2); font-weight: 600;
  border-top: 1px solid var(--border); background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; color: var(--text); }
.brand-logo {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--grad); font-size: 24px; box-shadow: 0 6px 18px rgba(108, 76, 255, .35);
}
.brand-text strong { display: block; font-size: 1.1rem; font-weight: 800; white-space: nowrap; text-align: right; }
.brand-text small { color: var(--text-3); font-size: .8rem; }

.grade-pill {
  border: 0; cursor: pointer; text-align: start; padding: 12px 14px; border-radius: 16px;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  transition: transform .15s;
}
.grade-pill:hover { transform: translateY(-1px); }
.grade-pill small { display: block; color: var(--text-2); font-weight: 500; font-size: .78rem; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav a .ni { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 17px; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(108, 76, 255, .3); }
.nav a.active .ni { background: rgba(255, 255, 255, .22); }

.sidebar-xp { margin-top: auto; background: var(--surface-2); border-radius: 16px; padding: 12px 14px; font-size: .85rem; }
.sidebar-xp .lvl { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.credit {
  font-weight: 800; font-size: .78rem; letter-spacing: 1.5px; white-space: nowrap; padding: 6px 12px; border-radius: 999px;
  background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(108, 76, 255, .25);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 18px; display: grid; place-items: center;
  transition: transform .15s, background .15s;
}
.icon-btn:hover { transform: translateY(-1px); background: var(--surface-2); }
.menu-btn { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 700; font-size: .88rem; white-space: nowrap;
}
.backdrop { display: none; }

/* ---------- Generic components ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 1.9rem; font-weight: 800; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm); transition: background .3s, border-color .3s;
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 1.3rem; }
.card h3 { font-size: 1.08rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.muted { color: var(--text-2); }
.small { font-size: .88rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 14px; border: 0; cursor: pointer; font-weight: 700;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s; text-decoration: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 6px 18px rgba(108, 76, 255, .3); }
.btn-warm { background: var(--grad-warm); color: #fff; border: 0; }
.btn-cool { background: var(--grad-cool); color: #fff; border: 0; }
.btn-danger { background: var(--red); color: #fff; border: 0; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 14px; font-size: .88rem; border-radius: 11px; }
.btn-lg { padding: 15px 28px; font-size: 1.08rem; border-radius: 16px; }
.btn-block { width: 100%; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; background: var(--primary-soft); color: var(--primary);
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.orange { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.tag.teal { background: color-mix(in srgb, var(--teal) 15%, transparent); color: var(--teal); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--text-2);
}
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg button.on { background: var(--primary); color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .92rem; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); transition: border-color .15s; outline: none;
}
.input:focus { border-color: var(--primary); }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.6; }

.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--grad); transition: width .6s ease; }
.progress.green > span { background: linear-gradient(90deg, #22c55e, #19c3b1); }
.progress.warm > span { background: var(--grad-warm); }
.progress.cool > span { background: var(--grad-cool); }

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty .big { font-size: 3rem; }

.toggle { position: relative; width: 52px; height: 30px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: var(--shadow-sm); }
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::after { transform: translateX(-22px); }

.speak { border: 0; background: var(--primary-soft); color: var(--primary); border-radius: 10px; width: 32px; height: 32px; cursor: pointer; font-size: 15px; display: inline-grid; place-items: center; flex: none; vertical-align: middle; }
.speak:hover { filter: brightness(.95); }

/* ---------- Home ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: 40px; color: #fff;
  background: var(--grad); box-shadow: var(--shadow-lg); margin-bottom: 22px;
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.hero::before { width: 320px; height: 320px; top: -120px; left: -80px; }
.hero::after { width: 200px; height: 200px; bottom: -90px; left: 30%; }
.hero-inner { position: relative; z-index: 1; display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: center; }
.hero h1 { font-size: 2.6rem; font-weight: 800; margin-bottom: 10px; }
.hero p { font-size: 1.1rem; opacity: .95; max-width: 520px; }
.hero .btn { background: #fff; color: var(--primary); }
.hero .btn.btn-ghost { background: rgba(255, 255, 255, .18); color: #fff; border: 1px solid rgba(255, 255, 255, .35); }
.hero-art { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hero-art span {
  aspect-ratio: 1; border-radius: 20px; background: rgba(255, 255, 255, .16); display: grid; place-items: center;
  font-size: 2rem; backdrop-filter: blur(4px); animation: float 4s ease-in-out infinite;
}
.hero-art span:nth-child(2n) { animation-delay: -1.5s; }
.hero-art span:nth-child(3n) { animation-delay: -2.6s; }
.hero-art span b { font-size: 1.05rem; direction: ltr; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.stat {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
}
.stat .si { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; flex: none; }
.stat b { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat small { color: var(--text-2); }

.feature {
  display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s; cursor: pointer; text-align: start;
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature .fi { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; font-size: 26px; color: #fff; }
.feature h3 { margin: 4px 0 0; font-size: 1.08rem; }
.feature p { margin: 0; color: var(--text-2); font-size: .9rem; }

/* ---------- Grades ---------- */
.grade-card {
  position: relative; overflow: hidden; border-radius: 24px; padding: 22px; color: #fff; cursor: pointer;
  min-height: 190px; display: flex; flex-direction: column; gap: 6px; border: 0; text-align: start;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.grade-card:hover { transform: translateY(-5px) rotate(-.4deg); box-shadow: var(--shadow-lg); }
.grade-card .gl { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.grade-card .ge { position: absolute; left: 16px; top: 14px; font-size: 2.6rem; opacity: .9; }
.grade-card p { margin: 0; opacity: .92; font-size: .9rem; }
.grade-card .cur { position: absolute; left: 14px; bottom: 14px; background: #fff; color: #333; border-radius: 999px; padding: 3px 12px; font-size: .8rem; font-weight: 700; }
.grade-card .gt { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; }
.grade-card .gt span { background: rgba(255, 255, 255, .22); padding: 2px 9px; border-radius: 999px; font-size: .75rem; }

/* ---------- Topic cards ---------- */
.topic-card {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--border); cursor: pointer; transition: transform .2s, box-shadow .2s; text-align: start; color: var(--text);
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.topic-card .ti { font-size: 2rem; }
.topic-card h3 { margin: 0; font-size: 1.05rem; }
.topic-card .en { color: var(--text-3); font-size: .85rem; align-self: flex-start; }
.book-body h3.en { align-self: flex-start; }
.topic-card.done { border-color: var(--green); }
.topic-card .tc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 8px; }

/* ---------- Lesson ---------- */
.lesson-hero { border-radius: 24px; padding: 26px 26px 26px 120px;color: #fff; margin-bottom: 18px; background: var(--grad-cool); position: relative; overflow: hidden; }
.lesson-hero .lh-emoji { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); font-size: 4rem; opacity: .85; }
.lesson-hero h1 { font-size: 1.8rem; margin-bottom: 4px; }
.lesson-hero p { margin: 0; opacity: .95; max-width: 640px; }
.explain p { font-size: 1.04rem; }
.rule { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--primary-soft); margin-bottom: 8px; }
.rule .rn { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; font-size: .85rem; }
.example {
  display: grid; grid-template-columns: auto 1fr 1fr; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 8px;
}
.example .en { font-weight: 600; font-size: 1.05rem; text-align: left; }
.example .he { color: var(--text-2); }
.mistake { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; border-radius: 14px; border: 1px dashed var(--border); margin-bottom: 10px; }
.mistake .w { color: var(--red); text-decoration: line-through; text-decoration-thickness: 2px; }
.mistake .r { color: var(--green); font-weight: 600; }
.mistake .why { grid-column: 1 / -1; color: var(--text-2); font-size: .92rem; }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.word-card { padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.word-card .wt { display: flex; align-items: center; gap: 8px; }
.word-card .wt .em { font-size: 1.6rem; }
.word-card .wt .en { font-weight: 700; font-size: 1.12rem; }
.word-card .wt .he { margin-inline-start: auto; font-weight: 600; color: var(--primary); }
.word-card .ex { font-size: .88rem; color: var(--text-2); }
.word-card .ex .en { display: block; text-align: left; color: var(--text); }

.section-title { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; font-weight: 800; margin: 0 0 14px; }
.section-title .st-i { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); }

/* ---------- Questions ---------- */
.q-wrap { max-width: 760px; margin: 0 auto; }
.q-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.q-top .progress { flex: 1; }
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 28px; box-shadow: var(--shadow); animation: pop .35s ease; }
.q-kind { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.q-instr { font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.q-prompt { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-prompt.en-block { justify-content: flex-start; }
.q-prompt .blank { display: inline-block; min-width: 70px; border-bottom: 3px solid var(--primary); margin: 0 4px; }
.q-hint { color: var(--text-2); margin-bottom: 18px; }
.q-passage { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; max-height: 240px; overflow-y: auto; font-size: .98rem; }
.q-passage summary { cursor: pointer; font-weight: 700; direction: rtl; text-align: right; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  padding: 16px 18px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: 1.05rem; text-align: center; transition: transform .12s, border-color .12s, background .12s;
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 62px; color: var(--text);
}
.opt:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); }
.opt .k { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: .8rem; color: var(--text-3); flex: none; }
.opt.selected { border-color: var(--primary); background: var(--primary-soft); }
.opt.correct { border-color: var(--green); background: var(--green-soft); color: var(--green); animation: pop .3s; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); animation: shake .4s; }
.opt:disabled { cursor: default; }
.answer-row { display: flex; gap: 10px; }
.answer-row .input { font-size: 1.15rem; }
.answer-row .input.ok { border-color: var(--green); background: var(--green-soft); }
.answer-row .input.bad { border-color: var(--red); background: var(--red-soft); animation: shake .4s; }

.tiles { display: flex; flex-wrap: wrap; gap: 8px; min-height: 58px; padding: 10px; border-radius: 16px; }
.tiles.target { border: 2px dashed var(--border); background: var(--surface-2); margin-bottom: 12px; }
.tile {
  padding: 9px 15px; border-radius: 12px; background: var(--surface); border: 2px solid var(--border); cursor: pointer;
  font-weight: 600; font-size: 1.05rem; box-shadow: 0 3px 0 var(--border); transition: transform .1s; color: var(--text);
}
.tile:hover { transform: translateY(-2px); }
.tile.used { opacity: .25; pointer-events: none; }

.match-board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  padding: 13px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600;
  text-align: center; transition: all .15s; color: var(--text);
}
.match-item.sel { border-color: var(--primary); background: var(--primary-soft); }
.match-item.done { border-color: var(--green); background: var(--green-soft); color: var(--green); pointer-events: none; opacity: .75; }
.match-item.bad { border-color: var(--red); animation: shake .4s; }

.feedback { margin-top: 18px; padding: 16px 18px; border-radius: 18px; animation: slideUp .3s ease; }
.feedback.ok { background: var(--green-soft); border: 2px solid var(--green); }
.feedback.bad { background: var(--red-soft); border: 2px solid var(--red); }
.feedback .fb-title { font-weight: 800; font-size: 1.15rem; margin-bottom: 4px; }
.feedback.ok .fb-title { color: var(--green); }
.feedback.bad .fb-title { color: var(--red); }
.feedback .fb-line { margin: 4px 0; }
.feedback .fb-tr { color: var(--text-2); font-size: .95rem; }
.q-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 10px; flex-wrap: wrap; }

@keyframes pop { 0% { transform: scale(.96); opacity: .6; } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-enter { animation: fadeIn .35s ease; }

/* ---------- Setup panel ---------- */
.setup { max-width: 820px; margin: 0 auto; }
.setup h3 { margin-top: 6px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice {
  border: 2px solid var(--border); border-radius: 16px; padding: 12px 14px; background: var(--surface); cursor: pointer;
  display: flex; align-items: center; gap: 10px; font-weight: 600; text-align: start; transition: all .15s; color: var(--text);
}
.choice:hover { border-color: var(--primary-2); }
.choice.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.choice .ce { font-size: 1.4rem; }
.choice small { display: block; font-weight: 500; color: var(--text-3); font-size: .78rem; }

/* ---------- Results ---------- */
.result-hero { text-align: center; padding: 30px; border-radius: 28px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.score-ring { width: 170px; height: 170px; margin: 0 auto 14px; position: relative; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .sr-txt { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring .sr-txt b { font-size: 2.4rem; font-weight: 800; display: block; line-height: 1; }
.review-item { padding: 14px 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 10px; }
.review-item.ok { border-inline-start: 5px solid var(--green); }
.review-item.bad { border-inline-start: 5px solid var(--red); }

/* ---------- Test ---------- */
.test-layout { display: grid; grid-template-columns: 1fr 240px; gap: 18px; align-items: start; }
.test-side { position: sticky; top: 84px; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.palette button { height: 38px;border-radius: 10px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700; color: var(--text); }
.palette button.ans { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.palette button.cur { outline: 3px solid var(--accent); outline-offset: 1px; }
.timer { font-size: 1.8rem; font-weight: 800; text-align: center; direction: ltr; }
.timer.low { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.exam-paper { border-top: 6px solid var(--primary); }

/* ---------- Flashcards ---------- */
.flash-stage { perspective: 1400px; max-width: 560px; margin: 0 auto; }
.flash { position: relative; width: 100%; aspect-ratio: 1.55; cursor: pointer; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3, .7, .3, 1); }
.flash.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 28px; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; box-shadow: var(--shadow-lg);
}
.flash-front { background: var(--grad); color: #fff; }
.flash-back { background: var(--surface); border: 2px solid var(--border); transform: rotateY(180deg); }
.flash-front .fw { font-size: 2.6rem; font-weight: 800; }
.flash-front .fe { font-size: 3rem; }
.flash-back .fh { font-size: 2rem; font-weight: 800; color: var(--primary); }
.flash-back .fx { color: var(--text-2); }
.flash-back .fx .en { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.flash-hint { position: absolute; bottom: 14px; font-size: .8rem; opacity: .8; }
.flash-controls { display: flex; justify-content: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Library ---------- */
.book {
  border-radius: 22px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); cursor: pointer;
  transition: transform .2s, box-shadow .2s; display: flex; flex-direction: column; color: var(--text); text-align: start;
}
.book:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.book-cover { height: 110px; display: grid; place-items: center; font-size: 3.2rem; position: relative; }
.book-cover .read-badge { position: absolute; top: 10px; right: 10px; background: #fff; color: var(--green); border-radius: 999px; padding: 2px 10px; font-size: .75rem; font-weight: 700; }
.book-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-body h3 { margin: 0; font-size: 1.05rem; }
.reader-line { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 10px 14px; border-radius: 12px; transition: background .15s; }
.reader-line:hover { background: var(--surface-2); }
.reader-line .en { font-size: 1.15rem; line-height: 1.7; text-align: left; }
.reader-line .he { color: var(--text-2); font-size: .95rem; }
.reader-line .spk { font-weight: 800; color: var(--primary); }
.reader.hide-tr .reader-line .he { display: none; }
.vocab-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.vocab-list div { padding: 9px 12px; border-radius: 12px; background: var(--surface-2); display: flex; justify-content: space-between; gap: 8px; }

/* ---------- Progress ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge { text-align: center; padding: 16px 10px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); }
.badge .be { font-size: 2.4rem; display: block; margin-bottom: 4px; }
.badge b { display: block; font-size: .92rem; }
.badge small { color: var(--text-3); font-size: .78rem; }
.badge.locked { filter: grayscale(1); opacity: .45; }
.badge.unlocked { background: linear-gradient(160deg, color-mix(in srgb, var(--yellow) 22%, var(--surface)), var(--surface)); border-color: var(--yellow); }
.topic-bar { display: grid; grid-template-columns: 30px 1fr 2fr 50px; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.topic-bar:last-child { border-bottom: 0; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; direction: ltr; }
.chart .bar { flex: 1; background: var(--grad); border-radius: 8px 8px 4px 4px; position: relative; min-height: 4px; }
.chart .bar span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: .72rem; font-weight: 700; color: var(--text-2); }
.level-ring { display: flex; align-items: center; gap: 18px; }
.level-badge { width: 84px; height: 84px; border-radius: 26px; background: var(--grad-warm); color: #fff; display: grid; place-items: center; font-size: 2rem; font-weight: 800; box-shadow: var(--shadow); flex: none; }
.word-chip { display: inline-flex; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); margin: 3px; font-size: .9rem; }

/* ---------- Writing ---------- */
.checklist { list-style: none; padding: 0; margin: 10px 0; }
.checklist li { padding: 6px 0; display: flex; gap: 8px; align-items: center; }
.picture-box { font-size: 4rem; text-align: center; padding: 18px; background: var(--surface-2); border-radius: 20px; letter-spacing: 10px; }

/* ---------- Toast / modal / confetti ---------- */
.toast-wrap { position: fixed; bottom: 22px; left: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: 14px 18px; border-radius: 18px;
  display: flex; align-items: center; gap: 12px; min-width: 260px; animation: slideUp .35s ease; max-width: 360px;
}
.toast .te { font-size: 2rem; }
.toast b { display: block; }
.modal-root .overlay { position: fixed; inset: 0; background: rgba(10, 12, 30, .55); display: grid; place-items: center; z-index: 150; padding: 20px; animation: fadeIn .2s; }
.modal { background: var(--surface); border-radius: 24px; padding: 26px; max-width: 460px; width: 100%; box-shadow: var(--shadow-lg); }
.modal h2 { margin-bottom: 8px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; width: 100%; height: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .test-layout { grid-template-columns: 1fr; }
  .test-side { position: static; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(10, 12, 30, .45); z-index: 40; }
  .main-wrap { margin-inline-start: 0; }
  .menu-btn { display: grid; }
  .main { padding: 18px 16px 30px; }
  .topbar { padding: 10px 16px; }
  .hero { padding: 28px 22px; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .hero h1 { font-size: 2rem; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .q-card { padding: 20px; }
  .q-prompt { font-size: 1.3rem; }
  .example { grid-template-columns: auto 1fr; }
  .example .he { grid-column: 2; }
  .mistake { grid-template-columns: 1fr; }
  .topbar-title { display: none; }
  .credit { font-size: .66rem; letter-spacing: .5px; padding: 5px 9px; margin-inline-end: auto; }
  .lesson-hero { padding: 22px; }
  .lesson-hero .lh-emoji { display: none; }
  .xp-chip { display: none; }
  .page-head h1 { font-size: 1.5rem; }
  .topic-bar { grid-template-columns: 26px 1fr 60px; }
  .topic-bar .progress { grid-column: 1 / -1; }
}
