* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f7f7f8;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
}

/* 모바일 환경에서 뷰포트 높이 조정 */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
    }
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 모바일 스타일 */
@media (max-width: 768px) {
    body {
        padding: 0;
        align-items: stretch;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    .chat-container {
        height: 100vh;
        height: 100dvh;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 모바일에서 메시지 영역 패딩 조정 */
@media (max-width: 768px) {
    .messages {
        padding: 16px;
        padding-bottom: 16px;
    }
}

/* .title {
    font-size: 36px;
    font-weight: 600;
    color: #1f2937;
    text-align: left;
    padding: 16px 0 8px 0;
    background: transparent;
    width: 100%;
    max-width: 800px;
} */

.title {
    text-align: left;
    padding: 16px 0 18px 0;
    background: transparent;
    width: 100%;
    max-width: 800px;
}

.title img {
    max-width: 100%;
    height: auto;
    max-height: 60px;
    object-fit: contain;
}

/* 모바일에서 타이틀 숨김 */
@media (max-width: 768px) {
    .title {
        display: none;
    }
}

.message {
    max-width: 80%;
    word-wrap: break-word;
}

/* 모바일에서 메시지 말풍선 조정 */
@media (max-width: 768px) {
    .message {
        max-width: 85%;
    }
    
    .message-content {
        -webkit-user-select: text;
        user-select: text;
    }
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 15px;
}

.message.user .message-content {
    background-color: #007aff;
    color: white;
}

.message.assistant .message-content {
    background-color: #f1f3f4;
    color: #1f2937;
}

/* 마크다운 스타일 */
.message-content h1, .message-content h2, .message-content h3 {
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.message-content h1 {
    font-size: 18px;
    color: #1f2937;
}

.message-content h2 {
    font-size: 16px;
    color: #374151;
}

.message-content h3 {
    font-size: 14px;
    color: #4b5563;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

/* 로딩 애니메이션 */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
}

.loading-dots {
    display: inline-flex;
    gap: 2px;
}

.loading-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: loadingDots 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0s;
}

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

.input-container {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    position: relative;
    z-index: 10;
}

/* 모바일에서 입력창 스타일 */
@media (max-width: 768px) {
    .input-container {
        padding: 16px 16px;
        padding-bottom: max(env(safe-area-inset-bottom), 16px);
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
    }
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

#messageInput {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 22px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

/* 모바일에서 입력창 조정 */
@media (max-width: 768px) {
    #messageInput {
        font-size: 16px;
        min-height: 48px;
        max-height: 100px;
        padding: 14px 16px;
        -webkit-user-select: text;
        user-select: text;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .input-wrapper {
        align-items: flex-end;
        gap: 12px;
    }
}

#messageInput:focus {
    border-color: #007aff;
}

#messageInput::placeholder {
    color: #9ca3af;
}

#sendButton {
    width: 44px;
    height: 44px;
    background: #007aff;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

/* 모바일에서 전송 버튼 조정 */
@media (max-width: 768px) {
    #sendButton {
        width: 48px;
        height: 48px;
        touch-action: manipulation;
    }
}

#sendButton:hover {
    background: #0056cc;
}

#sendButton:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* 스크롤바 스타일 */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

#messageInput {
    overflow-y: auto;
}

#messageInput::-webkit-scrollbar {
    display: none;
}

#messageInput {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
  