/* ============================================================================
   공개방(혼술바) — 메인 카드 배지/안내 버튼, 입장 시트, 방 채팅 UI, 프로필 사진
   로드 순서: style.css → freetalk.css → room.css
   z-index: 입장 시트 1900 < group-modal/crop-modal 2000 < custom-alert 9999
   ============================================================================ */

.character-card[hidden] { display: none !important; }

/* ── 메인 카드: 공개방 리본 + 안내(i) ── */
.character-card__room-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #d6335c, #8f1d43);
    border: 1px solid rgba(255, 220, 232, 0.5);
    color: #ffe3ec;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.character-card__multi-badge {
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    padding: 0.2rem 0.52rem 0.2rem 0.42rem;
    border-radius: 999px;
    background: rgba(20, 14, 22, 0.62);
    border: 1px solid rgba(255, 170, 200, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #ffe3ec;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}
.character-card__multi-icon { width: 0.82rem; height: 0.82rem; flex: none; }
@media (max-width: 480px) {
    .character-card__multi-badge { top: 0.35rem; right: 0.35rem; padding: 0.16rem 0.42rem 0.16rem 0.34rem; font-size: 0.62rem; }
    .character-card__multi-icon { width: 0.74rem; height: 0.74rem; }
}

.character-card__room-info {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 5;
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: rgba(8, 2, 6, 0.72);
    border: 1px solid rgba(255, 229, 173, 0.6);
    color: #ffe5ad;
    font: italic 800 0.95rem/1 Georgia, 'Times New Roman', serif;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}
.character-card__room-count {
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    max-width: calc(100% - 1rem);
    padding: 0.16rem 0.5rem;
    border-radius: 999px;
    background: rgba(8, 2, 6, 0.74);
    border: 1px solid rgba(255, 229, 173, 0.35);
    color: #fff3d6;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}
.character-card__room-count[hidden] { display: none !important; }
.character-card__room-count-dot {
    flex: none;
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: #4be38b;
    box-shadow: 0 0 6px rgba(75, 227, 139, 0.8);
}
.character-card__room-count.is-quiet { color: rgba(255, 243, 214, 0.78); }
.character-card__room-count.is-quiet .character-card__room-count-dot { background: #a6a0b3; box-shadow: none; }
.character-card__room-count-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
@media (orientation: landscape) and (max-height: 500px) {
    .character-card--room .character-card__info {
        padding-bottom: 0.2rem;
    }
    .character-card__room-count {
        top: 0.2rem;
        left: 0.2rem;
        padding: 0.06rem 0.3rem;
        font-size: 0.56rem;
        line-height: 1;
    }
}

.character-card__room-info:hover,
.character-card__room-info:focus-visible {
    background: #ffe5ad;
    color: #2a0b16;
    outline: 2px solid #fff;
    outline-offset: 2px;
}
/* 터치 영역은 눈에 보이는 크기보다 넓게 */
.character-card__room-info::after { content: ''; position: absolute; inset: -0.35rem; }

.character-card__room-notice {
    display: block;
    color: #ffd2e0;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
}

.profile__room-notice {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    background: rgba(214, 51, 92, 0.14);
    border: 1px solid rgba(214, 51, 92, 0.4);
    color: #ffd2e0;
    font-size: 0.82rem;
    line-height: 1.5;
}
.profile__room-notice[hidden] { display: none; }

/* 안내 팝업(커스텀 알림 안) */
.room-help { text-align: left; font-size: 0.86rem; line-height: 1.6; }
.room-help ul { margin: 0; padding-left: 1.1rem; }
.room-help li { margin: 0.3rem 0; }

/* ── 입장 시트 ── */
.room-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 1900;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.66);
    padding: env(safe-area-inset-top, 0) 0 0;
}
.room-sheet {
    width: min(100%, 460px);
    max-height: 92dvh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    background: linear-gradient(180deg, #1d0a13, #100409);
    border: 1px solid rgba(230, 190, 96, 0.22);
    color: var(--text-main, #f0e6e9);
}
@media (min-width: 640px) {
    .room-sheet-overlay { align-items: center; }
    .room-sheet { border-radius: 18px; }
}
.room-sheet__title { margin: 0 0 0.4rem; font-size: 1.1rem; }
.room-sheet__lead { margin: 0 0 0.8rem; color: var(--text-muted, #a38d97); font-size: 0.85rem; line-height: 1.5; }
.room-sheet__rows { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 0.8rem; margin: 0 0 0.8rem; font-size: 0.86rem; }
.room-sheet__rows dt { color: var(--text-muted, #a38d97); }
.room-sheet__rows dd { margin: 0; overflow-wrap: anywhere; }
.room-sheet__photo { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.4rem; }
.room-sheet__photo-img {
    display: inline-block;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: rgba(214, 51, 92, 0.18) center/cover no-repeat;
    border: 1px solid rgba(255, 255, 255, 0.18);
    overflow: hidden;
    flex: 0 0 56px;
}
.room-sheet__photo-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.room-sheet__hint { margin: 0 0 0.5rem; color: #ffb3c6; font-size: 0.82rem; }
.room-sheet__hint[hidden] { display: none; }
.room-sheet__notice { margin: 0 0 0.5rem; color: rgba(246, 235, 239, 0.8); font-size: 0.8rem; line-height: 1.5; }
.room-sheet__status { min-height: 1.1em; margin: 0 0 0.6rem; color: var(--accent, #e6be60); font-size: 0.8rem; }
.room-sheet__actions { display: flex; gap: 0.5rem; }
.room-sheet__btn {
    flex: 1;
    min-height: 44px;
    padding: 0 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.07);
    color: inherit;
    font-size: 0.88rem;
    cursor: pointer;
}
.room-sheet__btn--primary { background: linear-gradient(135deg, #d6335c, #9a2349); border-color: rgba(255, 220, 232, 0.4); font-weight: 800; }
.room-sheet__btn:disabled { opacity: 0.45; cursor: not-allowed; }
.room-sheet__photo .room-sheet__btn { flex: 0 0 auto; }

/* ── 설정 모달: 프로필 사진 ── */
.settings-photo { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.settings-photo[hidden] { display: none; }
.settings-photo__label { font-size: 0.85rem; color: var(--text-muted); }
.settings-photo__row { display: flex; align-items: center; gap: 12px; }
.settings-photo__preview {
    display: inline-block; width: 64px; height: 64px; flex: 0 0 64px; border-radius: 50%;
    background: rgba(214, 51, 92, 0.18); border: 1px solid rgba(255, 255, 255, 0.18); overflow: hidden;
}
.settings-photo__preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.settings-photo__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-photo__hint { margin: 0; font-size: 0.78rem; line-height: 1.5; color: var(--text-muted); }
.settings-photo__status { margin: 0; min-height: 1.1em; font-size: 0.78rem; color: var(--accent); }

/* 공개방에서는 초기화 UI를 숨긴다 */
#settings-reset-section[hidden] { display: none !important; }

/* ── 방 채팅 UI ── */
.ft-room-mode .ft-room-badge {
    display: inline-block; margin-left: 0.4rem; padding: 0.1rem 0.45rem; border-radius: 999px;
    background: rgba(214, 51, 92, 0.85); color: #fff; font-size: 0.65rem; font-weight: 800; vertical-align: middle;
}
.ft-room-count {
    display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.6rem; border-radius: 999px;
    background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text-main, #f0e6e9); font-size: 0.78rem; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ft-room-banner {
    margin: 0 0 0.4rem; padding: 0.35rem 0.7rem; border-radius: 10px;
    background: rgba(230, 190, 96, 0.12); border: 1px solid rgba(230, 190, 96, 0.28);
    color: #ffe5ad; font-size: 0.78rem; line-height: 1.4; text-align: center;
}
.ft-room-banner[hidden] { display: none; }
.ft-send-btn.is-room-locked, .ft-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* 다른 유저 메시지: AI 캐릭터 대사(.ft-log-msg.assistant)와 같은 말풍선 + 왼쪽 정렬. 구분은 닉네임 색·성별 아이콘으로만 한다. */
.ft-log-msg.peer {
    align-self: flex-start;
    max-width: min(72%, 650px);
    margin-left: clamp(0px, 0.7vw, 10px);
    background: linear-gradient(180deg, rgba(32, 8, 18, 0.82), rgba(18, 4, 11, 0.94));
    color: var(--text-main, #f0e6e9);
    border: 1px solid rgba(230, 190, 96, 0.095);
    border-bottom-left-radius: 4px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}
.ft-log-msg.peer[hidden] { display: none; }
.ft-peer-nick {
    appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 800;
    cursor: pointer; text-align: left; color: #8fc1ff;
}
.ft-peer-nick:focus-visible, .ft-peer-avatar:focus-visible { outline: 2px solid #ffe5ad; outline-offset: 2px; border-radius: 6px; }
.ft-peer-color-0 { color: #8fc1ff; }
.ft-peer-color-1 { color: #ffb86b; }
.ft-peer-color-2 { color: #8be3b0; }
.ft-peer-color-3 { color: #f09ad6; }
.ft-peer-color-4 { color: #d3c3ff; }
.ft-peer-age, .ft-peer-card__age { font-weight: 600; color: var(--text-muted, #c4aeb8); font-size: 0.9em; white-space: nowrap; }
.ft-peer-card__age[hidden] { display: none; }
.ft-gender-icon { display: inline-block; margin-left: 0.3rem; font-size: 0.8rem; font-weight: 800; vertical-align: baseline; }
.ft-gender-m { color: #7db8ff; }
.ft-gender-f { color: #ff8fb7; }
.ft-gender-x { color: #c9b8ff; }

/* VN 모드: 사진 없음, 닉네임 텍스트만 */
.freetalk-overlay.ft-mode-vn .ft-log-msg.peer .ft-peer-avatar { display: none; }

/* 채팅 모드: 사진 + 닉네임 */
.freetalk-overlay.ft-mode-chatbot .ft-log-msg.peer {
    align-self: stretch; justify-content: flex-start; max-width: 100%;
    background: transparent; border: none; box-shadow: none;
}
.freetalk-overlay.ft-mode-chatbot .ft-log-msg.peer .ft-log-content { border-bottom-left-radius: 4px; }
.freetalk-overlay.ft-mode-chatbot .ft-log-msg.peer .ft-log-name { color: inherit; margin-bottom: 0; }
.freetalk-overlay.ft-mode-chatbot .ft-peer-avatar { overflow: hidden; font-size: 0; }
.freetalk-overlay.ft-mode-chatbot .ft-peer-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.freetalk-overlay.ft-mode-chatbot .ft-peer-avatar--empty::before { content: '👤'; font-size: 1.2rem; }
.freetalk-overlay.ft-mode-chatbot .ft-peer-avatar--empty { background: rgba(120, 160, 230, 0.18); }

/* 프로필 카드 팝오버 */
.ft-peer-card {
    position: absolute; z-index: 30; box-sizing: border-box; padding: 0.8rem; border-radius: 14px;
    background: #17121c; border: 1px solid rgba(230, 190, 96, 0.3); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
    color: var(--text-main, #f0e6e9);
}
.ft-peer-card__head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.ft-peer-card__photo {
    display: inline-block; width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; overflow: hidden;
    background: rgba(120, 160, 230, 0.18);
}
.ft-peer-card__photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ft-peer-card__who { min-width: 0; overflow-wrap: anywhere; }
.ft-peer-card__intro { margin: 0 0 0.4rem; font-size: 0.84rem; line-height: 1.5; overflow-wrap: anywhere; }
.ft-peer-card__intro.is-empty { color: var(--text-muted, #a38d97); }
.ft-peer-card__tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }
.ft-peer-card__tag { padding: 0.1rem 0.5rem; border-radius: 999px; background: rgba(230, 190, 96, 0.12); border: 1px solid rgba(230, 190, 96, 0.28); color: #ffe5ad; font-size: 0.74rem; }
.ft-peer-card__actions { display: flex; gap: 0.4rem; }
.ft-peer-card__btn { flex: 1; min-height: 36px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.06); color: inherit; font-size: 0.78rem; cursor: pointer; }

.settings-photo__hint--warn { color: #ffb3c6; }

/* 하렘클럽: 받는 손님 칩(호스트 말풍선 이름 줄) · 대화 목록 안 '생각 중' 말풍선 */
.ft-room-to-chip {
    display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.45rem; border-radius: 999px;
    background: rgba(214, 51, 92, 0.14); border: 1px solid rgba(214, 51, 92, 0.3);
    color: var(--text-muted, #e9c9d4); font-size: 0.72rem; font-weight: 600; line-height: 1.5;
    vertical-align: middle; white-space: nowrap; max-width: 12rem; overflow: hidden; text-overflow: ellipsis;
}
.ft-room-thinking .ft-thinking-body { gap: 0.45rem; }
.ft-room-thinking__text { color: var(--text-muted, #c4aeb8); font-size: 0.86rem; }

.photo-upload-progress {
    height: 6px;
    width: 100%;
    margin-top: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 229, 173, 0.12);
    border: 1px solid rgba(255, 229, 173, 0.2);
}
.photo-upload-progress[hidden] { display: none !important; }
.photo-upload-progress__fill {
    display: block;
    height: 100%;
    width: 35%;
    border-radius: inherit;
    background: linear-gradient(90deg, #d6335c, #ffe5ad);
    animation: photo-upload-progress-slide 1.2s ease-in-out infinite;
}
@keyframes photo-upload-progress-slide {
    from { transform: translateX(-110%); }
    to { transform: translateX(310%); }
}
@media (prefers-reduced-motion: reduce) {
    .photo-upload-progress__fill { animation: none; width: 100%; opacity: 0.7; }
}
/* School locations share one account session and keep scene rendering local to the selected place. */
.ft-school-bar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:8px 12px; background:#18080e; border-bottom:1px solid #502131; }
.ft-school-bar button { min-height:36px; padding:6px 12px; border:1px solid #754052; border-radius:12px; background:#32131f; color:#f8e9ef; cursor:pointer; }
.ft-school-bar button:disabled { opacity:.6; cursor:default; }
.ft-school-hint { flex:1 1 220px; color:#cdb6c0; font-size:12px; overflow-wrap:anywhere; }
.ft-school-dialog { width:min(680px,calc(100% - 24px)); max-height:85dvh; padding:18px; border:1px solid #754052; border-radius:18px; background:#1b0911; color:#f8e9ef; box-sizing:border-box; }
.ft-school-dialog[open] { display:flex; flex-direction:column; gap:12px; }
.ft-school-dialog::backdrop { background:#000b; backdrop-filter:blur(5px); }
.ft-school-dialog-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-shrink:0; }
.ft-school-dialog-heading h2 { font-size:18px; margin:0; }
.ft-school-dialog-close { width:44px; height:44px; border:1px solid #754052; border-radius:10px; background:#32131f; color:inherit; font-size:24px; cursor:pointer; }
.ft-school-dialog-status { margin:0; font-size:13px; color:#dec4d0; flex-shrink:0; }
.ft-school-places { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; overflow:auto; min-height:0; }
.ft-school-place { display:flex; flex-direction:column; align-items:flex-start; gap:7px; min-height:88px; padding:12px; text-align:left; border:1px solid #663445; border-radius:12px; background:#2b101c; color:inherit; cursor:pointer; overflow-wrap:anywhere; }
.ft-school-place span,.ft-school-place small { color:#d5bec8; font-size:12px; word-break:keep-all; }
.ft-school-place[aria-current] { border-color:#e789ad; background:#4a1c31; }
.ft-school-place:disabled { cursor:default; }
.ft-school-location-label { font-weight:700; color:#f2a3c2; }
.ft-school-role { display:inline-block; margin-left:4px; color:#ceb6c2; font-size:.85em; font-weight:500; white-space:nowrap; }
.ft-room-mode .ft-log-name { flex-wrap:wrap; row-gap:3px; }
.ft-avatar-area.ft-school-scene { background-image:var(--ft-school-background); background-size:cover; background-position:center; }
.ft-avatar-area.ft-school-scene::before,.ft-avatar-area.ft-school-scene::after { display:none; }
.ft-avatar-area.ft-school-scene #ft-avatar { object-fit:contain; width:100%; height:100%; }
.freetalk-overlay.ft-school-room.ft-mode-chatbot .ft-main { background-image:linear-gradient(#10080c55,#10080c55),var(--ft-school-background); background-size:cover; background-position:center; }
.freetalk-overlay.ft-school-room.ft-mode-chatbot .ft-log-content { background:#190c14; color:#f6edf2; }
.freetalk-overlay.ft-school-room.ft-mode-chatbot .ft-log-msg.user .ft-log-content { background:#552039; color:#fff3f8; }
.freetalk-overlay.ft-school-room.ft-mode-chatbot .ft-scene-global-content,
.freetalk-overlay.ft-school-room.ft-mode-chatbot .ft-status-message { background:#190c14; border-radius:12px; padding:8px 12px; color:#eadce4; }
@media(max-height:500px) { .ft-school-dialog { max-height:92dvh; padding:10px; gap:6px; } .ft-school-place { min-height:70px; } }
