* {
    box-sizing: border-box;
}

body {
    margin: 0; padding: 20px; font-family: sans-serif; height: 100vh;
    background-color: #f0f2f5;
}

/* --- 上部ヘッダーバー --- */
.header-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    z-index: 1000;
}

.header-bar h2 {
    margin: 0; font-size: 1.2em; color: #333;
}

.user-counter {
    background: #007bff;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

/* --- メッセージ表示エリア --- */
#messages {
    list-style-type: none; 
    padding: 0; 
    margin-top: 60px; 
    height: calc(100vh - 210px); 
    overflow-y: auto;
}

#messages li {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    max-width: 80%;
    width: fit-content;
}

.message-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 0.85em;
    color: #555;
    font-weight: bold;
    word-break: break-all;
    max-width: 100px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 15px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-text {
    word-break: break-all;
    white-space: pre-wrap;
}

.my-message {
    margin-left: auto;
    align-items: flex-end;
}

.my-message .message-main {
    flex-direction: row-reverse;
}

.my-message .message-bubble {
    background-color: #007bff;
    color: #fff;
}

.other-message {
    margin-right: auto;
    align-items: flex-start;
}

.other-message .message-main {
    flex-direction: row;
}

.other-message .message-bubble {
    background-color: #fff;
    color: #333;
}

/* Systemメッセージ中央表示 */
.system-message {
    margin: 5px auto !important;
    background: #e0e0e0;
    color: #666;
    font-size: 0.85em;
    padding: 4px 12px;
    border-radius: 10px;
    text-align: center;
    max-width: 90% !important;
}

/* 3点リーダー */
.three-dots {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    color: #aaa;
    padding: 0 5px; 
    height: auto; 
    margin: 0;
}

.three-dots:hover {
    color: #333;
}

.reaction-area {
    margin-top: 4px; 
    display: flex; 
    gap: 8px; 
    font-size: 0.85em;
}

.other-message .reaction-area {
    margin-left: 65px;
}

.my-message .reaction-area {
    margin-right: 25px;
}

.like-count, .dislike-count {
    background: #fff; 
    padding: 2px 6px; 
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1); 
    color: #333;
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0,0,0,0.5); 
    z-index: 2000;
    display: flex; 
    align-items: center; 
    justify-content: center;
}

.modal-content {
    background: #fff; 
    padding: 25px; 
    border-radius: 10px; 
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    width: 340px;
}

.modal-content h3 {
    margin-top: 0; 
    font-size: 1.1em; 
    color: #333;
}

.modal-content input {
    width: 100%; 
    padding: 10px; 
    margin-bottom: 15px; 
    border: 1px solid #ddd; 
    border-radius: 5px; 
    outline: none;
}

.modal-content button {
    width: 100%; 
    height: 40px; 
    background-color: #007bff; 
    color: white; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    font-weight: bold;
}

#systemPasswordInput::placeholder {
    transition: color 0.3s ease;
}

#systemPasswordInput:focus {
    border-color: #007bff !important;
}

/* 3点リーダーメニュー */

.menu-popup {
    position: absolute; 
    background: #fff; 
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15); 
    z-index: 1500;
    display: flex; 
    flex-direction: column; 
    overflow: hidden;
}

.menu-item {
    background: none; 
    border: none; 
    padding: 10px 15px; 
    text-align: left;
    width: 160px; 
    cursor: pointer; 
    font-size: 0.9em;
    color: #333; 
    height: auto; 
    border-radius: 0;
}

.menu-item:hover {
    background: #f5f5f5;
}

/* 下部入力エリア */
.input-area {
    position: fixed;
    bottom: 20px; 
    left: 20px; 
    background: #fff;
    padding: 5px 15px; 
    border-radius: 10px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000; 
    display: flex; 
    gap: 10px;
    width: 400px; 
    min-height: 45px;
    align-items: center; 
    transition: width 0.4s ease, min-height 0.4s ease;
}

.input-area.is-expanded {
    width: calc(100% - 40px); 
    align-items: flex-end;
}

textarea {
    flex-grow: 1; 
    height: 35px; 
    min-height: 35px; 
    max-height: 200px; 
    border: none; 
    outline: none;
    resize: none; 
    background: transparent; 
    padding: 8px 0; 
    line-height: 1.5; 
    overflow: hidden;
}

#sendButton {
    height: 35px; 
    padding: 0 20px;
    border: none;
    background-color: #007bff;
    color: white; 
    border-radius: 5px; 
    cursor: pointer; 
    flex-shrink: 0;
}

.input-area.is-expanded #sendButton {
    align-self: flex-end; 
    margin-bottom: 5px;
}

.message-bubble a {
    color: inherit; /* 文字色を吹き出しに合わせる（自分なら白、他人なら黒） */
    text-decoration: underline; /* リンクと分かるように下線をつける */
    font-weight: bold;
}

.my-message .message-bubble a {
    color: #fff; /* 自分の青い吹き出しの中では白いリンクにする */
}



.chat-preview-img {
    border: 1px solid rgba(0, 0, 0, 0.1);
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.chat-preview-img:hover {
    transform: scale(1.02); /* ホバーしたときに少し浮き上がる演出 */
}

/* 自分の青い吹き出しの中の画像は、枠線を少し白っぽく */
.my-message .chat-preview-img {
    border-color: rgba(255, 255, 255, 0.3);
}

/* 削除済みファイル用のスタイル */
.expired-image {
    filter: grayscale(100%);
    opacity: 0.5;
}

.file-expired {
    color: #999;
    text-decoration: line-through;
    pointer-events: none; /* クリック無効化 */
}

@media screen and (max-width: 450px) {
  .input-area {
    width: calc(100% - 40px) !important; /* 画面幅から左右の余白分を引く */
    left: 20px; /* 左右の余白を維持 */
  }
}