body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.container, .login-container {
    width: 100%;
    max-width: 900px;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

.container { height: 95vh; display: flex; flex-direction: column; padding: 0 20px; box-sizing: border-box; }
.login-container { padding: 40px; text-align: center; background-color: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1); }
.login-button { display: inline-block; margin-top: 20px; padding: 14px 32px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-decoration: none; border-radius: 8px; font-weight: 600; transition: transform 0.2s, box-shadow 0.2s; }
.login-button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4); }

header { background: transparent; color: #2d3748; padding: 20px 0; border-radius: 12px 12px 0 0; }
header h1 { margin: 0; font-size: 1.8em; text-align: center; font-weight: 700; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.user-info { display: flex; justify-content: space-between; align-items: center; font-size: 0.9em; margin-bottom: 15px; padding: 0; }
.logout-button { color: #667eea; text-decoration: none; padding: 6px 16px; border: 2px solid #667eea; border-radius: 8px; transition: all 0.2s; font-weight: 600; }
.logout-button:hover { background-color: #667eea; color: white; }

.chat-box { 
    flex-grow: 1; 
    padding: 30px 0; 
    overflow-y: auto; 
    overflow-x: hidden;
    display: flex; 
    flex-direction: column; 
    gap: 20px;
    /* スクロールバーを非表示にする（WebKit系） */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.chat-box::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}
.message { display: flex; flex-direction: column; max-width: 80%; width: fit-content; }
.message-content { margin: 0; padding: 14px 18px; border-radius: 0; line-height: 1.6; word-wrap: break-word; overflow-wrap: break-word; font-size: 0.95em; box-sizing: border-box; }
.message.user { align-self: flex-end; }
.message.user .message-content { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 16px; border-bottom-right-radius: 4px; box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3); }
.message.bot { align-self: flex-start; max-width: 100%; width: 100%; }
.message.bot .message-content { background-color: transparent; color: #2d3748; padding: 0; box-shadow: none; max-width: 100%; overflow-x: hidden; }

/* Markdown styles inside message */
.message-content h1, .message-content h2, .message-content h3 { margin: 10px 0 5px 0; font-size: 1.1em; font-weight: bold; word-wrap: break-word; }
.message-content ul, .message-content ol { margin: 5px 0; padding-left: 20px; word-wrap: break-word; }
.message-content img { max-width: 100%; height: auto; border-radius: 4px; margin-top: 5px; }
.message-content pre, .message-content code { max-width: 100%; overflow-x: auto; word-wrap: break-word; white-space: pre-wrap; }

/* Bouncing three-dot loader used for streaming placeholder */
.loading-dots { display: inline-block; vertical-align: middle; margin-left: 8px; }
.loading-dots span { display: inline-block; width: 8px; height: 8px; margin: 0 3px; background: #667eea; border-radius: 50%; opacity: 0.6; animation: bounce 1s infinite ease-in-out; }
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.6 } 40% { transform: translateY(-6px); opacity: 1 } }

.message.loading { opacity: 1; }
#chat-form { display: flex; align-items: center; padding: 20px 0 30px 0; border-top: none; background-color: transparent; gap: 12px; box-sizing: border-box; }
#query-input { flex-grow: 1; padding: 14px 18px; border: 2px solid rgba(102, 126, 234, 0.3); border-radius: 24px; resize: none; font-size: 0.95em; margin-right: 0; background-color: white; transition: border-color 0.2s, box-shadow 0.2s; font-family: inherit; box-sizing: border-box; max-width: 100%; }
#query-input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); }
#submit-button { width: 48px; height: 48px; padding: 0; border: none; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 50%; cursor: pointer; font-size: 1em; display: flex; align-items: center; justify-content: center; transition: transform 0.2s, box-shadow 0.2s; }
#submit-button:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); }
#submit-button:disabled { background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%); cursor: not-allowed; opacity: 0.6; }
#submit-button svg { flex-shrink: 0; }

.loader { border: 4px solid #f3f320; padding: 16px; background-color: rgba(255, 255, 255, 0.7); border-radius: 12px; border: 1px solid rgba(102, 126, 234, 0.2); backdrop-filter: blur(10px); }
.sources-container h4 { margin: 0 0 10px 0; font-size: 0.9em; color: #667eea; font-weight: 600; }
.sources-container ul { margin: 0; padding-left: 20px; }
.sources-container li { font-size: 0.85em; margin-bottom: 6px; }
.sources-container a { color: #667eea; text-decoration: none; transition: color 0.2s; }
.sources-container a:hover { color: #764ba2; text-decoration: underline; }

/* デバッグ情報用のスタイル */
.debug-container {
    align-self: stretch;
    width: auto;
    margin-top: 15px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    font-size: 0.85em;
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
}
.debug-container details {
    padding: 14px;
}
.debug-container summary {
    cursor: pointer;
    font-weight: 600;
    color: #667eea;
}
.debug-container h5 {
    margin: 10px 0 5px 0;
    color: #2d3748;
}
.debug-container ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}
.debug-container li {
    margin-bottom: 5px;
    color: #4a5568
}
.debug-container li {
    margin-bottom: 5px;
    color: #555;
}
