:root {
  --bg: #f7f3ec; --card: #ffffff; --ink: #14213d; --muted: #6b7280; --line: #e7e0d4;
  --brand: #14213d; --accent: #ff6b4a; --accent-soft: #ffe6df; --good: #1f9d6b; --good-soft: #dcf5ea;
  --bad: #d64545; --bad-soft: #fde4e4; --gold: #f2b134; --chip: #efe9df; --shadow: 0 2px 0 rgba(20,33,61,.08), 0 8px 24px rgba(20,33,61,.06);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1424; --card: #1a2136; --ink: #eef1f8; --muted: #9aa3b8; --line: #2a3350; --brand: #eef1f8;
  --accent: #ff7d5e; --accent-soft: #3a2420; --good: #3ccf91; --good-soft: #15352a; --bad: #ff6b6b; --bad-soft: #3d1d22;
  --chip: #242c45; --shadow: 0 2px 0 rgba(0,0,0,.3);
} }
:root[data-theme="dark"] {
  --bg: #0f1424; --card: #1a2136; --ink: #eef1f8; --muted: #9aa3b8; --line: #2a3350; --brand: #eef1f8;
  --accent: #ff7d5e; --accent-soft: #3a2420; --good: #3ccf91; --good-soft: #15352a; --bad: #ff6b6b; --bad-soft: #3d1d22;
  --chip: #242c45; --shadow: 0 2px 0 rgba(0,0,0,.3);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Rubik', system-ui, sans-serif; }
body { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
#app { max-width: 620px; margin: 0 auto; padding: 16px; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }
.en { direction: ltr; unicode-bidi: isolate; text-align: left; }
.he { direction: rtl; text-align: right; }

/* top bar */
.top { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 18px; }
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.5px; }
.logo b { color: var(--accent); }
.pills { display: flex; gap: 8px; }
.pill { background: var(--card); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); white-space: nowrap; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.hero { background: var(--ink); color: var(--bg); position: relative; overflow: hidden; }
:root[data-theme="dark"] .hero { background: #26304d; color: #eef1f8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: #26304d; color: #eef1f8; } }
.hero h2 { margin: 0 0 6px; font-size: 22px; }
.hero p { margin: 0 0 14px; opacity: .8; font-size: 15px; }
.hero .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.hero .meta span { background: rgba(255,255,255,.12); padding: 5px 10px; border-radius: 999px; font-size: 13px; }
.btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 17px; background: var(--accent); color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.18); transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn.ghost { background: var(--chip); color: var(--ink); box-shadow: none; }
.btn.good { background: var(--good); }
.btn.small { padding: 10px 14px; font-size: 15px; width: auto; display: inline-block; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.goal { height: 10px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.goal i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

h3.sec { font-size: 15px; color: var(--muted); font-weight: 600; margin: 22px 4px 10px; }
.worlds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.world { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.world .ic { font-size: 24px; }
.world .nm { font-weight: 700; margin: 6px 0 2px; font-size: 15px; }
.world .sub { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.world .goal { height: 6px; }

/* session */
.sbar { display: flex; align-items: center; gap: 12px; margin: 2px 0 20px; }
.sbar .x { background: none; border: 0; font-size: 22px; color: var(--muted); padding: 4px 8px; }
.sbar .goal { flex: 1; height: 12px; }
.combo { font-weight: 700; color: var(--accent); min-width: 44px; text-align: center; }
.kind { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: none; margin-bottom: 8px; letter-spacing: .2px; }
.q { font-size: 15px; color: var(--muted); margin-bottom: 10px; }
.big { font-size: 26px; font-weight: 700; line-height: 1.3; margin: 6px 0 10px; }
.mid { font-size: 19px; font-weight: 500; line-height: 1.45; }
.sub2 { color: var(--muted); font-size: 15px; line-height: 1.5; }
.note { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-top: 12px; }
.blank { display: inline-block; min-width: 70px; border-bottom: 3px solid var(--accent); }
.speakbtn { background: var(--chip); border: 0; border-radius: 12px; padding: 8px 12px; font-size: 15px; margin-inline-end: 6px; }
.opts { display: grid; gap: 10px; margin-top: 16px; }
.opt { text-align: inherit; background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; padding: 14px 16px; font-size: 17px; line-height: 1.35; }
.opt.en { text-align: left; }
.opt:hover { border-color: var(--muted); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.opt .k { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; background: var(--chip); font-size: 12px; color: var(--muted); margin-inline-end: 8px; }

.tiles { display: flex; flex-wrap: wrap; gap: 8px; direction: ltr; }
.answer { min-height: 58px; border-bottom: 2px dashed var(--line); padding: 6px 0 12px; margin: 12px 0; }
.tile { background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; padding: 8px 12px; font-size: 17px; }
.tile.used { visibility: hidden; }
input.txt { width: 100%; font: inherit; font-size: 19px; padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); direction: ltr; }
input.txt:focus { outline: none; border-color: var(--accent); }

.fb { position: fixed; inset-inline: 0; bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--good-soft); border-top: 2px solid var(--good); z-index: 30; animation: up .18s ease-out; }
.fb.bad { background: var(--bad-soft); border-color: var(--bad); }
.fb .in { max-width: 620px; margin: 0 auto; }
.fb h4 { margin: 0 0 6px; font-size: 19px; color: var(--good); }
.fb.bad h4 { color: var(--bad); }
.fb .sub2 { margin-bottom: 12px; color: var(--ink); }
@keyframes up { from { transform: translateY(100%); } }
body.in-session #tabbar { display: none; }
body.in-session { padding-bottom: 200px; }

/* chat */
.chat { direction: ltr; display: flex; flex-direction: column; gap: 10px; }
.bub { max-width: 85%; padding: 10px 14px; border-radius: 18px; font-size: 17px; line-height: 1.4; }
.bub.them { align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.bub.you { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.bub .who { font-size: 12px; font-weight: 700; opacity: .65; margin-bottom: 2px; }
.bub .tr { font-size: 13px; color: var(--muted); margin-top: 4px; direction: rtl; text-align: right; display: none; }
.bub.show .tr { display: block; }
.chat .wrap { display: flex; flex-direction: column; }
.setting { font-size: 14px; color: var(--muted); background: var(--chip); padding: 8px 12px; border-radius: 12px; margin-bottom: 12px; }

/* book & stats */
.search { width: 100%; font: inherit; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); margin-bottom: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chipb { border: 0; background: var(--chip); padding: 7px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.chipb.on { background: var(--ink); color: var(--bg); }
.entry { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.entry .t { flex: 1; min-width: 0; }
.entry .e1 { font-weight: 600; font-size: 16px; }
.entry .e2 { color: var(--muted); font-size: 14px; }
.entry .e3 { color: var(--muted); font-size: 13px; margin-top: 3px; }
.dots { display: flex; gap: 3px; margin-top: 6px; direction: ltr; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--good); }
.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; direction: ltr; overflow-x: auto; padding: 4px 0; }
.heat i { width: 11px; height: 11px; border-radius: 3px; background: var(--chip); }
.heat i.l1 { background: #ffc7b8; } .heat i.l2 { background: #ff9a80; } .heat i.l3 { background: var(--accent); }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 8px; }
.ach div { background: var(--card); border-radius: 14px; padding: 10px; font-size: 13px; text-align: center; box-shadow: var(--shadow); opacity: .4; }
.ach div.on { opacity: 1; }
.ach div b { display: block; font-size: 22px; }
label.set { display: block; margin: 14px 0 6px; font-weight: 600; }
select, input[type=range] { width: 100%; font: inherit; padding: 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px; font-weight: 600; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); }
.code { font-family: ui-monospace, monospace; background: var(--chip); padding: 8px 10px; border-radius: 10px; direction: ltr; display: inline-block; letter-spacing: 1px; user-select: all; }

#tabbar { position: fixed; bottom: 0; inset-inline: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
#tabbar[hidden] { display: none; }
#tabbar button { flex: 1; border: 0; background: none; font-size: 12px; color: var(--muted); padding: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
#tabbar button span { font-size: 20px; }
#tabbar button.on { color: var(--accent); font-weight: 700; }
#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-120px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; z-index: 50; transition: transform .3s; max-width: 90vw; text-align: center; }
#toast.show { transform: translateX(-50%) translateY(0); }
.done-hero { text-align: center; padding: 30px 10px; }
.done-hero .em { font-size: 60px; }
.done-hero h2 { margin: 10px 0 4px; font-size: 26px; }
@media (max-width: 380px) { .big { font-size: 22px; } .opt { font-size: 16px; } }
