/* ===== Navar: плашка онлайна (слева) + чат поддержки (справа) ===== */

:root {
    --nv-page: #0a0f14;
    --nv-surface: #101c28;
    --nv-surface-2: #182a3d;
    --nv-border: #2a3f57;
    --nv-gold: #f5c63a;
    --nv-gold-light: #ffdc69;
    --nv-gold-dark: #c79a1e;
    --nv-crimson: #c9242f;
    --nv-red-top: #a71718;
    --nv-red-bottom: #70131c;
    --nv-text: #f4f2ec;
    --nv-body: #e6e3dc;
    --nv-muted: #8795a5;
    --nv-live: #3ecf6e;

    --nv-gap: 20px;
    --nv-bar: 0px;
    --nv-side: 0px;           /* ширина левого меню на десктопе, JS подставляет реальную */            /* высота нижней панели «Вход / Регистрация», JS подставляет реальную */
    --nv-bottom: calc(var(--nv-gap) + var(--nv-bar) + env(safe-area-inset-bottom, 0px));
}

.nv-online,
.nv-chat {
    font-family: Geologica, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

.nv-online *,
.nv-chat * { box-sizing: border-box; }

.nv-online button,
.nv-chat button {
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

/* ===================== Плашка онлайна ===================== */

.nv-online {
    position: fixed;
    left: calc(var(--nv-gap) + var(--nv-side) + env(safe-area-inset-left, 0px));
    transition-property: opacity, transform, visibility, left;
    bottom: var(--nv-bottom);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 214px;
    padding: 10px 34px 10px 10px;
    border-radius: 16px;
    color: var(--nv-text);
    background:
        radial-gradient(120% 140% at 0% 0%, rgba(245, 198, 58, .10), rgba(245, 198, 58, 0) 55%),
        var(--nv-surface);
    border: 1px solid var(--nv-border);
    box-shadow:
        inset 0 0 0 3px var(--nv-surface),
        inset 0 0 0 4px rgba(245, 198, 58, .22),
        0 12px 30px rgba(0, 0, 0, .5);
    animation: nv-slide-left .6s cubic-bezier(.2, .9, .3, 1.15) both;
    transition: opacity .25s ease, transform .25s ease, visibility .25s;
}

.nv-online[hidden] { display: none; }

.nv-online.is-closing { animation: nv-out-left .3s ease-in forwards; }

/* на телефоне прячем плашку, пока открыт чат */
.nv-online.is-covered {
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    pointer-events: none;
}

/* шерифская звезда */
.nv-online__badge {
    position: relative;
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--nv-surface-2), #0e1823);
    border: 1px solid var(--nv-border);
}

.nv-online__star {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .55));
    animation: nv-star 6s ease-in-out infinite;
}

.nv-online__live {
    position: absolute;
    right: -3px;
    top: -3px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--nv-live);
    border: 2px solid var(--nv-surface);
    animation: nv-pulse 1.8s ease-out infinite;
}

.nv-online__rows {
    display: grid;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.nv-online__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    white-space: nowrap;
}

.nv-online__name {
    font-size: 13px;
    color: var(--nv-muted);
}

.nv-online__value {
    font-family: Podkova, Georgia, serif;
    font-weight: 700;
    font-size: 19px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--nv-gold);
    transition: color .4s ease;
}

.nv-online__row--playing .nv-online__value {
    font-size: 16px;
    color: var(--nv-body);
}

.nv-online__value.is-up   { color: var(--nv-live); }
.nv-online__value.is-down { color: #ff5c4d; }

.nv-online__close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--nv-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: color .2s, background-color .2s;
}

.nv-online__close svg { width: 10px; height: 10px; }

.nv-online__close:hover { color: var(--nv-text); background: var(--nv-surface-2); }

.nv-online__close:focus-visible {
    outline: 2px solid var(--nv-gold);
    outline-offset: -2px;
    color: var(--nv-text);
}

/* ===================== Чат поддержки ===================== */

.nv-chat {
    position: fixed;
    right: calc(var(--nv-gap) + env(safe-area-inset-right, 0px));
    bottom: var(--nv-bottom);
    z-index: 61;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

/* --- значок --- */

.nv-chat__launcher {
    position: relative;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    display: grid;
    place-items: center;
    color: var(--nv-text);
    background: linear-gradient(180deg, var(--nv-red-top), var(--nv-red-bottom));
    box-shadow:
        inset 0 0 0 2px rgba(255, 220, 105, .9),
        inset 0 0 0 4px var(--nv-red-bottom),
        inset 0 2px 0 5px rgba(255, 255, 255, .08),
        0 10px 24px rgba(0, 0, 0, .5),
        0 0 0 0 rgba(201, 36, 47, .55);
    animation: nv-pop .5s cubic-bezier(.2, .9, .3, 1.3) .3s both, nv-ring 2.6s ease-out 1.2s 3;
    transition: transform .2s ease, background-color .2s;
}

.nv-chat__launcher:hover { transform: translateY(-2px); }
.nv-chat__launcher:active { transform: scale(.95); }

.nv-chat__launcher:focus-visible {
    outline: 2px solid var(--nv-gold);
    outline-offset: 3px;
}

.nv-chat__icon {
    width: 26px;
    height: 26px;
    grid-area: 1 / 1;
    transition: transform .3s ease, opacity .2s ease;
}

.nv-chat__icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(.6);
}

.nv-chat.is-open .nv-chat__icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(.6);
}

.nv-chat.is-open .nv-chat__icon--close {
    opacity: 1;
    transform: none;
}

/* маленькая звезда-жетон на значке */
.nv-chat__sheriff {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .6));
    transition: transform .4s cubic-bezier(.2, .9, .3, 1.4);
}

.nv-chat__launcher:hover .nv-chat__sheriff { transform: rotate(36deg) scale(1.08); }

.nv-chat__badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--nv-gold);
    color: var(--nv-page);
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--nv-page);
    transform: scale(0);
    transition: transform .25s cubic-bezier(.2, .9, .3, 1.4);
}

.nv-chat__badge.is-shown { transform: scale(1); }

/* --- окно чата --- */

.nv-chat__panel {
    width: 360px;
    height: min(500px, calc(100vh - var(--nv-bottom) - 60px - 12px - 24px));
    height: min(500px, calc(100dvh - var(--nv-bottom) - 60px - 12px - 24px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
    background: var(--nv-surface);
    border: 1px solid var(--nv-border);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .4);
    transform-origin: 100% 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(.94);
    transition: opacity .22s ease, transform .28s cubic-bezier(.2, .9, .3, 1.1), visibility 0s linear .28s;
}

.nv-chat.is-open .nv-chat__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition: opacity .22s ease, transform .28s cubic-bezier(.2, .9, .3, 1.1), visibility 0s;
}

.nv-chat__head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background:
        radial-gradient(140% 120% at 100% 0%, rgba(201, 36, 47, .35), rgba(201, 36, 47, 0) 60%),
        var(--nv-surface-2);
    border-bottom: 1px solid var(--nv-border);
}

/* «пунктирная строчка», как на кожаном жетоне */
.nv-chat__head::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 5px;
    border-bottom: 1px dashed rgba(245, 198, 58, .3);
}

.nv-chat__avatar {
    position: relative;
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, var(--nv-red-top), var(--nv-red-bottom));
    box-shadow: inset 0 0 0 2px rgba(255, 220, 105, .85);
}

.nv-chat__avatar svg { width: 26px; height: 26px; }

.nv-chat__avatar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--nv-live);
    border: 2px solid var(--nv-surface-2);
}

.nv-chat__title {
    min-width: 0;
    flex: 1;
}

.nv-chat__title strong {
    display: block;
    font-family: Podkova, Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--nv-text);
}

.nv-chat__title span {
    display: block;
    font-size: 12.5px;
    color: var(--nv-muted);
    margin-top: 2px;
}

.nv-chat__close {
    flex: none;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--nv-border);
    border-radius: 11px;
    background: var(--nv-surface);
    color: var(--nv-body);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background-color .2s, border-color .2s;
}

.nv-chat__close svg { width: 14px; height: 14px; }
.nv-chat__close:hover { background: var(--nv-border); }
.nv-chat__close:focus-visible { outline: 2px solid var(--nv-gold); outline-offset: 2px; }

.nv-chat__log {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--nv-border) transparent;
}

.nv-msg {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.42;
    overflow-wrap: anywhere;
    animation: nv-msg .28s ease-out both;
}

.nv-msg--bot {
    align-self: flex-start;
    color: var(--nv-body);
    background: var(--nv-surface-2);
    border: 1px solid var(--nv-border);
    border-bottom-left-radius: 5px;
}

.nv-msg--user {
    align-self: flex-end;
    color: var(--nv-text);
    background: linear-gradient(180deg, var(--nv-red-top), var(--nv-red-bottom));
    border-bottom-right-radius: 5px;
}

.nv-msg b { color: var(--nv-gold); font-weight: 600; }

.nv-msg__time {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--nv-muted);
    text-align: right;
}

.nv-msg--user .nv-msg__time { color: rgba(244, 242, 236, .6); }

.nv-msg__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 9px;
    padding: 8px 13px;
    border-radius: 11px;
    background: var(--nv-gold);
    color: var(--nv-page);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .2s;
}

.nv-msg__cta:hover { background: var(--nv-gold-light); }
.nv-msg__cta:focus-visible { outline: 2px solid var(--nv-text); outline-offset: 2px; }
.nv-msg__cta svg { width: 14px; height: 14px; }

.nv-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 13px 14px;
    border-radius: 16px;
    border-bottom-left-radius: 5px;
    background: var(--nv-surface-2);
    border: 1px solid var(--nv-border);
}

.nv-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--nv-muted);
    animation: nv-typing 1.1s ease-in-out infinite;
}

.nv-typing i:nth-child(2) { animation-delay: .15s; }
.nv-typing i:nth-child(3) { animation-delay: .3s; }

.nv-chat__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 14px 10px;
}

.nv-chat__quick[hidden] { display: none; }

.nv-chip {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(245, 198, 58, .45);
    background: rgba(245, 198, 58, .06);
    color: var(--nv-gold-light);
    font-size: 13px;
    cursor: pointer;
    transition: background-color .2s, border-color .2s;
}

.nv-chip:hover { background: rgba(245, 198, 58, .14); border-color: var(--nv-gold); }
.nv-chip:focus-visible { outline: 2px solid var(--nv-gold); outline-offset: 2px; }

.nv-chat__form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--nv-border);
    background: var(--nv-surface);
}

.nv-chat__input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--nv-border);
    background: var(--nv-page);
    color: var(--nv-text);
    font: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.nv-chat__input::placeholder { color: var(--nv-muted); }

.nv-chat__input:focus {
    border-color: var(--nv-gold-dark);
    box-shadow: 0 0 0 3px rgba(245, 198, 58, .15);
}

.nv-chat__send {
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: var(--nv-text);
    background: linear-gradient(180deg, var(--nv-red-top), var(--nv-red-bottom));
    transition: filter .2s, opacity .2s;
}

.nv-chat__send svg { width: 19px; height: 19px; }
.nv-chat__send:hover { filter: brightness(1.15); }
.nv-chat__send:disabled { opacity: .45; cursor: default; filter: none; }
.nv-chat__send:focus-visible { outline: 2px solid var(--nv-gold); outline-offset: 2px; }

/* ===================== Анимации ===================== */

@keyframes nv-slide-left {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: none; }
}

@keyframes nv-out-left {
    to { opacity: 0; transform: translateX(-30px); }
}

@keyframes nv-pop {
    from { opacity: 0; transform: scale(.4); }
    to   { opacity: 1; transform: none; }
}

@keyframes nv-ring {
    0%   { box-shadow: inset 0 0 0 2px rgba(255, 220, 105, .9), inset 0 0 0 4px var(--nv-red-bottom), inset 0 2px 0 5px rgba(255, 255, 255, .08), 0 10px 24px rgba(0, 0, 0, .5), 0 0 0 0 rgba(201, 36, 47, .55); }
    100% { box-shadow: inset 0 0 0 2px rgba(255, 220, 105, .9), inset 0 0 0 4px var(--nv-red-bottom), inset 0 2px 0 5px rgba(255, 255, 255, .08), 0 10px 24px rgba(0, 0, 0, .5), 0 0 0 18px rgba(201, 36, 47, 0); }
}

@keyframes nv-star {
    0%, 86%, 100% { transform: rotate(0); }
    92% { transform: rotate(36deg); }
}

@keyframes nv-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(62, 207, 110, .65); }
    70%  { box-shadow: 0 0 0 7px rgba(62, 207, 110, 0); }
    100% { box-shadow: 0 0 0 0 rgba(62, 207, 110, 0); }
}

@keyframes nv-msg {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@keyframes nv-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ===================== Мобильная версия ===================== */

@media (max-width: 767px) {
    :root { --nv-gap: 10px; }

    .nv-online {
        min-width: 0;
        gap: 9px;
        padding: 7px 30px 7px 7px;
        border-radius: 13px;
    }

    .nv-online__badge { width: 34px; height: 34px; border-radius: 10px; }
    .nv-online__star { width: 24px; height: 24px; }
    .nv-online__live { width: 10px; height: 10px; }
    .nv-online__row { gap: 10px; }
    .nv-online__name { font-size: 11.5px; }
    .nv-online__value { font-size: 15.5px; }
    .nv-online__row--playing .nv-online__value { font-size: 13.5px; }

    .nv-online__close {
        /* кружок маленький, зона нажатия — 32 px */
        top: 0;
        right: 0;
        width: 32px;
        height: 32px;
    }

    .nv-chat { gap: 10px; }

    .nv-chat__launcher { width: 50px; height: 50px; }
    .nv-chat__icon { width: 22px; height: 22px; }
    .nv-chat__sheriff { width: 20px; height: 20px; top: -4px; left: -4px; }

    .nv-chat__panel {
        width: min(360px, calc(100vw - 2 * var(--nv-gap)));
        height: min(440px, calc(100vh - var(--nv-bottom) - 50px - 10px - 70px));
        height: min(440px, calc(100dvh - var(--nv-bottom) - 50px - 10px - 70px));
        border-radius: 18px;
    }

    .nv-chat__head { padding: 11px 11px 12px 13px; }
    .nv-chat__avatar { width: 36px; height: 36px; }
    .nv-chat__avatar svg { width: 22px; height: 22px; }
    .nv-chat__title strong { font-size: 16px; }
    .nv-chat__log { padding: 12px 11px 6px; }
    .nv-msg { font-size: 13.5px; max-width: 88%; }
    .nv-chat__quick { padding: 2px 11px 8px; }
    .nv-chip { font-size: 12.5px; padding: 6px 11px; }
    .nv-chat__form { padding: 8px 10px 10px; }
    .nv-chat__input { height: 42px; font-size: 16px; }   /* 16px — iOS не зумит поле */
    .nv-chat__send { width: 42px; height: 42px; }
}

@media (max-width: 360px) {
    .nv-online__name { font-size: 11px; }
    .nv-online__value { font-size: 14.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .nv-online,
    .nv-online.is-closing,
    .nv-online__star,
    .nv-online__live,
    .nv-chat__launcher,
    .nv-msg,
    .nv-typing i { animation: none !important; }

    .nv-online,
    .nv-chat__panel,
    .nv-chat.is-open .nv-chat__panel,
    .nv-chat__icon,
    .nv-online__value { transition: none; }
}
