/* 라운지(공개 채팅). 토큰·헤더는 base.css */

body {
    height: 100vh;
    overflow: hidden;
}

/* ── 레이아웃 ────────────────────────────────────── */
.chat-wrap {
    max-width: 1240px;
    height: calc(100vh - var(--header-h));
    margin: 0 auto;
    padding: 18px 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 14px;
}

.chat-panel,
.people {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-height: 0;
}

.chat-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── 방 헤더 ─────────────────────────────────────── */
.chat-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--border);
}

.chat-head h1 { font-size: 1.05rem; font-weight: 700; }
.room-sub { color: var(--muted); font-size: .78rem; margin-top: 4px; }

.head-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.head-tools .danger {
    background: transparent;
    color: #fca5a5;
    border: 1px solid #7f1d1d;
    border-radius: 999px;
    padding: 5px 11px;
    font: inherit;
    font-size: .74rem;
    cursor: pointer;
}

.head-tools .danger:hover:not(:disabled) { background: rgba(239, 68, 68, .14); border-color: #ef4444; }
.head-tools .danger:disabled { opacity: .45; cursor: not-allowed; }

.conn {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    font-size: .76rem;
    color: var(--muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 11px;
}

.conn .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
}

.conn[data-state="online"] .dot { background: #22c55e; }
.conn[data-state="online"] { color: #86efac; }
.conn[data-state="connecting"] .dot { background: #eab308; animation: pulse 1.2s ease-in-out infinite; }
.conn[data-state="offline"] .dot { background: #ef4444; }
.conn[data-state="offline"] { color: #fca5a5; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ── 메시지 목록 ─────────────────────────────────── */
.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 18px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid var(--surface); }

.placeholder {
    margin: auto;
    color: var(--muted);
    font-size: .84rem;
}

.msg {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    padding: 2px 0;
}

.msg + .msg.stacked { margin-top: 0; }
.msg:not(.stacked) { margin-top: 12px; }

.msg .avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 50%;
    user-select: none;
}

.msg.stacked .avatar { visibility: hidden; height: 0; }

.msg-body { min-width: 0; }

.msg-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 3px;
}

.msg-name { font-size: .82rem; font-weight: 600; }
.msg-time { color: var(--muted); font-size: .68rem; }

.msg-you {
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--blue);
    border: 1px solid var(--blue);
    border-radius: 4px;
    padding: 0 4px;
}

.bubble {
    display: inline-block;
    max-width: min(100%, 640px);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px 10px 10px 10px;
    padding: 7px 11px;
    font-size: .9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg.mine .bubble {
    background: #5b4bd8;
    border-color: #6d5ff0;
    color: #f4f2ff;
}

.msg.stacked .bubble { border-radius: 10px; }

.bubble a { color: #cfc8ff; }

.sys {
    align-self: center;
    max-width: 90%;
    margin: 10px 0 2px;
    color: var(--muted);
    font-size: .74rem;
    text-align: center;
    background: rgba(148, 163, 184, .08);
    border-radius: 999px;
    padding: 4px 12px;
}

.day-mark {
    align-self: center;
    margin: 14px 0 2px;
    color: var(--muted);
    font-size: .7rem;
    letter-spacing: .06em;
}

/* ── 새 메시지 버튼 ──────────────────────────────── */
.jump {
    position: absolute;
    left: 50%;
    bottom: 148px;
    transform: translateX(-50%);
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 7px 15px;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .6);
}

.jump:hover { background: var(--accent-hover); }

/* ── 입력 중 표시 ────────────────────────────────── */
.typing {
    height: 18px;
    padding: 0 18px;
    color: var(--muted);
    font-size: .74rem;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 작성 영역 ───────────────────────────────────── */
.composer {
    border-top: 1px solid var(--border);
    padding: 12px 18px 14px;
}

.me {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
    font-size: .8rem;
}

.me .avatar { font-size: 1rem; }
.me-name { font-weight: 600; }

.reroll {
    margin-left: auto;
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 9px;
    font: inherit;
    font-size: .74rem;
    cursor: pointer;
}

.reroll:hover:not(:disabled) { color: var(--text); border-color: var(--blue); }
.reroll:disabled { opacity: .45; cursor: not-allowed; }

.input-row { display: flex; align-items: flex-end; gap: 8px; }

#input {
    flex: 1;
    min-height: 42px;
    max-height: 160px;
    resize: none;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
    font-size: .9rem;
    line-height: 1.5;
}

#input:focus { outline: none; border-color: var(--blue); }
#input:disabled { opacity: .5; }

#send {
    height: 42px;
    flex-shrink: 0;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 18px;
    font: inherit;
    font-size: .86rem;
    font-weight: 600;
    cursor: pointer;
}

#send:hover:not(:disabled) { background: var(--accent-hover); }
#send:disabled { background: var(--surface2); color: var(--muted); cursor: not-allowed; }

.composer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 7px;
    font-size: .72rem;
    color: var(--muted);
    min-height: 15px;
}

.hint.error { color: #fca5a5; }
.count.over { color: #fca5a5; }

/* ── 접속자 목록 ─────────────────────────────────── */
.people {
    display: flex;
    flex-direction: column;
    padding: 16px 0 0;
}

.people-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--border);
}

.people-head h2 { font-size: .9rem; font-weight: 600; }

.badge {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 9px;
}

.people-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    list-style: none;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.people-list li {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 7px;
    font-size: .82rem;
}

.people-list li.self { background: var(--surface2); }

.people-list .avatar {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: .88rem;
}

.people-list .name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.people-list .tag {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--blue);
    font-size: .66rem;
    font-weight: 700;
}

.people-list li.away { opacity: .45; }

.people-note {
    border-top: 1px solid var(--border);
    padding: 12px 16px 14px;
    color: var(--muted);
    font-size: .7rem;
    line-height: 1.6;
}

/* ── 반응형 ──────────────────────────────────────── */
@media (max-width: 900px) {
    body { overflow: auto; }

    .chat-wrap {
        grid-template-columns: 1fr;
        height: auto;
        padding: 12px 12px 24px;
    }

    .chat-panel { height: calc(100vh - var(--header-h) - 24px); }
    .people { max-height: 320px; }
    .jump { bottom: 160px; }
}
