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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    position: relative;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

.usage-link {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    transition: background 0.3s;
}

.usage-link:hover {
    background: rgba(255,255,255,0.3);
}

.chat-container {
    display: flex;
    flex-direction: column;
    min-height: 80vh;
    height: auto;
}

.character-setup {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    max-height: 40vh;
    overflow-y: auto;
}

.character-setup h3 {
    margin-bottom: 10px;
    color: #495057;
}

#character-setting {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 10px;
}

#character-setting:focus {
    outline: none;
    border-color: #667eea;
}

#save-character {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

#save-character:hover {
    background: #5a6fd8;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #ffffff;
    min-height: 200px;
    max-height: 50vh;
}

.message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
}

.message.user .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #f1f3f4;
    color: #333;
    border-bottom-left-radius: 4px;
}

.system-message {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    margin: 20px 0;
}

.chat-input-area {
    background: #f8f9fa;
    padding: 20px;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#user-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
}

#user-input:focus {
    outline: none;
    border-color: #667eea;
}

#send-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

#send-button:hover:not(:disabled) {
    background: #5a6fd8;
}

#send-button:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

#clear-chat {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

#clear-chat:hover {
    background: #c82333;
}


.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

.image-request-options {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #2196f3;
    margin: 10px 0;
}

.image-request-options p {
    margin-bottom: 15px;
    color: #1565c0;
    font-weight: 500;
}

.image-option-btn {
    background: #2196f3;
    color: white;
    border: none;
    padding: 10px 15px;
    margin: 5px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    display: inline-block;
}

.image-option-btn:hover {
    background: #1976d2;
}

.prompt-result {
    background: #f3e5f5;
    border: 2px solid #9c27b0;
    border-radius: 12px;
    padding: 20px;
    margin: 15px 0;
}

.prompt-result h4 {
    color: #7b1fa2;
    margin-bottom: 15px;
    font-size: 16px;
}

.prompt-section {
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(255,255,255,0.7);
    border-radius: 6px;
}

.prompt-section strong {
    color: #4a148c;
    display: inline-block;
    width: 100px;
    font-size: 14px;
}

.prompt-section code {
    background: #e1bee7;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #4a148c;
    word-break: break-all;
}

.analysis {
    background: rgba(156, 39, 176, 0.1);
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    font-style: italic;
    color: #7b1fa2;
}

.copy-prompt-btn {
    background: #9c27b0;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: background 0.3s;
}

.copy-prompt-btn:hover {
    background: #7b1fa2;
}

.image-placeholder {
    background: #f5f5f5;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.image-placeholder p {
    margin: 5px 0;
    font-style: italic;
}

.template-selector {
    margin-bottom: 10px;
}

.template-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.template-selector select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    background: white;
}

.template-selector select:focus {
    outline: none;
    border-color: #667eea;
}

.generation-status {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 10px;
    margin: 10px 0;
    color: #856404;
}

.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 10px;
    margin: 10px 0;
    color: #721c24;
}

.image-link {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
}

.image-link:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    .chat-container {
        height: 70vh;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .input-container {
        flex-direction: column;
    }
    
    #send-button {
        align-self: flex-end;
        padding: 10px 20px;
    }
    
    .image-option-btn {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
}

/* バージョン表示 */
.version-info {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 12px;
    opacity: 0.8;
    background: rgba(0,0,0,0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

/* LLM選択スタイル */
.llm-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.llm-selector label {
    font-size: 14px;
    font-weight: 500;
}

.llm-selector select {
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.llm-selector select:focus {
    outline: none;
    background: white;
    border-color: #fff;
}

.llm-status {
    font-size: 12px;
    background: rgba(255,255,255,0.2);
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

/* 画像生成オプション */
.generation-options {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    border: 1px solid #e9ecef;
}

.generation-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    font-weight: 500;
}

.generation-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.option-description {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 15px;
    margin-left: 26px;
    line-height: 1.4;
}

.keyword-filter-info {
    background: #e3f2fd;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
    margin-top: 15px;
}

.keyword-filter-info h4 {
    color: #1565c0;
    font-size: 14px;
    margin-bottom: 8px;
}

.filter-keywords {
    font-size: 12px;
    color: #424242;
    line-height: 1.5;
    word-break: break-all;
}