/* ===================== ألوان التطبيق (اللوحة الخضراء): فاتح وداكن ===================== */
:root {
  --bg: #f3f6f5;
  --card: #ffffff;
  --stroke: #e6ecea;
  --soft: #e9efec;
  --ink: #15211d;
  --muted: #7a8a84;
  --accent: #0e7656;        /* لون التطبيق */
  --accent-ink: #0e7656;    /* نص بلون التطبيق */
  --bright: #3ccb94;
  --hero-top: #123329;      /* نفس خلفية رأس التطبيق */
  --hero-bottom: #0a1714;
  --hero-muted: #a3b8b0;
  --shadow: 0 1px 2px rgba(21, 33, 29, .05), 0 8px 24px rgba(21, 33, 29, .06);
  --pop: 0 12px 32px rgba(21, 33, 29, .16);
  --r: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1714; --card: #16231f; --stroke: #22332d; --soft: #1a2924; --ink: #e8efec; --muted: #8fa39b;
    --accent-ink: #3ccb94; --shadow: none; --pop: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1714; --card: #16231f; --stroke: #22332d; --soft: #1a2924; --ink: #e8efec; --muted: #8fa39b;
  --accent-ink: #3ccb94; --shadow: none; --pop: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* خط اسم التطبيق (نفس خط التطبيق): /assets/fonts/nn.ttf */
@font-face { font-family: "MsmunName"; src: url("/assets/fonts/nn.ttf") format("truetype"); font-display: block; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;              /* التذييل يبقى أسفل الشاشة */
  background: var(--bg); color: var(--ink);
  font-family: "Readex Pro", system-ui, "Segoe UI", Tahoma, sans-serif; font-size: 16.5px; line-height: 1.6;
}
.tf, [lang="zgh"] { font-family: "Noto Sans Tifinagh", "Readex Pro", sans-serif; }
a { color: var(--accent-ink); }
button, select, textarea, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--bright); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.note { color: var(--muted); font-size: 14.5px; margin: 6px 0 12px; }

/* ===================== الرأس: نفس تدرج رأس التطبيق ===================== */
.hero { background: linear-gradient(180deg, var(--hero-top), var(--hero-bottom)); color: #fff; }
.hero-in {
  max-width: 1320px; margin: 0 auto; padding: 12px clamp(16px, 3vw, 32px);
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex: none; }
.brand img { border-radius: 11px; }
.wm { font-size: 26px; line-height: 1; white-space: nowrap; direction: ltr; }
.wm-nn { font-family: "MsmunName", sans-serif; display: none; }
.wm-uni { font-family: "Noto Sans Tifinagh", sans-serif; letter-spacing: .03em; }
.nn-ok .wm-nn { display: inline; }
.nn-ok .wm-uni { display: none; }

.tabs { flex: 1; display: flex; justify-content: center; gap: 6px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 8px 15px; border-radius: 999px; text-decoration: none; color: var(--hero-muted); font-size: 15px;
}
.tabs svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.tabs a[aria-current="page"] { color: #fff; background: var(--accent); }

.actions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .04); color: var(--hero-muted); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { color: #fff; }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn .i-moon { fill: currentColor; stroke: none; display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}
.lang {
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .04); color: var(--hero-muted);
  border-radius: 999px; padding: 7px 15px; font-size: 14px; cursor: pointer;
}
.lang:hover { color: #fff; }

/* ===================== الصفحة: يملأ عرض الحاسوب، والتذييل في الأسفل ===================== */
.page {
  flex: 1; width: 100%; max-width: 1320px; margin: 0 auto;
  padding: 22px clamp(16px, 3vw, 32px) 28px;
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start;
}
.panel { min-width: 0; }
.side { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r); box-shadow: var(--shadow); }
.sec { padding: 22px clamp(16px, 2.4vw, 30px) 26px; }
.sec-title { font-size: 21px; font-weight: 600; margin: 0 0 16px; }

/* ===================== أزرار الاختيار بشكل التطبيق (حبة داخل إطار) ===================== */
.seg {
  display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px;
  background: var(--soft); border: 1px solid var(--stroke); max-width: 100%;
}
.seg button {
  border: 0; background: none; cursor: pointer; border-radius: 999px;
  padding: 9px 22px; color: var(--muted); font-size: 16px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"], .seg button[aria-checked="true"], .seg button[aria-pressed="true"] {
  background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(14, 118, 86, .3);
}
.seg-dirs { display: flex; width: 100%; max-width: 560px; margin-bottom: 16px; }
.seg-dirs button { flex: 1; font-size: 17px; padding: 10px 8px; }
.seg-dirs .tf { font-size: 18px; }
.seg-small { margin-top: 12px; padding: 4px; }
.seg-small button { padding: 6px 16px; font-size: 14.5px; }

/* ===================== البحث ===================== */
.box {
  position: relative; display: flex; align-items: center; gap: 4px;
  background: var(--card); border: 1.5px solid var(--stroke); border-radius: 16px; padding: 4px 6px 4px 8px;
}
.box:focus-within { border-color: var(--accent); }
.box-ic { width: 22px; height: 22px; flex: none; margin-inline-start: 8px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
#q { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 21px; padding: 12px 10px; }
#q::placeholder { color: var(--muted); opacity: .8; }
#q.tf { font-size: 22px; }

.kbBtn {
  flex: none; width: 52px; height: 44px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--soft); color: var(--accent-ink); display: grid; place-items: center;
}
.kbBtn svg { width: 36px; height: 26px; }
.kbBtn rect, .kbBtn path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.kbBtn text { fill: currentColor; stroke: none; font-family: "Noto Sans Tifinagh", sans-serif; font-size: 15px; }
.kbBtn[aria-expanded="true"] { background: var(--accent); color: #fff; }
.kbBtn.small { width: 46px; height: 36px; }
.kbBtn.small svg { width: 30px; height: 22px; }

.sug {
  position: absolute; z-index: 5; top: calc(100% + 8px); left: 0; right: 0;
  list-style: none; margin: 0; padding: 6px; max-height: 380px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; box-shadow: var(--pop);
}
.opt { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 10px 14px; border-radius: 11px; cursor: pointer; }
.opt-w { font-size: 19px; }
.opt-w.tf { font-size: 20px; }
.opt-z { font-family: "Noto Sans Tifinagh", sans-serif; color: var(--accent-ink); font-size: 18px; direction: ltr; }
.opt-l { color: var(--muted); font-size: 15px; direction: ltr; }
.opt:hover, .opt[aria-selected="true"] { background: var(--soft); }

.kb {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px;
  margin-top: 10px; padding: 10px; direction: ltr;
  background: var(--soft); border: 1px solid var(--stroke); border-radius: 16px;
}
.kb button {
  height: 44px; border: 1px solid var(--stroke); border-radius: 10px; background: var(--card); cursor: pointer;
  font-family: "Noto Sans Tifinagh", sans-serif; font-size: 21px;
}
.kb button:active { background: var(--accent); color: #fff; }
.kb .wide { grid-column: span 2; font-family: "Readex Pro", sans-serif; font-size: 14.5px; }

/* مساحة النتيجة ثابتة: الصفحة لا تتقلص ولا تتوسع مع كل بحث */
.result-area { min-height: 340px; margin-top: 18px; border-top: 1px solid var(--stroke); padding-top: 14px; }
.status { color: var(--muted); font-size: 15px; min-height: 1.6em; }
.status.err { color: #d0564c; }

.word { padding: 6px 2px 0; }
.word-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 14px; }
.word-head .w { font-size: 30px; font-weight: 600; line-height: 1.3; }
.word-head .w.tf { font-weight: 400; }
.word-head .z { font-family: "Noto Sans Tifinagh", sans-serif; font-size: 28px; color: var(--accent-ink); direction: ltr; }
.word-head .cat { font-size: 13px; color: var(--muted); border: 1px solid var(--stroke); border-radius: 999px; padding: 1px 10px; }
.word dl { margin: 0; display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 10px 18px; }
.word dt { color: var(--muted); font-size: 14.5px; padding-top: 3px; }
.word dd { margin: 0; font-size: 18px; }
.word dd .tf { font-size: 20px; }
.word .lat { color: var(--muted); direction: ltr; unicode-bidi: isolate; font-size: 16px; }
.word .ex { display: block; margin-bottom: 4px; unicode-bidi: isolate; }
.word dd > span { unicode-bidi: isolate; }
.tools, .chips, .ocr-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chip, .tools button, .chips button {
  border: 1px solid var(--stroke); background: var(--soft); color: var(--accent-ink);
  border-radius: 999px; padding: 6px 15px; font-size: 14px; cursor: pointer;
}
.chip:hover, .tools button:hover, .chips button:hover { border-color: var(--accent); }

/* ===================== ترجمة تيفيناغ ===================== */
.conv { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.conv-col { min-width: 0; }
.conv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: 15px; min-height: 38px; }
#convIn, #ocrText {
  width: 100%; resize: vertical; padding: 14px 16px; font-size: 19px; outline: 0;
  background: var(--card); border: 1.5px solid var(--stroke); border-radius: 16px;
}
#convIn:focus, #ocrText:focus { border-color: var(--accent); }
#convIn.tf { font-size: 22px; }
.conv-out {
  min-height: 186px; padding: 14px 16px; font-size: 22px; white-space: pre-wrap; word-break: break-word;
  background: var(--soft); border: 1px solid var(--stroke); border-radius: 16px;
}
.conv-out.tf { font-size: 24px; letter-spacing: .02em; }

/* ===================== تعلم تيفيناغ ===================== */
.lesson { padding: 18px 0; border-top: 1px solid var(--stroke); }
.lesson:first-of-type { border-top: 0; padding-top: 0; }
.lesson h2 { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.lesson p { margin: 0 0 12px; }
.step {
  width: 28px; height: 28px; border-radius: 999px; display: inline-grid; place-items: center; flex: none;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}
.alpha { direction: ltr; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.alpha button {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 14px; cursor: pointer;
  padding: 9px 4px 7px; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.alpha button:hover, .alpha button[aria-pressed="true"] { border-color: var(--accent); background: var(--soft); }
.alpha .g { font-family: "Noto Sans Tifinagh", sans-serif; font-size: 28px; line-height: 1.25; }
.alpha .l { color: var(--muted); font-size: 13.5px; }
.alpha .a { color: var(--accent-ink); font-size: 14px; }
.letter-view {
  display: flex; align-items: center; gap: 22px; margin-bottom: 14px; padding: 12px 20px;
  background: var(--soft); border-radius: 16px; border: 1px solid var(--stroke);
}
.letter-view .big { font-size: 72px; line-height: 1; color: var(--accent-ink); }
.lv-info { display: flex; flex-direction: column; gap: 2px; font-size: 19px; }
.lv-info b { font-size: 26px; direction: ltr; }
.examples { display: flex; flex-wrap: wrap; gap: 10px; }
.examples > span {
  display: inline-flex; flex-direction: column; align-items: center; padding: 6px 16px;
  background: var(--soft); border: 1px solid var(--stroke); border-radius: 14px;
}
.examples .t { font-family: "Noto Sans Tifinagh", sans-serif; font-size: 22px; direction: ltr; }
.examples .l { color: var(--muted); font-size: 14px; direction: ltr; }
.dialog { background: var(--soft); border: 1px solid var(--stroke); border-radius: 16px; padding: 12px 18px; margin-bottom: 10px; direction: ltr; text-align: left; }
.dialog p { margin: 6px 0; font-size: 20px; }
.dialog b { color: var(--accent-ink); font-weight: 400; }
.dialog .lat { display: block; color: var(--muted); font-size: 15px; font-family: "Readex Pro", sans-serif; }
.quiz-q { font-size: 70px; line-height: 1.1; margin: 4px 0 12px; color: var(--accent-ink); }
.quiz-opts { display: flex; gap: 10px; flex-wrap: wrap; }
.quiz-opts button {
  min-width: 70px; padding: 8px 18px; font-size: 19px; direction: ltr; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--stroke); border-radius: 12px;
}
.quiz-opts button.right { border-color: var(--accent); background: var(--accent); color: #fff; }
.quiz-opts button.wrong { border-color: #d0564c; color: #d0564c; }
.credit { margin: 16px 0 0; color: var(--muted); font-size: 14px; }

/* ===================== استخراج النص ===================== */
.ocr-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 16px; }
.ocr-bar select {
  padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--stroke); background: var(--card); min-width: 170px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: 1.5px solid var(--accent); border-radius: 12px;
  padding: 9px 20px; font-size: 15.5px; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.ocr-work { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 18px; align-items: start; }
.ocr-img {
  min-height: 220px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14.5px;
  background: var(--soft); border: 1.5px dashed var(--stroke); border-radius: 16px; overflow: hidden;
}
#ocrPreview { max-width: 100%; display: block; }
.ocr-res { min-width: 0; }

/* ===================== الجانب ===================== */
.side-block { padding: 16px 18px; }
.side-block h2 { font-size: 15.5px; font-weight: 600; margin: 0 0 4px; }
.side-note { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
.app-row { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--stroke); }
.app-row img { grid-row: span 2; align-self: start; }
.app-row .gp { grid-column: 2; justify-self: start; }
.app-row img { border-radius: 11px; }
.app-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.app-txt b { font-weight: 500; font-size: 14.5px; }
.app-txt small { color: var(--muted); font-size: 12.5px; }
.gp {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none; white-space: nowrap;
  background: var(--accent); color: #fff; border-radius: 999px; padding: 5px 11px 5px 10px; font-size: 12.5px;
}
.gp svg { width: 12px; height: 12px; fill: currentColor; }
.gp:hover { filter: brightness(1.08); }
.social { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.social a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; color: var(--ink);
  background: var(--soft); border: 1px solid var(--stroke); border-radius: 999px; padding: 7px 15px 7px 12px; font-size: 14px;
}
.social a:hover { border-color: var(--accent); color: var(--accent-ink); }
.social svg { width: 18px; height: 18px; fill: currentColor; }
.social svg.stroke { fill: none; stroke: currentColor; stroke-width: 1.8; }
.social svg.stroke .dot { fill: currentColor; stroke: none; }

.ad { text-align: center; }
.ad-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.ad-inline { margin-top: 18px; }

/* ===================== التذييل: دائماً أسفل الشاشة ===================== */
.foot { border-top: 1px solid var(--stroke); background: var(--card); }
.foot-in {
  max-width: 1320px; margin: 0 auto; padding: 14px clamp(16px, 3vw, 32px);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 14px;
}
.foot a { color: var(--muted); }
.noscript { text-align: center; color: var(--muted); }

/* ===================== الشاشات الأصغر ===================== */
@media (max-width: 1060px) {
  .page { grid-template-columns: 1fr; }
  .side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .ad-side { display: none !important; } /* على الشاشات الصغيرة إعلان واحد فقط (أسفل القسم) */
}
@media (max-width: 900px) {
  .hero-in { flex-wrap: wrap; gap: 10px 12px; padding-bottom: 8px; }
  .actions { margin-inline-start: auto; }
  .tabs { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .tabs::-webkit-scrollbar { display: none; }
  .wm { font-size: 22px; }
  .conv, .ocr-work { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .side { grid-template-columns: 1fr; }
  .sec { padding: 18px 14px 20px; }
  .seg button { padding: 8px 14px; }
  .seg-small button { padding: 6px 11px; font-size: 13.5px; }
  #q { font-size: 19px; }
  .word-head .w { font-size: 25px; }
  .word dl { grid-template-columns: 1fr; gap: 2px; }
  .word dt { padding-top: 8px; }
  .result-area { min-height: 260px; }
  .letter-view .big { font-size: 60px; }
}
@media (prefers-reduced-motion: reduce) { .seg button { transition: none; } }

/* ===================== سحب وإفلات الصورة ===================== */
.ocr-img { cursor: pointer; transition: border-color .15s, background .15s; }
.ocr-img:hover { border-color: var(--accent); }
.ocr-img.over { border-color: var(--accent); background: var(--card); border-style: solid; }
.drop-msg { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 18px; pointer-events: none; }
.drop-msg svg { width: 38px; height: 38px; fill: none; stroke: var(--accent-ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
.drop-msg b { color: var(--ink); font-weight: 500; font-size: 15.5px; }

/* ===================== آخر الكلمات ===================== */
.recent { margin-top: 6px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 14.5px; }
.recent .chips { margin-top: 8px; }
.recent .chips .tf { font-size: 16px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-ink); font-size: 13.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ===================== تواصل معنا ===================== */
.contact { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 14.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; font-size: 16px; outline: 0;
  background: var(--card); border: 1.5px solid var(--stroke); border-radius: 12px;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.row-end { flex-direction: row; align-items: center; gap: 14px; flex-wrap: wrap; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.status.ok { color: var(--accent-ink); }
.contact-alt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--stroke); color: var(--muted); font-size: 14.5px; }
.contact-alt .chip { text-decoration: none; }
.social .contact-link { color: var(--accent-ink); }
.foot-links { display: inline-flex; gap: 18px; }
@media (max-width: 600px) { .contact { grid-template-columns: 1fr; } }

/* ===================== مؤثر استخراج النص فوق الصورة ===================== */
.ocr-img { position: relative; }
.ocr-img.busy { cursor: progress; border-style: solid; border-color: var(--accent); }
.ocr-img.busy #ocrPreview { filter: saturate(.6) brightness(.92); }
.ocr-scan {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  background: linear-gradient(180deg, rgba(14,118,86,.10), rgba(14,118,86,.22));
}
.ocr-scan[hidden] { display: none; }
.scan-line {
  position: absolute; inset-inline: 0; top: 0; height: 3px;
  background: var(--accent); box-shadow: 0 0 14px 4px rgba(60,203,148,.55);
  animation: scanMove 1.8s ease-in-out infinite alternate;
}
@keyframes scanMove { from { top: 2%; } to { top: 96%; } }
.scan-badge {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  background: var(--card); color: var(--ink); padding: 10px 16px; border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0,0,0,.18); font-size: 14.5px;
}
.scan-badge b { font-weight: 500; }
.spin {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 3px solid var(--soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scan-bar { position: absolute; inset-inline: 0; bottom: 0; height: 4px; background: rgba(14,118,86,.18); overflow: hidden; }
.scan-bar i { position: absolute; top: 0; bottom: 0; width: 40%; background: var(--accent); animation: barMove 1.2s ease-in-out infinite; }
@keyframes barMove { from { left: -40%; } to { left: 100%; } }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .scan-line { animation-duration: 4s; }
  .spin, .btn.loading::after { animation-duration: 1.6s; }
}

/* ===================== ترجمة تيفيناغ: الشرح فوق خانة الكتابة ===================== */
.conv-hint { margin: 14px 0 0; padding: 10px 14px; background: var(--soft); border-radius: 12px; border: 1px solid var(--stroke); }

/* ===================== تعلم تيفيناغ: خانات مربعة وصندوق الحرف ظاهر دائماً ===================== */
.alpha { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 7px; }
.alpha button { aspect-ratio: 1 / 1; min-height: 0; min-width: 0; overflow: hidden; padding: 2px; justify-content: center; gap: 0; border-radius: 12px; }
.alpha .g { font-size: 25px; line-height: 1.15; }
.alpha .l { font-size: 12.5px; line-height: 1.2; }
.alpha .a { font-size: 12.5px; line-height: 1.25; }
.letter-view { position: sticky; top: 8px; z-index: 3; background: var(--soft); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
@media (max-width: 600px) {
  .alpha { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .alpha button { border-radius: 10px; }
  .alpha .g { font-size: 20px; line-height: 1.1; }
  .alpha .l, .alpha .a { font-size: 10.5px; line-height: 1.15; }
  .letter-view { padding: 8px 14px; gap: 16px; margin-bottom: 10px; }
  .letter-view .big { font-size: 48px; }
  .lv-info { font-size: 16px; }
  .lv-info b { font-size: 21px; }
}
@media (max-width: 360px) { .alpha { grid-template-columns: repeat(5, 1fr); } }

/* ===================== نص تعريفي (SEO) ===================== */
.about { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--stroke); color: var(--muted); font-size: 14.5px; }
.about h2 { font-size: 16px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.about p { margin: 0 0 6px; }
.about a { color: var(--accent-ink); }

/* ===================== المفضلة ===================== */
.fav-top { position: relative; }
.fav-top[hidden] { display: none; }
.fav-top svg { stroke-linejoin: round; }
.fav-top .badge {
  position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: #f2b632; color: #1d1a10; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.fav-star {
  margin-inline-start: auto; align-self: center; width: 42px; height: 42px; flex: none; border-radius: 999px;
  border: 1px solid var(--stroke); background: var(--card); color: var(--muted); cursor: pointer; display: grid; place-items: center;
  transition: color .15s, border-color .15s, background .15s;
}
.fav-star svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.fav-star:hover { color: #d99a0b; border-color: #e7b84a; }
.fav-star[aria-pressed="true"] { color: #e0a10c; border-color: #e7b84a; background: rgba(242, 182, 50, .12); }
.fav-star[aria-pressed="true"] svg { fill: currentColor; }
.fav-star.pop svg { animation: favPop .35s ease-out; }
@keyframes favPop { 50% { transform: scale(1.35); } }
.favs { margin: 6px 0 18px; }
.star-ic svg { width: 16px; height: 16px; fill: #e0a10c; stroke: #e0a10c; stroke-width: 1.5; stroke-linejoin: round; vertical-align: -2px; margin-inline-end: 6px; }
.favs .muted { color: var(--muted); font-size: 13px; }
.fav-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.fav-list li { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--stroke); border-radius: 12px; overflow: hidden; }
.fav-list li:hover { border-color: var(--accent); }
.fav-open {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap;
  background: none; border: 0; padding: 9px 12px; cursor: pointer; color: var(--ink); text-align: start; font: inherit;
}
.fav-open .fw { font-weight: 500; font-size: 16.5px; }
.fav-open .fw.tf { font-family: "Noto Sans Tifinagh", sans-serif; font-weight: 400; }
.fav-open .fz { font-family: "Noto Sans Tifinagh", sans-serif; color: var(--accent-ink); font-size: 15.5px; direction: ltr; }
.fav-open .fm { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.fav-del { flex: none; width: 36px; border: 0; border-inline-start: 1px solid var(--stroke); background: none; color: var(--muted); font-size: 19px; cursor: pointer; }
.fav-del:hover { color: #c0392b; background: var(--soft); }
@media (max-width: 600px) { .fav-list { grid-template-columns: 1fr; } .fav-star { width: 38px; height: 38px; } }
