:root {
    --bg: #121214;
    --panel: #1c1c21;
    --line: #2c2c33;
    --text: #e8e8ec;
    --muted: #8b8b96;
    --accent: #ff4e45;
    --ok: #3ccf7a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
    font-size: 15px;
}

h1, h2 { margin: 0 0 8px; }
h2 { font-size: 15px; }
a { color: var(--text); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

input, button {
    font: inherit;
    color: var(--text);
    background: #26262d;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
}
input { width: 100%; }
input:focus { outline: 1px solid var(--accent); }
button { cursor: pointer; white-space: nowrap; background: var(--accent); border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button.ghost { background: transparent; border-color: var(--line); }
button.small { padding: 2px 8px; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}
.row { display: flex; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.small-text { font-size: 13px; margin: 0; }

/* ---------- 로비 ---------- */
.lobby { max-width: 560px; margin: 40px auto; padding: 0 16px; }
.lobby label { display: block; margin-bottom: 6px; }
.room-list { list-style: none; padding: 0; margin: 0; }
.room-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.warning {
    background: #3a2a12; border: 1px solid #7a5a20; border-radius: 10px;
    padding: 10px 14px; margin-bottom: 12px; line-height: 1.5;
}

/* ---------- 방 ---------- */
.topbar {
    display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
    padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.topbar h1 {
    font-size: 18px; margin: 0; flex: 1 1 160px; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge { white-space: nowrap; }
.home { text-decoration: none; font-size: 20px; }
.status { font-size: 13px; }
.status.online { color: var(--ok); }
.status.offline { color: var(--accent); }

.room {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
}
@media (max-width: 860px) { .room { grid-template-columns: 1fr; } }

/* YouTube 정책상 플레이어는 최소 200x200 이상 보이게 둔다 */
.player-wrap { width: 100%; aspect-ratio: 16 / 9; margin-bottom: 12px; border-radius: 12px; overflow: hidden; background: #000; }
.player-wrap.small { width: min(356px, 100%); height: 200px; aspect-ratio: auto; }

.now-label { font-size: 12px; color: var(--accent); font-weight: 600; }
.now-title { font-size: 18px; font-weight: 600; margin: 4px 0; }
.replaced { margin-top: 6px; font-size: 13px; color: #f5c46b; }
.progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: 12px; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: var(--accent); transition: width .5s linear; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.controls { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.volume { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.volume input { width: 120px; padding: 0; }

/* 방장/일반 사용자 화면 구분 (서버에서도 권한을 검사함) */
body:not(.is-host) .host-only { display: none !important; }
body.is-host .guest-only { display: none !important; }
.badge { font-size: 13px; color: #f5c46b; }
.code-badge {
    font-size: 13px; padding: 4px 10px; border-radius: 8px;
    background: #26262d; border: 1px solid var(--line); white-space: nowrap;
}
button.danger { color: var(--accent); border-color: #5a2a28; }

.progress.seekable { cursor: pointer; height: 10px; }
.progress.seekable:hover #progressBar { background: #ff7a73; }

.playlist { margin: 0; padding-left: 26px; }
.playlist li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.playlist li.playing::marker { color: var(--accent); }
.playlist li.playing .q-title { color: var(--accent); }
.playlist .track {
    flex: 1; text-align: left; background: transparent; border: none;
    padding: 8px 4px; white-space: normal; border-radius: 6px;
}
.playlist .track:hover { background: #26262d; }
.q-title { font-weight: 500; }

.members { list-style: none; padding: 0; margin: 0; }
.members li { padding: 3px 0; }

.chat { display: flex; flex-direction: column; height: 480px; }
.chat-log { flex: 1; overflow-y: auto; margin-bottom: 8px; font-size: 14px; }
.msg { padding: 3px 0; word-break: break-word; }
.msg.system { color: var(--muted); font-size: 13px; }

.overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .75);
    display: flex; align-items: center; justify-content: center; z-index: 10;
}
.overlay-box { background: var(--panel); padding: 24px 28px; border-radius: 14px; text-align: center; }
.overlay-box button { font-size: 17px; padding: 10px 24px; }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 6px; }
.toast { background: #2e2e36; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; max-width: 90vw; }
