/* ===== جوال ملدس: system layer ===== */
:root {
  --font: -apple-system, system-ui, "SF Pro Text", "SF Arabic", "Segoe UI", Tahoma, sans-serif;
  --W: 393px; --H: 852px; --sat: 59px; --sab: 34px; --corner: 55px;
  --pad: 24px; --col: 86px; --icon: 64px; --row: 98px;
  --glass: rgba(255, 255, 255, .14);
  --glass-edge: rgba(255, 255, 255, .28);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0614; font-family: var(--font); }
body { position: fixed; inset: 0; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
#probe { position: fixed; top: 0; left: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.ico { display: inline-flex; width: 1em; height: 1em; }
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------- desktop stage ---------- */
#stage { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(min(80vw, 520px) min(70vh, 620px) at 50% 52%, rgba(242, 194, 48, .10), transparent 72%),
    radial-gradient(1200px 700px at 50% 40%, #2a1356 0%, #120a24 55%, #07040e 100%); }
/* the MLDS name above the phone and the team credit under it (desktop and the framed phone) */
#brand-top, #brand-bottom { position: fixed; left: 0; right: 0; display: none; justify-content: center; align-items: center; gap: 8px; pointer-events: none; z-index: 0; }
html.desktop #brand-top, html.desktop #brand-bottom { display: flex; }
#brand-top { top: calc(50% - var(--dev-vh, 880px) / 2 - 32px); height: 26px; color: rgba(255, 255, 255, .9); font: 600 15px/1 var(--font); }
#brand-top img { width: 24px; height: 24px; border-radius: 6px; box-shadow: 0 0 0 .5px rgba(255, 255, 255, .2); }
#brand-bottom { top: calc(50% + var(--dev-vh, 880px) / 2 + 8px); height: 18px; color: #f2c230; font: 500 12.5px/1 var(--font); letter-spacing: .01em; opacity: .85; }
#device { z-index: 1; }
/* centred on its own: a grid would grow to the unscaled 880px box and push the phone down on short screens */
#device { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: calc(var(--W) + 28px); height: calc(var(--H) + 28px); border-radius: calc(var(--corner) + 14px);
  background: #0a0a0c; padding: 14px; transform-origin: 50% 50%;
  box-shadow: 0 0 0 2px #3b3546, 0 0 0 3.5px #17141c, 0 40px 90px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255,255,255,.06); }
#device::before, #device::after { content: ""; position: absolute; width: 4px; border-radius: 2px; background: #2c2834; }
#device::before { left: -5px; top: 190px; height: 64px; box-shadow: 0 84px 0 #2c2834; }
#device::after { right: -5px; top: 250px; height: 100px; }
#side-btn { position: absolute; right: -7px; top: 250px; width: 9px; height: 100px; z-index: 3; cursor: pointer; border-radius: 3px; }
#side-btn:active { transform: translateX(-1px); }
html.mobile #side-btn { display: none; }
#desk-hint { position: fixed; bottom: 14px; left: 0; right: 0; margin: 0; text-align: center; color: rgba(255,255,255,.45); font-size: 13px; }

#screen { position: relative; width: var(--W); height: var(--H); overflow: hidden; border-radius: var(--corner);
  background: #000; color: #fff; isolation: isolate; contain: layout paint; }

/* phone: the page is the phone */
html.mobile #stage { display: block; background: #000; }
html.mobile #device { position: fixed; inset: 0; translate: none; width: auto; height: auto; padding: 0; border-radius: 0; box-shadow: none; background: #000; transform: none !important; }
html.mobile #device::before, html.mobile #device::after, html.mobile #desk-hint { display: none; }
html.mobile #screen { border-radius: 0; }

/* ---------- wallpaper (MLDS night) ---------- */
#wallpaper, #cover .wp { position: absolute; inset: -2px; background:
  radial-gradient(70% 45% at 78% 18%, rgba(160, 92, 255, .55), transparent 70%),
  radial-gradient(65% 40% at 18% 72%, rgba(240, 190, 40, .28), transparent 70%),
  radial-gradient(90% 60% at 50% 105%, rgba(95, 30, 190, .75), transparent 70%),
  linear-gradient(180deg, #1b0b3c 0%, #2a0f5e 42%, #170834 100%); }
#wallpaper::after, #cover .wp::after { content: ""; position: absolute; inset: 0; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* ---------- status bar & island ---------- */
#statusbar { position: absolute; top: 0; left: 0; right: 0; height: 54px; z-index: 60; display: flex; align-items: center; justify-content: space-between;
  padding: 6px 30px 0 32px; pointer-events: none; font-weight: 600; font-size: 17px; letter-spacing: -.2px; transition: color .25s; }
.sb-light #statusbar { color: #fff; }
.sb-dark #statusbar { color: #000; }
.sb-time { width: 70px; text-align: center; font-variant-numeric: tabular-nums; }
.sb-right { display: flex; align-items: center; gap: 6px; direction: ltr; }
.sb-signal { width: 18px; height: 12px; } .sb-wifi { width: 16px; height: 12px; } .sb-batt { width: 27px; height: 13px; }
.sb-right svg { width: 100%; height: 100%; display: block; }
html.mobile #statusbar { display: none; }

#island { position: absolute; top: 11px; left: 50%; width: 126px; height: 37px; margin-left: -63px; border-radius: 19px; background: #000; z-index: 70;
  pointer-events: none; display: grid; place-items: center; overflow: hidden; }
html.mobile #island { display: none; }
html.mobile.has-island #island { display: grid; background: transparent; }
html.mobile.has-island #island.busy { background: #000; }
.isl-content { color: #fff; opacity: 0; display: grid; place-items: center; gap: 8px; }
.isl-content .fid { width: 56px; height: 56px; color: #fff; }
.isl-content .fid.ok { color: #34c759; }
.isl-content .fid svg path { stroke-width: 1.6; }

/* ---------- home ---------- */
#home { position: absolute; inset: 0; z-index: 10; transform-origin: 50% 50%; will-change: transform, opacity; }
#pager { position: absolute; inset: 0; will-change: transform; }
#home .page { position: absolute; top: 0; width: var(--W); height: 100%; }
#home .page.p-home { right: 0; }
#home .page.p-today { right: calc(var(--W) * -1); }
#home .page.p-lib { right: var(--W); }

#home .grid { position: absolute; top: calc(var(--sat) + 14px); right: var(--pad); left: var(--pad); display: grid;
  grid-template-columns: repeat(4, var(--col)); grid-auto-rows: var(--row); }
:is(#home, #spot) .app-icon { display: flex; flex-direction: column; align-items: center; gap: 6px; }
:is(#home, #spot) .app-icon .img { width: var(--icon); height: var(--icon); border-radius: 23%; overflow: hidden; position: relative; background: #222;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: filter .28s ease-out, opacity .2s; }
:is(#home, #spot) .app-icon .img img { width: 100%; height: 100%; display: block; }
:is(#home, #spot) .app-icon .img::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.18); }
:is(#home, #spot) .app-icon.pressed .img { filter: brightness(.62); transition: filter 0s; }
:is(#home, #spot) .app-icon .lbl { font-size: 11.5px; font-weight: 500; line-height: 1.15; color: #fff; text-shadow: 0 .5px 2px rgba(0,0,0,.35);
  max-width: calc(var(--col) + 6px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: auto; }
:is(#home, #spot) .app-icon.launching .img { visibility: hidden; }

#home .widget { grid-column: span 2; grid-row: span 2; justify-self: center; width: calc(var(--col) * 2 - 6px); height: calc(var(--col) * 2 - 6px);
  border-radius: 22px; background: #1c1c1e; padding: 15px 16px; overflow: hidden; position: relative; transition: transform .25s ease-out, filter .25s; }
#home .widget.pressed { transform: scale(.97); filter: brightness(.85); transition: transform .08s, filter .08s; }
#home .w-cal .wd { color: #ff453a; font-size: 13px; font-weight: 700; }
#home .w-cal .dn { font-size: 46px; font-weight: 300; line-height: 1.05; letter-spacing: -1px; margin-top: 2px; }
#home .w-cal .ev { position: absolute; bottom: 15px; right: 16px; left: 16px; font-size: 12.5px; color: rgba(235,235,245,.6); line-height: 1.3; }
#home .w-note { background: #1c1c1e; padding: 0; }
#home .w-note .bar { height: 38px; background: #ffd60a; display: flex; align-items: center; gap: 6px; padding: 0 12px; color: #1c1c1e; font-weight: 700; font-size: 13px; }
#home .w-note .bar .ico { width: 15px; height: 15px; }
#home .w-note .bd { padding: 10px 13px; }
#home .w-note .tt { font-weight: 700; font-size: 14.5px; line-height: 1.25; }
#home .w-note .tm { font-size: 12px; color: rgba(235,235,245,.6); margin-top: 3px; }
#home .w-note .pv { font-size: 12.5px; color: rgba(235,235,245,.6); margin-top: 6px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

#dots { position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 96px); display: flex; justify-content: center; gap: 8px; opacity: 0; transition: opacity .3s; pointer-events: none; }
#dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.35); }
#dots i.on { background: #fff; }
#home.swiping #dots { opacity: 1; } #home.swiping #spot-pill { opacity: 0; }
#spot-pill { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--sab) + 94px); height: 30px; padding: 0 13px; border-radius: 15px;
  display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: rgba(255,255,255,.95);
  background: rgba(255,255,255,.16); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); transition: opacity .3s; }
#spot-pill .ico { width: 13px; height: 13px; }
#dock { position: absolute; left: 12px; right: 12px; bottom: max(10px, calc(var(--sab) - 22px)); height: 92px; border-radius: 36px;
  display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; justify-items: center; padding: 0 6px;
  background: var(--glass); -webkit-backdrop-filter: blur(26px) saturate(1.7); backdrop-filter: blur(26px) saturate(1.7);
  box-shadow: inset 0 .5px 0 var(--glass-edge), inset 0 0 0 .5px rgba(255,255,255,.12); }
#dock .app-icon .lbl { display: none; }

/* today view & app library */
#home .p-scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; overscroll-behavior: contain;
  padding: calc(var(--sat) + 8px) 16px calc(var(--sab) + 40px); scrollbar-width: none; }
#home .p-scroll::-webkit-scrollbar { display: none; }
#home .srch { height: 38px; border-radius: 12px; display: flex; align-items: center; gap: 6px; padding: 0 10px; color: rgba(235,235,245,.7); font-size: 16px;
  background: rgba(255,255,255,.16); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); margin-bottom: 18px; }
#home .srch .ico { width: 17px; height: 17px; }
#home .today-stack { display: grid; gap: 16px; }
#home .tw { border-radius: 22px; overflow: hidden; position: relative; background: rgba(28,28,30,.72); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); transition: transform .25s ease-out; }
#home .tw.pressed { transform: scale(.97); transition: transform .08s; }
#home .tw-photo { height: 170px; background-size: cover; background-position: center; }
#home .tw-photo .cap { position: absolute; bottom: 12px; right: 14px; left: 14px; font-weight: 700; font-size: 15px; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
#home .tw-photo .cap small { display: block; font-weight: 500; font-size: 12px; opacity: .85; }
#home .tw-cal { padding: 14px 16px; display: flex; gap: 14px; align-items: center; }
#home .tw-cal .big { text-align: center; min-width: 64px; }
#home .tw-cal .big .wd { color: #ff453a; font-weight: 700; font-size: 13px; } .tw-cal .big .dn { font-size: 40px; font-weight: 300; line-height: 1.05; }
#home .tw-cal .txt { font-size: 14px; color: rgba(235,235,245,.65); line-height: 1.45; }
#home .tw-batt { padding: 14px 16px; display: flex; gap: 18px; }
#home .tw-batt .ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: conic-gradient(#30d158 0 87%, rgba(255,255,255,.12) 0); position: relative; }
#home .tw-batt .ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #1c1c1e; }
#home .tw-batt .ring span { position: relative; }

#home .lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; padding: 0 6px; }
#home .lib-box { display: grid; gap: 7px; }
#home .lib-tile { aspect-ratio: 1; border-radius: 24px; padding: 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  background: rgba(255,255,255,.14); -webkit-backdrop-filter: blur(20px) saturate(1.5); backdrop-filter: blur(20px) saturate(1.5); }
#home .lib-tile .app-icon .img { width: 100%; height: auto; aspect-ratio: 1; }
#home .lib-tile .app-icon .lbl { display: none; }
#home .lib-tile .mini { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
#home .lib-tile .mini .app-icon .img { border-radius: 24%; }
#home .lib-name { text-align: center; font-size: 12px; font-weight: 500; color: rgba(255,255,255,.9); }

/* ---------- app windows ---------- */
#apps { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
/* no will-change here: a window only gets a clip-path while it flies to or from its icon (see Win.render) */
.win { position: absolute; inset: 0; pointer-events: none; }
.win.live { pointer-events: auto; }
/* built in the background (os.js «warm-up»): painted once, invisible, never touched */
.win.warming { opacity: .01; }
.win.warming, .win.warming * { pointer-events: none !important; }
.win-body { position: absolute; top: 0; left: 0; width: var(--W); height: var(--H); transform-origin: 0 0; overflow: hidden; background: #000; will-change: transform; }
.win-icon { position: absolute; top: 0; left: 0; width: var(--icon); height: var(--icon); transform-origin: 0 0; pointer-events: none; will-change: transform, opacity; }
.win.card .win-body { pointer-events: none; }
/* a card is touched only through its shield, which follows the scaled body; the full-screen .win stays out of the way
   so taps between cards reach the backdrop, and the app's own scrollers and buttons never see the finger */
.win.card { pointer-events: none; }
.win-shield { position: absolute; inset: 0; z-index: 2147483647; display: none; touch-action: none; }
/* any window that is not the live app (a card, or one flying home) is touched only through its shield: app content that
   sets pointer-events: auto can't catch a tap meant for the icon under it, and a tap on the flying window reopens it */
.win:not(.live) .win-shield { display: block; pointer-events: auto; }
#sw-backdrop { position: absolute; inset: 0; z-index: 19; opacity: 0; pointer-events: none; background: rgba(0,0,0,.28);
  -webkit-backdrop-filter: blur(24px) saturate(1.2); backdrop-filter: blur(24px) saturate(1.2); }
#sw-backdrop.on { pointer-events: auto; }
#sw-labels { position: absolute; inset: 0; z-index: 21; pointer-events: none; }
.sw-label { position: absolute; top: 0; left: 0; display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; transform-origin: 0 0; }
.sw-label img { width: 26px; height: 26px; border-radius: 23%; }

/* ---------- cover: lock screen / notification centre ---------- */
#cover { position: absolute; inset: 0; z-index: 50; will-change: transform; overflow: hidden; touch-action: none; }
.lock-top { position: absolute; top: calc(var(--sat) - 8px); left: 0; right: 0; display: flex; justify-content: center; }
.lock-glyph { width: 15px; height: 20px; color: #fff; transition: transform .3s; }
.lock-glyph svg { width: 100%; height: 100%; }
html.has-island .lock-top, html.desktop .lock-top { top: calc(var(--sat) + 2px); }
.lock-date { position: absolute; top: calc(var(--sat) + 30px); left: 0; right: 0; text-align: center; font-size: 21px; font-weight: 600; color: rgba(255,255,255,.88); }
.lock-clock { position: absolute; top: calc(var(--sat) + 54px); left: 0; right: 0; text-align: center; font-size: 96px; font-weight: 700; line-height: 1; letter-spacing: -2px;
  color: rgba(255,255,255,.93); font-variant-numeric: tabular-nums; }
.lock-notes { position: absolute; left: 10px; right: 10px; bottom: calc(var(--sab) + 120px); display: grid; gap: 8px; }
.lock-hint { position: absolute; bottom: calc(var(--sab) + 2px); left: 0; right: 0; text-align: center; font-size: 13px; color: rgba(255,255,255,.75); opacity: 0; transition: opacity .4s; }
#cover.unlocked .lock-hint { opacity: 1; }
#cover.nc .lock-hint, #cover.nc .lock-btn { display: none; }
.lock-btn { position: absolute; bottom: calc(var(--sab) + 18px); width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.28); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); color: #fff; transition: transform .25s, background .2s, color .2s; }
.lock-btn .ico { width: 22px; height: 22px; }
.lock-btn.pressed { transform: scale(1.12); }
.lock-btn.on { background: #fff; color: #111; }
.lb-flash { right: 46px; } .lb-cam { left: 46px; }

/* notification card (lock + banner) */
.note-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 24px; min-height: 68px;
  background: rgba(40, 30, 60, .42); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8);
  box-shadow: inset 0 .5px 0 rgba(255,255,255,.25); color: #fff; transition: transform .25s ease-out; }
.note-card.pressed { transform: scale(.97); transition: transform .08s; }
.note-card img { width: 38px; height: 38px; border-radius: 23%; flex: none; }
.note-card .nc-body { flex: 1; min-width: 0; }
.note-card .nc-head { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.note-card .nc-head time { font-weight: 400; font-size: 13px; color: rgba(255,255,255,.6); white-space: nowrap; }
.note-card .nc-text { font-size: 15px; line-height: 1.3; color: rgba(255,255,255,.92); margin-top: 1px; }

#banners { position: absolute; top: 0; left: 0; right: 0; z-index: 65; pointer-events: none; }
#banners .note-card { position: absolute; left: 8px; right: 8px; top: 0; pointer-events: auto; will-change: transform; background: rgba(30, 24, 44, .55); }

/* ---------- system gesture zones ---------- */
#zone-top { position: absolute; top: 0; left: 0; right: 0; height: max(var(--sat), 24px); z-index: 80; touch-action: none; }
#zone-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: max(var(--sab), 26px); z-index: 80; touch-action: none; display: flex; justify-content: center; align-items: flex-end; }
.home-bar { width: 138px; height: 5px; border-radius: 3px; margin-bottom: 8px; background: #fff; transition: background .25s, opacity .25s; }
.sb-dark .home-bar { background: #000; }
.hide-bar .home-bar { opacity: 0; }

/* ---------- shared sheets/menus ---------- */
#screen > .glass-menu { position: absolute; z-index: 90; min-width: 230px; border-radius: 14px; overflow: hidden;
  background: rgba(37, 37, 40, .82); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8);
  box-shadow: 0 12px 40px rgba(0,0,0,.45); transform-origin: top left; }
#screen > .glass-menu button { display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 12px 16px; font-size: 16px; text-align: start; }
#screen > .glass-menu button + button { border-top: .5px solid rgba(255,255,255,.12); }
#screen > .glass-menu button.pressed { background: rgba(255,255,255,.1); }
#screen > .glass-menu button.danger { color: #ff453a; }
#screen > .glass-menu button .ico { width: 20px; height: 20px; }
#screen > .menu-scrim { position: absolute; inset: 0; z-index: 89; }
#screen > .toast { pointer-events: none; position: absolute; left: 50%; top: calc(var(--sat) + 8px); z-index: 95; transform: translateX(-50%); padding: 9px 16px; border-radius: 20px; font-size: 14px; font-weight: 600;
  background: rgba(40,40,44,.86); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); transition: opacity .3s; white-space: nowrap; }

#debug { position: absolute; left: 6px; right: 6px; top: 40%; z-index: 999; background: rgba(0,0,0,.8); color: #0f0; font: 12px/1.5 ui-monospace, monospace; padding: 8px; border-radius: 8px; direction: ltr; white-space: pre-wrap; pointer-events: none; }

@media (prefers-reduced-transparency: reduce) {
  #dock, .note-card, .lock-btn, #screen > .glass-menu, #spot-pill { background: rgba(30,30,34,.96); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* home icon badge (red count, top corner on the reading-end side like Arabic iOS) */
:is(#home, #spot) .app-icon { position: relative; }
:is(#home, #spot) .app-icon .badge { position: absolute; top: -6px; inset-inline-end: calc(50% - var(--icon) / 2 - 8px); min-width: 22px; height: 22px; padding: 0 6px;
  box-sizing: border-box; border-radius: 11px; background: #ff3b30; color: #fff; font: 600 14px/22px var(--font); text-align: center; pointer-events: none; }
