:root {
    --primary-color: #007bff;
    --text-color: #202020;
    --bg-white: #ffffff;
    --bg-gray: #f8f9fa;
    --bubble-ai: #f0f0f0;
    --bubble-user: #007bff;
    --header-height: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Helvetica Neue", Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-white);
    height: 100dvh; /* Dynamic Viewport Height */
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid #eee;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.header__logo-img { height: 30px; }

/* Layout Container */
.container {
    display: flex;
    flex: 1;
    margin-top: var(--header-height);
    height: calc(100dvh - var(--header-height));
}

/* Navigation (Mobile default: bottom) */
.nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: var(--bg-white);
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-around;
    z-index: 100;
}

.nav__item {
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #888;
    cursor: pointer;
    flex: 1;
}

.nav__item--active { color: var(--primary-color); }
.nav__icon { font-size: 20px; }
.nav__label { font-size: 13px; }

/* Main Content Area */
.main {
    flex: 1;
    display: flex;
    justify-content: center;
    padding-bottom: 60px; /* Space for nav */
    width: 100%;
}

.chat-screen {
    width: 100%;
    max-width: 750px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-white);
}

/* Messages */
.chat-screen__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message { display: flex; max-width: 85%; }
.message--ai { align-self: flex-start; }
.message--user { align-self: flex-end; flex-direction: row-reverse; }

.message__icon img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}
.message--user .message__icon { display: none; }

.message__bubble {
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-all;
}
.message__bubble img{
    width: 100px;
}
.message--ai .message__bubble {
    background: var(--bubble-ai);
    border-top-left-radius: 2px;
}

.message--user .message__bubble {
    background: var(--bubble-user);
    color: white;
    border-top-right-radius: 2px;
}
.message__text {
    white-space: pre-wrap; /* これを入れないと画面上で改行が表示されません */
    word-break: break-all;
}
/* Input Area */
.input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    background: var(--bg-white);
}

.input-area__previews {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.input-area__upload {
    font-size: 1.5rem;
    color: #5c5c5c;
}
.input-area__icon{
    line-height: 44px;
}

.preview-item {
    position: relative;
    width: 60px;
    height: 60px;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.preview-item__delete {
    position: absolute;
    top: -5px;
    right: -5px;
    background: rgba(0,0,0,0.6);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    border: none;
    cursor: pointer;
}

.input-area__controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.input-area__textarea {
flex: 1;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 10px 15px;
    resize: none;
    
    /* 1行の高さを約24pxとした場合、5行で約120px + パディング */
    min-height: 44px;  
    max-height: 144px; /* 5行分に相当する高さ */
    
    outline: none;
    font-size: 16px;
    line-height: 1.5; /* 行間を適切に設定 */
    background: #fdfdfd;
    transition: border-color 0.2s;
    overflow-y: auto;
    display: block;
}

.input-area__textarea:focus {
    border-color: var(--primary-color);
    background: #fff;
}

.input-area__send-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: bold;
    cursor: pointer;
    font-size: 20px;
    padding: 10px;
}

.preview-item__delete {
    position: absolute;
    top: -8px;
    right: -8px;
    background: white; /* アイコンが見えやすいように背景を白に */
    color: #ff4d4f;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* PC Responsive Layout */
@media (min-width: 768px) {
    .nav {
        position: static;
        width: 200px;
        height: 100%;
        flex-direction: column;
        border-top: none;
        border-right: 1px solid #eee;
        justify-content: flex-start;
        padding-top: 20px;
    }
    .nav__icon {
        margin-bottom: 0;
        width: 30px; /* アイコンの幅を揃える */
        text-align: center;
    }
    .nav__item {
        flex: none;
        height: 50px;
        flex-direction: row;
        padding-left: 20px;
        gap: 10px;
    }
    .main { padding-bottom: 0; }
}

/* タイピングインジケーターのスタイル */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 50%;
    display: inline-block;
    animation: typing-animation 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-animation {
    0%, 80%, 100% { 
        transform: scale(0.6);
        opacity: 0.4;
    } 
    40% { 
        transform: scale(1.2);
        opacity: 1;
    }
}