:root {
    --font-display: 'Oxanium', monospace;
    --font-body: 'Rajdhani', sans-serif;
    --bg: #101114;
    --panel: #181a20;
    --panel-strong: #20232b;
    --surface: #262a33;
    --surface-hover: #303641;
    --line: #373d49;
    --text: #f4f7fb;
    --muted: #9aa4b2;
    --accent: #7c5cff;
    --accent-2: #22c3a6;
    --danger: #f04438;
    --shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
}

body {
    min-width: 320px;
}

button,
input {
    font: inherit;
    line-height: 1;
}

.app-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 12px;
    width: 100%;
    height: 100vh;
    padding: 12px;
}

.content-area,
.chat-container {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.content-area {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 10px;
}

.player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: var(--panel-strong);
    border-bottom: 1px solid var(--line);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 190px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #eef5ff;
    color: #141820;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-block h1 {
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-block p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.player-btn,
.dropdown-btn,
.utility-btn,
.apply-btn,
.chat-option,
.chat-title span,
.share-panel button {
    font-family: var(--font-display);
}

.side-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--panel-strong);
    border-bottom: 1px solid var(--line);
}

.utility-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.utility-btn:hover {
    background: var(--surface-hover);
    border-color: #4b5361;
}

.utility-btn img {
    display: block;
    width: 17px;
    height: 17px;
    object-fit: contain;
}

.player-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.player-btn-group {
    position: relative;
    display: flex;
    align-items: stretch;
    min-width: 0;
}

.player-btn,
.dropdown-btn,
.apply-btn,
.chat-option {
    border: 1px solid var(--line);
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.player-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    min-height: 38px;
    padding: 0 13px;
    border-radius: 8px 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.player-btn img,
.chat-option img {
    display: block;
    width: 17px;
    height: 17px;
    object-fit: contain;
    flex: 0 0 auto;
}

.player-btn:hover,
.dropdown-btn:hover,
.chat-option:hover {
    background: var(--surface-hover);
    border-color: #4b5361;
}

.player-btn.active,
.chat-selector.active {
    background: rgba(124, 92, 255, 0.16);
    border-color: var(--accent);
    color: white;
    box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.18);
}

.dropdown-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 38px;
    min-height: 38px;
    border-left: 0;
    border-radius: 0 8px 8px 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.dropdown-btn::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.dropdown-input {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    display: none;
    width: min(340px, calc(100vw - 32px));
    padding: 10px;
    background: #1b1e26;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

.dropdown-input.show {
    display: block;
}

.dropdown-input label {
    display: block;
    margin-bottom: 7px;
    color: #c4cad4;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.dropdown-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 6px;
}

.channel-input {
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    background: #151821;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    outline: none;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.channel-input::placeholder {
    color: #687282;
}

.channel-input:focus {
    background: #12151d;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.14);
}

.apply-btn {
    height: 38px;
    padding: 0;
    border-radius: 7px;
    background: rgba(124, 92, 255, 0.16);
    border-color: rgba(124, 92, 255, 0.56);
    color: #f6f4ff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
}

.apply-btn:hover {
    background: rgba(124, 92, 255, 0.24);
    border-color: var(--accent);
}

.player-container {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: #030405;
}

.empty-player {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: none;
    place-items: center;
    background: #030405;
    color: var(--muted);
    text-align: center;
}

.empty-player.show {
    display: grid;
}

.empty-player strong {
    font-family: var(--font-display);
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 800;
}

.player-iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #050607;
}

.player-iframe.vk-player-iframe {
    width: calc(100% + 18px);
    max-width: none;
}

.chat-container {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    border-radius: 10px;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px;
    background: var(--panel-strong);
    border-bottom: 1px solid var(--line);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    line-height: 1;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.icon-btn:hover,
.icon-btn.active {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.chat-title span {
    display: block;
    font-size: 15px;
    font-weight: 800;
}

.chat-title {
    margin-right: auto;
}

.chat-selector {
    min-width: 118px;
    text-align: left;
}

.chat-menu {
    width: 190px;
}

.chat-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    margin-bottom: 7px;
    padding: 0 10px;
    border-radius: 8px;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.chat-option:last-child {
    margin-bottom: 0;
}

.chat-option.active {
    background: rgba(124, 92, 255, 0.2);
    border-color: var(--accent);
}

.chat-iframe {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    background: #111318;
}

#player-loader {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    background: rgba(3, 4, 5, 0.52);
    transition: opacity 0.3s ease;
}

.loader-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.share-panel {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1100;
    display: grid;
    grid-template-columns: minmax(220px, 420px) auto auto;
    gap: 8px;
    max-width: calc(100vw - 36px);
    padding: 10px;
    background: #20242c;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
}

.share-panel input {
    min-width: 0;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #12151b;
    color: var(--text);
    outline: none;
}

.share-panel button {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.share-panel button:hover {
    background: var(--surface-hover);
}

.status-indicator {
    position: absolute;
    top: -5px;
    right: -6px;
    width: 10px;
    height: 10px;
    border: 2px solid var(--panel-strong);
    border-radius: 50%;
    background: #6e7785;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.status-indicator.online {
    opacity: 1;
    transform: scale(1);
    background: #21d07a;
    box-shadow: 0 0 0 4px rgba(33, 208, 122, 0.16);
}

.status-indicator.checking {
    background: #f0b429;
    box-shadow: 0 0 0 4px rgba(240, 180, 41, 0.14);
}

.status-indicator.error {
    background: #6e7785;
    box-shadow: none;
}

.status-indicator.offline {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(240, 68, 56, 0.18);
}

.theater-mode {
    overflow: hidden;
}

.theater-mode .app-container {
    gap: 0;
    padding: 0;
}

.theater-mode .content-area,
.theater-mode .chat-container {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.theater-mode .player-header,
.theater-mode .side-actions {
    display: none;
}

.theater-mode .content-area {
    grid-template-rows: minmax(0, 1fr);
}

.theater-mode .chat-container {
    grid-template-rows: auto minmax(0, 1fr);
}

.theater-mode .chat-header {
    border-bottom: 1px solid #242832;
    background: #181a20;
}

.theater-mode .player-iframe,
.theater-mode .chat-iframe {
    border-radius: 0;
}

@media (max-width: 1100px) {
    .app-container {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .brand-block {
        min-width: 170px;
    }
}

@media (max-width: 860px) {
    html,
    body {
        overflow: auto;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(480px, 64vh) minmax(320px, 36vh);
        min-height: 100vh;
        height: auto;
    }

    .player-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .player-buttons {
        justify-content: flex-start;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .app-container {
        padding: 8px;
        gap: 8px;
        grid-template-rows: minmax(430px, 62vh) minmax(300px, 38vh);
    }

    .brand-block {
        min-width: 0;
    }

    .brand-mark {
        width: 34px;
        height: 34px;
    }

    .brand-block h1 {
        font-size: 15px;
    }

    .player-btn-group {
        flex: 1 1 142px;
    }

    .player-btn {
        flex: 1;
        min-width: 0;
        padding: 0 10px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dropdown-input {
        left: 0;
        right: auto;
    }

    .chat-header {
        align-items: center;
        flex-direction: row;
    }

    .share-panel {
        left: 8px;
        right: 8px;
        grid-template-columns: 1fr;
    }
}
