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

body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
min-height: 100vh;
color: #e4e4e7;
}

.container {
max-width: 900px;
margin: 0 auto;
padding: 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
}

header {
text-align: center;
margin-bottom: 24px;
}

header h1 {
font-size: 2.5rem;
background: linear-gradient(90deg, #60a5fa, #a78bfa, #f472b6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 8px;
}

.subtitle {
color: #a1a1aa;
font-size: 1.1rem;
}

.attribution {
display: inline-block;
margin-top: 12px;
padding: 6px 16px;
background: rgba(96, 165, 250, 0.2);
border: 1px solid rgba(96, 165, 250, 0.3);
border-radius: 20px;
color: #60a5fa;
text-decoration: none;
font-size: 0.9rem;
transition: all 0.3s ease;
}

.attribution:hover {
background: rgba(96, 165, 250, 0.3);
transform: translateY(-2px);
}

.model-selector {
display: flex;
gap: 12px;
align-items: center;
justify-content: center;
flex-wrap: wrap;
margin-bottom: 24px;
padding: 20px;
background: rgba(255, 255, 255, 0.05);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.1);
}

.model-selector label {
font-weight: 600;
color: #d4d4d8;
}

.model-selector select {
padding: 12px 16px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.1);
color: #e4e4e7;
font-size: 1rem;
min-width: 280px;
cursor: pointer;
}

.model-selector select:focus {
outline: none;
border-color: #60a5fa;
}

.model-selector select option {
background: #1a1a2e;
color: #e4e4e7;
}

.btn {
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
}

.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}

.btn-primary {
background: linear-gradient(135deg, #3b82f6, #8b5cf6);
color: white;
}

.btn-primary:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
background: rgba(255, 255, 255, 0.1);
color: #e4e4e7;
border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.2);
}

.btn-icon {
padding: 12px;
font-size: 1.2rem;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 8px;
}

.btn-icon:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.2);
}

.loading-container {
text-align: center;
padding: 40px;
background: rgba(255, 255, 255, 0.05);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-spinner {
width: 60px;
height: 60px;
border: 4px solid rgba(255, 255, 255, 0.1);
border-top-color: #60a5fa;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 20px;
}

@keyframes spin {
to { transform: rotate(360deg); }
}

.progress-bar-container {
width: 100%;
max-width: 400px;
height: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
margin: 16px auto;
overflow: hidden;
}

.progress-bar {
height: 100%;
background: linear-gradient(90deg, #3b82f6, #8b5cf6);
border-radius: 4px;
width: 0%;
transition: width 0.3s ease;
}

#progress-text {
color: #a1a1aa;
font-size: 0.9rem;
}

.chat-container {
flex: 1;
display: flex;
flex-direction: column;
background: rgba(255, 255, 255, 0.05);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.1);
overflow: hidden;
}

.chat-messages {
flex: 1;
overflow-y: auto;
padding: 20px;
min-height: 300px;
max-height: 500px;
}

.welcome-message {
text-align: center;
padding: 40px;
color: #a1a1aa;
}

.welcome-message .hint {
font-size: 0.9rem;
margin-top: 8px;
opacity: 0.7;
}

.message {
margin-bottom: 16px;
display: flex;
flex-direction: column;
}

.message.user {
align-items: flex-end;
}

.message.assistant {
align-items: flex-start;
}

.message-content {
max-width: 80%;
padding: 12px 16px;
border-radius: 16px;
line-height: 1.5;
}

.message.user .message-content {
background: linear-gradient(135deg, #3b82f6, #8b5cf6);
color: white;
border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
background: rgba(255, 255, 255, 0.1);
color: #e4e4e7;
border-bottom-left-radius: 4px;
}

.message-image {
max-width: 200px;
max-height: 200px;
border-radius: 12px;
margin-bottom: 8px;
}

.message-label {
font-size: 0.75rem;
color: #71717a;
margin-bottom: 4px;
padding: 0 8px;
}

.typing-indicator {
display: flex;
gap: 4px;
padding: 8px;
}

.typing-indicator span {
width: 8px;
height: 8px;
background: #60a5fa;
border-radius: 50%;
animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
0%, 80%, 100% { transform: scale(0); }
40% { transform: scale(1); }
}

.image-preview-container {
position: relative;
padding: 12px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.image-preview-container img {
max-width: 150px;
max-height: 150px;
border-radius: 8px;
}

.remove-image-btn {
position: absolute;
top: 8px;
left: 130px;
width: 24px;
height: 24px;
border-radius: 50%;
border: none;
background: #ef4444;
color: white;
font-size: 16px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}

.input-container {
padding: 16px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.input-row {
display: flex;
gap: 8px;
margin-bottom: 8px;
}

.input-row:last-child {
margin-bottom: 0;
}

.image-url-input {
flex: 1;
padding: 10px 14px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.1);
color: #e4e4e7;
font-size: 0.9rem;
}

.image-url-input:focus {
outline: none;
border-color: #60a5fa;
}

#user-input {
flex: 1;
padding: 12px 16px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.1);
color: #e4e4e7;
font-size: 1rem;
resize: none;
font-family: inherit;
}

#user-input:focus {
outline: none;
border-color: #60a5fa;
}

.settings-panel {
padding: 12px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-panel summary {
cursor: pointer;
color: #a1a1aa;
font-size: 0.9rem;
}

.settings-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 16px;
margin-top: 16px;
}

.setting-item label {
display: block;
margin-bottom: 8px;
color: #d4d4d8;
font-size: 0.9rem;
}

.setting-item input[type="range"] {
width: 100%;
accent-color: #60a5fa;
}

.error-container {
padding: 16px 20px;
background: rgba(239, 68, 68, 0.2);
border: 1px solid rgba(239, 68, 68, 0.3);
border-radius: 12px;
margin-top: 16px;
display: flex;
justify-content: space-between;
align-items: center;
}

#error-message {
color: #fca5a5;
}

footer {
text-align: center;
margin-top: 24px;
padding: 16px;
color: #71717a;
font-size: 0.9rem;
}

footer a {
color: #60a5fa;
text-decoration: none;
}

footer a:hover {
text-decoration: underline;
}

.hidden {
display: none !important;
}

@media (max-width: 600px) {
header h1 {
font-size: 1.8rem;
}

.model-selector {
flex-direction: column;
}

.model-selector select {
width: 100%;
min-width: unset;
}

.message-content {
max-width: 90%;
}
}