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

body {
    font-family: 'Zen Maru Gothic', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background:
        radial-gradient(ellipse at 70% 20%, rgba(200, 210, 255, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 30% 80%, rgba(180, 190, 255, 0.1) 0%, transparent 40%),
        linear-gradient(180deg, #0a1628 0%, #1a2744 30%, #2a3a5c 60%, #1e2d4a 100%);
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, white, transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 160px 120px, white, transparent),
        radial-gradient(2px 2px at 200px 50px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 250px 160px, white, transparent),
        radial-gradient(2px 2px at 300px 90px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 350px 200px, white, transparent),
        radial-gradient(2px 2px at 400px 130px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 450px 60px, white, transparent),
        radial-gradient(2px 2px at 500px 180px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 550px 100px, white, transparent),
        radial-gradient(2px 2px at 600px 220px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 650px 40px, white, transparent),
        radial-gradient(2px 2px at 700px 150px, rgba(255,255,255,0.5), transparent);
    background-repeat: repeat;
    background-size: 700px 250px;
    pointer-events: none;
    z-index: 0;
    animation: twinkle 4s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

header {
    background: linear-gradient(135deg, #2a3a6e 0%, #4a5a8e 50%, #6a7aae 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-bottom: 4px solid #1a2744;
    box-shadow: 0 4px 20px rgba(26, 39, 68, 0.4);
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.1) 40%, transparent 70%);
    border-radius: 50%;
}

header h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.header-avatar {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 350px;
    background: linear-gradient(180deg, #e8ecf8 0%, #d8dff0 100%);
    border-right: 1px solid #c0c8e0;
    padding: 20px;
    overflow-y: auto;
}

.settings-panel h2 {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 20px;
    color: #2a3a5c;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #3a4a6c;
    font-size: 14px;
}

.setting-item select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #a0a8c0;
    border-radius: 10px;
    font-size: 13px;
    font-family: 'Zen Maru Gothic', sans-serif;
    background: #fff;
    color: #2a3a5c;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233a4a6c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.setting-item select:focus {
    outline: none;
    border-color: #6a7aae;
}

.setting-item textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #a0a8c0;
    border-radius: 10px;
    font-size: 13px;
    font-family: 'Zen Maru Gothic', sans-serif;
    resize: vertical;
    line-height: 1.6;
    background: #fff;
    color: #2a3a5c;
}

.setting-item textarea:focus {
    outline: none;
    border-color: #6a7aae;
}

.setting-item input[type="range"] {
    width: 65%;
    margin-right: 10px;
    accent-color: #6a7aae;
}

.setting-item input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #a0a8c0;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Zen Maru Gothic', sans-serif;
    background: #fff;
    color: #2a3a5c;
}

.setting-item input[type="number"]:focus {
    outline: none;
    border-color: #6a7aae;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: #6a7aae;
}

.setting-item label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #3a4a6c;
}

#temperature-value {
    color: #2a3a5c;
    font-weight: 600;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-messages {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: #fafafa;
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-right: 15px;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #e8ecf8 0%, #d0d8f0 100%);
    overflow: hidden;
    border: 2px solid #6a7aae;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-right: 0;
    margin-left: 15px;
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 18px;
    line-height: 1.8;
    font-weight: 500;
    font-size: 15px;
}

.bot-message .message-content {
    background: white;
    border: 2px solid #6a7aae;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-controls {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.tts-play-button {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 12px;
    border: none;
    background: #6a7aae;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.tts-play-button:hover {
    background: #4a5a8e;
    transform: translateY(-1px);
}

.tts-play-button:active {
    transform: translateY(0);
}

.chat-input-container {
    padding: 20px 30px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.input-wrapper {
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #a0a8c0;
    border-radius: 25px;
    font-size: 15px;
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: 500;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: #fff;
}

#user-input:focus {
    border-color: #6a7aae;
    box-shadow: 0 0 0 3px rgba(106, 122, 174, 0.2);
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #4a5a8e 0%, #6a7aae 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 122, 174, 0.4);
    background: linear-gradient(135deg, #5a6a9e 0%, #7a8abe 100%);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: linear-gradient(135deg, #6a7aae 0%, #8a9abe 100%);
    color: white;
    width: 100%;
    margin-top: 10px;
    border: none;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6a9e 0%, #7a8abe 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 122, 174, 0.4);
}

.loading-indicator {
    text-align: center;
    padding: 10px;
    color: #666;
    font-style: italic;
}

/* スクロールバーのスタイル */
.chat-messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-track {
    background: #d8dff0;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #4a5a8e;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #6a7aae;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    .message-content {
        max-width: 85%;
    }
}

