/* ============================================================
   RESET
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: #0a0a0a;
    color: #ffffff;
    font-family: 'Share Tech Mono', monospace;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    padding-left: 0.42vw;
    padding-right: 0.42vw;
}

/* ============================================================
   ЖИВОЙ ФОН
   ============================================================ */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.4s ease;
    background-color: #0a0a0a;
}
body.app-ready .bg-layer { opacity: 1; }

.bg-grid-wrap {
    position: absolute;
    top: -50%;
    left: -20%;
    width: 140%;
    height: 200%;
    background-image:
        linear-gradient(to right,  rgba(255, 0, 51, 0.075) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 0, 51, 0.075) 1px, transparent 1px),
        radial-gradient(circle at 0 0,
            rgba(255, 0, 51, 0.55) 0px,
            rgba(255, 0, 51, 0.45) 1.2px,
            transparent 2px);
    background-size: 5vw 5vw;
    background-position: 0 0;
    background-repeat: repeat;
    animation: gridShift 75s linear infinite;
    will-change: transform;
}
@keyframes gridShift {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-25vw, -25vw, 0); }
}

.bg-nodes {
    position: absolute;
    inset: 0;
}

.bg-node {
    position: absolute;
    width: 0;
    height: 0;
}

.bg-node-dot {
    position: absolute;
    left: -2px;
    top: -2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle,
        #ff5577 0%,
        #ff0033 40%,
        rgba(255, 0, 51, 0.4) 70%,
        transparent 100%);
    opacity: 0;
    transform: scale(1);
    animation: nodePulse var(--d, 5s) ease-out infinite;
    animation-delay: var(--delay, 0s);
    will-change: opacity, transform;
}
@keyframes nodePulse {
    0%   { opacity: 0;    transform: scale(0.8); }
    6%   { opacity: 1;    transform: scale(2.4); }
    22%  { opacity: 0.9;  transform: scale(1.9); }
    45%  { opacity: 0.5;  transform: scale(1.1); }
    65%  { opacity: 0.15; transform: scale(0.9); }
    100% { opacity: 0;    transform: scale(0.8); }
}

.bg-node::before,
.bg-node::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    transform-origin: 50% 50%;
    will-change: transform, opacity;
    animation: rayPulse var(--d, 5s) ease-out infinite;
    animation-delay: var(--delay, 0s);
}
.bg-node::before {
    width: 11vw;
    height: 1px;
    margin-left: -5.5vw;
    margin-top: -0.5px;
    background: linear-gradient(to right,
        rgba(255, 0, 51, 0.03) 0%,
        rgba(255, 85, 119, 0.65) 12%,
        rgba(255, 51, 85, 0.85) 24%,
        rgba(255, 0, 51, 0.20) 42%,
        transparent 50%,
        transparent 50%,
        rgba(255, 0, 51, 0.20) 58%,
        rgba(255, 51, 85, 0.85) 76%,
        rgba(255, 85, 119, 0.65) 88%,
        rgba(255, 0, 51, 0.03) 100%);
    transform: scaleX(0);
    animation-name: rayH;
}
.bg-node::after {
    width: 1px;
    height: 11vw;
    margin-left: -0.5px;
    margin-top: -5.5vw;
    background: linear-gradient(to bottom,
        rgba(255, 0, 51, 0.03) 0%,
        rgba(255, 85, 119, 0.65) 12%,
        rgba(255, 51, 85, 0.85) 24%,
        rgba(255, 0, 51, 0.20) 42%,
        transparent 50%,
        transparent 50%,
        rgba(255, 0, 51, 0.20) 58%,
        rgba(255, 51, 85, 0.85) 76%,
        rgba(255, 85, 119, 0.65) 88%,
        rgba(255, 0, 51, 0.03) 100%);
    transform: scaleY(0);
    animation-name: rayV;
}
@keyframes rayH {
    0%   { opacity: 0;    transform: scaleX(0);    }
    10%  { opacity: 1;    transform: scaleX(0.15); }
    35%  { opacity: 0.9;  transform: scaleX(0.55); }
    60%  { opacity: 0.55; transform: scaleX(0.85); }
    85%  { opacity: 0.12; transform: scaleX(1);    }
    100% { opacity: 0;    transform: scaleX(1);    }
}
@keyframes rayV {
    0%   { opacity: 0;    transform: scaleY(0);    }
    10%  { opacity: 1;    transform: scaleY(0.15); }
    35%  { opacity: 0.9;  transform: scaleY(0.55); }
    60%  { opacity: 0.55; transform: scaleY(0.85); }
    85%  { opacity: 0.12; transform: scaleY(1);    }
    100% { opacity: 0;    transform: scaleY(1);    }
}

10%  {                                        opacity: 1; }
    50%  { transform: translate3d(0,   60vh,  0); opacity: 1; }
    88%  {                                        opacity: 0.9; }
    100% { transform: translate3d(0,   140vh, 0); opacity: 0; }
}

.bg-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 28%,
        rgba(0, 0, 0, 0.35) 75%,
        rgba(0, 0, 0, 0.8) 100%
    );
}
.bg-noise {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='7'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/></svg>");
    opacity: 0.05;
}

/* ============================================================
   ПРЕЛОАДЕР
   ============================================================ */
.preloader {
    position: fixed;
    inset: 0;
    background-color: #050505;
    z-index: 9999;
    overflow: hidden;
    font-family: 'Share Tech Mono', monospace;
    color: #ff0033;
}
.preloader.hidden {
    animation: crtOff 0.65s cubic-bezier(0.7, 0, 0.3, 1) forwards;
    pointer-events: none;
}
@keyframes crtOff {
    0%   { transform: scaleY(1);                 filter: brightness(1); }
    40%  { transform: scaleY(0.005);             filter: brightness(3); }
    60%  { transform: scaleY(0.005) scaleX(0.7); filter: brightness(6); }
    100% { transform: scaleY(0) scaleX(0);       filter: brightness(6); opacity: 0; }
}

.preloader::before {
    content: '';
    position: absolute;
    left: -5%; right: -5%;
    top: 30%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,0,51,0.85) 30%, #ff5577 50%, rgba(255,0,51,0.85) 70%, transparent);
    box-shadow: 0 0 14px #ff0033, 0 0 28px rgba(255,0,51,0.6);
    opacity: 0;
    pointer-events: none;
    z-index: 46;
    animation: glitchLine 2.6s steps(1) infinite;
}
@keyframes glitchLine {
    0%, 63%, 100% { opacity: 0; top: 30%; }
    64% { opacity: 0.9; top: 22%; }
    66% { opacity: 0.55; top: 74%; }
    68% { opacity: 0.85; top: 52%; }
    70% { opacity: 0; top: 30%; }
    92% { opacity: 0.7; top: 60%; }
    94% { opacity: 0; top: 30%; }
}

.pl-corrupt { position: absolute; inset: 0; pointer-events: none; z-index: 45; }
.pl-corrupt span {
    position: absolute;
    display: block;
    opacity: 0;
    animation: corruptFlash 2.4s steps(1) infinite;
    animation-delay: var(--cd, 0s);
}
@keyframes corruptFlash {
    0%, 88%, 100% { opacity: 0; }
    89% { opacity: 0.85; transform: translateX(var(--cx, 4px)); }
    91% { opacity: 0.15; }
    92% { opacity: 0.7; transform: translateX(var(--cx, 4px)) scaleX(var(--cs, 1)); }
    93% { opacity: 0; transform: translateX(0); }
}

.pl-scanlines {
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 0, 51, 0.035) 0,
        rgba(255, 0, 51, 0.035) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 50;
}
.pl-vignette {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.85) 100%);
    pointer-events: none;
    z-index: 40;
}

.pl-corner {
    position: absolute;
    width: 2.5vw; height: 2.5vw;
    border: 0.1vw solid #ff0033;
    z-index: 60;
    opacity: 0;
    animation: cornerIn 0.4s ease forwards;
}
.pl-tl { top: 2vh;    left: 2vw;  border-right: none;  border-bottom: none; }
.pl-tr { top: 2vh;    right: 2vw; border-left: none;   border-bottom: none; animation-delay: 0.1s; }
.pl-bl { bottom: 2vh; left: 2vw;  border-right: none;  border-top: none;    animation-delay: 0.2s; }
.pl-br { bottom: 2vh; right: 2vw; border-left: none;   border-top: none;    animation-delay: 0.3s; }
@keyframes cornerIn {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

.pl-top {
    position: absolute;
    top: 7vh; left: 0; right: 0;
    padding: 0 5vw;
    display: flex;
    justify-content: space-between;
    font-size: 0.63vw;
    letter-spacing: 0.15vw;
    color: #ff0033;
    z-index: 55;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards 0.5s;
}
.pl-tag { opacity: 0.75; }
.pl-live { color: #ff0033; animation: liveBlink 1s steps(2) infinite; }
@keyframes liveBlink { 50% { opacity: 0.2; } }
@keyframes fadeIn { to { opacity: 1; } }

.pl-bottom {
    position: absolute;
    bottom: 7vh; left: 0; right: 0;
    padding: 0 5vw;
    z-index: 55;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards 0.7s;
}
.pl-progress {
    height: 0.25vh;
    background: rgba(255,0,51,0.12);
    overflow: hidden;
    position: relative;
}
.pl-progress-fill {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #ff0033 0%, #ff5577 50%, #ff0033 100%);
    transform: scaleX(0);
    transform-origin: left;
    box-shadow: 0 0 1vw #ff0033, 0 0 2vw rgba(255,0,51,0.5);
    animation: progressFill 4.2s cubic-bezier(0.6, 0, 0.4, 1) forwards;
}
@keyframes progressFill {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}
.pl-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.9vh;
    font-size: 0.63vw;
    letter-spacing: 0.15vw;
    color: #ff0033;
    opacity: 0.8;
}
.pl-footer-left  { opacity: 0.75; }
.pl-footer-right { opacity: 0.75; }

.pl-core {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3vw;
    padding: 0 5vw;
    z-index: 20;
    animation: coreFadeOut 0.5s ease-in 3.9s forwards;
}
@keyframes coreFadeOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.94); }
}

.pl-builder {
    position: relative;
    width: 14vw;
    height: 14vw;
    flex-shrink: 0;
    animation: builderGlitch 3.4s steps(1) infinite;
}
@keyframes builderGlitch {
    0%, 82%, 100% { transform: translate(0, 0) skewX(0); opacity: 1; }
    83% { transform: translate(-0.45vw, 0.1vh) skewX(-4deg); opacity: 0.55; }
    84% { transform: translate(0.35vw, -0.15vh) skewX(3deg); opacity: 0.85; }
    85% { transform: translate(-0.2vw, 0) skewX(-2deg); opacity: 1; }
    86% { transform: translate(0, 0) skewX(0); opacity: 1; }
    95% { transform: translate(0.25vw, -0.1vh) skewX(2deg); opacity: 0.7; }
    96% { transform: translate(0, 0) skewX(0); opacity: 1; }
}

.pl-builder-inner {
    position: absolute;
    inset: 0;
    color: #ff0033;
    transform-origin: 50% 50%;
    will-change: transform;
}
.pl-builder-inner.matrix-final {
    animation: matrixGrow 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes matrixGrow {
    0%   { transform: scale(1);    }
    55%  { transform: scale(1.38); }
    100% { transform: scale(1.22); }
}

.pl-builder-burst {
    position: absolute;
    inset: -0.6vw;
    border: 2px solid rgba(255, 0, 51, 0.75);
    box-shadow:
        0 0 1.5vw rgba(255, 0, 51, 0.55),
        inset 0 0 1.5vw rgba(255, 0, 51, 0.25);
    opacity: 0;
    pointer-events: none;
    z-index: 25;
    animation: burstRing 3.4s ease-out infinite;
}
@keyframes burstRing {
    0%, 84%, 100% { opacity: 0; transform: scale(0.95); }
    85% { opacity: 0.9; transform: scale(1); }
    93% { opacity: 0; transform: scale(1.12); }
}

.pl-tear {
    position: absolute;
    left: -15%; right: -15%;
    height: 3px;
    pointer-events: none;
    opacity: 0;
    z-index: 32;
}
.pl-tear-1 {
    top: 22%;
    background: linear-gradient(90deg, transparent, rgba(0,240,255,0.9), transparent);
    animation: tearFlash 2.1s steps(1) infinite 0.3s;
}
.pl-tear-2 {
    top: 52%;
    background: linear-gradient(90deg, transparent, rgba(255,0,51,0.95), transparent);
    animation: tearFlash 2.7s steps(1) infinite 1.1s;
}
.pl-tear-3 {
    top: 78%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
    animation: tearFlash 3.3s steps(1) infinite 0.7s;
}
@keyframes tearFlash {
    0%, 90%, 100% { opacity: 0; transform: translateX(0); }
    91% { opacity: 1;   transform: translateX(-0.5vw); }
    92% { opacity: 0.4; transform: translateX(0.35vw); }
    93% { opacity: 0.9; transform: translateX(-0.25vw); }
    94% { opacity: 0;   transform: translateX(0); }
}

.cube {
    position: absolute;
    left: 50%; top: 50%;
    width: 2.6vw; height: 2.6vw;
    margin-left: -1.3vw;
    margin-top: -1.3vw;
    transform: translate(var(--dx, 0), var(--dy, 0));
    color: #ff0033;
    transition: color 0.5s ease;
}
.cube-inner {
    width: 100%; height: 100%;
    animation: cubeFly 0.8s cubic-bezier(0.22, 1.05, 0.36, 1) var(--delay, 0s) backwards;
}
@keyframes cubeFly {
    0% {
        opacity: 0;
        transform: translate(var(--fdx, 0), var(--fdy, 0)) rotate(var(--rot, 0deg)) scale(0.4);
    }
    45% { opacity: 0.9; }
    100% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
}
.cube svg { width: 100%; height: 100%; display: block; overflow: visible; }

.face-top,
.face-left,
.face-right {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-opacity: 0.85;
    transition: fill-opacity 0.5s ease;
}
.face-top   { fill: currentColor; fill-opacity: 0.32; }
.face-left  { fill: currentColor; fill-opacity: 0.10; }
.face-right { fill: currentColor; fill-opacity: 0.20; }

.pl-builder-inner.matrix-final .cube[data-final="white"] { color: #d0d0d0; }
.pl-builder-inner.matrix-final .cube[data-final="white"] .face-top   { fill-opacity: 0.58; }
.pl-builder-inner.matrix-final .cube[data-final="white"] .face-left  { fill-opacity: 0.24; }
.pl-builder-inner.matrix-final .cube[data-final="white"] .face-right { fill-opacity: 0.42; }

.pl-builder-inner.matrix-final .cube[data-final="red"] { color: #ff0033; }
.pl-builder-inner.matrix-final .cube[data-final="red"] .face-top   { fill-opacity: 0.82; }
.pl-builder-inner.matrix-final .cube[data-final="red"] .face-left  { fill-opacity: 0.42; }
.pl-builder-inner.matrix-final .cube[data-final="red"] .face-right { fill-opacity: 0.60; }

.pl-builder-inner.matrix-final .cube[data-final="blue"] { color: #6c5cff; }
.pl-builder-inner.matrix-final .cube[data-final="blue"] .face-top   { fill-opacity: 0.74; }
.pl-builder-inner.matrix-final .cube[data-final="blue"] .face-left  { fill-opacity: 0.34; }
.pl-builder-inner.matrix-final .cube[data-final="blue"] .face-right { fill-opacity: 0.52; }

.pl-log {
    min-width: 26vw;
    max-width: 32vw;
    display: flex;
    flex-direction: column;
    gap: 0.8vh;
    font-size: 0.73vw;
    letter-spacing: 0.08vw;
    color: #cccccc;
}
.log-line {
    opacity: 0;
    white-space: nowrap;
    overflow: hidden;
    animation: typeReveal 0.5s steps(28) forwards;
    animation-delay: var(--d, 0s);
    text-shadow: 0 0 0.3vw rgba(255,0,51,0.4);
}
@keyframes typeReveal {
    from { opacity: 1; clip-path: inset(0 100% 0 0); }
    to   { opacity: 1; clip-path: inset(0 0 0 0); }
}
.log-ok   { color: #ffffff; }
.log-warn { color: #ff0033; }
.log-err  { color: #6c5cff; animation: errBlink 0.6s steps(2) infinite; }
@keyframes errBlink { 50% { opacity: 0.3; } }

.pl-alert {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 2.4vw;
    font-weight: 900;
    color: #ff0033;
    padding: 2.4vh 3.4vw;
    border: 2px solid #ff0033;
    background: rgba(0, 0, 0, 0.94);
    box-shadow:
        0 0 2.5vw rgba(255, 0, 51, 0.45),
        0 0 0 4px rgba(0, 0, 0, 0.95),
        0 0 0 5px rgba(255, 0, 51, 0.65),
        inset 0 0 1.5vw rgba(255, 0, 51, 0.12);
    opacity: 0;
    pointer-events: none;
    z-index: 35;
    white-space: nowrap;
    animation: alertLife 1.1s ease-out 4.4s forwards;
    will-change: clip-path, opacity, transform;
}
.pl-alert::before,
.pl-alert::after {
    content: '';
    position: absolute;
    left: -1vw; right: -1vw;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ff0033 15%, #ff0033 85%, transparent);
    box-shadow: 0 0 0.5vw rgba(255,0,51,0.7);
    pointer-events: none;
}
.pl-alert::before { top: -0.9vh; }
.pl-alert::after  { bottom: -0.9vh; }

.pl-alert-text {
    display: inline-block;
    position: relative;
    letter-spacing: 0.55vw;
    margin-right: -0.55vw;
    text-shadow:
        0 0 0.4vw rgba(255, 0, 51, 0.7),
        0 0 0.9vw rgba(255, 0, 51, 0.35);
}
.pl-alert-text::before,
.pl-alert-text::after {
    content: attr(data-text);
    position: absolute;
    left: 0; top: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: 0;
    letter-spacing: inherit;
}
.pl-alert-text::before {
    color: #00f0ff;
    animation: alertGhostBlue 1.1s steps(2) 4.4s;
}
.pl-alert-text::after {
    color: #ff2a6d;
    animation: alertGhostPink 1.1s steps(2) 4.4s;
}
@keyframes alertLife {
    0%  { opacity: 0; transform: translate(-50%, -50%) scale(0.85); clip-path: inset(50% 0 50% 0); }
    6%  { opacity: 1; transform: translate(-50%, -50%) scale(1);    clip-path: inset(50% 0 50% 0); }
    20% { clip-path: inset(0 0 0 0); }
    24% { clip-path: inset(48% 0 48% 0); }
    28% { clip-path: inset(0 0 0 0); }
    33% { clip-path: inset(22% 0 22% 0); }
    37% { clip-path: inset(0 0 0 0); }
    82% { opacity: 1; clip-path: inset(0 0 0 0); transform: translate(-50%, -50%) scale(1); }
    94% { opacity: 0.6; clip-path: inset(45% 0 45% 0); transform: translate(-50%, -50%) scale(1.05); }
    100% { opacity: 0; clip-path: inset(50% 0 50% 0); transform: translate(-50%, -50%) scale(1.08); }
}
@keyframes alertGhostBlue {
    0%, 100% { opacity: 0; }
    22% { opacity: 0.85; transform: translate(-0.18vw, 0.06vh); clip-path: inset(0 0 55% 0); }
    24% { opacity: 0.3;  transform: translate(0.12vw, -0.04vh); clip-path: inset(45% 0 0 0); }
    26% { opacity: 0; }
    46% { opacity: 0.7;  transform: translate(-0.14vw, 0.08vh); clip-path: inset(20% 0 30% 0); }
    48% { opacity: 0; }
    76% { opacity: 0.55; transform: translate(0.16vw, -0.06vh); clip-path: inset(60% 0 5% 0); }
    78% { opacity: 0; }
}
@keyframes alertGhostPink {
    0%, 100% { opacity: 0; }
    22% { opacity: 0.75; transform: translate(0.16vw, -0.06vh); clip-path: inset(50% 0 0 0); }
    24% { opacity: 0.35; transform: translate(-0.14vw, 0.06vh); clip-path: inset(0 0 40% 0); }
    26% { opacity: 0; }
    48% { opacity: 0.6;  transform: translate(0.12vw, 0.08vh); clip-path: inset(25% 0 40% 0); }
    50% { opacity: 0; }
    78% { opacity: 0.5;  transform: translate(-0.18vw, -0.04vh); clip-path: inset(5% 0 65% 0); }
    80% { opacity: 0; }
}

.pl-hex {
    position: absolute;
    top: 8vh; right: 3vw;
    width: 6vw;
    font-size: 0.58vw;
    line-height: 1.6;
    color: #ff0033;
    opacity: 0.35;
    z-index: 15;
    text-align: right;
    pointer-events: none;
}
.pl-hex span {
    display: block;
    animation: hexFlicker 2s steps(3) infinite;
    animation-delay: var(--hd, 0s);
}
@keyframes hexFlicker {
    0%, 100% { opacity: 0.15; }
    50%      { opacity: 0.6; }
}

/* ============================================================
   ОСНОВНОЙ ИНТЕРФЕЙС
   ============================================================ */
.main-content {
    display: flex;
    align-items: center;
    gap: 3.13vw;
    padding: 3.7vh 2.08vw;
    opacity: 0;
    position: relative;
    z-index: 1;
}
body.app-ready .main-content {
    animation: fadeInUp 0.8s ease forwards 0.1s;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.left-panel { display: flex; justify-content: center; align-items: center; }

.main-logo {
    width: 12.5vw;
    height: 12.5vw;
    object-fit: contain;
    animation: logoGlow 3s ease-in-out infinite;
}
@keyframes logoGlow {
    0%, 100% { filter: drop-shadow(0 0 0.5vw rgba(255, 0, 51, 0.3)); }
    50%      { filter: drop-shadow(0 0 1.5vw rgba(255, 0, 51, 0.6)); }
}

.right-panel {
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 22vh;
    justify-content: center;
}

.stage {
    display: none;
    flex-direction: column;
    gap: 1.39vh;
    opacity: 0;
    transition: opacity 0.35s ease-in-out;
}
.stage.active { display: flex; opacity: 1; }

.label {
    color: #ff0033;
    font-size: 0.83vw;
    letter-spacing: 0.1vw;
    font-weight: bold;
    position: relative;
}

.glitch-text { position: relative; display: inline-block; }
.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute; left: 0; top: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.glitch-text:hover::before,
.glitch-text:hover::after { opacity: 1; }
.glitch-text::before {
    color: #00f0ff;
    animation: glitchShift 0.3s steps(2) infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}
.glitch-text::after {
    color: #ff2a6d;
    animation: glitchShift 0.3s steps(2) infinite reverse;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}
@keyframes glitchShift {
    0%   { transform: translate(0); }
    25%  { transform: translate(-2px, 1px); }
    50%  { transform: translate(2px, -1px); }
    75%  { transform: translate(-1px, -1px); }
    100% { transform: translate(0); }
}

.input-box {
    border: 0.1vw solid #ff0033;
    padding: 1.67vh 1.25vw;
    width: 23.44vw;
    background: transparent;
    display: flex;
    align-items: center;
    transition: box-shadow 0.3s ease;
}
.input-box:focus-within { box-shadow: 0 0 1.5vw rgba(255, 0, 51, 0.5); }

.input-box input {
    background: transparent;
    border: none;
    color: #ff0033;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.04vw;
    width: 100%;
    outline: none;
    caret-color: #ff0033;
    letter-spacing: 0.1vw;
}

.barcode { display: flex; align-items: center; margin-top: 0.93vh; gap: 0.78vw; }
.barcode-slashes { color: #ffffff; font-size: 0.94vw; letter-spacing: 0.1vw; font-weight: bold; }
.barcode-line { flex-grow: 1; height: 0.05vw; background-color: #ffffff; }

.status { display: flex; flex-direction: column; gap: 0.46vh; margin-top: 0.46vh; }
.status-item { font-size: 0.83vw; letter-spacing: 0.05vw; }
.status-label { color: #666666; }
.status-value { color: #ff0033; font-weight: bold; }

.welcome-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6vw;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.2vw;
    margin-top: 1vh;
}
.welcome-text span { color: #ff0033; }
.welcome-sub {
    font-size: 0.73vw;
    color: #666666;
    letter-spacing: 0.15vw;
    margin-top: 0.5vh;
}

.version-text {
    position: fixed;
    left: 1.04vw; bottom: 1.85vh;
    transform: rotate(-90deg);
    transform-origin: left bottom;
    color: #666666;
    font-size: 0.63vw;
    letter-spacing: 0.05vw;
    white-space: nowrap;
    z-index: 5;
    opacity: 0;
}
body.app-ready .version-text { animation: fadeIn 1s ease forwards 0.6s; }

.footer {
    position: fixed;
    right: 4.69vw; bottom: 3.7vh;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.93vh;
    z-index: 5;
    opacity: 0;
}
body.app-ready .footer { animation: fadeInUp 0.8s ease forwards 0.4s; }
.footer-logo-wide { width: 10.42vw; height: auto; object-fit: contain; }
.footer-bottom { display: flex; align-items: center; gap: 0.78vw; }
.footer-japanese {
    font-family: 'Yu Gothic', 'Hiragino Sans', 'Meiryo', sans-serif;
    font-size: 0.73vw;
    color: #666666;
    letter-spacing: 0.1vw;
}
.footer-line { width: 3.13vw; height: 0.05vw; background-color: #ffffff; }

/* ============================================================
   ЛЕВОЕ МЕНЮ РЕСУРСОВ
   ============================================================ */
.resource-panel {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 0.42vw;
    background-color: #ff0033;
    display: flex;
    flex-direction: column;
    z-index: 30;
    overflow: hidden;
    transition: width 0.5s cubic-bezier(0.65, 0, 0.35, 1),
                box-shadow 0.5s ease;
}
.resource-panel.active {
    width: 3.2vw;
    box-shadow: 0.3vw 0 1.2vw rgba(255, 0, 51, 0.45);
}

.resource-tab {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.2vh;
    padding: 2vh 0;
    border: none;
    background: transparent;
    color: #000000;
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-0.6vw);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.resource-panel.active .resource-tab {
    opacity: 0.85;
    transform: translateX(0);
    cursor: pointer;
}
.resource-panel.active .resource-tab:nth-child(1) { transition-delay: 0.10s; }
.resource-panel.active .resource-tab:nth-child(2) { transition-delay: 0.18s; }
.resource-panel.active .resource-tab:nth-child(3) { transition-delay: 0.26s; }
.resource-panel.active .resource-tab:nth-child(4) { transition-delay: 0.34s; }

.resource-tab + .resource-tab::before {
    content: '';
    position: absolute;
    top: 0; left: 18%; right: 18%;
    height: 1px;
    background: rgba(0, 0, 0, 0.55);
}

.resource-tab::after {
    content: '';
    position: absolute;
    top: 20%; bottom: 20%;
    left: 0;
    width: 3px;
    background: #000000;
    transform: scaleY(0);
    transform-origin: 50% 50%;
    transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.resource-panel.active .resource-tab.selected::after {
    transform: scaleY(1);
}

.resource-tab .tab-icon {
    display: block;
    width: 1.8vw;
    height: 1.8vw;
    flex-shrink: 0;
    color: #000000;
    transition: transform 0.3s ease;
}

.resource-tab .tab-label-wrap {
    flex: 1 1 auto;
    position: relative;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

.resource-tab .tab-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.66vw;
    letter-spacing: 0.35vw;
    line-height: 1;
    color: #000000;
    text-transform: uppercase;
    white-space: nowrap;
    transition: letter-spacing 0.3s ease;
    pointer-events: none;
}

.resource-panel.active .resource-tab:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.12);
}
.resource-panel.active .resource-tab:hover .tab-icon {
    transform: scale(1.08);
}
.resource-panel.active .resource-tab.selected {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.22);
}
.resource-panel.active .resource-tab.selected .tab-icon {
    transform: scale(1.12);
}
.resource-panel.active .resource-tab.selected .tab-label {
    letter-spacing: 0.45vw;
}

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 900px) {
    body { padding-left: 2vw; padding-right: 0.42vw; }

    .pl-core { flex-direction: column; gap: 3vh; padding: 0 6vw; }
    .pl-builder { width: 44vw; height: 44vw; }
    .cube { width: 8vw; height: 8vw; margin-left: -4vw; margin-top: -4vw; }
    .pl-log { font-size: 2vw; min-width: 0; max-width: 80vw; }
    .log-line { white-space: normal; }
    .pl-alert { font-size: 3.5vw; padding: 1vh 3vw 1vh 3.4vw; letter-spacing: 0.5vw; }
    .pl-alert-text { letter-spacing: 0.5vw; margin-right: -0.5vw; }
    .pl-top, .pl-footer { font-size: 2vw; }
    .pl-hex { display: none; }
    .pl-corner { width: 6vw; height: 6vw; border-width: 0.3vw; }

    .main-content { flex-direction: column; gap: 5vw; padding: 5vh 4vw; }
    .main-logo { width: 30vw; height: 30vw; }
    .input-box { width: 70vw; }
    .label, .status-item { font-size: 2.4vw; }
    .input-box input { font-size: 3vw; }
    .barcode-slashes { font-size: 2.6vw; }
    .welcome-text { font-size: 4.5vw; }
    .welcome-sub { font-size: 2.2vw; }
    .version-text { display: none; }
    .footer { right: 12vw; bottom: 3vh; }
    .footer-logo-wide { width: 25vw; }
    .footer-japanese { font-size: 2vw; }

    .resource-panel.active { width: 9vw; }
    .resource-tab .tab-icon  { width: 5vw; height: 5vw; }
    .resource-tab .tab-label { font-size: 2.4vw; letter-spacing: 1vw; }
    .resource-panel.active .resource-tab.selected .tab-label { letter-spacing: 1.2vw; }
}

@media (prefers-reduced-motion: reduce) {
    .bg-grid-wrap,
    .bg-node-dot,
    .bg-node::before,
    .bg-node::after { animation: none; }
}

/* ============================================================
   BG-LAYER — без красного пятна (bg-pulse удалён)
   Оставляем только сетку, виньетку, шум.
   ============================================================ */

/* ============================================================
   SESSION-INFO — плашка оператора в правом верхнем углу
   ============================================================ */
.session-info {
    position: fixed !important;
    top: 1.2vh !important;
    right: 1.2vw !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 200 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 0.7vw;
    padding: 0.7vh 0.9vw;
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid rgba(255, 0, 51, 0.35);
    border-radius: 0.5vw;
    box-shadow: 0 0.2vh 1vw rgba(255, 0, 51, 0.15),
                inset 0 0 0.8vw rgba(255, 0, 51, 0.05);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7vw;
    letter-spacing: 0.15vw;
    transition: opacity 0.25s ease;
    pointer-events: auto;
}
.session-info.hidden {
    display: none !important;
}
.session-label {
    color: #6a6a6a;
    font-size: 0.65vw;
    letter-spacing: 0.2vw;
}
.session-user {
    color: #ff0033;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.78vw;
    letter-spacing: 0.15vw;
    text-shadow: 0 0 0.6vw rgba(255, 0, 51, 0.55);
    text-transform: uppercase;
}
.session-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.4vw;
    padding: 0.45vh 0.7vw;
    margin-left: 0.3vw;
    background: transparent;
    border: 1px solid rgba(255, 0, 51, 0.4);
    border-radius: 0.4vw;
    color: #ff8099;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.62vw;
    letter-spacing: 0.15vw;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.session-logout:hover {
    background: rgba(255, 0, 51, 0.2);
    color: #fff;
    border-color: #ff0033;
}
.session-logout svg { flex-shrink: 0; }

/* Прячем, пока открыт iframe */
body.view-mode .session-info {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 900px) {
    .session-info {
        font-size: 2.2vw;
        padding: 0.9vh 2vw;
    }
    .session-label { font-size: 2vw; }
    .session-user { font-size: 2.4vw; }
    .session-logout { font-size: 2vw; padding: 0.6vh 2vw; }
}

/* ============================================================
   APP-VIEWPORT — CRT-эффект переключения вкладок
   ============================================================ */
.app-viewport {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 2.4vw;
    z-index: 100;
    background: #050505;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    overflow: hidden;
}
.app-viewport.open {
    opacity: 1;
    pointer-events: auto;
}

body.view-mode .main-content,
body.view-mode .footer,
body.view-mode .version-text,
body.view-mode .bg-layer {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

/* Обёртка iframe: по умолчанию сжата в горизонтальную линию.
   Разжимается при .frame-full — тогда виден весь iframe. */
.app-frame-wrap {
    position: absolute;
    inset: 0;
    /* Тонкая горизонтальная линия по центру — как схлопнутая ЭЛТ-развёртка */
    clip-path: inset(calc(50% - 1.5px) 0 calc(50% - 1.5px) 0);
    transition: clip-path 0.32s cubic-bezier(0.5, 0, 0.4, 1);
    will-change: clip-path;
    background: #050505;
}
.app-viewport.frame-full .app-frame-wrap {
    clip-path: inset(0 0 0 0);
}

.app-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #050505;
}

/* Яркая линия по центру — вспышка при переключении */
.app-glitch-line {
    position: absolute;
    top: 50%;
    left: -5%;
    right: -5%;
    height: 3px;
    margin-top: -1.5px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 0, 51, 0.95) 15%,
        #ffffff 50%,
        rgba(255, 0, 51, 0.95) 85%,
        transparent 100%);
    box-shadow: 0 0 1.5vw rgba(255, 0, 51, 0.9),
                0 0 3vw rgba(255, 0, 51, 0.5),
                0 0 6vw rgba(255, 0, 51, 0.25);
    opacity: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.09s ease;
}
.app-viewport.flashing .app-glitch-line {
    opacity: 1;
}

/* Тонкая красная линия-подсветка по центру — даже когда нет вспышки */
.app-viewport::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    margin-top: -0.5px;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 0, 51, 0.4) 20%,
        rgba(255, 0, 51, 0.6) 50%,
        rgba(255, 0, 51, 0.4) 80%,
        transparent);
    opacity: 0;
    pointer-events: none;
    z-index: 3;
    transition: opacity 0.3s ease;
}
.app-viewport.open:not(.frame-full)::before {
    opacity: 1;
}

/* Заглушка */
.app-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #0a0a0a 0%, #050505 80%);
    z-index: 4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.app-viewport.placeholder-mode .app-placeholder {
    opacity: 1;
    pointer-events: auto;
}
.app-placeholder-box {
    text-align: center;
    padding: 4vh 6vw;
    border: 1px dashed rgba(255, 0, 51, 0.35);
    border-radius: 0.8vw;
    background: rgba(255, 0, 51, 0.03);
}
.app-placeholder-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6vw;
    font-weight: 700;
    color: #ff0033;
    letter-spacing: 0.3vw;
    text-shadow: 0 0 1vw rgba(255, 0, 51, 0.5);
}
.app-placeholder-sub {
    margin-top: 1.2vh;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85vw;
    color: #6a6a6a;
    letter-spacing: 0.2vw;
    text-transform: uppercase;
}

@media (max-width: 900px) {
    .app-viewport { left: 10vw; }
}

/* ============================================================
   TABS-PANEL — панель вкладок: тёмно-красная, минимализм
   Кнопки на всю ширину панели, вертикальный текст, без зума.
   ============================================================ */

.resource-panel {
    background-color: #2e060d !important;
    justify-content: center !important;
    align-items: stretch;
    gap: 1.2vh;
    padding: 2vh 0;
    overflow: visible;
}
.resource-panel.active {
    width: 2.4vw !important;
    box-shadow: 0.3vw 0 1.2vw rgba(255, 0, 51, 0.3);
}

.resource-panel .resource-tab {
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 1.2vh 0;
    gap: 0.8vh;

    background-color: #3e0a14;
    border: none;
    border-top: 1px solid rgba(255, 0, 51, 0.18);
    border-bottom: 1px solid rgba(255, 0, 51, 0.18);
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    transition: background-color 0.2s ease, opacity 0.3s ease;
}
.resource-panel .resource-tab + .resource-tab::before { display: none; }
.resource-panel .resource-tab::after { display: none; }

.resource-panel .resource-tab .tab-icon {
    width: 1.35vw !important;
    height: 1.35vw !important;
    min-width: 20px;
    min-height: 20px;
    color: #ff5577 !important;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.resource-panel .resource-tab .tab-label-wrap {
    flex: 1 1 auto;
    position: relative;
    width: 100%;
    min-height: 12vh;
    overflow: hidden;
}
.resource-panel .resource-tab .tab-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;

    font-family: 'Orbitron', 'Share Tech Mono', sans-serif !important;
    font-weight: 900 !important;
    font-size: 0.72vw !important;
    letter-spacing: 0.15vw !important;
    line-height: 1;
    color: #ff5577 !important;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    transition: color 0.2s ease, letter-spacing 0.2s ease;
}

.resource-panel.active .resource-tab:hover {
    opacity: 1;
    background-color: #5a0e1e;
}
.resource-panel.active .resource-tab:hover .tab-icon { color: #ffffff !important; }
.resource-panel.active .resource-tab:hover .tab-label { color: #ffffff !important; }

.resource-panel.active .resource-tab.selected {
    opacity: 1;
    background-color: #ff0033;
    box-shadow: inset 0 0 1vw rgba(255, 255, 255, 0.08),
                0 0 0.8vw rgba(255, 0, 51, 0.5);
}
.resource-panel.active .resource-tab.selected .tab-icon { color: #ffffff !important; }
.resource-panel.active .resource-tab.selected .tab-label {
    color: #ffffff !important;
    text-shadow: 0 0 0.3vw rgba(255, 255, 255, 0.3);
}

.resource-panel .resource-tab { opacity: 0; }
.resource-panel.active .resource-tab { opacity: 1; cursor: pointer; }

@media (max-width: 900px) {
    .resource-panel.active { width: 10vw !important; }
    .resource-panel .resource-tab .tab-icon {
        width: 4.5vw !important;
        height: 4.5vw !important;
    }
    .resource-panel .resource-tab .tab-label {
        font-size: 2.2vw !important;
        letter-spacing: 0.3vw !important;
    }
    .resource-panel .resource-tab .tab-label-wrap { min-height: 14vh; }
}
