/* تعلّم التركية — الأنماط
 * الألوان كلها متغيرات على :root، ويُعاد تعريفها للوضع الليلي:
 * تلقائياً حسب الجهاز، أو يدوياً بـ data-theme على عنصر html (زر ◐).
 */
:root {
  --bg: #f8f3ec;
  --surface: #fffdf9;
  --surface-2: #f3eadf;
  --ink: #2a1f1f;
  --muted: #6f6461;
  --line: #e7dacb;
  --brand: #b3262e;
  --brand-2: #cc3a40;
  --brand-ink: #fff;
  --teal: #1f7a72;
  --gold: #b8892d;
  --gold-soft: #f6e8c8;
  --good: #2f8a4c;
  --warn: #c07a12;
  --bad: #b3262e;
  --tr-word: #1f4e79;
  --shadow: 0 1px 2px rgba(60, 25, 15, .06), 0 6px 20px rgba(60, 25, 15, .06);
  --radius: 14px;
  --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-head: 'Amiri', 'Traditional Arabic', serif;
  --font-tr: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --tabbar-h: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151112; --surface: #1e1819; --surface-2: #2a2223; --ink: #f0e7e2;
    --muted: #a99d99; --line: #3a2f30; --brand: #f0646a; --brand-2: #ff7d82; --brand-ink: #1a1012;
    --teal: #4fb8ad; --gold: #dcb462; --gold-soft: #3b3020; --good: #5cbf7a; --warn: #e3a440; --bad: #f0646a;
    --tr-word: #8cc0f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .28);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151112; --surface: #1e1819; --surface-2: #2a2223; --ink: #f0e7e2;
  --muted: #a99d99; --line: #3a2f30; --brand: #f0646a; --brand-2: #ff7d82; --brand-ink: #1a1012;
  --teal: #4fb8ad; --gold: #dcb462; --gold-soft: #3b3020; --good: #5cbf7a; --warn: #e3a440; --bad: #f0646a;
  --tr-word: #8cc0f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--brand) var(--surface-2); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
::-webkit-scrollbar { width: 12px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 999px; border: 3px solid var(--surface-2); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.75;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.55rem; color: var(--brand); }
h3 { font-size: 1.2rem; }
.muted { color: var(--muted); }
[hidden], .hidden { display: none !important; }
button { font: inherit; }

/* الكلمة التركية: خط لاتيني واتجاه من اليسار إلى اليمين */
.tr, [lang="tr"] { font-family: var(--font-tr); direction: ltr; unicode-bidi: isolate; }
.tr { color: var(--tr-word); font-weight: 700; }
.pron { font-family: var(--font); color: var(--muted); font-size: .85em; font-weight: 500; }

/* ===== الشريط العلوي ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) 24px 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand strong { display: block; font-family: var(--font-head); font-size: 1.25rem; line-height: 1.1; }
.brand small { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.brand-mark { display: block; width: 40px; height: 40px; flex: none; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: nowrap; }
.nav a { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.active { background: var(--brand); color: var(--brand-ink); }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1.1rem; text-decoration: none;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.install-btn { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 800; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; min-height: 70vh; }
.view-head { margin-bottom: 20px; }
.view-head h1 { margin-bottom: .2em; }
.section-title { margin-top: 10px; }

/* ===== عناصر عامة ===== */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 500;
  cursor: pointer; text-decoration: none; transition: transform .1s, background .2s; min-height: 42px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.btn.primary:hover { background: var(--brand-2); }
.btn.sm { padding: 5px 12px; min-height: 34px; font-size: .9rem; }
.btn.good { border-color: var(--good); color: var(--good); }
.btn.bad { border-color: var(--bad); color: var(--bad); }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn:disabled { opacity: .5; cursor: default; }
.chip {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 500;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.chip.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.chip.brand { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }

.search {
  width: 100%; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; outline: none;
}
.search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.search.big { font-size: 1.2rem; padding: 14px 18px; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 220px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; color: var(--muted); padding: 6px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chips-row button {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 4px 12px; border-radius: 999px; cursor: pointer; font-size: .92rem;
}
.chips-row button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chips-row button small { opacity: .75; margin-inline-start: 4px; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.subtabs button {
  border: 0; background: none; padding: 8px 14px; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.subtabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.list-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.list-actions .muted { margin-inline-end: auto; font-size: .92rem; }

/* زر الاستماع */
.say {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--brand); cursor: pointer; font-size: .95rem; padding: 0;
}
.say:hover { border-color: var(--brand); }
.say.sm { width: 28px; height: 28px; font-size: .8rem; }
.say.playing { background: var(--brand); color: var(--brand-ink); }
.say.ar { color: var(--gold); vertical-align: middle; margin-inline-start: 4px; }
.star { background: none; border: 0; cursor: pointer; font-size: 1.2rem; color: var(--line); padding: 0 4px; line-height: 1; }
.star.on { color: var(--gold); }

/* ===== الرئيسية ===== */
.hero {
  text-align: center; padding: 36px 20px 30px; margin-bottom: 24px; border-radius: 20px;
  background:
    radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 50%),
    radial-gradient(circle at 85% 100%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 50%),
    var(--surface);
  border: 1px solid var(--line);
}
.hero h1 { font-size: 2.8rem; }
.hero h1 span { color: var(--brand); }
.lead { font-family: var(--font-head); font-size: 1.25rem; color: var(--muted); margin: 0 auto 20px; max-width: 680px; }
.hero-stats { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.stat { min-width: 112px; padding: 10px 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.stat b { display: block; font-size: 1.7rem; color: var(--brand); line-height: 1.2; font-family: var(--font-tr); }
.stat span { font-size: .85rem; color: var(--muted); }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.today h2, .wotd h2 { font-size: 1.3rem; }
.goal-ring { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring span { width: 68px; height: 68px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 800; font-family: var(--font-tr); }
.goal-ring p { margin: 0; }
.streak { color: var(--warn); font-weight: 800; }
.wotd .big-word { font-size: 2.2rem; margin: 4px 0 0; display: flex; align-items: center; gap: 12px; justify-content: flex-end; flex-direction: row-reverse; }
.wotd .meaning { font-size: 1.25rem; font-weight: 700; margin: 2px 0 8px; }
.wotd .ex { border-inline-start: 3px solid var(--gold); padding-inline-start: 12px; margin-top: 8px; }

.sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 24px; }
.sec-card {
  display: block; text-decoration: none; color: var(--ink); padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.sec-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.sec-card .ico { font-size: 1.8rem; }
.sec-card b { display: block; font-size: 1.15rem; margin: 4px 0 2px; }
.sec-card small { color: var(--muted); display: block; line-height: 1.6; }
.sec-card .count { color: var(--brand); font-weight: 800; font-family: var(--font-tr); }
.steps { margin: 0; padding-inline-start: 22px; }
.steps li { margin-bottom: 6px; }

/* ===== المواضيع ===== */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.topic {
  display: flex; flex-direction: column; gap: 4px; text-align: start; text-decoration: none; color: var(--ink);
  padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s, transform .15s;
}
.topic:hover { border-color: var(--brand); transform: translateY(-2px); }
.topic .ico { font-size: 1.7rem; line-height: 1; }
.topic b { font-size: 1.02rem; }
.topic small { color: var(--muted); font-size: .82rem; }
.mini-bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.mini-bar i { display: block; height: 100%; background: var(--good); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; text-decoration: none; font-weight: 700; }
.topic-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.topic-head .ico { font-size: 2.4rem; }
.topic-head h2 { margin: 0; }

/* ===== قوائم الكلمات ===== */
.word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.wcard {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.wcard.clickable { cursor: pointer; }
.wcard.clickable:hover { border-color: var(--brand); }
.wcard .row { display: flex; align-items: center; gap: 10px; }
.wcard .w { font-size: 1.25rem; }
.wcard .m { font-weight: 700; margin-inline-start: auto; text-align: end; }
.wcard .sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.wcard .ex { font-size: .92rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; }
.wcard .ex .ex-tr { display: flex; align-items: center; gap: 6px; direction: ltr; margin-bottom: 2px; }
.wcard .ex .tr { font-weight: 600; font-size: .95rem; }
.wcard .shift { font-size: .9rem; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--ink); }
.wcard .shift b { color: var(--warn); }
.wcard .note { font-size: .85rem; color: var(--muted); }
.wcard.known { border-inline-start: 4px solid var(--good); }
.wcard.learning { border-inline-start: 4px solid var(--warn); }
.lvl { font-family: var(--font-tr); font-size: .72rem; font-weight: 800; padding: 0 7px; border-radius: 6px; border: 1px solid currentColor; }
.lvl.l1 { color: var(--good); } .lvl.l2 { color: var(--warn); } .lvl.l3 { color: var(--brand); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); grid-column: 1 / -1; }
.more-row { grid-column: 1 / -1; text-align: center; margin-top: 6px; }
.shift-word { color: var(--warn); }

/* مقدمة قسم الكلمات العربية */
.arabic-intro { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ai-card { padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.ai-card b { display: block; color: var(--brand); margin-bottom: 4px; }
.ai-card p { margin: 0; font-size: .92rem; color: var(--muted); }
.ai-card .pair { display: flex; justify-content: space-between; gap: 8px; font-size: .95rem; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.ai-card .pair:last-child { border: 0; }

/* ===== نافذة الفعل ===== */
.dlg {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink);
  width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.dlg::backdrop { background: rgba(20, 10, 10, .55); backdrop-filter: blur(2px); }
.dlg-body { padding: 22px 24px; position: relative; }
.dlg-close { position: absolute; top: 14px; inset-inline-end: 14px; }
.verb-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; padding-inline-end: 44px; }
.verb-head .tr { font-size: 2rem; }
.verb-head .m { font-size: 1.25rem; font-weight: 700; }
.verb-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.verb-ex { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); margin-bottom: 14px; }
.verb-ex .tr { font-weight: 700; }
.conj-ctrl { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.conj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.conj {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg);
}
.conj h4 { margin: 0 0 2px; font-size: 1rem; color: var(--brand); display: flex; justify-content: space-between; gap: 6px; }
.conj h4 code { font-family: var(--font-tr); font-size: .8rem; color: var(--muted); font-weight: 600; direction: ltr; }
.conj .hint { font-size: .78rem; color: var(--muted); margin: 0 0 6px; line-height: 1.5; }
.conj table { width: 100%; border-collapse: collapse; }
.conj td { padding: 2px 0; font-size: .95rem; }
.conj td.p { color: var(--muted); width: 1%; white-space: nowrap; padding-inline-end: 10px; font-size: .85rem; }
.conj td.f { text-align: left; direction: ltr; font-family: var(--font-tr); font-weight: 700; color: var(--tr-word); }
.conj td.f .sfx { color: var(--brand); }
.conj td.s { width: 1%; }
.extras { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; margin-top: 12px; }
.extras div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding: 4px 0; font-size: .95rem; }
.extras .tr { font-weight: 700; }

/* ===== الأساسيات ===== */
.alpha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.letter {
  position: relative; text-align: center; padding: 12px 8px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer;
}
.letter:hover { border-color: var(--brand); }
.letter .L { font-family: var(--font-tr); font-size: 2rem; font-weight: 800; color: var(--tr-word); line-height: 1.1; direction: ltr; }
.letter .A { font-size: 1.3rem; font-weight: 800; color: var(--brand); }
.letter small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.letter .ex { font-family: var(--font-tr); direction: ltr; font-size: .85rem; color: var(--ink); }
.letter.special { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.letter.vowel .L { color: var(--teal); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 4px; vertical-align: middle; }
.rule-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .95rem; }
.rule-table th, .rule-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: start; }
.rule-table th { background: var(--surface-2); }
.rule-table td.tr, .rule-table td [lang="tr"] { text-align: left; }
.table-wrap { overflow-x: auto; }
.callout { padding: 12px 16px; border-radius: 12px; background: var(--gold-soft); margin: 12px 0; }
.callout b { color: var(--gold); }
.harmony-try { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.harmony-try input { max-width: 240px; direction: ltr; text-align: left; font-family: var(--font-tr); }
.harmony-out { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 12px; }
.harmony-out div { padding: 8px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.trkeys { display: flex; gap: 6px; flex-wrap: wrap; }
.trkeys button {
  font-family: var(--font-tr); font-weight: 800; min-width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; font-size: 1.05rem;
}

/* ===== البطاقات ===== */
.setup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.deck {
  text-align: start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.deck:hover { border-color: var(--brand); }
.deck.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.deck .ico { font-size: 1.5rem; }
.deck b { font-size: 1.02rem; }
.deck small { color: var(--muted); font-size: .82rem; }
.deck .due { color: var(--brand); font-weight: 700; }
.opts-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin: 4px 0 18px; }
.opts-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.opts-row select { font: inherit; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.setup-label { font-weight: 700; margin: 8px 0 8px; display: block; }

.card-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: .92rem; color: var(--muted); }
.pbar { flex: 1; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--good); transition: width .3s; }
.flash-wrap { perspective: 1400px; max-width: 600px; margin: 0 auto 16px; touch-action: pan-y; }
.flash { position: relative; min-height: 360px; cursor: pointer; transform-style: preserve-3d; transition: transform .5s; outline: none; }
.flash.flipped { transform: rotateY(180deg); }
.flash.swipe-l { transform: translateX(-120%) rotate(-8deg); opacity: 0; transition: transform .3s, opacity .3s; }
.flash.swipe-r { transform: translateX(120%) rotate(8deg); opacity: 0; transition: transform .3s, opacity .3s; }
.flash .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 22px; padding: 26px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 6px;
}
.flash .front { background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--brand) 8%, transparent), transparent 60%), var(--surface); }
.flash .back { transform: rotateY(180deg); overflow-y: auto; justify-content: flex-start; padding-top: 30px; }
/* احتياط لمتصفحات لا تطبّق backface-visibility: تبديل الوجهين في منتصف الدوران */
.flash .front, .flash.flipped .back { visibility: visible; transition: visibility 0s .2s; }
.flash.flipped .front, .flash .back { visibility: hidden; transition: visibility 0s .2s; }
.flash .tag { position: absolute; top: 14px; inset-inline-start: 16px; }
.flash .box-ind { position: absolute; top: 14px; inset-inline-end: 16px; display: flex; gap: 3px; }
.flash .box-ind i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); }
.flash .box-ind i.on { background: var(--good); }
.flash .q { font-size: 2.6rem; line-height: 1.25; margin: 8px 0 0; word-break: break-word; }
.flash .q.ar { font-family: var(--font-head); color: var(--ink); font-weight: 700; }
.flash .hint { color: var(--muted); font-size: .88rem; margin-top: 14px; }
.flash .ans { font-size: 1.7rem; font-weight: 800; color: var(--ink); line-height: 1.35; }
.flash .ans.tr { color: var(--tr-word); }
.flash .ex { font-size: .98rem; margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); width: 100%; }
.flash .ex .tr { font-weight: 700; }
.flash .shift { width: 100%; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, transparent); font-size: .95rem; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 600px; margin: 0 auto 10px; }
.rate .btn { flex-direction: column; gap: 0; padding: 10px 6px; font-weight: 700; }
.rate .btn small { font-weight: 400; font-size: .75rem; opacity: .85; }
.rate .btn.again { border-color: var(--bad); color: var(--bad); }
.rate .btn.hard { border-color: var(--warn); color: var(--warn); }
.rate .btn.easy { border-color: var(--good); color: var(--good); }
.flip-btn { display: flex; max-width: 600px; margin: 0 auto 10px; width: 100%; }
.kbd-hint { text-align: center; color: var(--muted); font-size: .8rem; }
.done-box { text-align: center; padding: 30px 20px; }
.done-box .big { font-size: 3rem; }
.sum-row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 16px 0; }

/* ===== الاختبار ===== */
.quiz-box { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); min-height: 300px; max-width: 760px; margin: 0 auto; }
.q-top { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin-bottom: 10px; gap: 10px; }
.q-label { color: var(--muted); font-size: .95rem; margin-bottom: 4px; }
.q-text { font-size: 2rem; margin-bottom: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.q-text.ar { font-family: var(--font-head); font-weight: 700; }
.q-text .tr { font-size: 2.1rem; }
.q-listen { display: flex; justify-content: center; margin: 10px 0 22px; }
.q-listen .say { width: 84px; height: 84px; font-size: 2rem; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 1.1rem; cursor: pointer; text-align: start; min-height: 56px;
}
.opt.tr { font-weight: 700; text-align: left; }
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--bg)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--bg)); }
.opt .ord { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: .8rem; margin-inline-end: 8px; font-family: var(--font); }
.type-row { display: flex; gap: 10px; flex-wrap: wrap; }
.type-row input { flex: 1; min-width: 200px; direction: ltr; text-align: left; font-family: var(--font-tr); font-size: 1.3rem; }
.type-row input.right { border-color: var(--good); }
.type-row input.wrong { border-color: var(--bad); }
.feedback { margin-top: 16px; padding: 12px 16px; border-radius: 12px; background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.feedback.ok { background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.next-row { display: flex; justify-content: flex-end; margin-top: 14px; }
.inc { padding: 10px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); margin-bottom: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inc .yours { color: var(--bad); text-decoration: line-through; font-size: .9rem; }
.score-big { font-size: 3.2rem; font-weight: 800; color: var(--brand); font-family: var(--font-tr); line-height: 1.1; }
.mode {
  text-align: start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.mode:hover { border-color: var(--brand); }
.mode.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.mode .ico { font-size: 1.4rem; }
.mode b { font-size: 1.02rem; }
.mode small { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.mode .best { color: var(--gold); font-size: .78rem; font-weight: 700; }

/* ===== التقدم ===== */
.prog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 20px; }
.prog-item { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.prog-item .row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.boxes { display: flex; gap: 6px; align-items: flex-end; height: 130px; margin: 10px 0 4px; }
.boxes div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: .8rem; color: var(--muted); }
.boxes i { display: block; width: 100%; border-radius: 6px 6px 2px 2px; background: var(--good); min-height: 3px; }
.cal { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; max-width: 420px; }
.cal i { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); }
.cal i.on { background: var(--good); }
.cal i.today { outline: 2px solid var(--brand); }

/* ===== التذييل والإشعارات ===== */
.footer { text-align: center; color: var(--muted); font-size: .88rem; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.footer p { margin: 4px 0; }
.toast {
  position: fixed; bottom: calc(20px + var(--tabbar-h) + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 30px);
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 999px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 60; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.ios-install { width: min(460px, calc(100vw - 32px)); }
.ios-steps { margin: 0 0 14px; padding-inline-start: 22px; line-height: 2.2; }
.ios-ico { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); margin: 0 4px; }

/* شريط التنقل السفلي (الجوال فقط) */
.tabbar { display: none; }

/* ===== الشاشات المتوسطة ===== */
@media (max-width: 1100px) and (min-width: 761px) {
  .topbar { gap: 10px; padding-inline: 16px; }
  .nav { gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .nav a { padding: 6px 10px; font-size: .92rem; }
  .brand small { display: none; }
}

/* ===== الجوال ===== */
@media (max-width: 760px) {
  :root { --tabbar-h: 62px; }
  body { font-size: 16px; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 16px 8px; gap: 8px; }
  .brand strong { font-size: 1.15rem; }
  .brand small { font-size: .72rem; }
  .brand-mark { width: 34px; height: 34px; }
  .nav { display: none; }
  .topbar .brand { margin-inline-end: auto; }
  main { padding: 18px 16px 40px; }
  h1 { font-size: 1.75rem; }
  .hero { padding: 26px 14px 22px; }
  .hero h1 { font-size: 2rem; }
  .lead { font-size: 1.08rem; }
  .stat { min-width: 0; flex: 1 1 40%; padding: 8px 10px; }
  .stat b { font-size: 1.4rem; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .panel { padding: 18px 16px; }
  .word-list { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sections { grid-template-columns: 1fr 1fr; gap: 10px; }
  .sec-card { padding: 14px; }
  .sec-card small { display: none; }
  .options { grid-template-columns: 1fr; }
  .q-text { font-size: 1.6rem; }
  .quiz-box { padding: 18px 16px; }
  .flash { min-height: 330px; }
  .flash .q { font-size: 2.1rem; }
  .dlg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; border: 0; }
  .dlg-body { padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
  .conj-grid { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .deck, .mode { padding: 12px; }
  .toolbar .search { min-width: 0; flex-basis: 100%; }
  .subtabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .subtabs button { white-space: nowrap; }
  .alpha-grid { grid-template-columns: repeat(2, 1fr); }
  .footer { padding-bottom: 20px; }

  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 500;
  }
  .tabbar a i { font-style: normal; font-size: 1.25rem; line-height: 1.2; }
  .tabbar a.active { color: var(--brand); font-weight: 700; }
  .tabbar a.active i { transform: scale(1.1); }
  .badge {
    position: absolute; top: 5px; inset-inline-start: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-size: .68rem; display: grid; place-items: center; font-family: var(--font-tr);
  }
}
@media (max-width: 380px) {
  .setup-grid, .sections { grid-template-columns: 1fr; }
}
@media (display-mode: standalone) {
  .footer p:last-child::after { content: ' · يعمل دون اتصال'; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
