html.page-chat,
html.page-chat body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

html.page-chat body {
    display: flex;
    flex-direction: column;
}

.page-chat .site-nav {
    position: relative;
    flex-shrink: 0;
}

.page-chat .site-footer {
    display: none;
}

.chat-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-atmosphere {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 8% 0%, rgba(61, 27, 123, 0.45), transparent 42%),
        radial-gradient(ellipse at 92% 100%, rgba(212, 196, 160, 0.08), transparent 46%);
    z-index: 0;
}

.chat-atmosphere::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.22;
    background-image:
        linear-gradient(rgba(212, 196, 160, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 196, 160, 0.04) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 80%);
}

.chat-app {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(280px, 22vw) minmax(0, 1fr) minmax(240px, 18vw);
    gap: 0;
}

.chat-rail,
.chat-thread,
.chat-people {
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: 0;
    background: rgba(12, 7, 22, 0.78);
    backdrop-filter: blur(16px);
}

.chat-rail {
    border-right: 1px solid var(--hairline);
}

.chat-people {
    border-left: 1px solid var(--hairline);
}

.chat-rail-head,
.chat-people-head {
    flex-shrink: 0;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--hairline);
}

.chat-rail-title,
.chat-people-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.15;
}

.chat-room-list,
.chat-log,
.chat-people-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.chat-room-list {
    padding: 8px;
}

.chat-room-btn {
    width: 100%;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px 10px;
    margin-bottom: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.chat-room-btn:hover,
.chat-room-btn.is-active {
    border-color: var(--hairline);
    background: rgba(212, 196, 160, 0.07);
}

.chat-room-btn.is-active {
    box-shadow: inset 2px 0 0 var(--accent);
}

.chat-room-mark {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--hairline);
    color: var(--accent);
    background: rgba(61, 27, 123, 0.35);
    line-height: 1;
    font-size: 1.85rem;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

.chat-room-mark i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    font-size: 1.45rem;
    line-height: 1;
}

.chat-room-emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    font-size: 1.85rem;
    line-height: 1;
    font-style: normal;
}

.chat-room-btn strong {
    display: block;
    font-size: 0.92rem;
    color: var(--text);
}

.chat-room-preview {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-thread-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 4px 12px;
    min-height: 34px;
    border-bottom: 1px solid var(--hairline);
}

.chat-thread-identity {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.chat-thread-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-thread-kicker {
    margin: 0;
    flex-shrink: 0;
    font-size: 0.58rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}

.chat-thread-sub {
    margin: 0 0 0 auto;
    flex-shrink: 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.chat-icon-btn {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--hairline);
    background: rgba(16, 8, 28, 0.8);
    color: var(--accent);
    cursor: pointer;
}

.chat-pin {
    flex-shrink: 0;
    margin: 10px 14px 0;
    padding: 10px 12px;
    border: 1px solid rgba(212, 196, 160, 0.28);
    background: rgba(212, 196, 160, 0.08);
    color: var(--accent-strong);
    font-size: 0.9rem;
}

.chat-pin strong {
    display: block;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.chat-banner {
    flex-shrink: 0;
    margin: 10px 14px 0;
    padding: 10px 12px;
    border: 1px solid rgba(255, 59, 107, 0.35);
    background: rgba(255, 59, 107, 0.1);
    color: #ffd0da;
    font-size: 0.88rem;
}

.chat-log {
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-empty {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    padding: 24px 12px;
}

.chat-empty i {
    display: block;
    font-size: 1.6rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.chat-msg {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
    align-items: end;
    max-width: 86%;
}

.chat-msg.is-mine {
    margin-left: auto;
    grid-template-columns: minmax(0, 1fr) 36px;
}

.chat-msg.is-announce {
    max-width: 100%;
    grid-template-columns: 1fr;
    margin: 6px 0;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--hairline);
    background: #160c26;
}

.chat-bubble {
    padding: 10px 14px 8px;
    border: 1px solid var(--hairline);
    background: rgba(22, 12, 38, 0.92);
}

.chat-bubble-name {
    display: block;
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--accent);
    margin-bottom: 2px;
}

.chat-bubble p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
    font-size: 1.02rem;
}

.chat-bubble time {
    display: block;
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-msg.is-mine .chat-bubble {
    background: linear-gradient(180deg, rgba(61, 27, 123, 0.72), rgba(22, 12, 38, 0.95));
    border-color: rgba(212, 196, 160, 0.28);
}

.chat-msg.is-mine .chat-bubble-name {
    display: none;
}

.chat-announce {
    text-align: center;
    padding: 10px 16px;
    border: 1px dashed rgba(212, 196, 160, 0.4);
    color: var(--accent-strong);
    font-family: var(--font-display);
    font-size: 1.05rem;
}

.chat-msg-actions {
    display: none;
    gap: 6px;
    margin-top: 6px;
}

body.is-admin .chat-msg-actions {
    display: flex;
    flex-wrap: wrap;
}

.chat-msg-actions button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 0;
}

.chat-msg-actions button:hover {
    color: var(--live);
}

.chat-compose-wrap {
    flex-shrink: 0;
    padding: 6px 12px 4px;
    border-top: 1px solid var(--hairline);
}

.chat-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.chat-form {
    display: grid;
    gap: 4px;
    position: relative;
}

.chat-compose-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 48px;
    gap: 8px;
    align-items: end;
}

.chat-emoji-btn {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--hairline);
    background: rgba(16, 8, 28, 0.85);
    color: var(--accent);
    cursor: pointer;
    font-size: 1.2rem;
}

.chat-emoji-btn:hover,
.chat-emoji-btn.is-open {
    background: rgba(212, 196, 160, 0.14);
    border-color: var(--accent);
}

.chat-form textarea {
    width: 100%;
    resize: none;
    min-height: 46px;
    max-height: 140px;
    padding: 12px 14px;
    border: 1px solid var(--hairline);
    background: rgba(8, 5, 16, 0.85);
    color: var(--text);
    font: inherit;
    line-height: 1.4;
}

.chat-emoji-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    max-height: 280px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--hairline);
    background: rgba(10, 6, 20, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    z-index: 6;
}

.chat-form[hidden],
.chat-emoji-panel[hidden] {
    display: none !important;
}

.chat-emoji-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--hairline);
}

.chat-emoji-cats {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    flex: 1;
    min-width: 0;
}

.chat-emoji-cat {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
}

.chat-emoji-cat.is-active,
.chat-emoji-cat:hover {
    border-color: var(--hairline);
    background: rgba(212, 196, 160, 0.1);
}

.chat-emoji-search {
    width: min(150px, 38%);
    flex-shrink: 0;
    padding: 8px 10px;
    border: 1px solid var(--hairline);
    background: rgba(8, 5, 16, 0.9);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 2px;
    padding: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.chat-emoji-grid button {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 1.45rem;
    line-height: 1;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

.chat-emoji-grid button:hover {
    background: rgba(212, 196, 160, 0.12);
}

.chat-form textarea:focus {
    outline: 1px solid var(--accent);
}

.chat-form-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.chat-form-bar span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-send {
    width: 42px;
    height: 42px;
    border: 1px solid var(--accent);
    border-radius: 50%;
    background: rgba(212, 196, 160, 0.12);
    color: var(--accent);
    cursor: pointer;
}

.chat-send:hover {
    background: var(--accent);
    color: #1a1028;
}

.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-people-list {
    padding: 10px 12px 16px;
}

.chat-person {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 7px 4px;
}

.chat-person img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--hairline);
}

.chat-person strong {
    display: block;
    font-size: 0.85rem;
}

.chat-person span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.chat-person-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #43b581;
    box-shadow: 0 0 8px rgba(67, 181, 129, 0.7);
    display: inline-block;
    margin-right: 4px;
}

/* Offline salon */
body.page-chat:not(.is-live) .chat-rail-title,
body.page-chat:not(.is-live) .chat-thread-head h2 {
    letter-spacing: 0.04em;
}

body.page-chat:not(.is-live) .chat-bubble {
    border-radius: 2px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

body.page-chat:not(.is-live) .chat-room-mark {
    border-radius: 2px;
}

/* Live messenger */
body.page-chat.is-live .chat-rail,
body.page-chat.is-live .chat-thread,
body.page-chat.is-live .chat-people {
    background: rgba(10, 8, 18, 0.88);
}

body.page-chat.is-live .chat-bubble {
    border-radius: 18px 18px 18px 6px;
}

body.page-chat.is-live .chat-msg.is-mine .chat-bubble {
    border-radius: 18px 18px 6px 18px;
    background: linear-gradient(180deg, #5b2bb5, #3d1b7b);
    border-color: transparent;
}

body.page-chat.is-live .chat-thread {
    box-shadow: 0 0 0 1px rgba(255, 59, 107, 0.18), 0 20px 50px rgba(0, 0, 0, 0.35);
}

body.page-chat.is-live .chat-room-mark {
    border-radius: 16px;
}

body.page-chat.is-live .chat-thread-kicker {
    color: var(--live);
}

@media (max-width: 980px) {
    .chat-app {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .chat-rail,
    .chat-people {
        position: absolute;
        top: 0;
        bottom: 0;
        width: min(320px, 86vw);
        z-index: 4;
        display: none;
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
        background: rgba(10, 6, 20, 0.96);
    }

    .chat-rail {
        left: 0;
        border-right: 1px solid var(--hairline);
    }

    .chat-people {
        right: 0;
        border-left: 1px solid var(--hairline);
    }

    .chat-app.is-rooms .chat-rail,
    .chat-app.is-people .chat-people {
        display: flex;
    }

    .chat-icon-btn {
        display: inline-flex;
    }
}

@media (max-width: 640px) {
    .chat-msg {
        max-width: 94%;
    }

    .chat-emoji-toolbar {
        flex-wrap: wrap;
    }

    .chat-emoji-search {
        width: 100%;
    }
}
