/* فاتح، بخلفية متدرجة ناعمة، وكرة صوت حيّة في المنتصف. */
:root {
  --bg: #f7f4ff; --fg: #1e1b3a; --muted: #6e6a8a; --glass: rgba(255,255,255,.66); --glass-line: rgba(255,255,255,.9);
  --line: rgba(30,27,58,.08); --accent: #5b4bff; --accent2: #b44bff; --accent-soft: rgba(91,75,255,.1);
  --grad: linear-gradient(135deg, #5b4bff, #b44bff 55%, #ff7aa8);
  --bad: #e5484d; --good: #12a594; --shadow: 0 10px 40px rgba(60,40,140,.12);
  --head: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "Plus Jakarta Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.75 var(--body); padding-bottom: calc(110px + env(safe-area-inset-bottom)); overflow-x: hidden; }
svg { width: 24px; height: 24px; fill: currentColor; }
h1, h2, h3 { font-family: var(--head); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; font-weight: 700; line-height: 1.35; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 10px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }

/* خلفية: بقع لونية ضبابية */
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blobs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.blobs i:nth-child(1) { width: 340px; height: 340px; background: #c9c2ff; top: -120px; right: -80px; }
.blobs i:nth-child(2) { width: 300px; height: 300px; background: #ffd3e4; top: 260px; left: -140px; }
.blobs i:nth-child(3) { width: 280px; height: 280px; background: #c8f1ea; bottom: -80px; right: -60px; }

.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
       max-width: 560px; margin: 0 auto; padding: calc(22px + env(safe-area-inset-top)) 22px 6px; }
.greeting { margin: 0; color: var(--muted); font-size: .95rem; }
.streak { font-family: var(--head); font-weight: 600; font-size: .85rem; color: #fff; background: var(--grad);
          border-radius: 999px; padding: 6px 14px; white-space: nowrap; box-shadow: 0 6px 18px rgba(91,75,255,.3); }
main { max-width: 560px; margin: 0 auto; padding: 14px 22px 24px; }
.view { display: grid; gap: 18px; animation: rise .35s ease; }
.view[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.glass { background: var(--glass); border: 1px solid var(--glass-line); border-radius: 26px; padding: 20px;
         box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }

/* المواقف: شبكة بطاقات */
.setup h2 { margin-bottom: 12px; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.topic { font: 500 .82rem/1.35 var(--body); color: var(--fg);
         display: grid; justify-items: center; align-content: start; gap: 6px; padding: 12px 6px 10px; text-align: center; cursor: pointer;
         background: var(--glass); border: 1px solid var(--glass-line); border-radius: 20px; box-shadow: 0 4px 16px rgba(60,40,140,.06);
         transition: transform .2s, box-shadow .2s, background .2s; }
.topic .emoji { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem;
                background: var(--tint, #eeeaff); }
.topic:active { transform: scale(.96); }
.topic[aria-checked="true"] { background: #fff; box-shadow: 0 0 0 2px var(--accent), 0 10px 26px rgba(91,75,255,.22); font-weight: 600; }

/* المنصة: كرة الصوت */
.stage { display: grid; justify-items: center; gap: 6px; padding: 6px 0 4px; text-align: center; }
.orb-wrap { position: relative; width: 210px; height: 210px; display: grid; place-items: center; }
.orb { position: absolute; inset: 0; border-radius: 50%;
       background: conic-gradient(from 0deg, #5b4bff, #b44bff, #ff7aa8, #ffb86b, #5b4bff);
       filter: blur(18px) saturate(1.1); opacity: .55; animation: spin 14s linear infinite;
       transform: scale(calc(.82 + var(--level, 0) * .45)); transition: transform .12s ease-out, opacity .4s; }
@keyframes spin { to { rotate: 360deg; } }
body.in-session .orb { opacity: .9; animation-duration: 6s; }
.mic { position: relative; width: 116px; height: 116px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
       background: var(--grad); display: grid; place-items: center;
       box-shadow: inset 0 2px 0 rgba(255,255,255,.35), 0 14px 34px rgba(91,75,255,.4); transition: transform .2s; }
.mic svg { width: 46px; height: 46px; }
.mic:active { transform: scale(.95); }
.mic.stop { background: linear-gradient(135deg, #ff5f6d, #ff8a5c); box-shadow: inset 0 2px 0 rgba(255,255,255,.35), 0 14px 34px rgba(255,95,109,.4); }
.mic.stop svg { display: none; }
.mic.stop::after { content: ""; width: 34px; height: 34px; border-radius: 9px; background: #fff; }
.mic:disabled { opacity: .6; cursor: wait; }
.mic-label { font-family: var(--head); font-weight: 600; font-size: 1.05rem; margin-top: 4px; }
.status { color: var(--muted); font-size: .9rem; min-height: 1em; }
.live { margin: 0; font: 600 .9rem var(--body); color: var(--accent); background: var(--accent-soft);
        border-radius: 999px; padding: 4px 14px; font-variant-numeric: tabular-nums; direction: ltr; }
body.in-session #setup, body.in-session .switch { display: none; }
body:not(.on-talk) .top h1 { display: none; }

.switch[hidden] { display: none; }
.invite { margin-top: 12px; }
.voice-pick { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--muted); font-size: .92rem; }
.voice-pick button { border: 0; border-radius: 999px; padding: 5px 12px; font: inherit; color: var(--muted); background: rgba(30,27,58,.06); cursor: pointer; }
.voice-pick button[aria-checked="true"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
body.in-session .voice-pick { display: none; }
body.in-session .invite { display: none; }
.switch { display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; cursor: pointer; color: var(--muted); font-size: .92rem; }
.switch small { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 8px; font-size: .72rem; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 44px; height: 26px; border-radius: 999px; background: rgba(30,27,58,.14); position: relative; transition: .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
                        background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { right: 21px; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* المحادثة */
.chat { display: grid; gap: 10px; }
.chat:empty { display: none; }
.msg { padding: 11px 16px; border-radius: 22px; max-width: 86%; animation: rise .3s ease; }
.msg.user { justify-self: start; color: #fff; background: var(--grad); border-end-start-radius: 8px; box-shadow: 0 8px 20px rgba(91,75,255,.22); }
.msg.tutor { justify-self: end; background: var(--glass); border: 1px solid var(--glass-line); border-end-end-radius: 8px;
             box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }

/* القوائم */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.list:not(.cards) > li + li { border-top: 1px solid var(--line); padding-top: 12px; }
.list.cards > li { background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px; padding: 16px 18px;
                   box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.en { direction: ltr; unicode-bidi: isolate; text-align: left; }
.mistakes strong { font-family: var(--head); font-weight: 600; font-size: .9rem; color: var(--accent); }
.mistakes .wrong { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; opacity: .85; }
.mistakes .right { color: var(--good); font-weight: 600; }
.words .word { font-family: var(--head); font-weight: 600; font-size: 1.1rem; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.words .meaning { font: 500 .95rem var(--body); color: var(--accent); direction: rtl; unicode-bidi: isolate; }
.words .en.muted { font-size: .92rem; }
.history .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.chip { font-family: var(--head); font-size: .85rem; font-weight: 600; color: var(--accent); }
.chip.plain { font-family: var(--body); font-weight: 400; color: var(--muted); }

/* التقدّم */
.ring-card { display: flex; align-items: center; gap: 18px; }
.ring { --p: 0; width: 112px; height: 112px; flex: none; border-radius: 50%; display: grid; place-items: center;
        background: conic-gradient(#5b4bff, #b44bff calc(var(--p) * 1%), rgba(30,27,58,.08) 0); }
.ring > div { width: 88px; height: 88px; border-radius: 50%; background: #fff; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring strong { font-family: var(--head); font-size: 1.7rem; }
.ring span { font-size: .75rem; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px; padding: 16px; display: grid; gap: 2px;
        box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.stat strong { font-family: var(--head); font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.wide { grid-column: 1 / -1; }
.meter { height: 8px; border-radius: 999px; background: rgba(30,27,58,.08); overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; background: var(--grad); border-radius: 999px; }
.trend { display: flex; align-items: flex-end; gap: 8px; height: 120px; direction: ltr; padding-top: 22px; }
.trend .bar { flex: 1; max-width: 26px; background: var(--grad); border-radius: 10px; position: relative; }
.trend .bar span { position: absolute; top: -20px; width: 100%; text-align: center; font-size: .78rem; color: var(--muted); }

/* شريط الأقسام العائم */
.tabs { position: fixed; z-index: 5; inset-inline: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto;
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px; border-radius: 26px;
        background: rgba(255,255,255,.78); border: 1px solid var(--glass-line); box-shadow: 0 12px 40px rgba(60,40,140,.18);
        backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.tabs button { font: 500 .74rem var(--body); border: 0; background: none; color: var(--muted); padding: 8px 0 6px; border-radius: 20px;
               display: grid; justify-items: center; gap: 2px; cursor: pointer; transition: background .2s, color .2s; }
.tabs button[hidden] { display: none; }
.tabs button.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
/* أثناء الجلسة: يختفي شريط الأقسام حتى لا يغطي آخر رسالة. */
body.in-session .tabs { display: none; }
body.in-session { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.version { margin: 8px 0 0; text-align: center; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.words .word-text { display: inline-flex; align-items: center; gap: 10px; }
.say { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
       color: #fff; background: var(--grad); box-shadow: 0 4px 12px rgba(91,75,255,.25); transition: transform .15s; }
.say svg { width: 18px; height: 18px; }
.say:active { transform: scale(.92); }
.say:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* الدخول */
.login { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 22px; background: var(--bg); overflow-y: auto; }
.login[hidden] { display: none; }
body.locked > :not(.login, .blobs) { display: none; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; justify-items: stretch; text-align: center; }
.login-card img { justify-self: center; border-radius: 20px; box-shadow: var(--shadow); }
.form { display: grid; gap: 12px; }
.login-card label, .form label { display: grid; gap: 4px; text-align: start; font-size: .9rem; color: var(--muted); }
input:not([type=checkbox]) { font: 500 1rem var(--body); color: var(--fg); padding: 11px 14px; border-radius: 14px;
        border: 1px solid rgba(30,27,58,.14); background: rgba(255,255,255,.85); width: 100%; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.btn { font: 600 1rem var(--head); color: #fff; background: var(--grad); border: 0; border-radius: 16px; padding: 12px 18px;
       cursor: pointer; box-shadow: 0 8px 22px rgba(91,75,255,.28); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ghost { color: var(--accent); background: var(--accent-soft); box-shadow: none; font-size: .85rem; padding: 7px 12px; border-radius: 12px; }
.btn.danger { color: var(--bad); background: rgba(229,72,77,.1); }
.error { color: var(--bad); margin: 0; min-height: 1.2em; font-size: .9rem; }
.link { font: inherit; font-size: .8rem; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.footer-links { display: flex; justify-content: center; gap: 16px; margin: 4px 0 0; }

/* الحسابات */
.users .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.users .head strong { font-family: var(--head); font-size: 1.05rem; }
.users .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.users li.off { opacity: .55; }
.badge { font-size: .72rem; border-radius: 999px; padding: 1px 9px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* الحد الشهري والطلبات */
.account p { margin: 0 0 10px; }
.payment { white-space: pre-line; background: var(--accent-soft); border-radius: 16px; padding: 12px 14px; font-weight: 500; }
.request-form { display: grid; gap: 10px; }
.request-form label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.requests .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tabs button { position: relative; }
.dot { position: absolute; top: 4px; inset-inline-end: 22%; min-width: 18px; height: 18px; border-radius: 999px; padding: 0 5px;
       background: var(--bad); color: #fff; font: 600 .7rem/18px var(--body); }
.dot[hidden] { display: none; }
.account[hidden] { display: none; }

/* نافذة الشحن */
.topup { width: min(420px, calc(100% - 32px)); border: 1px solid var(--glass-line); color: var(--fg); padding: 26px 22px 20px; text-align: center;
         background: rgba(255,255,255,.94); }
.topup::backdrop { background: rgba(30,27,58,.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.topup h2 { margin-bottom: 8px; }
.topup p { margin: 0 0 14px; }
.topup [hidden] { display: none; }
.topup .close { position: absolute; top: 10px; inset-inline-end: 12px; border: 0; background: none; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.amounts .btn { padding: 14px 6px; font-size: 1.1rem; }
.amounts .btn small { display: block; font-size: .72rem; font-weight: 500; opacity: .9; }
.custom { display: flex; gap: 8px; }
.custom .btn { flex: none; }
.topup .payment { text-align: start; }
.topup #topupSent { width: 100%; margin-bottom: 12px; }
.sent-note { background: rgba(18,165,148,.1); color: var(--good); border-radius: 14px; padding: 10px 12px; font-weight: 600; }
.soon { color: var(--accent); }

/* المعجم */
.dict[hidden], .dict [hidden] { display: none; }
.dict p { margin: 0 0 10px; }
.dict-search { display: flex; gap: 8px; align-items: center; }
.dict-search input { flex: 1; min-width: 0; }
.dict-search .btn { flex: none; padding: 11px 16px; }
.dict-search .say { width: 44px; height: 44px; }
.dict-search .say.rec { background: linear-gradient(135deg, #ff5f6d, #ff8a5c); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.dict-result:empty { display: none; }
.dict-result { display: grid; gap: 8px; margin-top: 6px; }
.dict-result .head { display: flex; align-items: center; gap: 10px; }
.dict-result .head strong { font: 700 1.4rem var(--head); direction: ltr; }
.dict-result ul { margin: 0; padding-inline-start: 18px; }
.dict-result .pos { color: var(--accent); font-weight: 600; }
.dict-result .tip { background: var(--accent-soft); border-radius: 12px; padding: 8px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; direction: ltr; }
.chips button { font: 500 .85rem var(--body); border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; color: var(--fg); }
.tabs button span { white-space: nowrap; }
.view h3.sub { margin: 22px 4px 8px; font-size: 1.1rem; }
.login-card[hidden] { display: none; }
#resetStep2 { display: grid; gap: 14px; }
#resetStep2[hidden] { display: none; }
.backup { display: grid; gap: 8px; }
.backup p { margin: 0; }
.ledger { margin-top: 12px; text-align: start; }
.ledger summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.ledger p { margin: 8px 0; }
.ledger-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(0,0,0,.06); }
.ledger-row small { margin-inline-start: 6px; }
.ledger-row .plus { color: var(--good); }
.ledger-row .minus { color: var(--bad, #d64545); }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.summary-col h3 { margin-bottom: 6px; }
.summary-row { display: flex; justify-content: space-between; gap: 6px; margin: 4px 0; font-size: .85rem; color: var(--muted); }
.summary-row b { color: var(--ink, inherit); white-space: nowrap; }
.search { width: 100%; }
.users > li[hidden] { display: none; }

/* المستوى */
.level-hint { margin: 0 0 14px; padding: 12px 14px; border-radius: 16px; background: #dcf5e3; color: #1f5b35; font-size: .95rem; line-height: 1.7; }
.level-card { display: flex; align-items: center; gap: 18px; }
.level-card h3 { margin: 0 0 4px; }
.level-card p { margin: 0 0 6px; }
.level-badge { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 76px; padding: 10px 12px;
  border-radius: 18px; background: linear-gradient(135deg, #dcf5e3, #e2f4ff); color: #1f5b35; font-size: .85rem; }
.level-badge strong { font-size: 1.6rem; line-height: 1.2; font-family: system-ui, sans-serif; }
#levelResult { margin-bottom: 10px; }

/* المهارات */
.level-card { flex-wrap: wrap; }
.skills { width: 100%; display: grid; gap: 8px; margin-top: 6px; }
.skill { display: grid; grid-template-columns: 82px 1fr 28px; align-items: center; gap: 10px; font-size: .85rem; }
.skill .bar { height: 8px; border-radius: 99px; background: #ece9f6; overflow: hidden; }
.skill .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #8fd3a8, #6aa8e8); }
.skill.weak span, .skill.weak b { color: #b4572e; font-weight: 600; }
.skill.weak .bar i { background: linear-gradient(90deg, #f3b38a, #e98a6a); }
.skill b { font-family: system-ui, sans-serif; font-weight: 500; text-align: left; }
.skills p { margin: 2px 0 0; }
#resultSkills { margin-bottom: 12px; }

/* مؤشرات المدير */
.insights h3 { margin: 14px 0 8px; }
.insights h3:first-child { margin-top: 0; }
.level-dist { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; text-align: center; font-size: .8rem; }
.dist-bar { height: 70px; display: flex; align-items: flex-end; justify-content: center; }
.dist-bar i { width: 60%; min-height: 3px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #a99cf5, #7c6ae6); }
.dist-col b { font-family: system-ui, sans-serif; }
.level-card > div:not(.level-badge):not(.skills) { flex: 1; min-width: 0; }
.row-btns { display: flex; gap: 6px; flex-shrink: 0; }
.btn.small { font-size: .8rem; padding: 6px 10px; border-radius: 10px; }
