.pl {
  --pl-bg: #F0F5FF; --pl-fg: #1F3447; --pl-a1: #0284C7; --pl-a2: #1F3447;
  --pl-muted: #64748b; --pl-grid: rgba(31,52,71,.06); --pl-glow: rgba(2,132,199,.18);
  --pl-size: clamp(88px, 22vmin, 148px);
  position: fixed; inset: 0; z-index: 99999; display: grid; place-items: center;
  min-height: 100vh; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--pl-bg); color: var(--pl-fg); overflow: hidden; direction: rtl;
  font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  transition: opacity .5s ease, visibility .5s ease;
}
html.dark .pl {
  --pl-bg: #060E1A; --pl-fg: #E6F2FF; --pl-a1: #38BDF8; --pl-a2: #2563eb;
  --pl-muted: #8aa0b8; --pl-grid: rgba(56,189,248,.06); --pl-glow: rgba(56,189,248,.18);
}
.pl.pl-hide { opacity: 0; visibility: hidden; pointer-events: none; }

.pl--inline {
  position: relative; inset: auto; z-index: auto; background: transparent;
  min-height: 60vh; padding: 0; transition: none;
  --pl-size: clamp(72px, 16vmin, 104px);
  animation: pl-in .35s ease .15s both;
}

.pl::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(var(--pl-grid) 1px, transparent 1px), linear-gradient(90deg, var(--pl-grid) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(circle at center, #000 0, transparent 70%);
          mask-image: radial-gradient(circle at center, #000 0, transparent 70%);
}
.pl::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: min(560px, 110vw); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--pl-glow), transparent 65%);
  animation: pl-breathe 3.2s ease-in-out infinite;
}

.pl__stage { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3.2vmin, 24px); padding: 24px; text-align: center; }
.pl__emblem { width: var(--pl-size); height: var(--pl-size); overflow: visible; filter: drop-shadow(0 0 16px var(--pl-glow)); }

.pl__gear   { transform-origin: 60px 60px; animation: pl-spin 22s linear infinite; }
.pl__ticks  { transform-origin: 60px 60px; animation: pl-spin 14s linear infinite reverse; }
.pl__sweep  { transform-origin: 60px 60px; animation: pl-spin 1.5s cubic-bezier(.5,.1,.5,.9) infinite; }
.pl__fill   { transform-box: fill-box; animation: pl-fill 2.6s cubic-bezier(.65,0,.35,1) infinite; }
.pl__shine  { transform-box: fill-box; animation: pl-shine 2.6s ease-in-out infinite; }

.pl__brand  { font-size: clamp(13px, 2.4vmin, 15px); font-weight: 800; }
.pl__status { position: relative; height: 20px; width: min(260px, 80vw); }
.pl__status span {
  position: absolute; inset: 0; font-size: clamp(11px, 2vmin, 12.5px); font-weight: 600; color: var(--pl-muted);
  opacity: 0; animation: pl-status 6s infinite;
}
.pl__status span:nth-child(2) { animation-delay: 2s; }
.pl__status span:nth-child(3) { animation-delay: 4s; }

.pl__rail { position: relative; width: min(190px, 56vw); height: 3px; border-radius: 3px; overflow: hidden; direction: ltr;
  background: color-mix(in srgb, var(--pl-fg) 12%, transparent); }
.pl__rail::after {
  content: ''; position: absolute; inset-block: 0; left: 0; width: 38%; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--pl-a1), var(--pl-a2)); animation: pl-rail 1.4s cubic-bezier(.6,0,.3,1) infinite;
}

.pl__corner { position: absolute; width: 26px; height: 26px; border: 0 solid color-mix(in srgb, var(--pl-a1) 70%, transparent); z-index: 1; }
.pl__corner--tl { top: 22px; left: 22px;  border-top-width: 2px; border-left-width: 2px; }
.pl__corner--tr { top: 22px; right: 22px; border-top-width: 2px; border-right-width: 2px; }
.pl__corner--bl { bottom: 22px; left: 22px;  border-bottom-width: 2px; border-left-width: 2px; }
.pl__corner--br { bottom: 22px; right: 22px; border-bottom-width: 2px; border-right-width: 2px; }
.pl__tag { position: absolute; z-index: 1; font: 600 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .28em; color: var(--pl-muted); direction: ltr; opacity: .8; }
.pl__tag--t { top: 28px; left: 58px; } .pl__tag--b { bottom: 28px; right: 58px; }
.pl--inline .pl__corner, .pl--inline .pl__tag, .pl--inline::before, .pl--inline::after { display: none; }
@media (max-width: 520px), (max-height: 480px) { .pl__corner, .pl__tag { display: none; } }

@keyframes pl-in      { from { opacity: 0; } to { opacity: 1; } }
@keyframes pl-spin    { to { transform: rotate(360deg); } }
@keyframes pl-breathe { 0%,100% { transform: scale(.92); opacity: .75; } 50% { transform: scale(1.06); opacity: 1; } }
@keyframes pl-fill    { 0% { transform: translateY(100%); } 55%,70% { transform: translateY(0); } 100% { transform: translateY(-100%); } }
@keyframes pl-shine   { 0% { transform: translateX(-140%); } 60%,100% { transform: translateX(240%); } }
@keyframes pl-rail    { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }
@keyframes pl-status  { 0% { opacity: 0; transform: translateY(6px); } 6%,28% { opacity: 1; transform: none; } 34%,100% { opacity: 0; transform: translateY(-6px); } }

.rp {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100000; pointer-events: none; transform-origin: right;
  background: linear-gradient(270deg, #0284C7, #1F3447); box-shadow: 0 0 12px rgba(2,132,199,.55);
  animation: rp .9s cubic-bezier(.22,1,.36,1) forwards;
}
html.dark .rp { background: linear-gradient(270deg, #38BDF8, #2563eb); box-shadow: 0 0 14px rgba(56,189,248,.8); }
@keyframes rp { 0% { transform: scaleX(0); opacity: 1; } 65% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .pl__gear, .pl__ticks, .pl__sweep, .pl__fill, .pl__shine, .pl::after, .rp { animation: none !important; }
  .pl__fill { transform: translateY(0); }
  .pl__status span:first-child { opacity: 1; animation: none; }
}
