/* ==========================================================================
   지은이 음성 포털 (Lee Jieun Voice Portal) - 스타일 시트
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", Roboto, "Noto Sans KR", sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #121316;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* 0. 뷰 전환 시스템 */
.view-screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.view-screen.active {
    display: flex;
}

/* 1. 메인 대화방 목록 헤더 & 컨테이너 */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #181a1f;
    border-bottom: 1px solid #272a31;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: #f3f4f6;
    letter-spacing: -0.5px;
}

.header-sub-badge {
    font-size: 0.72rem;
    background: #272a31;
    color: #f43f5e;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-top: 2px;
}

.rooms-container {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 카톡 스타일 룸 카드 (대형 104px 아바타 지원) */
.room-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #1a1d24;
    border: 1px solid #282d38;
    border-radius: 18px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.room-card:active {
    background: #252a35;
    transform: scale(0.98);
}

.room-avatar {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.room-avatar img, .avatar-circle img, .msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 32%;
    transform: scale(1.18);
    display: block;
}

.room-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.room-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.room-name-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #f3f4f6;
}

.room-badge {
    font-size: 0.72rem;
    background: #282e3c;
    color: #93c5fd;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.room-time {
    font-size: 0.75rem;
    color: #71717a;
}

.room-role {
    font-size: 0.8rem;
    color: #a1a1aa;
    line-height: 1.35;
}

.room-last-msg {
    font-size: 0.85rem;
    color: #d1d5db;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* 2. 대화방 상단 헤더 (64px 시원한 아바타) */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #181a1f;
    border-bottom: 1px solid #272a31;
    flex-shrink: 0;
    z-index: 10;
}

.back-btn {
    background: transparent;
    border: none;
    color: #f43f5e;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0 8px 0 2px;
    line-height: 1;
}

.back-btn:active {
    transform: scale(0.9);
}

.avatar-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.header-title-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f3f4f6;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 7px;
    height: 7px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #10b981;
}

/* L / M / H 모델 선택 세그먼트 버튼 */
.model-tier-group {
    display: flex;
    background: #121418;
    border: 1px solid #2e3442;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    margin-left: 4px;
}

.tier-btn {
    background: transparent;
    border: none;
    color: #8892b0;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.2;
}

.tier-btn.active {
    background: #f43f5e;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(244, 63, 94, 0.4);
}

.tier-btn:active {
    transform: scale(0.92);
}

.status-text {
    font-size: 0.72rem;
    color: #9ca3af;
    margin-top: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-header-btn {
    background: #232730;
    border: 1px solid #3b4252;
    color: #e5e7eb;
    padding: 7px 10px;
    border-radius: 9px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: all 0.15s ease;
    line-height: 1;
    white-space: nowrap;
}

.action-header-btn.care-btn {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
}

.action-header-btn.care-btn:active {
    background: #10b981;
    color: #ffffff;
    transform: scale(0.94);
}

.action-header-btn.reset-btn {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.4);
    color: #fda4af;
}

.action-header-btn.reset-btn:active {
    background: #f43f5e;
    color: #ffffff;
    transform: scale(0.94);
}

.icon-btn {
    background: #232730;
    border: 1px solid #333845;
    color: #d1d5db;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.icon-btn:active {
    background: #f43f5e;
    color: #fff;
    transform: scale(0.95);
}

/* 3. 대화창 메시지 컨테이너 & 카톡 스타일 프로필 레이아웃 */
#chatContainer {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    max-width: 90%;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 오빠 메시지: 우측 정렬 */
.message-row.user {
    align-self: flex-end;
    justify-content: flex-end;
}

/* 지은이/상대방 메시지: 카톡 스타일 좌측 아바타 + 우측 바디 */
.message-row:not(.user) {
    align-self: flex-start;
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: flex-start;
}

.msg-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    margin-top: 1px;
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.msg-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sender-name {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 4px;
    padding: 0 2px;
    font-weight: 500;
}

.bubble-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
}

.bubble {
    padding: 12px 15px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
}

.message-row.user .bubble {
    background: #3b222d;
    border: 1px solid #632d43;
    color: #ffe4e6;
    border-bottom-right-radius: 4px;
}

.message-row:not(.user) .bubble {
    background: #1e2128;
    border: 1px solid #2d3340;
    color: #f3f4f6;
    border-bottom-left-radius: 4px;
}

/* 발화 중 핑크 펄스 글로우 */
@keyframes speakingPulse {
    0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

.speaking-glow {
    animation: speakingPulse 1.5s infinite;
    border: 2px solid #f43f5e !important;
}

.bubble-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    gap: 8px;
    font-size: 0.72rem;
    color: #71717a;
    padding: 0 2px;
}

.replay-btn {
    background: transparent;
    border: none;
    color: #f43f5e;
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}

.replay-btn:active {
    background: rgba(244, 63, 94, 0.2);
}

/* 4. 더보기 / 접기 클리핑 시스템 */
.bubble-content.collapsed {
    max-height: 105px;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
}

.more-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    background: #14171d;
    border: 1px solid #2d3340;
    color: #93c5fd;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 0;
    border-radius: 6px;
    margin-top: 6px;
    cursor: pointer;
}

.more-toggle-btn:active {
    background: #202634;
}

/* 5. 하단 고정 퀵 칩 & 입력창 */
.bottom-dock {
    background: #181a1f;
    border-top: 1px solid #272a31;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-chips-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.quick-chips-row::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    background: #232730;
    border: 1px solid #333845;
    color: #d1d5db;
    font-size: 0.75rem;
    padding: 5px 10px;
    border-radius: 14px;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}

.chip-btn:active {
    background: #f43f5e;
    color: #fff;
    border-color: #f43f5e;
}

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

#chatInput {
    flex: 1;
    background: #121316;
    border: 1px solid #333845;
    color: #f3f4f6;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    max-height: 90px;
    min-height: 42px;
    resize: none;
    outline: none;
}

#chatInput:focus {
    border-color: #f43f5e;
}

.send-btn {
    background: #f43f5e;
    color: #ffffff;
    border: none;
    width: 44px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
}

.send-btn:active {
    background: #e11d48;
    transform: scale(0.95);
}

.stop-btn {
    background: #272a31;
    border: 1px solid #3f4451;
    color: #fb7185;
    width: 38px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}

.stop-btn:active {
    background: #3f4451;
}

/* 6. 안드로이드 스타일 설정 바텀시트 모달 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.settings-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #181a1f;
    border-top: 1px solid #333845;
    border-radius: 20px 20px 0 0;
    padding: 16px 18px calc(20px + env(safe-area-inset-bottom, 0px)) 18px;
    z-index: 101;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.1, 0.9, 0.2, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-overlay.show .settings-sheet {
    transform: translateY(0);
}

.sheet-drag-handle {
    width: 40px;
    height: 4px;
    background: #4b5563;
    border-radius: 2px;
    margin: 0 auto 14px auto;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #272a31;
}

.sheet-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f3f4f6;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
}

.setting-section {
    background: #1e2128;
    border: 1px solid #2d3340;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.setting-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #a1a1aa;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.val-badge {
    background: #f43f5e;
    color: #fff;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
}

.val-badge.pitch {
    background: #8b5cf6;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.step-btn {
    background: #272a30;
    border: 1px solid #3f4451;
    color: #f3f4f6;
    font-weight: bold;
    font-size: 1.1rem;
    width: 44px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

input[type=range] {
    flex: 1;
    height: 8px;
    background: #2d3340;
    border-radius: 4px;
    border: none;
    accent-color: #f43f5e;
    cursor: pointer;
}

input[type=range].pitch-slider {
    accent-color: #8b5cf6;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.preset-btn {
    background: #272a30;
    border: 1px solid #3f4451;
    color: #d1d5db;
    padding: 8px 2px;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
}

.preset-btn.active {
    background: #f43f5e;
    color: #fff;
    border-color: #f43f5e;
    font-weight: 700;
}

.preset-btn.pitch-preset.active {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

select {
    width: 100%;
    background: #14161a;
    border: 1px solid #3b4252;
    color: #f3f4f6;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
}

.log-box {
    background: #0d0e11;
    border: 1px solid #232730;
    border-radius: 8px;
    padding: 10px;
    font-family: monospace;
    font-size: 0.72rem;
    color: #10b981;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 7. 생각 중 로딩 애니메이션 & 세션 리셋 제안 */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 2px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background-color: #f43f5e;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.3); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

.loading-text {
    font-size: 0.8rem;
    color: #fda4af;
    font-weight: 500;
}

.reset-suggest-box {
    background: #2a1520;
    border: 1px dashed #f43f5e;
    border-radius: 12px;
    padding: 10px 12px;
    margin-top: 6px;
    font-size: 0.82rem;
    color: #fda4af;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: fadeIn 0.3s ease-out;
}

.reset-btn-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.reset-action-btn {
    background: #f43f5e;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(244, 63, 94, 0.4);
}

.reset-action-btn:active {
    background: #e11d48;
    transform: scale(0.95);
}
