:root {
    --primary: #9b59b6;
    --primary-dark: #8e44ad;
    --danger: #e74c3c;
    --text: #2c3e50;
    --bg-light: rgba(255,255,255,0.7);
    --border: #d5dbdb;
    --bg-gradient: linear-gradient(135deg, #f5d9e8, #f8e0f0);
}
body.theme-light {
    --primary: #9b59b6;
    --primary-dark: #8e44ad;
    --text: #2c3e50;
    --bg-light: rgba(255,255,255,0.7);
    --border: #d5dbdb;
    --bg-gradient: linear-gradient(135deg, #f5d9e8, #f8e0f0);
}
body.theme-red {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --text: #2c3e50;
    --bg-light: rgba(255,235,235,0.7);
    --border: #e6b0aa;
    --bg-gradient: linear-gradient(135deg, #fadbd8, #f5b7b1);
}
body.theme-purple {
    --primary: #8e44ad;
    --primary-dark: #6c3483;
    --text: #2c3e50;
    --bg-light: rgba(235,225,245,0.7);
    --border: #b39ddb;
    --bg-gradient: linear-gradient(135deg, #d2b4de, #c39bd3);
}
body.theme-blue {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --text: #2c3e50;
    --bg-light: rgba(225,240,255,0.7);
    --border: #a9cce3;
    --bg-gradient: linear-gradient(135deg, #d4e6f1, #a9cce3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    color: var(--text);
}
#app { display: flex; flex-direction: column; height: 100%; }
#top-panel {
    background: rgba(255,255,255,0.3);
    backdrop-filter: blur(5px);
    padding: 8px;
    border-radius: 0 0 20px 20px;
    margin-bottom: 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}
.top-row-selects {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.top-row-icons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}
.menu-toggle {
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}
.menu-toggle:hover { background: rgba(0,0,0,0.05); }
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 8px;
    width: 220px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 12px 0;
    margin-top: 4px;
    display: none;
    z-index: 1000;
}
.dropdown-menu.show { display: block; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
}
.menu-item:hover { background: rgba(155, 89, 182, 0.1); }
.menu-item i {
    width: 20px;
    font-size: 16px;
    color: var(--primary-dark);
}
.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}
.context-menu {
    position: fixed;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 8px 0;
    min-width: 180px;
    z-index: 10000;
    display: none;
}
.context-menu .menu-item {
    padding: 10px 16px;
    font-size: 14px;
}
select {
    padding: 10px 9px;
    border: 2px solid var(--border);
    border-radius: 40px;
    background: white;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url(image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232c3e50'><polyline points='6 9 12 15 18 9'/></svg>);
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
select:hover { border-color: var(--primary-dark); }
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.2);
}
.icon-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.icon-group i {
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    transition: transform 0.2s;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
}
.icon-group i:hover { transform: scale(1.1); }
.sound-toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
    margin: 0 10px 10px;
    border-radius: 30px;
    padding: 10px;
    min-height: 0;
}
#leftdiv {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 20px;
    margin-bottom: 10px;
    font-size: 20px;
    line-height: 1.5;
    word-wrap: break-word;
    -webkit-overflow-scrolling: touch;
}
.msg {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    position: relative;
    font-size: 1em;
    min-width: 0;
    will-change: transform, opacity;
}
.msg-mine { background: rgba(230, 200, 250, 0.7); }
.msg-private { background: rgba(200, 220, 250, 0.7); font-style: italic; }
.msg-time {
    font-size: 0.8em;
    color: #7f8c8d;
    cursor: pointer;
    white-space: nowrap;
}
.msg-text {
    flex: 1;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
}
.msg .msg-text img { vertical-align: bottom; }
.msg-delete {
    cursor: pointer;
    opacity: 0.6;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,0,0,0.1);
    transition: opacity 0.2s;
    flex-shrink: 0;
}
.msg-delete:hover { opacity: 1; background: rgba(255,0,0,0.2); }
.msg-delete i { font-size: 14px; color: var(--danger); }
.special-msg {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    position: relative;
    font-size: 1em;
}
.special-msg.vsem {
    background: rgba(255, 192, 203, 0.5);
    border: 3px double rgba(0, 0, 0, 0.7);
}
.special-msg.dev {
    background: rgba(255, 192, 203, 0.5);
    border: 3px double rgba(72, 6, 7, 0.7);
}
.special-msg.parn {
    background: rgba(255, 192, 203, 0.5);
    border: 3px double rgba(25, 25, 112, 0.7);
}
.special-msg .msg-time {
    font-size: 0.8em;
    color: #7f8c8d;
    cursor: pointer;
    white-space: nowrap;
}
.special-msg .msg-sender-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.special-msg .msg-text {
    font-family: 'Arial Black', sans-serif;
    font-size: 1em;
    font-weight: bold;
    margin-left: 4px;
    word-break: break-word;
    overflow-wrap: break-word;
}
.special-msg.vsem .msg-text { color: #000000; }
.special-msg.dev .msg-text { color: #480607; }
.special-msg.parn .msg-text { color: #191970; }
.special-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    color: white;
    margin: 0 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    letter-spacing: 0.5px;
}
.special-tag.vsem { background: #c0392b; }
.special-tag.dev { background: #d2527f; }
.special-tag.parn { background: #2980b9; }
.media-image {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    cursor: pointer;
    margin: 4px 0;
}
.msg audio, .msg video {
    max-width: 100%;
    margin: 4px 0;
    border-radius: 8px;
}
.msg iframe {
    max-width: 100%;
    border-radius: 8px;
    margin: 4px 0;
}
.video-embed {
    max-width: 100%;
    width: 40%;
    height: auto;
    aspect-ratio: 16/9;
    max-height: 250px;
    border: none;
    border-radius: 8px;
    display: block;
    margin: 4px 0;
}
@media (max-width: 1199px) { .video-embed { width: 30%; } }
@media (max-width: 699px) { .video-embed { width: 20%; } }
@media (max-width: 360px) { .video-embed { width: 40%; } }
.input-panel {
    background: var(--bg-light);
    border-radius: 30px;
    padding: 12px;
}
.main-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
#tonick {
    width: 100px;
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 40px;
    font-size: 14px;
    outline: none;
}
.save-nick-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
    margin: 0px -5px;
}
input#autotext { margin: 0px -6px; }
.fa-paper-plane:before { content: "Отправить"; }
#text0 {
    flex: 1;
    min-width: 150px;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 40px;
    font-size: 16px;
    outline: none;
}
.send-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    width: 167px;
    height: 29px;
    border-radius: 20px;
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0 auto;
    transition: transform 0.2s;
    will-change: transform;
}
.send-btn:hover { transform: scale(1.05); }
.panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 320px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(5px);
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    transition: transform 0.3s;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    padding: 15px;
    will-change: transform;
    transform: translateZ(0);
}
.panel.left { left: 0; transform: translateX(-100%); border-radius: 0 20px 20px 0; }
.panel.right { right: 0; transform: translateX(100%); border-radius: 20px 0 0 20px; }
.panel.open { transform: translateX(0); }
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}
.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--danger);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}
.close-btn:hover { background: rgba(0,0,0,0.05); }
.spoiler {
    margin-bottom: 15px;
    border-radius: 12px;
    background: rgba(255,255,255,0.5);
    overflow: hidden;
    flex-shrink: 0;
}
.spoiler-header {
    padding: 10px 15px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    font-weight: bold;
}
.spoiler-arrow {
    font-size: 18px;
    transition: transform 0.3s;
}
.spoiler-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s;
    background: rgba(255,255,255,0.8);
}
.spoiler-content.open {
    max-height: 500px;
    overflow-y: auto;
}
#menu-content .menu-item {
    padding: 12px 16px;
    font-size: 16px;
    gap: 12px;
    cursor: pointer;
}
#menu-content .menu-item i { font-size: 18px; }
.player-container {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    text-align: center;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.player-container:last-child { border-bottom: none; }
.station-name {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
    text-align: center;
    color: var(--text);
    width: 100%;
    word-wrap: break-word;
}
.player-container audio {
    width: 100%;
    height: auto;
    min-height: 50px;
    border-radius: 12px;
}
.red-player audio {
    background: #ffcccc;
    border: 2px solid #cc0000;
}
.blue-player audio {
    background: #cce5ff;
    border: 2px solid #0044cc;
}
.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.category-divider {
    background: linear-gradient(135deg, #6ab0b0, #4f9a9a);
    color: var(--text);
    font-weight: bold;
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 16px;
}
.category-count {
    background: rgba(255,255,255,0.3);
    padding: 2px 8px;
    border-radius: 30px;
    font-size: 14px;
}
.user-item {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    transition: background 0.2s;
    font-size: 16px;
    will-change: transform, opacity;
}
.user-item:hover { background: rgba(0,0,0,0.02); }
.user-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.user-icon-left { flex-shrink: 0; }
.custom-user-icon {
    max-width: 50px;
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: pointer;
    transition: opacity 0.2s;
}
.graf-container { flex: 1; text-align: center; }
.status-main-right { flex-shrink: 0; }
.user-icons-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.status-icon, .gender-icon, .love-icon, .clan-icon, .user-icon, .ign-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    cursor: pointer;
    transition: opacity 0.2s;
}
.status-icon:hover, .gender-icon:hover, .love-icon:hover, 
.clan-icon:hover, .user-icon:hover, .ign-icon:hover { opacity: 0.8; }
.graf-nick {
    max-width: 150px;
    max-height: 30px;
    object-fit: contain;
    cursor: pointer;
}
.user-nick-link {
    color: #2980b9;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    font-size: 1em;
}
.user-nick-link:hover { color: var(--danger); }
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9997;
    display: none;
}
.overlay.active { display: block; }

/* 🔧 СТИЛИ ДЛЯ СТАТУСА ПОЛЬЗОВАТЕЛЯ */
.user-status-text {
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #7f8c8d;
    background: rgba(255,255,255,0.5);
    border-radius: 8px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-status-text img {
    max-width: 16px;
    max-height: 16px;
    vertical-align: middle;
}

@media (max-width: 360px) {
    #action-select, #action-cmd-select, #status-select {
        min-width: 0;
        width: auto;
        flex: 1 1 0;
    }
}
@media (min-width: 1000px) {
    #top-panel {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 15px;
        flex-wrap: nowrap;
    }
    .top-row-selects {
        display: flex;
        flex-direction: row;
        gap: 8px;
        margin-bottom: 0;
        flex: 1 1 auto;
    }
    .top-row-icons {
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-left: auto;
        flex: 0 0 auto;
    }
    .icon-group { flex-wrap: nowrap; }
    select { min-width: 140px; }
}
.btn-3d {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border: none;
    cursor: pointer;
}
.btn-3d:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}
#smile-loader {
    text-align: center;
    padding: 30px 20px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
#smile-loader i {
    font-size: 32px;
    color: var(--primary);
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
#smile-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
}
#smile-frame.loaded { display: block; }

/* Личные смайлы */
.emoji-panel-mobile {
    position: fixed; bottom: 75px; left: 0; right: 0;
    background: white; border-top: 3px solid #ff6b9d;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.15);
    z-index: 9999; transition: bottom 0.3s;
    bottom: -300px; max-height: 280px;
    display: flex; flex-direction: column;
}
.emoji-panel-mobile.open { bottom: 75px; }
.emoji-panel-mobile-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; background: #ff6b9d; color: white;
    border-radius: 20px 20px 0 0;
}
.emoji-panel-mobile-header button {
    background: rgba(255,255,255,0.3); border: none;
    padding: 4px 10px; border-radius: 20px; color: white;
    cursor: pointer; margin-left: 5px;
}
.emoji-panel-mobile-content { flex: 1; overflow-y: auto; padding: 8px; }
.emoji-grid-mobile { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-item-mobile {
    background: #f0f0f0; border-radius: 8px; padding: 5px;
    text-align: center; cursor: pointer; position: relative;
    width: 55px; height: 55px; display: flex; align-items: center; justify-content: center;
}
.emoji-item-mobile img { max-width: 45px; max-height: 45px; }
.emoji-delete-mobile {
    position: absolute; top: -4px; right: -4px;
    background: red; color: white; border-radius: 50%;
    width: 16px; height: 16px; font-size: 9px;
    display: none; align-items: center; justify-content: center; cursor: pointer;
}
.emoji-item-mobile:hover .emoji-delete-mobile { display: flex; }
.empty-emoji-mobile { text-align: center; color: #999; padding: 15px; }
.custom-smile {
    max-width: 50px; max-height: 50px; vertical-align: middle;
    border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); cursor: pointer;
}
.custom-smile:hover { transform: scale(1.05); }