:root{
  --bg: #f6f4ff;
  --bg2: #fffaf0;
  --card: #ffffff;
  --ink: #2c2350;
  --ink-soft: #5c5480;
  --primary: #7c5cff;
  --primary-dark: #5b3df0;
  --accent: #ff9f5a;
  --good: #35c46f;
  --bad: #ff5d6c;
  --star: #ffc93c;
  --line: #e4defc;
  --soft: #efeaff;
  --track: #e5e0fb;
  --good-bg: #e3f9ec;
  --bad-bg: #ffe9eb;
  --warn-bg: #fff4da;
  --shadow: 0 10px 30px rgba(80, 60, 160, .15);
  --shadow-sm: 0 2px 8px rgba(80, 60, 160, .10);
  --shadow-lift: 0 14px 34px rgba(80, 60, 160, .22);
  --radius: 20px;
  --radius-sm: 14px;
  --tap: 44px;
  font-size: 16px;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#171326; --bg2:#1e1a30; --card:#241f38; --ink:#f1eefc; --ink-soft:#b9b0e0;
    --line:#3a3257; --soft:#2f2850; --track:#3a3257; --good-bg:#1d3a2a; --bad-bg:#43222a; --warn-bg:#3d3320;
    --primary-dark:#a996ff;
    --shadow: 0 10px 30px rgba(0,0,0,.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.28);
    --shadow-lift: 0 14px 34px rgba(0,0,0,.5);
  }
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family:"Heebo", sans-serif;
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  color: var(--ink);
  min-height:100vh;
  direction: rtl;
  overflow-x: hidden;
}
h1,h2{ font-family:"Baloo 2", "Heebo", sans-serif; }
button{ font-family:inherit; cursor:pointer; border:none; color: inherit; }
input, select{ font-family:inherit; }
.hidden{ display:none !important; }
.sr-only{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* English inside Hebrew: always LTR, isolated */
bdi.en, .en{ unicode-bidi: isolate; direction: ltr; font-weight:700; }
.en-say{ background: none; padding: 0 2px; font: inherit; font-weight:700; color: var(--primary-dark); border-bottom: 1px dotted currentColor; border-radius: 4px; min-height: auto; }
.en-say::after{ content:"🔊"; font-size: .7em; margin-inline-start: 2px; opacity:.6; }

/* focus visibility */
:focus-visible{ outline: 3px solid var(--accent); outline-offset: 2px; }
[tabindex="-1"]:focus{ outline: none; }

#app{ max-width: 720px; margin:0 auto; min-height:100vh; position:relative; padding-bottom: 8px; }

.screen{ display:none; min-height:100vh; flex-direction:column; }
.screen.active{ display:flex; }
.screen.has-nav{ padding-bottom: 84px; }

/* ---------- Welcome ---------- */
#screen-welcome.active{ align-items:center; justify-content:center; padding:24px 16px; }
.welcome-card{
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 36px 28px; text-align:center; max-width:480px; width:100%;
}
.welcome-emoji{ font-size: 42px; margin-bottom:8px; }
.welcome-card h1{ font-size: 28px; margin: 0 0 6px; color: var(--primary-dark); }
.subtitle{ color: var(--ink-soft); margin: 0 0 4px; font-size: 15px; }
.tagline{ color: var(--accent); font-weight:700; font-size:14px; margin-bottom: 20px; }
#name-entry label{ display:block; font-weight:600; margin-bottom:8px; }
#user-name{
  width:100%; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line);
  font-size:16px; margin-bottom:14px; text-align:right; background: var(--bg);
  color: var(--ink);
}
#user-name:focus{ outline:none; border-color: var(--primary); }
#user-name.invalid{ border-color: var(--bad); }
.welcome-back{ font-size:16px; margin-bottom:16px; }

.btn{ border-radius: 16px; padding: 14px 22px; font-weight:700; font-size:16px; min-height: var(--tap); transition: transform .12s ease, box-shadow .18s ease, filter .18s ease; }
.btn:active{ transform: scale(.97); }
.btn-primary{ background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color:white; box-shadow: 0 6px 18px rgba(124,92,255,.4); width:100%; }
.btn-primary:hover{ filter: brightness(1.06); box-shadow: 0 8px 22px rgba(124,92,255,.5); }
.btn-primary:disabled{ opacity:.45; box-shadow:none; filter:none; }
.btn-ghost{ background: transparent; color: var(--ink-soft); width:100%; margin-top:8px; font-weight:600; }
.btn-ghost.small{ width:auto; padding: 10px 14px; font-size: 14px; }
.btn-ghost.danger{ color: var(--bad); }
.btn-block{ width:100%; }
.btn-big{ font-size: 18px; padding: 18px 22px; }

/* ---------- Topbar / nav ---------- */
.topbar{ display:flex; align-items:center; justify-content:space-between; padding: 16px; position:sticky; top:0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index:5; gap:8px; border-bottom: 1px solid transparent; }
.topbar-title{ font-weight:800; font-size:16px; flex:1; }
.topbar-stats{ display:flex; gap:8px; font-weight:700; font-size:14px; white-space:nowrap; }
.stat{ background: var(--card); padding:6px 10px; border-radius:12px; box-shadow: var(--shadow-sm); transition: transform .15s ease; }
.icon-btn{ background: var(--card); border-radius:12px; width: var(--tap); height: var(--tap); font-size:18px; box-shadow: var(--shadow-sm); flex-shrink:0; transition: transform .12s ease, box-shadow .12s ease; }
.icon-btn:active{ transform: scale(.92); }

.bottom-nav{ position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 720px; display:flex; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 -6px 20px rgba(80,60,160,.12); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav button{ flex:1; background:none; padding: 8px 4px 10px; min-height: 60px; display:flex; flex-direction:column; align-items:center; gap:2px; font-size: 12px; font-weight:700; color: var(--ink-soft); position:relative; transition: color .15s ease; }
.bottom-nav button span{ font-size: 22px; transition: transform .18s ease; }
.bottom-nav button.active{ color: var(--primary-dark); }
.bottom-nav button.active span{ transform: translateY(-2px) scale(1.08); }
.bottom-nav button.active::before{ content:""; position:absolute; top:2px; left:50%; transform:translateX(-50%); width:22px; height:3px; border-radius:3px; background: linear-gradient(90deg, var(--primary), var(--accent)); }

.toast{ position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 520px; background: var(--ink); color: var(--card); padding: 12px 16px; border-radius: 14px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); text-align:center; }

.modal-overlay{ position: fixed; inset: 0; background: rgba(20,14,40,.55); display:flex; align-items:center; justify-content:center; padding: 20px; z-index: 60; }
.modal-card{ background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lift); padding: 24px 22px; max-width: 400px; width:100%; text-align:center; }
.modal-card p{ font-size: 16px; line-height: 1.6; margin: 0 0 20px; }
.modal-buttons{ display:flex; flex-direction:column; gap: 8px; }

.progress-bar-outer{ display:block; background: var(--track); border-radius:20px; height:12px; overflow:hidden; }
.progress-bar-inner{ display:block; background: linear-gradient(90deg, var(--accent), var(--star)); height:100%; width:0%; transition: width .4s ease; border-radius:20px; }

/* ---------- Onboarding ---------- */
#screen-onboarding.active{ align-items:center; justify-content:center; padding: 24px 16px; }
.onb-card{ background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 20px; max-width: 520px; width: 100%; }
.onb-card h2{ margin: 4px 0 6px; color: var(--primary-dark); font-size: 24px; }
.onb-step{ font-size: 13px; font-weight:700; color: var(--accent); }
.onb-sub{ color: var(--ink-soft); font-size: 14px; line-height: 1.6; margin: 0 0 16px; }
.onb-options{ display:flex; flex-direction:column; gap: 10px; }
.onb-options.minutes{ display:grid; grid-template-columns: 1fr 1fr; }
.onb-option{ background: var(--bg); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; text-align: right; display:flex; flex-direction:column; gap: 2px; min-height: var(--tap); }
.onb-option b{ font-size: 16px; }
.onb-option span{ font-size: 13px; color: var(--ink-soft); }
.onb-option:hover, .onb-option.on{ border-color: var(--primary); background: var(--soft); }
.chips{ display:flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip{ background: var(--bg); border: 2px solid var(--line); border-radius: 999px; padding: 10px 14px; font-weight:700; font-size: 14px; min-height: var(--tap); }
.chip.on{ border-color: var(--primary); background: var(--soft); color: var(--primary-dark); }

/* ---------- Home (today) ---------- */
.home-body{ padding: 4px 16px 24px; display:flex; flex-direction:column; gap: 16px; }
.home-flavor{ margin: 0; color: var(--ink-soft); font-size: 15px; }
.today-card{ background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; }
.today-head{ display:flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.today-head h2{ margin: 0; font-size: 20px; }
.today-minutes{ font-weight:700; color: var(--ink-soft); font-size: 14px; }
.plan-list{ list-style: none; margin: 14px 0 0; padding: 0; display:flex; flex-direction:column; gap: 10px; }
.plan-item, .convo-item{ width:100%; display:flex; align-items:center; gap: 12px; background: var(--bg); border: 2px solid var(--line); border-radius: 16px; padding: 12px; text-align: right; min-height: 60px; transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease; }
.plan-item:hover, .convo-item:hover{ border-color: var(--primary); box-shadow: var(--shadow-sm); }
.plan-item:active, .convo-item:active{ transform: scale(.99); }
.plan-item.done{ opacity: .6; }
.plan-icon, .convo-icon{ font-size: 26px; width: 44px; text-align:center; flex-shrink:0; }
.plan-text{ flex:1; display:flex; flex-direction:column; min-width:0; }
.plan-text b{ font-size: 15px; }
.plan-text span{ font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; }
.plan-min{ font-size: 12px; font-weight:700; color: var(--primary-dark); white-space: nowrap; }
.plan-empty{ color: var(--ink-soft); font-size: 14px; }
.home-level{ text-align:center; color: var(--ink-soft); font-size: 14px; margin: 0; }
.tag{ display:inline-block; font-size: 11px; font-weight:700; background: var(--warn-bg); color: #8a6a1f; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.tag.good{ background: var(--good-bg); color: #1c6b3f; }

/* ---------- Course map ---------- */
.map-legend{ display:flex; flex-wrap:wrap; gap: 6px 12px; padding: 0 16px 8px; font-size: 12px; color: var(--ink-soft); }
.map-body{ padding: 0 16px 24px; display:flex; flex-direction:column; gap: 18px; }
.map-level-title{ margin: 8px 0 8px; font-size: 20px; color: var(--primary-dark); }
.map-level-title small{ font-size: 13px; color: var(--ink-soft); font-family: "Heebo", sans-serif; }
.unit-card{
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding:14px;
  margin-bottom: 12px;
}
.unit-head{ display:flex; align-items:center; gap: 12px; margin-bottom: 8px; }
.unit-icon{ font-size:28px; width:48px; height:48px; display:flex; align-items:center; justify-content:center; background: var(--bg); border-radius:14px; flex-shrink:0; }
.unit-title{ font-weight:800; font-size:16px; }
.lesson-rows{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap: 6px; }
.lesson-row{ width:100%; display:flex; gap: 10px; align-items: flex-start; background: none; text-align: right; padding: 10px 8px; border-radius: 12px; min-height: var(--tap); border: 2px solid transparent; }
.lesson-row:hover{ background: var(--bg); }
.lesson-state{ width: 28px; height: 28px; flex-shrink:0; border-radius: 50%; display:flex; align-items:center; justify-content:center; font-weight: 800; font-size: 15px; background: var(--bg); color: var(--ink-soft); }
.lesson-text{ flex:1; display:flex; flex-direction:column; gap: 2px; min-width: 0; }
.lesson-text b{ font-size: 15px; }
.lesson-text > span{ font-size: 12px; color: var(--ink-soft); }
.st-mastered .lesson-state{ background: var(--good); color: white; }
.st-completed .lesson-state{ background: var(--good-bg); color: var(--good); }
.st-current{ border-color: var(--primary); background: var(--soft); }
.st-current .lesson-state{ background: var(--primary); color: white; }
.st-available .lesson-state, .st-placedOut .lesson-state{ border: 2px solid var(--primary); background: transparent; color: var(--primary); }
.st-locked, .st-planned{ opacity: .55; }
.mini-bar{ display:block; height: 5px; background: var(--track); border-radius: 6px; overflow:hidden; margin-top: 4px; max-width: 180px; }
.mini-bar span{ display:block; height:100%; background: var(--good); border-radius: 6px; }

/* ---------- Lesson ---------- */
.lesson-topbar{ display:flex; align-items:center; gap:12px; padding: 14px 16px; }
.lesson-progress-outer{ flex:1; background: var(--track); height:14px; border-radius:20px; overflow:hidden; }
.lesson-progress-inner{ background: linear-gradient(90deg, var(--primary), var(--accent)); height:100%; width:4%; transition: width .35s ease; border-radius:20px; }
.lesson-hearts{ font-size:16px; white-space:nowrap; }

.lesson-body{ flex:1; padding: 10px 16px 20px; display:flex; flex-direction:column; min-width: 0; }

.q-kicker{ font-size:13px; font-weight:700; color: var(--primary); margin-bottom:6px; }
.q-title{ font-size:20px; font-weight:800; margin: 0 0 16px; line-height:1.5; }
.q-word-en{ font-size: 28px; font-weight:800; color: var(--primary-dark); direction: ltr; text-align:center; margin: 6px 0 10px; overflow-wrap: anywhere; }
.q-word-he{ font-size: 22px; font-weight:800; text-align:center; margin: 6px 0 12px; line-height: 1.6; }
.q-emoji{ font-size: 72px; text-align:center; margin: 4px 0 8px; }
.q-sentence{ font-size: 22px; font-weight: 700; text-align:center; margin: 8px 0 8px; line-height: 1.6; overflow-wrap: anywhere; }
.q-sentence .blank{ display:inline-block; min-width: 56px; border-bottom: 3px solid var(--primary); color: transparent; }
.wrong-sentence{ text-decoration: underline wavy var(--bad); text-underline-offset: 6px; }
.q-audio-row{ display:flex; justify-content:center; margin-bottom: 12px; }
.say-group{ display:inline-flex; gap: 6px; margin-inline-start: 6px; vertical-align: middle; }
.say-btn{ background: var(--card); border: 2px solid var(--line); border-radius: 50%; width: var(--tap); height: var(--tap); font-size: 18px; display:inline-flex; align-items:center; justify-content:center; }
.say-group.big .say-btn{ width: 60px; height: 60px; font-size: 26px; box-shadow: var(--shadow); border: none; }
.listen-box{ text-align:center; margin: 10px 0 6px; }
.npc-bubble{ display:flex; align-items:center; gap: 8px; flex-wrap: wrap; background: var(--soft); padding: 12px 14px; border-radius: 18px 18px 18px 4px; font-size: 18px; font-weight: 700; margin: 6px 0; }
.npc-avatar{ font-size: 26px; }

.options-grid{ display:flex; flex-direction:column; gap:12px; margin-top:auto; padding-top: 12px; }
.option{
  background: var(--card); border: 2px solid var(--line); border-radius:16px; padding:14px 16px; min-height: 52px;
  font-size:16px; font-weight:600; text-align:right; box-shadow: 0 2px 6px rgba(0,0,0,.03);
  display:flex; align-items:center; justify-content:space-between;
}
.option .opt-en{ direction:ltr; font-weight:800; unicode-bidi: isolate; }
.option.selected{ border-color: var(--primary); background: var(--soft); }
.option.correct{ border-color: var(--good); background: var(--good-bg); }
.option.wrong{ border-color: var(--bad); background: var(--bad-bg); }
.option:disabled, .option[disabled]{ opacity: 1; cursor: default; }

.match-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;}
.match-item{ background: var(--card); border:2px solid var(--line); border-radius:14px; padding: 12px 8px; min-height: 52px; text-align:center; font-weight:700; font-size:14px; overflow-wrap: anywhere; }
.match-item.selected{ border-color: var(--primary); background: var(--soft); }
.match-item.matched{ border-color: var(--good); background: var(--good-bg); opacity:.6; }
.match-item.wrong-flash{ border-color: var(--bad); background: var(--bad-bg); }

.type-answer-input{
  width:100%; padding:16px; border-radius:14px; border:2px solid var(--line); font-size:18px;
  text-align:center; direction:ltr; margin-top: 10px; background: var(--bg); color:var(--ink);
}
.type-answer-input:focus{ outline:none; border-color:var(--primary); }
.is-good{ border-color: var(--good) !important; }
.is-bad{ border-color: var(--bad) !important; }
.hint-line{ text-align:center; color: var(--ink-soft); font-size:13px; margin-top:10px; }

/* sentence builder (tap to place) */
.build-answer{ min-height: 64px; border-bottom: 2px solid var(--line); display:flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; margin-top: 8px; align-content: flex-start; }
.build-bank{ display:flex; flex-wrap: wrap; gap: 8px; justify-content:center; padding: 16px 0 4px; }
.chunk{ background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; padding: 8px 14px; min-height: var(--tap); font-size: 17px; font-weight: 700; }
.build-answer .chunk{ background: var(--soft); }

/* speaking */
.speak-box{ text-align:center; margin-top: 12px; display:flex; flex-direction:column; align-items:center; gap: 10px; }
.mic-btn{ width: 84px; height: 84px; border-radius: 50%; font-size: 36px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 6px 18px rgba(124,92,255,.4); }
.mic-btn.listening{ animation: pulse 1s infinite; background: var(--bad); }
@keyframes pulse{ 0%,100%{ transform: scale(1); } 50%{ transform: scale(1.08); } }
.speak-status{ font-size: 14px; color: var(--ink-soft); min-height: 20px; line-height: 1.6; }
.speak-actions{ display:flex; gap: 8px; flex-wrap: wrap; justify-content:center; }
.speak-note{ font-size: 12px; color: var(--ink-soft); margin: 0; }

/* learn cards */
.learn-card h2{ margin: 2px 0 10px; font-size: 22px; color: var(--primary-dark); }
.learn-card h3{ font-size: 15px; margin: 18px 0 8px; }
.learn-expl{ font-size: 16px; line-height: 1.8; background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.examples, .mistakes, .word-list{ list-style:none; margin: 0; padding: 0; display:flex; flex-direction:column; gap: 8px; }
.examples li{ background: var(--card); border-radius: 14px; padding: 10px 12px; display:flex; flex-wrap: wrap; align-items:center; gap: 4px 8px; }
.ex-en{ font-weight: 800; font-size: 17px; unicode-bidi: isolate; }
.ex-he{ width: 100%; color: var(--ink-soft); font-size: 14px; }
.mistakes li{ background: var(--warn-bg); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.7; }
.word-list li{ background: var(--card); border-radius: 14px; padding: 10px 12px; display:flex; gap: 12px; align-items:flex-start; }
.w-emoji{ font-size: 30px; width: 40px; text-align:center; flex-shrink:0; }
.w-main{ display:flex; flex-wrap: wrap; align-items:center; gap: 4px 6px; flex:1; min-width: 0; }
.w-en{ font-size: 19px; font-weight: 800; unicode-bidi: isolate; }
.w-he{ width:100%; font-size: 14px; color: var(--ink-soft); }
.w-ex{ width:100%; font-size: 14px; }

.lesson-footer{ position:sticky; bottom:0; background: var(--bg); padding: 12px 16px 20px; }
.feedback-banner{ display:flex; align-items:flex-start; gap:12px; padding:14px 16px; border-radius:16px; margin-bottom:12px; max-height: 42vh; overflow-y: auto; }
.feedback-banner.good{ background: var(--good-bg); }
.feedback-banner.bad{ background: var(--bad-bg); }
.feedback-icon{ font-size:26px; }
.feedback-title{ font-weight:800; font-size:15px; }
.feedback-sub{ font-size:14px; color: var(--ink); line-height: 1.7; }
.feedback-sub .say-btn{ width: 36px; height: 36px; font-size: 15px; }

/* ---------- Conversations ---------- */
.convo-note{ margin: 0 16px 12px; background: var(--warn-bg); border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.6; }
.convo-list{ padding: 0 16px 24px; display:flex; flex-direction:column; gap: 10px; }
.convo-item{ background: var(--card); }
.convo-item.locked{ opacity: .55; }
.chat-title{ font-weight: 800; flex:1; }
.chat-intro{ padding: 0 16px 8px; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }

/* ---------- Real-world missions ---------- */
.convo-section-title{ margin: 22px 16px 4px; }
.mission-body{ flex:1; padding: 4px 16px 28px; }
.mission-intro{ font-size: 14px; color: var(--ink-soft); line-height: 1.6; margin: 0 0 14px; }
.mission-checklist{ list-style:none; padding:0; margin: 0 0 18px; display:flex; flex-direction:column; gap: 8px; }
.mission-checklist li{ background: var(--card); border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: var(--shadow-sm); }
.mission-checklist li.done{ opacity: .6; text-decoration: line-through; }
.mission-step-card{ background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 18px; }
.mission-step-label{ font-weight: 800; font-size: 16px; margin-bottom: 12px; }
#mission-feedback{ min-height: 18px; margin: 8px 0; }
.chat-log{ flex:1; padding: 8px 16px; display:flex; flex-direction:column; gap: 10px; }
.bubble{ max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 17px; font-weight: 600; display:flex; flex-wrap: wrap; align-items:center; gap: 4px 6px; }
.bubble.npc{ align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-top-right-radius: 4px; }
.bubble.me{ align-self: flex-end; background: var(--soft); border-top-left-radius: 4px; }
.bubble .say-btn{ width: 36px; height: 36px; font-size: 15px; }
.bubble-he{ width: 100%; font-size: 13px; color: var(--ink-soft); }
.bubble-he summary{ cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.chat-footer{ position: sticky; bottom: 0; background: var(--bg); padding: 10px 16px 18px; }
.chat-choices{ display:flex; flex-direction:column; gap: 8px; }
.chat-type-row{ display:flex; gap: 8px; margin-top: 4px; }
.chat-type-row .text-input{ margin-bottom: 0; flex: 1; text-align: left; }
.convo-review{ list-style:none; padding:0; margin: 0 0 16px; display:flex; flex-direction:column; gap: 10px; text-align: right; }
.convo-review li{ background: var(--bg); border-radius: 14px; padding: 12px; font-size: 14px; line-height: 1.8; }
.concept-link{ font-size: 12px; color: var(--ink-soft); }

/* ---------- Reading ---------- */
.reading-note{ margin: 0 16px 12px; background: var(--warn-bg); border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.6; }
.reading-list{ padding: 0 16px 24px; display:flex; flex-direction:column; gap: 10px; }
.reading-item{ background: var(--card); }
.reading-item.done{ border-color: var(--good); }
.reading-item.done .plan-text b::after{ content: " ✓"; color: var(--good); }
.reading-icon{ font-size: 26px; flex-shrink:0; }
.article-body{ flex:1; padding: 4px 16px 28px; }
.article-para{ background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 16px 18px; margin: 0 0 12px; line-height: 2.1; font-size: 16px; }
.article-sentence{ display:inline; }
.article-en{ font-size: 17px; }
.article-he{ display:block; font-size: 13.5px; color: var(--ink-soft); margin: 0 0 10px; }

/* ---------- Progress ---------- */
.progress-body{ padding: 0 16px 24px; }
.cefr-card{ background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; text-align:center; }
.cefr-label{ font-size: 13px; color: var(--ink-soft); }
.cefr-level{ font-family: "Baloo 2", sans-serif; font-size: 44px; font-weight: 700; color: var(--primary-dark); line-height: 1.2; margin-bottom: 10px; }
.lvl-row{ display:grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items:center; font-size: 13px; margin-top: 6px; text-align: right; }
.stats-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stats-grid div{ background: var(--card); border-radius: 16px; padding: 14px; text-align:center; box-shadow: var(--shadow); display:flex; flex-direction:column; }
.stats-grid b{ font-size: 22px; color: var(--primary-dark); }
.stats-grid span{ font-size: 13px; color: var(--ink-soft); }
.sec-title{ font-size: 18px; margin: 22px 0 10px; }
.skills{ display:flex; flex-direction:column; gap: 10px; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.skill-row{ display:grid; grid-template-columns: 90px 1fr; gap: 4px 10px; align-items:center; }
.skill-name{ font-weight: 700; font-size: 14px; }
.skill-val{ grid-column: 2; font-size: 12px; color: var(--ink-soft); }
.week-card{ background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.week-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; margin-bottom: 6px; }
.week-grid div{ display:flex; flex-direction:column; }
.week-grid b{ font-size: 20px; color: var(--primary-dark); }
.week-grid span{ font-size: 12px; color: var(--ink-soft); }
.week-line{ font-size: 13px; margin: 8px 0 0; }
.week-line.good{ color: var(--good); font-weight:700; }
.link-btn{ background:none; color: var(--primary-dark); font-weight:700; text-decoration: underline; padding:0; min-height:auto; font-size: inherit; }
.mastery-map{ display:flex; flex-direction:column; gap: 8px; }
.mastery-row{ display:grid; grid-template-columns: 1fr; gap: 4px; text-align: right; background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-sm); transition: transform .12s ease, box-shadow .15s ease; }
.mastery-row:hover{ box-shadow: var(--shadow); }
.mastery-row:active{ transform: scale(.99); }
.mastery-name{ font-weight: 700; font-size: 14px; }
.mastery-val{ font-size: 12px; color: var(--ink-soft); }
.rem-list, .badges{ display:flex; flex-wrap: wrap; gap: 8px; }
.badge{ background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13px; opacity: .45; display:inline-flex; gap: 6px; align-items:center; }
.badge.on{ opacity: 1; box-shadow: var(--shadow); }
.settings{ display:flex; flex-direction:column; gap: 8px; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.set-row{ display:flex; justify-content: space-between; align-items:center; gap: 10px; min-height: var(--tap); font-size: 15px; }
.set-row input[type=checkbox]{ width: 24px; height: 24px; }
.set-row select{ min-height: var(--tap); border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); padding: 0 10px; font-size: 15px; }

/* ---------- Reward / interstitial ---------- */
#screen-reward.active, #screen-interstitial.active{ align-items:center; justify-content:center; padding:24px 16px; text-align:center; }
.reward-card{ background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 22px; max-width: 460px; width:100%; }
.reward-burst{ font-size: 54px; animation: pop .6s ease; }
@keyframes pop{ 0%{ transform: scale(0); } 60%{ transform: scale(1.2);} 100%{ transform: scale(1); } }
.reward-card h2{ margin: 8px 0 16px; color: var(--primary-dark); }
.reward-gift-box{ font-size:60px; margin-bottom: 10px; background: none; transition: transform .2s; min-width: 88px; min-height: 88px; }
.reward-gift-box:active, .reward-gift-box.opened{ transform: scale(1.2) rotate(-8deg); }
.reward-message{ font-size:15px; color: var(--ink-soft); margin-bottom: 16px; min-height: 20px; line-height: 1.6; }
.reward-note{ font-size: 13px; color: var(--ink-soft); }
.reward-stats{ display:flex; justify-content:center; gap: 22px; margin-bottom: 14px; }
.reward-stat{ display:flex; flex-direction:column; align-items:center; }
.reward-stat-num{ font-size:22px; font-weight:800; color: var(--primary); }
.reward-stat-label{ font-size:12px; color: var(--ink-soft); }
.badge-unlock{ display:flex; align-items:center; gap:12px; background: linear-gradient(135deg,#fff4da,#ffe6c2); border-radius:16px; padding:14px; margin-bottom:18px; text-align:right; }
.badge-icon{ font-size:34px; }
.badge-title{ font-size:12px; color:#8a6a1f; font-weight:700; }
.badge-name{ font-weight:800; font-size:15px; color:#5c4210; }
.inter-buttons{ display:flex; flex-direction:column; gap: 4px; margin-top: 8px; }

/* ---------- Certificate ---------- */
#screen-certificate.active{ align-items:center; justify-content:center; padding:24px 16px; }
.certificate-card{ background: var(--card); border: 3px dashed var(--star); border-radius: var(--radius); box-shadow: var(--shadow); padding: 40px 22px; text-align:center; max-width: 480px; width: 100%; }
.cert-ribbon{ font-size:50px; }
.cert-sub{ color: var(--ink-soft); margin: 6px 0 2px; }
.cert-name{ font-size: 26px; font-weight:800; color: var(--primary-dark); margin-bottom: 14px; }
.cert-body{ font-size:14px; color: var(--ink-soft); line-height:1.6; }
.cert-emph{ color: var(--primary); font-weight:700; }
#btn-cert-close{ margin-top: 18px; }

@media (max-width: 420px){
  .welcome-card, .reward-card, .certificate-card{ padding: 24px 16px; }
  .q-title{ font-size: 18px; }
  .q-word-en{ font-size: 24px; }
  .q-sentence{ font-size: 19px; }
  .topbar-title{ font-size: 15px; }
  .skill-row{ grid-template-columns: 76px 1fr; }
}

/* ---------- Tablet / wide screens: the small centered cards (welcome, onboarding, reward,
   certificate, confirm dialog) get a bit more room instead of floating like a stretched phone card ---------- */
@media (min-width: 700px){
  .welcome-card{ max-width: 560px; padding: 44px 40px; }
  .welcome-emoji{ font-size: 50px; }
  .welcome-card h1{ font-size: 32px; }
  .onb-card{ max-width: 600px; padding: 36px 32px; }
  .onb-card h2{ font-size: 27px; }
  .onb-options.minutes{ grid-template-columns: repeat(4, 1fr); }
  .reward-card{ max-width: 520px; padding: 38px 30px; }
  .certificate-card{ max-width: 540px; padding: 48px 32px; }
  .modal-card{ max-width: 440px; }
  .cefr-level{ font-size: 52px; }
  .stats-grid{ grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* =====================================================================
   Duolingo-style visual layer (same purple palette, flat + tactile)
   Flat surfaces, thick bottom edges on every tappable, path-style map.
   ===================================================================== */
:root{
  --edge: #d3c9f7;          /* bottom "3D" edge of neutral tappables */
  --primary-edge: #4a2fd0;
  --good-edge: #27a058;
  --bad-edge: #e0404f;
  --radius: 18px;
  --shadow: 0 2px 0 var(--line);
  --shadow-sm: 0 2px 0 var(--line);
  --shadow-lift: 0 4px 0 var(--edge);
}
@media (prefers-color-scheme: dark){
  :root{ --edge:#100c1e; --primary-edge:#4a2fd0; --shadow:0 2px 0 #100c1e; --shadow-sm:0 2px 0 #100c1e; --shadow-lift:0 4px 0 #100c1e; }
}
body{ background: var(--bg); }
h1,h2{ letter-spacing:-.2px; }

/* cards: flat with outline instead of blurry shadow */
.welcome-card,.onb-card,.today-card,.unit-card,.cefr-card,.week-card,.skills,.settings,
.reward-card,.mission-step-card,.article-para,.learn-expl,.stats-grid div,.mastery-row,
.examples li,.word-list li,.mission-checklist li,.modal-card{
  box-shadow:none; border:2px solid var(--line);
}
.certificate-card{ box-shadow:none; }

/* buttons: chunky, press down on tap */
.btn{ text-transform:none; letter-spacing:.2px; border-radius:16px; font-weight:800; transition: transform .08s ease, box-shadow .08s ease, filter .15s ease; }
.btn-primary{ background: var(--primary); box-shadow: 0 5px 0 var(--primary-edge); }
.btn-primary:hover{ filter:brightness(1.05); box-shadow: 0 5px 0 var(--primary-edge); }
.btn-primary:active{ transform: translateY(4px); box-shadow: 0 1px 0 var(--primary-edge); }
.btn-primary:disabled{ background: var(--track); color: var(--ink-soft); box-shadow: 0 5px 0 var(--edge); opacity:1; }
.btn-ghost{ border:2px solid var(--line); border-radius:16px; box-shadow: 0 4px 0 var(--edge); color: var(--primary-dark); font-weight:800; }
.btn-ghost:active{ transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.btn-ghost.small{ box-shadow:0 3px 0 var(--edge); }
.btn-ghost.danger{ color: var(--bad); }
.icon-btn{ border:2px solid var(--line); box-shadow:0 3px 0 var(--edge); }
.icon-btn:active{ transform: translateY(2px); box-shadow:0 1px 0 var(--edge); }

/* top bar: stats as flat pills */
.topbar{ backdrop-filter:none; -webkit-backdrop-filter:none; background: var(--bg); border-bottom:2px solid var(--line); }
.stat{ background:transparent; box-shadow:none; padding:4px 8px; font-weight:800; }

/* bottom nav: icon tabs with highlighted active tile */
.bottom-nav{ backdrop-filter:none; -webkit-backdrop-filter:none; background: var(--card); box-shadow:none; border-top:2px solid var(--line); padding: 4px 6px env(safe-area-inset-bottom); gap:4px; }
.bottom-nav button{ border:2px solid transparent; border-radius:14px; min-height:56px; margin:2px 0; text-transform:none; }
.bottom-nav button.active{ background: var(--soft); border-color: var(--primary); color: var(--primary-dark); }
.bottom-nav button.active span{ transform:none; }
.bottom-nav button.active::before{ display:none; }

/* progress bars: thick, glossy-flat, green like Duolingo */
.progress-bar-outer,.lesson-progress-outer{ height:16px; border-radius:16px; background: var(--track); }
.progress-bar-inner,.lesson-progress-inner{ background: var(--good); border-radius:16px; position:relative; }
.progress-bar-inner::after,.lesson-progress-inner::after{ content:""; position:absolute; top:3px; left:8px; right:8px; height:4px; border-radius:4px; background: rgba(255,255,255,.35); }

/* answer options: 2px outline + thick bottom edge */
.option,.match-item,.chunk,.plan-item,.convo-item,.onb-option,.chip{
  border:2px solid var(--line); border-bottom-width:4px; box-shadow:none;
  transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.option:active,.match-item:active,.chunk:active,.plan-item:active,.convo-item:active,.onb-option:active,.chip:active{ transform: translateY(2px); border-bottom-width:2px; margin-bottom:2px; }
.option:hover,.match-item:hover,.chunk:hover{ background: var(--soft); }
.option.selected,.match-item.selected,.onb-option.on,.chip.on{ border-color: var(--primary); background: var(--soft); color: var(--primary-dark); }
.option.correct,.match-item.matched{ border-color: var(--good); background: var(--good-bg); color:#1c6b3f; }
.option.wrong,.match-item.wrong-flash{ border-color: var(--bad); background: var(--bad-bg); color:#b3283a; }
@media (prefers-color-scheme: dark){
  .option.correct,.match-item.matched{ color:#8ee8b3; }
  .option.wrong,.match-item.wrong-flash{ color:#ffa3ad; }
}
.match-item.matched{ opacity:.55; }
.option:disabled:active{ transform:none; border-bottom-width:4px; margin-bottom:0; }
.plan-item:hover,.convo-item:hover{ box-shadow:none; border-color: var(--primary); }
.type-answer-input,#user-name,.set-row select{ border-width:2px; border-bottom-width:4px; border-radius:16px; }

/* lesson screen */
.q-title{ font-size:22px; }
.q-kicker{ text-transform:none; font-weight:800; color: var(--primary); }
.q-emoji{ font-size:88px; }
.say-btn{ border-bottom-width:4px; }
.say-group.big .say-btn{ border:2px solid var(--line); border-bottom-width:4px; box-shadow:none; background: var(--card); }
.npc-bubble,.bubble.npc{ border:2px solid var(--line); box-shadow:none; }
.bubble.me{ border:2px solid var(--primary); }
.mic-btn{ background: var(--primary); box-shadow: 0 6px 0 var(--primary-edge); }
.mic-btn:active{ transform: translateY(4px); box-shadow:0 2px 0 var(--primary-edge); }
.mic-btn.listening{ box-shadow:0 6px 0 var(--bad-edge); }

/* bottom feedback panel: full-bleed, tinted, like Duolingo */
.lesson-footer{ border-top:2px solid var(--line); background: var(--bg); }
.feedback-banner{ margin: -12px -16px 12px; padding:16px; border-radius:0; border-top:none; }
.feedback-banner.good{ background: var(--good-bg); color:#1c6b3f; }
.feedback-banner.bad{ background: var(--bad-bg); color:#b3283a; }
.feedback-banner .feedback-sub{ color: inherit; }
.feedback-title{ font-size:18px; font-weight:800; }
.feedback-icon{ width:40px; height:40px; border-radius:50%; background:#fff; display:flex; align-items:center; justify-content:center; font-size:22px; flex-shrink:0; }
@media (prefers-color-scheme: dark){
  .feedback-banner.good{ color:#8ee8b3; } .feedback-banner.bad{ color:#ffa3ad; }
  .feedback-icon{ background: var(--card); }
}

/* course map: winding path of chunky round nodes */
.unit-card{ border:none; background:transparent; padding:0; margin-bottom:28px; }
.unit-head{ background: var(--primary); color:#fff; border-radius: var(--radius); padding:14px 16px; box-shadow: 0 5px 0 var(--primary-edge); margin-bottom:22px; }
.unit-head .unit-icon{ background: rgba(255,255,255,.2); }
.unit-title{ font-size:17px; color:#fff; }
.unit-head .tag, .unit-head span{ color:inherit; }
.lesson-rows{ align-items:center; gap:14px; }
.lesson-row{ width:min(100%,340px); border:none; padding:6px 8px; border-radius:16px; align-items:center; background:transparent; }
.lesson-row:hover{ background:transparent; }
.lesson-row:nth-child(4n+2),.lesson-row:nth-child(4n+4){ transform: translateX(34px); }
.lesson-row:nth-child(4n+3){ transform: translateX(56px); }
.lesson-state{ width:60px; height:60px; font-size:24px; border:none; background: var(--track); color: var(--ink-soft); box-shadow: 0 6px 0 var(--edge); flex-shrink:0; }
.lesson-row:active .lesson-state{ transform: translateY(4px); box-shadow:0 2px 0 var(--edge); }
.st-mastered .lesson-state{ background:#ffc93c; color:#fff; box-shadow:0 6px 0 #d9a520; }
.st-completed .lesson-state{ background: var(--good); color:#fff; box-shadow:0 6px 0 var(--good-edge); }
.st-current, .st-current:hover{ background:transparent; border:none; }
.st-current .lesson-state{ background: var(--primary); color:#fff; box-shadow:0 6px 0 var(--primary-edge); animation: node-bob 1.6s ease-in-out infinite; }
.st-available .lesson-state,.st-placedOut .lesson-state{ background: var(--primary); color:#fff; border:none; box-shadow:0 6px 0 var(--primary-edge); }
.st-locked .lesson-state,.st-planned .lesson-state{ background: var(--track); }
.st-locked,.st-planned{ opacity:.7; }
@keyframes node-bob{ 0%,100%{ translate:0 0; } 50%{ translate:0 -5px; } }
.lesson-text b{ font-size:15px; }
.mini-bar{ height:8px; border-radius:8px; }
.mini-bar span{ background: var(--good); }
.map-level-title{ font-size:22px; }

/* home / progress accents */
.stats-grid b,.week-grid b,.reward-stat-num{ color: var(--primary); }
.cefr-level{ color: var(--primary); }
.badge{ border:2px solid var(--line); }
.badge.on{ box-shadow:none; border-color: var(--star); }
.reward-card,.modal-card{ border-bottom-width:5px; }
.toast{ border-radius:16px; font-weight:700; }

@media (prefers-reduced-motion: reduce){
  .st-current .lesson-state,.reward-burst,.mic-btn.listening{ animation:none; }
  .btn,.option,.chunk,.lesson-state{ transition:none; }
}

/* ---------- Home: streak + XP hero, Duolingo-style daily path ---------- */
.home-body{ padding-bottom: 116px; }
.streak-card{ background: var(--card); border:2px solid var(--line); border-radius: var(--radius); padding:16px; display:flex; flex-direction:column; gap:14px; }
.streak-main{ display:flex; align-items:center; gap:14px; }
.streak-flame{ font-size:56px; line-height:1; filter: drop-shadow(0 4px 0 rgba(255,159,90,.35)); animation: flame 1.8s ease-in-out infinite; }
.streak-num{ font-family:"Baloo 2","Heebo",sans-serif; font-size:44px; font-weight:800; line-height:1; color: var(--accent); }
.streak-sub{ font-size:14px; font-weight:700; color: var(--ink-soft); margin-top:2px; }
.streak-week{ list-style:none; margin:0; padding:0; display:grid; grid-template-columns:repeat(7,1fr); gap:6px; text-align:center; }
.streak-week li{ display:flex; flex-direction:column; align-items:center; gap:4px; font-size:12px; font-weight:800; color: var(--ink-soft); }
.day-dot{ width:34px; height:34px; border-radius:50%; background: var(--track); display:flex; align-items:center; justify-content:center; font-size:17px; box-shadow: 0 3px 0 var(--edge); }
.streak-week li.on .day-dot{ background:#fff1dc; box-shadow:0 3px 0 #f5c98f; }
.streak-week li.today .day-dot{ outline:3px solid var(--primary); outline-offset:2px; }
.streak-week li.today{ color: var(--primary-dark); }
.xp-row{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.xp-box{ display:flex; align-items:center; gap:8px; background: var(--soft); border:2px solid var(--line); border-radius:14px; padding:10px 12px; }
.xp-box span{ font-size:22px; }
.xp-box b{ font-size:22px; font-weight:800; color: var(--primary-dark); }
.xp-box small{ font-size:12px; font-weight:700; color: var(--ink-soft); margin-inline-start:auto; }
@keyframes flame{ 0%,100%{ transform: scale(1) rotate(-2deg); } 50%{ transform: scale(1.08) rotate(2deg); } }

/* today's plan as a vertical path of round nodes */
.plan-list{ gap:0; position:relative; }
.plan-list li{ position:relative; padding-bottom:14px; }
.plan-list li:not(:last-child)::before{ content:""; position:absolute; inset-inline-start:33px; top:62px; bottom:-2px; width:6px; border-radius:6px; background: var(--track); }
.plan-item{ background:transparent; border:none; border-bottom:none; padding:4px 6px; min-height:0; }
.plan-item:hover{ border:none; background:transparent; }
.plan-item:active{ transform:none; margin-bottom:0; border-bottom-width:0; }
.plan-icon{ width:56px; height:56px; border-radius:50%; background: var(--primary); box-shadow:0 5px 0 var(--primary-edge); display:flex; align-items:center; justify-content:center; font-size:26px; transition: transform .08s ease, box-shadow .08s ease; }
.plan-item:active .plan-icon{ transform: translateY(4px); box-shadow:0 1px 0 var(--primary-edge); }
.plan-item.done{ opacity:1; }
.plan-item.done .plan-icon{ background: var(--good); box-shadow:0 5px 0 var(--good-edge); }
.plan-item.done .plan-text b{ color: var(--ink-soft); text-decoration: line-through; }
.plan-text b{ font-size:16px; }
.plan-min{ background: var(--soft); border-radius:999px; padding:4px 10px; }

/* main CTA pinned above the bottom nav */
#btn-home-main{ position:fixed; bottom: calc(90px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); width:calc(100% - 32px); max-width:560px; z-index:15; }
#btn-home-main:active{ transform: translateX(-50%) translateY(4px); }
#screen-home:not(.active) #btn-home-main{ display:none; }

@media (prefers-reduced-motion: reduce){ .streak-flame{ animation:none; } }

/* ---------- Lesson-complete screen ---------- */
#screen-reward.active{ background: var(--bg); }
.reward-card{ position:relative; overflow:hidden; border:2px solid var(--line); border-bottom-width:5px; }
.reward-card > *:not(.confetti){ position:relative; z-index:1; }
.reward-card h2{ font-size:26px; color: var(--primary); }
.reward-burst{ font-size:72px; }
.reward-gift-box{ background: var(--soft); border:2px solid var(--line); border-bottom-width:5px; border-radius:24px; margin-bottom:14px; }
.reward-stats{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:16px; }
.reward-stat{ border:2px solid; border-radius:16px; overflow:hidden; background: var(--card); align-items:stretch; }
.reward-stat-label{ padding:4px 0; font-size:12px; font-weight:800; color:#fff; text-align:center; }
.reward-stat-num{ display:flex; justify-content:center; align-items:center; gap:4px; padding:10px 0; font-size:22px; font-weight:800; }
.reward-stat.xp{ border-color:#ffc93c; } .reward-stat.xp .reward-stat-label{ background:#ffc93c; color:#5c4210; } .reward-stat.xp .reward-stat-num{ color:#c98f00; }
.reward-stat.acc{ border-color: var(--good); } .reward-stat.acc .reward-stat-label{ background: var(--good); } .reward-stat.acc .reward-stat-num{ color: var(--good-edge); }
.reward-stat.fire{ border-color: var(--accent); } .reward-stat.fire .reward-stat-label{ background: var(--accent); } .reward-stat.fire .reward-stat-num{ color:#e07a2a; }
.badge-unlock{ border:2px solid var(--star); }
.confetti{ position:absolute; inset:0; pointer-events:none; z-index:0; overflow:hidden; }
.confetti i{ position:absolute; top:-14px; width:9px; height:14px; border-radius:2px; opacity:.9; animation: confetti-fall linear forwards; }
@keyframes confetti-fall{ to{ top:105%; translate: 30px 0; rotate: 540deg; opacity:.9; } }
@media (prefers-reduced-motion: reduce){ .confetti{ display:none; } }
#reward-stars-earned, #reward-accuracy{ direction:ltr; unicode-bidi:isolate; }

/* ---------- Conversations, missions & reading (Duolingo-style) ---------- */
/* hint cards read like a friendly tip, not a warning box */
.convo-note,.reading-note{ background: var(--soft); border:2px solid var(--line); border-inline-start:6px solid var(--primary); border-radius: var(--radius); color: var(--ink); }
.convo-section-title{ font-size:20px; }

/* list rows: icon tile + title + chevron */
.convo-item,.reading-item{ width:100%; display:flex; align-items:center; gap:14px; padding:12px 14px; min-height:76px; border-radius: var(--radius); text-align:right; position:relative; }
.convo-item::after,.reading-item::after{ content:"‹"; font-size:28px; font-weight:800; color: var(--primary); margin-inline-start:auto; line-height:1; }
.convo-icon,.reading-icon{ width:56px; height:56px; border-radius:16px; background: var(--soft); border:2px solid var(--line); box-shadow:0 4px 0 var(--edge); display:flex; align-items:center; justify-content:center; font-size:28px; flex-shrink:0; }
.convo-item:hover,.reading-item:hover{ border-color: var(--primary); background: var(--soft); }
.convo-item .plan-text,.reading-item .plan-text{ flex:1; }
.convo-item .plan-text b,.reading-item .plan-text b{ font-size:17px; }

/* locked conversations: grey tile with lock, no chevron */
.convo-item.locked{ opacity:1; background: var(--bg); border-color: var(--line); }
.convo-item.locked .convo-icon{ background: var(--track); filter: grayscale(1); opacity:.7; }
.convo-item.locked .plan-text b{ color: var(--ink-soft); }
.convo-item.locked::after{ content:none; }

/* finished articles: green tile + check */
.reading-item.done{ border-color: var(--good); }
.reading-item.done .reading-icon{ background: var(--good-bg); border-color: var(--good); box-shadow:0 4px 0 var(--good-edge); }
.reading-item.done::after{ content:"✓"; width:30px; height:30px; border-radius:50%; background: var(--good); color:#fff; font-size:18px; display:flex; align-items:center; justify-content:center; }
.reading-item.done .plan-text b::after{ content:""; }

/* chat: speech bubbles with tails, my replies solid purple */
.chat-intro{ background: var(--soft); border-radius:16px; margin:0 16px 8px; padding:10px 14px; }
.chat-log{ padding-top:12px; }
.bubble{ border-radius:20px; font-weight:700; }
.bubble.npc{ background: var(--card); border:2px solid var(--line); border-bottom-width:4px; border-top-right-radius:6px; }
.bubble.me{ background: var(--primary); color:#fff; border:2px solid var(--primary-edge); border-bottom-width:4px; border-top-left-radius:6px; }
.bubble.me .say-btn{ background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.4); color:#fff; }
.bubble.me .bubble-he{ color: rgba(255,255,255,.85); }
.chat-footer{ border-top:2px solid var(--line); }
.chat-choices .option{ justify-content:center; text-align:center; }
.chat-type-row .text-input{ border:2px solid var(--line); border-bottom-width:4px; border-radius:16px; padding:12px 14px; background: var(--card); color: var(--ink); font-size:16px; }
.chat-type-row .text-input:focus{ outline:none; border-color: var(--primary); }

/* reading a story: each paragraph a card, English prominent, tap highlight */
.article-body{ padding-bottom:24px; }
.article-para{ border-radius: var(--radius); line-height:2; }
.article-en{ font-size:19px; color: var(--ink); border-bottom:2px dotted var(--primary); border-radius:0; padding:0 2px; }
.article-en:hover,.article-en:active{ background: var(--soft); }
.article-he{ border-inline-start:3px solid var(--line); padding-inline-start:8px; margin-top:4px; }
#btn-article-done{ background: var(--good); box-shadow:0 5px 0 var(--good-edge); }
#btn-article-done:hover{ box-shadow:0 5px 0 var(--good-edge); }
#btn-article-done:active{ box-shadow:0 1px 0 var(--good-edge); }

/* ---------- Progress screen (Duolingo-style profile) ---------- */
.progress-body{ display:flex; flex-direction:column; gap:0; padding-bottom:24px; }
.cefr-card{ background: var(--primary); border:none; box-shadow:0 6px 0 var(--primary-edge); color:#fff; border-radius: var(--radius); padding:20px 16px 16px; }
.cefr-label{ color: rgba(255,255,255,.85); font-weight:800; font-size:14px; }
.cefr-level{ color:#fff; font-size:34px; line-height:1.3; margin-bottom:14px; }
.cefr-card .lvl-row{ color:#fff; font-weight:700; }
.cefr-card .progress-bar-outer{ background: rgba(255,255,255,.28); }
.cefr-card .progress-bar-inner{ background:#ffc93c; }
.cefr-card .progress-bar-inner::after{ background: rgba(255,255,255,.5); }

/* stat tiles: each one has its own accent, like Duolingo's profile stats */
.stats-grid{ gap:12px; margin-top:20px; }
.stats-grid div{ flex-direction:column; align-items:center; gap:2px; border-width:2px; border-bottom-width:4px; border-radius:16px; padding:14px 8px; }
.stats-grid div:nth-child(1){ border-color: var(--accent); } .stats-grid div:nth-child(1) b{ color:#e07a2a; }
.stats-grid div:nth-child(2){ border-color:#4aa8ff; } .stats-grid div:nth-child(2) b{ color:#2b86d9; }
.stats-grid div:nth-child(3){ border-color: var(--good); } .stats-grid div:nth-child(3) b{ color: var(--good-edge); }
.stats-grid div:nth-child(4){ border-color: var(--primary); } .stats-grid div:nth-child(4) b{ color: var(--primary); }
.stats-grid b{ font-size:26px; font-family:"Baloo 2","Heebo",sans-serif; }
.stats-grid span{ font-weight:700; }
.sec-title{ font-size:20px; font-weight:800; margin:28px 0 12px; }

/* weekly card & skills: thick coloured bars */
.week-card{ border-color: var(--line); }
.week-grid b{ font-size:24px; font-family:"Baloo 2","Heebo",sans-serif; }
.skill-row{ grid-template-columns:96px 1fr; }
.skill-row .progress-bar-outer{ height:14px; }
.skill-row:nth-child(5n+1) .progress-bar-inner{ background: var(--primary); }
.skill-row:nth-child(5n+2) .progress-bar-inner{ background:#4aa8ff; }
.skill-row:nth-child(5n+3) .progress-bar-inner{ background: var(--accent); }
.skill-row:nth-child(5n+4) .progress-bar-inner{ background: var(--good); }
.skill-row:nth-child(5n+5) .progress-bar-inner{ background:#ff5d9e; }
.skill-name{ font-weight:800; }

/* mastery map rows & chips */
.mastery-row{ border-bottom-width:4px; }
.rem-list .chip{ background: var(--card); }

/* achievements: grid of badge tiles; locked ones are grey */
.badges{ display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
.badge{ border-radius:16px; border:2px solid var(--line); border-bottom-width:4px; padding:12px 12px; font-weight:800; font-size:14px; opacity:1; filter:grayscale(1); color: var(--ink-soft); background: var(--bg); }
.badge > span[aria-hidden]{ font-size:26px; }
.badge.on{ filter:none; color: var(--ink); background: var(--card); border-color: var(--star); box-shadow:none; }

/* settings: grouped list rows */
.settings{ gap:0; padding:6px 14px 14px; }
.set-row{ padding:8px 0; border-bottom:2px solid var(--line); font-weight:700; }
.settings .btn-ghost{ margin-top:10px; }
.set-row input[type=checkbox]{ accent-color: var(--primary); }
.set-row select{ max-width:58%; min-width:0; text-overflow:ellipsis; }

/* ---------- Welcome & onboarding (Duolingo-style) ---------- */
#screen-welcome.active{ background: var(--bg); }
.welcome-card{ border-bottom-width:5px; padding:32px 24px 28px; }
.welcome-emoji{ font-size:64px; letter-spacing:6px; margin-bottom:12px; animation: welcome-bob 2.4s ease-in-out infinite; }
@keyframes welcome-bob{ 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-6px); } }
.welcome-card h1{ font-size:32px; color: var(--primary); }
.subtitle{ font-weight:700; font-size:16px; }
.tagline{ background: var(--warn-bg); color:#8a6a1f; border-radius:999px; display:inline-block; padding:6px 14px; margin:8px 0 22px; }
@media (prefers-color-scheme: dark){ .tagline{ color:#ffd98a; } }
#name-entry label{ text-align:right; font-weight:800; }
#btn-start,#btn-continue{ font-size:18px; padding:16px 22px; }
.welcome-back{ font-weight:800; font-size:18px; }

#screen-onboarding.active{ background: var(--bg); align-items:stretch; justify-content:flex-start; padding:0; }
.onb-card{ border:none; border-radius:0; background: transparent; max-width:560px; margin:0 auto; padding:20px 16px 28px; }
.onb-progress{ height:16px; margin-bottom:22px; }
.onb-step{ font-size:13px; font-weight:800; color: var(--primary); }
.onb-card h2{ font-size:26px; color: var(--ink); margin:6px 0 8px; }
.onb-sub{ font-size:15px; }
.onb-option{ border-radius:18px; padding:16px 18px; }
.onb-option b{ font-size:17px; }
.onb-option.on,.onb-option:hover{ border-color: var(--primary); background: var(--soft); }
.chips{ gap:10px; }
.chip{ padding:12px 18px; font-size:15px; }

@media (prefers-reduced-motion: reduce){ .welcome-emoji{ animation:none; } }

/* ---------- Mission screen polish ---------- */
.mission-checklist li{ display:flex; align-items:center; gap:12px; font-weight:700; font-size:15px; border-bottom-width:4px; padding:12px 14px; }
.mission-checklist li > span[aria-hidden]{ font-size:0; flex-shrink:0; width:28px; height:28px; border-radius:50%; border:3px solid var(--line); background: var(--bg); display:inline-flex; align-items:center; justify-content:center; }
.mission-checklist li.done{ opacity:1; text-decoration:none; color: var(--ink-soft); }
.mission-checklist li.done > span[aria-hidden]{ background: var(--good); border-color: var(--good); }
.mission-checklist li.done > span[aria-hidden]::after{ content:"✓"; font-size:16px; font-weight:800; color:#fff; }
.mission-step-card{ border-bottom-width:5px; }
.text-input,#mission-input{ width:100%; border:2px solid var(--line); border-bottom-width:4px; border-radius:16px; padding:14px 16px; font-size:17px; font-family:inherit; background: var(--bg); color: var(--ink); margin-bottom:12px; }
#mission-input:focus,.text-input:focus{ outline:none; border-color: var(--primary); }
.chat-type-row .text-input{ margin-bottom:0; width:auto; }
.mission-step-card #mission-hint{ width:100%; }
.xp-box small{ white-space:nowrap; font-size:11px; }

/* ---------- Habits: weekly goal, easy day, banners ---------- */
.week-goal{ background: var(--card); border:2px solid var(--line); border-bottom-width:4px; border-radius: var(--radius); padding:14px 16px; display:flex; flex-direction:column; gap:10px; }
.week-goal-head{ display:flex; justify-content:space-between; align-items:baseline; font-size:15px; }
.week-goal-head span{ font-weight:800; color: var(--primary-dark); }
.week-goal-foot{ display:flex; justify-content:space-between; align-items:center; gap:8px; font-size:13px; font-weight:700; color: var(--ink-soft); }
.week-goal-foot .btn-ghost.small{ margin-top:0; }
.easy-day-btn{ background: var(--soft); border:2px solid var(--line); border-bottom-width:4px; border-radius:999px; padding:4px 12px; font-size:12px; font-weight:800; color: var(--ink-soft); min-height:32px; }
.easy-day-btn.on{ background: var(--good-bg); border-color: var(--good); color:#1c6b3f; }
@media (prefers-color-scheme: dark){ .easy-day-btn.on{ color:#8ee8b3; } }
.today-head{ flex-wrap:wrap; gap:6px; }
.home-banners{ display:flex; flex-direction:column; gap:12px; }
.home-banners:empty{ display:none; }
.banner{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; background: var(--warn-bg); border:2px solid var(--star); border-radius: var(--radius); padding:12px 14px; }
.banner-icon{ font-size:28px; }
.banner-text{ flex:1; min-width:160px; display:flex; flex-direction:column; gap:2px; }
.banner-text b{ font-size:15px; } .banner-text span{ font-size:13px; color: var(--ink-soft); line-height:1.5; }
.banner-actions{ display:flex; align-items:center; gap:10px; }
.btn.small{ padding:8px 14px; font-size:14px; min-height:40px; width:auto; }

/* ---------- Reading / listening switch ---------- */
.seg{ display:flex; gap:8px; margin:0 16px 12px; background: var(--soft); border:2px solid var(--line); border-radius:16px; padding:4px; }
.seg button{ flex:1; background:transparent; border-radius:12px; padding:10px 8px; font-weight:800; font-size:15px; color: var(--ink-soft); min-height:44px; }
.seg button.on{ background: var(--card); color: var(--primary-dark); box-shadow:0 2px 0 var(--edge); border:2px solid var(--primary); }

/* ---------- Listening player ---------- */
.listen-body{ flex:1; padding:10px 16px 20px; display:flex; flex-direction:column; min-width:0; }
.listen-player{ display:flex; flex-direction:column; align-items:center; gap:14px; margin:18px 0; }
.listen-play{ width:112px; height:112px; border-radius:50%; background: var(--primary); color:#fff; font-size:44px; box-shadow:0 8px 0 var(--primary-edge); transition: transform .08s ease, box-shadow .08s ease; }
.listen-play:active{ transform: translateY(6px); box-shadow:0 2px 0 var(--primary-edge); }
.listen-play.playing{ animation: pulse 1.2s infinite; }
.listen-actions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:center; }
.listen-lines{ display:flex; flex-direction:column; gap:10px; margin-top:8px; }
.listen-line{ background: var(--card); border:2px solid var(--line); border-radius:14px; padding:10px 14px; display:flex; flex-direction:column; gap:4px; }
.listen-line.now{ border-color: var(--primary); background: var(--soft); }
.listen-line .article-en{ text-align:left; font-size:17px; }
.listen-result{ box-shadow:none; max-width:none; border:none; padding:10px 0; text-align:center; }
.listen-result .listen-lines{ text-align:right; margin-top:16px; }

/* ---------- Shadowing (record & compare) ---------- */
.shadow-box{ display:flex; flex-direction:column; align-items:center; gap:8px; width:100%; padding:12px; border:2px dashed var(--line); border-radius:16px; }
.shadow-actions{ display:flex; gap:8px; }

/* ---------- Trouble words & unit celebration ---------- */
.trouble-card{ background: var(--card); border:2px solid var(--line); border-bottom-width:4px; border-radius: var(--radius); padding:14px; display:flex; flex-direction:column; gap:14px; }
.trouble-words{ display:flex; flex-wrap:wrap; gap:8px; }
.trouble-word{ display:inline-flex; flex-direction:column; align-items:center; gap:2px; background: var(--bad-bg); border:2px solid var(--bad); border-radius:14px; padding:8px 12px; font-weight:800; }
.trouble-word small{ font-size:12px; color: var(--ink-soft); font-weight:700; }
.unit-unlock{ border-color: var(--good); background: var(--good-bg); }
.unit-unlock .badge-title{ color:#1c6b3f; } .unit-unlock .badge-name{ color:#14502e; }
