/* ベーススタイル */
body {
    font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
    background-color: #e9e9e9;
    color: #333;
    margin: 0;
    padding: 0;
    text-align: center;
}

/* メインコンテナ - チャットウィンドウ風 */
.chat-container {
    max-width: 720px;
    height: 100vh;
    margin: 0 auto;
    background-color: #ffffff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ヘッダー (Flexboxでタイトルとボタンを左右に配置) */
.header {
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    background-color: #f8f8f8;
    display: flex;
    justify-content: flex-start; /* 左端から要素を配置 */
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header h1 {
    font-size: 1.3em; 
    color: #1a73e8; 
    margin: 0;
    margin-right: auto; /* ★★★ これが最重要：右側の要素にスペースを全て譲る ★★★ */
    white-space: nowrap; 
    flex-shrink: 1; /* スペースが足りない時に縮小を許可 */
}

/* ユーザー名の表示 */
.user-status {
    margin-right: 5px; /* ボタンとの間のスペース */
    font-size: 0.9em; 
    white-space: nowrap;
    color: #444;
    font-weight: bold;
    flex-shrink: 0; /* スペースが足りなくても縮小しない */
}

/* メッセージリストエリア */
#chat-messages {
    flex-grow: 1; 
    padding: 10px 20px;
    overflow-y: auto; 
    display: flex;
    flex-direction: column;
}

/* メッセージアイテム (チャットバブル風) */
.message-item {
    margin: 8px 0;
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-item.other {
    background-color: #e0f7fa;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-item.self {
    background-color: #d1e7dd;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-meta {
    font-size: 0.75em;
    color: #777;
    margin-top: 5px;
}

.message-item.self .message-meta {
    text-align: right;
}
.message-item.other .message-meta {
    text-align: left;
}


/* 投稿フォームエリア */
.post-form {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    background-color: #f8f8f8;
    box-sizing: border-box;
}

.post-form form {
    display: flex;
    align-items: center;
    width: 100%;
}

.post-form textarea {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
    margin-right: 10px;
    resize: none;
    font-size: 1em;
    box-sizing: border-box;
    height: 40px;
}

.post-form button {
    background-color: #1a73e8;
    color: white;
    padding: 8px 15px;
    font-size: 0.9em;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.post-form button:hover {
    background-color: #1558b3;
}


/* 認証・ログイン画面 */
.register-container, .login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.register-container input, .login-container input {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}
.register-container button, .login-container button {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    border-radius: 4px;
    background-color: #1a73e8;
    color: white;
    font-size: 1.1em;
    border: none;
    cursor: pointer;
}

/* リンクと共通ボタン */
a {
    color: #1a73e8;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.button {
    background-color: #1a73e8;
    color: white;
    padding: 6px 10px;
    font-size: 0.8em;
    border-radius: 4px; 
    font-weight: bold;
    margin-left: 5px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.button:hover {
    background-color: #1558b3;
}

/* フォームの縦並び調整のためのCSS */
.register-container p, .login-container p {
    margin: 0;
    padding: 0;
    text-align: left;
}