/* ============ БАЗА ============ */
* { box-sizing: border-box; }

html, body {
    overflow-x: hidden;
    max-width: 100vw;
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}
body > .main-content {
    flex: 1;
    min-height: 0;
    max-width: none;
    width: 100%;
    padding: 0;
}

.chat-page {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    color: #e8eef7;
    padding: 12px 16px;
    overflow-x: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-page h1 {
    font-size: 24px;
    font-weight: 500;
    color: wheat;
    margin: 0 0 14px;
}

.badge-admin {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(200,60,60,0.18);
    color: #b83b3b;
    border: 1px solid rgba(200,60,60,0.4);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    vertical-align: middle;
    text-decoration: none;
    cursor: pointer;
    transition: .15s;
}
.badge-admin:hover {
    background: rgba(200,60,60,0.35);
    color: #7a1a1a;
}

.badge-archive {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(74, 124, 247, 0.18);
    color: #4a7cf7;
    border: 1px solid rgba(74, 124, 247, 0.4);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    vertical-align: middle;
    text-decoration: none;
    cursor: pointer;
    transition: .15s;
}
.badge-archive:hover {
    background: rgba(74, 124, 247, 0.35);
    color: #2a5aa7;
}

.chat-ban {
    padding: 12px 16px;
    margin-bottom: 14px;
    background: rgba(200, 60, 60, 0.18);
    border: 1px solid rgba(200, 60, 60, 0.5);
    border-radius: 10px;
    color: #ffd0d0;
    font-size: 14px;
    word-wrap: break-word;
}

/* ============ ЕДИНЫЙ СТИЛЬ КНОПОК ============ */
/* Главная кнопка — как «Отправить» */
.enter-btn,
.chat-login-hint .btn-login,
.chat-input .send-btn,
.media-actions button.primary,
.kick-box button,
.archive-login-buttons .enter-btn:not(.secondary) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 26px;
    border-radius: 24px;
    border: none;
    background: linear-gradient(135deg, #4a7cf7, #6a4cf7);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow .15s;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.2;
    white-space: nowrap;
}
.enter-btn:hover,
.chat-login-hint .btn-login:hover,
.chat-input .send-btn:hover:not(:disabled),
.media-actions button.primary:hover:not(:disabled),
.kick-box button:hover,
.archive-login-buttons .enter-btn:not(.secondary):hover {
    box-shadow: 0 6px 22px rgba(74, 124, 247, 0.5);
}
.chat-input .send-btn:disabled,
.media-actions button.primary:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

/* Вторичная кнопка — как «Выйти» */
.enter-btn.secondary,
.chat-login-hint .btn-reg,
.chat-input .exit-btn,
.media-actions button:not(.primary),
.kick-box button.secondary,
.archive-login-buttons .enter-btn.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #c8d5ea;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.2;
    white-space: nowrap;
}
.enter-btn.secondary:hover,
.chat-login-hint .btn-reg:hover,
.chat-input .exit-btn:hover,
.media-actions button:not(.primary):hover,
.kick-box button.secondary:hover,
.archive-login-buttons .enter-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.chat-input .exit-btn:hover {
    background: rgba(255, 90, 90, 0.18);
    border-color: rgba(255, 90, 90, 0.5);
    color: #ffd0d0;
}

/* Иконки внутри кнопок */
.enter-btn .btn-icon,
.enter-btn.secondary .btn-icon {
    font-size: 16px;
    line-height: 1;
}

/* ============ ЭКРАН ВХОДА В ЧАТ ============ */
.enter-overlay {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    padding: 30px 20px;
    overflow: hidden;
    border-radius: 20px;
    background:
        radial-gradient(circle at 20% 30%, rgba(74, 124, 247, 0.25), transparent 45%),
        radial-gradient(circle at 80% 70%, rgba(168, 76, 247, 0.22), transparent 45%),
        radial-gradient(circle at 50% 100%, rgba(247, 76, 148, 0.15), transparent 55%),
        linear-gradient(135deg, #0a1628 0%, #0f1f3a 50%, #131a2e 100%);
    isolation: isolate;
}
.enter-overlay[hidden] { display: none; }

.enter-decor {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.decor-icon {
    position: absolute;
    font-size: 32px;
    opacity: 0.18;
    filter: blur(0.5px);
    animation: decor-float 12s ease-in-out infinite;
    animation-delay: calc(var(--i) * -1.5s);
    top: calc(10% + (var(--i) * 10%));
    left: calc(5% + (var(--i) * 12%));
    transform: translateZ(0);
}
.decor-icon:nth-child(odd) {
    left: auto;
    right: calc(5% + (var(--i) * 8%));
    top: calc(20% + (var(--i) * 8%));
}
@keyframes decor-float {
    0%, 100%   { transform: translate(0, 0) rotate(0deg); }
    25%        { transform: translate(20px, -30px) rotate(6deg); }
    50%        { transform: translate(-15px, -15px) rotate(-4deg); }
    75%        { transform: translate(10px, 20px) rotate(3deg); }
}

.enter-card {
    position: relative;
    z-index: 1;
    max-width: 500px;
    width: 100%;
    padding: 48px 38px 40px;
    background: rgba(20, 25, 40, 0.75);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    text-align: center;
    color: #e8eef7;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
    animation: enter-pop .35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes enter-pop {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}

.enter-glow {
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle, rgba(74, 124, 247, 0.35), transparent 60%);
    filter: blur(40px);
    z-index: -1;
    animation: glow-pulse 4s ease-in-out infinite;
    pointer-events: none;
}
@keyframes glow-pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50%      { opacity: 0.85; transform: scale(1.05); }
}

.enter-icon {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 0 auto 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.enter-icon-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #4a7cf7, #a84cf7, #f74c94, #4a7cf7);
    animation: ring-spin 6s linear infinite;
    opacity: 0.85;
}
@keyframes ring-spin {
    to { transform: rotate(360deg); }
}
.enter-icon-core {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f1f3a, #1a2a4a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    animation: icon-bounce 3s ease-in-out infinite;
}
@keyframes icon-bounce {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

.enter-card h2 {
    margin: 0 0 8px;
    font-size: 26px;
    color: #fff;
    font-weight: 700;
    letter-spacing: .3px;
    background: linear-gradient(135deg, #fff, #b8c8e0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.enter-subtitle {
    margin: 0 0 28px !important;
    font-size: 14px !important;
    color: rgba(255, 255, 255, 0.55) !important;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 500;
}
.enter-hint {
    margin: 0 0 26px !important;
    font-size: 15px !important;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.72) !important;
}

.enter-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.enter-features {
    margin-top: 30px;
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.enter-features .feature {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.65);
    font-size: 12px;
    font-weight: 500;
    transition: .15s;
}
.enter-features .feature:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* ============ ОСНОВНАЯ СЕТКА ============ */
.chat-main {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 18px;
    min-width: 0;
    flex: 1;
    min-height: 0;
}
.chat-main[hidden] { display: none; }

.chat-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    position: relative;
}

.chat-window {
    background: #fff;
    color: #222;
    border-radius: 12px;
    padding: 10px 16px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #ccc;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.msg {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #eef2f7;
    min-width: 0;
    max-width: 100%;
}
.msg:last-child { border-bottom: none; }

.msg-avatar {
    width: 36px; height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #e6f0dc;
    border: 1px solid #b8cfe0;
    display: flex; align-items: center; justify-content: center;
    color: #4a7a3a;
    font-weight: 600;
    font-size: 15px;
    text-transform: uppercase;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.msg-body {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.msg-meta {
    font-size: 13px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    min-width: 0;
}
.msg-nick {
    font-weight: 600;
    color: #2a5a9e;
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-nick:hover { text-decoration: underline; }
.msg-time {
    color: #9aa8bd;
    font-size: 11px;
    margin-left: 8px;
    flex-shrink: 0;
}
.msg-text {
    color: #222;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    line-height: 1.4;
    margin-bottom: 4px;
    max-width: 100%;
}
.msg-text:empty { display: none; }

.msg.is-bot {
    background: linear-gradient(90deg, rgba(74, 124, 247, 0.06), transparent 60%);
    border-left: 3px solid rgba(74, 124, 247, 0.4);
    padding-left: 10px;
    border-radius: 4px;
}
.msg.is-bot .msg-nick { color: #4a7cf7; }

.msg-attach-image {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 360px;
    object-fit: contain;
    border-radius: 8px;
    margin-top: 4px;
    cursor: zoom-in;
    border: 1px solid #d8e2f0;
}
.msg-attach-audio {
    display: block;
    margin-top: 4px;
    width: 100%;
    max-width: 420px;
}
.msg-attach-link {
    display: inline-block;
    margin-top: 4px;
    padding: 6px 12px;
    border-radius: 8px;
    background: #eef4fb;
    color: #2a5a9e;
    text-decoration: none;
    font-size: 13px;
    border: 1px solid #cfe0f5;
    word-break: break-all;
    max-width: 100%;
}
.msg-attach-link:hover { background: #e2ecf9; }

.msg.mentioned { background: #fff7dc; border-left: 3px solid #f0b400; padding-left: 10px; border-radius: 4px; }
.msg.mine .msg-nick { color: #2e8b57; }

.msg-admin {
    display: inline-flex;
    gap: 3px;
    margin-left: auto;
    vertical-align: middle;
    opacity: 0;
    transition: .15s;
}
.msg:hover .msg-admin,
.msg:active .msg-admin { opacity: 1; }
.msg-admin .ma-btn {
    border: 1px solid #d8e2f0;
    background: #f4f6fa;
    color: #556c8a;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: .12s;
}
.msg-admin .ma-del:hover   { background: #c85c5c; color: #fff; border-color: #c85c5c; }
.msg-admin .ma-ban:hover   { background: #c9a04a; color: #fff; border-color: #c9a04a; }
.msg-admin .ma-kick:hover  { background: #6a9de0; color: #fff; border-color: #6a9de0; }
.msg-admin .ma-clear:hover { background: #7a2a2a; color: #fff; border-color: #7a2a2a; }

.chat-empty {
    color: #7a90b5;
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

.chat-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(20, 25, 40, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #c8d5ea;
    font-size: 13px;
    min-width: 0;
    flex-shrink: 0;
}
.chat-preview[hidden] { display: none; }
.chat-preview .thumb {
    width: 44px; height: 44px;
    border-radius: 6px;
    overflow: hidden;
    background: #0f1f3a;
    display: flex; align-items: center; justify-content: center;
    color: #7bb6ff; font-size: 20px;
    flex: 0 0 44px;
}
.chat-preview .thumb img { width: 100%; height: 100%; object-fit: cover; }
.chat-preview .info { flex: 1; min-width: 0; }
.chat-preview .info .name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-preview .info .size { color: #93a4c2; font-size: 11px; word-break: break-all; }
.chat-preview .rm {
    background: none; border: none; color: #ff9090;
    font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px;
}

.chat-input {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: nowrap;
    align-items: center;
    min-width: 0;
    flex-shrink: 0;
}
.chat-input .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 50%;
    border: 1px solid #3b5687;
    background: #16294a;
    color: #c8d5ea;
    font-size: 18px;
    cursor: pointer;
    transition: .15s;
    padding: 0;
}
.chat-input .icon-btn:hover {
    background: #1e3a63;
    color: #fff;
    border-color: #6a9de0;
}
.chat-input input[type=text] {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid #3b5687;
    background: #16294a;
    color: #eef4ff;
    font-size: 14px;
}
.chat-input input[type=text]::placeholder { color: #7a90b5; }
.chat-input input[type=text]:focus {
    outline: none;
    border-color: #6a9de0;
    box-shadow: 0 0 0 2px rgba(106,157,224,0.35);
}
.chat-input .send-btn,
.chat-input .exit-btn {
    height: 44px;
    padding: 0 22px;
    flex: 0 0 auto;
}

/* ============ ЭМОДЗИ-ПИКЕР ============ */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 0;
    width: 340px;
    max-width: calc(100vw - 40px);
    background: #fff;
    color: #222;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid #d8e2f0;
    padding: 10px;
    z-index: 50;
    max-height: 340px;
    overflow-y: auto;
}
.emoji-picker[hidden] { display: none; }
.emoji-picker .cat {
    font-size: 11px;
    color: #7a8ba5;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 8px 4px 4px;
}
.emoji-picker .cat:first-child { margin-top: 0; }
.emoji-picker .grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 2px;
}
.emoji-picker button {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    padding: 4px;
    cursor: pointer;
    border-radius: 6px;
    transition: .12s;
}
.emoji-picker button:hover {
    background: #eef4fb;
    transform: scale(1.15);
}

/* ============ МЕДИА-ПИКЕР ============ */
.media-picker {
    position: absolute;
    bottom: 70px;
    left: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: #fff;
    color: #222;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid #d8e2f0;
    padding: 14px;
    z-index: 50;
    max-height: 420px;
    overflow-y: auto;
}
.media-picker[hidden] { display: none; }
.media-picker h3 {
    margin: 0 0 10px;
    font-size: 15px;
    color: #1a2a4a;
    font-weight: 600;
}
.media-picker input[type=text] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #b6c2d4;
    font-size: 13px;
    box-sizing: border-box;
}
.media-picker input[type=text]:focus {
    outline: none;
    border-color: #4a7ab8;
    box-shadow: 0 0 0 2px rgba(74, 122, 184, 0.2);
}
.media-picker .media-hint {
    margin-top: 6px;
    color: #7a8ba5;
    font-size: 11px;
    line-height: 1.45;
}
.media-picker .media-preview {
    margin-top: 10px;
}
.media-picker .media-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 8px;
    border: 1px solid #d8e2f0;
    display: block;
}
.media-picker .media-preview audio { width: 100%; }
.media-picker .media-preview .link-preview {
    padding: 8px 12px;
    border-radius: 8px;
    background: #eef4fb;
    border: 1px solid #cfe0f5;
    color: #2a5a9e;
    font-size: 12px;
    word-break: break-all;
}
.media-picker .media-preview .error-preview {
    padding: 8px 12px;
    border-radius: 8px;
    background: #fde2e2;
    border: 1px solid #d88080;
    color: #7a1a1a;
    font-size: 12px;
}
.media-picker .media-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.media-picker .media-actions button {
    padding: 10px 22px;
    font-size: 13px;
}

.chat-login-hint {
    margin-top: 10px;
    padding: 10px 20px;
    background: rgba(20, 25, 40, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.chat-login-hint span { color: #c8d5ea; font-size: 14px; }

/* ============ САЙДБАР ============ */
.chat-sidebar {
    background: #fff;
    color: #222;
    border-radius: 12px;
    padding: 14px;
    overflow-y: auto;
    border: 1px solid #ccc;
    min-width: 0;
    height: 100%;
    max-height: 100%;
}
.chat-sidebar .sidebar-me {
    font-size: 13px;
    color: #4a5a75;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid #eef2f7;
    word-break: break-word;
}
.chat-sidebar .sidebar-me b { color: #1a2a4a; }
.chat-sidebar .sidebar-me a {
    color: #2a5a9e;
    margin-left: 6px;
    text-decoration: none;
    font-weight: 600;
}
.chat-sidebar .sidebar-me a:hover { text-decoration: underline; }

.chat-sidebar h3 {
    margin: 0 0 12px;
    font-size: 15px;
    color: #333;
    border-bottom: 1px solid #eef2f7;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-sidebar h3 .count {
    background: #e8f0fb;
    color: #2a5a9e;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 12px;
}
#users-list { list-style: none; padding: 0; margin: 0; }
#users-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: #2a5a9e;
    transition: .12s;
    min-width: 0;
}
#users-list li:hover { background: #eaf2fc; }
#users-list li.me { color: #2e8b57; font-weight: 600; }
#users-list li.is-bot-user {
    background: linear-gradient(90deg, rgba(74, 124, 247, 0.1), transparent);
    color: #4a7cf7;
    font-weight: 600;
}
#users-list li .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #34c759;
    flex-shrink: 0;
}
#users-list li.is-bot-user .dot {
    background: #4a7cf7;
    animation: bot-dot 1.5s ease-in-out infinite;
}
@keyframes bot-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.3); opacity: 0.6; }
}
#users-list li .uname {
    flex: 1;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
#users-list li .info-btn {
    flex: 0 0 18px;
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1px solid #b8cfe0;
    background: #eaf2fc;
    color: #2a5a9e;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .12s;
    font-style: italic;
    font-family: Georgia, serif;
}
#users-list li .info-btn:hover {
    background: #2a5a9e;
    color: #fff;
    border-color: #2a5a9e;
}

/* ============ МОДАЛКИ ============ */
.uinfo-modal[hidden],
.kick-modal[hidden],
.img-viewer[hidden] { display: none; }

.uinfo-modal,
.kick-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.uinfo-overlay,
.kick-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}
.kick-overlay { background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(6px); }

.uinfo-box,
.kick-box {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    color: #222;
    border-radius: 14px;
    padding: 26px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: uinfo-pop .16s ease-out;
    max-height: 92vh;
    overflow-y: auto;
}
.kick-box { max-width: 420px; text-align: center; padding: 34px 28px 26px; }
@keyframes uinfo-pop {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
.uinfo-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none; border: none;
    font-size: 26px; line-height: 1;
    color: #9aa8bd; cursor: pointer;
    padding: 0;
}
.uinfo-close:hover { color: #333; }
.uinfo-loading, .uinfo-error {
    padding: 24px 0;
    text-align: center;
    font-size: 14px;
    color: #666;
}
.uinfo-error { color: #b00; }
.uinfo-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eef2f7;
}
.uinfo-avatar {
    width: 64px; height: 64px;
    flex: 0 0 64px;
    border-radius: 50%;
    overflow: hidden;
    background: #e6f0dc;
    color: #5a8a3a;
    font-size: 28px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    border: 2px solid #7ba05b;
}
.uinfo-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.uinfo-head-text { min-width: 0; flex: 1; }
.uinfo-head-text h3 { margin: 0 0 4px; font-size: 18px; color: #1a2a4a; word-break: break-word; }
.uinfo-username { color: #93a4c2; font-size: 13px; word-break: break-all; }
.uinfo-table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.uinfo-table td {
    padding: 8px 6px 8px 0;
    vertical-align: top;
    color: #222;
    border-bottom: 1px solid #f4f6fa;
    word-break: break-word;
}
.uinfo-table td.k { color: #7a8ba5; white-space: nowrap; width: 110px; font-size: 13px; }
.uinfo-table tr:last-child td { border-bottom: none; }

.kick-box .emoji { font-size: 52px; line-height: 1; margin-bottom: 12px; }
.kick-box h2 { margin: 0 0 14px; font-size: 20px; color: #b83b3b; font-weight: 600; }
.kick-box p { margin: 8px 0; font-size: 15px; line-height: 1.5; color: #444; }
.kick-box p b { color: #1a2a4a; }
.kick-box .reason {
    margin-top: 14px;
    padding: 10px 14px;
    background: #fde2e2;
    border: 1px solid #d88080;
    border-radius: 8px;
    color: #7a1a1a;
    font-size: 14px;
}
.kick-box button {
    margin-top: 22px;
    min-width: 160px;
}

.img-viewer {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
}
.img-viewer img {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
    border-radius: 6px;
}

/* ============ КНОПКА "ВНИЗ" ============ */
.scroll-down-btn {
    position: absolute;
    right: 20px;
    bottom: 80px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7cf7, #6a4cf7);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(74, 124, 247, 0.5);
    font-size: 20px;
    line-height: 1;
    z-index: 5;
    opacity: 0;
    transition: opacity .2s, transform .15s;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scroll-down-btn[hidden] { display: none; }
.scroll-down-btn.visible {
    opacity: 1;
    pointer-events: auto;
}
.scroll-down-btn:hover { transform: scale(1.08); }

/* ============ АРХИВ ============ */
.archive-page {
    width: 100%;
    padding: 20px 16px;
    color: #e8eef7;
}
.archive-page h1 {
    font-size: 24px;
    font-weight: 500;
    color: wheat;
    margin: 0 0 14px;
}
.archive-days {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    padding: 12px;
    background: rgba(20, 25, 40, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}
.archive-day {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #c8d5ea;
    text-decoration: none;
    font-size: 13px;
    transition: .15s;
}
.archive-day:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.archive-day.active {
    background: linear-gradient(135deg, #4a7cf7, #6a4cf7);
    color: #fff;
    border-color: transparent;
}
.archive-day .cnt {
    color: #93a4c2;
    font-size: 11px;
    margin-left: 6px;
}
.archive-day.active .cnt { color: rgba(255,255,255,0.75); }

.archive-window {
    background: #fff;
    color: #222;
    border-radius: 12px;
    padding: 14px 18px;
    border: 1px solid #ccc;
    max-height: 70vh;
    overflow-y: auto;
}
.archive-empty {
    color: #7a90b5;
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}
.archive-note {
    margin-top: 14px;
    padding: 10px 14px;
    background: rgba(20, 25, 40, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #93a4c2;
    font-size: 12px;
}

/* ============ КАРТОЧКА ВХОДА В АРХИВ (гость) ============ */
.archive-login-card {
    max-width: 440px;
    margin: 40px auto;
    padding: 40px 32px 32px;
    background: rgba(20, 25, 40, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    text-align: center;
    color: #e8eef7;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.archive-login-emoji {
    font-size: 52px;
    line-height: 1;
    margin-bottom: 14px;
}
.archive-login-card h2 {
    margin: 0 0 10px;
    font-size: 22px;
    color: #fff;
    font-weight: 600;
}
.archive-login-card p {
    margin: 0 0 22px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    line-height: 1.5;
}
.archive-login-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.archive-login-buttons .enter-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 12px 20px;
    font-size: 14px;
}
.archive-login-back {
    margin: 22px 0 0 !important;
    font-size: 13px !important;
}
.archive-login-back a {
    color: #7bb6ff;
    text-decoration: none;
}
.archive-login-back a:hover {
    text-decoration: underline;
}

/* ==================================================
   ПЛАНШЕТ — до 900px
   ================================================== */
@media (max-width: 900px) {
    body {
        display: block;
    }
    body > .main-content {
        display: block;
        height: auto;
        min-height: 0;
        flex: none;
    }
    .chat-page {
        height: auto;
        display: block;
        min-height: 0;
    }
    .chat-main {
        display: flex;
        flex-direction: column;
        gap: 12px;
        min-height: 0;
        flex: none;
    }
    .chat-wrapper {
        display: block;
    }
    .chat-sidebar {
        order: -1;
        height: auto;
        max-height: 180px;
        padding: 10px 14px;
        margin-bottom: 12px;
    }
    .chat-window {
        height: 520px;
        flex: none;
    }
    .chat-page h1 {
        font-size: 20px;
    }
    .sidebar-me {
        margin-bottom: 6px;
        padding-bottom: 6px;
    }
    .chat-sidebar h3 {
        font-size: 14px;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    #users-list li {
        padding: 5px 6px;
        font-size: 12px;
    }
}

/* ==================================================
   ТЕЛЕФОН — до 600px
   ================================================== */
@media (max-width: 600px) {
    .chat-page {
        padding: 0 8px;
    }
    .chat-page h1 {
        font-size: 18px;
        margin-bottom: 8px;
    }

    .enter-overlay {
        min-height: 65vh;
        padding: 20px 12px;
        border-radius: 16px;
    }
    .enter-card {
        padding: 32px 22px 28px;
        border-radius: 20px;
    }
    .enter-icon {
        width: 76px;
        height: 76px;
        margin-bottom: 16px;
    }
    .enter-icon-core {
        width: 66px;
        height: 66px;
        font-size: 34px;
    }
    .enter-card h2 {
        font-size: 20px;
    }
    .enter-subtitle {
        font-size: 12px !important;
        margin-bottom: 22px !important;
    }
    .enter-hint {
        font-size: 14px !important;
        margin-bottom: 20px !important;
    }
    .enter-buttons { flex-direction: column; }
    .enter-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }
    .enter-features {
        margin-top: 22px;
        padding-top: 18px;
        gap: 6px;
    }
    .enter-features .feature {
        font-size: 11px;
        padding: 5px 10px;
    }
    .decor-icon {
        font-size: 24px;
    }

    .chat-sidebar {
        max-height: 140px;
        padding: 10px 12px;
        border-radius: 10px;
    }
    .sidebar-me {
        font-size: 12px;
        margin-bottom: 6px;
        padding-bottom: 6px;
    }
    .chat-sidebar h3 {
        font-size: 13px;
        margin-bottom: 6px;
        padding-bottom: 5px;
    }
    #users-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    #users-list li {
        padding: 4px 10px;
        font-size: 12px;
        background: #eaf2fc;
        border-radius: 20px;
        flex: 0 0 auto;
    }
    #users-list li .uname {
        flex: 0 1 auto;
        max-width: 120px;
    }

    .chat-window {
        height: 60vh;
        min-height: 340px;
        padding: 8px 10px;
        border-radius: 10px;
    }
    .msg {
        gap: 8px;
        padding: 7px 0;
    }
    .msg-avatar {
        width: 30px;
        height: 30px;
        flex: 0 0 30px;
        font-size: 13px;
    }
    .msg-meta { font-size: 12px; }
    .msg-nick { max-width: 55%; }
    .msg-text { font-size: 14px; }

    .msg-attach-image {
        max-width: 100%;
        max-height: 45vh;
        width: auto;
        height: auto;
    }
    .msg-attach-audio { max-width: 100%; }

    .msg-admin { opacity: 1; }
    .msg-admin .ma-btn {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .chat-input {
        gap: 4px;
        margin-top: 8px;
    }
    .chat-input .icon-btn {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
        font-size: 16px;
    }
    .chat-input input[type=text] {
        padding: 10px 14px;
        font-size: 15px;
    }
    .chat-input .send-btn,
    .chat-input .exit-btn {
        height: 38px;
        padding: 0 14px;
        font-size: 13px;
    }

    .chat-preview {
        padding: 6px 10px;
        font-size: 12px;
    }
    .chat-preview .thumb {
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
        font-size: 16px;
    }

    .chat-login-hint {
        padding: 12px 14px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    .chat-login-hint span { font-size: 13px; }
    .chat-login-hint > div {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    .chat-login-hint .btn-login,
    .chat-login-hint .btn-reg {
        flex: 1 1 auto;
        padding: 10px 16px;
        font-size: 13px;
    }

    .emoji-picker {
        width: calc(100vw - 20px);
        left: 50%;
        transform: translateX(-50%);
        max-width: 420px;
        max-height: 260px;
    }
    .emoji-picker .grid {
        grid-template-columns: repeat(8, 1fr);
    }
    .emoji-picker button {
        font-size: 22px;
        padding: 5px;
    }

    .media-picker {
        width: calc(100vw - 20px);
        left: 50%;
        transform: translateX(-50%);
        max-width: 420px;
        max-height: 320px;
        padding: 12px;
    }
    .media-picker h3 { font-size: 14px; }
    .media-picker .media-actions button {
        flex: 1 1 auto;
        padding: 9px 14px;
        font-size: 12px;
    }

    .uinfo-modal,
    .kick-modal {
        padding: 12px;
    }
    .uinfo-box,
    .kick-box {
        padding: 20px 18px;
        border-radius: 12px;
        max-height: 94vh;
    }
    .uinfo-avatar {
        width: 52px;
        height: 52px;
        flex: 0 0 52px;
        font-size: 22px;
    }
    .uinfo-head-text h3 { font-size: 16px; }
    .uinfo-table { font-size: 13px; }
    .uinfo-table td.k {
        width: 90px;
        font-size: 12px;
    }
    .kick-box h2 { font-size: 18px; }
    .kick-box p { font-size: 14px; }

    .scroll-down-btn {
        right: 14px;
        bottom: 60px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .archive-page { padding: 12px 8px; }
    .archive-page h1 { font-size: 18px; }
    .archive-days { padding: 8px; gap: 4px; }
    .archive-day { padding: 5px 10px; font-size: 12px; }
    .archive-window { padding: 10px 12px; max-height: 65vh; }

    .archive-login-card {
        padding: 30px 20px 26px;
        border-radius: 16px;
        margin: 20px auto;
    }
    .archive-login-emoji { font-size: 42px; }
    .archive-login-card h2 { font-size: 18px; }
    .archive-login-card p { font-size: 14px; }
    .archive-login-buttons { flex-direction: column; }
    .archive-login-buttons .enter-btn { width: 100%; flex: none; }
}

/* ==================================================
   ОЧЕНЬ УЗКИЙ — до 380px
   ================================================== */
@media (max-width: 380px) {
    .chat-window {
        height: 55vh;
        min-height: 300px;
    }
    .chat-input .send-btn,
    .chat-input .exit-btn {
        padding: 0 12px;
        font-size: 12px;
    }
    .chat-input .icon-btn {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
        font-size: 14px;
    }
    .msg-avatar {
        width: 26px;
        height: 26px;
        flex: 0 0 26px;
        font-size: 12px;
    }
    .msg-nick { max-width: 50%; }
}