:root {
  --bg: #fff8f1;
  --card: #ffffff;
  --ink: #2b1a0e;
  --muted: #7a6656;
  --line: #f0dfcf;
  --brand: #e8590c;
  --brand-2: #ff922b;
  --brand-soft: #fff0e3;
  --ok: #2b8a3e;
  --ok-soft: #e6f6ea;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --focus: #1c7ed6;
  --shadow: 0 2px 10px rgba(80, 40, 10, .08);
  --radius: 16px;
  --fs: 17px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120e; --card: #221a14; --ink: #f4e9df; --muted: #b29d8b; --line: #3a2d22;
    --brand-soft: #3a2316; --ok-soft: #173321; --bad-soft: #3b1a1a; --shadow: none;
  }
}
:root.big-text { --fs: 21px; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: var(--fs)/1.55 "Segoe UI", "Rubik", "Arial Hebrew", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.app { max-width: 760px; margin: 0 auto; padding: 12px 16px 48px; }
h1, h2, h3 { line-height: 1.25; margin: .3em 0 .5em; }
h1 { font-size: 1.5em; } h2 { font-size: 1.3em; } h3 { font-size: 1.08em; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; }
.en { font-family: "Segoe UI", Verdana, Arial, sans-serif; unicode-bidi: isolate; }
.b { font-weight: 700; } .ok { color: var(--ok); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* cards & buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.btn, .btn-ghost, .btn-icon, .choice, .chip, .tile, .iopt, .pblank, .match-word, .match-def {
  font: inherit; color: inherit; cursor: pointer; border-radius: 12px; -webkit-tap-highlight-color: transparent;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 18px; border: 2px solid var(--line); background: var(--card); text-decoration: none; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:not(:disabled):active { transform: translateY(1px); }
.btn-wide { width: 100%; margin-top: 10px; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .9em; }
.btn-ghost { background: none; border: none; padding: 8px 10px; min-height: 44px; min-width: 44px; text-decoration: none; font-size: 1.1em; }
.btn-ghost.small { font-size: .85em; color: var(--muted); }
.btn-icon { background: var(--brand-soft); border: none; width: 40px; height: 40px; font-size: 1.1em; margin-inline-start: 8px; vertical-align: middle; }
.btn-big { font-size: 1.3em; padding: 14px 22px; border-radius: 14px; border: 2px solid var(--brand); background: var(--brand-soft); }

.inp { font: inherit; width: 100%; min-height: 50px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); }
.inp:focus { border-color: var(--brand); outline: none; }
.inp.small { min-height: 40px; width: auto; padding: 6px 10px; }
.inp.good { border-color: var(--ok); background: var(--ok-soft); }
.inp:disabled { opacity: .8; }
textarea.inp { resize: vertical; }

/* topbar & home */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.brand { font-weight: 800; }
.chips { display: flex; gap: 6px; }
.chip-s { background: var(--brand-soft); border-radius: 999px; padding: 2px 10px; font-weight: 700; font-size: .9em; }
.hero { display: flex; gap: 16px; align-items: center; }
.hero-txt { flex: 1; min-width: 0; }
.countdown { font-size: 1.35em; font-weight: 800; color: var(--brand); }
.ring-wrap { text-align: center; flex: 0 0 auto; }
.ring { width: 110px; height: 110px; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--brand); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .6s; }
.ring-num { font: 800 26px "Segoe UI", Arial, sans-serif; fill: var(--ink); }
.ring-label { font-size: .85em; color: var(--muted); }
.btn-mission { display: flex; flex-direction: column; width: 100%; min-height: 76px; font-size: 1.2em; border-radius: 18px; }
.btn-mission .sub { font-size: .7em; font-weight: 400; opacity: .9; }
.sec-h { margin-top: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tiles.two { margin-top: 10px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; background: var(--card); border: 1px solid var(--line); text-decoration: none; box-shadow: var(--shadow); }
.tile.accent { border: 2px solid var(--brand); }
.tile .t-ic { font-size: 1.6em; }
.tile .muted { font-size: .85em; }

/* round */
.round-head { display: flex; align-items: center; gap: 8px; }
.round-title { flex: 1; font-weight: 700; }
.round-score { font-weight: 800; }
.pbar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 12px; }
.pbar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); transition: width .4s; }
.round-body { min-height: 40vh; }
.instr { color: var(--muted); font-weight: 600; margin: 8px 0; }
.prompt { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 16px; text-align: center; margin-bottom: 12px; }
.big { font-size: 1.75em; font-weight: 800; }
.choices { display: grid; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; text-align: start; padding: 14px; min-height: 56px; border: 2px solid var(--line); background: var(--card); font-size: 1.05em; }
.choice .kbd { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--brand-soft); font-size: .8em; font-weight: 800; flex: 0 0 auto; }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.hint { min-height: 1.6em; font-family: Consolas, monospace; font-size: 1.2em; letter-spacing: .08em; text-align: center; margin: 8px 0; }
.hint-he { font-family: inherit; letter-spacing: 0; font-size: .85em; color: var(--muted); }
.syll { font-size: 1.1em; letter-spacing: .05em; color: var(--brand); font-weight: 700; }
.cloze { font-size: 1.25em; line-height: 1.7; }
.blank { display: inline-block; min-width: 4em; border-bottom: 3px solid var(--brand); color: var(--brand); font-weight: 700; text-align: center; }
.frames { font-size: .85em; margin: 6px 0; }

.card.learn { text-align: center; }
.learn-en { font-size: 2em; font-weight: 800; }
.learn-he { font-size: 1.5em; margin: 6px 0; }
.learn-ex { margin-top: 12px; font-size: 1.1em; }
.learn-tip { margin-top: 10px; background: var(--brand-soft); border-radius: 12px; padding: 8px 12px; }
.pos { font-size: .55em; color: var(--muted); margin-inline-start: 8px; }

/* feedback panel */
.round-foot { margin-top: 12px; scroll-margin-bottom: 16px; }
.feedback { border-radius: var(--radius); padding: 14px 16px; border: 2px solid; background: var(--card); box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
.fb-actions .btn-primary { position: sticky; bottom: 8px; }
.feedback.ok { border-color: var(--ok); background: var(--ok-soft); }
.feedback.bad { border-color: var(--bad); background: var(--bad-soft); }
.fb-title { font-weight: 800; font-size: 1.15em; }
.fb-tag { font-weight: 700; color: var(--bad); margin: 4px 0; }
.fb-word { margin: 6px 0; }
.fb-en { font-weight: 800; }
.fb-ex { color: var(--muted); }
.fb-tip { margin-top: 4px; }
.fb-conf { margin: 4px 0; }
.fb-copy { margin-top: 8px; }
.fb-actions { display: flex; flex-direction: column; align-items: stretch; }
.diffs { background: var(--card); border-radius: 10px; padding: 8px 12px; margin: 6px 0; font-family: Consolas, monospace; font-size: 1.25em; }
.diff-l { color: var(--muted); font-size: .7em; }
.d-bad { color: var(--bad); text-decoration: underline wavy; }
.d-strike { text-decoration: line-through; }
.d-fix { color: var(--ok); font-weight: 800; text-decoration: underline; }
.d-gap { color: var(--bad); }
.score-pill { display: inline-block; background: var(--card); border-radius: 99px; padding: 2px 12px; font-weight: 800; }

.round-done { text-align: center; padding: 20px 0; }
.big-emoji { font-size: 3.2em; }
.mistakes { text-align: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin: 12px 0; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.done-note { font-weight: 800; font-size: 1.1em; }

/* match */
.match { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 10px; }
.match-col { display: grid; gap: 8px; align-content: start; }
.match-word, .match-def { text-align: start; padding: 10px 12px; border: 2px solid var(--line); background: var(--card); min-height: 48px; }
.match-word .tag { display: inline-block; min-width: 1.6em; text-align: center; font-weight: 800; color: var(--brand); margin-inline-end: 6px; }
.match-word.sel { border-color: var(--brand); background: var(--brand-soft); }
.match-def.used { opacity: .55; }
.match-word.right { border-color: var(--ok); background: var(--ok-soft); }
.match-word.wrong { border-color: var(--bad); background: var(--bad-soft); }
@media (max-width: 520px) { .match { grid-template-columns: 1fr; } }

/* paragraph */
.para { font-size: 1.12em; line-height: 2.1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.pblank { border: none; border-bottom: 3px dashed var(--brand); background: var(--brand-soft); padding: 0 8px; font-weight: 700; border-radius: 6px; }
.pblank.active { outline: 3px solid var(--focus); }
.pblank.filled { border-bottom-style: solid; }
.pblank.right { background: var(--ok-soft); border-color: var(--ok); }
.pblank.wrong { background: var(--bad-soft); border-color: var(--bad); }
.bank { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; justify-content: center; }
.chip { border: 2px solid var(--brand); background: var(--card); padding: 8px 14px; font-weight: 700; min-height: 44px; }
.chip:disabled { opacity: .3; }

/* quiz */
.quiz-top { display: flex; align-items: center; gap: 8px; }
.quiz-sec { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.sec-title { font-weight: 800; font-size: 1.1em; }
.qrow { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.qrow.col { flex-direction: column; align-items: stretch; }
.qrow .inp { flex: 1; min-width: 180px; }
.qn { font-weight: 800; color: var(--brand); }
.qhe { min-width: 7em; font-weight: 700; }
.qen { min-width: 7em; font-weight: 700; }
.defs { background: var(--brand-soft); border-radius: 12px; padding: 10px 14px; margin-top: 10px; }
.inline-opts { white-space: normal; }
.iopt { border: 2px solid var(--line); background: var(--card); padding: 2px 10px; min-height: 38px; margin: 2px 0; }
.iopt.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 800; }
.bank-line { font-weight: 700; background: var(--brand-soft); border-radius: 10px; padding: 6px 12px; margin-bottom: 10px; }
.inp.inline { display: inline-block; width: auto; min-height: 38px; padding: 2px 6px; margin: 2px; }
.quiz-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 8px; }
.checklist { text-align: start; background: var(--brand-soft); border-radius: 12px; padding: 10px 16px; margin: 12px 0; }
.checklist ul { list-style: none; padding: 0; margin: 6px 0 0; }
.sec-scores { display: grid; gap: 4px; text-align: start; margin-top: 10px; }
.sec-score { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.mistake { border-top: 1px solid var(--line); padding: 10px 0; }
.m-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .9em; }
.m-sec { font-weight: 700; }
.m-tag { color: var(--bad); }
.m-pts { margin-inline-start: auto; color: var(--muted); }
.m-why { margin-top: 4px; background: var(--brand-soft); border-radius: 10px; padding: 6px 10px; }

/* words list */
.toolbar { margin: 8px 0; }
.wordlist { display: grid; gap: 6px; }
.wl-row { display: grid; grid-template-columns: 1.3fr 1fr auto auto; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.wl-en { font-weight: 700; direction: ltr; text-align: left; }
.wl-box { color: var(--brand); letter-spacing: 1px; font-size: .8em; }
.wl-tag { font-size: .75em; background: var(--brand-soft); border-radius: 99px; padding: 1px 8px; margin-inline-start: 6px; }
@media (max-width: 480px) { .wl-row { grid-template-columns: 1fr 1fr; } }

/* login */
.login { max-width: 420px; margin: 8vh auto; text-align: center; }
.logo { font-size: 3.5em; }
.seg { display: flex; border: 2px solid var(--line); border-radius: 14px; overflow: hidden; margin: 14px 0; }
.seg button { flex: 1; font: inherit; padding: 12px; border: none; background: var(--card); color: var(--ink); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; font-weight: 700; }
.pin { text-align: center; font-size: 1.4em; letter-spacing: .3em; }
.err { color: var(--bad); min-height: 1.4em; margin-top: 6px; }

/* parent */
.parent-head { display: flex; justify-content: space-between; align-items: center; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.grid3 .card { margin: 0; text-align: center; }
.big-num { font-size: 2em; font-weight: 800; color: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.4em; }
.stat span { font-size: .8em; color: var(--muted); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--brand-2); }
.chart .dot { fill: var(--ok); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 3; }
.chart .goal { stroke: var(--ok); stroke-dasharray: 6 6; }
.chart .axis { font-size: 11px; fill: var(--muted); }
.legend { font-size: .85em; }
.lg-bar, .lg-dot { display: inline-block; width: 12px; height: 12px; vertical-align: middle; }
.lg-bar { background: var(--brand-2); } .lg-dot { background: var(--ok); border-radius: 50%; }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr auto; gap: 8px; align-items: center; font-size: .9em; }
.hb-t { background: var(--line); height: 12px; border-radius: 99px; overflow: hidden; }
.hb-f { display: block; height: 100%; background: var(--bad); opacity: .75; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .88em; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.tbl tr.weak td { background: var(--bad-soft); }
.tbl tr.good td:first-child { box-shadow: inset -4px 0 0 var(--ok); }
.quiz-row { border-top: 1px solid var(--line); padding: 8px 0; }
.quiz-row summary { cursor: pointer; }
.sent { border-top: 1px solid var(--line); padding: 10px 0; }
.sent-text { font-size: 1.1em; background: var(--brand-soft); border-radius: 10px; padding: 6px 10px; margin: 4px 0; }

/* progress mini bars */
.mini-bars { display: flex; gap: 6px; align-items: flex-end; height: 120px; }
.mb { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; text-align: center; font-size: .7em; color: var(--muted); }
.mb-f { background: var(--brand-2); border-radius: 6px 6px 0 0; }

/* dialog & toast */
dialog.menu { border: none; border-radius: var(--radius); padding: 16px; width: min(92vw, 360px); background: var(--card); color: var(--ink); }
dialog.menu::backdrop { background: rgba(0,0,0,.35); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; opacity: 0; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* grammar navigator */
.nav-steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.nav-step { flex: 1; min-width: 92px; text-align: center; padding: 6px; border-radius: 10px; background: var(--line); font-size: .8em; color: var(--muted); }
.nav-step.cur { background: var(--brand); color: #fff; font-weight: 700; }
.nav-step.done { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.nav-step.err { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
.tok { display: inline-block; padding: 2px 4px; margin: 1px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; background: none; font: inherit; color: inherit; }
.tok:hover { background: var(--brand-soft); }
.tok.on { border-color: var(--brand); background: var(--brand-soft); }
.tok.marker { background: #ffe066; color: #2b1a0e; font-weight: 700; }
.tok.wrongpick { border-color: var(--bad); }
.verb-hint { color: var(--muted); }
.rule-card { background: var(--brand-soft); border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.red-s { color: var(--bad); font-weight: 800; }
.flow { display: grid; gap: 8px; }
.flow-box { border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--card); }
.flow-arrow { text-align: center; color: var(--muted); }
