/* ==========================================================================
   Zero-Lag Background Tab Optimization (Frees 100% GPU/CPU for other apps)
   ========================================================================== */
body.tab-hidden *,
body.tab-hidden *::before,
body.tab-hidden *::after {
    animation-play-state: paused !important;
    transition: none !important;
}

:root {
    --xboot-bg: #070914;
    --xboot-panel: rgba(16, 19, 37, 0.72);
    --xboot-line: rgba(255, 255, 255, 0.09);
    --xboot-text: #f7f8ff;
    --xboot-muted: rgba(224, 228, 247, 0.58);
    --xboot-violet: #a68bff;
    --xboot-cyan: #68d8f4;
    --xboot-rose: #f08ab9;
}

.xboot-screen,
.xboot-screen *,
.xboot-screen *::before,
.xboot-screen *::after {
    box-sizing: border-box;
}

.messenger-body.is-booting {
    overflow: hidden !important;
}

.messenger-body > .app-layout {
    transition: opacity 240ms cubic-bezier(0.22, 1, 0.36, 1), filter 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.messenger-body.is-booting > .app-layout {
    opacity: 0;
    filter: saturate(0.8) blur(5px);
    pointer-events: none;
}

.xboot-screen {
    position: fixed;
    inset: 0;
    z-index: 200000;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    place-items: center;
    overflow: hidden;
    padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    color: var(--xboot-text);
    background:
        radial-gradient(circle at 14% 18%, rgba(150, 111, 255, 0.2), transparent 32rem),
        radial-gradient(circle at 84% 76%, rgba(77, 205, 236, 0.16), transparent 34rem),
        radial-gradient(circle at 56% 112%, rgba(240, 138, 185, 0.1), transparent 30rem),
        linear-gradient(145deg, #070914 0%, #0b0d1b 46%, #080a15 100%);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    opacity: 1;
    visibility: visible;
    transition: opacity 240ms cubic-bezier(0.22, 1, 0.36, 1), visibility 240ms;
}

.xboot-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('/web/img/doodle-pattern.svg');
    background-position: center;
    background-size: 620px auto;
    opacity: 0.018;
    pointer-events: none;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 8%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, #000 8%, transparent 75%);
}

.xboot-screen::after {
    content: "XSSM";
    position: absolute;
    left: 50%;
    bottom: -0.23em;
    color: rgba(255, 255, 255, 0.018);
    font-size: clamp(12rem, 31vw, 34rem);
    font-weight: 800;
    letter-spacing: -0.095em;
    line-height: 0.8;
    transform: translateX(-51%);
    pointer-events: none;
    white-space: nowrap;
}

.xboot-screen.is-leaving {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.xboot-aurora,
.xboot-orbit-field,
.xboot-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.xboot-aurora span {
    position: absolute;
    width: min(44vw, 650px);
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.19;
    animation: xbootAurora 7s ease-in-out infinite alternate;
}

.xboot-aurora span:first-child {
    top: -26%;
    left: 15%;
    background: #815cf3;
}

.xboot-aurora span:last-child {
    right: 7%;
    bottom: -38%;
    background: #34bddf;
    animation-delay: -3s;
}

.xboot-orbit-field::before,
.xboot-orbit-field::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid rgba(166, 139, 255, 0.07);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotate(-12deg);
}

.xboot-orbit-field::before {
    width: min(76vw, 1050px);
    aspect-ratio: 1.9;
    box-shadow: 0 0 0 84px rgba(104, 216, 244, 0.008), 0 0 0 168px rgba(166, 139, 255, 0.006);
}

.xboot-orbit-field::after {
    width: min(53vw, 730px);
    aspect-ratio: 1.7;
    border-color: rgba(104, 216, 244, 0.075);
    transform: translate(-50%, -50%) rotate(18deg);
}

.xboot-stars i {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.8);
    animation: xbootTwinkle 2.8s ease-in-out infinite;
}

.xboot-stars i:nth-child(1) { top: 17%; left: 21%; }
.xboot-stars i:nth-child(2) { top: 26%; right: 18%; animation-delay: -0.8s; }
.xboot-stars i:nth-child(3) { bottom: 22%; left: 15%; animation-delay: -1.8s; }
.xboot-stars i:nth-child(4) { right: 24%; bottom: 14%; animation-delay: -1.1s; }
.xboot-stars i:nth-child(5) { top: 12%; left: 62%; width: 2px; height: 2px; animation-delay: -2.2s; }

.xboot-stage {
    position: relative;
    z-index: 3;
    display: flex;
    width: 100%;
    max-width: 620px;
    min-width: 0;
    align-items: center;
    flex-direction: column;
    text-align: center;
}

.xboot-emblem {
    position: relative;
    display: grid;
    width: 126px;
    height: 126px;
    margin-bottom: 34px;
    place-items: center;
}

.xboot-emblem-ring {
    position: absolute;
    inset: 1px;
    border: 1px solid rgba(166, 139, 255, 0.16);
    border-radius: 39px;
    transform: rotate(45deg);
    animation: xbootRing 7s linear infinite;
}

.xboot-emblem-ring::before,
.xboot-emblem-ring::after {
    content: "";
    position: absolute;
    border-radius: inherit;
    border: 1px solid rgba(104, 216, 244, 0.1);
}

.xboot-emblem-ring::before { inset: -13px; }
.xboot-emblem-ring::after { inset: 12px; border-color: rgba(240, 138, 185, 0.12); }

.xboot-emblem-glow {
    position: absolute;
    inset: 17px;
    border-radius: 34px;
    background: linear-gradient(135deg, rgba(166, 139, 255, 0.5), rgba(104, 216, 244, 0.24));
    filter: blur(25px);
    opacity: 0.72;
    animation: xbootPulse 2.6s ease-in-out infinite;
}

.xboot-logo {
    position: relative;
    display: grid;
    width: 88px;
    height: 88px;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 28px;
    background: linear-gradient(145deg, rgba(29, 33, 62, 0.96), rgba(12, 15, 30, 0.98));
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

.xboot-logo::after {
    content: "";
    position: absolute;
    inset: -30% 48% -30% -70%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
    transform: skewX(-18deg);
    animation: xbootShine 2.9s ease-in-out infinite;
}

.xboot-logo img {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 8px 18px rgba(134, 105, 244, 0.28));
}

.xboot-kicker {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 14px;
    color: rgba(226, 231, 250, 0.6);
    font-size: 0.67rem;
    font-weight: 750;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.xboot-kicker::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--xboot-violet), var(--xboot-cyan));
    box-shadow: 0 0 15px rgba(104, 216, 244, 0.62);
}

.xboot-title {
    max-width: 100%;
    margin: 0;
    color: var(--xboot-text);
    font-size: clamp(2.35rem, 5.2vw, 4.55rem);
    font-weight: 780;
    letter-spacing: -0.065em;
    line-height: 0.98;
}

.xboot-title-line {
    display: block;
}

.xboot-title .xboot-title-line:first-child {
    color: var(--xboot-text);
}

.xboot-title-accent {
    color: transparent;
    background: linear-gradient(100deg, #b69dff 5%, #f2eefe 48%, #6edbf4 95%);
    background-clip: text;
    -webkit-background-clip: text;
}

.xboot-subtitle {
    max-width: 470px;
    margin: 18px auto 0;
    color: var(--xboot-muted);
    font-size: 0.88rem;
    line-height: 1.65;
}

.xboot-user {
    display: inline-flex;
    min-height: 27px;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    padding: 6px 11px 6px 7px;
    border: 1px solid rgba(166, 139, 255, 0.12);
    border-radius: 999px;
    color: rgba(240, 241, 252, 0.72);
    background: rgba(255, 255, 255, 0.035);
    font-size: 0.65rem;
}

.xboot-user[hidden] { display: none; }

.xboot-user-avatar {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #8d72f2, #58cbe9);
    font-size: 0.56rem;
    font-weight: 800;
}

.xboot-progress-card {
    width: 100%;
    max-width: 470px;
    margin-top: 32px;
    padding: 16px 18px 14px;
    border: 1px solid var(--xboot-line);
    border-radius: 21px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.024));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.075);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.xboot-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    color: rgba(236, 239, 253, 0.75);
    font-size: 0.66rem;
    font-weight: 650;
}

.xboot-progress-head output {
    color: var(--xboot-cyan);
    font-variant-numeric: tabular-nums;
    font-weight: 780;
}

.xboot-progress {
    position: relative;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.24);
}

.xboot-progress > span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 8%;
    min-width: 18px;
    overflow: hidden;
    border-radius: inherit;
    background: linear-gradient(90deg, #8769ec, #b78fff 42%, #61d5ef 100%);
    box-shadow: 0 0 22px rgba(104, 216, 244, 0.28);
    transition: width 580ms cubic-bezier(0.22, 1, 0.36, 1);
}

.xboot-progress > span::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    transform: translateX(-100%);
    animation: xbootProgressShine 1.65s ease-in-out infinite;
}

.xboot-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}

.xboot-steps i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.11);
    box-shadow: 0 0 0 4px transparent;
    transition: background 320ms ease, box-shadow 320ms ease, transform 320ms ease;
}

.xboot-steps i.is-active {
    background: var(--xboot-cyan);
    box-shadow: 0 0 0 4px rgba(104, 216, 244, 0.08), 0 0 14px rgba(104, 216, 244, 0.55);
    transform: scale(1.15);
}

.xboot-retry {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    padding: 0 19px;
    border: 1px solid rgba(240, 138, 185, 0.22);
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, rgba(240, 138, 185, 0.2), rgba(166, 139, 255, 0.18));
    font: inherit;
    font-size: 0.7rem;
    font-weight: 720;
    cursor: pointer;
}

.xboot-retry[hidden] { display: none; }

.xboot-float {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 13px 10px 10px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 17px;
    color: rgba(237, 240, 252, 0.66);
    background: rgba(17, 20, 38, 0.58);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.065);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    font-size: 0.61rem;
    animation: xbootFloat 4.8s ease-in-out infinite;
}

.xboot-float::before {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    color: #fff;
    font-size: 0.69rem;
    font-weight: 800;
}

.xboot-float strong { display: block; color: rgba(249, 250, 255, 0.86); font-size: 0.62rem; }
.xboot-float small { display: block; margin-top: 2px; color: rgba(224, 228, 247, 0.42); font-size: 0.51rem; }
.xboot-float-one { top: 21%; left: max(4%, calc(50% - 560px)); transform: rotate(-4deg); }
.xboot-float-one::before { content: "М"; background: linear-gradient(135deg, #8062e8, #bc8df4); }
.xboot-float-two { top: 28%; right: max(4%, calc(50% - 575px)); transform: rotate(4deg); animation-delay: -1.6s; }
.xboot-float-two::before { content: "✦"; background: linear-gradient(135deg, #36b9dc, #77d9ee); }
.xboot-float-three { right: max(7%, calc(50% - 510px)); bottom: 20%; transform: rotate(-2deg); animation-delay: -3.1s; }
.xboot-float-three::before { content: "▶"; background: linear-gradient(135deg, #e37caa, #9d75ee); font-size: 0.55rem; }

.xboot-screen.is-error .xboot-emblem-ring { border-color: rgba(240, 138, 185, 0.24); animation-play-state: paused; }
.xboot-screen.is-error .xboot-progress > span { background: linear-gradient(90deg, #d76f9e, #f0a1c4); }
.xboot-screen.is-error .xboot-kicker::before { background: var(--xboot-rose); box-shadow: 0 0 15px rgba(240, 138, 185, 0.55); }

html[data-theme="light"] .xboot-screen {
    --xboot-text: #17192a;
    --xboot-muted: rgba(43, 48, 75, 0.58);
    --xboot-line: rgba(67, 58, 105, 0.1);
    background:
        radial-gradient(circle at 14% 18%, rgba(150, 111, 255, 0.16), transparent 32rem),
        radial-gradient(circle at 84% 76%, rgba(77, 205, 236, 0.13), transparent 34rem),
        radial-gradient(circle at 56% 112%, rgba(240, 138, 185, 0.08), transparent 30rem),
        linear-gradient(145deg, #f8f8ff 0%, #f1f3fa 48%, #edf2f7 100%);
}

html[data-theme="light"] .xboot-screen::after { color: rgba(71, 57, 125, 0.028); }
html[data-theme="light"] .xboot-logo { background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(237, 239, 250, 0.98)); box-shadow: 0 25px 60px rgba(84, 73, 120, 0.16), inset 0 1px 0 #fff; }
html[data-theme="light"] .xboot-kicker { color: rgba(55, 59, 88, 0.58); }
html[data-theme="light"] .xboot-user { color: rgba(35, 39, 65, 0.68); background: rgba(255, 255, 255, 0.5); }
html[data-theme="light"] .xboot-progress-card { background: rgba(255, 255, 255, 0.55); box-shadow: 0 24px 70px rgba(70, 76, 112, 0.13), inset 0 1px 0 #fff; }
html[data-theme="light"] .xboot-progress-head { color: rgba(35, 39, 65, 0.7); }
html[data-theme="light"] .xboot-progress { background: rgba(69, 58, 112, 0.07); }
html[data-theme="light"] .xboot-float { color: rgba(39, 44, 70, 0.66); background: rgba(255, 255, 255, 0.58); box-shadow: 0 22px 60px rgba(70, 76, 112, 0.11), inset 0 1px 0 #fff; }
html[data-theme="light"] .xboot-float strong { color: rgba(25, 28, 48, 0.86); }
html[data-theme="light"] .xboot-float small { color: rgba(43, 48, 75, 0.48); }

@keyframes xbootAurora {
    from { transform: translate3d(-3%, -2%, 0) scale(0.96); opacity: 0.14; }
    to { transform: translate3d(4%, 3%, 0) scale(1.07); opacity: 0.23; }
}

@keyframes xbootRing {
    to { transform: rotate(405deg); }
}

@keyframes xbootPulse {
    0%, 100% { transform: scale(0.88); opacity: 0.48; }
    50% { transform: scale(1.12); opacity: 0.82; }
}

@keyframes xbootShine {
    0%, 55% { transform: translateX(-80%) skewX(-18deg); opacity: 0; }
    68% { opacity: 1; }
    86%, 100% { transform: translateX(230%) skewX(-18deg); opacity: 0; }
}

@keyframes xbootProgressShine {
    0%, 25% { transform: translateX(-110%); opacity: 0; }
    45% { opacity: 0.8; }
    75%, 100% { transform: translateX(110%); opacity: 0; }
}

@keyframes xbootFloat {
    0%, 100% { margin-top: 0; }
    50% { margin-top: -10px; }
}

@keyframes xbootTwinkle {
    0%, 100% { opacity: 0.18; transform: scale(0.7); }
    50% { opacity: 0.9; transform: scale(1.2); }
}

@media (max-width: 900px) {
    .xboot-float { opacity: 0.52; transform: scale(0.88); }
    .xboot-float-one { top: 13%; left: 3%; }
    .xboot-float-two { top: 18%; right: 2%; }
    .xboot-float-three { right: 4%; bottom: 12%; }
}

@media (max-width: 640px) {
    .xboot-screen { padding-inline: 22px; }
    .xboot-stage { width: calc(100vw - 64px); max-width: calc(100vw - 64px); }
    .xboot-emblem { width: 106px; height: 106px; margin-bottom: 27px; }
    .xboot-logo { width: 76px; height: 76px; border-radius: 24px; }
    .xboot-logo img { width: 51px; height: 51px; }
    .xboot-emblem-ring { border-radius: 34px; }
    .xboot-kicker { margin-bottom: 12px; font-size: 0.57rem; }
    .xboot-title { width: 100%; font-size: clamp(2.15rem, 10vw, 2.6rem); letter-spacing: -0.052em; }
    .xboot-title .xboot-title-line:first-child { font-size: 0.86em; }
    .xboot-subtitle { max-width: 275px; margin-top: 15px; font-size: 0.74rem; }
    .xboot-progress-card { margin-top: 26px; padding: 14px 15px 13px; border-radius: 19px; }
    .xboot-float { display: none; }
    .xboot-orbit-field::before { width: 150vw; }
    .xboot-orbit-field::after { width: 112vw; }
    .xboot-screen::after { bottom: -0.1em; font-size: 9rem; }
}

@media (max-height: 700px) {
    .xboot-emblem { width: 92px; height: 92px; margin-bottom: 20px; }
    .xboot-logo { width: 68px; height: 68px; border-radius: 21px; }
    .xboot-logo img { width: 46px; height: 46px; }
    .xboot-title { font-size: clamp(2.15rem, 9vh, 3.15rem); }
    .xboot-subtitle { margin-top: 12px; }
    .xboot-progress-card { margin-top: 21px; }
}

@media (prefers-reduced-motion: reduce) {
    .xboot-screen *,
    .xboot-screen *::before,
    .xboot-screen *::after {
        animation: none !important;
        scroll-behavior: auto !important;
    }
    .xboot-progress > span { transition-duration: 120ms; }
}
