/* ============ WordBridge — نظام التصميم ============ */
:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --bg-2: #efece4;
  --surface: #fffefb;
  --surface-2: #f4f2ec;
  --surface-3: #e9e6dd;
  --line: #e3dfd4;
  --line-strong: #cfcabd;
  --ink: #1b1a17;
  --ink-2: #55524b;
  --ink-3: #8a867c;
  --primary: #1b1a17;
  --primary-ink: #fffefb;
  --gold: #e9a91b;
  --gold-soft: #fbefd0;
  --gold-ink: #8a5a00;

  /* ألوان حالات الكلمات (متحقق منها لعمى الألوان) */
  --st-new: #9a968c;
  --st-hard: #eb6834;
  --st-review: #2a78d6;
  --st-mastered: #1baf7a;
  --st-new-soft: #eeece6;
  --st-hard-soft: #fde6dc;
  --st-review-soft: #dde9f9;
  --st-mastered-soft: #d9f3e9;
  --st-hard-ink: #b2441a;
  --st-review-ink: #1c5cab;
  --st-mastered-ink: #0c7a52;

  /* أدوات التعريف */
  --der: #1c5cab;
  --die: #c23a3a;
  --das: #0d7a4c;

  /* خريطة النشاط */
  --heat-0: #ebe8e0;
  --heat-1: #b7d3f6;
  --heat-2: #6da7ec;
  --heat-3: #2a78d6;
  --heat-4: #184f95;

  --hero-a: #1b1a17;
  --hero-b: #2d2a22;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(27, 26, 23, .04), 0 8px 24px -12px rgba(27, 26, 23, .12);
  --shadow-lg: 0 24px 60px -20px rgba(27, 26, 23, .35);
  --font-ar: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  --font-de: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --bg-2: #171716; --surface: #1c1c1a; --surface-2: #242421; --surface-3: #2e2e2a;
    --line: #2f2f2b; --line-strong: #45443e; --ink: #f4f2ea; --ink-2: #c3c0b5; --ink-3: #8d8a80;
    --primary: #f4f2ea; --primary-ink: #141413; --gold: #f2b43c; --gold-soft: #3a2f16; --gold-ink: #f5c66a;
    --st-new: #7b7870; --st-hard: #d95926; --st-review: #3987e5; --st-mastered: #199e70;
    --st-new-soft: #2a2a27; --st-hard-soft: #3a2419; --st-review-soft: #1a2a40; --st-mastered-soft: #15322a;
    --st-hard-ink: #f08a5f; --st-review-ink: #7fb2f0; --st-mastered-ink: #5cd3a5;
    --der: #7fb2f0; --die: #f08a8a; --das: #5cd3a5;
    --heat-0: #262624; --heat-1: #104281; --heat-2: #256abf; --heat-3: #3987e5; --heat-4: #86b6ef;
    --hero-a: #22211d; --hero-b: #2e2c25;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --bg-2: #171716; --surface: #1c1c1a; --surface-2: #242421; --surface-3: #2e2e2a;
  --line: #2f2f2b; --line-strong: #45443e; --ink: #f4f2ea; --ink-2: #c3c0b5; --ink-3: #8d8a80;
  --primary: #f4f2ea; --primary-ink: #141413; --gold: #f2b43c; --gold-soft: #3a2f16; --gold-ink: #f5c66a;
  --st-new: #7b7870; --st-hard: #d95926; --st-review: #3987e5; --st-mastered: #199e70;
  --st-new-soft: #2a2a27; --st-hard-soft: #3a2419; --st-review-soft: #1a2a40; --st-mastered-soft: #15322a;
  --st-hard-ink: #f08a5f; --st-review-ink: #7fb2f0; --st-mastered-ink: #5cd3a5;
  --der: #7fb2f0; --die: #f08a8a; --das: #5cd3a5;
  --heat-0: #262624; --heat-1: #104281; --heat-2: #256abf; --heat-3: #3987e5; --heat-4: #86b6ef;
  --hero-a: #22211d; --hero-b: #2e2c25;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ar);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(circle at 100% 0, var(--bg-2), transparent 40%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.de, [lang="de"] { font-family: var(--font-de); }
.num { font-family: var(--font-de); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 1280px; margin: 0 auto; padding-inline: 24px; }
@media (max-width: 640px) { .wrap { padding-inline: 16px; } }

/* ============ الهيدر ============ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark { width: 44px; height: 44px; display: block; flex: none; }
.brand-name { font-family: var(--font-de); font-weight: 800; font-size: 18px; letter-spacing: -.02em; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); }
.nav { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; margin-inline-start: 12px; }
.nav a {
  text-decoration: none; white-space: nowrap; color: var(--ink-2); padding: 7px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 6px; transition: .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { color: var(--ink); }
.nav a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.topbar .spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 820px) {
  .brand-sub { display: none; }
  .nav a span.lbl { display: none; }
  .btn .lbl-sm { display: none; }
}
@media (max-width: 520px) { .brand-text { display: none; } .nav { margin-inline-start: 0; } }

/* ============ الأزرار ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { border-color: var(--primary); opacity: .92; }
.btn-gold { background: var(--gold); color: #1b1a17; border-color: var(--gold); }
.btn-gold:hover { border-color: var(--gold); filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.is-on { background: var(--surface-3); border-color: var(--line-strong); }
.btn-danger { color: var(--die); }

/* ============ الكروت ============ */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 13px; color: var(--ink-3); margin: 2px 0 0; }
.link { color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; background: none; border: 0; padding: 0; }
.link:hover { color: var(--ink); text-decoration: underline; }

main { padding-block: 28px 64px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }

/* ============ الهيرو ============ */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 30px 32px; color: #f7f3e8;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
  display: grid; grid-template-columns: 1.4fr auto; gap: 28px; align-items: center;
  box-shadow: var(--shadow-lg);
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 12% 120%, rgba(242, 180, 60, .28), transparent 45%),
    radial-gradient(circle at 95% -20%, rgba(221, 44, 44, .18), transparent 40%);
  pointer-events: none;
}
.hero > * { position: relative; }
.hero-hello { direction: ltr; text-align: right; font-family: var(--font-de); color: var(--gold); font-weight: 700; font-size: 14px; letter-spacing: .02em; }
.hero h1 { font-size: clamp(24px, 3vw, 34px); line-height: 1.25; margin: 4px 0 8px; font-weight: 800; }
.hero p { margin: 0; color: #cfc9b8; max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero .btn:not(.btn-gold) { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #f7f3e8; }
.hero .btn:not(.btn-gold):hover { background: rgba(255, 255, 255, .14); }
.hero-stats { display: flex; gap: 22px; align-items: center; }
.ring-wrap { position: relative; width: 148px; height: 148px; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center b { font-size: 34px; line-height: 1; font-family: var(--font-de); }
.ring-center small { color: #cfc9b8; font-size: 12px; margin-top: 4px; }
.streak { text-align: center; }
.streak-flame { font-size: 40px; line-height: 1; filter: drop-shadow(0 4px 12px rgba(242, 180, 60, .45)); }
.streak b { display: block; font-size: 30px; font-family: var(--font-de); line-height: 1.1; margin-top: 4px; }
.streak small { color: #cfc9b8; font-size: 12px; }
.streak.off .streak-flame { filter: grayscale(1); opacity: .5; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding: 24px; } .hero-stats { justify-content: space-around; } }

/* ============ مؤشرات الأداء ============ */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis .kpi:first-child { grid-column: 1 / -1; } }
.kpi {
  position: relative; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px 18px 14px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
  overflow: hidden; display: block;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.kpi::before { content: ''; position: absolute; inset-block: 14px; inset-inline-start: 0; width: 4px; border-radius: 0 4px 4px 0; background: var(--kc, var(--ink)); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--ks, var(--surface-2)); font-size: 17px; }
.kpi-value { font-family: var(--font-de); font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 8px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.kpi-bar { height: 5px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.kpi-bar i { display: block; height: 100%; background: var(--kc); border-radius: 4px; }

/* ============ التخطيط ============ */
.row-2 { display: grid; grid-template-columns: 1fr 1.5fr; gap: 18px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.row-wotd { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
@media (max-width: 980px) { .row-2, .row-3, .row-wotd { grid-template-columns: minmax(0, 1fr); } }

/* ============ الدونات ============ */
.donut-box { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.donut { position: relative; width: 200px; height: 200px; flex: none; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.donut .seg { transition: opacity .15s, stroke-width .15s; cursor: pointer; }
.donut.hovering .seg:not(.on) { opacity: .35; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font-family: var(--font-de); font-size: 36px; line-height: 1; font-weight: 800; }
.donut-center small { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.legend { display: grid; gap: 8px; flex: 1; min-width: 180px; }
.legend-item {
  display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; text-decoration: none; color: inherit; transition: background .15s;
}
.legend-item:hover, .legend-item.on { background: var(--surface-2); }
.legend-sw { width: 12px; height: 12px; border-radius: 4px; }
.legend-item b { font-family: var(--font-de); font-size: 15px; }
.legend-item small { color: var(--ink-3); font-family: var(--font-de); font-size: 12px; min-width: 38px; text-align: end; }

/* ============ رسم النشاط ============ */
.seg-ctl { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg-ctl button { border: 0; background: none; padding: 4px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg-ctl button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--ink-3); font-size: 11px; font-family: var(--font-de); }
.chart .bar { fill: var(--st-review); }
.chart .bar-new { fill: var(--st-mastered); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + g .bar, .chart g.col:hover rect.bar { opacity: .85; }
.chart .goal-line { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 5 5; }
.chart .goal-text { fill: var(--gold-ink); font-size: 11px; font-weight: 700; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 10px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--primary); color: var(--primary-ink);
  padding: 8px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow-lg);
  transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap; opacity: 0; transition: opacity .1s;
}
.tip.show { opacity: 1; }
.tip b { font-family: var(--font-de); }

/* ============ خريطة النشاط ============ */
.heat-scroll { overflow-x: auto; padding-bottom: 4px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 4px; direction: ltr; width: max-content; margin-inline: auto; }
.heat i { width: 14px; height: 14px; border-radius: 4px; background: var(--heat-0); display: block; }
.heat i.l1 { background: var(--heat-1); } .heat i.l2 { background: var(--heat-2); } .heat i.l3 { background: var(--heat-3); } .heat i.l4 { background: var(--heat-4); }
.heat i.today { outline: 2px solid var(--gold); outline-offset: 1px; }
.heat i.future { background: transparent; }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); justify-content: flex-end; margin-top: 10px; direction: ltr; }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
@media (max-width: 640px) { .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mini { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.mini small { color: var(--ink-3); font-size: 12px; display: block; }
.mini b { font-family: var(--font-de); font-size: 22px; font-weight: 800; }
.mini b em { font-style: normal; font-size: 13px; color: var(--ink-3); font-weight: 600; margin-inline-start: 2px; }

/* ============ تقدم الوحدات ============ */
.units { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 28px; }
@media (max-width: 860px) { .units { grid-template-columns: 1fr; } }
.unit {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 4px 12px; align-items: center; text-decoration: none; color: inherit;
  padding: 10px 10px; border-radius: 12px; transition: background .15s;
}
.unit:hover { background: var(--surface-2); }
.unit-n { grid-row: span 2; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-family: var(--font-de); font-weight: 700; font-size: 12.5px; color: var(--ink-2); }
.unit:hover .unit-n { background: var(--surface); }
.unit-name { font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-name small { color: var(--ink-3); font-family: var(--font-de); font-weight: 500; margin-inline-start: 6px; font-size: 12px; }
.unit-pct { font-family: var(--font-de); font-weight: 700; font-size: 13px; color: var(--ink-2); }
.stack { grid-column: 2 / 4; display: flex; height: 8px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack i { display: block; height: 100%; min-width: 0; }
.stack i:first-child { border-start-start-radius: 4px; border-end-start-radius: 4px; }
.stack i:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; }

/* ============ القوايم ============ */
.list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 9px 10px; border-radius: 12px;
  transition: background .15s;
}
.li:hover { background: var(--surface-2); }
.li-de { font-family: var(--font-de); font-weight: 600; font-size: 14.5px; direction: ltr; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-ar { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-txt { min-width: 0; }
.li-meta { font-size: 12px; color: var(--ink-3); font-family: var(--font-de); white-space: nowrap; }
.empty { text-align: center; color: var(--ink-3); padding: 24px 12px; font-size: 14px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 4px; }

/* ============ كلمة اليوم ============ */
.wotd { display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: center; }
.wotd-img { width: 150px; height: 150px; border-radius: 16px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 46px; }
.wotd-tag { font-size: 12px; color: var(--gold-ink); background: var(--gold-soft); padding: 2px 10px; border-radius: 20px; font-weight: 700; display: inline-block; }
.wotd-de { font-family: var(--font-de); font-size: 28px; font-weight: 800; direction: ltr; text-align: right; line-height: 1.25; margin: 8px 0 2px; letter-spacing: -.02em; }
.wotd-ar { font-size: 17px; font-weight: 600; }
.wotd-en { font-family: var(--font-de); font-size: 13px; color: var(--ink-3); direction: ltr; text-align: right; }
@media (max-width: 520px) { .wotd { grid-template-columns: 1fr; } .wotd-img { width: 100%; height: 180px; } }

.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge-ach {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 12px; border-radius: 14px; background: var(--surface-2);
  border: 1px solid var(--line); min-width: 0; flex: 1 1 160px;
}
.badge-ach .ic { font-size: 24px; line-height: 1; }
.badge-ach b { display: block; font-size: 13.5px; }
.badge-ach small { color: var(--ink-3); font-size: 11.5px; }
.badge-ach.locked { opacity: .5; }
.badge-ach.locked .ic { filter: grayscale(1); }
.badge-ach .prog { height: 4px; border-radius: 3px; background: var(--surface-3); margin-top: 4px; overflow: hidden; }
.badge-ach .prog i { display: block; height: 100%; background: var(--gold); }

/* ============ شارات الحالة ============ */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; background: var(--surface-2); color: var(--ink-2);
}
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.new { background: var(--st-new-soft); color: var(--ink-2); }
.chip.new::before { background: var(--st-new); }
.chip.hard { background: var(--st-hard-soft); color: var(--st-hard-ink); }
.chip.review { background: var(--st-review-soft); color: var(--st-review-ink); }
.chip.mastered { background: var(--st-mastered-soft); color: var(--st-mastered-ink); }
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--line-strong); }
.due-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); display: inline-block; box-shadow: 0 0 0 3px var(--gold-soft); }

/* ============ صفحة الكلمات ============ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: clamp(24px, 3vw, 30px); font-weight: 800; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 12px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.search { position: relative; flex: 0 1 250px; min-width: 180px; }
.search input {
  width: 100%; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding-inline: 38px 12px; font-size: 13.5px;
  outline: none; transition: border-color .15s, background .15s;
}
.search input:focus { border-color: var(--line-strong); background: var(--surface); }
.search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.select {
  height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px; outline: none; max-width: 100%;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  height: 34px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600;
  color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
}
.filter-chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.filter-chip .n { font-family: var(--font-de); color: var(--ink-3); font-size: 12px; }
.filter-chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.filter-chip.on .n { color: inherit; opacity: .7; }
.tb-sep { width: 1px; align-self: stretch; background: var(--line); margin-inline: 2px; }
@media (max-width: 760px) { .tb-sep { display: none; } }

.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: clip; }
.tbl-scroll { overflow-x: auto; }
table.words { width: 100%; border-collapse: collapse; min-width: 760px; }
.words th {
  text-align: start; font-size: 12.5px; color: var(--ink-3); font-weight: 700; padding: 12px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
.words td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.words tr:last-child td { border-bottom: 0; }
.words tbody tr { transition: background .12s; }
.words tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.words .c-n { width: 48px; color: var(--ink-3); font-family: var(--font-de); font-size: 12.5px; text-align: center; }
.words .c-ar { width: 30%; }
.words .c-de { width: 32%; }
.words .c-audio { width: 90px; text-align: center; }
.words .c-img { width: 96px; text-align: center; }
.words .c-st { width: 170px; white-space: nowrap; }
.words .c-act { width: 52px; }
.ar-main { font-weight: 700; font-size: 15.5px; line-height: 1.45; }
.ar-en { font-family: var(--font-de); color: var(--ink-3); font-size: 12px; direction: ltr; text-align: right; line-height: 1.4; margin-top: 2px; }
.de-main { font-family: var(--font-de); font-weight: 600; font-size: 16px; direction: ltr; text-align: left; line-height: 1.4; }
.de-meta { font-size: 11.5px; color: var(--ink-3); direction: ltr; text-align: left; margin-top: 3px; font-family: var(--font-de); }
.art { font-weight: 800; }
.art.der { color: var(--der); } .art.die { color: var(--die); } .art.das { color: var(--das); }
.masked { position: relative; cursor: pointer; border-radius: 10px; }
.masked > .cell-content { filter: blur(7px); opacity: .6; user-select: none; pointer-events: none; transition: filter .2s; }
.masked::after {
  content: 'اضغط عشان تشوف'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink-2);
  font-family: var(--font-ar);
}
.masked:hover > .cell-content { filter: blur(5px); }
/* list and cards: the hidden word keeps its place and the label sits right on it */
.wl-de.masked, .wl-mean.masked, .wl-ex.masked { width: fit-content; min-width: 130px; max-width: 100%; }
.wl-de.masked > .cell-content, .wl-mean.masked > .cell-content, .wl-ex.masked > .cell-content { display: inline-block; }
.masked-quiet::after { content: none !important; }

.play {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); display: inline-grid; place-items: center;
  color: var(--ink); transition: .15s; position: relative;
}
.play:hover { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.play svg { width: 18px; height: 18px; }
.play.playing { background: var(--gold); border-color: var(--gold); color: #1b1a17; }
.play.playing::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--gold); animation: pulse 1s infinite; }
.play .tts-tag { position: absolute; bottom: -6px; inset-inline-end: -8px; font-size: 9px; background: var(--gold-soft); color: var(--gold-ink); border-radius: 6px; padding: 0 4px; font-weight: 800; font-family: var(--font-de); }
@keyframes pulse { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.no-media { color: var(--ink-3); font-size: 18px; }
.thumb { width: 72px; height: 54px; border-radius: 10px; object-fit: cover; display: block; margin: auto; cursor: zoom-in; background: var(--surface-2); transition: transform .15s; }
.thumb:hover { transform: scale(1.06); }
.thumb-empty {
  width: 72px; height: 54px; border-radius: 10px; margin: auto; display: grid; place-items: center; color: var(--ink-3);
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, transparent 6px 12px); border: 1px dashed var(--line); font-size: 11px;
}
.row-menu { position: relative; }

/* الصفحات */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager-info { font-size: 13px; color: var(--ink-3); }
.pages { display: flex; gap: 4px; flex-wrap: wrap; direction: ltr; }
.pages button {
  min-width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-family: var(--font-de); font-weight: 600; font-size: 13px; padding: 0 8px;
}
.pages button:hover:not(:disabled) { border-color: var(--line-strong); }
.pages button.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.pages button:disabled { opacity: .4; cursor: default; }
.pages .dots { padding: 0 4px; color: var(--ink-3); align-self: center; }

/* الموبايل: الجدول يتحول لكروت */
@media (max-width: 760px) {
  table.words { min-width: 0; }
  .words thead { display: none; }
  .words tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px; border-bottom: 1px solid var(--line); }
  .words td { border: 0; padding: 0; width: auto !important; }
  .words .c-n { display: none; }
  .words .c-de { grid-column: 1; grid-row: 1; }
  .words .c-ar { grid-column: 1; grid-row: 2; }
  .words .c-img { grid-column: 2; grid-row: 1 / 3; }
  .words .c-audio { grid-column: 2; grid-row: 3; }
  .words .c-st { grid-column: 1; grid-row: 3; }
  .words .c-act { display: none; }
  .de-main { text-align: right; }
  .de-meta { text-align: right; }
}

/* ============ القوايم المنسدلة ============ */
.menu {
  position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 190px; animation: pop .12s ease-out;
}
.menu button, .menu label {
  display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 9px; text-align: start; font-size: 14px; cursor: pointer;
}
.menu button:hover, .menu label:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .dot { width: 10px; height: 10px; border-radius: 50%; }
.menu .check { margin-inline-start: auto; color: var(--ink-3); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ============ المودال ============ */
.overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(15, 14, 12, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 24px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 18px 22px; display: grid; gap: 16px; }
.modal-foot { padding: 0 22px 22px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field > span em { font-style: normal; font-weight: 500; color: var(--ink-3); }
.input, .textarea {
  width: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 10px 14px; outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus, .textarea:focus { border-color: var(--gold); background: var(--surface); }
.input.de { direction: ltr; text-align: left; font-size: 16px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .fields-2 { grid-template-columns: 1fr; } }
.art-helper { display: flex; gap: 6px; direction: ltr; }
.art-helper button { height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; font-family: var(--font-de); font-weight: 700; font-size: 12.5px; }
.art-helper button:nth-child(1) { color: var(--der); } .art-helper button:nth-child(2) { color: var(--die); } .art-helper button:nth-child(3) { color: var(--das); }
.art-helper button.umlaut { color: var(--ink-2); font-weight: 600; }

.media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .media-grid { grid-template-columns: 1fr; } }
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: 16px; min-height: 170px; display: grid; place-items: center; text-align: center;
  padding: 12px; background: var(--surface-2); position: relative; transition: border-color .15s, background .15s; overflow: hidden;
}
.drop.drag { border-color: var(--gold); background: var(--gold-soft); }
.drop img { max-height: 150px; border-radius: 10px; object-fit: contain; }
.drop .hint { color: var(--ink-3); font-size: 13px; }
.drop .hint b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.drop .x { position: absolute; top: 8px; inset-inline-end: 8px; }
.audio-box { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface-2); display: grid; gap: 10px; align-content: start; min-height: 170px; }
.audio-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rec-btn.recording { background: #dd2c2c; color: #fff; border-color: #dd2c2c; }
.rec-btn.recording::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.audio-state { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); background: var(--surface); border-radius: 12px; padding: 8px 10px; min-height: 58px; }
.audio-state .play { flex: none; }
.muted { color: var(--ink-3); font-size: 12.5px; }

/* لايت بوكس */
.lightbox img { max-width: min(90vw, 900px); max-height: 80vh; border-radius: 18px; box-shadow: var(--shadow-lg); }
.lightbox figcaption { text-align: center; color: #fff; margin-top: 12px; font-family: var(--font-de); font-size: 18px; font-weight: 600; }

/* ============ وضع المذاكرة ============ */
.study { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; animation: fade .2s; }
.study-top { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.study-progress { flex: 1; height: 8px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.study-progress i { display: block; height: 100%; background: var(--gold); border-radius: 6px; transition: width .3s; }
.study-count { direction: ltr; font-family: var(--font-de); font-weight: 700; color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.study-edit { position: absolute; left: 20px; bottom: 18px; z-index: 2; }
.study-edit[hidden] { display: none; }
.study-main { flex: 1; display: grid; place-items: center; padding: 20px 16px; overflow: auto; }
.flash-wrap { width: min(620px, 100%); margin-inline: auto; perspective: 1600px; }
.flash {
  position: relative; width: 100%; min-height: 420px; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, .7, .2, 1); cursor: pointer;
}
.flash.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 12px; padding: 48px 24px 28px; text-align: center; overflow-y: auto; overscroll-behavior: contain;
}
.face.back { transform: rotateY(180deg); }
/* the picture is shown whole (never cropped): your own pictures often have two halves */
.card-pic { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; max-width: 100%; }
.face .ph { display: block; max-width: min(340px, 100%); max-height: 190px; width: auto; height: auto; border-radius: 16px; object-fit: contain; background: var(--surface-2); }
.card-pic.small .ph { max-height: 96px; max-width: 160px; border-radius: 12px; }
.card-pic .img-credit { margin-top: 0; }
.ans-de { display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ans-de .big-de { font-size: clamp(22px, 4vw, 30px); }
.listen-hint { font-size: 13px; }
.face .big-de { font-family: var(--font-de); font-size: clamp(26px, 5vw, 40px); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; direction: ltr; }
.face .big-ar { font-size: clamp(24px, 4.5vw, 36px); font-weight: 800; line-height: 1.35; }
.face .sm-en { font-family: var(--font-de); color: var(--ink-3); direction: ltr; }
.face .tap { position: absolute; bottom: 18px; font-size: 12.5px; color: var(--ink-3); }
.face .extra { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 12px; padding: 8px 12px; direction: ltr; font-family: var(--font-de); }
.face .lesson-tag { position: absolute; top: 18px; inset-inline-start: 20px; font-size: 12px; color: var(--ink-3); }
.face .face-chip { position: absolute; top: 14px; inset-inline-end: 16px; }
.grade-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: min(620px, 100%); margin: 20px auto 0; }
.grade {
  position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 10px 6px; display: grid; gap: 2px; justify-items: center;
  font-weight: 700; transition: transform .12s, border-color .15s; box-shadow: var(--shadow);
}
.grade:hover { transform: translateY(-2px); }
.grade small { font-family: var(--font-de); color: var(--ink-3); font-weight: 600; font-size: 11.5px; }
.grade kbd { position: absolute; top: 7px; left: 9px; font-family: var(--font-de); font-size: 10.5px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.grade.again { border-bottom: 3px solid #dd2c2c; } .grade.hard { border-bottom: 3px solid var(--st-hard); }
.grade.good { border-bottom: 3px solid var(--st-review); } .grade.easy { border-bottom: 3px solid var(--st-mastered); }
.study-setup { width: min(560px, 100%); display: grid; gap: 16px; }
.dir-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.dir-pick button {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 6px; border: 0; border-radius: 9px; background: none;
  color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s;
}
.dir-pick button:hover { color: var(--ink); }
.dir-pick button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1.5px var(--gold); }
.dir-pick .dp-ic { font-size: 15px; line-height: 1; }
.dir-pick b { font-size: 12.5px; }
.dir-hint { margin: -8px 0 0; text-align: center; font-size: 12px; color: var(--ink-3); }
@media (max-width: 560px) { .dir-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flash.flash-type { min-height: 500px; cursor: default; }
.flash.flash-type .face { gap: 10px; padding: 48px 24px 22px; }
.type-hint { font-family: var(--font-de); font-size: 18px; letter-spacing: .06em; color: var(--gold); }
.td-note { font-size: 13px; color: var(--ink-2); background: var(--gold-soft); border-radius: 10px; padding: 6px 10px; }
.grade.suggested { outline: 2px solid var(--gold); outline-offset: 2px; }
.type-audio { display: flex; gap: 18px; }
.type-audio span { display: grid; justify-items: center; gap: 3px; }
.type-audio small { font-size: 11.5px; color: var(--ink-3); }
.type-box { width: 100%; display: grid; gap: 8px; }
.type-box label { font-size: 13px; color: var(--ink-2); }
.type-in { font-family: var(--font-de); font-size: 17px; text-align: center; }
.type-tools { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; direction: ltr; }
.type-tools .uml { width: 34px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); font-family: var(--font-de); font-weight: 700; }
.type-tools .uml:hover { border-color: var(--gold); }
.type-result { width: 100%; display: grid; gap: 8px; text-align: start; }
.td-score { justify-self: center; font-weight: 800; font-size: 14px; color: var(--st-hard); background: var(--surface-2); border-radius: 999px; padding: 4px 12px; }
.td-score.good { color: var(--st-mastered); }
.td-row { display: grid; gap: 2px; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; }
.td-row small { font-size: 11.5px; color: var(--ink-3); }
.td-line { font-family: var(--font-de); font-size: 17px; line-height: 1.6; word-break: break-word; }
.td-line .ex-say { vertical-align: middle; }
.td-ok { color: var(--st-mastered); }
.td-bad { color: #e5484d; background: color-mix(in srgb, #e5484d 16%, transparent); border-radius: 3px; }
.td-x { text-decoration: line-through; }
.td-gap { color: var(--gold); text-decoration: underline; }
.td-miss { color: var(--gold); font-weight: 800; }
.td-want { color: var(--gold); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.face .play-xl { width: 76px; height: 76px; }
.face .play-xl svg { width: 34px; height: 34px; }
.opt-cards { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface);
  text-align: start; transition: border-color .15s;
}
.opt:hover { border-color: var(--line-strong); }
.opt.on { border-color: var(--gold); background: var(--gold-soft); }
.opt .ic { font-size: 26px; }
.opt b { display: block; }
.opt small { color: var(--ink-3); }
.opt .n { margin-inline-start: auto; font-family: var(--font-de); font-weight: 800; font-size: 20px; }
.opt:disabled { opacity: .45; cursor: not-allowed; }
.summary { text-align: center; display: grid; gap: 14px; justify-items: center; width: min(520px, 100%); }
.summary .trophy { font-size: 64px; line-height: 1; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
@media (max-width: 520px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } .grade-bar { grid-template-columns: repeat(2, 1fr); } }

/* ============ التوست ============ */
.toasts { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); z-index: 120; display: grid; gap: 8px; }
.toast {
  background: var(--primary); color: var(--primary-ink); padding: 10px 18px; border-radius: 14px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 14px;
  animation: rise .2s ease-out; display: flex; align-items: center; gap: 8px;
}

.foot { text-align: center; color: var(--ink-3); font-size: 12.5px; padding: 24px 16px 40px; }
.foot .de { direction: ltr; }
.skeleton { color: var(--ink-3); text-align: center; padding: 60px 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============ المصادر ============ */
.nav { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.nav .src-emoji { font-size: 16px; line-height: 1; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--src, transparent), var(--shadow); }
/* source switcher: one button in the top bar, a panel with every source */
.src-switch {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--ink-2); padding: 7px 12px 7px 14px;
  border-radius: 10px; font-weight: 600; font-size: 14px; white-space: nowrap; max-width: 260px; transition: .15s;
}
.src-switch .lbl { overflow: hidden; text-overflow: ellipsis; }
.src-switch:hover, .src-switch.open { color: var(--ink); background: var(--surface); }
.src-switch.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 -2px 0 var(--src), var(--shadow); }
.src-switch .chev { width: 15px; height: 15px; flex: none; opacity: .6; transition: transform .2s; }
.src-switch.open .chev { transform: rotate(180deg); }
.src-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-3, var(--line)); font-size: 11.5px; display: grid; place-items: center; color: var(--ink-2); }
.switcher {
  position: fixed; z-index: 60; width: min(410px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; animation: sw-in .16s ease-out;
}
@keyframes sw-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.sw-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.sw-search svg { width: 17px; height: 17px; flex: none; }
.sw-search input { flex: 1; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; font-size: 14.5px; }
.sw-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 6px; }
.sw-item {
  display: grid; grid-template-columns: 38px 1fr 46px 34px 14px; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px;
  text-decoration: none; color: inherit; position: relative;
}
.sw-item[hidden] { display: none; }
.sw-item:hover { background: var(--surface-2); }
.sw-item.on { background: color-mix(in srgb, var(--src, var(--gold)) 12%, transparent); }
.sw-emoji {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 19px;
  background: color-mix(in srgb, var(--src, var(--ink-3)) 18%, var(--surface-2));
}
.sw-txt { min-width: 0; display: flex; flex-direction: column; }
.sw-txt b { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-txt small { font-size: 12px; color: var(--ink-3); }
.sw-due { color: var(--gold-ink, var(--gold)); font-weight: 600; }
.sw-prog { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.sw-prog i { display: block; height: 100%; background: var(--src, var(--st-mastered)); border-radius: 3px; }
.sw-pct { font-size: 12px; color: var(--ink-3); text-align: end; }
.sw-check { color: var(--src, var(--ink)); font-weight: 800; }
.sw-empty { padding: 18px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.sw-foot { border-top: 1px solid var(--line); padding: 6px; display: grid; gap: 2px; }
.sw-foot .sw-all { grid-template-columns: 38px 1fr; }
.sw-add {
  display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--ink-2); font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 12px; border-radius: 12px; text-align: start;
}
.sw-add svg { width: 17px; height: 17px; margin-inline: 10px; }
.sw-add:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 820px) { .src-switch { max-width: 160px; } }
.topbar .brand { flex: none; }
.topbar .nav { flex: 0 1 auto; min-width: 0; }

.src-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.src-pills button {
  height: 34px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.src-pills button:hover { border-color: var(--line-strong); }
.src-pills button.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.dash-filter { justify-content: flex-start; }

.src-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.src-card {
  display: grid; gap: 10px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2);
  text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; position: relative; overflow: hidden; text-align: start;
}
.src-card::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--src, var(--line-strong)); }
.src-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.src-card-top { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.src-card-top b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-card-top small { color: var(--ink-3); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-dot { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--src, #888) 18%, var(--surface)); }
.src-pct { font-weight: 800; font-size: 18px; }
.src-card .stack { grid-column: auto; background: var(--surface); }
.src-card-foot { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); gap: 8px; flex-wrap: wrap; }
.src-card-add { border-style: dashed; place-content: center; justify-items: center; text-align: center; min-height: 140px; cursor: pointer; }
.src-card-add::before { display: none; }
.src-card-add .big { font-size: 30px; line-height: 1; color: var(--ink-3); }
.src-card-add small { color: var(--ink-3); }
.level-h { font-size: 14px; margin: 14px 0 6px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.level-h::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.src-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.src-head-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.src-badge {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; flex: none;
  background: color-mix(in srgb, var(--src) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--src) 35%, var(--line));
}
.src-head h1 { margin: 0; font-size: clamp(22px, 3vw, 30px); font-weight: 800; line-height: 1.2; }
.src-head p { margin: 2px 0 0; color: var(--ink-3); }
.src-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.level-tabs { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.level-tabs button { border: 0; background: none; padding: 7px 18px; border-radius: 10px; font-weight: 700; font-family: var(--font-de); color: var(--ink-2); }
.level-tabs button:first-child { font-family: var(--font-ar); }
.level-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.dup-badge {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 5px; font-size: 11.5px; font-weight: 600; color: var(--gold-ink);
  background: var(--gold-soft); border-radius: 8px; padding: 1px 8px; font-family: var(--font-ar);
}
.dup-badge a { color: inherit; }
.dup-warn { font-size: 13px; background: var(--gold-soft); color: var(--gold-ink); border-radius: 12px; padding: 8px 12px; }
.src-empty { padding: 40px 12px; }

.fields-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fields-3 .select { width: 100%; }
@media (max-width: 560px) { .fields-3 { grid-template-columns: 1fr; } }

.src-preview { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.src-preview .src-dot { background: color-mix(in srgb, currentColor 0%, transparent); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.emoji-grid button { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; }
.emoji-grid button.on { border-color: var(--gold); background: var(--gold-soft); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.color-row button.on { box-shadow: 0 0 0 2px var(--ink); }

.modal-wide { width: min(860px, 100%); }
.import-tabs { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
@media (max-width: 640px) { .import-tabs { grid-template-columns: 1fr; } }
.import-way { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.import-way .ic { font-size: 26px; }
.import-way small { color: var(--ink-3); }
.import-way textarea { margin-top: 6px; font-family: var(--font-de); font-size: 13px; }
.map-table table { border-collapse: collapse; width: 100%; font-size: 13px; }
.map-table th { padding: 6px; background: var(--surface-2); min-width: 130px; }
.map-table th .select { width: 100%; height: 34px; }
.map-table td { padding: 6px 10px; border-top: 1px solid var(--line); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-table td.skip { color: var(--ink-3); text-decoration: line-through; opacity: .6; }
.map-table { border: 1px solid var(--line); border-radius: 12px; }
.import-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 560px) { .import-summary { grid-template-columns: repeat(2, 1fr); } }
.import-summary div { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.import-summary b { display: block; font-size: 22px; }
.import-summary div:first-child { background: var(--st-mastered-soft); color: var(--st-mastered-ink); }
.import-summary small { font-size: 12px; color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.c-de .dup-badge { display: flex; width: fit-content; margin-inline-start: auto; }
@media (max-width: 760px) { .c-de .dup-badge { margin-inline-start: 0; } }

.ar-gd { font-family: var(--font-de); color: var(--ink-3); font-size: 12px; direction: ltr; text-align: right; line-height: 1.45; margin-top: 3px; }

/* ============ المواقف ووضع الحوار ============ */
.sit-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 14px; }
.sit-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.sit-card .sit-main { grid-template-columns: auto 1fr; flex: 1; align-items: start; }
.sit-txt { min-width: 0; padding-top: 2px; }
.sit-txt b { line-height: 1.3; }
.sit-txt small { display: block; margin-top: 3px; }
.sit-foot { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-inline-start: 16px; border-top: 1px solid var(--line); }
.sit-meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.sit-prog { flex: 1; min-width: 30px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.sit-prog i { display: block; height: 100%; background: var(--st-mastered); border-radius: inherit; }
.sit-foot small { font-size: 12px; color: var(--st-mastered-ink); }
.sit-foot .sit-go { border: 0; cursor: pointer; flex: none; }
.sit-foot .sit-go:hover { background: var(--line); color: var(--ink); }
.sit-main {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 14px 16px;
  border: 0; background: none; text-align: start; transition: background .15s;
}
.sit-main:hover { background: var(--surface-2); }
.sit-emoji { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; background: color-mix(in srgb, var(--src, #0e9aa7) 16%, var(--surface)); }
.sit-main b { display: block; font-size: 16px; }
.sit-main small { color: var(--ink-3); font-family: var(--font-de); font-size: 12.5px; }
.sit-go { font-size: 12.5px; font-weight: 700; color: var(--ink-2); background: var(--surface-2); padding: 5px 10px; border-radius: 20px; white-space: nowrap; }
.sit-lvs { display: flex; border-top: 1px solid var(--line); }
.sit-lv { flex: 1; border: 0; background: none; padding: 8px 4px; display: flex; gap: 6px; justify-content: center; align-items: baseline; border-inline-start: 1px solid var(--line); }
.sit-lv:first-child { border-inline-start: 0; }
.sit-lv:hover { background: var(--surface-2); }
.sit-lv b { font-family: var(--font-de); }
.sit-lv small { color: var(--st-mastered-ink); font-size: 12px; }

.dialog-view .dlg-top { gap: 12px; flex-wrap: wrap; }
.dlg-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.dlg-title b { display: block; font-size: 18px; line-height: 1.2; }
.dlg-title small { color: var(--ink-3); font-family: var(--font-de); }
.dlg-emoji { font-size: 30px; }
.dlg-levels { margin: 0; }
.dlg-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dlg-main { place-items: start center; scroll-behavior: smooth; }
.dlg-col { width: min(760px, 100%); display: flex; flex-direction: column; gap: 10px; padding-bottom: 60px; }
.dlg-cast { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; margin-bottom: 4px; }
.cast { font-size: 13px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); padding: 3px 10px; border-radius: 20px; }
.cast.me { background: var(--gold-soft); color: var(--gold-ink); border-color: transparent; }
.dlg-stage { display: flex; align-items: center; gap: 10px; margin: 14px 0 2px; color: var(--ink-2); font-weight: 700; font-size: 14px; }
.dlg-stage::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.dlg-stage span { min-width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-family: var(--font-de); font-size: 12.5px; padding: 0 6px; }
.bubble {
  position: relative; max-width: 82%; padding: 10px 14px 10px 52px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s;
}
.bubble.other { align-self: flex-end; border-end-end-radius: 6px; }
.bubble.me { align-self: flex-start; background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 40%, transparent); border-end-start-radius: 6px; }
.bubble.now { box-shadow: 0 0 0 3px var(--gold), var(--shadow-lg); transform: scale(1.01); }
.bubble-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink-3); margin-bottom: 2px; }
.bubble.me .bubble-head { color: var(--gold-ink); }
.bubble-de { font-family: var(--font-de); font-size: 16.5px; font-weight: 600; line-height: 1.45; text-align: left; cursor: default; }
.bubble-de.hid { font-family: var(--font-ar); font-size: 13.5px; font-weight: 600; color: var(--ink-3); text-align: right; cursor: pointer; border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 6px 10px; direction: rtl; }
.bubble-ar { font-size: 14px; color: var(--ink-2); margin-top: 3px; }
.bubble-play { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; }
.dot-st { width: 8px; height: 8px; border-radius: 50%; background: var(--st-new); }
.dot-st.hard { background: var(--st-hard); } .dot-st.review { background: var(--st-review); } .dot-st.mastered { background: var(--st-mastered); }
.dlg-vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.vchip { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 8px 12px; text-align: start; display: grid; gap: 2px; }
.vchip:hover { border-color: var(--line-strong); }
.vchip b { font-family: var(--font-de); font-weight: 600; text-align: left; }
.vchip small { color: var(--ink-3); }
.dlg-end { text-align: center; color: var(--ink-3); margin-top: 20px; font-size: 14px; }
@media (max-width: 560px) { .bubble { max-width: 94%; } .dlg-bar .btn { flex: 1 1 auto; } }

/* ============ عدادات Anki ============ */
:root { --ac-new: #2a78d6; --ac-learn: #d8453a; --ac-due: #0c8a5a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ac-new: #7fb2f0; --ac-learn: #f08a8a; --ac-due: #5cd3a5; } }
:root[data-theme="dark"] { --ac-new: #7fb2f0; --ac-learn: #f08a8a; --ac-due: #5cd3a5; }
.anki-counts { flex: 1; display: flex; justify-content: center; gap: 22px; }
.anki-counts .ac { display: flex; align-items: baseline; gap: 6px; padding-bottom: 2px; border-bottom: 2px solid transparent; }
.anki-counts .ac b { font-size: 20px; font-weight: 800; }
.anki-counts .ac small { font-size: 12px; color: var(--ink-3); }
.anki-counts .ac.cur { border-bottom-color: currentColor; }
.ac.new { color: var(--ac-new); } .ac.learn { color: var(--ac-learn); } .ac.due { color: var(--ac-due); }
.anki-big { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.anki-big .ac { background: var(--surface-2); border-radius: 16px; padding: 14px 10px; text-align: center; display: grid; gap: 2px; border-top: 4px solid currentColor; }
.anki-big .ac b { font-size: 36px; font-weight: 800; line-height: 1.1; }
.anki-big .ac small { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.anki-big .ac em { font-style: normal; color: var(--ink-3); font-size: 11.5px; }
.today-card .anki-big { margin-bottom: 14px; }
.deck-table { width: 100%; border-collapse: collapse; }
.deck-table th { font-size: 12.5px; color: var(--ink-3); font-weight: 700; text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.deck-table td { padding: 10px; border-bottom: 1px solid var(--line); }
.deck-table tr:last-child td { border-bottom: 0; }
.deck-table .c { text-align: center; width: 90px; }
.deck-name { color: inherit; text-decoration: none; font-weight: 700; }
.deck-name:hover { text-decoration: underline; }
.tn { font-family: var(--font-de); font-weight: 800; font-size: 16px; }
.tn.new { color: var(--ac-new); } .tn.learn { color: var(--ac-learn); } .tn.due { color: var(--ac-due); }
.tn.zero { color: var(--ink-3); opacity: .5; font-weight: 600; }
.custom-study { border: 1px dashed var(--line-strong); border-radius: 14px; padding: 12px; display: grid; gap: 8px; text-align: center; }
.cs-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.anki-settings { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.anki-settings summary { cursor: pointer; font-weight: 700; }
.anki-settings[open] summary { margin-bottom: 12px; }
.study-top [data-undo][hidden] { display: none; }
@media (max-width: 520px) { .anki-counts { gap: 12px; } .anki-counts .ac small { display: none; } .anki-big .ac b { font-size: 28px; } }

.q-chip { background: var(--surface-2); }
.q-chip.q-new { color: var(--ac-new); } .q-chip.q-learn { color: var(--ac-learn); } .q-chip.q-review { color: var(--ac-due); }

/* شجرة المجموعات زي Anki */
.deck-table .deck-row td { padding-block: 7px; }
.deck-table .deck-row.d0 td { border-top: 1px solid var(--line); }
.deck-table .deck-row:not(.d0) td { border-bottom: 0; }
.deck-cell { display: flex; align-items: center; gap: 6px; }
.deck-tg { width: 22px; height: 22px; border-radius: 6px; border: 0; background: none; color: var(--ink-2); font-size: 17px; font-weight: 700; line-height: 1; display: grid; place-items: center; font-family: var(--font-de); }
.deck-tg:hover { background: var(--surface-2); color: var(--ink); }
.deck-tg-sp { width: 22px; flex: none; }
.deck-table button.deck-name { border: 0; background: none; padding: 2px 4px; border-radius: 6px; text-align: start; font-weight: 600; color: var(--ink); cursor: pointer; font-size: 14.5px; }
.deck-table .d0 button.deck-name { font-weight: 800; font-size: 15px; }
.deck-table .d2 button.deck-name { font-weight: 500; color: var(--ink-2); font-family: var(--font-de); }
.deck-table button.deck-name:hover { background: var(--surface-2); text-decoration: underline; }
.deck-table .deck-row:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* المثال والملاحظة */
.ex-line { display: flex; align-items: flex-start; gap: 6px; margin-top: 5px; font-family: var(--font-de); font-size: 13px; color: var(--ink-2); font-style: italic; text-align: left; line-height: 1.45; }
.ex-say { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); display: inline-grid; place-items: center; padding: 0; vertical-align: middle; }
.ex-say svg { width: 12px; height: 12px; }
.ex-say:hover, .ex-say.playing { background: var(--gold); border-color: var(--gold); color: #1b1a17; }
.note-line { margin-top: 5px; text-align: left; }
.note-chip { border: 1px dashed var(--line-strong); background: none; color: var(--ink-3); font-size: 12px; font-weight: 600; border-radius: 8px; padding: 1px 8px; font-family: var(--font-ar); }
.note-chip:hover, .note-chip.on { color: var(--ink); border-style: solid; background: var(--surface-2); }
.note-box { margin-top: 5px; background: var(--gold-soft); color: var(--ink); border-radius: 10px; padding: 6px 10px; font-size: 13px; white-space: pre-wrap; direction: auto; unicode-bidi: plaintext; text-align: start; }
.face .ex-extra { font-style: italic; display: flex; align-items: center; gap: 8px; }
.face .note-chip { margin-top: 2px; }
.face .note-box { max-width: 90%; }
.note-wrap { display: grid; gap: 6px; }
.note-wrap [data-note-tg] { justify-self: start; }

/* مكتبة المصادر */
.lib-intro, .lib-empty { text-align: center; display: grid; gap: 8px; justify-items: center; padding: 18px 12px; }
.lib-intro .big, .lib-empty .big { font-size: 46px; line-height: 1; }
.lib-intro p, .lib-empty p { margin: 0; max-width: 56ch; }
.lib-empty h2 { margin: 0; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lib-card { position: relative; border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface-2); display: grid; gap: 8px; overflow: hidden; }
.lib-card::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--src, var(--line-strong)); }
.lib-card.on { border-color: color-mix(in srgb, var(--st-mastered) 45%, var(--line)); }
.lib-top { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.lib-top b { display: block; }
.lib-top small { color: var(--ink-3); font-size: 12px; }
.lib-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* مركز المصادر والترحيب */
.hub-ways { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.hub-way { display: grid; gap: 4px; justify-items: start; text-align: start; padding: 14px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); transition: transform .15s, border-color .15s; }
.hub-way:hover { transform: translateY(-2px); border-color: var(--gold); }
.hub-way span { font-size: 26px; line-height: 1; }
.hub-way b { font-size: 15px; }
.hub-way small { color: var(--ink-3); font-size: 12.5px; line-height: 1.5; }
.hub-ways.big { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.hub-ways.big .hub-way { padding: 20px; min-height: 150px; box-shadow: var(--shadow); }
.hub-ways.big .hub-way span { font-size: 34px; }
.hub-ways.big .hub-way b { font-size: 17px; }
.welcome { width: 100%; max-width: 980px; margin: 0 auto; display: grid; gap: 22px; padding-block: 10px 30px; }
.welcome-head { text-align: center; display: grid; justify-items: center; gap: 8px; }
.welcome-head h1 { margin: 6px 0 0; font-size: clamp(26px, 4vw, 36px); }
.welcome-head p { margin: 0; color: var(--ink-2); }
.big-mark { width: 72px; height: 72px; margin-inline: auto; }
.welcome-q { display: grid; gap: 10px; justify-items: center; }
.welcome-h2 { text-align: center; margin: 8px 0 0; }
.quick-add { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1.5px dashed var(--line-strong); border-radius: 16px; padding: 8px 10px; margin-bottom: 12px; }
.quick-add:focus-within { border-style: solid; border-color: var(--gold); }
.quick-add .input { flex: 1; border: 0; background: transparent; padding: 6px 4px; }
.qa-ic { font-size: 18px; }

/* ============ English (left to right) ============ */
html[dir="ltr"] { --font-ar: 'Inter', 'Cairo', 'Segoe UI', system-ui, sans-serif; }
html[dir="ltr"] .hero-hello, html[dir="ltr"] .li-de, html[dir="ltr"] .wotd-de, html[dir="ltr"] .wotd-en,
html[dir="ltr"] .ar-en, html[dir="ltr"] .ar-gd { text-align: left; }
html[dir="ltr"] .masked::after { content: 'Click to reveal'; }
html[dir="ltr"] .toasts { transform: translateX(-50%); }
html[dir="ltr"] .bubble.other { align-self: flex-start; border-end-end-radius: 18px; border-end-start-radius: 6px; }
html[dir="ltr"] .bubble.me { align-self: flex-end; border-end-start-radius: 18px; border-end-end-radius: 6px; }
html[dir="ltr"] .bubble-de.hid { direction: ltr; text-align: left; }
@media (max-width: 760px) { html[dir="ltr"] .de-main, html[dir="ltr"] .de-meta { text-align: left; } }
/* Arabic text inside the English site keeps its Arabic font */
html[dir="ltr"] [dir="rtl"], html[dir="ltr"] [dir="auto"]:lang(ar) { font-family: 'Cairo', var(--font-de); }
.lang-btn { min-width: 40px; height: 40px; padding: 0 10px; font-weight: 800; font-family: 'Cairo', var(--font-de); font-size: 15px; }
html[dir="rtl"] .lang-btn { font-family: var(--font-de); font-size: 13px; }

/* ============ dashboard button: its own calm, fixed color ============ */
:root { --dash: #4f7a5a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dash: #8fbf98; } }
:root[data-theme="dark"] { --dash: #8fbf98; }
.nav a.nav-dash { color: #111; background: #e6e5e0; border: 1px solid rgba(0, 0, 0, .08); font-weight: 800; }
.nav a.nav-dash:hover { color: #000; background: #d9d8d2; }
.nav a.nav-dash.active { color: #000; background: #e6e5e0; box-shadow: inset 0 -2px 0 #111, var(--shadow); }

/* ============ global search (Ctrl+K) ============ */
.gsearch-btn {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-3); font: inherit; font-size: 14px; font-weight: 500; width: clamp(200px, 26vw, 340px); transition: .15s;
}
.gsearch-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.gsearch-btn svg { width: 17px; height: 17px; flex: none; }
.gsearch-btn kbd { margin-inline-start: auto; font-family: var(--font-de); font-size: 10.5px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--ink-3); background: var(--surface); }
@media (max-width: 1000px) { .gsearch-btn { width: auto; } .gsearch-btn kbd { display: none; } }
.gsearch-ov { align-items: flex-start; padding-top: 10vh; }
.gsearch {
  width: min(680px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 76vh; animation: sw-in .16s ease-out;
}
.gs-bar { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.gs-bar svg { width: 20px; height: 20px; flex: none; }
.gs-bar input { flex: 1; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; font-size: 17px; }
.gs-bar kbd { font-family: var(--font-de); font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.gs-body { overflow-y: auto; padding: 6px; }
.gs-count { padding: 6px 12px; font-size: 12px; color: var(--ink-3); }
.gs-item { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; cursor: pointer; }
.gs-item.sel { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--src); }
html[dir="rtl"] .gs-item.sel { box-shadow: inset -3px 0 0 var(--src); }
.gs-play { width: 34px; height: 34px; }
.gs-txt { min-width: 0; }
.gs-de { font-family: var(--font-de); font-weight: 600; font-size: 15.5px; text-align: start; }
.gs-mean { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-mean span { color: var(--ink-3); }
.gs-ex { font-family: var(--font-de); font-size: 12.5px; font-style: italic; color: var(--ink-3); margin-top: 2px; text-align: start; }
.gs-ex mark { background: var(--gold-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.gs-src {
  display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; padding: 3px 9px;
  border-radius: 20px; background: color-mix(in srgb, var(--src) 14%, transparent); max-width: 170px; overflow: hidden;
}
.gs-empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 34px 20px; color: var(--ink-2); }
.gs-empty .big { font-size: 34px; }
.gs-empty small { color: var(--ink-3); font-size: 12.5px; }
.gs-foot { border-top: 1px solid var(--line); padding: 9px 16px; font-size: 12px; color: var(--ink-3); }
@media (max-width: 560px) { .gs-src bdi { display: none; } }

/* ============ toolbar on one line ============ */
.toolbar > .btn { flex: none; white-space: nowrap; }
.toolbar .search { flex: 1 1 200px; min-width: 150px; }
.toolbar .select { flex: 0 1 210px; min-width: 120px; text-overflow: ellipsis; }
@media (min-width: 1000px) { .toolbar { flex-wrap: nowrap; } }

/* ============ top bar: the source name is always shown in full ============ */
.topbar .nav { flex: none; overflow: visible; }
.src-switch { max-width: none; }
.topbar .top-actions { flex: 0 1 auto; min-width: 0; }
.gsearch-btn { flex: 0 1 340px; width: auto; min-width: 44px; overflow: hidden; }
.gsearch-btn .lbl-sm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) { .brand-sub { display: none; } }
@media (max-width: 820px) { .src-switch { max-width: 170px; } }

/* ============ voice picker ============ */
.voices-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.voices-head em { font-style: normal; color: var(--ink-3); font-weight: 500; font-size: 12.5px; }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 4px; max-height: 330px; overflow-y: auto; padding: 2px; }
.voice-card {
  display: grid; grid-template-columns: 40px 1fr 36px; align-items: center; gap: 10px; padding: 10px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.voice-card:hover { border-color: var(--line-strong); }
.voice-card.on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--surface)); }
.voice-card.off { opacity: .45; cursor: not-allowed; }
.vc-av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: var(--surface-3); }
.vc-av.f { background: color-mix(in srgb, #d0508a 18%, var(--surface)); }
.vc-av.m { background: color-mix(in srgb, #2a78d6 18%, var(--surface)); }
.vc-txt { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.vc-txt b { font-family: var(--font-de); font-size: 15px; }
.vc-txt small { color: var(--ink-3); font-size: 12px; }
.vc-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.vtag { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); color: var(--ink-2); }
.vtag.nat { background: color-mix(in srgb, var(--st-mastered) 18%, transparent); color: var(--st-mastered); }
.vtag.main { background: var(--gold-soft); color: var(--gold-ink); }
.vtag.partner { background: color-mix(in srgb, #2a78d6 18%, transparent); color: #5b9be8; }
.vc-play { width: 34px; height: 34px; }
.voice-help { margin-top: 8px; background: var(--gold-soft); border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.6; }
.voice-help ol { margin: 6px 0 0; padding-inline-start: 20px; }
.rec-voices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 4px; }

/* ============ word list (the main view) ============ */
.view-ctl button { font-size: 15px; line-height: 1; padding: 5px 10px; }
.wl { display: flex; flex-direction: column; }
.wl-row {
  display: grid; grid-template-columns: 40px 1fr auto auto auto; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); position: relative; cursor: pointer; transition: background .12s;
}
.wl-row::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--st, transparent); opacity: .85; }
.wl-row.new::before { background: var(--st-new); } .wl-row.hard::before { background: var(--st-hard); }
.wl-row.review::before { background: var(--st-review); } .wl-row.mastered::before { background: var(--st-mastered); }
.wl-row:last-child { border-bottom: 0; }
.wl-row:hover { background: var(--surface-2); }
.wl-txt { min-width: 0; }
.wl-de { font-family: var(--font-de); font-weight: 600; font-size: 16px; line-height: 1.35; text-align: start; }
.wl-mean { font-size: 14px; color: var(--ink-2); margin-top: 1px; }
.wl-alt { color: var(--ink-3); font-size: 12.5px; }
.wl-ex { font-family: var(--font-de); font-size: 12.5px; font-style: italic; color: var(--ink-3); margin-top: 3px; text-align: start; }
.wl-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 11.5px; color: var(--ink-3); }
.wl-chips { display: inline-flex; gap: 4px; align-items: center; }
.wl-chip {
  border: 1px dashed var(--line-strong); background: none; color: var(--ink-3); font: inherit; font-size: 11px; font-weight: 600;
  border-radius: 8px; padding: 1px 7px; line-height: 1.6; cursor: pointer;
}
.wl-chip:hover, .wl-chip.on { color: var(--ink); border-style: solid; background: var(--surface-2); }
.wl-chip.dup { border-style: solid; border-color: transparent; background: var(--gold-soft); color: var(--gold-ink); }
.wl-chip a { text-decoration: none; }
.wl-play { width: 38px; height: 38px; }
.wl-img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.wl-dot { width: 12px; height: 12px; border-radius: 50%; border: 0; padding: 0; background: var(--ink-3); cursor: pointer; position: relative; }
.wl-dot.new { background: var(--st-new); } .wl-dot.hard { background: var(--st-hard); }
.wl-dot.review { background: var(--st-review); } .wl-dot.mastered { background: var(--st-mastered); }
.wl-dot.due::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--gold); }
.wl-dot:hover { transform: scale(1.25); }
.wl-more { opacity: .35; }
.wl-row:hover .wl-more { opacity: 1; }
.wl-group {
  position: sticky; top: 68px; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2);
}
.wl-group b { font-weight: 700; }
.wl-group small { color: var(--ink-3); }
/* cards */
.wl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; padding: 14px; }
.wl-card { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface-2); cursor: pointer; transition: .15s; }
.wl-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.wl-card-img { position: relative; height: 104px; display: grid; place-items: center; background: var(--surface-3); overflow: hidden; }
.wl-letter { font-family: var(--font-de); font-size: 44px; font-weight: 800; color: var(--ink-3); opacity: .35; }
.wl-card-img img { width: 100%; height: 100%; object-fit: cover; }
.wl-card-img .wl-dot { position: absolute; top: 8px; inset-inline-end: 8px; width: 14px; height: 14px; box-shadow: 0 0 0 3px var(--surface); }
.wl-card-body { padding: 10px 12px 12px; display: grid; gap: 3px; }
.wl-card .wl-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.wl-card .wl-foot .btn { margin-inline-start: auto; }
.wl-card .wl-play { width: 34px; height: 34px; }
@media (max-width: 560px) {
  .wl-row { grid-template-columns: 36px 1fr auto; gap: 10px; padding: 10px; }
  .wl-img { display: none; }
  .wl-more { display: none; }
}

/* ===== الهيدر على الموبايل: كل الزراير تكفي في عرض الشاشة ===== */
@media (max-width: 520px) {
  .topbar .wrap { gap: 6px; height: 58px; padding-inline: 10px; }
  .brand-mark { width: 40px; height: 40px; }
  .nav { padding: 3px; gap: 3px; }
  .nav a, .src-switch { padding-inline: 8px; }
  .src-switch .lbl, .src-switch .src-count { display: none; }
  .top-actions { gap: 2px; }
  .top-actions .btn, .gsearch-btn { padding-inline: 8px; min-width: 0; }
  .top-actions .btn-icon, .top-actions .lang-btn { width: 34px; padding: 0; }
  .top-actions > * { flex: none; }
  .gsearch-btn .lbl-sm { display: none; }
}
@media (max-width: 760px) { .study-main { padding-bottom: 70px; } .study-edit { left: 12px; bottom: 12px; } }

/* ===== تذكير النسخة الاحتياطية ===== */
.backup-bar {
  position: fixed; z-index: 60; inset-inline: 16px; bottom: 16px; margin-inline: auto; max-width: 640px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: fade .2s;
}
.backup-bar span { flex: 1 1 260px; }

/* ===== ❤️ ادعمنا ===== */
.support-body { text-align: center; }
.support-body p { margin: 0; line-height: 1.7; }
.support-logo { width: 72px; height: 72px; margin: 0 auto 4px; display: block; }
.support-nudge {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 10px 14px;
  background: var(--gold-soft); color: var(--ink); border-radius: 14px; font-size: 13.5px; max-width: 520px;
}

/* ===== سطر المصوّر تحت صور Wikimedia ===== */
.img-credit { display: block; max-width: 280px; margin-top: -8px; font-size: 10.5px; line-height: 1.3; color: var(--ink-3); text-decoration: none; direction: ltr; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.img-credit:hover { color: var(--ink-2); text-decoration: underline; }
.lightbox .img-credit { display: inline; margin: 0; max-width: none; white-space: normal; }


/* ===== card faces v2 (2026-09-27): one column, clear hierarchy ===== */
.face > * { max-width: 460px; }
.face { gap: 14px; }
.c-word { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: nowrap; max-width: 100%; }
.c-word > :not(.c-word-de) { flex: none; }
.c-word-de { font-family: var(--font-de); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; min-width: 0; font-size: clamp(22px, 3.6vw, 30px); }
.c-word.big .c-word-de { font-size: clamp(26px, 4.6vw, 38px); }
.c-play { width: 40px; height: 40px; flex: none; }
.c-mean { display: grid; gap: 2px; justify-items: center; }
.c-mean-main { font-size: 19px; font-weight: 700; color: var(--ink-2); line-height: 1.4; }
.c-mean.big .c-mean-main { font-size: clamp(24px, 4.2vw, 32px); font-weight: 800; color: var(--ink); }
.c-mean-alt { font-size: 13.5px; color: var(--ink-3); direction: ltr; font-family: var(--font-de); }
.c-more { width: 100%; display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.c-ex { display: flex; align-items: center; gap: 10px; text-align: left; font-family: var(--font-de); font-size: 15px; line-height: 1.5; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.c-ex .ex-say { flex: none; }
.c-gd { text-align: left; font-family: var(--font-de); font-size: 13.5px; color: var(--ink-2); }
.c-foot { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }
.face .note-box { text-align: start; }
.type-result { width: 100%; display: grid; gap: 6px; justify-items: center; }
.td-score { font-size: 13.5px; font-weight: 800; border-radius: 999px; padding: 4px 14px; background: var(--surface-2); }
.td-score.good { color: var(--st-mastered); background: color-mix(in srgb, var(--st-mastered) 14%, transparent); }
.td-score.bad { color: #e5484d; background: color-mix(in srgb, #e5484d 13%, transparent); }
.td-spell { font-size: 12.5px; color: var(--ink-3); }
.td-spell b { color: var(--ink); font-family: var(--font-de); }
.td-mine { font-family: var(--font-de); font-size: 20px; font-weight: 700; letter-spacing: .01em; line-height: 1.4; word-break: break-word; text-align: center; }
.tm-ok { color: var(--st-mastered); }
.tm-bad { color: #e5484d; background: color-mix(in srgb, #e5484d 15%, transparent); border-radius: 3px; }
.tm-extra { color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, transparent); border-radius: 3px; }
.td-compare { width: 100%; display: grid; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; text-align: left; font-family: var(--font-de); font-size: 16px; }
.td-compare div { display: flex; gap: 10px; align-items: baseline; }
.td-compare small { width: 44px; flex: none; font-size: 11px; color: var(--ink-3); font-family: var(--font-ar); }
.flash { min-height: 520px; }
.flash.flash-type { min-height: 570px; }
@media (max-width: 520px) { .flash { min-height: 440px; } .face { padding: 44px 16px 20px; gap: 12px; } }
.face.back .card-pic .ph { max-height: 150px; }
@media (max-width: 520px) {
  .flash.flash-type { min-height: 520px; }
  .face .ph { max-height: 150px; }
  .face.back .card-pic .ph { max-height: 110px; }
  .grade-bar { margin-top: 12px; }
}
/* phones: "Edit" lives in the top bar (icon only) so it never covers the rating buttons */
.study-actions { display: flex; align-items: center; gap: 6px; }
@media (max-width: 520px) {
  .study-top { gap: 8px; padding-inline: 10px; }
  .study-actions .study-edit { position: static; padding-inline: 10px; }  /* in the top bar, icon only */
  .study-edit-lbl { display: none; }
  .flash.flash-type { min-height: 540px; }
  .study-main { padding-bottom: 16px; }
}
.face .c-note { max-width: 100%; width: 100%; line-height: 1.7; font-size: 13.5px; }
