/* ============================================================
   AY/OS : desktop.css : wallpaper, icons, taskbar, start,
   palette, toasts, statusbar, overlays
   ============================================================ */

.desktop { position: fixed; inset: 0; overflow: hidden; }

/* ---------- WALLPAPER LAYERS ---------- */
#wall { position: absolute; inset: 0; width: 100%; height: 100%; }

.wall-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 75% 65% at 50% 35%, rgba(0, 0, 0, .3), transparent 68%);
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 50% 35%, rgba(0, 0, 0, .3), transparent 68%);
  opacity: .22;
}
html[data-wall="void"] .wall-grid { display: none; }
html[data-wall="grid"] .wall-grid { opacity: .75; mask-image: none; -webkit-mask-image: none; }

.wall-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 38%, transparent 45%, var(--bg0) 130%);
}

/* ---------- DESKTOP ICONS ---------- */
.icons {
  position: absolute; top: 18px; bottom: calc(var(--tb-h) + 24px);
  inset-inline-start: 14px;
  display: flex; flex-direction: column; flex-wrap: wrap;
  align-content: flex-start; gap: 6px;
  width: max-content; max-width: 40vw;
}
.dicon {
  width: 92px; padding: 12px 6px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border-radius: var(--r);
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast) var(--ease);
  -webkit-user-select: none; user-select: none;
}
.dicon:hover { background: var(--panel-2); border-color: var(--line); }
.dicon:active { transform: scale(.94); }
.dicon .di-tile {
  width: 50px; height: 50px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--panel-2), transparent), var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  color: var(--acc);
  transition: transform var(--t-med) var(--ease-snap), box-shadow var(--t-med), border-color var(--t-fast);
}
html[data-theme="light"] .dicon .di-tile { box-shadow: 0 6px 16px rgba(30, 38, 50, .12); }
.dicon:hover .di-tile { transform: translateY(-3px) scale(1.06); border-color: var(--acc); box-shadow: var(--glow), 0 10px 24px rgba(0, 0, 0, .3); }
.dicon .di-tile svg { width: 26px; height: 26px; }
.dicon .di-label {
  font-size: .74rem; color: var(--ink2); text-align: center; line-height: 1.3;
  max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dicon.dicon-danger .di-tile { color: var(--warn); }
.dicon.dicon-danger:hover .di-tile { border-color: var(--warn); box-shadow: 0 0 22px rgba(255, 180, 84, .3); }

/* ---------- STATUS BAR (mobile) ---------- */
.statusbar {
  display: none;
  position: absolute; top: 0; left: 0; right: 0; z-index: 600;
  height: var(--sb-h); padding: 0 16px;
  align-items: center; justify-content: space-between;
  font-family: var(--f-mono); font-size: .74rem; color: var(--ink2);
  background: linear-gradient(to bottom, var(--bg0), transparent);
}
.sb-gem { color: var(--acc); display: inline-block; vertical-align: -3px; }
.sb-gem svg { width: 13px; height: 13px; }
.sb-clock, .sb-batt { font-family: var(--f-mono); font-size: .74rem; color: var(--ink2); }
.sb-clock:active, .sb-batt:active { opacity: .55; }

/* ---------- TASKBAR ---------- */
.taskbar {
  position: absolute; bottom: 10px; inset-inline: 12px; z-index: 700;
  height: var(--tb-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
}
.tb-start {
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 16px;
  border-radius: 11px;
  font-weight: 700; font-size: .9rem;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: all var(--t-fast) var(--ease);
}
.tb-start svg { width: 17px; height: 17px; color: var(--acc); filter: drop-shadow(0 0 8px var(--acc)); }
.tb-start:hover { border-color: var(--acc); box-shadow: var(--glow); transform: translateY(-1px); }
.tb-start:active { transform: scale(.96); }
.tb-start[aria-expanded="true"] { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
.tb-start[aria-expanded="true"] svg { color: var(--acc-ink); filter: none; }

.tb-tasks { flex: 1; display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tb-tasks::-webkit-scrollbar { display: none; }
.tb-task {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 13px;
  border-radius: 10px; border: 1px solid transparent;
  color: var(--ink2); font-size: .82rem; white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
  position: relative;
}
.tb-task svg { width: 16px; height: 16px; }
.tb-task::after {
  content: ""; position: absolute; bottom: 3px; inset-inline-start: 50%;
  width: 5px; height: 5px; border-radius: 99px;
  background: var(--muted);
  transform: translateX(-50%);
  transition: all var(--t-fast);
}
html[dir="rtl"] .tb-task::after { transform: translateX(50%); }
.tb-task:hover { background: var(--panel-2); color: var(--ink); }
.tb-task.is-active { background: var(--panel-2); border-color: var(--line); color: var(--ink); }
.tb-task.is-active::after { background: var(--acc); width: 16px; box-shadow: 0 0 8px var(--acc); }
.tb-task.is-min { opacity: .55; }

.tb-tray { display: flex; align-items: center; gap: 4px; }
.tb-ico {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--ink2); font-size: .8rem; font-weight: 600;
  transition: all var(--t-fast);
}
.tb-ico svg { width: 17px; height: 17px; }
.tb-ico:hover { background: var(--panel-2); color: var(--acc); }
.tb-lang { font-family: var(--f-mono); letter-spacing: .05em; }
.tb-clock {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 40px; padding: 0 12px; border-radius: 10px;
  font-family: var(--f-mono); line-height: 1.3;
  transition: background var(--t-fast);
}
.tb-clock:hover { background: var(--panel-2); }
#tb-time { font-size: .82rem; color: var(--ink); font-weight: 500; }
#tb-date { font-size: .62rem; color: var(--muted); }

/* ---------- START MENU ---------- */
.startmenu {
  position: absolute; bottom: calc(var(--tb-h) + 20px + env(safe-area-inset-bottom, 0px)); inset-inline-start: 12px; z-index: 800;
  width: min(400px, calc(100vw - 24px));
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-win);
  padding: 18px;
  transform-origin: bottom;
  animation: sm-in var(--t-med) var(--ease-snap) both;
}
html[dir="ltr"] .startmenu { transform-origin: bottom left; }
html[dir="rtl"] .startmenu { transform-origin: bottom right; }
@keyframes sm-in { from { opacity: 0; transform: scale(.92) translateY(14px); } }
.startmenu.sm-out { animation: sm-out var(--t-fast) var(--ease) both; }
@keyframes sm-out { to { opacity: 0; transform: scale(.95) translateY(10px); } }

.sm-head { display: flex; align-items: center; gap: 13px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.sm-avatar {
  width: 52px; height: 52px; border-radius: 16px; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--acc-deep), var(--acc));
  color: #fff; font-weight: 700; font-size: 1.3rem;
  box-shadow: var(--glow);
}
.sm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sm-name { font-weight: 700; font-size: 1.02rem; }
.sm-title { font-size: .74rem; color: var(--muted); margin-top: 2px; }

.sm-apps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 14px 0; }
.sm-app {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 4px 10px; border-radius: var(--r);
  transition: background var(--t-fast), transform var(--t-fast) var(--ease);
}
.sm-app svg { width: 22px; height: 22px; color: var(--acc); }
.sm-app span { font-size: .68rem; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sm-app:hover { background: var(--panel-2); transform: translateY(-2px); }
.sm-app:active { transform: scale(.93); }

.sm-secrets { padding: 12px 4px 14px; border-top: 1px solid var(--line); }
.sm-secrets-row { display: flex; justify-content: space-between; font-size: .76rem; color: var(--ink2); margin-bottom: 8px; }
.sm-secrets-row b { font-family: var(--f-mono); color: var(--acc); }
.sm-secrets-bar { height: 5px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.sm-secrets-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--acc-deep), var(--acc));
  border-radius: 99px;
  transition: width .6s var(--ease);
  box-shadow: 0 0 10px var(--acc);
}

.sm-classic {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--panel-2); border: 1px solid var(--line);
  transition: all var(--t-fast);
}
.sm-classic:hover { border-color: var(--acc); box-shadow: var(--glow); text-decoration: none; }
.sm-classic-ico { font-size: 1.3rem; }
.sm-classic-txt b { display: block; font-size: .85rem; color: var(--ink); }
.sm-classic-txt small { font-size: .7rem; color: var(--muted); }

.sm-power {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; margin-top: 8px;
  padding: 11px;
  border-radius: var(--r);
  border: 1px solid transparent;
  color: var(--muted); font-size: .8rem;
  transition: all var(--t-fast);
}
.sm-power svg { width: 15px; height: 15px; }
.sm-power:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 7%, transparent); }

/* ---------- قائمة الزر الأيمن ---------- */
.ctxmenu {
  position: fixed; z-index: 8600;
  min-width: 215px;
  padding: 6px;
  background: var(--panel-solid);
  border: 1px solid var(--line2);
  border-radius: 14px;
  box-shadow: var(--shadow-win);
  animation: sm-in 140ms var(--ease-snap) both;
}
.ctx-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: start;
  padding: 10px 13px;
  border-radius: 9px;
  color: var(--ink2); font-size: .84rem;
  transition: background 80ms, color 80ms;
}
.ctx-item svg { width: 16px; height: 16px; color: var(--acc); flex-shrink: 0; }
.ctx-item:hover { background: var(--panel-2); color: var(--ink); }

/* ---------- إيقاف التشغيل ---------- */
.shutdown {
  position: fixed; inset: 0; z-index: 9750;
  background: #04060a;
  display: grid; place-items: center;
  opacity: 0; transition: opacity .8s var(--ease);
}
.shutdown.on { opacity: 1; }
.sd-txt { font-family: var(--f-mono); font-size: 1rem; color: #aebdcd; animation: gem-pulse 1.6s infinite; }

/* ---------- اهتزاز ترتيب الأيقونات ---------- */
.dicon.wiggle { animation: icon-wiggle .45s var(--ease); }
@keyframes icon-wiggle {
  25% { transform: rotate(-4deg) scale(1.04); }
  60% { transform: rotate(3deg); }
}

/* ---------- COMMAND PALETTE ---------- */
.palette {
  position: fixed; inset: 0; z-index: 8500;
  background: color-mix(in srgb, var(--bg0) 78%, transparent);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 16vh;
  animation: pal-bg-in var(--t-fast) both;
}
@keyframes pal-bg-in { from { opacity: 0; } }
.pal-box {
  width: min(580px, 92vw);
  background: var(--panel-solid);
  border: 1px solid var(--line2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-win), var(--glow);
  overflow: hidden;
  animation: sm-in var(--t-med) var(--ease-snap) both;
}
.pal-input-row { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.pal-gem { color: var(--acc); animation: gem-pulse 2.2s infinite; display: grid; place-items: center; }
.pal-gem svg { width: 18px; height: 18px; }
#pal-input { flex: 1; background: none; border: 0; outline: none; font-size: 1.02rem; color: var(--ink); font-family: var(--f-ui); }
.pal-list { max-height: 330px; overflow-y: auto; padding: 8px; }
.pal-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: start;
  padding: 11px 12px; border-radius: var(--r-sm);
  color: var(--ink2); font-size: .9rem;
  transition: background 80ms;
}
.pal-item svg { width: 17px; height: 17px; color: var(--acc); flex-shrink: 0; }
.pal-item .pal-k { margin-inline-start: auto; }
.pal-item.is-act { background: var(--panel-2); color: var(--ink); }
.pal-item.is-act::before { content: "▸"; color: var(--acc); font-size: .8rem; order: -1; }
html[dir="rtl"] .pal-item.is-act::before { content: "◂"; }
.pal-empty { padding: 26px; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- TOASTS ---------- */
.toasts {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 9500;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
  width: max-content; max-width: 92vw;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 20px;
  background: var(--panel-solid);
  border: 1px solid var(--line2);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  font-size: .88rem; color: var(--ink);
  max-width: 92vw;
  animation: toast-in var(--t-med) var(--ease-snap) both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.94); } }
.toast.toast-out { animation: toast-out var(--t-med) var(--ease) both; }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(.96); } }
.toast .t-ico { display: grid; place-items: center; color: var(--acc); }
.toast .t-ico svg { width: 19px; height: 19px; }
.toast.toast-achv .t-ico { color: var(--warn); }
.toast.toast-achv {
  border-color: var(--warn);
  background: linear-gradient(100deg, var(--panel), color-mix(in srgb, var(--warn) 12%, var(--panel)));
  position: relative; overflow: hidden;
}
.toast.toast-achv::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .18) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: shine 1.6s .3s var(--ease) 2;
}
@keyframes shine { to { transform: translateX(120%); } }
.toast .t-txt b { display: block; font-size: .8rem; color: var(--warn); }

/* ---------- SNAP GHOST ---------- */
.snap-ghost {
  position: absolute; z-index: 890;
  border: 2px dashed var(--acc);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--acc) 9%, transparent);
  transition: all 150ms var(--ease);
  pointer-events: none;
}

/* ---------- الوجه الحي ---------- */
.face {
  position: absolute; bottom: calc(var(--tb-h) - 18px); inset-inline-end: 52px;
  width: 200px; z-index: 590;   /* فوق النوافذ (500+) ليبقى ظاهرا دائما، وتحت شريط المهام (600+) */
  color: var(--acc);
  cursor: pointer;
  pointer-events: none;         /* لا يحجب النقر على النوافذ خلفه؛ الجسم المرسوم وحده يستقبل النقر */
  -webkit-user-select: none; user-select: none;
}
.face svg { width: 100%; display: block; overflow: visible; pointer-events: auto; }
.face .outline { opacity: .4; transition: opacity var(--t-med); }
.face:hover .outline { opacity: .6; }
.face .glow { filter: drop-shadow(0 0 9px currentColor); }
.face .blink {
  animation: bot-blink 4.6s ease-in-out infinite;
  transform-origin: center; transform-box: fill-box;
}
.face .pupil-r .blink { animation-delay: .12s; }
.face .psize { transition: transform var(--t-fast); transform-origin: center; transform-box: fill-box; }
.face svg[data-mood="shock"] .psize { transform: scale(1.3); }

/* المشاعر: إظهار/إخفاء */
.face .arc, .face .xeyes, .face .m { opacity: 0; transition: opacity .16s var(--ease); }
.face svg[data-mood="normal"] .m-normal { opacity: 1; }
.face svg[data-mood="happy"] .m-happy,
.face svg[data-mood="happy"] .arc-l,
.face svg[data-mood="happy"] .arc-r { opacity: 1; }
.face svg[data-mood="happy"] .eye { opacity: 0; }
.face svg[data-mood="sad"] .m-sad { opacity: 1; }
.face svg[data-mood="shock"] .m-shock { opacity: 1; }
.face svg[data-mood="dead"] .m-dead,
.face svg[data-mood="dead"] .xeyes { opacity: 1; }
.face svg[data-mood="dead"] .eye { opacity: 0; }
.face svg[data-mood="wink"] .m-happy,
.face svg[data-mood="wink"] .arc-r { opacity: 1; }
.face svg[data-mood="wink"] .eye-r { opacity: 0; }
.face .eye { transition: opacity .16s var(--ease); }

.face.bounce { animation: face-bounce .45s var(--ease-snap); }
@keyframes face-bounce {
  30% { transform: translateY(-14px) scale(1.04, .96); }
  60% { transform: translateY(2px) scale(.98, 1.02); }
}

/* وجه مصغر يزرع داخل التطبيقات (spawnFace)، نفس رسم بدي وروحه */
.face.face--mini { position: static; inset: auto; width: 100%; height: 100%; z-index: auto; cursor: default; color: inherit; display: grid; place-items: center; }
.face--mini .breath { width: 100%; display: grid; place-items: center; }
.face--mini svg { width: 100%; height: auto; }
.tear { opacity: 0; transition: opacity .25s var(--ease); transform-box: fill-box; transform-origin: center; }
.face--mini svg[data-mood="sad"] .tear { opacity: 1; animation: tear-drip .9s var(--ease); }
@keyframes tear-drip { 0% { transform: translateY(-5px); opacity: 0; } 45% { opacity: 1; } 100% { transform: translateY(0); } }
.face--mini .psize { transition: transform .5s var(--ease-snap); }

/* ذروة البكاء (data-cry): عيون كبيرة جدا بلمعات كثيرة + فم انكسار يرتجف */
.cry-spark, .m-cry { opacity: 0; }
.cry-spark { transition: opacity .35s var(--ease); }
.face--mini svg[data-cry="1"] .cry-spark { opacity: 1; }
.face--mini svg[data-cry="1"] .m-cry { opacity: 1; }
.face--mini svg[data-cry="1"] .m-sad { opacity: 0; }
.face--mini svg[data-cry="1"] .glow,
.face--mini svg[data-cry="1"] .mouths { animation: cry-quiver .22s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes cry-quiver { 0%,100% { transform: translate(0,0); } 25% { transform: translate(.6px,-.4px); } 50% { transform: translate(-.5px,.4px); } 75% { transform: translate(.4px,.3px); } }
/* خيبة الأمل: المربع يبقى منتصبا، والهوائي وحده ينحني بقوس ناعم وينزل للأسفل (انحناء مسار حقيقي، لا دوران صلب) */
.face--mini .antenna > path { d: path("M110 30 C110 24 110 18 110 12"); transition: d .85s cubic-bezier(.34, 0, .24, 1); }
.face--mini.crying .antenna > path { d: path("M110 30 C107 8 134 12 126 42"); }
@media (prefers-reduced-motion: reduce) {
  .face--mini svg[data-cry="1"] .glow, .face--mini svg[data-cry="1"] .mouths { animation: none; }
}

/* ورقة نبتة على رأس الهوائي بدل الكرة، وفرع نحيف صغير يحمل ورقة ثانية أصغر (تذبلان مع الهوائي في ذروة الحزن، استعارة الزهرة الذابلة) */
.leaf-anchor {
  transform-box: view-box; transform-origin: 0 0;
  transform: translate(110px, 12px) rotate(-34deg) scale(1.15);
  transition: transform .85s cubic-bezier(.34, 0, .24, 1);
}
.leaf-anchor-r { transform: translate(117px, 16.5px) rotate(78deg) scale(.4); }
.face--mini.crying .leaf-anchor-l { transform: translate(120px, 20px) rotate(112deg) scale(1.15); }
/* فرع نحيف واضح (أنحف من سمك الساق الرئيسي بكثير)، والورقة الثانية أصغر معلقة في طرفه */
.branch-stem { fill: none; stroke-width: 1.6; }
.branch {
  transform-box: view-box; transform-origin: 110px 23px;
  transition: transform .85s cubic-bezier(.34, 0, .24, 1);
}
.face--mini.crying .branch { transform: rotate(98deg); }
.leaf { fill: currentColor; opacity: .92; }
.leaf-vein { fill: none; stroke: #05131d; stroke-width: 1.3; stroke-linecap: round; opacity: .5; }
/* تمايل هواء دائم وخفيف، بتوقيت مختلف بين الورقتين */
.leaf-sway {
  transform-box: fill-box; transform-origin: center bottom;
  animation: leaf-sway 3.6s ease-in-out infinite;
}
.leaf-sway-r { animation-duration: 4.2s; animation-direction: reverse; }
@keyframes leaf-sway {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .leaf-sway { animation: none; }
}

/* التنفس الدائم + التحفز عند الاقتراب */
.face svg { animation: face-breath 4.4s ease-in-out infinite; }
@keyframes face-breath { 50% { transform: translateY(-3px); } }
.face .breath { transition: transform .35s var(--ease); transform-origin: bottom center; }
.face .breath.near { transform: scale(1.05); }

/* حركات الخمول */
.face.tilt { animation: face-tilt 1s var(--ease); }
@keyframes face-tilt {
  30% { transform: rotate(-3.5deg); }
  70% { transform: rotate(2deg); }
}
.face .antenna { transform-origin: 110px 30px; transform-box: view-box; }
.face svg.wig .antenna { animation: ant-sway .85s var(--ease); }
@keyframes ant-sway {
  25% { transform: rotate(14deg); }
  60% { transform: rotate(-11deg); }
  85% { transform: rotate(5deg); }
}
.face .blink.fb { animation: blink-once .26s ease-in-out 2 !important; }
@keyframes blink-once { 50% { transform: scaleY(.08); } }

/* الغضب: يحمر ويهتز وتظهر حواجبه */
.face svg[data-mood="angry"] { color: var(--bad); }
.face .brows { opacity: 0; transition: opacity .14s var(--ease); }
.face svg[data-mood="angry"] .brows,
.face svg[data-mood="angry"] .m-angry { opacity: 1; }
.face svg[data-mood="angry"] .psize { transform: scale(1.12); }
.face.shake { animation: face-shake .55s var(--ease); }
@keyframes face-shake {
  12%, 52%, 88% { transform: translateX(-6px) rotate(-1deg); }
  32%, 72% { transform: translateX(6px) rotate(1deg); }
}

/* النعاس: الجفن يكاد ينطبق، شق رفيع عند أسفل العين، والبؤبؤ يختفي */
.face.is-sleepy .blink { animation: none !important; transform: scaleY(.12); transform-origin: center 107.5px; transform-box: view-box; }
.face.is-sleepy .pupil { opacity: 0; transition: opacity .3s var(--ease); }

/* الدوخة: عيون دوامة تلتف، فم متموج، رأس يترنح، لون أخضر، نجوم تدور */
.face svg { transition: color .45s var(--ease); }
.face svg[data-mood="dizzy"] { color: #3ddc97; }
.face .swirls { opacity: 0; transition: opacity .3s var(--ease); }
.face svg[data-mood="dizzy"] .pupil,
.face svg[data-mood="dizzy"] .eye > .blink > .psize > circle:first-child { opacity: 0; }
.face svg[data-mood="dizzy"] .swirls { opacity: 1; }
.face svg[data-mood="dizzy"] .m-dizzy { opacity: 1; }
.sw-l { transform-box: fill-box; transform-origin: center; animation: swirl 1.1s linear infinite; }
.sw-r { transform-box: fill-box; transform-origin: center; animation: swirl 1.1s linear infinite reverse; }
@keyframes swirl { to { transform: rotate(360deg); } }
.face.is-dizzy { animation: dizzy-wobble 1.15s ease-in-out infinite; }
@keyframes dizzy-wobble {
  0%, 100% { transform: rotate(-6deg) translateY(0); }
  25% { transform: rotate(4deg) translateY(-2px); }
  50% { transform: rotate(-3deg) translateY(1px); }
  75% { transform: rotate(5deg) translateY(-1px); }
}
/* تسوية الخروج: يترنح بهدوء متناقص حتى يستقر */
.face.settle { animation: settle-out .65s var(--ease) both; }
@keyframes settle-out {
  0% { transform: rotate(-6deg); }
  35% { transform: rotate(3.5deg); }
  65% { transform: rotate(-1.8deg); }
  85% { transform: rotate(.8deg); }
  100% { transform: rotate(0deg); }
}
.stars {
  position: absolute; top: 6%; inset-inline-start: 50%;
  width: 0; height: 0; pointer-events: none;
  opacity: 0; transition: opacity .3s var(--ease);
  animation: stars-spin 1.5s linear infinite;
}
.face.is-dizzy .stars { opacity: 1; }
.stars i {
  position: absolute; font-style: normal; color: #9ff2ff;
  font-size: .8rem; filter: drop-shadow(0 0 5px #3ddc97);
}
.stars i:nth-child(1) { transform: rotate(0deg) translateX(34px); }
.stars i:nth-child(2) { transform: rotate(120deg) translateX(34px); font-size: .6rem; }
.stars i:nth-child(3) { transform: rotate(240deg) translateX(34px); font-size: .7rem; }
@keyframes stars-spin { to { transform: rotate(360deg); } }
.face svg[data-mood="sleepy"] .m-sleepy { opacity: 1; }
.zzz {
  position: absolute; top: -4px; inset-inline-start: 20%;
  width: 64px; height: 50px;
  opacity: 0; pointer-events: none;
  transition: opacity .5s var(--ease);
}
.face.is-sleepy .zzz { opacity: 1; }
.zzz i {
  position: absolute; bottom: 0; inset-inline-start: 0;
  font-style: normal; font-family: var(--f-mono); font-weight: 700;
  color: var(--acc); font-size: .85rem;
  opacity: 0;
  animation: zfloat 2.7s linear infinite;
}
.zzz i:nth-child(2) { inset-inline-start: 16px; font-size: 1.05rem; animation-delay: .9s; }
.zzz i:nth-child(3) { inset-inline-start: 33px; font-size: 1.25rem; animation-delay: 1.8s; }
@keyframes zfloat {
  12% { opacity: .9; }
  100% { transform: translateY(-36px) rotate(14deg); opacity: 0; }
}

.face-bubble {
  position: absolute; bottom: calc(100% + 12px); inset-inline-end: 8px;
  width: max-content; max-width: min(300px, 70vw);
  background: var(--panel-solid);
  border: 1px solid var(--line2);
  border-radius: 14px;
  border-end-end-radius: 4px;
  padding: 11px 15px;
  font-size: .8rem; color: var(--ink); text-align: start; line-height: 1.6;
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(8px) scale(.94);
  transform-origin: bottom; pointer-events: none;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease-snap);
  z-index: 5;
}
.face-bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.face-bubble::after {
  content: ""; position: absolute; top: 100%; inset-inline-end: 26px;
  border: 7px solid transparent; border-top-color: var(--line2);
}
@media (max-width: 840px), (max-height: 540px) and (pointer: coarse) {
  .face { width: 140px; inset-inline-end: 18px; bottom: calc(var(--tb-h) - 6px); z-index: 40; }
}

/* ---------- شاشة التوقف ---------- */
.saver {
  position: fixed; inset: 0; z-index: 9700;
  background: #04060a;
  opacity: 0; transition: opacity .45s var(--ease);
  cursor: none; overflow: hidden;
}
.saver.on { opacity: 1; }
.saver-logo {
  position: absolute; top: 0; left: 0;
  width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  will-change: transform;
  filter: drop-shadow(0 0 18px currentColor);
  transition: color .25s;
}
.saver-logo svg { width: 78px; height: 78px; }
.saver-logo b { font-family: var(--f-mono); font-size: .8rem; letter-spacing: .3em; color: currentColor; }
.saver-foot {
  position: absolute; bottom: 36px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.saver-foot span { font-family: var(--f-mono); font-size: 1.6rem; color: #aebdcd; }
.saver-foot small { font-size: .72rem; color: #49596c; animation: gem-pulse 2.4s infinite; }
.saver.corner-hit { animation: corner-flash .9s ease-out; }
@keyframes corner-flash {
  0% { background: #04060a; }
  18% { background: #1b2d44; }
  100% { background: #04060a; }
}

/* ---------- ALARM OVERLAY ---------- */
.alarm { position: fixed; inset: 0; z-index: 8800; pointer-events: none; }
.alarm.on { animation: alarm-flash .45s ease-in-out 5; }
@keyframes alarm-flash {
  0%, 100% { background: transparent; }
  50% { background: radial-gradient(ellipse at center, rgba(255, 60, 70, .22), rgba(255, 60, 70, .38)); }
}

/* ---------- BSOD ---------- */
.bsod {
  position: fixed; inset: 0; z-index: 9800;
  background: #0a72d5; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: auto;
  font-family: var(--f-ui);
  animation: pal-bg-in .2s both;
}
.bsod-inner { width: min(640px, 88vw); padding: 28px 24px; text-align: start; }
.bsod-face { font-size: clamp(4.5rem, 12vw, 7rem); font-weight: 300; line-height: 1; margin-bottom: 26px; font-family: var(--f-display); }
.bsod-text { font-family: var(--f-ui); font-size: clamp(.95rem, 2vw, 1.12rem); line-height: 1.8; white-space: pre-wrap; margin-bottom: 22px; opacity: .96; }
.bsod-progress { font-size: 1rem; opacity: .92; font-family: var(--f-mono); margin-bottom: 28px; }
.bsod-info { display: flex; align-items: center; gap: 16px; }
.bsod-qr { width: 88px; height: 88px; background: #fff; border-radius: 4px; padding: 6px; flex-shrink: 0; }
.bsod-qr svg { display: block; width: 100%; height: 100%; }
.bsod-info-text { font-size: .82rem; line-height: 1.7; opacity: .92; }
.bsod-stop { margin-top: 7px; }
.bsod-stopcode { font-family: var(--f-mono); letter-spacing: .02em; }
.bsod-exit { margin-top: 34px; font-size: .8rem; opacity: .7; animation: gem-pulse 2s infinite; }

/* ============================================================
   MOBILE : phone launcher mode
   ============================================================ */
@media (max-width: 840px), (max-height: 540px) and (pointer: coarse) {
  /* اجلس شريط الحالة أسفل نوتش/شريط الهاتف الحقيقي */
  .statusbar {
    display: flex;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--sb-h) + env(safe-area-inset-top, 0px));
  }

  .icons {
    top: calc(var(--sb-h) + 20px + env(safe-area-inset-top, 0px));
    bottom: calc(var(--tb-h) + 30px + env(safe-area-inset-bottom, 0px));
    inset-inline: 0; width: auto; max-width: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: max-content;
    align-content: start;
    gap: 14px 4px; padding: 12px 14px;
    overflow-y: auto;
  }
  .dicon { width: auto; }
  .dicon .di-tile { width: 56px; height: 56px; border-radius: 17px; }
  .dicon .di-tile svg { width: 27px; height: 27px; }

  .taskbar { inset-inline: 14px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); justify-content: space-between; }
  .tb-tasks { display: none; }
  .tb-clock { display: none; }
  .tb-start span { display: none; }
  .tb-start { padding: 0 14px; }

  .startmenu { inset-inline: 12px; width: auto; }
  .toasts { top: calc(var(--sb-h) + 10px + env(safe-area-inset-top, 0px)); }
  .palette { padding-top: 9vh; }
}
