:root {
  --bg: #FAF7F0;
  --ink: #1C2541;
  --ink-2: #3A4256;
  --muted: #5B6275;
  --line: #E6E0D2;
  --line-2: #EFEAE0;
  --card: #FFFFFF;
  --brand: #1F3A93;
  --brand-soft: #E9EDF8;
  --brand-ink: #DCE3F5;
  --gold: #E0A526;
  --gold-soft: #FFF3D6;
  --gold-ink: #5A3D00;
  --ok-bg: #E3F1EA; --ok-fg: #1E5A3C;
  --warn-bg: #FFE9D6; --warn-fg: #8A3B00;
  --bad-bg: #FDE4E4; --bad-fg: #9B1C1C;
  --radius: 20px;
  --font-rtl: 'Noto Sans Arabic', 'Inter', system-ui, sans-serif;
  --font-ltr: 'Inter', 'Noto Sans Arabic', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #EFEBE1; color: var(--ink); font-family: var(--font-rtl); -webkit-font-smoothing: antialiased; }
html[dir="ltr"] body { font-family: var(--font-ltr); }
.app { max-width: 480px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; position: relative; }
@media (min-width: 560px) { .app { box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(28,37,65,.08); } }
a { color: var(--brand); }
button { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; font-family: var(--font-ltr); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* layout */
.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 24px 20px 24px; }
.screen.with-nav { padding-bottom: 100px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.h1 { font-size: 26px; font-weight: 800; line-height: 1.3; margin: 0; }
.h2 { font-size: 17px; font-weight: 800; margin: 0; }
.sub { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.6; }
.small { font-size: 12px; color: var(--muted); line-height: 1.6; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--brand); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.link { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list > * + * { border-top: 1px solid var(--line-2); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); }
.icon-box { width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hero { background: var(--brand); color: #fff; border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.hero .muted { color: var(--brand-ink); }

/* buttons */
.btn { min-height: 52px; border-radius: 16px; border: 0; padding: 0 18px; font-size: 16px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; }
.btn-brand { background: var(--brand); color: #fff; }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-ghost { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); font-weight: 700; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); cursor: pointer; flex-shrink: 0; text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .word:focus-visible, a:focus-visible, .opt:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* pills & chips */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.info { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.pill.neutral { background: #F2EEE4; color: var(--ink-2); font-weight: 600; }
.streak { height: 40px; padding: 0 14px; border-radius: 20px; background: var(--gold-soft); color: #7A5200; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* progress */
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.hero .bar { height: 6px; background: rgba(255,255,255,.22); }
.hero .bar > i { background: var(--gold); }

/* search */
.search { height: 50px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 14px; color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); min-width: 0; }
.search:focus-within { border-color: var(--brand); }

/* practice */
.words { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; direction: ltr; }
.word { min-height: 56px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font-family: var(--font-ltr); font-size: 18px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; padding: 0 8px; }
.word[aria-pressed="true"] { border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand); }
.word.right { border: 2px solid var(--ok-fg); background: var(--ok-bg); color: var(--ok-fg); }
.word.wrong { border: 2px solid var(--bad-fg); background: var(--bad-bg); color: var(--bad-fg); }
.word.missed { border: 2px dashed var(--ok-fg); background: var(--card); color: var(--ok-fg); }
.sentence { direction: ltr; text-align: left; font-family: var(--font-ltr); font-size: 20px; line-height: 1.6; font-weight: 600; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.sentence .blank { display: inline-block; min-width: 80px; border-bottom: 3px solid var(--brand); color: var(--brand); text-align: center; }
.opts { display: flex; flex-direction: column; gap: 10px; direction: ltr; }
.opt { min-height: 52px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card); text-align: left; padding: 0 16px; font-family: var(--font-ltr); font-size: 17px; font-weight: 600; cursor: pointer; color: var(--ink); }
.opt[aria-pressed="true"] { border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand); }
.opt.right { border: 2px solid var(--ok-fg); background: var(--ok-bg); color: var(--ok-fg); }
.opt.wrong { border: 2px solid var(--bad-fg); background: var(--bad-bg); color: var(--bad-fg); }
.tip { border-radius: 16px; background: var(--gold-soft); padding: 14px 16px; display: flex; gap: 10px; align-items: flex-start; color: var(--gold-ink); font-size: 14px; line-height: 1.6; }
.feedback { border-radius: 16px; padding: 14px 16px; font-size: 15px; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.feedback.ok { background: var(--ok-bg); color: var(--ok-fg); }
.feedback.bad { background: var(--bad-bg); color: var(--bad-fg); }
.timer { display: flex; align-items: center; gap: 8px; color: var(--warn-fg); font-size: 14px; font-weight: 600; }
.bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

/* result */
.score { font-size: 52px; font-weight: 800; line-height: 1.1; color: var(--brand); }
.share-card { background: var(--brand); color: #fff; border-radius: 22px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.share-card .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--bg); display: flex; align-items: center; justify-content: center; }

/* checklist */
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid #CFC8B8; background: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.check input:checked + .box { background: var(--brand); border-color: var(--brand); }
.check input:checked ~ .lbl { text-decoration: line-through; color: var(--muted); }
.check input:focus-visible + .box { outline: 3px solid var(--gold); outline-offset: 2px; }

/* guide */
.prose { font-size: 16px; line-height: 1.9; color: var(--ink-2); }
.prose h3 { font-size: 17px; color: var(--ink); margin: 18px 0 6px; }
.prose ol, .prose ul { padding-inline-start: 22px; margin: 6px 0; }
.prose li { margin-bottom: 8px; }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* nav */
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; height: 76px; padding: 8px 6px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); z-index: 10; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.nav a[aria-current="page"] { color: var(--brand); font-weight: 800; }

/* welcome */
.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 64px 28px 40px; text-align: center; }
.logo-big { width: 96px; height: 96px; border-radius: 28px; background: var(--brand); display: flex; align-items: center; justify-content: center; }
.lang-btn { height: 60px; border-radius: 18px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; font-size: 20px; font-weight: 700; cursor: pointer; width: 100%; background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.lang-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.lang-btn .tag { font-family: var(--font-ltr); font-size: 13px; font-weight: 500; opacity: .8; }

.toast { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; z-index: 20; max-width: 90vw; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
