/* ============================================================
   getlive.css — AI Live 서비스 전용 스타일시트
   기존 getstyle.css 구조를 기반으로, AI Live 전용 UI 강화
   ============================================================ */

/* ── 무대(스테이지): 비디오 + 사이드 패널 ── */

:root {
    /* 태블릿·데스크톱: 패널이 너무 넓으면 무대가 잘림 → 상한·하한 조정 */
    --live-chat-panel-width: clamp(300px, min(38vw, 560px), 640px);
    /* 메인 무대와 우측 대화록 사이 여백(배경이 비치며 구분됨) */
    --live-chat-layout-gap: max(12px, clamp(12px, 2vw, 28px));
    /* hedra · 무대 · Available Avatars 그리드 공통 가로 상한 (PC에서 동일 컬럼) */
    --live-main-column-max: 1200px;
}

/* 이 페이지만 로드되는 스타일: 가로 오버플로 방지 (모바일·패드) */
html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

.page-getlive .avatar-container {
    width: 100%;
    max-width: 100vw;
    margin-left: auto;
    margin-right: auto;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    box-sizing: border-box;
}

/* START LIVE — getstyle 고정 height + 미디어쿼리 padding 충돌 제거(세로 잘림·정렬 어긋남) */
.page-getlive .btn-create-top {
    height: auto !important;
    min-height: 48px;
    padding: 10px 16px;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.45rem;
    flex-wrap: wrap;
    overflow: visible;
    line-height: 1.25;
    white-space: normal;
}

.page-getlive .btn-create-top i {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.page-getlive .btn-create-top__label {
    display: inline-block;
    line-height: 1.2;
    white-space: nowrap;
}

.page-getlive .btn-create-top .credit-cost-hint {
    display: inline-flex !important;
    align-items: center;
    margin-left: 0 !important;
    padding: 4px 9px;
    font-size: 0.68rem !important;
    opacity: 0.9 !important;
    line-height: 1.2;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
}

/* AI Live: 메인 영역·갤러리와 동일 가로 폭 (Available Avatars max와 정렬) */
html body .avatar-container .avatar-display-section .hedra-container,
.avatar-display-section .hedra-container,
body .avatar-display-section .hedra-container {
    max-width: min(var(--live-main-column-max), 100%) !important;
    width: 100% !important;
}

@media (max-width: 980px) {
    html body .avatar-container .avatar-display-section .hedra-container,
    .avatar-display-section .hedra-container {
        max-width: 100% !important;
        padding-left: max(10px, env(safe-area-inset-left)) !important;
        padding-right: max(10px, env(safe-area-inset-right)) !important;
    }
}

/* 태블릿: 데스크톱용 고정 패널 폭 완화 (무대 최소 너비 확보) */
@media (min-width: 769px) and (max-width: 1199px) {
    :root {
        --live-chat-panel-width: clamp(280px, min(34vw, 420px), 520px);
        --live-chat-layout-gap: 12px;
    }
}

/* 상단 컨트롤: 타 서비스(getstyle)와 동일하게 세로 스택 · 전폭 */
@media (max-width: 1024px) {
    .page-getlive .top-controls-wrapper {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 0.65rem !important;
        padding: 0 2px;
        box-sizing: border-box;
    }

    .page-getlive .top-left-control,
    .page-getlive .top-center-control,
    .page-getlive .top-right-control {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .page-getlive .style-dropdown-top,
    .page-getlive .btn-create-top {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 가로(폴더블·소형 태블릿): getstyle이 상단을 한 줄·버튼 max 180px로 묶는 것을 Live에서는 세로 스택으로 완화 */
@media screen and (min-width: 600px) and (max-width: 1000px) and (orientation: landscape) {
    .page-getlive .top-controls-wrapper {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        max-width: 100% !important;
        width: 100% !important;
        gap: 0.65rem !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }

    .page-getlive .top-left-control,
    .page-getlive .top-center-control,
    .page-getlive .top-right-control {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

.live-stage {
    position: relative;
    width: 100%;
    max-width: min(var(--live-main-column-max), 100%);
    margin: 0 auto !important;
    display: flex;
    align-items: stretch;
    /* 고정 패널 제외 시에도 인라인 대화 영역과의 간격 느낌용 */
    gap: var(--live-chat-layout-gap);
    overflow: visible;
    border-radius: 16px;
    transition: width 0.35s ease, max-width 0.35s ease, margin 0.35s ease;
    box-sizing: border-box;
    min-width: 0;
}

body.live-chat-open {
    overflow-x: hidden;
}

body.live-chat-open .avatar-container {
    width: calc(100vw - var(--live-chat-panel-width) - var(--live-chat-layout-gap)) !important;
    max-width: calc(100vw - var(--live-chat-panel-width) - var(--live-chat-layout-gap)) !important;
    margin-left: 0 !important;
    margin-right: auto !important;
    overflow-x: hidden !important;
    transition: width 0.35s ease, max-width 0.35s ease;
}

body.live-chat-open .avatar-display-section {
    width: 100%;
}

body.live-chat-open .avatar-display-section .hedra-container {
    width: 100% !important;
    max-width: calc(100vw - var(--live-chat-panel-width) - var(--live-chat-layout-gap)) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

body.live-chat-open .live-stage {
    width: calc(100vw - var(--live-chat-panel-width) - var(--live-chat-layout-gap)) !important;
    max-width: min(
        var(--live-main-column-max),
        calc(100vw - var(--live-chat-panel-width) - var(--live-chat-layout-gap))
    ) !important;
}

body.live-chat-open .live-video-wrapper {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
    max-height: min(78vh, 860px);
}

/* ── 비디오 영역: AI Live 전용 대형 무대 (16:9) ── */
.live-video-wrapper {
    position: relative;
    width: 100%;
    max-width: min(var(--live-main-column-max), 100%);
    aspect-ratio: 16 / 9;
    height: auto;
    max-height: min(85vh, 960px);
    margin: 0 auto;
    background: linear-gradient(135deg, #0c0a1c 0%, #1a0f3a 50%, #2d1b69 100%);
    border-radius: 16px;
    overflow: hidden;
    border: 1.5px solid rgba(139, 92, 246, 0.25);
    box-shadow:
        0 0 40px rgba(94, 66, 166, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, max-width 0.35s ease, flex 0.35s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 100%;
    min-width: 0;
}

.live-video-wrapper.is-live {
    border-color: rgba(139, 92, 246, 0.45);
    box-shadow:
        0 0 60px rgba(94, 66, 166, 0.2),
        0 0 40px rgba(94, 66, 166, 0.15);
}

/* 넓은 화면: 세로 상한만 완화 (비율은 16:9 유지) */
@media (min-width: 981px) {
    .live-video-wrapper {
        max-height: min(82vh, 960px);
    }
}

.live-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* LiveKit 비디오 컨테이너 — 플레이스홀더(z:2)보다 위에 두어 실제 스트림이 보이게 함 */
.live-video-wrapper #liveVideoContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    overflow: hidden;
    border-radius: inherit;
}

.live-video-wrapper #liveVideoContainer video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 비디오 대기 상태 플레이스홀더 */
.live-video-placeholder {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
    background: linear-gradient(135deg, #0c0a1c 0%, #1a0f3a 50%, #2d1b69 100%);
    transition: opacity 0.5s ease;
}

.live-video-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

.live-video-wrapper.is-live .live-video-placeholder.hidden {
    visibility: hidden;
}

.live-placeholder-avatar {
    width: 208px;
    height: 208px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(139, 92, 246, 0.3);
    margin-bottom: 1.5rem;
    background: rgba(139, 92, 246, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.08), inset 0 0 30px rgba(139, 92, 246, 0.05);
}

.live-placeholder-avatar.has-image {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.15), inset 0 0 30px rgba(139, 92, 246, 0.05);
}

.live-placeholder-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-icon-default {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: placeholderFloat 3s ease-in-out infinite;
}

@keyframes placeholderFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.live-placeholder-text {
    color: rgba(255,255,255,0.5);
    font-size: 0.95rem;
    text-align: center;
}

.live-placeholder-text .avatar-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    margin-bottom: 0.3rem;
}

.live-placeholder-hint {
    opacity: 0.6;
    font-size: 0.85rem;
}

/* 모바일·태블릿: 안내 문구 숨김 — 이름만 */
@media (max-width: 1199px) {
    .live-placeholder-hint {
        display: none !important;
    }

    .live-placeholder-text .avatar-name {
        margin-bottom: 0;
    }
}

/* 비디오 컨트롤 오버레이 */
.live-video-controls {
    position: absolute;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 2.5vw, 16px);
    z-index: 10;
    max-width: calc(100% - 24px);
    padding: 0 4px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.live-video-wrapper.is-live .live-video-controls {
    opacity: 1;
    pointer-events: auto;
}

/* 마이크·대화: 밝은 원 안에 진한 보라 아이콘(회색 톤 무너뜨림 방지) */
.live-ctrl-btn {
    width: 54px !important;
    height: 54px !important;
    min-width: 54px !important;
    min-height: 54px !important;
    max-width: 54px !important;
    max-height: 54px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    border: 1.5px solid rgba(76, 29, 149, 0.38);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #4c1d95 !important;
    font-size: 1.15rem;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    aspect-ratio: 1 / 1 !important;
    box-sizing: border-box !important;
    flex: 0 0 54px !important;
    line-height: 1 !important;
    overflow: hidden !important;
    appearance: none;
    -webkit-appearance: none;
}

.live-ctrl-btn:not(.btn-end-call) i {
    display: block;
    line-height: 1;
    pointer-events: none;
    color: #4c1d95 !important;
    opacity: 1 !important;
    font-weight: 900;
    -webkit-text-fill-color: #4c1d95;
}

.live-ctrl-btn:not(.btn-end-call):hover {
    background: #ffffff;
    transform: scale(1.08);
    color: #5b21b6 !important;
    border-color: rgba(124, 58, 237, 0.55);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 0 22px rgba(139, 92, 246, 0.22);
}

.live-ctrl-btn:not(.btn-end-call):hover i {
    color: #5b21b6 !important;
    -webkit-text-fill-color: #5b21b6;
}

.live-ctrl-btn.btn-end-call i {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
    font-weight: 900;
}

.live-ctrl-btn.btn-end-call {
    border: 1px solid rgba(255, 255, 255, 0.38) !important;
    background: linear-gradient(135deg, #7c3aed 0%, #b74e91 100%);
    color: #fff !important;
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    min-height: 58px !important;
    max-width: 58px !important;
    max-height: 58px !important;
    font-size: 1.2rem;
    flex-basis: 58px !important;
    aspect-ratio: 1 / 1 !important;
    box-shadow: 0 12px 32px rgba(124, 58, 237, 0.35), 0 0 22px rgba(183, 78, 145, 0.2);
}

.live-ctrl-btn.btn-end-call:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #c45a9e 100%);
    color: #fff;
    transform: scale(1.1);
}

.live-ctrl-btn.is-muted {
    background: rgba(91, 33, 182, 0.72);
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.45);
}

.live-ctrl-btn.is-muted i {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
}

/* ── Time Remaining 알약 (좌측 상단) ── */
.live-time-pill {
    position: absolute;
    top: 14px;
    left: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(245, 245, 248, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 18px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    font-size: 0.8rem;
    color: #2c2640;
    font-weight: 500;
}

.live-video-wrapper.is-live .live-time-pill {
    opacity: 1;
}

.live-time-pill .time-pill-label {
    color: #5e5375;
}

.live-time-pill .time-pill-value {
    color: #1a0f3a;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ── 우측 슬라이드 채팅 패널 (페이지 레벨 고정) ── */
.live-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--live-chat-panel-width);
    height: 100vh;
    /* 메인 무대와 톤 맞춘 밝은 라벤더·아이보리 계열 */
    background: linear-gradient(180deg, #faf8ff 0%, #f3efff 42%, #ebe4ff 100%);
    border-left: 1.5px solid rgba(139, 92, 246, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.35s ease, opacity 0.25s ease;
    opacity: 0;
    z-index: 1000;
    box-shadow:
        -12px 0 48px rgba(91, 33, 182, 0.14),
        -4px 0 24px rgba(0, 0, 0, 0.06);
}

.live-stage.chat-open .live-chat-panel {
    transform: translateX(0);
    opacity: 1;
}

.live-stage.chat-open .live-video-wrapper {
    border-radius: 16px;
}

.live-chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.22);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(167, 139, 250, 0.18));
}

.live-chat-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #3b2f5c;
    font-size: 1.05rem;
}

.live-chat-panel-title i {
    color: #7c3aed;
}

.live-chat-panel-title strong {
    color: #2d2640;
    font-weight: 600;
}

.live-chat-panel-close {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 2px solid rgba(76, 29, 149, 0.45);
    background: linear-gradient(180deg, #faf8ff 0%, #ede9fe 100%);
    color: #4c1d95 !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.05rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    flex: 0 0 42px !important;
    aspect-ratio: 1 / 1 !important;
    box-shadow: 0 2px 8px rgba(76, 29, 149, 0.12);
}

.live-chat-panel-close i {
    color: #4c1d95 !important;
    opacity: 1 !important;
    font-weight: 900;
    -webkit-text-fill-color: #4c1d95;
}

.live-chat-panel-close:hover {
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(76, 29, 149, 0.65);
    color: #3b0764 !important;
}

.live-chat-panel-close:hover i {
    color: #3b0764 !important;
    -webkit-text-fill-color: #3b0764;
}

.live-chat-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 58, 237, 0.35) transparent;
}

.live-chat-panel-body::-webkit-scrollbar { width: 6px; }
.live-chat-panel-body::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.35); border-radius: 3px; }

.live-chat-panel-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.live-chat-input {
    flex: 1;
    height: 48px;
    padding: 0 16px;
    background: #ffffff;
    border: 1px solid rgba(139, 92, 246, 0.28);
    border-radius: 12px;
    color: #2d2640;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.live-chat-input::placeholder {
    color: rgba(45, 38, 64, 0.42);
}

.live-chat-input:focus {
    border-color: rgba(124, 58, 237, 0.55);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.live-chat-send {
    width: 54px !important;
    height: 48px !important;
    min-width: 54px !important;
    max-width: 54px !important;
    padding: 0 !important;
    border-radius: 24px;
    border: none;
    background: linear-gradient(135deg, #8b5cf6, #b74e91);
    color: #fff;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    flex: 0 0 54px !important;
}

.live-chat-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

/* 채팅 메시지 (사이드 패널용) */
.live-chat-panel-body .chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 0.85rem;
    line-height: 1.5;
}

.live-chat-panel-body .chat-msg .msg-role {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    margin-top: 1px;
}

.live-chat-panel-body .chat-msg.user .msg-role {
    background: rgba(139, 92, 246, 0.16);
    color: #5b21b6;
}

.live-chat-panel-body .chat-msg.ai .msg-role {
    background: linear-gradient(135deg, #06b6d4, #22d3ee);
    color: #fff;
}

.live-chat-panel-body .chat-msg .msg-text {
    flex: 1;
    color: rgba(45, 38, 64, 0.9);
}

.live-chat-panel-body .msg-text.chat-placeholder-hint {
    color: rgba(45, 38, 64, 0.48) !important;
    font-style: italic;
}

/* 모바일에서 채팅 패널 전체 너비 */
@media (max-width: 768px) {
    :root {
        --live-chat-panel-width: 100vw;
        --live-chat-layout-gap: 0px;
    }

    body.live-chat-open .avatar-container,
    body.live-chat-open .avatar-display-section .hedra-container,
    body.live-chat-open .live-stage {
        width: 100% !important;
        max-width: 100% !important;
    }

    .live-chat-panel {
        width: 100%;
        max-width: 100vw;
        transform: translateX(100%);
    }
    .live-stage.chat-open .live-chat-panel {
        transform: translateX(0);
    }
}

/* ── LEGACY: LIVE 인디케이터 / 기존 타이머는 사용 안 함 (호환용 유지) ── */
.live-indicator,
.live-timer { display: none !important; }

/* ── 세션 정보 바 ── */
.live-session-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.85rem 1.25rem;
    padding: 0.75rem max(0.6rem, env(safe-area-inset-left)) 0.75rem max(0.6rem, env(safe-area-inset-right));
    margin-top: 0.8rem;
    margin-left: auto;
    margin-right: auto;
    background: rgba(94, 66, 166, 0.08);
    border: 1px solid rgba(94, 66, 166, 0.15);
    border-radius: 10px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    width: 100%;
    max-width: min(var(--live-main-column-max), 100%);
    box-sizing: border-box;
}

.live-session-bar .session-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    flex: 0 1 auto;
}

.live-session-bar .session-stat i {
    color: #c4b5fd;
    font-size: 0.9rem;
}

.live-session-bar .session-stat .stat-value {
    color: rgba(255,255,255,0.85);
    font-weight: 600;
}

/* ── 아바타 카드 그리드 (gallery 스타일) ── */
.live-avatars-section {
    margin-top: 0.4rem;
    padding: 0.4rem max(8px, env(safe-area-inset-left)) 2rem max(8px, env(safe-area-inset-right));
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.live-avatars-header {
    text-align: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: solid 1px rgba(94, 66, 166, 0.2);
    width: 100%;
    max-width: min(var(--live-main-column-max), 100%);
}

.live-avatars-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 0.075em;
    color: rgba(255,255,255,0.9);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.live-avatars-header h3 i {
    color: #c4b5fd;
}

/* 메인 영역 너비 안에서 자동 열 수 · 좁은 화면은 여러 행 갤러리(가로 스크롤 없음) */
.live-avatars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 140px));
    justify-content: center;
    justify-items: stretch;
    align-items: stretch;
    gap: 1rem;
    width: 100%;
    max-width: min(var(--live-main-column-max), 100%);
    box-sizing: border-box;
    padding: 0;
    overflow-x: visible;
    overflow-y: visible;
}

.live-avatar-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    min-height: 0;
    background: rgba(94, 66, 166, 0.08);
    border: 1.5px solid rgba(94, 66, 166, 0.2);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
}

.live-avatar-card:hover {
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(94, 66, 166, 0.2);
}

.live-avatar-card.selected {
    border-color: rgba(139, 92, 246, 0.8);
    box-shadow:
        0 0 0 2px rgba(139, 92, 246, 0.3),
        0 8px 30px rgba(94, 66, 166, 0.25);
}

.live-avatar-card.selected::after {
    display: none;
}

.live-avatar-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    flex-shrink: 0;
    overflow: hidden;
    background: rgba(255,255,255,0.03);
}

.live-avatar-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.live-avatar-card:hover .live-avatar-card-thumb img {
    transform: scale(1.05);
}

.live-avatar-card-info {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8px 8px 10px;
    background: rgba(12, 8, 28, 0.96);
    text-align: center;
    border-top: 1px solid rgba(94, 66, 166, 0.15);
    min-height: 0;
}

.live-avatar-card-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.92);
    margin-bottom: 2px;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word;
}

.live-avatar-card-role {
    font-size: 0.68rem;
    color: rgba(196, 181, 253, 0.75);
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word;
}

/* more 카드 */
.live-avatar-card.more-card {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    background: rgba(94, 66, 166, 0.05);
    border-style: dashed;
}

.live-avatar-card.more-card .live-avatar-card-thumb {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    min-height: 0;
}

.live-avatar-card.more-card .live-avatar-card-info {
    flex: 0 0 auto;
}

.live-avatar-card.more-card:hover {
    background: rgba(94, 66, 166, 0.12);
}

.more-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.6rem;
    transition: background 0.2s ease;
}

.live-avatar-card.more-card:hover .more-card-icon {
    background: rgba(139, 92, 246, 0.3);
}

.more-card-icon i {
    font-size: 1.2rem;
    color: #c4b5fd;
}

.more-card-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(196, 181, 253, 0.8);
    letter-spacing: 2px;
}

/* 로딩 스피너 */
.live-avatar-card.loading-card {
    justify-content: center;
    align-items: center;
    min-height: 160px;
}

.live-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 스켈레톤 카드 */
.live-avatar-card.skeleton {
    pointer-events: none;
}

.live-avatar-card.skeleton .live-avatar-card-thumb {
    background: linear-gradient(90deg, rgba(94,66,166,0.08) 25%, rgba(94,66,166,0.15) 50%, rgba(94,66,166,0.08) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.live-avatar-card.skeleton .live-avatar-card-name,
.live-avatar-card.skeleton .live-avatar-card-role {
    background: linear-gradient(90deg, rgba(94,66,166,0.1) 25%, rgba(94,66,166,0.18) 50%, rgba(94,66,166,0.1) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    color: transparent;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ── 대화 로그 ── */
.live-chat-log-section {
    margin-top: 1.5rem;
}

.live-chat-log-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.7rem 1rem;
    background: rgba(94, 66, 166, 0.06);
    border: 1px solid rgba(94, 66, 166, 0.15);
    border-radius: 10px;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s ease;
    user-select: none;
}

.live-chat-log-toggle:hover {
    background: rgba(94, 66, 166, 0.12);
}

.live-chat-log-toggle i.toggle-arrow {
    transition: transform 0.2s ease;
    font-size: 0.8rem;
    margin-left: auto;
}

.live-chat-log-toggle.expanded i.toggle-arrow {
    transform: rotate(180deg);
}

.live-chat-log-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border: 1px solid transparent;
    border-radius: 0 0 10px 10px;
    margin-top: -1px;
}

.live-chat-log-container.expanded {
    max-height: 400px;
    border-color: rgba(94, 66, 166, 0.15);
    overflow-y: auto;
}

.live-chat-log {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-msg {
    display: flex;
    gap: 0.6rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.chat-msg .msg-role {
    flex-shrink: 0;
    font-weight: 600;
    min-width: 40px;
}

.chat-msg.user .msg-role {
    color: #60a5fa;
}

.chat-msg.ai .msg-role {
    color: #c4b5fd;
}

.chat-msg .msg-text {
    color: rgba(255,255,255,0.75);
}

/* ── 반응형 (16:9 비율 유지) ── */
@media (max-width: 980px) {
    .live-stage {
        max-width: 100%;
        width: 100%;
    }

    .live-avatars-grid {
        grid-template-columns: repeat(auto-fill, minmax(96px, 132px));
        gap: 0.75rem;
    }
}

@media (max-width: 736px) {
    .live-avatars-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
        gap: 0.65rem;
    }

    .live-placeholder-avatar {
        width: 180px;
        height: 180px;
    }
}

@media (max-width: 768px) {
    .live-video-wrapper {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        border-radius: 12px;
    }

    .live-avatars-grid {
        grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
        gap: 0.55rem;
    }

    .live-avatar-card {
        border-radius: 10px;
    }

    .live-avatar-card-info {
        padding: 6px 6px 8px;
    }

    .live-avatar-card-name {
        font-size: 0.74rem;
    }

    .live-avatar-card-role {
        font-size: 0.62rem;
    }

    .live-avatar-card.selected::after {
        width: 20px;
        height: 20px;
        top: 6px;
        right: 6px;
        font-size: 0.65rem;
    }

    .live-ctrl-btn {
        width: 46px !important;
        height: 46px !important;
        min-width: 46px !important;
        min-height: 46px !important;
        max-width: 46px !important;
        max-height: 46px !important;
        flex-basis: 46px !important;
        font-size: 0.9rem;
    }

    .live-ctrl-btn.btn-end-call {
        width: 50px !important;
        height: 50px !important;
        min-width: 50px !important;
        min-height: 50px !important;
        max-width: 50px !important;
        max-height: 50px !important;
        flex-basis: 50px !important;
        font-size: 0.95rem;
    }

    .live-session-bar {
        flex-wrap: wrap;
        gap: 0.8rem;
        font-size: 0.8rem;
    }

    .live-placeholder-avatar {
        width: 140px;
        height: 140px;
    }

    .live-time-pill {
        top: 10px;
        left: 10px;
        font-size: 0.72rem;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    .live-avatars-grid {
        grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
        gap: 0.45rem;
    }

    .live-avatar-card-name {
        font-size: 0.68rem;
    }

    .live-avatar-card-role {
        font-size: 0.58rem;
    }

    .live-placeholder-avatar {
        width: 120px;
        height: 120px;
    }
}

/* 헤더: 좁은 폰에서 타이틀 줄바꿈 · 중앙 정렬 (타 서비스 톤) */
@media (max-width: 640px) {
    .page-getlive .avatar-header .header-content {
        padding-left: max(4px, env(safe-area-inset-left));
        padding-right: max(4px, env(safe-area-inset-right));
    }

    .page-getlive .avatar-header .title {
        font-size: clamp(1.35rem, 5.2vw, 1.75rem);
        justify-content: center;
        text-align: center;
        flex-wrap: wrap;
        line-height: 1.25;
        gap: 0.35rem;
    }

    .page-getlive .avatar-header .subtitle {
        font-size: 0.92rem;
        padding: 0 10px;
        line-height: 1.45;
    }

    .live-time-pill {
        top: max(8px, env(safe-area-inset-top));
        left: max(8px, env(safe-area-inset-left));
        font-size: 0.72rem;
        padding: 5px 10px;
    }
}

/* ── AI Live: 크레딧 부족 모달 ── */
@keyframes liveRechargeOverlayIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes liveRechargeModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.live-recharge-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    background: rgba(8, 6, 22, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: liveRechargeOverlayIn 0.35s ease forwards;
}

.live-recharge-modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 2rem 1.75rem 1.65rem;
    border-radius: 22px;
    text-align: center;
    background: linear-gradient(
        155deg,
        rgba(22, 14, 48, 0.97) 0%,
        rgba(32, 19, 72, 0.98) 48%,
        rgba(26, 15, 58, 0.97) 100%
    );
    border: 1px solid rgba(167, 139, 250, 0.28);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 28px 72px rgba(0, 0, 0, 0.55),
        0 0 100px rgba(124, 58, 237, 0.14);
    animation: liveRechargeModalIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.live-recharge-modal__accent {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(56%, 220px);
    height: 3px;
    border-radius: 0 0 10px 10px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(167, 139, 250, 0.35),
        #c4b5fd,
        rgba(167, 139, 250, 0.35),
        transparent
    );
}

.live-recharge-modal__icon {
    margin-bottom: 1.15rem;
}

.live-recharge-modal__icon-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(124, 58, 237, 0.35), rgba(167, 139, 250, 0.12));
    border: 1px solid rgba(196, 181, 253, 0.35);
    box-shadow:
        0 8px 28px rgba(91, 33, 182, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.live-recharge-modal__icon-ring i {
    font-size: 1.45rem;
    color: #e9d5ff;
    filter: drop-shadow(0 2px 8px rgba(124, 58, 237, 0.45));
}

.live-recharge-modal__title {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: rgba(255, 255, 255, 0.96);
    line-height: 1.3;
}

.live-recharge-modal__lead {
    margin: 0 0 1.35rem;
    font-size: 0.9rem;
    line-height: 1.55;
    color: rgba(226, 232, 240, 0.78);
    font-weight: 400;
}

.live-recharge-modal__stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.live-recharge-stat {
    padding: 0.85rem 0.75rem;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(139, 92, 246, 0.22);
}

.live-recharge-stat__label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(196, 181, 253, 0.65);
    margin-bottom: 0.35rem;
}

.live-recharge-stat__value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #f5f3ff;
    line-height: 1.2;
}

.live-recharge-modal__footnote {
    margin: 0 0 1.45rem;
    font-size: 0.78rem;
    line-height: 1.55;
    color: rgba(203, 213, 225, 0.55);
}

.live-recharge-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: center;
}

.live-recharge-btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0 1.35rem;
    margin: 0;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease;
    box-sizing: border-box;
    border-style: solid;
    border-width: 1px;
}

.live-recharge-btn > span {
    display: inline-block;
    vertical-align: middle;
}

.live-recharge-btn i {
    font-size: 0.95rem;
    line-height: 1;
    flex-shrink: 0;
}

.live-recharge-btn--primary {
    flex: 1 1 140px;
    min-width: min(100%, 160px);
    color: #fff;
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 50%, #8b5cf6 100%);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow:
        0 4px 20px rgba(91, 33, 182, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.live-recharge-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow:
        0 8px 28px rgba(91, 33, 182, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.live-recharge-btn--primary:active {
    transform: translateY(0);
}

.live-recharge-btn--ghost {
    flex: 1 1 120px;
    min-width: min(100%, 140px);
    color: rgba(241, 245, 249, 0.88);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
}

.live-recharge-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
}

.live-recharge-btn--ghost:active {
    transform: translateY(0);
}

@media (max-width: 420px) {
    .live-recharge-modal {
        padding: 1.65rem 1.25rem 1.35rem;
        border-radius: 18px;
    }

    .live-recharge-modal__stats {
        grid-template-columns: 1fr;
    }

    .live-recharge-modal__actions {
        flex-direction: column;
    }

    .live-recharge-btn {
        width: 100%;
        flex: 1 1 auto;
    }
}

/* ============================================================
   AI Live 최종 폭 보정
   - getstyle.css의 560px landscape 제한보다 뒤에서 적용
   - 메인 프레임을 Available Avatars 전체 가로폭과 동일하게 확대
   - 16:9 비율로 세로도 자동 확대
   ============================================================ */
body.page-getlive {
    --live-main-column-max: 1640px;
}

body.page-getlive .avatar-container,
body.page-getlive .avatar-display-section,
body.page-getlive .live-avatars-section {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
}

html body.page-getlive .avatar-container .avatar-display-section .hedra-container {
    width: min(var(--live-main-column-max), calc(100vw - 72px)) !important;
    max-width: min(var(--live-main-column-max), calc(100vw - 72px)) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}

html body.page-getlive .live-stage,
html body.page-getlive .live-video-wrapper,
html body.page-getlive .live-session-bar,
html body.page-getlive .live-avatars-header,
html body.page-getlive .live-avatars-grid {
    width: min(var(--live-main-column-max), calc(100vw - 72px)) !important;
    max-width: min(var(--live-main-column-max), calc(100vw - 72px)) !important;
    box-sizing: border-box !important;
}

html body.page-getlive .live-video-wrapper {
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
    min-height: unset !important;
}

@media screen and (min-width: 600px) and (max-width: 1000px) {
    html body.page-getlive .avatar-container .avatar-display-section .hedra-container,
    html body.page-getlive .live-stage,
    html body.page-getlive .live-video-wrapper,
    html body.page-getlive .live-session-bar,
    html body.page-getlive .live-avatars-header,
    html body.page-getlive .live-avatars-grid {
        width: min(var(--live-main-column-max), calc(100vw - 48px)) !important;
        max-width: min(var(--live-main-column-max), calc(100vw - 48px)) !important;
    }
}

/* Available Avatars: 메인 프레임 폭 안에서 실제 썸네일 카드 묶음만 중앙 정렬 */
html body.page-getlive .live-avatars-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: stretch !important;
    gap: clamp(1rem, 1.25vw, 1.6rem) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

html body.page-getlive .live-avatar-card {
    flex: 0 0 clamp(140px, 8.75vw, 180px) !important;
    width: clamp(140px, 8.75vw, 180px) !important;
    max-width: 180px !important;
}
